2 Provides string functions, linked list functions, math functions, synchronization
3 functions, file path functions, and CPU architecture-specific functions.
5 Copyright (c) 2006 - 2017, 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
,
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
,
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
1539 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1542 [ATTENTION] This function is deprecated for security reason.
1544 Convert a Null-terminated Unicode string to a Null-terminated
1545 ASCII string and returns the ASCII string.
1547 This function converts the content of the Unicode string Source
1548 to the ASCII string Destination by copying the lower 8 bits of
1549 each Unicode character. It returns Destination.
1551 The caller is responsible to make sure Destination points to a buffer with size
1552 equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.
1554 If any Unicode characters in Source contain non-zero value in
1555 the upper 8 bits, then ASSERT().
1557 If Destination is NULL, then ASSERT().
1558 If Source is NULL, then ASSERT().
1559 If Source is not aligned on a 16-bit boundary, then ASSERT().
1560 If Source and Destination overlap, then ASSERT().
1562 If PcdMaximumUnicodeStringLength is not zero, and Source contains
1563 more than PcdMaximumUnicodeStringLength Unicode characters not including
1564 the Null-terminator, then ASSERT().
1566 If PcdMaximumAsciiStringLength is not zero, and Source contains more
1567 than PcdMaximumAsciiStringLength Unicode characters not including the
1568 Null-terminator, then ASSERT().
1570 @param Source The pointer to a Null-terminated Unicode string.
1571 @param Destination The pointer to a Null-terminated ASCII string.
1573 @return Destination.
1578 UnicodeStrToAsciiStr (
1579 IN CONST CHAR16
*Source
,
1580 OUT CHAR8
*Destination
1586 Convert a Null-terminated Unicode string to a Null-terminated
1589 This function is similar to AsciiStrCpyS.
1591 This function converts the content of the Unicode string Source
1592 to the ASCII string Destination by copying the lower 8 bits of
1593 each Unicode character. The function terminates the ASCII string
1594 Destination by appending a Null-terminator character at the end.
1596 The caller is responsible to make sure Destination points to a buffer with size
1597 equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.
1599 If any Unicode characters in Source contain non-zero value in
1600 the upper 8 bits, then ASSERT().
1602 If Source is not aligned on a 16-bit boundary, then ASSERT().
1603 If an error would be returned, then the function will also ASSERT().
1605 If an error is returned, then the Destination is unmodified.
1607 @param Source The pointer to a Null-terminated Unicode string.
1608 @param Destination The pointer to a Null-terminated ASCII string.
1609 @param DestMax The maximum number of Destination Ascii
1610 char, including terminating null char.
1612 @retval RETURN_SUCCESS String is converted.
1613 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
1614 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
1616 If PcdMaximumAsciiStringLength is not zero,
1617 and DestMax is greater than
1618 PcdMaximumAsciiStringLength.
1619 If PcdMaximumUnicodeStringLength is not zero,
1620 and DestMax is greater than
1621 PcdMaximumUnicodeStringLength.
1623 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
1628 UnicodeStrToAsciiStrS (
1629 IN CONST CHAR16
*Source
,
1630 OUT CHAR8
*Destination
,
1634 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1637 [ATTENTION] This function is deprecated for security reason.
1639 Copies one Null-terminated ASCII string to another Null-terminated ASCII
1640 string and returns the new ASCII string.
1642 This function copies the contents of the ASCII string Source to the ASCII
1643 string Destination, and returns Destination. If Source and Destination
1644 overlap, then the results are undefined.
1646 If Destination is NULL, then ASSERT().
1647 If Source is NULL, then ASSERT().
1648 If Source and Destination overlap, then ASSERT().
1649 If PcdMaximumAsciiStringLength is not zero and Source contains more than
1650 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1653 @param Destination The pointer to a Null-terminated ASCII string.
1654 @param Source The pointer to a Null-terminated ASCII string.
1662 OUT CHAR8
*Destination
,
1663 IN CONST CHAR8
*Source
1668 [ATTENTION] This function is deprecated for security reason.
1670 Copies up to a specified length one Null-terminated ASCII string to another
1671 Null-terminated ASCII string and returns the new ASCII string.
1673 This function copies the contents of the ASCII string Source to the ASCII
1674 string Destination, and returns Destination. At most, Length ASCII characters
1675 are copied from Source to Destination. If Length is 0, then Destination is
1676 returned unmodified. If Length is greater that the number of ASCII characters
1677 in Source, then Destination is padded with Null ASCII characters. If Source
1678 and Destination overlap, then the results are undefined.
1680 If Destination is NULL, then ASSERT().
1681 If Source is NULL, then ASSERT().
1682 If Source and Destination overlap, then ASSERT().
1683 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
1684 PcdMaximumAsciiStringLength, then ASSERT().
1685 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1686 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1689 @param Destination The pointer to a Null-terminated ASCII string.
1690 @param Source The pointer to a Null-terminated ASCII string.
1691 @param Length The maximum number of ASCII characters to copy.
1699 OUT CHAR8
*Destination
,
1700 IN CONST CHAR8
*Source
,
1706 Returns the length of a Null-terminated ASCII string.
1708 This function returns the number of ASCII characters in the Null-terminated
1709 ASCII string specified by String.
1711 If Length > 0 and Destination is NULL, then ASSERT().
1712 If Length > 0 and Source is NULL, then ASSERT().
1713 If PcdMaximumAsciiStringLength is not zero and String contains more than
1714 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1717 @param String The pointer to a Null-terminated ASCII string.
1719 @return The length of String.
1725 IN CONST CHAR8
*String
1730 Returns the size of a Null-terminated ASCII string in bytes, including the
1733 This function returns the size, in bytes, of the Null-terminated ASCII string
1734 specified by String.
1736 If String is NULL, then ASSERT().
1737 If PcdMaximumAsciiStringLength is not zero and String contains more than
1738 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1741 @param String The pointer to a Null-terminated ASCII string.
1743 @return The size of String.
1749 IN CONST CHAR8
*String
1754 Compares two Null-terminated ASCII strings, and returns the difference
1755 between the first mismatched ASCII characters.
1757 This function compares the Null-terminated ASCII string FirstString to the
1758 Null-terminated ASCII string SecondString. If FirstString is identical to
1759 SecondString, then 0 is returned. Otherwise, the value returned is the first
1760 mismatched ASCII character in SecondString subtracted from the first
1761 mismatched ASCII character in FirstString.
1763 If FirstString is NULL, then ASSERT().
1764 If SecondString is NULL, then ASSERT().
1765 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
1766 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1768 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
1769 than PcdMaximumAsciiStringLength ASCII characters not including the
1770 Null-terminator, then ASSERT().
1772 @param FirstString The pointer to a Null-terminated ASCII string.
1773 @param SecondString The pointer to a Null-terminated ASCII string.
1775 @retval ==0 FirstString is identical to SecondString.
1776 @retval !=0 FirstString is not identical to SecondString.
1782 IN CONST CHAR8
*FirstString
,
1783 IN CONST CHAR8
*SecondString
1788 Performs a case insensitive comparison of two Null-terminated ASCII strings,
1789 and returns the difference between the first mismatched ASCII characters.
1791 This function performs a case insensitive comparison of the Null-terminated
1792 ASCII string FirstString to the Null-terminated ASCII string SecondString. If
1793 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
1794 value returned is the first mismatched lower case ASCII character in
1795 SecondString subtracted from the first mismatched lower case ASCII character
1798 If FirstString is NULL, then ASSERT().
1799 If SecondString is NULL, then ASSERT().
1800 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
1801 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1803 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
1804 than PcdMaximumAsciiStringLength ASCII characters not including the
1805 Null-terminator, then ASSERT().
1807 @param FirstString The pointer to a Null-terminated ASCII string.
1808 @param SecondString The pointer to a Null-terminated ASCII string.
1810 @retval ==0 FirstString is identical to SecondString using case insensitive
1812 @retval !=0 FirstString is not identical to SecondString using case
1813 insensitive comparisons.
1819 IN CONST CHAR8
*FirstString
,
1820 IN CONST CHAR8
*SecondString
1825 Compares two Null-terminated ASCII strings with maximum lengths, and returns
1826 the difference between the first mismatched ASCII characters.
1828 This function compares the Null-terminated ASCII string FirstString to the
1829 Null-terminated ASCII string SecondString. At most, Length ASCII characters
1830 will be compared. If Length is 0, then 0 is returned. If FirstString is
1831 identical to SecondString, then 0 is returned. Otherwise, the value returned
1832 is the first mismatched ASCII character in SecondString subtracted from the
1833 first mismatched ASCII character in FirstString.
1835 If Length > 0 and FirstString is NULL, then ASSERT().
1836 If Length > 0 and SecondString is NULL, then ASSERT().
1837 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
1838 PcdMaximumAsciiStringLength, then ASSERT().
1839 If PcdMaximumAsciiStringLength is not zero, and FirstString contains more than
1840 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1842 If PcdMaximumAsciiStringLength is not zero, and SecondString contains more than
1843 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1846 @param FirstString The pointer to a Null-terminated ASCII string.
1847 @param SecondString The pointer to a Null-terminated ASCII string.
1848 @param Length The maximum number of ASCII characters for compare.
1850 @retval ==0 FirstString is identical to SecondString.
1851 @retval !=0 FirstString is not identical to SecondString.
1857 IN CONST CHAR8
*FirstString
,
1858 IN CONST CHAR8
*SecondString
,
1863 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1866 [ATTENTION] This function is deprecated for security reason.
1868 Concatenates one Null-terminated ASCII string to another Null-terminated
1869 ASCII string, and returns the concatenated ASCII string.
1871 This function concatenates two Null-terminated ASCII strings. The contents of
1872 Null-terminated ASCII string Source are concatenated to the end of Null-
1873 terminated ASCII string Destination. The Null-terminated concatenated ASCII
1876 If Destination is NULL, then ASSERT().
1877 If Source is NULL, then ASSERT().
1878 If PcdMaximumAsciiStringLength is not zero and Destination contains more than
1879 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1881 If PcdMaximumAsciiStringLength is not zero and Source contains more than
1882 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1884 If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
1885 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
1886 ASCII characters, then ASSERT().
1888 @param Destination The pointer to a Null-terminated ASCII string.
1889 @param Source The pointer to a Null-terminated ASCII string.
1897 IN OUT CHAR8
*Destination
,
1898 IN CONST CHAR8
*Source
1903 [ATTENTION] This function is deprecated for security reason.
1905 Concatenates up to a specified length one Null-terminated ASCII string to
1906 the end of another Null-terminated ASCII string, and returns the
1907 concatenated ASCII string.
1909 This function concatenates two Null-terminated ASCII strings. The contents
1910 of Null-terminated ASCII string Source are concatenated to the end of Null-
1911 terminated ASCII string Destination, and Destination is returned. At most,
1912 Length ASCII characters are concatenated from Source to the end of
1913 Destination, and Destination is always Null-terminated. If Length is 0, then
1914 Destination is returned unmodified. If Source and Destination overlap, then
1915 the results are undefined.
1917 If Length > 0 and Destination is NULL, then ASSERT().
1918 If Length > 0 and Source is NULL, then ASSERT().
1919 If Source and Destination overlap, then ASSERT().
1920 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
1921 PcdMaximumAsciiStringLength, then ASSERT().
1922 If PcdMaximumAsciiStringLength is not zero, and Destination contains more than
1923 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1925 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1926 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1928 If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
1929 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
1930 ASCII characters, not including the Null-terminator, then ASSERT().
1932 @param Destination The pointer to a Null-terminated ASCII string.
1933 @param Source The pointer to a Null-terminated ASCII string.
1934 @param Length The maximum number of ASCII characters to concatenate from
1943 IN OUT CHAR8
*Destination
,
1944 IN CONST CHAR8
*Source
,
1950 Returns the first occurrence of a Null-terminated ASCII sub-string
1951 in a Null-terminated ASCII string.
1953 This function scans the contents of the ASCII string specified by String
1954 and returns the first occurrence of SearchString. If SearchString is not
1955 found in String, then NULL is returned. If the length of SearchString is zero,
1956 then String is returned.
1958 If String is NULL, then ASSERT().
1959 If SearchString is NULL, then ASSERT().
1961 If PcdMaximumAsciiStringLength is not zero, and SearchString or
1962 String contains more than PcdMaximumAsciiStringLength Unicode characters
1963 not including the Null-terminator, then ASSERT().
1965 @param String The pointer to a Null-terminated ASCII string.
1966 @param SearchString The pointer to a Null-terminated ASCII string to search for.
1968 @retval NULL If the SearchString does not appear in String.
1969 @retval others If there is a match return the first occurrence of SearchingString.
1970 If the length of SearchString is zero,return String.
1976 IN CONST CHAR8
*String
,
1977 IN CONST CHAR8
*SearchString
1982 Convert a Null-terminated ASCII decimal string to a value of type
1985 This function returns a value of type UINTN by interpreting the contents
1986 of the ASCII string String as a decimal number. The format of the input
1987 ASCII string String is:
1989 [spaces] [decimal digits].
1991 The valid decimal digit character is in the range [0-9]. The function will
1992 ignore the pad space, which includes spaces or tab characters, before the digits.
1993 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1994 function stops at the first character that is a not a valid decimal character or
1995 Null-terminator, whichever on comes first.
1997 If String has only pad spaces, then 0 is returned.
1998 If String has no pad spaces or valid decimal digits, then 0 is returned.
1999 If the number represented by String overflows according to the range defined by
2000 UINTN, then MAX_UINTN is returned.
2001 If String is NULL, then ASSERT().
2002 If PcdMaximumAsciiStringLength is not zero, and String contains more than
2003 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
2006 @param String The pointer to a Null-terminated ASCII string.
2008 @retval The value translated from String.
2013 AsciiStrDecimalToUintn (
2014 IN CONST CHAR8
*String
2019 Convert a Null-terminated ASCII decimal string to a value of type
2022 This function returns a value of type UINT64 by interpreting the contents
2023 of the ASCII string String as a decimal number. The format of the input
2024 ASCII string String is:
2026 [spaces] [decimal digits].
2028 The valid decimal digit character is in the range [0-9]. The function will
2029 ignore the pad space, which includes spaces or tab characters, before the digits.
2030 The running zero in the beginning of [decimal digits] will be ignored. Then, the
2031 function stops at the first character that is a not a valid decimal character or
2032 Null-terminator, whichever on comes first.
2034 If String has only pad spaces, then 0 is returned.
2035 If String has no pad spaces or valid decimal digits, then 0 is returned.
2036 If the number represented by String overflows according to the range defined by
2037 UINT64, then MAX_UINT64 is returned.
2038 If String is NULL, then ASSERT().
2039 If PcdMaximumAsciiStringLength is not zero, and String contains more than
2040 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
2043 @param String The pointer to a Null-terminated ASCII string.
2045 @retval Value translated from String.
2050 AsciiStrDecimalToUint64 (
2051 IN CONST CHAR8
*String
2056 Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.
2058 This function returns a value of type UINTN by interpreting the contents of
2059 the ASCII string String as a hexadecimal number. The format of the input ASCII
2062 [spaces][zeros][x][hexadecimal digits].
2064 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
2065 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
2066 appears in the input string, it must be prefixed with at least one 0. The function
2067 will ignore the pad space, which includes spaces or tab characters, before [zeros],
2068 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
2069 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
2070 digit. Then, the function stops at the first character that is a not a valid
2071 hexadecimal character or Null-terminator, whichever on comes first.
2073 If String has only pad spaces, then 0 is returned.
2074 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
2077 If the number represented by String overflows according to the range defined by UINTN,
2078 then MAX_UINTN is returned.
2079 If String is NULL, then ASSERT().
2080 If PcdMaximumAsciiStringLength is not zero,
2081 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
2082 the Null-terminator, then ASSERT().
2084 @param String The pointer to a Null-terminated ASCII string.
2086 @retval Value translated from String.
2091 AsciiStrHexToUintn (
2092 IN CONST CHAR8
*String
2097 Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.
2099 This function returns a value of type UINT64 by interpreting the contents of
2100 the ASCII string String as a hexadecimal number. The format of the input ASCII
2103 [spaces][zeros][x][hexadecimal digits].
2105 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
2106 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
2107 appears in the input string, it must be prefixed with at least one 0. The function
2108 will ignore the pad space, which includes spaces or tab characters, before [zeros],
2109 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
2110 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
2111 digit. Then, the function stops at the first character that is a not a valid
2112 hexadecimal character or Null-terminator, whichever on comes first.
2114 If String has only pad spaces, then 0 is returned.
2115 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
2118 If the number represented by String overflows according to the range defined by UINT64,
2119 then MAX_UINT64 is returned.
2120 If String is NULL, then ASSERT().
2121 If PcdMaximumAsciiStringLength is not zero,
2122 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
2123 the Null-terminator, then ASSERT().
2125 @param String The pointer to a Null-terminated ASCII string.
2127 @retval Value translated from String.
2132 AsciiStrHexToUint64 (
2133 IN CONST CHAR8
*String
2136 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
2139 [ATTENTION] This function is deprecated for security reason.
2141 Convert one Null-terminated ASCII string to a Null-terminated
2142 Unicode string and returns the Unicode string.
2144 This function converts the contents of the ASCII string Source to the Unicode
2145 string Destination, and returns Destination. The function terminates the
2146 Unicode string Destination by appending a Null-terminator character at the end.
2147 The caller is responsible to make sure Destination points to a buffer with size
2148 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
2150 If Destination is NULL, then ASSERT().
2151 If Destination is not aligned on a 16-bit boundary, then ASSERT().
2152 If Source is NULL, then ASSERT().
2153 If Source and Destination overlap, then ASSERT().
2154 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
2155 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
2157 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
2158 PcdMaximumUnicodeStringLength ASCII characters not including the
2159 Null-terminator, then ASSERT().
2161 @param Source The pointer to a Null-terminated ASCII string.
2162 @param Destination The pointer to a Null-terminated Unicode string.
2164 @return Destination.
2169 AsciiStrToUnicodeStr (
2170 IN CONST CHAR8
*Source
,
2171 OUT CHAR16
*Destination
2177 Convert one Null-terminated ASCII string to a Null-terminated
2180 This function is similar to StrCpyS.
2182 This function converts the contents of the ASCII string Source to the Unicode
2183 string Destination. The function terminates the Unicode string Destination by
2184 appending a Null-terminator character at the end.
2186 The caller is responsible to make sure Destination points to a buffer with size
2187 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
2189 If Destination is not aligned on a 16-bit boundary, then ASSERT().
2190 If an error would be returned, then the function will also ASSERT().
2192 If an error is returned, then the Destination is unmodified.
2194 @param Source The pointer to a Null-terminated ASCII string.
2195 @param Destination The pointer to a Null-terminated Unicode string.
2196 @param DestMax The maximum number of Destination Unicode
2197 char, including terminating null char.
2199 @retval RETURN_SUCCESS String is converted.
2200 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
2201 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
2203 If PcdMaximumUnicodeStringLength is not zero,
2204 and DestMax is greater than
2205 PcdMaximumUnicodeStringLength.
2206 If PcdMaximumAsciiStringLength is not zero,
2207 and DestMax is greater than
2208 PcdMaximumAsciiStringLength.
2210 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
2215 AsciiStrToUnicodeStrS (
2216 IN CONST CHAR8
*Source
,
2217 OUT CHAR16
*Destination
,
2222 Converts an 8-bit value to an 8-bit BCD value.
2224 Converts the 8-bit value specified by Value to BCD. The BCD value is
2227 If Value >= 100, then ASSERT().
2229 @param Value The 8-bit value to convert to BCD. Range 0..99.
2231 @return The BCD value.
2242 Converts an 8-bit BCD value to an 8-bit value.
2244 Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit
2247 If Value >= 0xA0, then ASSERT().
2248 If (Value & 0x0F) >= 0x0A, then ASSERT().
2250 @param Value The 8-bit BCD value to convert to an 8-bit value.
2252 @return The 8-bit value is returned.
2262 // File Path Manipulation Functions
2266 Removes the last directory or file entry in a path.
2268 @param[in, out] Path The pointer to the path to modify.
2270 @retval FALSE Nothing was found to remove.
2271 @retval TRUE A directory or file was removed.
2280 Function to clean up paths.
2281 - Single periods in the path are removed.
2282 - Double periods in the path are removed along with a single parent directory.
2283 - Forward slashes L'/' are converted to backward slashes L'\'.
2285 This will be done inline and the existing buffer may be larger than required
2288 @param[in] Path The pointer to the string containing the path.
2290 @return Returns Path, otherwise returns NULL to indicate that an error has occurred.
2294 PathCleanUpDirectories(
2299 // Linked List Functions and Macros
2303 Initializes the head node of a doubly linked list that is declared as a
2304 global variable in a module.
2306 Initializes the forward and backward links of a new linked list. After
2307 initializing a linked list with this macro, the other linked list functions
2308 may be used to add and remove nodes from the linked list. This macro results
2309 in smaller executables by initializing the linked list in the data section,
2310 instead if calling the InitializeListHead() function to perform the
2311 equivalent operation.
2313 @param ListHead The head note of a list to initialize.
2316 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&(ListHead), &(ListHead)}
2320 Initializes the head node of a doubly linked list, and returns the pointer to
2321 the head node of the doubly linked list.
2323 Initializes the forward and backward links of a new linked list. After
2324 initializing a linked list with this function, the other linked list
2325 functions may be used to add and remove nodes from the linked list. It is up
2326 to the caller of this function to allocate the memory for ListHead.
2328 If ListHead is NULL, then ASSERT().
2330 @param ListHead A pointer to the head node of a new doubly linked list.
2337 InitializeListHead (
2338 IN OUT LIST_ENTRY
*ListHead
2343 Adds a node to the beginning of a doubly linked list, and returns the pointer
2344 to the head node of the doubly linked list.
2346 Adds the node Entry at the beginning of the doubly linked list denoted by
2347 ListHead, and returns ListHead.
2349 If ListHead is NULL, then ASSERT().
2350 If Entry is NULL, then ASSERT().
2351 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
2352 InitializeListHead(), then ASSERT().
2353 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
2354 of nodes in ListHead, including the ListHead node, is greater than or
2355 equal to PcdMaximumLinkedListLength, then ASSERT().
2357 @param ListHead A pointer to the head node of a doubly linked list.
2358 @param Entry A pointer to a node that is to be inserted at the beginning
2359 of a doubly linked list.
2367 IN OUT LIST_ENTRY
*ListHead
,
2368 IN OUT LIST_ENTRY
*Entry
2373 Adds a node to the end of a doubly linked list, and returns the pointer to
2374 the head node of the doubly linked list.
2376 Adds the node Entry to the end of the doubly linked list denoted by ListHead,
2377 and returns ListHead.
2379 If ListHead is NULL, then ASSERT().
2380 If Entry is NULL, then ASSERT().
2381 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
2382 InitializeListHead(), then ASSERT().
2383 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
2384 of nodes in ListHead, including the ListHead node, is greater than or
2385 equal to PcdMaximumLinkedListLength, then ASSERT().
2387 @param ListHead A pointer to the head node of a doubly linked list.
2388 @param Entry A pointer to a node that is to be added at the end of the
2397 IN OUT LIST_ENTRY
*ListHead
,
2398 IN OUT LIST_ENTRY
*Entry
2403 Retrieves the first node of a doubly linked list.
2405 Returns the first node of a doubly linked list. List must have been
2406 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
2407 If List is empty, then List is returned.
2409 If List is NULL, then ASSERT().
2410 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
2411 InitializeListHead(), then ASSERT().
2412 If PcdMaximumLinkedListLength is not zero, and the number of nodes
2413 in List, including the List node, is greater than or equal to
2414 PcdMaximumLinkedListLength, then ASSERT().
2416 @param List A pointer to the head node of a doubly linked list.
2418 @return The first node of a doubly linked list.
2419 @retval List The list is empty.
2425 IN CONST LIST_ENTRY
*List
2430 Retrieves the next node of a doubly linked list.
2432 Returns the node of a doubly linked list that follows Node.
2433 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
2434 or InitializeListHead(). If List is empty, then List is returned.
2436 If List is NULL, then ASSERT().
2437 If Node is NULL, then ASSERT().
2438 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
2439 InitializeListHead(), then ASSERT().
2440 If PcdMaximumLinkedListLength is not zero, and List contains more than
2441 PcdMaximumLinkedListLength nodes, then ASSERT().
2442 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
2444 @param List A pointer to the head node of a doubly linked list.
2445 @param Node A pointer to a node in the doubly linked list.
2447 @return The pointer to the next node if one exists. Otherwise List is returned.
2453 IN CONST LIST_ENTRY
*List
,
2454 IN CONST LIST_ENTRY
*Node
2459 Retrieves the previous node of a doubly linked list.
2461 Returns the node of a doubly linked list that precedes Node.
2462 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
2463 or InitializeListHead(). If List is empty, then List is returned.
2465 If List is NULL, then ASSERT().
2466 If Node is NULL, then ASSERT().
2467 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
2468 InitializeListHead(), then ASSERT().
2469 If PcdMaximumLinkedListLength is not zero, and List contains more than
2470 PcdMaximumLinkedListLength nodes, then ASSERT().
2471 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
2473 @param List A pointer to the head node of a doubly linked list.
2474 @param Node A pointer to a node in the doubly linked list.
2476 @return The pointer to the previous node if one exists. Otherwise List is returned.
2482 IN CONST LIST_ENTRY
*List
,
2483 IN CONST LIST_ENTRY
*Node
2488 Checks to see if a doubly linked list is empty or not.
2490 Checks to see if the doubly linked list is empty. If the linked list contains
2491 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
2493 If ListHead is NULL, then ASSERT().
2494 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
2495 InitializeListHead(), then ASSERT().
2496 If PcdMaximumLinkedListLength is not zero, and the number of nodes
2497 in List, including the List node, is greater than or equal to
2498 PcdMaximumLinkedListLength, then ASSERT().
2500 @param ListHead A pointer to the head node of a doubly linked list.
2502 @retval TRUE The linked list is empty.
2503 @retval FALSE The linked list is not empty.
2509 IN CONST LIST_ENTRY
*ListHead
2514 Determines if a node in a doubly linked list is the head node of a the same
2515 doubly linked list. This function is typically used to terminate a loop that
2516 traverses all the nodes in a doubly linked list starting with the head node.
2518 Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the
2519 nodes in the doubly linked list specified by List. List must have been
2520 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
2522 If List is NULL, then ASSERT().
2523 If Node is NULL, then ASSERT().
2524 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(),
2526 If PcdMaximumLinkedListLength is not zero, and the number of nodes
2527 in List, including the List node, is greater than or equal to
2528 PcdMaximumLinkedListLength, then ASSERT().
2529 If PcdVerifyNodeInList is TRUE and Node is not a node in List the and Node is not equal
2530 to List, then ASSERT().
2532 @param List A pointer to the head node of a doubly linked list.
2533 @param Node A pointer to a node in the doubly linked list.
2535 @retval TRUE Node is the head of the doubly-linked list pointed by List.
2536 @retval FALSE Node is not the head of the doubly-linked list pointed by List.
2542 IN CONST LIST_ENTRY
*List
,
2543 IN CONST LIST_ENTRY
*Node
2548 Determines if a node the last node in a doubly linked list.
2550 Returns TRUE if Node is the last node in the doubly linked list specified by
2551 List. Otherwise, FALSE is returned. List must have been initialized with
2552 INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
2554 If List is NULL, then ASSERT().
2555 If Node is NULL, then ASSERT().
2556 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
2557 InitializeListHead(), then ASSERT().
2558 If PcdMaximumLinkedListLength is not zero, and the number of nodes
2559 in List, including the List node, is greater than or equal to
2560 PcdMaximumLinkedListLength, then ASSERT().
2561 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
2563 @param List A pointer to the head node of a doubly linked list.
2564 @param Node A pointer to a node in the doubly linked list.
2566 @retval TRUE Node is the last node in the linked list.
2567 @retval FALSE Node is not the last node in the linked list.
2573 IN CONST LIST_ENTRY
*List
,
2574 IN CONST LIST_ENTRY
*Node
2579 Swaps the location of two nodes in a doubly linked list, and returns the
2580 first node after the swap.
2582 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
2583 Otherwise, the location of the FirstEntry node is swapped with the location
2584 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
2585 same double linked list as FirstEntry and that double linked list must have
2586 been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
2587 SecondEntry is returned after the nodes are swapped.
2589 If FirstEntry is NULL, then ASSERT().
2590 If SecondEntry is NULL, then ASSERT().
2591 If PcdVerifyNodeInList is TRUE and SecondEntry and FirstEntry are not in the
2592 same linked list, then ASSERT().
2593 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
2594 linked list containing the FirstEntry and SecondEntry nodes, including
2595 the FirstEntry and SecondEntry nodes, is greater than or equal to
2596 PcdMaximumLinkedListLength, then ASSERT().
2598 @param FirstEntry A pointer to a node in a linked list.
2599 @param SecondEntry A pointer to another node in the same linked list.
2601 @return SecondEntry.
2607 IN OUT LIST_ENTRY
*FirstEntry
,
2608 IN OUT LIST_ENTRY
*SecondEntry
2613 Removes a node from a doubly linked list, and returns the node that follows
2616 Removes the node Entry from a doubly linked list. It is up to the caller of
2617 this function to release the memory used by this node if that is required. On
2618 exit, the node following Entry in the doubly linked list is returned. If
2619 Entry is the only node in the linked list, then the head node of the linked
2622 If Entry is NULL, then ASSERT().
2623 If Entry is the head node of an empty list, then ASSERT().
2624 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
2625 linked list containing Entry, including the Entry node, is greater than
2626 or equal to PcdMaximumLinkedListLength, then ASSERT().
2628 @param Entry A pointer to a node in a linked list.
2636 IN CONST LIST_ENTRY
*Entry
2644 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
2645 with zeros. The shifted value is returned.
2647 This function shifts the 64-bit value Operand to the left by Count bits. The
2648 low Count bits are set to zero. The shifted value is returned.
2650 If Count is greater than 63, then ASSERT().
2652 @param Operand The 64-bit operand to shift left.
2653 @param Count The number of bits to shift left.
2655 @return Operand << Count.
2667 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
2668 filled with zeros. The shifted value is returned.
2670 This function shifts the 64-bit value Operand to the right by Count bits. The
2671 high Count bits are set to zero. The shifted value is returned.
2673 If Count is greater than 63, then ASSERT().
2675 @param Operand The 64-bit operand to shift right.
2676 @param Count The number of bits to shift right.
2678 @return Operand >> Count
2690 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
2691 with original integer's bit 63. The shifted value is returned.
2693 This function shifts the 64-bit value Operand to the right by Count bits. The
2694 high Count bits are set to bit 63 of Operand. The shifted value is returned.
2696 If Count is greater than 63, then ASSERT().
2698 @param Operand The 64-bit operand to shift right.
2699 @param Count The number of bits to shift right.
2701 @return Operand >> Count
2713 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
2714 with the high bits that were rotated.
2716 This function rotates the 32-bit value Operand to the left by Count bits. The
2717 low Count bits are fill with the high Count bits of Operand. The rotated
2720 If Count is greater than 31, then ASSERT().
2722 @param Operand The 32-bit operand to rotate left.
2723 @param Count The number of bits to rotate left.
2725 @return Operand << Count
2737 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
2738 with the low bits that were rotated.
2740 This function rotates the 32-bit value Operand to the right by Count bits.
2741 The high Count bits are fill with the low Count bits of Operand. The rotated
2744 If Count is greater than 31, then ASSERT().
2746 @param Operand The 32-bit operand to rotate right.
2747 @param Count The number of bits to rotate right.
2749 @return Operand >> Count
2761 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
2762 with the high bits that were rotated.
2764 This function rotates the 64-bit value Operand to the left by Count bits. The
2765 low Count bits are fill with the high Count bits of Operand. The rotated
2768 If Count is greater than 63, then ASSERT().
2770 @param Operand The 64-bit operand to rotate left.
2771 @param Count The number of bits to rotate left.
2773 @return Operand << Count
2785 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
2786 with the high low bits that were rotated.
2788 This function rotates the 64-bit value Operand to the right by Count bits.
2789 The high Count bits are fill with the low Count bits of Operand. The rotated
2792 If Count is greater than 63, then ASSERT().
2794 @param Operand The 64-bit operand to rotate right.
2795 @param Count The number of bits to rotate right.
2797 @return Operand >> Count
2809 Returns the bit position of the lowest bit set in a 32-bit value.
2811 This function computes the bit position of the lowest bit set in the 32-bit
2812 value specified by Operand. If Operand is zero, then -1 is returned.
2813 Otherwise, a value between 0 and 31 is returned.
2815 @param Operand The 32-bit operand to evaluate.
2817 @retval 0..31 The lowest bit set in Operand was found.
2818 @retval -1 Operand is zero.
2829 Returns the bit position of the lowest bit set in a 64-bit value.
2831 This function computes the bit position of the lowest bit set in the 64-bit
2832 value specified by Operand. If Operand is zero, then -1 is returned.
2833 Otherwise, a value between 0 and 63 is returned.
2835 @param Operand The 64-bit operand to evaluate.
2837 @retval 0..63 The lowest bit set in Operand was found.
2838 @retval -1 Operand is zero.
2850 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
2853 This function computes the bit position of the highest bit set in the 32-bit
2854 value specified by Operand. If Operand is zero, then -1 is returned.
2855 Otherwise, a value between 0 and 31 is returned.
2857 @param Operand The 32-bit operand to evaluate.
2859 @retval 0..31 Position of the highest bit set in Operand if found.
2860 @retval -1 Operand is zero.
2871 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
2874 This function computes the bit position of the highest bit set in the 64-bit
2875 value specified by Operand. If Operand is zero, then -1 is returned.
2876 Otherwise, a value between 0 and 63 is returned.
2878 @param Operand The 64-bit operand to evaluate.
2880 @retval 0..63 Position of the highest bit set in Operand if found.
2881 @retval -1 Operand is zero.
2892 Returns the value of the highest bit set in a 32-bit value. Equivalent to
2895 This function computes the value of the highest bit set in the 32-bit value
2896 specified by Operand. If Operand is zero, then zero is returned.
2898 @param Operand The 32-bit operand to evaluate.
2900 @return 1 << HighBitSet32(Operand)
2901 @retval 0 Operand is zero.
2912 Returns the value of the highest bit set in a 64-bit value. Equivalent to
2915 This function computes the value of the highest bit set in the 64-bit value
2916 specified by Operand. If Operand is zero, then zero is returned.
2918 @param Operand The 64-bit operand to evaluate.
2920 @return 1 << HighBitSet64(Operand)
2921 @retval 0 Operand is zero.
2932 Switches the endianness of a 16-bit integer.
2934 This function swaps the bytes in a 16-bit unsigned value to switch the value
2935 from little endian to big endian or vice versa. The byte swapped value is
2938 @param Value A 16-bit unsigned value.
2940 @return The byte swapped Value.
2951 Switches the endianness of a 32-bit integer.
2953 This function swaps the bytes in a 32-bit unsigned value to switch the value
2954 from little endian to big endian or vice versa. The byte swapped value is
2957 @param Value A 32-bit unsigned value.
2959 @return The byte swapped Value.
2970 Switches the endianness of a 64-bit integer.
2972 This function swaps the bytes in a 64-bit unsigned value to switch the value
2973 from little endian to big endian or vice versa. The byte swapped value is
2976 @param Value A 64-bit unsigned value.
2978 @return The byte swapped Value.
2989 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
2990 generates a 64-bit unsigned result.
2992 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
2993 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
2994 bit unsigned result is returned.
2996 @param Multiplicand A 64-bit unsigned value.
2997 @param Multiplier A 32-bit unsigned value.
2999 @return Multiplicand * Multiplier
3005 IN UINT64 Multiplicand
,
3006 IN UINT32 Multiplier
3011 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
3012 generates a 64-bit unsigned result.
3014 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
3015 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
3016 bit unsigned result is returned.
3018 @param Multiplicand A 64-bit unsigned value.
3019 @param Multiplier A 64-bit unsigned value.
3021 @return Multiplicand * Multiplier.
3027 IN UINT64 Multiplicand
,
3028 IN UINT64 Multiplier
3033 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
3034 64-bit signed result.
3036 This function multiples the 64-bit signed value Multiplicand by the 64-bit
3037 signed value Multiplier and generates a 64-bit signed result. This 64-bit
3038 signed result is returned.
3040 @param Multiplicand A 64-bit signed value.
3041 @param Multiplier A 64-bit signed value.
3043 @return Multiplicand * Multiplier
3049 IN INT64 Multiplicand
,
3055 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
3056 a 64-bit unsigned result.
3058 This function divides the 64-bit unsigned value Dividend by the 32-bit
3059 unsigned value Divisor and generates a 64-bit unsigned quotient. This
3060 function returns the 64-bit unsigned quotient.
3062 If Divisor is 0, then ASSERT().
3064 @param Dividend A 64-bit unsigned value.
3065 @param Divisor A 32-bit unsigned value.
3067 @return Dividend / Divisor.
3079 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
3080 a 32-bit unsigned remainder.
3082 This function divides the 64-bit unsigned value Dividend by the 32-bit
3083 unsigned value Divisor and generates a 32-bit remainder. This function
3084 returns the 32-bit unsigned remainder.
3086 If Divisor is 0, then ASSERT().
3088 @param Dividend A 64-bit unsigned value.
3089 @param Divisor A 32-bit unsigned value.
3091 @return Dividend % Divisor.
3103 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
3104 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
3106 This function divides the 64-bit unsigned value Dividend by the 32-bit
3107 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
3108 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
3109 This function returns the 64-bit unsigned quotient.
3111 If Divisor is 0, then ASSERT().
3113 @param Dividend A 64-bit unsigned value.
3114 @param Divisor A 32-bit unsigned value.
3115 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
3116 optional and may be NULL.
3118 @return Dividend / Divisor.
3123 DivU64x32Remainder (
3126 OUT UINT32
*Remainder OPTIONAL
3131 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
3132 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
3134 This function divides the 64-bit unsigned value Dividend by the 64-bit
3135 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
3136 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
3137 This function returns the 64-bit unsigned quotient.
3139 If Divisor is 0, then ASSERT().
3141 @param Dividend A 64-bit unsigned value.
3142 @param Divisor A 64-bit unsigned value.
3143 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
3144 optional and may be NULL.
3146 @return Dividend / Divisor.
3151 DivU64x64Remainder (
3154 OUT UINT64
*Remainder OPTIONAL
3159 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
3160 64-bit signed result and a optional 64-bit signed remainder.
3162 This function divides the 64-bit signed value Dividend by the 64-bit signed
3163 value Divisor and generates a 64-bit signed quotient. If Remainder is not
3164 NULL, then the 64-bit signed remainder is returned in Remainder. This
3165 function returns the 64-bit signed quotient.
3167 It is the caller's responsibility to not call this function with a Divisor of 0.
3168 If Divisor is 0, then the quotient and remainder should be assumed to be
3169 the largest negative integer.
3171 If Divisor is 0, then ASSERT().
3173 @param Dividend A 64-bit signed value.
3174 @param Divisor A 64-bit signed value.
3175 @param Remainder A pointer to a 64-bit signed value. This parameter is
3176 optional and may be NULL.
3178 @return Dividend / Divisor.
3183 DivS64x64Remainder (
3186 OUT INT64
*Remainder OPTIONAL
3191 Reads a 16-bit value from memory that may be unaligned.
3193 This function returns the 16-bit value pointed to by Buffer. The function
3194 guarantees that the read operation does not produce an alignment fault.
3196 If the Buffer is NULL, then ASSERT().
3198 @param Buffer The pointer to a 16-bit value that may be unaligned.
3200 @return The 16-bit value read from Buffer.
3206 IN CONST UINT16
*Buffer
3211 Writes a 16-bit value to memory that may be unaligned.
3213 This function writes the 16-bit value specified by Value to Buffer. Value is
3214 returned. The function guarantees that the write operation does not produce
3217 If the Buffer is NULL, then ASSERT().
3219 @param Buffer The pointer to a 16-bit value that may be unaligned.
3220 @param Value 16-bit value to write to Buffer.
3222 @return The 16-bit value to write to Buffer.
3234 Reads a 24-bit value from memory that may be unaligned.
3236 This function returns the 24-bit value pointed to by Buffer. The function
3237 guarantees that the read operation does not produce an alignment fault.
3239 If the Buffer is NULL, then ASSERT().
3241 @param Buffer The pointer to a 24-bit value that may be unaligned.
3243 @return The 24-bit value read from Buffer.
3249 IN CONST UINT32
*Buffer
3254 Writes a 24-bit value to memory that may be unaligned.
3256 This function writes the 24-bit value specified by Value to Buffer. Value is
3257 returned. The function guarantees that the write operation does not produce
3260 If the Buffer is NULL, then ASSERT().
3262 @param Buffer The pointer to a 24-bit value that may be unaligned.
3263 @param Value 24-bit value to write to Buffer.
3265 @return The 24-bit value to write to Buffer.
3277 Reads a 32-bit value from memory that may be unaligned.
3279 This function returns the 32-bit value pointed to by Buffer. The function
3280 guarantees that the read operation does not produce an alignment fault.
3282 If the Buffer is NULL, then ASSERT().
3284 @param Buffer The pointer to a 32-bit value that may be unaligned.
3286 @return The 32-bit value read from Buffer.
3292 IN CONST UINT32
*Buffer
3297 Writes a 32-bit value to memory that may be unaligned.
3299 This function writes the 32-bit value specified by Value to Buffer. Value is
3300 returned. The function guarantees that the write operation does not produce
3303 If the Buffer is NULL, then ASSERT().
3305 @param Buffer The pointer to a 32-bit value that may be unaligned.
3306 @param Value 32-bit value to write to Buffer.
3308 @return The 32-bit value to write to Buffer.
3320 Reads a 64-bit value from memory that may be unaligned.
3322 This function returns the 64-bit value pointed to by Buffer. The function
3323 guarantees that the read operation does not produce an alignment fault.
3325 If the Buffer is NULL, then ASSERT().
3327 @param Buffer The pointer to a 64-bit value that may be unaligned.
3329 @return The 64-bit value read from Buffer.
3335 IN CONST UINT64
*Buffer
3340 Writes a 64-bit value to memory that may be unaligned.
3342 This function writes the 64-bit value specified by Value to Buffer. Value is
3343 returned. The function guarantees that the write operation does not produce
3346 If the Buffer is NULL, then ASSERT().
3348 @param Buffer The pointer to a 64-bit value that may be unaligned.
3349 @param Value 64-bit value to write to Buffer.
3351 @return The 64-bit value to write to Buffer.
3363 // Bit Field Functions
3367 Returns a bit field from an 8-bit value.
3369 Returns the bitfield specified by the StartBit and the EndBit from Operand.
3371 If 8-bit operations are not supported, then ASSERT().
3372 If StartBit is greater than 7, then ASSERT().
3373 If EndBit is greater than 7, then ASSERT().
3374 If EndBit is less than StartBit, then ASSERT().
3376 @param Operand Operand on which to perform the bitfield operation.
3377 @param StartBit The ordinal of the least significant bit in the bit field.
3379 @param EndBit The ordinal of the most significant bit in the bit field.
3382 @return The bit field read.
3395 Writes a bit field to an 8-bit value, and returns the result.
3397 Writes Value to the bit field specified by the StartBit and the EndBit in
3398 Operand. All other bits in Operand are preserved. The new 8-bit value is
3401 If 8-bit operations are not supported, then ASSERT().
3402 If StartBit is greater than 7, then ASSERT().
3403 If EndBit is greater than 7, then ASSERT().
3404 If EndBit is less than StartBit, then ASSERT().
3405 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3407 @param Operand Operand on which to perform the bitfield operation.
3408 @param StartBit The ordinal of the least significant bit in the bit field.
3410 @param EndBit The ordinal of the most significant bit in the bit field.
3412 @param Value New value of the bit field.
3414 @return The new 8-bit value.
3428 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
3431 Performs a bitwise OR between the bit field specified by StartBit
3432 and EndBit in Operand and the value specified by OrData. All other bits in
3433 Operand are preserved. The new 8-bit value is returned.
3435 If 8-bit operations are not supported, then ASSERT().
3436 If StartBit is greater than 7, then ASSERT().
3437 If EndBit is greater than 7, then ASSERT().
3438 If EndBit is less than StartBit, then ASSERT().
3439 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3441 @param Operand Operand on which to perform the bitfield operation.
3442 @param StartBit The ordinal of the least significant bit in the bit field.
3444 @param EndBit The ordinal of the most significant bit in the bit field.
3446 @param OrData The value to OR with the read value from the value
3448 @return The new 8-bit value.
3462 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
3465 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3466 in Operand and the value specified by AndData. All other bits in Operand are
3467 preserved. The new 8-bit value is returned.
3469 If 8-bit operations are not supported, then ASSERT().
3470 If StartBit is greater than 7, then ASSERT().
3471 If EndBit is greater than 7, then ASSERT().
3472 If EndBit is less than StartBit, then ASSERT().
3473 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3475 @param Operand Operand on which to perform the bitfield operation.
3476 @param StartBit The ordinal of the least significant bit in the bit field.
3478 @param EndBit The ordinal of the most significant bit in the bit field.
3480 @param AndData The value to AND with the read value from the value.
3482 @return The new 8-bit value.
3496 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
3497 bitwise OR, and returns the result.
3499 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3500 in Operand and the value specified by AndData, followed by a bitwise
3501 OR with value specified by OrData. All other bits in Operand are
3502 preserved. The new 8-bit value is returned.
3504 If 8-bit operations are not supported, then ASSERT().
3505 If StartBit is greater than 7, then ASSERT().
3506 If EndBit is greater than 7, then ASSERT().
3507 If EndBit is less than StartBit, then ASSERT().
3508 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3509 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3511 @param Operand Operand on which to perform the bitfield operation.
3512 @param StartBit The ordinal of the least significant bit in the bit field.
3514 @param EndBit The ordinal of the most significant bit in the bit field.
3516 @param AndData The value to AND with the read value from the value.
3517 @param OrData The value to OR with the result of the AND operation.
3519 @return The new 8-bit value.
3524 BitFieldAndThenOr8 (
3534 Returns a bit field from a 16-bit value.
3536 Returns the bitfield specified by the StartBit and the EndBit from Operand.
3538 If 16-bit operations are not supported, then ASSERT().
3539 If StartBit is greater than 15, then ASSERT().
3540 If EndBit is greater than 15, then ASSERT().
3541 If EndBit is less than StartBit, then ASSERT().
3543 @param Operand Operand on which to perform the bitfield operation.
3544 @param StartBit The ordinal of the least significant bit in the bit field.
3546 @param EndBit The ordinal of the most significant bit in the bit field.
3549 @return The bit field read.
3562 Writes a bit field to a 16-bit value, and returns the result.
3564 Writes Value to the bit field specified by the StartBit and the EndBit in
3565 Operand. All other bits in Operand are preserved. The new 16-bit value is
3568 If 16-bit operations are not supported, then ASSERT().
3569 If StartBit is greater than 15, then ASSERT().
3570 If EndBit is greater than 15, then ASSERT().
3571 If EndBit is less than StartBit, then ASSERT().
3572 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3574 @param Operand Operand on which to perform the bitfield operation.
3575 @param StartBit The ordinal of the least significant bit in the bit field.
3577 @param EndBit The ordinal of the most significant bit in the bit field.
3579 @param Value New value of the bit field.
3581 @return The new 16-bit value.
3595 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
3598 Performs a bitwise OR between the bit field specified by StartBit
3599 and EndBit in Operand and the value specified by OrData. All other bits in
3600 Operand are preserved. The new 16-bit value is returned.
3602 If 16-bit operations are not supported, then ASSERT().
3603 If StartBit is greater than 15, then ASSERT().
3604 If EndBit is greater than 15, then ASSERT().
3605 If EndBit is less than StartBit, then ASSERT().
3606 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3608 @param Operand Operand on which to perform the bitfield operation.
3609 @param StartBit The ordinal of the least significant bit in the bit field.
3611 @param EndBit The ordinal of the most significant bit in the bit field.
3613 @param OrData The value to OR with the read value from the value
3615 @return The new 16-bit value.
3629 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
3632 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3633 in Operand and the value specified by AndData. All other bits in Operand are
3634 preserved. The new 16-bit value is returned.
3636 If 16-bit operations are not supported, then ASSERT().
3637 If StartBit is greater than 15, then ASSERT().
3638 If EndBit is greater than 15, then ASSERT().
3639 If EndBit is less than StartBit, then ASSERT().
3640 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3642 @param Operand Operand on which to perform the bitfield operation.
3643 @param StartBit The ordinal of the least significant bit in the bit field.
3645 @param EndBit The ordinal of the most significant bit in the bit field.
3647 @param AndData The value to AND with the read value from the value
3649 @return The new 16-bit value.
3663 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
3664 bitwise OR, and returns the result.
3666 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3667 in Operand and the value specified by AndData, followed by a bitwise
3668 OR with value specified by OrData. All other bits in Operand are
3669 preserved. The new 16-bit value is returned.
3671 If 16-bit operations are not supported, then ASSERT().
3672 If StartBit is greater than 15, then ASSERT().
3673 If EndBit is greater than 15, then ASSERT().
3674 If EndBit is less than StartBit, then ASSERT().
3675 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3676 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3678 @param Operand Operand on which to perform the bitfield operation.
3679 @param StartBit The ordinal of the least significant bit in the bit field.
3681 @param EndBit The ordinal of the most significant bit in the bit field.
3683 @param AndData The value to AND with the read value from the value.
3684 @param OrData The value to OR with the result of the AND operation.
3686 @return The new 16-bit value.
3691 BitFieldAndThenOr16 (
3701 Returns a bit field from a 32-bit value.
3703 Returns the bitfield specified by the StartBit and the EndBit from Operand.
3705 If 32-bit operations are not supported, then ASSERT().
3706 If StartBit is greater than 31, then ASSERT().
3707 If EndBit is greater than 31, then ASSERT().
3708 If EndBit is less than StartBit, then ASSERT().
3710 @param Operand Operand on which to perform the bitfield operation.
3711 @param StartBit The ordinal of the least significant bit in the bit field.
3713 @param EndBit The ordinal of the most significant bit in the bit field.
3716 @return The bit field read.
3729 Writes a bit field to a 32-bit value, and returns the result.
3731 Writes Value to the bit field specified by the StartBit and the EndBit in
3732 Operand. All other bits in Operand are preserved. The new 32-bit value is
3735 If 32-bit operations are not supported, then ASSERT().
3736 If StartBit is greater than 31, then ASSERT().
3737 If EndBit is greater than 31, then ASSERT().
3738 If EndBit is less than StartBit, then ASSERT().
3739 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3741 @param Operand Operand on which to perform the bitfield operation.
3742 @param StartBit The ordinal of the least significant bit in the bit field.
3744 @param EndBit The ordinal of the most significant bit in the bit field.
3746 @param Value New value of the bit field.
3748 @return The new 32-bit value.
3762 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
3765 Performs a bitwise OR between the bit field specified by StartBit
3766 and EndBit in Operand and the value specified by OrData. All other bits in
3767 Operand are preserved. The new 32-bit value is returned.
3769 If 32-bit operations are not supported, then ASSERT().
3770 If StartBit is greater than 31, then ASSERT().
3771 If EndBit is greater than 31, then ASSERT().
3772 If EndBit is less than StartBit, then ASSERT().
3773 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3775 @param Operand Operand on which to perform the bitfield operation.
3776 @param StartBit The ordinal of the least significant bit in the bit field.
3778 @param EndBit The ordinal of the most significant bit in the bit field.
3780 @param OrData The value to OR with the read value from the value.
3782 @return The new 32-bit value.
3796 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
3799 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3800 in Operand and the value specified by AndData. All other bits in Operand are
3801 preserved. The new 32-bit value is returned.
3803 If 32-bit operations are not supported, then ASSERT().
3804 If StartBit is greater than 31, then ASSERT().
3805 If EndBit is greater than 31, then ASSERT().
3806 If EndBit is less than StartBit, then ASSERT().
3807 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3809 @param Operand Operand on which to perform the bitfield operation.
3810 @param StartBit The ordinal of the least significant bit in the bit field.
3812 @param EndBit The ordinal of the most significant bit in the bit field.
3814 @param AndData The value to AND with the read value from the value
3816 @return The new 32-bit value.
3830 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
3831 bitwise OR, and returns the result.
3833 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3834 in Operand and the value specified by AndData, followed by a bitwise
3835 OR with value specified by OrData. All other bits in Operand are
3836 preserved. The new 32-bit value is returned.
3838 If 32-bit operations are not supported, then ASSERT().
3839 If StartBit is greater than 31, then ASSERT().
3840 If EndBit is greater than 31, then ASSERT().
3841 If EndBit is less than StartBit, then ASSERT().
3842 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3843 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3845 @param Operand Operand on which to perform the bitfield operation.
3846 @param StartBit The ordinal of the least significant bit in the bit field.
3848 @param EndBit The ordinal of the most significant bit in the bit field.
3850 @param AndData The value to AND with the read value from the value.
3851 @param OrData The value to OR with the result of the AND operation.
3853 @return The new 32-bit value.
3858 BitFieldAndThenOr32 (
3868 Returns a bit field from a 64-bit value.
3870 Returns the bitfield specified by the StartBit and the EndBit from Operand.
3872 If 64-bit operations are not supported, then ASSERT().
3873 If StartBit is greater than 63, then ASSERT().
3874 If EndBit is greater than 63, then ASSERT().
3875 If EndBit is less than StartBit, then ASSERT().
3877 @param Operand Operand on which to perform the bitfield operation.
3878 @param StartBit The ordinal of the least significant bit in the bit field.
3880 @param EndBit The ordinal of the most significant bit in the bit field.
3883 @return The bit field read.
3896 Writes a bit field to a 64-bit value, and returns the result.
3898 Writes Value to the bit field specified by the StartBit and the EndBit in
3899 Operand. All other bits in Operand are preserved. The new 64-bit value is
3902 If 64-bit operations are not supported, then ASSERT().
3903 If StartBit is greater than 63, then ASSERT().
3904 If EndBit is greater than 63, then ASSERT().
3905 If EndBit is less than StartBit, then ASSERT().
3906 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3908 @param Operand Operand on which to perform the bitfield operation.
3909 @param StartBit The ordinal of the least significant bit in the bit field.
3911 @param EndBit The ordinal of the most significant bit in the bit field.
3913 @param Value New value of the bit field.
3915 @return The new 64-bit value.
3929 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
3932 Performs a bitwise OR between the bit field specified by StartBit
3933 and EndBit in Operand and the value specified by OrData. All other bits in
3934 Operand are preserved. The new 64-bit value is returned.
3936 If 64-bit operations are not supported, then ASSERT().
3937 If StartBit is greater than 63, then ASSERT().
3938 If EndBit is greater than 63, then ASSERT().
3939 If EndBit is less than StartBit, then ASSERT().
3940 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3942 @param Operand Operand on which to perform the bitfield operation.
3943 @param StartBit The ordinal of the least significant bit in the bit field.
3945 @param EndBit The ordinal of the most significant bit in the bit field.
3947 @param OrData The value to OR with the read value from the value
3949 @return The new 64-bit value.
3963 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
3966 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3967 in Operand and the value specified by AndData. All other bits in Operand are
3968 preserved. The new 64-bit value is returned.
3970 If 64-bit operations are not supported, then ASSERT().
3971 If StartBit is greater than 63, then ASSERT().
3972 If EndBit is greater than 63, then ASSERT().
3973 If EndBit is less than StartBit, then ASSERT().
3974 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3976 @param Operand Operand on which to perform the bitfield operation.
3977 @param StartBit The ordinal of the least significant bit in the bit field.
3979 @param EndBit The ordinal of the most significant bit in the bit field.
3981 @param AndData The value to AND with the read value from the value
3983 @return The new 64-bit value.
3997 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
3998 bitwise OR, and returns the result.
4000 Performs a bitwise AND between the bit field specified by StartBit and EndBit
4001 in Operand and the value specified by AndData, followed by a bitwise
4002 OR with value specified by OrData. All other bits in Operand are
4003 preserved. The new 64-bit value is returned.
4005 If 64-bit operations are not supported, then ASSERT().
4006 If StartBit is greater than 63, then ASSERT().
4007 If EndBit is greater than 63, then ASSERT().
4008 If EndBit is less than StartBit, then ASSERT().
4009 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4010 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4012 @param Operand Operand on which to perform the bitfield operation.
4013 @param StartBit The ordinal of the least significant bit in the bit field.
4015 @param EndBit The ordinal of the most significant bit in the bit field.
4017 @param AndData The value to AND with the read value from the value.
4018 @param OrData The value to OR with the result of the AND operation.
4020 @return The new 64-bit value.
4025 BitFieldAndThenOr64 (
4034 // Base Library Checksum Functions
4038 Returns the sum of all elements in a buffer in unit of UINT8.
4039 During calculation, the carry bits are dropped.
4041 This function calculates the sum of all elements in a buffer
4042 in unit of UINT8. The carry bits in result of addition are dropped.
4043 The result is returned as UINT8. If Length is Zero, then Zero is
4046 If Buffer is NULL, then ASSERT().
4047 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4049 @param Buffer The pointer to the buffer to carry out the sum operation.
4050 @param Length The size, in bytes, of Buffer.
4052 @return Sum The sum of Buffer with carry bits dropped during additions.
4058 IN CONST UINT8
*Buffer
,
4064 Returns the two's complement checksum of all elements in a buffer
4067 This function first calculates the sum of the 8-bit values in the
4068 buffer specified by Buffer and Length. The carry bits in the result
4069 of addition are dropped. Then, the two's complement of the sum is
4070 returned. If Length is 0, then 0 is returned.
4072 If Buffer is NULL, then ASSERT().
4073 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4075 @param Buffer The pointer to the buffer to carry out the checksum operation.
4076 @param Length The size, in bytes, of Buffer.
4078 @return Checksum The two's complement checksum of Buffer.
4083 CalculateCheckSum8 (
4084 IN CONST UINT8
*Buffer
,
4090 Returns the sum of all elements in a buffer of 16-bit values. During
4091 calculation, the carry bits are dropped.
4093 This function calculates the sum of the 16-bit values in the buffer
4094 specified by Buffer and Length. The carry bits in result of addition are dropped.
4095 The 16-bit result is returned. If Length is 0, then 0 is returned.
4097 If Buffer is NULL, then ASSERT().
4098 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
4099 If Length is not aligned on a 16-bit boundary, then ASSERT().
4100 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4102 @param Buffer The pointer to the buffer to carry out the sum operation.
4103 @param Length The size, in bytes, of Buffer.
4105 @return Sum The sum of Buffer with carry bits dropped during additions.
4111 IN CONST UINT16
*Buffer
,
4117 Returns the two's complement checksum of all elements in a buffer of
4120 This function first calculates the sum of the 16-bit values in the buffer
4121 specified by Buffer and Length. The carry bits in the result of addition
4122 are dropped. Then, the two's complement of the sum is returned. If Length
4123 is 0, then 0 is returned.
4125 If Buffer is NULL, then ASSERT().
4126 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
4127 If Length is not aligned on a 16-bit boundary, then ASSERT().
4128 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4130 @param Buffer The pointer to the buffer to carry out the checksum operation.
4131 @param Length The size, in bytes, of Buffer.
4133 @return Checksum The two's complement checksum of Buffer.
4138 CalculateCheckSum16 (
4139 IN CONST UINT16
*Buffer
,
4145 Returns the sum of all elements in a buffer of 32-bit values. During
4146 calculation, the carry bits are dropped.
4148 This function calculates the sum of the 32-bit values in the buffer
4149 specified by Buffer and Length. The carry bits in result of addition are dropped.
4150 The 32-bit result is returned. If Length is 0, then 0 is returned.
4152 If Buffer is NULL, then ASSERT().
4153 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
4154 If Length is not aligned on a 32-bit boundary, then ASSERT().
4155 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4157 @param Buffer The pointer to the buffer to carry out the sum operation.
4158 @param Length The size, in bytes, of Buffer.
4160 @return Sum The sum of Buffer with carry bits dropped during additions.
4166 IN CONST UINT32
*Buffer
,
4172 Returns the two's complement checksum of all elements in a buffer of
4175 This function first calculates the sum of the 32-bit values in the buffer
4176 specified by Buffer and Length. The carry bits in the result of addition
4177 are dropped. Then, the two's complement of the sum is returned. If Length
4178 is 0, then 0 is returned.
4180 If Buffer is NULL, then ASSERT().
4181 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
4182 If Length is not aligned on a 32-bit boundary, then ASSERT().
4183 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4185 @param Buffer The pointer to the buffer to carry out the checksum operation.
4186 @param Length The size, in bytes, of Buffer.
4188 @return Checksum The two's complement checksum of Buffer.
4193 CalculateCheckSum32 (
4194 IN CONST UINT32
*Buffer
,
4200 Returns the sum of all elements in a buffer of 64-bit values. During
4201 calculation, the carry bits are dropped.
4203 This function calculates the sum of the 64-bit values in the buffer
4204 specified by Buffer and Length. The carry bits in result of addition are dropped.
4205 The 64-bit result is returned. If Length is 0, then 0 is returned.
4207 If Buffer is NULL, then ASSERT().
4208 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
4209 If Length is not aligned on a 64-bit boundary, then ASSERT().
4210 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4212 @param Buffer The pointer to the buffer to carry out the sum operation.
4213 @param Length The size, in bytes, of Buffer.
4215 @return Sum The sum of Buffer with carry bits dropped during additions.
4221 IN CONST UINT64
*Buffer
,
4227 Returns the two's complement checksum of all elements in a buffer of
4230 This function first calculates the sum of the 64-bit values in the buffer
4231 specified by Buffer and Length. The carry bits in the result of addition
4232 are dropped. Then, the two's complement of the sum is returned. If Length
4233 is 0, then 0 is returned.
4235 If Buffer is NULL, then ASSERT().
4236 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
4237 If Length is not aligned on a 64-bit boundary, then ASSERT().
4238 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4240 @param Buffer The pointer to the buffer to carry out the checksum operation.
4241 @param Length The size, in bytes, of Buffer.
4243 @return Checksum The two's complement checksum of Buffer.
4248 CalculateCheckSum64 (
4249 IN CONST UINT64
*Buffer
,
4255 // Base Library CPU Functions
4259 Function entry point used when a stack switch is requested with SwitchStack()
4261 @param Context1 Context1 parameter passed into SwitchStack().
4262 @param Context2 Context2 parameter passed into SwitchStack().
4267 (EFIAPI
*SWITCH_STACK_ENTRY_POINT
)(
4268 IN VOID
*Context1
, OPTIONAL
4269 IN VOID
*Context2 OPTIONAL
4274 Used to serialize load and store operations.
4276 All loads and stores that proceed calls to this function are guaranteed to be
4277 globally visible when this function returns.
4288 Saves the current CPU context that can be restored with a call to LongJump()
4291 Saves the current CPU context in the buffer specified by JumpBuffer and
4292 returns 0. The initial call to SetJump() must always return 0. Subsequent
4293 calls to LongJump() cause a non-zero value to be returned by SetJump().
4295 If JumpBuffer is NULL, then ASSERT().
4296 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
4298 NOTE: The structure BASE_LIBRARY_JUMP_BUFFER is CPU architecture specific.
4299 The same structure must never be used for more than one CPU architecture context.
4300 For example, a BASE_LIBRARY_JUMP_BUFFER allocated by an IA-32 module must never be used from an x64 module.
4301 SetJump()/LongJump() is not currently supported for the EBC processor type.
4303 @param JumpBuffer A pointer to CPU context buffer.
4305 @retval 0 Indicates a return from SetJump().
4311 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
4316 Restores the CPU context that was saved with SetJump().
4318 Restores the CPU context from the buffer specified by JumpBuffer. This
4319 function never returns to the caller. Instead is resumes execution based on
4320 the state of JumpBuffer.
4322 If JumpBuffer is NULL, then ASSERT().
4323 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
4324 If Value is 0, then ASSERT().
4326 @param JumpBuffer A pointer to CPU context buffer.
4327 @param Value The value to return when the SetJump() context is
4328 restored and must be non-zero.
4334 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
4340 Enables CPU interrupts.
4351 Disables CPU interrupts.
4362 Disables CPU interrupts and returns the interrupt state prior to the disable
4365 @retval TRUE CPU interrupts were enabled on entry to this call.
4366 @retval FALSE CPU interrupts were disabled on entry to this call.
4371 SaveAndDisableInterrupts (
4377 Enables CPU interrupts for the smallest window required to capture any
4383 EnableDisableInterrupts (
4389 Retrieves the current CPU interrupt state.
4391 Returns TRUE if interrupts are currently enabled. Otherwise
4394 @retval TRUE CPU interrupts are enabled.
4395 @retval FALSE CPU interrupts are disabled.
4406 Set the current CPU interrupt state.
4408 Sets the current CPU interrupt state to the state specified by
4409 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
4410 InterruptState is FALSE, then interrupts are disabled. InterruptState is
4413 @param InterruptState TRUE if interrupts should enabled. FALSE if
4414 interrupts should be disabled.
4416 @return InterruptState
4422 IN BOOLEAN InterruptState
4427 Requests CPU to pause for a short period of time.
4429 Requests CPU to pause for a short period of time. Typically used in MP
4430 systems to prevent memory starvation while waiting for a spin lock.
4441 Transfers control to a function starting with a new stack.
4443 Transfers control to the function specified by EntryPoint using the
4444 new stack specified by NewStack and passing in the parameters specified
4445 by Context1 and Context2. Context1 and Context2 are optional and may
4446 be NULL. The function EntryPoint must never return. This function
4447 supports a variable number of arguments following the NewStack parameter.
4448 These additional arguments are ignored on IA-32, x64, and EBC architectures.
4449 Itanium processors expect one additional parameter of type VOID * that specifies
4450 the new backing store pointer.
4452 If EntryPoint is NULL, then ASSERT().
4453 If NewStack is NULL, then ASSERT().
4455 @param EntryPoint A pointer to function to call with the new stack.
4456 @param Context1 A pointer to the context to pass into the EntryPoint
4458 @param Context2 A pointer to the context to pass into the EntryPoint
4460 @param NewStack A pointer to the new stack to use for the EntryPoint
4462 @param ... This variable argument list is ignored for IA-32, x64, and
4463 EBC architectures. For Itanium processors, this variable
4464 argument list is expected to contain a single parameter of
4465 type VOID * that specifies the new backing store pointer.
4472 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
4473 IN VOID
*Context1
, OPTIONAL
4474 IN VOID
*Context2
, OPTIONAL
4481 Generates a breakpoint on the CPU.
4483 Generates a breakpoint on the CPU. The breakpoint must be implemented such
4484 that code can resume normal execution after the breakpoint.
4495 Executes an infinite loop.
4497 Forces the CPU to execute an infinite loop. A debugger may be used to skip
4498 past the loop and the code that follows the loop must execute properly. This
4499 implies that the infinite loop must not cause the code that follow it to be
4509 #if defined (MDE_CPU_IPF)
4512 Flush a range of cache lines in the cache coherency domain of the calling
4515 Flushes the cache lines specified by Address and Length. If Address is not aligned
4516 on a cache line boundary, then entire cache line containing Address is flushed.
4517 If Address + Length is not aligned on a cache line boundary, then the entire cache
4518 line containing Address + Length - 1 is flushed. This function may choose to flush
4519 the entire cache if that is more efficient than flushing the specified range. If
4520 Length is 0, the no cache lines are flushed. Address is returned.
4521 This function is only available on Itanium processors.
4523 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
4525 @param Address The base address of the instruction lines to invalidate. If
4526 the CPU is in a physical addressing mode, then Address is a
4527 physical address. If the CPU is in a virtual addressing mode,
4528 then Address is a virtual address.
4530 @param Length The number of bytes to invalidate from the instruction cache.
4537 AsmFlushCacheRange (
4544 Executes an FC instruction.
4545 Executes an FC instruction on the cache line specified by Address.
4546 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
4547 An implementation may flush a larger region. This function is only available on Itanium processors.
4549 @param Address The Address of cache line to be flushed.
4551 @return The address of FC instruction executed.
4562 Executes an FC.I instruction.
4563 Executes an FC.I instruction on the cache line specified by Address.
4564 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
4565 An implementation may flush a larger region. This function is only available on Itanium processors.
4567 @param Address The Address of cache line to be flushed.
4569 @return The address of the FC.I instruction executed.
4580 Reads the current value of a Processor Identifier Register (CPUID).
4582 Reads and returns the current value of Processor Identifier Register specified by Index.
4583 The Index of largest implemented CPUID (One less than the number of implemented CPUID
4584 registers) is determined by CPUID [3] bits {7:0}.
4585 No parameter checking is performed on Index. If the Index value is beyond the
4586 implemented CPUID register range, a Reserved Register/Field fault may occur. The caller
4587 must either guarantee that Index is valid, or the caller must set up fault handlers to
4588 catch the faults. This function is only available on Itanium processors.
4590 @param Index The 8-bit Processor Identifier Register index to read.
4592 @return The current value of Processor Identifier Register specified by Index.
4603 Reads the current value of 64-bit Processor Status Register (PSR).
4604 This function is only available on Itanium processors.
4606 @return The current value of PSR.
4617 Writes the current value of 64-bit Processor Status Register (PSR).
4619 No parameter checking is performed on Value. All bits of Value corresponding to
4620 reserved fields of PSR must be 0 or a Reserved Register/Field fault may occur.
4621 The caller must either guarantee that Value is valid, or the caller must set up
4622 fault handlers to catch the faults. This function is only available on Itanium processors.
4624 @param Value The 64-bit value to write to PSR.
4626 @return The 64-bit value written to the PSR.
4637 Reads the current value of 64-bit Kernel Register #0 (KR0).
4639 Reads and returns the current value of KR0.
4640 This function is only available on Itanium processors.
4642 @return The current value of KR0.
4653 Reads the current value of 64-bit Kernel Register #1 (KR1).
4655 Reads and returns the current value of KR1.
4656 This function is only available on Itanium processors.
4658 @return The current value of KR1.
4669 Reads the current value of 64-bit Kernel Register #2 (KR2).
4671 Reads and returns the current value of KR2.
4672 This function is only available on Itanium processors.
4674 @return The current value of KR2.
4685 Reads the current value of 64-bit Kernel Register #3 (KR3).
4687 Reads and returns the current value of KR3.
4688 This function is only available on Itanium processors.
4690 @return The current value of KR3.
4701 Reads the current value of 64-bit Kernel Register #4 (KR4).
4703 Reads and returns the current value of KR4.
4704 This function is only available on Itanium processors.
4706 @return The current value of KR4.
4717 Reads the current value of 64-bit Kernel Register #5 (KR5).
4719 Reads and returns the current value of KR5.
4720 This function is only available on Itanium processors.
4722 @return The current value of KR5.
4733 Reads the current value of 64-bit Kernel Register #6 (KR6).
4735 Reads and returns the current value of KR6.
4736 This function is only available on Itanium processors.
4738 @return The current value of KR6.
4749 Reads the current value of 64-bit Kernel Register #7 (KR7).
4751 Reads and returns the current value of KR7.
4752 This function is only available on Itanium processors.
4754 @return The current value of KR7.
4765 Write the current value of 64-bit Kernel Register #0 (KR0).
4767 Writes the current value of KR0. The 64-bit value written to
4768 the KR0 is returned. This function is only available on Itanium processors.
4770 @param Value The 64-bit value to write to KR0.
4772 @return The 64-bit value written to the KR0.
4783 Write the current value of 64-bit Kernel Register #1 (KR1).
4785 Writes the current value of KR1. The 64-bit value written to
4786 the KR1 is returned. This function is only available on Itanium processors.
4788 @param Value The 64-bit value to write to KR1.
4790 @return The 64-bit value written to the KR1.
4801 Write the current value of 64-bit Kernel Register #2 (KR2).
4803 Writes the current value of KR2. The 64-bit value written to
4804 the KR2 is returned. This function is only available on Itanium processors.
4806 @param Value The 64-bit value to write to KR2.
4808 @return The 64-bit value written to the KR2.
4819 Write the current value of 64-bit Kernel Register #3 (KR3).
4821 Writes the current value of KR3. The 64-bit value written to
4822 the KR3 is returned. This function is only available on Itanium processors.
4824 @param Value The 64-bit value to write to KR3.
4826 @return The 64-bit value written to the KR3.
4837 Write the current value of 64-bit Kernel Register #4 (KR4).
4839 Writes the current value of KR4. The 64-bit value written to
4840 the KR4 is returned. This function is only available on Itanium processors.
4842 @param Value The 64-bit value to write to KR4.
4844 @return The 64-bit value written to the KR4.
4855 Write the current value of 64-bit Kernel Register #5 (KR5).
4857 Writes the current value of KR5. The 64-bit value written to
4858 the KR5 is returned. This function is only available on Itanium processors.
4860 @param Value The 64-bit value to write to KR5.
4862 @return The 64-bit value written to the KR5.
4873 Write the current value of 64-bit Kernel Register #6 (KR6).
4875 Writes the current value of KR6. The 64-bit value written to
4876 the KR6 is returned. This function is only available on Itanium processors.
4878 @param Value The 64-bit value to write to KR6.
4880 @return The 64-bit value written to the KR6.
4891 Write the current value of 64-bit Kernel Register #7 (KR7).
4893 Writes the current value of KR7. The 64-bit value written to
4894 the KR7 is returned. This function is only available on Itanium processors.
4896 @param Value The 64-bit value to write to KR7.
4898 @return The 64-bit value written to the KR7.
4909 Reads the current value of Interval Timer Counter Register (ITC).
4911 Reads and returns the current value of ITC.
4912 This function is only available on Itanium processors.
4914 @return The current value of ITC.
4925 Reads the current value of Interval Timer Vector Register (ITV).
4927 Reads and returns the current value of ITV.
4928 This function is only available on Itanium processors.
4930 @return The current value of ITV.
4941 Reads the current value of Interval Timer Match Register (ITM).
4943 Reads and returns the current value of ITM.
4944 This function is only available on Itanium processors.
4946 @return The current value of ITM.
4956 Writes the current value of 64-bit Interval Timer Counter Register (ITC).
4958 Writes the current value of ITC. The 64-bit value written to the ITC is returned.
4959 This function is only available on Itanium processors.
4961 @param Value The 64-bit value to write to ITC.
4963 @return The 64-bit value written to the ITC.
4974 Writes the current value of 64-bit Interval Timer Match Register (ITM).
4976 Writes the current value of ITM. The 64-bit value written to the ITM is returned.
4977 This function is only available on Itanium processors.
4979 @param Value The 64-bit value to write to ITM.
4981 @return The 64-bit value written to the ITM.
4992 Writes the current value of 64-bit Interval Timer Vector Register (ITV).
4994 Writes the current value of ITV. The 64-bit value written to the ITV is returned.
4995 No parameter checking is performed on Value. All bits of Value corresponding to
4996 reserved fields of ITV must be 0 or a Reserved Register/Field fault may occur.
4997 The caller must either guarantee that Value is valid, or the caller must set up
4998 fault handlers to catch the faults.
4999 This function is only available on Itanium processors.
5001 @param Value The 64-bit value to write to ITV.
5003 @return The 64-bit value written to the ITV.
5014 Reads the current value of Default Control Register (DCR).
5016 Reads and returns the current value of DCR. This function is only available on Itanium processors.
5018 @return The current value of DCR.
5029 Reads the current value of Interruption Vector Address Register (IVA).
5031 Reads and returns the current value of IVA. This function is only available on Itanium processors.
5033 @return The current value of IVA.
5043 Reads the current value of Page Table Address Register (PTA).
5045 Reads and returns the current value of PTA. This function is only available on Itanium processors.
5047 @return The current value of PTA.
5058 Writes the current value of 64-bit Default Control Register (DCR).
5060 Writes the current value of DCR. The 64-bit value written to the DCR is returned.
5061 No parameter checking is performed on Value. All bits of Value corresponding to
5062 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
5063 The caller must either guarantee that Value is valid, or the caller must set up
5064 fault handlers to catch the faults.
5065 This function is only available on Itanium processors.
5067 @param Value The 64-bit value to write to DCR.
5069 @return The 64-bit value written to the DCR.
5080 Writes the current value of 64-bit Interruption Vector Address Register (IVA).
5082 Writes the current value of IVA. The 64-bit value written to the IVA is returned.
5083 The size of vector table is 32 K bytes and is 32 K bytes aligned
5084 the low 15 bits of Value is ignored when written.
5085 This function is only available on Itanium processors.
5087 @param Value The 64-bit value to write to IVA.
5089 @return The 64-bit value written to the IVA.
5100 Writes the current value of 64-bit Page Table Address Register (PTA).
5102 Writes the current value of PTA. The 64-bit value written to the PTA is returned.
5103 No parameter checking is performed on Value. All bits of Value corresponding to
5104 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
5105 The caller must either guarantee that Value is valid, or the caller must set up
5106 fault handlers to catch the faults.
5107 This function is only available on Itanium processors.
5109 @param Value The 64-bit value to write to PTA.
5111 @return The 64-bit value written to the PTA.
5121 Reads the current value of Local Interrupt ID Register (LID).
5123 Reads and returns the current value of LID. This function is only available on Itanium processors.
5125 @return The current value of LID.
5136 Reads the current value of External Interrupt Vector Register (IVR).
5138 Reads and returns the current value of IVR. This function is only available on Itanium processors.
5140 @return The current value of IVR.
5151 Reads the current value of Task Priority Register (TPR).
5153 Reads and returns the current value of TPR. This function is only available on Itanium processors.
5155 @return The current value of TPR.
5166 Reads the current value of External Interrupt Request Register #0 (IRR0).
5168 Reads and returns the current value of IRR0. This function is only available on Itanium processors.
5170 @return The current value of IRR0.
5181 Reads the current value of External Interrupt Request Register #1 (IRR1).
5183 Reads and returns the current value of IRR1. This function is only available on Itanium processors.
5185 @return The current value of IRR1.
5196 Reads the current value of External Interrupt Request Register #2 (IRR2).
5198 Reads and returns the current value of IRR2. This function is only available on Itanium processors.
5200 @return The current value of IRR2.
5211 Reads the current value of External Interrupt Request Register #3 (IRR3).
5213 Reads and returns the current value of IRR3. This function is only available on Itanium processors.
5215 @return The current value of IRR3.
5226 Reads the current value of Performance Monitor Vector Register (PMV).
5228 Reads and returns the current value of PMV. This function is only available on Itanium processors.
5230 @return The current value of PMV.
5241 Reads the current value of Corrected Machine Check Vector Register (CMCV).
5243 Reads and returns the current value of CMCV. This function is only available on Itanium processors.
5245 @return The current value of CMCV.
5256 Reads the current value of Local Redirection Register #0 (LRR0).
5258 Reads and returns the current value of LRR0. This function is only available on Itanium processors.
5260 @return The current value of LRR0.
5271 Reads the current value of Local Redirection Register #1 (LRR1).
5273 Reads and returns the current value of LRR1. This function is only available on Itanium processors.
5275 @return The current value of LRR1.
5286 Writes the current value of 64-bit Page Local Interrupt ID Register (LID).
5288 Writes the current value of LID. The 64-bit value written to the LID is returned.
5289 No parameter checking is performed on Value. All bits of Value corresponding to
5290 reserved fields of LID must be 0 or a Reserved Register/Field fault may occur.
5291 The caller must either guarantee that Value is valid, or the caller must set up
5292 fault handlers to catch the faults.
5293 This function is only available on Itanium processors.
5295 @param Value The 64-bit value to write to LID.
5297 @return The 64-bit value written to the LID.
5308 Writes the current value of 64-bit Task Priority Register (TPR).
5310 Writes the current value of TPR. The 64-bit value written to the TPR is returned.
5311 No parameter checking is performed on Value. All bits of Value corresponding to
5312 reserved fields of TPR must be 0 or a Reserved Register/Field fault may occur.
5313 The caller must either guarantee that Value is valid, or the caller must set up
5314 fault handlers to catch the faults.
5315 This function is only available on Itanium processors.
5317 @param Value The 64-bit value to write to TPR.
5319 @return The 64-bit value written to the TPR.
5330 Performs a write operation on End OF External Interrupt Register (EOI).
5332 Writes a value of 0 to the EOI Register. This function is only available on Itanium processors.
5343 Writes the current value of 64-bit Performance Monitor Vector Register (PMV).
5345 Writes the current value of PMV. The 64-bit value written to the PMV is returned.
5346 No parameter checking is performed on Value. All bits of Value corresponding
5347 to reserved fields of PMV must be 0 or a Reserved Register/Field fault may occur.
5348 The caller must either guarantee that Value is valid, or the caller must set up
5349 fault handlers to catch the faults.
5350 This function is only available on Itanium processors.
5352 @param Value The 64-bit value to write to PMV.
5354 @return The 64-bit value written to the PMV.
5365 Writes the current value of 64-bit Corrected Machine Check Vector Register (CMCV).
5367 Writes the current value of CMCV. The 64-bit value written to the CMCV is returned.
5368 No parameter checking is performed on Value. All bits of Value corresponding
5369 to reserved fields of CMCV must be 0 or a Reserved Register/Field fault may occur.
5370 The caller must either guarantee that Value is valid, or the caller must set up
5371 fault handlers to catch the faults.
5372 This function is only available on Itanium processors.
5374 @param Value The 64-bit value to write to CMCV.
5376 @return The 64-bit value written to the CMCV.
5387 Writes the current value of 64-bit Local Redirection Register #0 (LRR0).
5389 Writes the current value of LRR0. The 64-bit value written to the LRR0 is returned.
5390 No parameter checking is performed on Value. All bits of Value corresponding
5391 to reserved fields of LRR0 must be 0 or a Reserved Register/Field fault may occur.
5392 The caller must either guarantee that Value is valid, or the caller must set up
5393 fault handlers to catch the faults.
5394 This function is only available on Itanium processors.
5396 @param Value The 64-bit value to write to LRR0.
5398 @return The 64-bit value written to the LRR0.
5409 Writes the current value of 64-bit Local Redirection Register #1 (LRR1).
5411 Writes the current value of LRR1. The 64-bit value written to the LRR1 is returned.
5412 No parameter checking is performed on Value. All bits of Value corresponding
5413 to reserved fields of LRR1 must be 0 or a Reserved Register/Field fault may occur.
5414 The caller must either guarantee that Value is valid, or the caller must
5415 set up fault handlers to catch the faults.
5416 This function is only available on Itanium processors.
5418 @param Value The 64-bit value to write to LRR1.
5420 @return The 64-bit value written to the LRR1.
5431 Reads the current value of Instruction Breakpoint Register (IBR).
5433 The Instruction Breakpoint Registers are used in pairs. The even numbered
5434 registers contain breakpoint addresses, and the odd numbered registers contain
5435 breakpoint mask conditions. At least four instruction registers pairs are implemented
5436 on all processor models. Implemented registers are contiguous starting with
5437 register 0. No parameter checking is performed on Index, and if the Index value
5438 is beyond the implemented IBR register range, a Reserved Register/Field fault may
5439 occur. The caller must either guarantee that Index is valid, or the caller must
5440 set up fault handlers to catch the faults.
5441 This function is only available on Itanium processors.
5443 @param Index The 8-bit Instruction Breakpoint Register index to read.
5445 @return The current value of Instruction Breakpoint Register specified by Index.
5456 Reads the current value of Data Breakpoint Register (DBR).
5458 The Data Breakpoint Registers are used in pairs. The even numbered registers
5459 contain breakpoint addresses, and odd numbered registers contain breakpoint
5460 mask conditions. At least four data registers pairs are implemented on all processor
5461 models. Implemented registers are contiguous starting with register 0.
5462 No parameter checking is performed on Index. If the Index value is beyond
5463 the implemented DBR register range, a Reserved Register/Field fault may occur.
5464 The caller must either guarantee that Index is valid, or the caller must set up
5465 fault handlers to catch the faults.
5466 This function is only available on Itanium processors.
5468 @param Index The 8-bit Data Breakpoint Register index to read.
5470 @return The current value of Data Breakpoint Register specified by Index.
5481 Reads the current value of Performance Monitor Configuration Register (PMC).
5483 All processor implementations provide at least four performance counters
5484 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow
5485 status registers (PMC [0]... PMC [3]). Processor implementations may provide
5486 additional implementation-dependent PMC and PMD to increase the number of
5487 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
5488 register set is implementation dependent. No parameter checking is performed
5489 on Index. If the Index value is beyond the implemented PMC register range,
5490 zero value will be returned.
5491 This function is only available on Itanium processors.
5493 @param Index The 8-bit Performance Monitor Configuration Register index to read.
5495 @return The current value of Performance Monitor Configuration Register
5507 Reads the current value of Performance Monitor Data Register (PMD).
5509 All processor implementations provide at least 4 performance counters
5510 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter
5511 overflow status registers (PMC [0]... PMC [3]). Processor implementations may
5512 provide additional implementation-dependent PMC and PMD to increase the number
5513 of 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
5514 register set is implementation dependent. No parameter checking is performed
5515 on Index. If the Index value is beyond the implemented PMD register range,
5516 zero value will be returned.
5517 This function is only available on Itanium processors.
5519 @param Index The 8-bit Performance Monitor Data Register index to read.
5521 @return The current value of Performance Monitor Data Register specified by Index.
5532 Writes the current value of 64-bit Instruction Breakpoint Register (IBR).
5534 Writes current value of Instruction Breakpoint Register specified by Index.
5535 The Instruction Breakpoint Registers are used in pairs. The even numbered
5536 registers contain breakpoint addresses, and odd numbered registers contain
5537 breakpoint mask conditions. At least four instruction registers pairs are implemented
5538 on all processor models. Implemented registers are contiguous starting with
5539 register 0. No parameter checking is performed on Index. If the Index value
5540 is beyond the implemented IBR register range, a Reserved Register/Field fault may
5541 occur. The caller must either guarantee that Index is valid, or the caller must
5542 set up fault handlers to catch the faults.
5543 This function is only available on Itanium processors.
5545 @param Index The 8-bit Instruction Breakpoint Register index to write.
5546 @param Value The 64-bit value to write to IBR.
5548 @return The 64-bit value written to the IBR.
5560 Writes the current value of 64-bit Data Breakpoint Register (DBR).
5562 Writes current value of Data Breakpoint Register specified by Index.
5563 The Data Breakpoint Registers are used in pairs. The even numbered registers
5564 contain breakpoint addresses, and odd numbered registers contain breakpoint
5565 mask conditions. At least four data registers pairs are implemented on all processor
5566 models. Implemented registers are contiguous starting with register 0. No parameter
5567 checking is performed on Index. If the Index value is beyond the implemented
5568 DBR register range, a Reserved Register/Field fault may occur. The caller must
5569 either guarantee that Index is valid, or the caller must set up fault handlers to
5571 This function is only available on Itanium processors.
5573 @param Index The 8-bit Data Breakpoint Register index to write.
5574 @param Value The 64-bit value to write to DBR.
5576 @return The 64-bit value written to the DBR.
5588 Writes the current value of 64-bit Performance Monitor Configuration Register (PMC).
5590 Writes current value of Performance Monitor Configuration Register specified by Index.
5591 All processor implementations provide at least four performance counters
5592 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow status
5593 registers (PMC [0]... PMC [3]). Processor implementations may provide additional
5594 implementation-dependent PMC and PMD to increase the number of 'generic' performance
5595 counters (PMC/PMD pairs). The remainder of PMC and PMD register set is implementation
5596 dependent. No parameter checking is performed on Index. If the Index value is
5597 beyond the implemented PMC register range, the write is ignored.
5598 This function is only available on Itanium processors.
5600 @param Index The 8-bit Performance Monitor Configuration Register index to write.
5601 @param Value The 64-bit value to write to PMC.
5603 @return The 64-bit value written to the PMC.
5615 Writes the current value of 64-bit Performance Monitor Data Register (PMD).
5617 Writes current value of Performance Monitor Data Register specified by Index.
5618 All processor implementations provide at least four performance counters
5619 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow
5620 status registers (PMC [0]... PMC [3]). Processor implementations may provide
5621 additional implementation-dependent PMC and PMD to increase the number of 'generic'
5622 performance counters (PMC/PMD pairs). The remainder of PMC and PMD register set
5623 is implementation dependent. No parameter checking is performed on Index. If the
5624 Index value is beyond the implemented PMD register range, the write is ignored.
5625 This function is only available on Itanium processors.
5627 @param Index The 8-bit Performance Monitor Data Register index to write.
5628 @param Value The 64-bit value to write to PMD.
5630 @return The 64-bit value written to the PMD.
5642 Reads the current value of 64-bit Global Pointer (GP).
5644 Reads and returns the current value of GP.
5645 This function is only available on Itanium processors.
5647 @return The current value of GP.
5658 Write the current value of 64-bit Global Pointer (GP).
5660 Writes the current value of GP. The 64-bit value written to the GP is returned.
5661 No parameter checking is performed on Value.
5662 This function is only available on Itanium processors.
5664 @param Value The 64-bit value to write to GP.
5666 @return The 64-bit value written to the GP.
5677 Reads the current value of 64-bit Stack Pointer (SP).
5679 Reads and returns the current value of SP.
5680 This function is only available on Itanium processors.
5682 @return The current value of SP.
5693 /// Valid Index value for AsmReadControlRegister().
5695 #define IPF_CONTROL_REGISTER_DCR 0
5696 #define IPF_CONTROL_REGISTER_ITM 1
5697 #define IPF_CONTROL_REGISTER_IVA 2
5698 #define IPF_CONTROL_REGISTER_PTA 8
5699 #define IPF_CONTROL_REGISTER_IPSR 16
5700 #define IPF_CONTROL_REGISTER_ISR 17
5701 #define IPF_CONTROL_REGISTER_IIP 19
5702 #define IPF_CONTROL_REGISTER_IFA 20
5703 #define IPF_CONTROL_REGISTER_ITIR 21
5704 #define IPF_CONTROL_REGISTER_IIPA 22
5705 #define IPF_CONTROL_REGISTER_IFS 23
5706 #define IPF_CONTROL_REGISTER_IIM 24
5707 #define IPF_CONTROL_REGISTER_IHA 25
5708 #define IPF_CONTROL_REGISTER_LID 64
5709 #define IPF_CONTROL_REGISTER_IVR 65
5710 #define IPF_CONTROL_REGISTER_TPR 66
5711 #define IPF_CONTROL_REGISTER_EOI 67
5712 #define IPF_CONTROL_REGISTER_IRR0 68
5713 #define IPF_CONTROL_REGISTER_IRR1 69
5714 #define IPF_CONTROL_REGISTER_IRR2 70
5715 #define IPF_CONTROL_REGISTER_IRR3 71
5716 #define IPF_CONTROL_REGISTER_ITV 72
5717 #define IPF_CONTROL_REGISTER_PMV 73
5718 #define IPF_CONTROL_REGISTER_CMCV 74
5719 #define IPF_CONTROL_REGISTER_LRR0 80
5720 #define IPF_CONTROL_REGISTER_LRR1 81
5723 Reads a 64-bit control register.
5725 Reads and returns the control register specified by Index. The valid Index valued
5726 are defined above in "Related Definitions".
5727 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only
5728 available on Itanium processors.
5730 @param Index The index of the control register to read.
5732 @return The control register specified by Index.
5737 AsmReadControlRegister (
5743 /// Valid Index value for AsmReadApplicationRegister().
5745 #define IPF_APPLICATION_REGISTER_K0 0
5746 #define IPF_APPLICATION_REGISTER_K1 1
5747 #define IPF_APPLICATION_REGISTER_K2 2
5748 #define IPF_APPLICATION_REGISTER_K3 3
5749 #define IPF_APPLICATION_REGISTER_K4 4
5750 #define IPF_APPLICATION_REGISTER_K5 5
5751 #define IPF_APPLICATION_REGISTER_K6 6
5752 #define IPF_APPLICATION_REGISTER_K7 7
5753 #define IPF_APPLICATION_REGISTER_RSC 16
5754 #define IPF_APPLICATION_REGISTER_BSP 17
5755 #define IPF_APPLICATION_REGISTER_BSPSTORE 18
5756 #define IPF_APPLICATION_REGISTER_RNAT 19
5757 #define IPF_APPLICATION_REGISTER_FCR 21
5758 #define IPF_APPLICATION_REGISTER_EFLAG 24
5759 #define IPF_APPLICATION_REGISTER_CSD 25
5760 #define IPF_APPLICATION_REGISTER_SSD 26
5761 #define IPF_APPLICATION_REGISTER_CFLG 27
5762 #define IPF_APPLICATION_REGISTER_FSR 28
5763 #define IPF_APPLICATION_REGISTER_FIR 29
5764 #define IPF_APPLICATION_REGISTER_FDR 30
5765 #define IPF_APPLICATION_REGISTER_CCV 32
5766 #define IPF_APPLICATION_REGISTER_UNAT 36
5767 #define IPF_APPLICATION_REGISTER_FPSR 40
5768 #define IPF_APPLICATION_REGISTER_ITC 44
5769 #define IPF_APPLICATION_REGISTER_PFS 64
5770 #define IPF_APPLICATION_REGISTER_LC 65
5771 #define IPF_APPLICATION_REGISTER_EC 66
5774 Reads a 64-bit application register.
5776 Reads and returns the application register specified by Index. The valid Index
5777 valued are defined above in "Related Definitions".
5778 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only
5779 available on Itanium processors.
5781 @param Index The index of the application register to read.
5783 @return The application register specified by Index.
5788 AsmReadApplicationRegister (
5794 Reads the current value of a Machine Specific Register (MSR).
5796 Reads and returns the current value of the Machine Specific Register specified by Index. No
5797 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
5798 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
5799 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
5800 only available on Itanium processors.
5802 @param Index The 8-bit Machine Specific Register index to read.
5804 @return The current value of the Machine Specific Register specified by Index.
5815 Writes the current value of a Machine Specific Register (MSR).
5817 Writes Value to the Machine Specific Register specified by Index. Value is returned. No
5818 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
5819 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
5820 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
5821 only available on Itanium processors.
5823 @param Index The 8-bit Machine Specific Register index to write.
5824 @param Value The 64-bit value to write to the Machine Specific Register.
5826 @return The 64-bit value to write to the Machine Specific Register.
5838 Determines if the CPU is currently executing in virtual, physical, or mixed mode.
5840 Determines the current execution mode of the CPU.
5841 If the CPU is in virtual mode(PSR.RT=1, PSR.DT=1, PSR.IT=1), then 1 is returned.
5842 If the CPU is in physical mode(PSR.RT=0, PSR.DT=0, PSR.IT=0), then 0 is returned.
5843 If the CPU is not in physical mode or virtual mode, then it is in mixed mode,
5845 This function is only available on Itanium processors.
5847 @retval 1 The CPU is in virtual mode.
5848 @retval 0 The CPU is in physical mode.
5849 @retval -1 The CPU is in mixed mode.
5860 Makes a PAL procedure call.
5862 This is a wrapper function to make a PAL procedure call. Based on the Index
5863 value this API will make static or stacked PAL call. The following table
5864 describes the usage of PAL Procedure Index Assignment. Architected procedures
5865 may be designated as required or optional. If a PAL procedure is specified
5866 as optional, a unique return code of 0xFFFFFFFFFFFFFFFF is returned in the
5867 Status field of the PAL_CALL_RETURN structure.
5868 This indicates that the procedure is not present in this PAL implementation.
5869 It is the caller's responsibility to check for this return code after calling
5870 any optional PAL procedure.
5871 No parameter checking is performed on the 5 input parameters, but there are
5872 some common rules that the caller should follow when making a PAL call. Any
5873 address passed to PAL as buffers for return parameters must be 8-byte aligned.
5874 Unaligned addresses may cause undefined results. For those parameters defined
5875 as reserved or some fields defined as reserved must be zero filled or the invalid
5876 argument return value may be returned or undefined result may occur during the
5877 execution of the procedure. If the PalEntryPoint does not point to a valid
5878 PAL entry point then the system behavior is undefined. This function is only
5879 available on Itanium processors.
5881 @param PalEntryPoint The PAL procedure calls entry point.
5882 @param Index The PAL procedure Index number.
5883 @param Arg2 The 2nd parameter for PAL procedure calls.
5884 @param Arg3 The 3rd parameter for PAL procedure calls.
5885 @param Arg4 The 4th parameter for PAL procedure calls.
5887 @return structure returned from the PAL Call procedure, including the status and return value.
5893 IN UINT64 PalEntryPoint
,
5901 #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
5903 /// IA32 and x64 Specific Functions.
5904 /// Byte packed structure for 16-bit Real Mode EFLAGS.
5908 UINT32 CF
:1; ///< Carry Flag.
5909 UINT32 Reserved_0
:1; ///< Reserved.
5910 UINT32 PF
:1; ///< Parity Flag.
5911 UINT32 Reserved_1
:1; ///< Reserved.
5912 UINT32 AF
:1; ///< Auxiliary Carry Flag.
5913 UINT32 Reserved_2
:1; ///< Reserved.
5914 UINT32 ZF
:1; ///< Zero Flag.
5915 UINT32 SF
:1; ///< Sign Flag.
5916 UINT32 TF
:1; ///< Trap Flag.
5917 UINT32 IF
:1; ///< Interrupt Enable Flag.
5918 UINT32 DF
:1; ///< Direction Flag.
5919 UINT32 OF
:1; ///< Overflow Flag.
5920 UINT32 IOPL
:2; ///< I/O Privilege Level.
5921 UINT32 NT
:1; ///< Nested Task.
5922 UINT32 Reserved_3
:1; ///< Reserved.
5928 /// Byte packed structure for EFLAGS/RFLAGS.
5929 /// 32-bits on IA-32.
5930 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5934 UINT32 CF
:1; ///< Carry Flag.
5935 UINT32 Reserved_0
:1; ///< Reserved.
5936 UINT32 PF
:1; ///< Parity Flag.
5937 UINT32 Reserved_1
:1; ///< Reserved.
5938 UINT32 AF
:1; ///< Auxiliary Carry Flag.
5939 UINT32 Reserved_2
:1; ///< Reserved.
5940 UINT32 ZF
:1; ///< Zero Flag.
5941 UINT32 SF
:1; ///< Sign Flag.
5942 UINT32 TF
:1; ///< Trap Flag.
5943 UINT32 IF
:1; ///< Interrupt Enable Flag.
5944 UINT32 DF
:1; ///< Direction Flag.
5945 UINT32 OF
:1; ///< Overflow Flag.
5946 UINT32 IOPL
:2; ///< I/O Privilege Level.
5947 UINT32 NT
:1; ///< Nested Task.
5948 UINT32 Reserved_3
:1; ///< Reserved.
5949 UINT32 RF
:1; ///< Resume Flag.
5950 UINT32 VM
:1; ///< Virtual 8086 Mode.
5951 UINT32 AC
:1; ///< Alignment Check.
5952 UINT32 VIF
:1; ///< Virtual Interrupt Flag.
5953 UINT32 VIP
:1; ///< Virtual Interrupt Pending.
5954 UINT32 ID
:1; ///< ID Flag.
5955 UINT32 Reserved_4
:10; ///< Reserved.
5961 /// Byte packed structure for Control Register 0 (CR0).
5962 /// 32-bits on IA-32.
5963 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5967 UINT32 PE
:1; ///< Protection Enable.
5968 UINT32 MP
:1; ///< Monitor Coprocessor.
5969 UINT32 EM
:1; ///< Emulation.
5970 UINT32 TS
:1; ///< Task Switched.
5971 UINT32 ET
:1; ///< Extension Type.
5972 UINT32 NE
:1; ///< Numeric Error.
5973 UINT32 Reserved_0
:10; ///< Reserved.
5974 UINT32 WP
:1; ///< Write Protect.
5975 UINT32 Reserved_1
:1; ///< Reserved.
5976 UINT32 AM
:1; ///< Alignment Mask.
5977 UINT32 Reserved_2
:10; ///< Reserved.
5978 UINT32 NW
:1; ///< Mot Write-through.
5979 UINT32 CD
:1; ///< Cache Disable.
5980 UINT32 PG
:1; ///< Paging.
5986 /// Byte packed structure for Control Register 4 (CR4).
5987 /// 32-bits on IA-32.
5988 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5992 UINT32 VME
:1; ///< Virtual-8086 Mode Extensions.
5993 UINT32 PVI
:1; ///< Protected-Mode Virtual Interrupts.
5994 UINT32 TSD
:1; ///< Time Stamp Disable.
5995 UINT32 DE
:1; ///< Debugging Extensions.
5996 UINT32 PSE
:1; ///< Page Size Extensions.
5997 UINT32 PAE
:1; ///< Physical Address Extension.
5998 UINT32 MCE
:1; ///< Machine Check Enable.
5999 UINT32 PGE
:1; ///< Page Global Enable.
6000 UINT32 PCE
:1; ///< Performance Monitoring Counter
6002 UINT32 OSFXSR
:1; ///< Operating System Support for
6003 ///< FXSAVE and FXRSTOR instructions
6004 UINT32 OSXMMEXCPT
:1; ///< Operating System Support for
6005 ///< Unmasked SIMD Floating Point
6007 UINT32 Reserved_0
:2; ///< Reserved.
6008 UINT32 VMXE
:1; ///< VMX Enable
6009 UINT32 Reserved_1
:18; ///< Reserved.
6015 /// Byte packed structure for a segment descriptor in a GDT/LDT.
6034 } IA32_SEGMENT_DESCRIPTOR
;
6037 /// Byte packed structure for an IDTR, GDTR, LDTR descriptor.
6046 #define IA32_IDT_GATE_TYPE_TASK 0x85
6047 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
6048 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
6049 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
6050 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
6053 #if defined (MDE_CPU_IA32)
6055 /// Byte packed structure for an IA-32 Interrupt Gate Descriptor.
6059 UINT32 OffsetLow
:16; ///< Offset bits 15..0.
6060 UINT32 Selector
:16; ///< Selector.
6061 UINT32 Reserved_0
:8; ///< Reserved.
6062 UINT32 GateType
:8; ///< Gate Type. See #defines above.
6063 UINT32 OffsetHigh
:16; ///< Offset bits 31..16.
6066 } IA32_IDT_GATE_DESCRIPTOR
;
6070 #if defined (MDE_CPU_X64)
6072 /// Byte packed structure for an x64 Interrupt Gate Descriptor.
6076 UINT32 OffsetLow
:16; ///< Offset bits 15..0.
6077 UINT32 Selector
:16; ///< Selector.
6078 UINT32 Reserved_0
:8; ///< Reserved.
6079 UINT32 GateType
:8; ///< Gate Type. See #defines above.
6080 UINT32 OffsetHigh
:16; ///< Offset bits 31..16.
6081 UINT32 OffsetUpper
:32; ///< Offset bits 63..32.
6082 UINT32 Reserved_1
:32; ///< Reserved.
6088 } IA32_IDT_GATE_DESCRIPTOR
;
6093 /// Byte packed structure for an FP/SSE/SSE2 context.
6100 /// Structures for the 16-bit real mode thunks.
6153 IA32_EFLAGS32 EFLAGS
;
6163 } IA32_REGISTER_SET
;
6166 /// Byte packed structure for an 16-bit real mode thunks.
6169 IA32_REGISTER_SET
*RealModeState
;
6170 VOID
*RealModeBuffer
;
6171 UINT32 RealModeBufferSize
;
6172 UINT32 ThunkAttributes
;
6175 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
6176 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
6177 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
6180 Retrieves CPUID information.
6182 Executes the CPUID instruction with EAX set to the value specified by Index.
6183 This function always returns Index.
6184 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
6185 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
6186 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
6187 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
6188 This function is only available on IA-32 and x64.
6190 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
6192 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
6193 instruction. This is an optional parameter that may be NULL.
6194 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
6195 instruction. This is an optional parameter that may be NULL.
6196 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
6197 instruction. This is an optional parameter that may be NULL.
6198 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
6199 instruction. This is an optional parameter that may be NULL.
6208 OUT UINT32
*Eax
, OPTIONAL
6209 OUT UINT32
*Ebx
, OPTIONAL
6210 OUT UINT32
*Ecx
, OPTIONAL
6211 OUT UINT32
*Edx OPTIONAL
6216 Retrieves CPUID information using an extended leaf identifier.
6218 Executes the CPUID instruction with EAX set to the value specified by Index
6219 and ECX set to the value specified by SubIndex. This function always returns
6220 Index. This function is only available on IA-32 and x64.
6222 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
6223 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
6224 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
6225 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
6227 @param Index The 32-bit value to load into EAX prior to invoking the
6229 @param SubIndex The 32-bit value to load into ECX prior to invoking the
6231 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
6232 instruction. This is an optional parameter that may be
6234 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
6235 instruction. This is an optional parameter that may be
6237 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
6238 instruction. This is an optional parameter that may be
6240 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
6241 instruction. This is an optional parameter that may be
6252 OUT UINT32
*Eax
, OPTIONAL
6253 OUT UINT32
*Ebx
, OPTIONAL
6254 OUT UINT32
*Ecx
, OPTIONAL
6255 OUT UINT32
*Edx OPTIONAL
6260 Set CD bit and clear NW bit of CR0 followed by a WBINVD.
6262 Disables the caches by setting the CD bit of CR0 to 1, clearing the NW bit of CR0 to 0,
6263 and executing a WBINVD instruction. This function is only available on IA-32 and x64.
6274 Perform a WBINVD and clear both the CD and NW bits of CR0.
6276 Enables the caches by executing a WBINVD instruction and then clear both the CD and NW
6277 bits of CR0 to 0. This function is only available on IA-32 and x64.
6288 Returns the lower 32-bits of a Machine Specific Register(MSR).
6290 Reads and returns the lower 32-bits of the MSR specified by Index.
6291 No parameter checking is performed on Index, and some Index values may cause
6292 CPU exceptions. The caller must either guarantee that Index is valid, or the
6293 caller must set up exception handlers to catch the exceptions. This function
6294 is only available on IA-32 and x64.
6296 @param Index The 32-bit MSR index to read.
6298 @return The lower 32 bits of the MSR identified by Index.
6309 Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.
6310 The upper 32-bits of the MSR are set to zero.
6312 Writes the 32-bit value specified by Value to the MSR specified by Index. The
6313 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
6314 the MSR is returned. No parameter checking is performed on Index or Value,
6315 and some of these may cause CPU exceptions. The caller must either guarantee
6316 that Index and Value are valid, or the caller must establish proper exception
6317 handlers. This function is only available on IA-32 and x64.
6319 @param Index The 32-bit MSR index to write.
6320 @param Value The 32-bit value to write to the MSR.
6334 Reads a 64-bit MSR, performs a bitwise OR on the lower 32-bits, and
6335 writes the result back to the 64-bit MSR.
6337 Reads the 64-bit MSR specified by Index, performs a bitwise OR
6338 between the lower 32-bits of the read result and the value specified by
6339 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
6340 32-bits of the value written to the MSR is returned. No parameter checking is
6341 performed on Index or OrData, and some of these may cause CPU exceptions. The
6342 caller must either guarantee that Index and OrData are valid, or the caller
6343 must establish proper exception handlers. This function is only available on
6346 @param Index The 32-bit MSR index to write.
6347 @param OrData The value to OR with the read value from the MSR.
6349 @return The lower 32-bit value written to the MSR.
6361 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
6362 the result back to the 64-bit MSR.
6364 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
6365 lower 32-bits of the read result and the value specified by AndData, and
6366 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
6367 the value written to the MSR is returned. No parameter checking is performed
6368 on Index or AndData, and some of these may cause CPU exceptions. The caller
6369 must either guarantee that Index and AndData are valid, or the caller must
6370 establish proper exception handlers. This function is only available on IA-32
6373 @param Index The 32-bit MSR index to write.
6374 @param AndData The value to AND with the read value from the MSR.
6376 @return The lower 32-bit value written to the MSR.
6388 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise OR
6389 on the lower 32-bits, and writes the result back to the 64-bit MSR.
6391 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
6392 lower 32-bits of the read result and the value specified by AndData
6393 preserving the upper 32-bits, performs a bitwise OR between the
6394 result of the AND operation and the value specified by OrData, and writes the
6395 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
6396 written to the MSR is returned. No parameter checking is performed on Index,
6397 AndData, or OrData, and some of these may cause CPU exceptions. The caller
6398 must either guarantee that Index, AndData, and OrData are valid, or the
6399 caller must establish proper exception handlers. This function is only
6400 available on IA-32 and x64.
6402 @param Index The 32-bit MSR index to write.
6403 @param AndData The value to AND with the read value from the MSR.
6404 @param OrData The value to OR with the result of the AND operation.
6406 @return The lower 32-bit value written to the MSR.
6419 Reads a bit field of an MSR.
6421 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
6422 specified by the StartBit and the EndBit. The value of the bit field is
6423 returned. The caller must either guarantee that Index is valid, or the caller
6424 must set up exception handlers to catch the exceptions. This function is only
6425 available on IA-32 and x64.
6427 If StartBit is greater than 31, then ASSERT().
6428 If EndBit is greater than 31, then ASSERT().
6429 If EndBit is less than StartBit, then ASSERT().
6431 @param Index The 32-bit MSR index to read.
6432 @param StartBit The ordinal of the least significant bit in the bit field.
6434 @param EndBit The ordinal of the most significant bit in the bit field.
6437 @return The bit field read from the MSR.
6442 AsmMsrBitFieldRead32 (
6450 Writes a bit field to an MSR.
6452 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
6453 field is specified by the StartBit and the EndBit. All other bits in the
6454 destination MSR are preserved. The lower 32-bits of the MSR written is
6455 returned. The caller must either guarantee that Index and the data written
6456 is valid, or the caller must set up exception handlers to catch the exceptions.
6457 This function is only available on IA-32 and x64.
6459 If StartBit is greater than 31, then ASSERT().
6460 If EndBit is greater than 31, then ASSERT().
6461 If EndBit is less than StartBit, then ASSERT().
6462 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6464 @param Index The 32-bit MSR index to write.
6465 @param StartBit The ordinal of the least significant bit in the bit field.
6467 @param EndBit The ordinal of the most significant bit in the bit field.
6469 @param Value New value of the bit field.
6471 @return The lower 32-bit of the value written to the MSR.
6476 AsmMsrBitFieldWrite32 (
6485 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
6486 result back to the bit field in the 64-bit MSR.
6488 Reads the 64-bit MSR specified by Index, performs a bitwise OR
6489 between the read result and the value specified by OrData, and writes the
6490 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
6491 written to the MSR are returned. Extra left bits in OrData are stripped. The
6492 caller must either guarantee that Index and the data written is valid, or
6493 the caller must set up exception handlers to catch the exceptions. This
6494 function is only available on IA-32 and x64.
6496 If StartBit is greater than 31, then ASSERT().
6497 If EndBit is greater than 31, then ASSERT().
6498 If EndBit is less than StartBit, then ASSERT().
6499 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6501 @param Index The 32-bit MSR index to write.
6502 @param StartBit The ordinal of the least significant bit in the bit field.
6504 @param EndBit The ordinal of the most significant bit in the bit field.
6506 @param OrData The value to OR with the read value from the MSR.
6508 @return The lower 32-bit of the value written to the MSR.
6513 AsmMsrBitFieldOr32 (
6522 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
6523 result back to the bit field in the 64-bit MSR.
6525 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
6526 read result and the value specified by AndData, and writes the result to the
6527 64-bit MSR specified by Index. The lower 32-bits of the value written to the
6528 MSR are returned. Extra left bits in AndData are stripped. The caller must
6529 either guarantee that Index and the data written is valid, or the caller must
6530 set up exception handlers to catch the exceptions. This function is only
6531 available on IA-32 and x64.
6533 If StartBit is greater than 31, then ASSERT().
6534 If EndBit is greater than 31, then ASSERT().
6535 If EndBit is less than StartBit, then ASSERT().
6536 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6538 @param Index The 32-bit MSR index to write.
6539 @param StartBit The ordinal of the least significant bit in the bit field.
6541 @param EndBit The ordinal of the most significant bit in the bit field.
6543 @param AndData The value to AND with the read value from the MSR.
6545 @return The lower 32-bit of the value written to the MSR.
6550 AsmMsrBitFieldAnd32 (
6559 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
6560 bitwise OR, and writes the result back to the bit field in the
6563 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
6564 bitwise OR between the read result and the value specified by
6565 AndData, and writes the result to the 64-bit MSR specified by Index. The
6566 lower 32-bits of the value written to the MSR are returned. Extra left bits
6567 in both AndData and OrData are stripped. The caller must either guarantee
6568 that Index and the data written is valid, or the caller must set up exception
6569 handlers to catch the exceptions. This function is only available on IA-32
6572 If StartBit is greater than 31, then ASSERT().
6573 If EndBit is greater than 31, then ASSERT().
6574 If EndBit is less than StartBit, then ASSERT().
6575 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6576 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6578 @param Index The 32-bit MSR index to write.
6579 @param StartBit The ordinal of the least significant bit in the bit field.
6581 @param EndBit The ordinal of the most significant bit in the bit field.
6583 @param AndData The value to AND with the read value from the MSR.
6584 @param OrData The value to OR with the result of the AND operation.
6586 @return The lower 32-bit of the value written to the MSR.
6591 AsmMsrBitFieldAndThenOr32 (
6601 Returns a 64-bit Machine Specific Register(MSR).
6603 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
6604 performed on Index, and some Index values may cause CPU exceptions. The
6605 caller must either guarantee that Index is valid, or the caller must set up
6606 exception handlers to catch the exceptions. This function is only available
6609 @param Index The 32-bit MSR index to read.
6611 @return The value of the MSR identified by Index.
6622 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
6625 Writes the 64-bit value specified by Value to the MSR specified by Index. The
6626 64-bit value written to the MSR is returned. No parameter checking is
6627 performed on Index or Value, and some of these may cause CPU exceptions. The
6628 caller must either guarantee that Index and Value are valid, or the caller
6629 must establish proper exception handlers. This function is only available on
6632 @param Index The 32-bit MSR index to write.
6633 @param Value The 64-bit value to write to the MSR.
6647 Reads a 64-bit MSR, performs a bitwise OR, and writes the result
6648 back to the 64-bit MSR.
6650 Reads the 64-bit MSR specified by Index, performs a bitwise OR
6651 between the read result and the value specified by OrData, and writes the
6652 result to the 64-bit MSR specified by Index. The value written to the MSR is
6653 returned. No parameter checking is performed on Index or OrData, and some of
6654 these may cause CPU exceptions. The caller must either guarantee that Index
6655 and OrData are valid, or the caller must establish proper exception handlers.
6656 This function is only available on IA-32 and x64.
6658 @param Index The 32-bit MSR index to write.
6659 @param OrData The value to OR with the read value from the MSR.
6661 @return The value written back to the MSR.
6673 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
6676 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
6677 read result and the value specified by OrData, and writes the result to the
6678 64-bit MSR specified by Index. The value written to the MSR is returned. No
6679 parameter checking is performed on Index or OrData, and some of these may
6680 cause CPU exceptions. The caller must either guarantee that Index and OrData
6681 are valid, or the caller must establish proper exception handlers. This
6682 function is only available on IA-32 and x64.
6684 @param Index The 32-bit MSR index to write.
6685 @param AndData The value to AND with the read value from the MSR.
6687 @return The value written back to the MSR.
6699 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise
6700 OR, and writes the result back to the 64-bit MSR.
6702 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
6703 result and the value specified by AndData, performs a bitwise OR
6704 between the result of the AND operation and the value specified by OrData,
6705 and writes the result to the 64-bit MSR specified by Index. The value written
6706 to the MSR is returned. No parameter checking is performed on Index, AndData,
6707 or OrData, and some of these may cause CPU exceptions. The caller must either
6708 guarantee that Index, AndData, and OrData are valid, or the caller must
6709 establish proper exception handlers. This function is only available on IA-32
6712 @param Index The 32-bit MSR index to write.
6713 @param AndData The value to AND with the read value from the MSR.
6714 @param OrData The value to OR with the result of the AND operation.
6716 @return The value written back to the MSR.
6729 Reads a bit field of an MSR.
6731 Reads the bit field in the 64-bit MSR. The bit field is specified by the
6732 StartBit and the EndBit. The value of the bit field is returned. The caller
6733 must either guarantee that Index is valid, or the caller must set up
6734 exception handlers to catch the exceptions. This function is only available
6737 If StartBit is greater than 63, then ASSERT().
6738 If EndBit is greater than 63, then ASSERT().
6739 If EndBit is less than StartBit, then ASSERT().
6741 @param Index The 32-bit MSR index to read.
6742 @param StartBit The ordinal of the least significant bit in the bit field.
6744 @param EndBit The ordinal of the most significant bit in the bit field.
6747 @return The value read from the MSR.
6752 AsmMsrBitFieldRead64 (
6760 Writes a bit field to an MSR.
6762 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
6763 the StartBit and the EndBit. All other bits in the destination MSR are
6764 preserved. The MSR written is returned. The caller must either guarantee
6765 that Index and the data written is valid, or the caller must set up exception
6766 handlers to catch the exceptions. This function is only available on IA-32 and x64.
6768 If StartBit is greater than 63, then ASSERT().
6769 If EndBit is greater than 63, then ASSERT().
6770 If EndBit is less than StartBit, then ASSERT().
6771 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6773 @param Index The 32-bit MSR index to write.
6774 @param StartBit The ordinal of the least significant bit in the bit field.
6776 @param EndBit The ordinal of the most significant bit in the bit field.
6778 @param Value New value of the bit field.
6780 @return The value written back to the MSR.
6785 AsmMsrBitFieldWrite64 (
6794 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and
6795 writes the result back to the bit field in the 64-bit MSR.
6797 Reads the 64-bit MSR specified by Index, performs a bitwise OR
6798 between the read result and the value specified by OrData, and writes the
6799 result to the 64-bit MSR specified by Index. The value written to the MSR is
6800 returned. Extra left bits in OrData are stripped. The caller must either
6801 guarantee that Index and the data written is valid, or the caller must set up
6802 exception handlers to catch the exceptions. This function is only available
6805 If StartBit is greater than 63, then ASSERT().
6806 If EndBit is greater than 63, then ASSERT().
6807 If EndBit is less than StartBit, then ASSERT().
6808 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6810 @param Index The 32-bit MSR index to write.
6811 @param StartBit The ordinal of the least significant bit in the bit field.
6813 @param EndBit The ordinal of the most significant bit in the bit field.
6815 @param OrData The value to OR with the read value from the bit field.
6817 @return The value written back to the MSR.
6822 AsmMsrBitFieldOr64 (
6831 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
6832 result back to the bit field in the 64-bit MSR.
6834 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
6835 read result and the value specified by AndData, and writes the result to the
6836 64-bit MSR specified by Index. The value written to the MSR is returned.
6837 Extra left bits in AndData are stripped. The caller must either guarantee
6838 that Index and the data written is valid, or the caller must set up exception
6839 handlers to catch the exceptions. This function is only available on IA-32
6842 If StartBit is greater than 63, then ASSERT().
6843 If EndBit is greater than 63, then ASSERT().
6844 If EndBit is less than StartBit, then ASSERT().
6845 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6847 @param Index The 32-bit MSR index to write.
6848 @param StartBit The ordinal of the least significant bit in the bit field.
6850 @param EndBit The ordinal of the most significant bit in the bit field.
6852 @param AndData The value to AND with the read value from the bit field.
6854 @return The value written back to the MSR.
6859 AsmMsrBitFieldAnd64 (
6868 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
6869 bitwise OR, and writes the result back to the bit field in the
6872 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
6873 a bitwise OR between the read result and the value specified by
6874 AndData, and writes the result to the 64-bit MSR specified by Index. The
6875 value written to the MSR is returned. Extra left bits in both AndData and
6876 OrData are stripped. The caller must either guarantee that Index and the data
6877 written is valid, or the caller must set up exception handlers to catch the
6878 exceptions. This function is only available on IA-32 and x64.
6880 If StartBit is greater than 63, then ASSERT().
6881 If EndBit is greater than 63, then ASSERT().
6882 If EndBit is less than StartBit, then ASSERT().
6883 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6884 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6886 @param Index The 32-bit MSR index to write.
6887 @param StartBit The ordinal of the least significant bit in the bit field.
6889 @param EndBit The ordinal of the most significant bit in the bit field.
6891 @param AndData The value to AND with the read value from the bit field.
6892 @param OrData The value to OR with the result of the AND operation.
6894 @return The value written back to the MSR.
6899 AsmMsrBitFieldAndThenOr64 (
6909 Reads the current value of the EFLAGS register.
6911 Reads and returns the current value of the EFLAGS register. This function is
6912 only available on IA-32 and x64. This returns a 32-bit value on IA-32 and a
6913 64-bit value on x64.
6915 @return EFLAGS on IA-32 or RFLAGS on x64.
6926 Reads the current value of the Control Register 0 (CR0).
6928 Reads and returns the current value of CR0. This function is only available
6929 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6932 @return The value of the Control Register 0 (CR0).
6943 Reads the current value of the Control Register 2 (CR2).
6945 Reads and returns the current value of CR2. This function is only available
6946 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6949 @return The value of the Control Register 2 (CR2).
6960 Reads the current value of the Control Register 3 (CR3).
6962 Reads and returns the current value of CR3. This function is only available
6963 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6966 @return The value of the Control Register 3 (CR3).
6977 Reads the current value of the Control Register 4 (CR4).
6979 Reads and returns the current value of CR4. This function is only available
6980 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6983 @return The value of the Control Register 4 (CR4).
6994 Writes a value to Control Register 0 (CR0).
6996 Writes and returns a new value to CR0. This function is only available on
6997 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6999 @param Cr0 The value to write to CR0.
7001 @return The value written to CR0.
7012 Writes a value to Control Register 2 (CR2).
7014 Writes and returns a new value to CR2. This function is only available on
7015 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
7017 @param Cr2 The value to write to CR2.
7019 @return The value written to CR2.
7030 Writes a value to Control Register 3 (CR3).
7032 Writes and returns a new value to CR3. This function is only available on
7033 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
7035 @param Cr3 The value to write to CR3.
7037 @return The value written to CR3.
7048 Writes a value to Control Register 4 (CR4).
7050 Writes and returns a new value to CR4. This function is only available on
7051 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
7053 @param Cr4 The value to write to CR4.
7055 @return The value written to CR4.
7066 Reads the current value of Debug Register 0 (DR0).
7068 Reads and returns the current value of DR0. This function is only available
7069 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
7072 @return The value of Debug Register 0 (DR0).
7083 Reads the current value of Debug Register 1 (DR1).
7085 Reads and returns the current value of DR1. This function is only available
7086 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
7089 @return The value of Debug Register 1 (DR1).
7100 Reads the current value of Debug Register 2 (DR2).
7102 Reads and returns the current value of DR2. This function is only available
7103 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
7106 @return The value of Debug Register 2 (DR2).
7117 Reads the current value of Debug Register 3 (DR3).
7119 Reads and returns the current value of DR3. This function is only available
7120 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
7123 @return The value of Debug Register 3 (DR3).
7134 Reads the current value of Debug Register 4 (DR4).
7136 Reads and returns the current value of DR4. This function is only available
7137 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
7140 @return The value of Debug Register 4 (DR4).
7151 Reads the current value of Debug Register 5 (DR5).
7153 Reads and returns the current value of DR5. This function is only available
7154 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
7157 @return The value of Debug Register 5 (DR5).
7168 Reads the current value of Debug Register 6 (DR6).
7170 Reads and returns the current value of DR6. This function is only available
7171 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
7174 @return The value of Debug Register 6 (DR6).
7185 Reads the current value of Debug Register 7 (DR7).
7187 Reads and returns the current value of DR7. This function is only available
7188 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
7191 @return The value of Debug Register 7 (DR7).
7202 Writes a value to Debug Register 0 (DR0).
7204 Writes and returns a new value to DR0. This function is only available on
7205 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
7207 @param Dr0 The value to write to Dr0.
7209 @return The value written to Debug Register 0 (DR0).
7220 Writes a value to Debug Register 1 (DR1).
7222 Writes and returns a new value to DR1. This function is only available on
7223 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
7225 @param Dr1 The value to write to Dr1.
7227 @return The value written to Debug Register 1 (DR1).
7238 Writes a value to Debug Register 2 (DR2).
7240 Writes and returns a new value to DR2. This function is only available on
7241 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
7243 @param Dr2 The value to write to Dr2.
7245 @return The value written to Debug Register 2 (DR2).
7256 Writes a value to Debug Register 3 (DR3).
7258 Writes and returns a new value to DR3. This function is only available on
7259 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
7261 @param Dr3 The value to write to Dr3.
7263 @return The value written to Debug Register 3 (DR3).
7274 Writes a value to Debug Register 4 (DR4).
7276 Writes and returns a new value to DR4. This function is only available on
7277 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
7279 @param Dr4 The value to write to Dr4.
7281 @return The value written to Debug Register 4 (DR4).
7292 Writes a value to Debug Register 5 (DR5).
7294 Writes and returns a new value to DR5. This function is only available on
7295 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
7297 @param Dr5 The value to write to Dr5.
7299 @return The value written to Debug Register 5 (DR5).
7310 Writes a value to Debug Register 6 (DR6).
7312 Writes and returns a new value to DR6. This function is only available on
7313 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
7315 @param Dr6 The value to write to Dr6.
7317 @return The value written to Debug Register 6 (DR6).
7328 Writes a value to Debug Register 7 (DR7).
7330 Writes and returns a new value to DR7. This function is only available on
7331 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
7333 @param Dr7 The value to write to Dr7.
7335 @return The value written to Debug Register 7 (DR7).
7346 Reads the current value of Code Segment Register (CS).
7348 Reads and returns the current value of CS. This function is only available on
7351 @return The current value of CS.
7362 Reads the current value of Data Segment Register (DS).
7364 Reads and returns the current value of DS. This function is only available on
7367 @return The current value of DS.
7378 Reads the current value of Extra Segment Register (ES).
7380 Reads and returns the current value of ES. This function is only available on
7383 @return The current value of ES.
7394 Reads the current value of FS Data Segment Register (FS).
7396 Reads and returns the current value of FS. This function is only available on
7399 @return The current value of FS.
7410 Reads the current value of GS Data Segment Register (GS).
7412 Reads and returns the current value of GS. This function is only available on
7415 @return The current value of GS.
7426 Reads the current value of Stack Segment Register (SS).
7428 Reads and returns the current value of SS. This function is only available on
7431 @return The current value of SS.
7442 Reads the current value of Task Register (TR).
7444 Reads and returns the current value of TR. This function is only available on
7447 @return The current value of TR.
7458 Reads the current Global Descriptor Table Register(GDTR) descriptor.
7460 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
7461 function is only available on IA-32 and x64.
7463 If Gdtr is NULL, then ASSERT().
7465 @param Gdtr The pointer to a GDTR descriptor.
7471 OUT IA32_DESCRIPTOR
*Gdtr
7476 Writes the current Global Descriptor Table Register (GDTR) descriptor.
7478 Writes and the current GDTR descriptor specified by Gdtr. This function is
7479 only available on IA-32 and x64.
7481 If Gdtr is NULL, then ASSERT().
7483 @param Gdtr The pointer to a GDTR descriptor.
7489 IN CONST IA32_DESCRIPTOR
*Gdtr
7494 Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.
7496 Reads and returns the current IDTR descriptor and returns it in Idtr. This
7497 function is only available on IA-32 and x64.
7499 If Idtr is NULL, then ASSERT().
7501 @param Idtr The pointer to a IDTR descriptor.
7507 OUT IA32_DESCRIPTOR
*Idtr
7512 Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.
7514 Writes the current IDTR descriptor and returns it in Idtr. This function is
7515 only available on IA-32 and x64.
7517 If Idtr is NULL, then ASSERT().
7519 @param Idtr The pointer to a IDTR descriptor.
7525 IN CONST IA32_DESCRIPTOR
*Idtr
7530 Reads the current Local Descriptor Table Register(LDTR) selector.
7532 Reads and returns the current 16-bit LDTR descriptor value. This function is
7533 only available on IA-32 and x64.
7535 @return The current selector of LDT.
7546 Writes the current Local Descriptor Table Register (LDTR) selector.
7548 Writes and the current LDTR descriptor specified by Ldtr. This function is
7549 only available on IA-32 and x64.
7551 @param Ldtr 16-bit LDTR selector value.
7562 Save the current floating point/SSE/SSE2 context to a buffer.
7564 Saves the current floating point/SSE/SSE2 state to the buffer specified by
7565 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
7566 available on IA-32 and x64.
7568 If Buffer is NULL, then ASSERT().
7569 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
7571 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
7577 OUT IA32_FX_BUFFER
*Buffer
7582 Restores the current floating point/SSE/SSE2 context from a buffer.
7584 Restores the current floating point/SSE/SSE2 state from the buffer specified
7585 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
7586 only available on IA-32 and x64.
7588 If Buffer is NULL, then ASSERT().
7589 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
7590 If Buffer was not saved with AsmFxSave(), then ASSERT().
7592 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
7598 IN CONST IA32_FX_BUFFER
*Buffer
7603 Reads the current value of 64-bit MMX Register #0 (MM0).
7605 Reads and returns the current value of MM0. This function is only available
7608 @return The current value of MM0.
7619 Reads the current value of 64-bit MMX Register #1 (MM1).
7621 Reads and returns the current value of MM1. This function is only available
7624 @return The current value of MM1.
7635 Reads the current value of 64-bit MMX Register #2 (MM2).
7637 Reads and returns the current value of MM2. This function is only available
7640 @return The current value of MM2.
7651 Reads the current value of 64-bit MMX Register #3 (MM3).
7653 Reads and returns the current value of MM3. This function is only available
7656 @return The current value of MM3.
7667 Reads the current value of 64-bit MMX Register #4 (MM4).
7669 Reads and returns the current value of MM4. This function is only available
7672 @return The current value of MM4.
7683 Reads the current value of 64-bit MMX Register #5 (MM5).
7685 Reads and returns the current value of MM5. This function is only available
7688 @return The current value of MM5.
7699 Reads the current value of 64-bit MMX Register #6 (MM6).
7701 Reads and returns the current value of MM6. This function is only available
7704 @return The current value of MM6.
7715 Reads the current value of 64-bit MMX Register #7 (MM7).
7717 Reads and returns the current value of MM7. This function is only available
7720 @return The current value of MM7.
7731 Writes the current value of 64-bit MMX Register #0 (MM0).
7733 Writes the current value of MM0. This function is only available on IA32 and
7736 @param Value The 64-bit value to write to MM0.
7747 Writes the current value of 64-bit MMX Register #1 (MM1).
7749 Writes the current value of MM1. This function is only available on IA32 and
7752 @param Value The 64-bit value to write to MM1.
7763 Writes the current value of 64-bit MMX Register #2 (MM2).
7765 Writes the current value of MM2. This function is only available on IA32 and
7768 @param Value The 64-bit value to write to MM2.
7779 Writes the current value of 64-bit MMX Register #3 (MM3).
7781 Writes the current value of MM3. This function is only available on IA32 and
7784 @param Value The 64-bit value to write to MM3.
7795 Writes the current value of 64-bit MMX Register #4 (MM4).
7797 Writes the current value of MM4. This function is only available on IA32 and
7800 @param Value The 64-bit value to write to MM4.
7811 Writes the current value of 64-bit MMX Register #5 (MM5).
7813 Writes the current value of MM5. This function is only available on IA32 and
7816 @param Value The 64-bit value to write to MM5.
7827 Writes the current value of 64-bit MMX Register #6 (MM6).
7829 Writes the current value of MM6. This function is only available on IA32 and
7832 @param Value The 64-bit value to write to MM6.
7843 Writes the current value of 64-bit MMX Register #7 (MM7).
7845 Writes the current value of MM7. This function is only available on IA32 and
7848 @param Value The 64-bit value to write to MM7.
7859 Reads the current value of Time Stamp Counter (TSC).
7861 Reads and returns the current value of TSC. This function is only available
7864 @return The current value of TSC
7875 Reads the current value of a Performance Counter (PMC).
7877 Reads and returns the current value of performance counter specified by
7878 Index. This function is only available on IA-32 and x64.
7880 @param Index The 32-bit Performance Counter index to read.
7882 @return The value of the PMC specified by Index.
7893 Sets up a monitor buffer that is used by AsmMwait().
7895 Executes a MONITOR instruction with the register state specified by Eax, Ecx
7896 and Edx. Returns Eax. This function is only available on IA-32 and x64.
7898 @param Eax The value to load into EAX or RAX before executing the MONITOR
7900 @param Ecx The value to load into ECX or RCX before executing the MONITOR
7902 @param Edx The value to load into EDX or RDX before executing the MONITOR
7918 Executes an MWAIT instruction.
7920 Executes an MWAIT instruction with the register state specified by Eax and
7921 Ecx. Returns Eax. This function is only available on IA-32 and x64.
7923 @param Eax The value to load into EAX or RAX before executing the MONITOR
7925 @param Ecx The value to load into ECX or RCX before executing the MONITOR
7940 Executes a WBINVD instruction.
7942 Executes a WBINVD instruction. This function is only available on IA-32 and
7954 Executes a INVD instruction.
7956 Executes a INVD instruction. This function is only available on IA-32 and
7968 Flushes a cache line from all the instruction and data caches within the
7969 coherency domain of the CPU.
7971 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
7972 This function is only available on IA-32 and x64.
7974 @param LinearAddress The address of the cache line to flush. If the CPU is
7975 in a physical addressing mode, then LinearAddress is a
7976 physical address. If the CPU is in a virtual
7977 addressing mode, then LinearAddress is a virtual
7980 @return LinearAddress.
7985 IN VOID
*LinearAddress
7990 Enables the 32-bit paging mode on the CPU.
7992 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
7993 must be properly initialized prior to calling this service. This function
7994 assumes the current execution mode is 32-bit protected mode. This function is
7995 only available on IA-32. After the 32-bit paging mode is enabled, control is
7996 transferred to the function specified by EntryPoint using the new stack
7997 specified by NewStack and passing in the parameters specified by Context1 and
7998 Context2. Context1 and Context2 are optional and may be NULL. The function
7999 EntryPoint must never return.
8001 If the current execution mode is not 32-bit protected mode, then ASSERT().
8002 If EntryPoint is NULL, then ASSERT().
8003 If NewStack is NULL, then ASSERT().
8005 There are a number of constraints that must be followed before calling this
8007 1) Interrupts must be disabled.
8008 2) The caller must be in 32-bit protected mode with flat descriptors. This
8009 means all descriptors must have a base of 0 and a limit of 4GB.
8010 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
8012 4) CR3 must point to valid page tables that will be used once the transition
8013 is complete, and those page tables must guarantee that the pages for this
8014 function and the stack are identity mapped.
8016 @param EntryPoint A pointer to function to call with the new stack after
8018 @param Context1 A pointer to the context to pass into the EntryPoint
8019 function as the first parameter after paging is enabled.
8020 @param Context2 A pointer to the context to pass into the EntryPoint
8021 function as the second parameter after paging is enabled.
8022 @param NewStack A pointer to the new stack to use for the EntryPoint
8023 function after paging is enabled.
8029 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
8030 IN VOID
*Context1
, OPTIONAL
8031 IN VOID
*Context2
, OPTIONAL
8037 Disables the 32-bit paging mode on the CPU.
8039 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
8040 mode. This function assumes the current execution mode is 32-paged protected
8041 mode. This function is only available on IA-32. After the 32-bit paging mode
8042 is disabled, control is transferred to the function specified by EntryPoint
8043 using the new stack specified by NewStack and passing in the parameters
8044 specified by Context1 and Context2. Context1 and Context2 are optional and
8045 may be NULL. The function EntryPoint must never return.
8047 If the current execution mode is not 32-bit paged mode, then ASSERT().
8048 If EntryPoint is NULL, then ASSERT().
8049 If NewStack is NULL, then ASSERT().
8051 There are a number of constraints that must be followed before calling this
8053 1) Interrupts must be disabled.
8054 2) The caller must be in 32-bit paged mode.
8055 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
8056 4) CR3 must point to valid page tables that guarantee that the pages for
8057 this function and the stack are identity mapped.
8059 @param EntryPoint A pointer to function to call with the new stack after
8061 @param Context1 A pointer to the context to pass into the EntryPoint
8062 function as the first parameter after paging is disabled.
8063 @param Context2 A pointer to the context to pass into the EntryPoint
8064 function as the second parameter after paging is
8066 @param NewStack A pointer to the new stack to use for the EntryPoint
8067 function after paging is disabled.
8072 AsmDisablePaging32 (
8073 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
8074 IN VOID
*Context1
, OPTIONAL
8075 IN VOID
*Context2
, OPTIONAL
8081 Enables the 64-bit paging mode on the CPU.
8083 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
8084 must be properly initialized prior to calling this service. This function
8085 assumes the current execution mode is 32-bit protected mode with flat
8086 descriptors. This function is only available on IA-32. After the 64-bit
8087 paging mode is enabled, control is transferred to the function specified by
8088 EntryPoint using the new stack specified by NewStack and passing in the
8089 parameters specified by Context1 and Context2. Context1 and Context2 are
8090 optional and may be 0. The function EntryPoint must never return.
8092 If the current execution mode is not 32-bit protected mode with flat
8093 descriptors, then ASSERT().
8094 If EntryPoint is 0, then ASSERT().
8095 If NewStack is 0, then ASSERT().
8097 @param Cs The 16-bit selector to load in the CS before EntryPoint
8098 is called. The descriptor in the GDT that this selector
8099 references must be setup for long mode.
8100 @param EntryPoint The 64-bit virtual address of the function to call with
8101 the new stack after paging is enabled.
8102 @param Context1 The 64-bit virtual address of the context to pass into
8103 the EntryPoint function as the first parameter after
8105 @param Context2 The 64-bit virtual address of the context to pass into
8106 the EntryPoint function as the second parameter after
8108 @param NewStack The 64-bit virtual address of the new stack to use for
8109 the EntryPoint function after paging is enabled.
8116 IN UINT64 EntryPoint
,
8117 IN UINT64 Context1
, OPTIONAL
8118 IN UINT64 Context2
, OPTIONAL
8124 Disables the 64-bit paging mode on the CPU.
8126 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
8127 mode. This function assumes the current execution mode is 64-paging mode.
8128 This function is only available on x64. After the 64-bit paging mode is
8129 disabled, control is transferred to the function specified by EntryPoint
8130 using the new stack specified by NewStack and passing in the parameters
8131 specified by Context1 and Context2. Context1 and Context2 are optional and
8132 may be 0. The function EntryPoint must never return.
8134 If the current execution mode is not 64-bit paged mode, then ASSERT().
8135 If EntryPoint is 0, then ASSERT().
8136 If NewStack is 0, then ASSERT().
8138 @param Cs The 16-bit selector to load in the CS before EntryPoint
8139 is called. The descriptor in the GDT that this selector
8140 references must be setup for 32-bit protected mode.
8141 @param EntryPoint The 64-bit virtual address of the function to call with
8142 the new stack after paging is disabled.
8143 @param Context1 The 64-bit virtual address of the context to pass into
8144 the EntryPoint function as the first parameter after
8146 @param Context2 The 64-bit virtual address of the context to pass into
8147 the EntryPoint function as the second parameter after
8149 @param NewStack The 64-bit virtual address of the new stack to use for
8150 the EntryPoint function after paging is disabled.
8155 AsmDisablePaging64 (
8157 IN UINT32 EntryPoint
,
8158 IN UINT32 Context1
, OPTIONAL
8159 IN UINT32 Context2
, OPTIONAL
8165 // 16-bit thunking services
8169 Retrieves the properties for 16-bit thunk functions.
8171 Computes the size of the buffer and stack below 1MB required to use the
8172 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
8173 buffer size is returned in RealModeBufferSize, and the stack size is returned
8174 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
8175 then the actual minimum stack size is ExtraStackSize plus the maximum number
8176 of bytes that need to be passed to the 16-bit real mode code.
8178 If RealModeBufferSize is NULL, then ASSERT().
8179 If ExtraStackSize is NULL, then ASSERT().
8181 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
8182 required to use the 16-bit thunk functions.
8183 @param ExtraStackSize A pointer to the extra size of stack below 1MB
8184 that the 16-bit thunk functions require for
8185 temporary storage in the transition to and from
8191 AsmGetThunk16Properties (
8192 OUT UINT32
*RealModeBufferSize
,
8193 OUT UINT32
*ExtraStackSize
8198 Prepares all structures a code required to use AsmThunk16().
8200 Prepares all structures and code required to use AsmThunk16().
8202 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
8203 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
8205 If ThunkContext is NULL, then ASSERT().
8207 @param ThunkContext A pointer to the context structure that describes the
8208 16-bit real mode code to call.
8214 IN OUT THUNK_CONTEXT
*ThunkContext
8219 Transfers control to a 16-bit real mode entry point and returns the results.
8221 Transfers control to a 16-bit real mode entry point and returns the results.
8222 AsmPrepareThunk16() must be called with ThunkContext before this function is used.
8223 This function must be called with interrupts disabled.
8225 The register state from the RealModeState field of ThunkContext is restored just prior
8226 to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState,
8227 which is used to set the interrupt state when a 16-bit real mode entry point is called.
8228 Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.
8229 The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to
8230 the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function.
8231 The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,
8232 so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment
8233 and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry
8234 point must exit with a RETF instruction. The register state is captured into RealModeState immediately
8235 after the RETF instruction is executed.
8237 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
8238 or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure
8239 the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode.
8241 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
8242 then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode.
8243 This includes the base vectors, the interrupt masks, and the edge/level trigger mode.
8245 If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code
8246 is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.
8248 If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
8249 ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to
8250 disable the A20 mask.
8252 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in
8253 ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails,
8254 then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
8256 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in
8257 ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
8259 If ThunkContext is NULL, then ASSERT().
8260 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
8261 If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
8262 ThunkAttributes, then ASSERT().
8264 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
8265 virtual to physical mappings for ThunkContext.RealModeBuffer are mapped 1:1.
8267 @param ThunkContext A pointer to the context structure that describes the
8268 16-bit real mode code to call.
8274 IN OUT THUNK_CONTEXT
*ThunkContext
8279 Prepares all structures and code for a 16-bit real mode thunk, transfers
8280 control to a 16-bit real mode entry point, and returns the results.
8282 Prepares all structures and code for a 16-bit real mode thunk, transfers
8283 control to a 16-bit real mode entry point, and returns the results. If the
8284 caller only need to perform a single 16-bit real mode thunk, then this
8285 service should be used. If the caller intends to make more than one 16-bit
8286 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
8287 once and AsmThunk16() can be called for each 16-bit real mode thunk.
8289 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
8290 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
8292 See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.
8294 @param ThunkContext A pointer to the context structure that describes the
8295 16-bit real mode code to call.
8300 AsmPrepareAndThunk16 (
8301 IN OUT THUNK_CONTEXT
*ThunkContext
8305 Generates a 16-bit random number through RDRAND instruction.
8307 if Rand is NULL, then ASSERT().
8309 @param[out] Rand Buffer pointer to store the random result.
8311 @retval TRUE RDRAND call was successful.
8312 @retval FALSE Failed attempts to call RDRAND.
8322 Generates a 32-bit random number through RDRAND instruction.
8324 if Rand is NULL, then ASSERT().
8326 @param[out] Rand Buffer pointer to store the random result.
8328 @retval TRUE RDRAND call was successful.
8329 @retval FALSE Failed attempts to call RDRAND.
8339 Generates a 64-bit random number through RDRAND instruction.
8341 if Rand is NULL, then ASSERT().
8343 @param[out] Rand Buffer pointer to store the random result.
8345 @retval TRUE RDRAND call was successful.
8346 @retval FALSE Failed attempts to call RDRAND.