2 Provides string functions, linked list functions, math functions, synchronization
3 functions, file path functions, and CPU architecture-specific functions.
5 Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
6 Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
7 Copyright (c) Microsoft Corporation.<BR>
8 SPDX-License-Identifier: BSD-2-Clause-Patent
16 // Definitions for architecture-specific types
18 #if defined (MDE_CPU_IA32)
20 /// The IA-32 architecture context buffer used by SetJump() and LongJump().
30 } BASE_LIBRARY_JUMP_BUFFER
;
32 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4
34 #endif // defined (MDE_CPU_IA32)
36 #if defined (MDE_CPU_X64)
38 /// The x64 architecture context buffer used by SetJump() and LongJump().
52 UINT8 XmmBuffer
[160]; ///< XMM6-XMM15.
54 } BASE_LIBRARY_JUMP_BUFFER
;
56 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
58 #endif // defined (MDE_CPU_X64)
60 #if defined (MDE_CPU_EBC)
62 /// The EBC context buffer used by SetJump() and LongJump().
70 } BASE_LIBRARY_JUMP_BUFFER
;
72 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
74 #endif // defined (MDE_CPU_EBC)
76 #if defined (MDE_CPU_ARM)
79 UINT32 R3
; ///< A copy of R13.
90 } BASE_LIBRARY_JUMP_BUFFER
;
92 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4
94 #endif // defined (MDE_CPU_ARM)
96 #if defined (MDE_CPU_AARCH64)
122 } BASE_LIBRARY_JUMP_BUFFER
;
124 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
126 #endif // defined (MDE_CPU_AARCH64)
135 Returns the length of a Null-terminated Unicode string.
137 This function is similar as strlen_s defined in C11.
139 If String is not aligned on a 16-bit boundary, then ASSERT().
141 @param String A pointer to a Null-terminated Unicode string.
142 @param MaxSize The maximum number of Destination Unicode
143 char, including terminating null char.
145 @retval 0 If String is NULL.
146 @retval MaxSize If there is no null character in the first MaxSize characters of String.
147 @return The number of characters that percede the terminating null character.
153 IN CONST CHAR16
*String
,
158 Returns the size of a Null-terminated Unicode string in bytes, including the
161 This function returns the size of the Null-terminated Unicode string
162 specified by String in bytes, including the Null terminator.
164 If String is not aligned on a 16-bit boundary, then ASSERT().
166 @param String A pointer to a Null-terminated Unicode string.
167 @param MaxSize The maximum number of Destination Unicode
168 char, including the Null terminator.
170 @retval 0 If String is NULL.
171 @retval (sizeof (CHAR16) * (MaxSize + 1))
172 If there is no Null terminator in the first MaxSize characters of
174 @return The size of the Null-terminated Unicode string in bytes, including
181 IN CONST CHAR16
*String
,
186 Copies the string pointed to by Source (including the terminating null char)
187 to the array pointed to by Destination.
189 This function is similar as strcpy_s defined in C11.
191 If Destination is not aligned on a 16-bit boundary, then ASSERT().
192 If Source is not aligned on a 16-bit boundary, then ASSERT().
193 If an error would be returned, then the function will also ASSERT().
195 If an error is returned, then the Destination is unmodified.
197 @param Destination A pointer to a Null-terminated Unicode string.
198 @param DestMax The maximum number of Destination Unicode
199 char, including terminating null char.
200 @param Source A pointer to a Null-terminated Unicode string.
202 @retval RETURN_SUCCESS String is copied.
203 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
204 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
206 If PcdMaximumUnicodeStringLength is not zero,
207 and DestMax is greater than
208 PcdMaximumUnicodeStringLength.
210 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
215 OUT CHAR16
*Destination
,
217 IN CONST CHAR16
*Source
221 Copies not more than Length successive char from the string pointed to by
222 Source to the array pointed to by Destination. If no null char is copied from
223 Source, then Destination[Length] is always set to null.
225 This function is similar as strncpy_s defined in C11.
227 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
228 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
229 If an error would be returned, then the function will also ASSERT().
231 If an error is returned, then the Destination is unmodified.
233 @param Destination A pointer to a Null-terminated Unicode string.
234 @param DestMax The maximum number of Destination Unicode
235 char, including terminating null char.
236 @param Source A pointer to a Null-terminated Unicode string.
237 @param Length The maximum number of Unicode characters to copy.
239 @retval RETURN_SUCCESS String is copied.
240 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than
241 MIN(StrLen(Source), Length).
242 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
244 If PcdMaximumUnicodeStringLength is not zero,
245 and DestMax is greater than
246 PcdMaximumUnicodeStringLength.
248 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
253 OUT CHAR16
*Destination
,
255 IN CONST CHAR16
*Source
,
260 Appends a copy of the string pointed to by Source (including the terminating
261 null char) to the end of the string pointed to by Destination.
263 This function is similar as strcat_s defined in C11.
265 If Destination is not aligned on a 16-bit boundary, then ASSERT().
266 If Source is not aligned on a 16-bit boundary, then ASSERT().
267 If an error would be returned, then the function will also ASSERT().
269 If an error is returned, then the Destination is unmodified.
271 @param Destination A pointer to a Null-terminated Unicode string.
272 @param DestMax The maximum number of Destination Unicode
273 char, including terminating null char.
274 @param Source A pointer to a Null-terminated Unicode string.
276 @retval RETURN_SUCCESS String is appended.
277 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
279 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
280 greater than StrLen(Source).
281 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
283 If PcdMaximumUnicodeStringLength is not zero,
284 and DestMax is greater than
285 PcdMaximumUnicodeStringLength.
287 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
292 IN OUT CHAR16
*Destination
,
294 IN CONST CHAR16
*Source
298 Appends not more than Length successive char from the string pointed to by
299 Source to the end of the string pointed to by Destination. If no null char is
300 copied from Source, then Destination[StrLen(Destination) + Length] is always
303 This function is similar as strncat_s defined in C11.
305 If Destination is not aligned on a 16-bit boundary, then ASSERT().
306 If Source is not aligned on a 16-bit boundary, then ASSERT().
307 If an error would be returned, then the function will also ASSERT().
309 If an error is returned, then the Destination is unmodified.
311 @param Destination A pointer to a Null-terminated Unicode string.
312 @param DestMax The maximum number of Destination Unicode
313 char, including terminating null char.
314 @param Source A pointer to a Null-terminated Unicode string.
315 @param Length The maximum number of Unicode characters to copy.
317 @retval RETURN_SUCCESS String is appended.
318 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
320 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
321 greater than MIN(StrLen(Source), Length).
322 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
324 If PcdMaximumUnicodeStringLength is not zero,
325 and DestMax is greater than
326 PcdMaximumUnicodeStringLength.
328 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
333 IN OUT CHAR16
*Destination
,
335 IN CONST CHAR16
*Source
,
340 Convert a Null-terminated Unicode decimal string to a value of type UINTN.
342 This function outputs a value of type UINTN by interpreting the contents of
343 the Unicode string specified by String as a decimal number. The format of the
344 input Unicode string String is:
346 [spaces] [decimal digits].
348 The valid decimal digit character is in the range [0-9]. The function will
349 ignore the pad space, which includes spaces or tab characters, before
350 [decimal digits]. The running zero in the beginning of [decimal digits] will
351 be ignored. Then, the function stops at the first character that is a not a
352 valid decimal character or a Null-terminator, whichever one comes first.
354 If String is NULL, then ASSERT().
355 If Data is NULL, then ASSERT().
356 If String is not aligned in a 16-bit boundary, then ASSERT().
357 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
358 PcdMaximumUnicodeStringLength Unicode characters, not including the
359 Null-terminator, then ASSERT().
361 If String has no valid decimal digits in the above format, then 0 is stored
362 at the location pointed to by Data.
363 If the number represented by String exceeds the range defined by UINTN, then
364 MAX_UINTN is stored at the location pointed to by Data.
366 If EndPointer is not NULL, a pointer to the character that stopped the scan
367 is stored at the location pointed to by EndPointer. If String has no valid
368 decimal digits right after the optional pad spaces, the value of String is
369 stored at the location pointed to by EndPointer.
371 @param String Pointer to a Null-terminated Unicode string.
372 @param EndPointer Pointer to character that stops scan.
373 @param Data Pointer to the converted value.
375 @retval RETURN_SUCCESS Value is translated from String.
376 @retval RETURN_INVALID_PARAMETER If String is NULL.
378 If PcdMaximumUnicodeStringLength is not
379 zero, and String contains more than
380 PcdMaximumUnicodeStringLength Unicode
381 characters, not including the
383 @retval RETURN_UNSUPPORTED If the number represented by String exceeds
384 the range defined by UINTN.
390 IN CONST CHAR16
*String
,
391 OUT CHAR16
**EndPointer
, OPTIONAL
396 Convert a Null-terminated Unicode decimal string to a value of type UINT64.
398 This function outputs a value of type UINT64 by interpreting the contents of
399 the Unicode string specified by String as a decimal number. The format of the
400 input Unicode string String is:
402 [spaces] [decimal digits].
404 The valid decimal digit character is in the range [0-9]. The function will
405 ignore the pad space, which includes spaces or tab characters, before
406 [decimal digits]. The running zero in the beginning of [decimal digits] will
407 be ignored. Then, the function stops at the first character that is a not a
408 valid decimal character or a Null-terminator, whichever one comes first.
410 If String is NULL, then ASSERT().
411 If Data is NULL, then ASSERT().
412 If String is not aligned in a 16-bit boundary, then ASSERT().
413 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
414 PcdMaximumUnicodeStringLength Unicode characters, not including the
415 Null-terminator, then ASSERT().
417 If String has no valid decimal digits in the above format, then 0 is stored
418 at the location pointed to by Data.
419 If the number represented by String exceeds the range defined by UINT64, then
420 MAX_UINT64 is stored at the location pointed to by Data.
422 If EndPointer is not NULL, a pointer to the character that stopped the scan
423 is stored at the location pointed to by EndPointer. If String has no valid
424 decimal digits right after the optional pad spaces, the value of String is
425 stored at the location pointed to by EndPointer.
427 @param String Pointer to a Null-terminated Unicode string.
428 @param EndPointer Pointer to character that stops scan.
429 @param Data Pointer to the converted value.
431 @retval RETURN_SUCCESS Value is translated from String.
432 @retval RETURN_INVALID_PARAMETER If String is NULL.
434 If PcdMaximumUnicodeStringLength is not
435 zero, and String contains more than
436 PcdMaximumUnicodeStringLength Unicode
437 characters, not including the
439 @retval RETURN_UNSUPPORTED If the number represented by String exceeds
440 the range defined by UINT64.
445 StrDecimalToUint64S (
446 IN CONST CHAR16
*String
,
447 OUT CHAR16
**EndPointer
, OPTIONAL
452 Convert a Null-terminated Unicode hexadecimal string to a value of type
455 This function outputs a value of type UINTN by interpreting the contents of
456 the Unicode string specified by String as a hexadecimal number. The format of
457 the input Unicode string String is:
459 [spaces][zeros][x][hexadecimal digits].
461 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
462 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
463 If "x" appears in the input string, it must be prefixed with at least one 0.
464 The function will ignore the pad space, which includes spaces or tab
465 characters, before [zeros], [x] or [hexadecimal digit]. The running zero
466 before [x] or [hexadecimal digit] will be ignored. Then, the decoding starts
467 after [x] or the first valid hexadecimal digit. Then, the function stops at
468 the first character that is a not a valid hexadecimal character or NULL,
469 whichever one comes first.
471 If String is NULL, then ASSERT().
472 If Data is NULL, then ASSERT().
473 If String is not aligned in a 16-bit boundary, then ASSERT().
474 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
475 PcdMaximumUnicodeStringLength Unicode characters, not including the
476 Null-terminator, then ASSERT().
478 If String has no valid hexadecimal digits in the above format, then 0 is
479 stored at the location pointed to by Data.
480 If the number represented by String exceeds the range defined by UINTN, then
481 MAX_UINTN is stored at the location pointed to by Data.
483 If EndPointer is not NULL, a pointer to the character that stopped the scan
484 is stored at the location pointed to by EndPointer. If String has no valid
485 hexadecimal digits right after the optional pad spaces, the value of String
486 is stored at the location pointed to by EndPointer.
488 @param String Pointer to a Null-terminated Unicode string.
489 @param EndPointer Pointer to character that stops scan.
490 @param Data Pointer to the converted value.
492 @retval RETURN_SUCCESS Value is translated from String.
493 @retval RETURN_INVALID_PARAMETER If String is NULL.
495 If PcdMaximumUnicodeStringLength is not
496 zero, and String contains more than
497 PcdMaximumUnicodeStringLength Unicode
498 characters, not including the
500 @retval RETURN_UNSUPPORTED If the number represented by String exceeds
501 the range defined by UINTN.
507 IN CONST CHAR16
*String
,
508 OUT CHAR16
**EndPointer
, OPTIONAL
513 Convert a Null-terminated Unicode hexadecimal string to a value of type
516 This function outputs a value of type UINT64 by interpreting the contents of
517 the Unicode string specified by String as a hexadecimal number. The format of
518 the input Unicode string String is:
520 [spaces][zeros][x][hexadecimal digits].
522 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
523 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
524 If "x" appears in the input string, it must be prefixed with at least one 0.
525 The function will ignore the pad space, which includes spaces or tab
526 characters, before [zeros], [x] or [hexadecimal digit]. The running zero
527 before [x] or [hexadecimal digit] will be ignored. Then, the decoding starts
528 after [x] or the first valid hexadecimal digit. Then, the function stops at
529 the first character that is a not a valid hexadecimal character or NULL,
530 whichever one comes first.
532 If String is NULL, then ASSERT().
533 If Data is NULL, then ASSERT().
534 If String is not aligned in a 16-bit boundary, then ASSERT().
535 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
536 PcdMaximumUnicodeStringLength Unicode characters, not including the
537 Null-terminator, then ASSERT().
539 If String has no valid hexadecimal digits in the above format, then 0 is
540 stored at the location pointed to by Data.
541 If the number represented by String exceeds the range defined by UINT64, then
542 MAX_UINT64 is stored at the location pointed to by Data.
544 If EndPointer is not NULL, a pointer to the character that stopped the scan
545 is stored at the location pointed to by EndPointer. If String has no valid
546 hexadecimal digits right after the optional pad spaces, the value of String
547 is stored at the location pointed to by EndPointer.
549 @param String Pointer to a Null-terminated Unicode string.
550 @param EndPointer Pointer to character that stops scan.
551 @param Data Pointer to the converted value.
553 @retval RETURN_SUCCESS Value is translated from String.
554 @retval RETURN_INVALID_PARAMETER If String is NULL.
556 If PcdMaximumUnicodeStringLength is not
557 zero, and String contains more than
558 PcdMaximumUnicodeStringLength Unicode
559 characters, not including the
561 @retval RETURN_UNSUPPORTED If the number represented by String exceeds
562 the range defined by UINT64.
568 IN CONST CHAR16
*String
,
569 OUT CHAR16
**EndPointer
, OPTIONAL
574 Returns the length of a Null-terminated Ascii string.
576 This function is similar as strlen_s defined in C11.
578 @param String A pointer to a Null-terminated Ascii string.
579 @param MaxSize The maximum number of Destination Ascii
580 char, including terminating null char.
582 @retval 0 If String is NULL.
583 @retval MaxSize If there is no null character in the first MaxSize characters of String.
584 @return The number of characters that percede the terminating null character.
590 IN CONST CHAR8
*String
,
595 Returns the size of a Null-terminated Ascii string in bytes, including the
598 This function returns the size of the Null-terminated Ascii string specified
599 by String in bytes, including the Null terminator.
601 @param String A pointer to a Null-terminated Ascii string.
602 @param MaxSize The maximum number of Destination Ascii
603 char, including the Null terminator.
605 @retval 0 If String is NULL.
606 @retval (sizeof (CHAR8) * (MaxSize + 1))
607 If there is no Null terminator in the first MaxSize characters of
609 @return The size of the Null-terminated Ascii string in bytes, including the
616 IN CONST CHAR8
*String
,
621 Copies the string pointed to by Source (including the terminating null char)
622 to the array pointed to by Destination.
624 This function is similar as strcpy_s defined in C11.
626 If an error would be returned, then the function will also ASSERT().
628 If an error is returned, then the Destination is unmodified.
630 @param Destination A pointer to a Null-terminated Ascii string.
631 @param DestMax The maximum number of Destination Ascii
632 char, including terminating null char.
633 @param Source A pointer to a Null-terminated Ascii string.
635 @retval RETURN_SUCCESS String is copied.
636 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
637 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
639 If PcdMaximumAsciiStringLength is not zero,
640 and DestMax is greater than
641 PcdMaximumAsciiStringLength.
643 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
648 OUT CHAR8
*Destination
,
650 IN CONST CHAR8
*Source
654 Copies not more than Length successive char from the string pointed to by
655 Source to the array pointed to by Destination. If no null char is copied from
656 Source, then Destination[Length] is always set to null.
658 This function is similar as strncpy_s defined in C11.
660 If an error would be returned, then the function will also ASSERT().
662 If an error is returned, then the Destination is unmodified.
664 @param Destination A pointer to a Null-terminated Ascii string.
665 @param DestMax The maximum number of Destination Ascii
666 char, including terminating null char.
667 @param Source A pointer to a Null-terminated Ascii string.
668 @param Length The maximum number of Ascii characters to copy.
670 @retval RETURN_SUCCESS String is copied.
671 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than
672 MIN(StrLen(Source), Length).
673 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
675 If PcdMaximumAsciiStringLength is not zero,
676 and DestMax is greater than
677 PcdMaximumAsciiStringLength.
679 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
684 OUT CHAR8
*Destination
,
686 IN CONST CHAR8
*Source
,
691 Appends a copy of the string pointed to by Source (including the terminating
692 null char) to the end of the string pointed to by Destination.
694 This function is similar as strcat_s defined in C11.
696 If an error would be returned, then the function will also ASSERT().
698 If an error is returned, then the Destination is unmodified.
700 @param Destination A pointer to a Null-terminated Ascii string.
701 @param DestMax The maximum number of Destination Ascii
702 char, including terminating null char.
703 @param Source A pointer to a Null-terminated Ascii string.
705 @retval RETURN_SUCCESS String is appended.
706 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
708 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
709 greater than StrLen(Source).
710 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
712 If PcdMaximumAsciiStringLength is not zero,
713 and DestMax is greater than
714 PcdMaximumAsciiStringLength.
716 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
721 IN OUT CHAR8
*Destination
,
723 IN CONST CHAR8
*Source
727 Appends not more than Length successive char from the string pointed to by
728 Source to the end of the string pointed to by Destination. If no null char is
729 copied from Source, then Destination[StrLen(Destination) + Length] is always
732 This function is similar as strncat_s defined in C11.
734 If an error would be returned, then the function will also ASSERT().
736 If an error is returned, then the Destination is unmodified.
738 @param Destination A pointer to a Null-terminated Ascii string.
739 @param DestMax The maximum number of Destination Ascii
740 char, including terminating null char.
741 @param Source A pointer to a Null-terminated Ascii string.
742 @param Length The maximum number of Ascii characters to copy.
744 @retval RETURN_SUCCESS String is appended.
745 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
747 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
748 greater than MIN(StrLen(Source), Length).
749 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
751 If PcdMaximumAsciiStringLength is not zero,
752 and DestMax is greater than
753 PcdMaximumAsciiStringLength.
755 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
760 IN OUT CHAR8
*Destination
,
762 IN CONST CHAR8
*Source
,
767 Convert a Null-terminated Ascii decimal string to a value of type UINTN.
769 This function outputs a value of type UINTN by interpreting the contents of
770 the Ascii string specified by String as a decimal number. The format of the
771 input Ascii string String is:
773 [spaces] [decimal digits].
775 The valid decimal digit character is in the range [0-9]. The function will
776 ignore the pad space, which includes spaces or tab characters, before
777 [decimal digits]. The running zero in the beginning of [decimal digits] will
778 be ignored. Then, the function stops at the first character that is a not a
779 valid decimal character or a Null-terminator, whichever one comes first.
781 If String is NULL, then ASSERT().
782 If Data is NULL, then ASSERT().
783 If PcdMaximumAsciiStringLength is not zero, and String contains more than
784 PcdMaximumAsciiStringLength Ascii characters, not including the
785 Null-terminator, then ASSERT().
787 If String has no valid decimal digits in the above format, then 0 is stored
788 at the location pointed to by Data.
789 If the number represented by String exceeds the range defined by UINTN, then
790 MAX_UINTN is stored at the location pointed to by Data.
792 If EndPointer is not NULL, a pointer to the character that stopped the scan
793 is stored at the location pointed to by EndPointer. If String has no valid
794 decimal digits right after the optional pad spaces, the value of String is
795 stored at the location pointed to by EndPointer.
797 @param String Pointer to a Null-terminated Ascii string.
798 @param EndPointer Pointer to character that stops scan.
799 @param Data Pointer to the converted value.
801 @retval RETURN_SUCCESS Value is translated from String.
802 @retval RETURN_INVALID_PARAMETER If String is NULL.
804 If PcdMaximumAsciiStringLength is not zero,
805 and String contains more than
806 PcdMaximumAsciiStringLength Ascii
807 characters, not including the
809 @retval RETURN_UNSUPPORTED If the number represented by String exceeds
810 the range defined by UINTN.
815 AsciiStrDecimalToUintnS (
816 IN CONST CHAR8
*String
,
817 OUT CHAR8
**EndPointer
, OPTIONAL
822 Convert a Null-terminated Ascii decimal string to a value of type UINT64.
824 This function outputs a value of type UINT64 by interpreting the contents of
825 the Ascii string specified by String as a decimal number. The format of the
826 input Ascii string String is:
828 [spaces] [decimal digits].
830 The valid decimal digit character is in the range [0-9]. The function will
831 ignore the pad space, which includes spaces or tab characters, before
832 [decimal digits]. The running zero in the beginning of [decimal digits] will
833 be ignored. Then, the function stops at the first character that is a not a
834 valid decimal character or a Null-terminator, whichever one comes first.
836 If String is NULL, then ASSERT().
837 If Data is NULL, then ASSERT().
838 If PcdMaximumAsciiStringLength is not zero, and String contains more than
839 PcdMaximumAsciiStringLength Ascii characters, not including the
840 Null-terminator, then ASSERT().
842 If String has no valid decimal digits in the above format, then 0 is stored
843 at the location pointed to by Data.
844 If the number represented by String exceeds the range defined by UINT64, then
845 MAX_UINT64 is stored at the location pointed to by Data.
847 If EndPointer is not NULL, a pointer to the character that stopped the scan
848 is stored at the location pointed to by EndPointer. If String has no valid
849 decimal digits right after the optional pad spaces, the value of String is
850 stored at the location pointed to by EndPointer.
852 @param String Pointer to a Null-terminated Ascii string.
853 @param EndPointer Pointer to character that stops scan.
854 @param Data Pointer to the converted value.
856 @retval RETURN_SUCCESS Value is translated from String.
857 @retval RETURN_INVALID_PARAMETER If String is NULL.
859 If PcdMaximumAsciiStringLength is not zero,
860 and String contains more than
861 PcdMaximumAsciiStringLength Ascii
862 characters, not including the
864 @retval RETURN_UNSUPPORTED If the number represented by String exceeds
865 the range defined by UINT64.
870 AsciiStrDecimalToUint64S (
871 IN CONST CHAR8
*String
,
872 OUT CHAR8
**EndPointer
, OPTIONAL
877 Convert a Null-terminated Ascii hexadecimal string to a value of type UINTN.
879 This function outputs a value of type UINTN by interpreting the contents of
880 the Ascii string specified by String as a hexadecimal number. The format of
881 the input Ascii string String is:
883 [spaces][zeros][x][hexadecimal digits].
885 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
886 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If
887 "x" appears in the input string, it must be prefixed with at least one 0. The
888 function will ignore the pad space, which includes spaces or tab characters,
889 before [zeros], [x] or [hexadecimal digits]. The running zero before [x] or
890 [hexadecimal digits] will be ignored. Then, the decoding starts after [x] or
891 the first valid hexadecimal digit. Then, the function stops at the first
892 character that is a not a valid hexadecimal character or Null-terminator,
893 whichever on comes first.
895 If String is NULL, then ASSERT().
896 If Data is NULL, then ASSERT().
897 If PcdMaximumAsciiStringLength is not zero, and String contains more than
898 PcdMaximumAsciiStringLength Ascii characters, not including the
899 Null-terminator, then ASSERT().
901 If String has no valid hexadecimal digits in the above format, then 0 is
902 stored at the location pointed to by Data.
903 If the number represented by String exceeds the range defined by UINTN, then
904 MAX_UINTN is stored at the location pointed to by Data.
906 If EndPointer is not NULL, a pointer to the character that stopped the scan
907 is stored at the location pointed to by EndPointer. If String has no valid
908 hexadecimal digits right after the optional pad spaces, the value of String
909 is stored at the location pointed to by EndPointer.
911 @param String Pointer to a Null-terminated Ascii string.
912 @param EndPointer Pointer to character that stops scan.
913 @param Data Pointer to the converted value.
915 @retval RETURN_SUCCESS Value is translated from String.
916 @retval RETURN_INVALID_PARAMETER If String is NULL.
918 If PcdMaximumAsciiStringLength is not zero,
919 and String contains more than
920 PcdMaximumAsciiStringLength Ascii
921 characters, not including the
923 @retval RETURN_UNSUPPORTED If the number represented by String exceeds
924 the range defined by UINTN.
929 AsciiStrHexToUintnS (
930 IN CONST CHAR8
*String
,
931 OUT CHAR8
**EndPointer
, OPTIONAL
936 Convert a Null-terminated Ascii hexadecimal string to a value of type UINT64.
938 This function outputs a value of type UINT64 by interpreting the contents of
939 the Ascii string specified by String as a hexadecimal number. The format of
940 the input Ascii string String is:
942 [spaces][zeros][x][hexadecimal digits].
944 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
945 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If
946 "x" appears in the input string, it must be prefixed with at least one 0. The
947 function will ignore the pad space, which includes spaces or tab characters,
948 before [zeros], [x] or [hexadecimal digits]. The running zero before [x] or
949 [hexadecimal digits] will be ignored. Then, the decoding starts after [x] or
950 the first valid hexadecimal digit. Then, the function stops at the first
951 character that is a not a valid hexadecimal character or Null-terminator,
952 whichever on comes first.
954 If String is NULL, then ASSERT().
955 If Data is NULL, then ASSERT().
956 If PcdMaximumAsciiStringLength is not zero, and String contains more than
957 PcdMaximumAsciiStringLength Ascii characters, not including the
958 Null-terminator, then ASSERT().
960 If String has no valid hexadecimal digits in the above format, then 0 is
961 stored at the location pointed to by Data.
962 If the number represented by String exceeds the range defined by UINT64, then
963 MAX_UINT64 is stored at the location pointed to by Data.
965 If EndPointer is not NULL, a pointer to the character that stopped the scan
966 is stored at the location pointed to by EndPointer. If String has no valid
967 hexadecimal digits right after the optional pad spaces, the value of String
968 is stored at the location pointed to by EndPointer.
970 @param String Pointer to a Null-terminated Ascii string.
971 @param EndPointer Pointer to character that stops scan.
972 @param Data Pointer to the converted value.
974 @retval RETURN_SUCCESS Value is translated from String.
975 @retval RETURN_INVALID_PARAMETER If String is NULL.
977 If PcdMaximumAsciiStringLength is not zero,
978 and String contains more than
979 PcdMaximumAsciiStringLength Ascii
980 characters, not including the
982 @retval RETURN_UNSUPPORTED If the number represented by String exceeds
983 the range defined by UINT64.
988 AsciiStrHexToUint64S (
989 IN CONST CHAR8
*String
,
990 OUT CHAR8
**EndPointer
, OPTIONAL
995 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
998 [ATTENTION] This function is deprecated for security reason.
1000 Copies one Null-terminated Unicode string to another Null-terminated Unicode
1001 string and returns the new Unicode string.
1003 This function copies the contents of the Unicode string Source to the Unicode
1004 string Destination, and returns Destination. If Source and Destination
1005 overlap, then the results are undefined.
1007 If Destination is NULL, then ASSERT().
1008 If Destination is not aligned on a 16-bit boundary, then ASSERT().
1009 If Source is NULL, then ASSERT().
1010 If Source is not aligned on a 16-bit boundary, then ASSERT().
1011 If Source and Destination overlap, then ASSERT().
1012 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1013 PcdMaximumUnicodeStringLength Unicode characters not including the
1014 Null-terminator, then ASSERT().
1016 @param Destination The pointer to a Null-terminated Unicode string.
1017 @param Source The pointer to a Null-terminated Unicode string.
1019 @return Destination.
1025 OUT CHAR16
*Destination
,
1026 IN CONST CHAR16
*Source
1031 [ATTENTION] This function is deprecated for security reason.
1033 Copies up to a specified length from one Null-terminated Unicode string to
1034 another Null-terminated Unicode string and returns the new Unicode string.
1036 This function copies the contents of the Unicode string Source to the Unicode
1037 string Destination, and returns Destination. At most, Length Unicode
1038 characters are copied from Source to Destination. If Length is 0, then
1039 Destination is returned unmodified. If Length is greater that the number of
1040 Unicode characters in Source, then Destination is padded with Null Unicode
1041 characters. If Source and Destination overlap, then the results are
1044 If Length > 0 and Destination is NULL, then ASSERT().
1045 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
1046 If Length > 0 and Source is NULL, then ASSERT().
1047 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
1048 If Source and Destination overlap, then ASSERT().
1049 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
1050 PcdMaximumUnicodeStringLength, then ASSERT().
1051 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1052 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
1055 @param Destination The pointer to a Null-terminated Unicode string.
1056 @param Source The pointer to a Null-terminated Unicode string.
1057 @param Length The maximum number of Unicode characters to copy.
1059 @return Destination.
1065 OUT CHAR16
*Destination
,
1066 IN CONST CHAR16
*Source
,
1069 #endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES)
1072 Returns the length of a Null-terminated Unicode string.
1074 This function returns the number of Unicode characters in the Null-terminated
1075 Unicode string specified by String.
1077 If String is NULL, then ASSERT().
1078 If String is not aligned on a 16-bit boundary, then ASSERT().
1079 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
1080 PcdMaximumUnicodeStringLength Unicode characters not including the
1081 Null-terminator, then ASSERT().
1083 @param String Pointer to a Null-terminated Unicode string.
1085 @return The length of String.
1091 IN CONST CHAR16
*String
1096 Returns the size of a Null-terminated Unicode string in bytes, including the
1099 This function returns the size, in bytes, of the Null-terminated Unicode string
1100 specified by String.
1102 If String is NULL, then ASSERT().
1103 If String is not aligned on a 16-bit boundary, then ASSERT().
1104 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
1105 PcdMaximumUnicodeStringLength Unicode characters not including the
1106 Null-terminator, then ASSERT().
1108 @param String The pointer to a Null-terminated Unicode string.
1110 @return The size of String.
1116 IN CONST CHAR16
*String
1121 Compares two Null-terminated Unicode strings, and returns the difference
1122 between the first mismatched Unicode characters.
1124 This function compares the Null-terminated Unicode string FirstString to the
1125 Null-terminated Unicode string SecondString. If FirstString is identical to
1126 SecondString, then 0 is returned. Otherwise, the value returned is the first
1127 mismatched Unicode character in SecondString subtracted from the first
1128 mismatched Unicode character in FirstString.
1130 If FirstString is NULL, then ASSERT().
1131 If FirstString is not aligned on a 16-bit boundary, then ASSERT().
1132 If SecondString is NULL, then ASSERT().
1133 If SecondString is not aligned on a 16-bit boundary, then ASSERT().
1134 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
1135 than PcdMaximumUnicodeStringLength Unicode characters not including the
1136 Null-terminator, then ASSERT().
1137 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
1138 than PcdMaximumUnicodeStringLength Unicode characters, not including the
1139 Null-terminator, then ASSERT().
1141 @param FirstString The pointer to a Null-terminated Unicode string.
1142 @param SecondString The pointer to a Null-terminated Unicode string.
1144 @retval 0 FirstString is identical to SecondString.
1145 @return others FirstString is not identical to SecondString.
1151 IN CONST CHAR16
*FirstString
,
1152 IN CONST CHAR16
*SecondString
1157 Compares up to a specified length the contents of two Null-terminated Unicode strings,
1158 and returns the difference between the first mismatched Unicode characters.
1160 This function compares the Null-terminated Unicode string FirstString to the
1161 Null-terminated Unicode string SecondString. At most, Length Unicode
1162 characters will be compared. If Length is 0, then 0 is returned. If
1163 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
1164 value returned is the first mismatched Unicode character in SecondString
1165 subtracted from the first mismatched Unicode character in FirstString.
1167 If Length > 0 and FirstString is NULL, then ASSERT().
1168 If Length > 0 and FirstString is not aligned on a 16-bit boundary, then ASSERT().
1169 If Length > 0 and SecondString is NULL, then ASSERT().
1170 If Length > 0 and SecondString is not aligned on a 16-bit boundary, then ASSERT().
1171 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
1172 PcdMaximumUnicodeStringLength, then ASSERT().
1173 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more than
1174 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
1176 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more than
1177 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
1180 @param FirstString The pointer to a Null-terminated Unicode string.
1181 @param SecondString The pointer to a Null-terminated Unicode string.
1182 @param Length The maximum number of Unicode characters to compare.
1184 @retval 0 FirstString is identical to SecondString.
1185 @return others FirstString is not identical to SecondString.
1191 IN CONST CHAR16
*FirstString
,
1192 IN CONST CHAR16
*SecondString
,
1197 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1200 [ATTENTION] This function is deprecated for security reason.
1202 Concatenates one Null-terminated Unicode string to another Null-terminated
1203 Unicode string, and returns the concatenated Unicode string.
1205 This function concatenates two Null-terminated Unicode strings. The contents
1206 of Null-terminated Unicode string Source are concatenated to the end of
1207 Null-terminated Unicode string Destination. The Null-terminated concatenated
1208 Unicode String is returned. If Source and Destination overlap, then the
1209 results are undefined.
1211 If Destination is NULL, then ASSERT().
1212 If Destination is not aligned on a 16-bit boundary, then ASSERT().
1213 If Source is NULL, then ASSERT().
1214 If Source is not aligned on a 16-bit boundary, then ASSERT().
1215 If Source and Destination overlap, then ASSERT().
1216 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
1217 than PcdMaximumUnicodeStringLength Unicode characters, not including the
1218 Null-terminator, then ASSERT().
1219 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1220 PcdMaximumUnicodeStringLength Unicode characters, not including the
1221 Null-terminator, then ASSERT().
1222 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
1223 and Source results in a Unicode string with more than
1224 PcdMaximumUnicodeStringLength Unicode characters, not including the
1225 Null-terminator, then ASSERT().
1227 @param Destination The pointer to a Null-terminated Unicode string.
1228 @param Source The pointer to a Null-terminated Unicode string.
1230 @return Destination.
1236 IN OUT CHAR16
*Destination
,
1237 IN CONST CHAR16
*Source
1242 [ATTENTION] This function is deprecated for security reason.
1244 Concatenates up to a specified length one Null-terminated Unicode to the end
1245 of another Null-terminated Unicode string, and returns the concatenated
1248 This function concatenates two Null-terminated Unicode strings. The contents
1249 of Null-terminated Unicode string Source are concatenated to the end of
1250 Null-terminated Unicode string Destination, and Destination is returned. At
1251 most, Length Unicode characters are concatenated from Source to the end of
1252 Destination, and Destination is always Null-terminated. If Length is 0, then
1253 Destination is returned unmodified. If Source and Destination overlap, then
1254 the results are undefined.
1256 If Destination is NULL, then ASSERT().
1257 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
1258 If Length > 0 and Source is NULL, then ASSERT().
1259 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
1260 If Source and Destination overlap, then ASSERT().
1261 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
1262 PcdMaximumUnicodeStringLength, then ASSERT().
1263 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
1264 than PcdMaximumUnicodeStringLength Unicode characters, not including the
1265 Null-terminator, then ASSERT().
1266 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1267 PcdMaximumUnicodeStringLength Unicode characters, not including the
1268 Null-terminator, then ASSERT().
1269 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
1270 and Source results in a Unicode string with more than PcdMaximumUnicodeStringLength
1271 Unicode characters, not including the Null-terminator, then ASSERT().
1273 @param Destination The pointer to a Null-terminated Unicode string.
1274 @param Source The pointer to a Null-terminated Unicode string.
1275 @param Length The maximum number of Unicode characters to concatenate from
1278 @return Destination.
1284 IN OUT CHAR16
*Destination
,
1285 IN CONST CHAR16
*Source
,
1288 #endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES)
1291 Returns the first occurrence of a Null-terminated Unicode sub-string
1292 in a Null-terminated Unicode string.
1294 This function scans the contents of the Null-terminated Unicode string
1295 specified by String and returns the first occurrence of SearchString.
1296 If SearchString is not found in String, then NULL is returned. If
1297 the length of SearchString is zero, then String is returned.
1299 If String is NULL, then ASSERT().
1300 If String is not aligned on a 16-bit boundary, then ASSERT().
1301 If SearchString is NULL, then ASSERT().
1302 If SearchString is not aligned on a 16-bit boundary, then ASSERT().
1304 If PcdMaximumUnicodeStringLength is not zero, and SearchString
1305 or String contains more than PcdMaximumUnicodeStringLength Unicode
1306 characters, not including the Null-terminator, then ASSERT().
1308 @param String The pointer to a Null-terminated Unicode string.
1309 @param SearchString The pointer to a Null-terminated Unicode string to search for.
1311 @retval NULL If the SearchString does not appear in String.
1312 @return others If there is a match.
1318 IN CONST CHAR16
*String
,
1319 IN CONST CHAR16
*SearchString
1323 Convert a Null-terminated Unicode decimal string to a value of
1326 This function returns a value of type UINTN by interpreting the contents
1327 of the Unicode string specified by String as a decimal number. The format
1328 of the input Unicode string String is:
1330 [spaces] [decimal digits].
1332 The valid decimal digit character is in the range [0-9]. The
1333 function will ignore the pad space, which includes spaces or
1334 tab characters, before [decimal digits]. The running zero in the
1335 beginning of [decimal digits] will be ignored. Then, the function
1336 stops at the first character that is a not a valid decimal character
1337 or a Null-terminator, whichever one comes first.
1339 If String is NULL, then ASSERT().
1340 If String is not aligned in a 16-bit boundary, then ASSERT().
1341 If String has only pad spaces, then 0 is returned.
1342 If String has no pad spaces or valid decimal digits,
1344 If the number represented by String overflows according
1345 to the range defined by UINTN, then MAX_UINTN is returned.
1347 If PcdMaximumUnicodeStringLength is not zero, and String contains
1348 more than PcdMaximumUnicodeStringLength Unicode characters not including
1349 the Null-terminator, then ASSERT().
1351 @param String The pointer to a Null-terminated Unicode string.
1353 @retval Value translated from String.
1359 IN CONST CHAR16
*String
1363 Convert a Null-terminated Unicode decimal string to a value of
1366 This function returns a value of type UINT64 by interpreting the contents
1367 of the Unicode string specified by String as a decimal number. The format
1368 of the input Unicode string String is:
1370 [spaces] [decimal digits].
1372 The valid decimal digit character is in the range [0-9]. The
1373 function will ignore the pad space, which includes spaces or
1374 tab characters, before [decimal digits]. The running zero in the
1375 beginning of [decimal digits] will be ignored. Then, the function
1376 stops at the first character that is a not a valid decimal character
1377 or a Null-terminator, whichever one comes first.
1379 If String is NULL, then ASSERT().
1380 If String is not aligned in a 16-bit boundary, then ASSERT().
1381 If String has only pad spaces, then 0 is returned.
1382 If String has no pad spaces or valid decimal digits,
1384 If the number represented by String overflows according
1385 to the range defined by UINT64, then MAX_UINT64 is returned.
1387 If PcdMaximumUnicodeStringLength is not zero, and String contains
1388 more than PcdMaximumUnicodeStringLength Unicode characters not including
1389 the Null-terminator, then ASSERT().
1391 @param String The pointer to a Null-terminated Unicode string.
1393 @retval Value translated from String.
1398 StrDecimalToUint64 (
1399 IN CONST CHAR16
*String
1404 Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.
1406 This function returns a value of type UINTN by interpreting the contents
1407 of the Unicode string specified by String as a hexadecimal number.
1408 The format of the input Unicode string String is:
1410 [spaces][zeros][x][hexadecimal digits].
1412 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1413 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
1414 If "x" appears in the input string, it must be prefixed with at least one 0.
1415 The function will ignore the pad space, which includes spaces or tab characters,
1416 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
1417 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
1418 first valid hexadecimal digit. Then, the function stops at the first character
1419 that is a not a valid hexadecimal character or NULL, whichever one comes first.
1421 If String is NULL, then ASSERT().
1422 If String is not aligned in a 16-bit boundary, then ASSERT().
1423 If String has only pad spaces, then zero is returned.
1424 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
1425 then zero is returned.
1426 If the number represented by String overflows according to the range defined by
1427 UINTN, then MAX_UINTN is returned.
1429 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
1430 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
1433 @param String The pointer to a Null-terminated Unicode string.
1435 @retval Value translated from String.
1441 IN CONST CHAR16
*String
1446 Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.
1448 This function returns a value of type UINT64 by interpreting the contents
1449 of the Unicode string specified by String as a hexadecimal number.
1450 The format of the input Unicode string String is
1452 [spaces][zeros][x][hexadecimal digits].
1454 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1455 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
1456 If "x" appears in the input string, it must be prefixed with at least one 0.
1457 The function will ignore the pad space, which includes spaces or tab characters,
1458 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
1459 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
1460 first valid hexadecimal digit. Then, the function stops at the first character that is
1461 a not a valid hexadecimal character or NULL, whichever one comes first.
1463 If String is NULL, then ASSERT().
1464 If String is not aligned in a 16-bit boundary, then ASSERT().
1465 If String has only pad spaces, then zero is returned.
1466 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
1467 then zero is returned.
1468 If the number represented by String overflows according to the range defined by
1469 UINT64, then MAX_UINT64 is returned.
1471 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
1472 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
1475 @param String The pointer to a Null-terminated Unicode string.
1477 @retval Value translated from String.
1483 IN CONST CHAR16
*String
1487 Convert a Null-terminated Unicode string to IPv6 address and prefix length.
1489 This function outputs a value of type IPv6_ADDRESS and may output a value
1490 of type UINT8 by interpreting the contents of the Unicode string specified
1491 by String. The format of the input Unicode string String is as follows:
1495 X contains one to four hexadecimal digit characters in the range [0-9], [a-f] and
1496 [A-F]. X is converted to a value of type UINT16, whose low byte is stored in low
1497 memory address and high byte is stored in high memory address. P contains decimal
1498 digit characters in the range [0-9]. The running zero in the beginning of P will
1499 be ignored. /P is optional.
1501 When /P is not in the String, the function stops at the first character that is
1502 not a valid hexadecimal digit character after eight X's are converted.
1504 When /P is in the String, the function stops at the first character that is not
1505 a valid decimal digit character after P is converted.
1507 "::" can be used to compress one or more groups of X when X contains only 0.
1508 The "::" can only appear once in the String.
1510 If String is NULL, then ASSERT().
1512 If Address is NULL, then ASSERT().
1514 If String is not aligned in a 16-bit boundary, then ASSERT().
1516 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
1517 PcdMaximumUnicodeStringLength Unicode characters, not including the
1518 Null-terminator, then ASSERT().
1520 If EndPointer is not NULL and Address is translated from String, a pointer
1521 to the character that stopped the scan is stored at the location pointed to
1524 @param String Pointer to a Null-terminated Unicode string.
1525 @param EndPointer Pointer to character that stops scan.
1526 @param Address Pointer to the converted IPv6 address.
1527 @param PrefixLength Pointer to the converted IPv6 address prefix
1528 length. MAX_UINT8 is returned when /P is
1531 @retval RETURN_SUCCESS Address is translated from String.
1532 @retval RETURN_INVALID_PARAMETER If String is NULL.
1534 @retval RETURN_UNSUPPORTED If X contains more than four hexadecimal
1536 If String contains "::" and number of X
1538 If P starts with character that is not a
1539 valid decimal digit character.
1540 If the decimal number converted from P
1547 IN CONST CHAR16
*String
,
1548 OUT CHAR16
**EndPointer
, OPTIONAL
1549 OUT IPv6_ADDRESS
*Address
,
1550 OUT UINT8
*PrefixLength OPTIONAL
1554 Convert a Null-terminated Unicode string to IPv4 address and prefix length.
1556 This function outputs a value of type IPv4_ADDRESS and may output a value
1557 of type UINT8 by interpreting the contents of the Unicode string specified
1558 by String. The format of the input Unicode string String is as follows:
1562 D and P are decimal digit characters in the range [0-9]. The running zero in
1563 the beginning of D and P will be ignored. /P is optional.
1565 When /P is not in the String, the function stops at the first character that is
1566 not a valid decimal digit character after four D's are converted.
1568 When /P is in the String, the function stops at the first character that is not
1569 a valid decimal digit character after P is converted.
1571 If String is NULL, then ASSERT().
1573 If Address is NULL, then ASSERT().
1575 If String is not aligned in a 16-bit boundary, then ASSERT().
1577 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
1578 PcdMaximumUnicodeStringLength Unicode characters, not including the
1579 Null-terminator, then ASSERT().
1581 If EndPointer is not NULL and Address is translated from String, a pointer
1582 to the character that stopped the scan is stored at the location pointed to
1585 @param String Pointer to a Null-terminated Unicode string.
1586 @param EndPointer Pointer to character that stops scan.
1587 @param Address Pointer to the converted IPv4 address.
1588 @param PrefixLength Pointer to the converted IPv4 address prefix
1589 length. MAX_UINT8 is returned when /P is
1592 @retval RETURN_SUCCESS Address is translated from String.
1593 @retval RETURN_INVALID_PARAMETER If String is NULL.
1595 @retval RETURN_UNSUPPORTED If String is not in the correct format.
1596 If any decimal number converted from D
1598 If the decimal number converted from P
1605 IN CONST CHAR16
*String
,
1606 OUT CHAR16
**EndPointer
, OPTIONAL
1607 OUT IPv4_ADDRESS
*Address
,
1608 OUT UINT8
*PrefixLength OPTIONAL
1611 #define GUID_STRING_LENGTH 36
1614 Convert a Null-terminated Unicode GUID string to a value of type
1617 This function outputs a GUID value by interpreting the contents of
1618 the Unicode string specified by String. The format of the input
1619 Unicode string String consists of 36 characters, as follows:
1621 aabbccdd-eeff-gghh-iijj-kkllmmnnoopp
1623 The pairs aa - pp are two characters in the range [0-9], [a-f] and
1624 [A-F], with each pair representing a single byte hexadecimal value.
1626 The mapping between String and the EFI_GUID structure is as follows:
1644 If String is NULL, then ASSERT().
1645 If Guid is NULL, then ASSERT().
1646 If String is not aligned in a 16-bit boundary, then ASSERT().
1648 @param String Pointer to a Null-terminated Unicode string.
1649 @param Guid Pointer to the converted GUID.
1651 @retval RETURN_SUCCESS Guid is translated from String.
1652 @retval RETURN_INVALID_PARAMETER If String is NULL.
1654 @retval RETURN_UNSUPPORTED If String is not as the above format.
1660 IN CONST CHAR16
*String
,
1665 Convert a Null-terminated Unicode hexadecimal string to a byte array.
1667 This function outputs a byte array by interpreting the contents of
1668 the Unicode string specified by String in hexadecimal format. The format of
1669 the input Unicode string String is:
1673 X is a hexadecimal digit character in the range [0-9], [a-f] and [A-F].
1674 The function decodes every two hexadecimal digit characters as one byte. The
1675 decoding stops after Length of characters and outputs Buffer containing
1678 If String is not aligned in a 16-bit boundary, then ASSERT().
1680 If String is NULL, then ASSERT().
1682 If Buffer is NULL, then ASSERT().
1684 If Length is not multiple of 2, then ASSERT().
1686 If PcdMaximumUnicodeStringLength is not zero and Length is greater than
1687 PcdMaximumUnicodeStringLength, then ASSERT().
1689 If MaxBufferSize is less than (Length / 2), then ASSERT().
1691 @param String Pointer to a Null-terminated Unicode string.
1692 @param Length The number of Unicode characters to decode.
1693 @param Buffer Pointer to the converted bytes array.
1694 @param MaxBufferSize The maximum size of Buffer.
1696 @retval RETURN_SUCCESS Buffer is translated from String.
1697 @retval RETURN_INVALID_PARAMETER If String is NULL.
1699 If Length is not multiple of 2.
1700 If PcdMaximumUnicodeStringLength is not zero,
1701 and Length is greater than
1702 PcdMaximumUnicodeStringLength.
1703 @retval RETURN_UNSUPPORTED If Length of characters from String contain
1704 a character that is not valid hexadecimal
1705 digit characters, or a Null-terminator.
1706 @retval RETURN_BUFFER_TOO_SMALL If MaxBufferSize is less than (Length / 2).
1711 IN CONST CHAR16
*String
,
1714 IN UINTN MaxBufferSize
1717 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1720 [ATTENTION] This function is deprecated for security reason.
1722 Convert a Null-terminated Unicode string to a Null-terminated
1723 ASCII string and returns the ASCII string.
1725 This function converts the content of the Unicode string Source
1726 to the ASCII string Destination by copying the lower 8 bits of
1727 each Unicode character. It returns Destination.
1729 The caller is responsible to make sure Destination points to a buffer with size
1730 equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.
1732 If any Unicode characters in Source contain non-zero value in
1733 the upper 8 bits, then ASSERT().
1735 If Destination is NULL, then ASSERT().
1736 If Source is NULL, then ASSERT().
1737 If Source is not aligned on a 16-bit boundary, then ASSERT().
1738 If Source and Destination overlap, then ASSERT().
1740 If PcdMaximumUnicodeStringLength is not zero, and Source contains
1741 more than PcdMaximumUnicodeStringLength Unicode characters not including
1742 the Null-terminator, then ASSERT().
1744 If PcdMaximumAsciiStringLength is not zero, and Source contains more
1745 than PcdMaximumAsciiStringLength Unicode characters not including the
1746 Null-terminator, then ASSERT().
1748 @param Source The pointer to a Null-terminated Unicode string.
1749 @param Destination The pointer to a Null-terminated ASCII string.
1751 @return Destination.
1756 UnicodeStrToAsciiStr (
1757 IN CONST CHAR16
*Source
,
1758 OUT CHAR8
*Destination
1761 #endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES)
1764 Convert a Null-terminated Unicode string to a Null-terminated
1767 This function is similar to AsciiStrCpyS.
1769 This function converts the content of the Unicode string Source
1770 to the ASCII string Destination by copying the lower 8 bits of
1771 each Unicode character. The function terminates the ASCII string
1772 Destination by appending a Null-terminator character at the end.
1774 The caller is responsible to make sure Destination points to a buffer with size
1775 equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.
1777 If any Unicode characters in Source contain non-zero value in
1778 the upper 8 bits, then ASSERT().
1780 If Source is not aligned on a 16-bit boundary, then ASSERT().
1781 If an error would be returned, then the function will also ASSERT().
1783 If an error is returned, then the Destination is unmodified.
1785 @param Source The pointer to a Null-terminated Unicode string.
1786 @param Destination The pointer to a Null-terminated ASCII string.
1787 @param DestMax The maximum number of Destination Ascii
1788 char, including terminating null char.
1790 @retval RETURN_SUCCESS String is converted.
1791 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
1792 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
1794 If PcdMaximumAsciiStringLength is not zero,
1795 and DestMax is greater than
1796 PcdMaximumAsciiStringLength.
1797 If PcdMaximumUnicodeStringLength is not zero,
1798 and DestMax is greater than
1799 PcdMaximumUnicodeStringLength.
1801 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
1806 UnicodeStrToAsciiStrS (
1807 IN CONST CHAR16
*Source
,
1808 OUT CHAR8
*Destination
,
1813 Convert not more than Length successive characters from a Null-terminated
1814 Unicode string to a Null-terminated Ascii string. If no null char is copied
1815 from Source, then Destination[Length] is always set to null.
1817 This function converts not more than Length successive characters from the
1818 Unicode string Source to the Ascii string Destination by copying the lower 8
1819 bits of each Unicode character. The function terminates the Ascii string
1820 Destination by appending a Null-terminator character at the end.
1822 The caller is responsible to make sure Destination points to a buffer with size
1823 equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.
1825 If any Unicode characters in Source contain non-zero value in the upper 8
1826 bits, then ASSERT().
1827 If Source is not aligned on a 16-bit boundary, then ASSERT().
1828 If an error would be returned, then the function will also ASSERT().
1830 If an error is returned, then the Destination is unmodified.
1832 @param Source The pointer to a Null-terminated Unicode string.
1833 @param Length The maximum number of Unicode characters to
1835 @param Destination The pointer to a Null-terminated Ascii string.
1836 @param DestMax The maximum number of Destination Ascii
1837 char, including terminating null char.
1838 @param DestinationLength The number of Unicode characters converted.
1840 @retval RETURN_SUCCESS String is converted.
1841 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
1843 If DestinationLength is NULL.
1844 If PcdMaximumAsciiStringLength is not zero,
1845 and Length or DestMax is greater than
1846 PcdMaximumAsciiStringLength.
1847 If PcdMaximumUnicodeStringLength is not
1848 zero, and Length or DestMax is greater than
1849 PcdMaximumUnicodeStringLength.
1851 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than
1852 MIN(StrLen(Source), Length).
1853 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
1858 UnicodeStrnToAsciiStrS (
1859 IN CONST CHAR16
*Source
,
1861 OUT CHAR8
*Destination
,
1863 OUT UINTN
*DestinationLength
1866 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1869 [ATTENTION] This function is deprecated for security reason.
1871 Copies one Null-terminated ASCII string to another Null-terminated ASCII
1872 string and returns the new ASCII string.
1874 This function copies the contents of the ASCII string Source to the ASCII
1875 string Destination, and returns Destination. If Source and Destination
1876 overlap, then the results are undefined.
1878 If Destination is NULL, then ASSERT().
1879 If Source is NULL, then ASSERT().
1880 If Source and Destination overlap, then ASSERT().
1881 If PcdMaximumAsciiStringLength is not zero and Source contains more than
1882 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1885 @param Destination The pointer to a Null-terminated ASCII string.
1886 @param Source The pointer to a Null-terminated ASCII string.
1894 OUT CHAR8
*Destination
,
1895 IN CONST CHAR8
*Source
1900 [ATTENTION] This function is deprecated for security reason.
1902 Copies up to a specified length one Null-terminated ASCII string to another
1903 Null-terminated ASCII string and returns the new ASCII string.
1905 This function copies the contents of the ASCII string Source to the ASCII
1906 string Destination, and returns Destination. At most, Length ASCII characters
1907 are copied from Source to Destination. If Length is 0, then Destination is
1908 returned unmodified. If Length is greater that the number of ASCII characters
1909 in Source, then Destination is padded with Null ASCII characters. If Source
1910 and Destination overlap, then the results are undefined.
1912 If Destination is NULL, then ASSERT().
1913 If Source is NULL, then ASSERT().
1914 If Source and Destination overlap, then ASSERT().
1915 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
1916 PcdMaximumAsciiStringLength, then ASSERT().
1917 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1918 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1921 @param Destination The pointer to a Null-terminated ASCII string.
1922 @param Source The pointer to a Null-terminated ASCII string.
1923 @param Length The maximum number of ASCII characters to copy.
1931 OUT CHAR8
*Destination
,
1932 IN CONST CHAR8
*Source
,
1935 #endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES)
1938 Returns the length of a Null-terminated ASCII string.
1940 This function returns the number of ASCII characters in the Null-terminated
1941 ASCII string specified by String.
1943 If Length > 0 and Destination is NULL, then ASSERT().
1944 If Length > 0 and Source is NULL, then ASSERT().
1945 If PcdMaximumAsciiStringLength is not zero and String contains more than
1946 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1949 @param String The pointer to a Null-terminated ASCII string.
1951 @return The length of String.
1957 IN CONST CHAR8
*String
1962 Returns the size of a Null-terminated ASCII string in bytes, including the
1965 This function returns the size, in bytes, of the Null-terminated ASCII string
1966 specified by String.
1968 If String is NULL, then ASSERT().
1969 If PcdMaximumAsciiStringLength is not zero and String contains more than
1970 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1973 @param String The pointer to a Null-terminated ASCII string.
1975 @return The size of String.
1981 IN CONST CHAR8
*String
1986 Compares two Null-terminated ASCII strings, and returns the difference
1987 between the first mismatched ASCII characters.
1989 This function compares the Null-terminated ASCII string FirstString to the
1990 Null-terminated ASCII string SecondString. If FirstString is identical to
1991 SecondString, then 0 is returned. Otherwise, the value returned is the first
1992 mismatched ASCII character in SecondString subtracted from the first
1993 mismatched ASCII character in FirstString.
1995 If FirstString is NULL, then ASSERT().
1996 If SecondString is NULL, then ASSERT().
1997 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
1998 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
2000 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
2001 than PcdMaximumAsciiStringLength ASCII characters not including the
2002 Null-terminator, then ASSERT().
2004 @param FirstString The pointer to a Null-terminated ASCII string.
2005 @param SecondString The pointer to a Null-terminated ASCII string.
2007 @retval ==0 FirstString is identical to SecondString.
2008 @retval !=0 FirstString is not identical to SecondString.
2014 IN CONST CHAR8
*FirstString
,
2015 IN CONST CHAR8
*SecondString
2020 Performs a case insensitive comparison of two Null-terminated ASCII strings,
2021 and returns the difference between the first mismatched ASCII characters.
2023 This function performs a case insensitive comparison of the Null-terminated
2024 ASCII string FirstString to the Null-terminated ASCII string SecondString. If
2025 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
2026 value returned is the first mismatched lower case ASCII character in
2027 SecondString subtracted from the first mismatched lower case ASCII character
2030 If FirstString is NULL, then ASSERT().
2031 If SecondString is NULL, then ASSERT().
2032 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
2033 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
2035 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
2036 than PcdMaximumAsciiStringLength ASCII characters not including the
2037 Null-terminator, then ASSERT().
2039 @param FirstString The pointer to a Null-terminated ASCII string.
2040 @param SecondString The pointer to a Null-terminated ASCII string.
2042 @retval ==0 FirstString is identical to SecondString using case insensitive
2044 @retval !=0 FirstString is not identical to SecondString using case
2045 insensitive comparisons.
2051 IN CONST CHAR8
*FirstString
,
2052 IN CONST CHAR8
*SecondString
2057 Compares two Null-terminated ASCII strings with maximum lengths, and returns
2058 the difference between the first mismatched ASCII characters.
2060 This function compares the Null-terminated ASCII string FirstString to the
2061 Null-terminated ASCII string SecondString. At most, Length ASCII characters
2062 will be compared. If Length is 0, then 0 is returned. If FirstString is
2063 identical to SecondString, then 0 is returned. Otherwise, the value returned
2064 is the first mismatched ASCII character in SecondString subtracted from the
2065 first mismatched ASCII character in FirstString.
2067 If Length > 0 and FirstString is NULL, then ASSERT().
2068 If Length > 0 and SecondString is NULL, then ASSERT().
2069 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
2070 PcdMaximumAsciiStringLength, then ASSERT().
2071 If PcdMaximumAsciiStringLength is not zero, and FirstString contains more than
2072 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
2074 If PcdMaximumAsciiStringLength is not zero, and SecondString contains more than
2075 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
2078 @param FirstString The pointer to a Null-terminated ASCII string.
2079 @param SecondString The pointer to a Null-terminated ASCII string.
2080 @param Length The maximum number of ASCII characters for compare.
2082 @retval ==0 FirstString is identical to SecondString.
2083 @retval !=0 FirstString is not identical to SecondString.
2089 IN CONST CHAR8
*FirstString
,
2090 IN CONST CHAR8
*SecondString
,
2095 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
2098 [ATTENTION] This function is deprecated for security reason.
2100 Concatenates one Null-terminated ASCII string to another Null-terminated
2101 ASCII string, and returns the concatenated ASCII string.
2103 This function concatenates two Null-terminated ASCII strings. The contents of
2104 Null-terminated ASCII string Source are concatenated to the end of Null-
2105 terminated ASCII string Destination. The Null-terminated concatenated ASCII
2108 If Destination is NULL, then ASSERT().
2109 If Source is NULL, then ASSERT().
2110 If PcdMaximumAsciiStringLength is not zero and Destination contains more than
2111 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
2113 If PcdMaximumAsciiStringLength is not zero and Source contains more than
2114 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
2116 If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
2117 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
2118 ASCII characters, then ASSERT().
2120 @param Destination The pointer to a Null-terminated ASCII string.
2121 @param Source The pointer to a Null-terminated ASCII string.
2129 IN OUT CHAR8
*Destination
,
2130 IN CONST CHAR8
*Source
2135 [ATTENTION] This function is deprecated for security reason.
2137 Concatenates up to a specified length one Null-terminated ASCII string to
2138 the end of another Null-terminated ASCII string, and returns the
2139 concatenated ASCII string.
2141 This function concatenates two Null-terminated ASCII strings. The contents
2142 of Null-terminated ASCII string Source are concatenated to the end of Null-
2143 terminated ASCII string Destination, and Destination is returned. At most,
2144 Length ASCII characters are concatenated from Source to the end of
2145 Destination, and Destination is always Null-terminated. If Length is 0, then
2146 Destination is returned unmodified. If Source and Destination overlap, then
2147 the results are undefined.
2149 If Length > 0 and Destination is NULL, then ASSERT().
2150 If Length > 0 and Source is NULL, then ASSERT().
2151 If Source and Destination overlap, then ASSERT().
2152 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
2153 PcdMaximumAsciiStringLength, then ASSERT().
2154 If PcdMaximumAsciiStringLength is not zero, and Destination contains more than
2155 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
2157 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
2158 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
2160 If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
2161 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
2162 ASCII characters, not including the Null-terminator, then ASSERT().
2164 @param Destination The pointer to a Null-terminated ASCII string.
2165 @param Source The pointer to a Null-terminated ASCII string.
2166 @param Length The maximum number of ASCII characters to concatenate from
2175 IN OUT CHAR8
*Destination
,
2176 IN CONST CHAR8
*Source
,
2179 #endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES)
2182 Returns the first occurrence of a Null-terminated ASCII sub-string
2183 in a Null-terminated ASCII string.
2185 This function scans the contents of the ASCII string specified by String
2186 and returns the first occurrence of SearchString. If SearchString is not
2187 found in String, then NULL is returned. If the length of SearchString is zero,
2188 then String is returned.
2190 If String is NULL, then ASSERT().
2191 If SearchString is NULL, then ASSERT().
2193 If PcdMaximumAsciiStringLength is not zero, and SearchString or
2194 String contains more than PcdMaximumAsciiStringLength Unicode characters
2195 not including the Null-terminator, then ASSERT().
2197 @param String The pointer to a Null-terminated ASCII string.
2198 @param SearchString The pointer to a Null-terminated ASCII string to search for.
2200 @retval NULL If the SearchString does not appear in String.
2201 @retval others If there is a match return the first occurrence of SearchingString.
2202 If the length of SearchString is zero,return String.
2208 IN CONST CHAR8
*String
,
2209 IN CONST CHAR8
*SearchString
2214 Convert a Null-terminated ASCII decimal string to a value of type
2217 This function returns a value of type UINTN by interpreting the contents
2218 of the ASCII string String as a decimal number. The format of the input
2219 ASCII string String is:
2221 [spaces] [decimal digits].
2223 The valid decimal digit character is in the range [0-9]. The function will
2224 ignore the pad space, which includes spaces or tab characters, before the digits.
2225 The running zero in the beginning of [decimal digits] will be ignored. Then, the
2226 function stops at the first character that is a not a valid decimal character or
2227 Null-terminator, whichever on comes first.
2229 If String has only pad spaces, then 0 is returned.
2230 If String has no pad spaces or valid decimal digits, then 0 is returned.
2231 If the number represented by String overflows according to the range defined by
2232 UINTN, then MAX_UINTN is returned.
2233 If String is NULL, then ASSERT().
2234 If PcdMaximumAsciiStringLength is not zero, and String contains more than
2235 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
2238 @param String The pointer to a Null-terminated ASCII string.
2240 @retval The value translated from String.
2245 AsciiStrDecimalToUintn (
2246 IN CONST CHAR8
*String
2251 Convert a Null-terminated ASCII decimal string to a value of type
2254 This function returns a value of type UINT64 by interpreting the contents
2255 of the ASCII string String as a decimal number. The format of the input
2256 ASCII string String is:
2258 [spaces] [decimal digits].
2260 The valid decimal digit character is in the range [0-9]. The function will
2261 ignore the pad space, which includes spaces or tab characters, before the digits.
2262 The running zero in the beginning of [decimal digits] will be ignored. Then, the
2263 function stops at the first character that is a not a valid decimal character or
2264 Null-terminator, whichever on comes first.
2266 If String has only pad spaces, then 0 is returned.
2267 If String has no pad spaces or valid decimal digits, then 0 is returned.
2268 If the number represented by String overflows according to the range defined by
2269 UINT64, then MAX_UINT64 is returned.
2270 If String is NULL, then ASSERT().
2271 If PcdMaximumAsciiStringLength is not zero, and String contains more than
2272 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
2275 @param String The pointer to a Null-terminated ASCII string.
2277 @retval Value translated from String.
2282 AsciiStrDecimalToUint64 (
2283 IN CONST CHAR8
*String
2288 Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.
2290 This function returns a value of type UINTN by interpreting the contents of
2291 the ASCII string String as a hexadecimal number. The format of the input ASCII
2294 [spaces][zeros][x][hexadecimal digits].
2296 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
2297 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
2298 appears in the input string, it must be prefixed with at least one 0. The function
2299 will ignore the pad space, which includes spaces or tab characters, before [zeros],
2300 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
2301 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
2302 digit. Then, the function stops at the first character that is a not a valid
2303 hexadecimal character or Null-terminator, whichever on comes first.
2305 If String has only pad spaces, then 0 is returned.
2306 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
2309 If the number represented by String overflows according to the range defined by UINTN,
2310 then MAX_UINTN is returned.
2311 If String is NULL, then ASSERT().
2312 If PcdMaximumAsciiStringLength is not zero,
2313 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
2314 the Null-terminator, then ASSERT().
2316 @param String The pointer to a Null-terminated ASCII string.
2318 @retval Value translated from String.
2323 AsciiStrHexToUintn (
2324 IN CONST CHAR8
*String
2329 Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.
2331 This function returns a value of type UINT64 by interpreting the contents of
2332 the ASCII string String as a hexadecimal number. The format of the input ASCII
2335 [spaces][zeros][x][hexadecimal digits].
2337 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
2338 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
2339 appears in the input string, it must be prefixed with at least one 0. The function
2340 will ignore the pad space, which includes spaces or tab characters, before [zeros],
2341 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
2342 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
2343 digit. Then, the function stops at the first character that is a not a valid
2344 hexadecimal character or Null-terminator, whichever on comes first.
2346 If String has only pad spaces, then 0 is returned.
2347 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
2350 If the number represented by String overflows according to the range defined by UINT64,
2351 then MAX_UINT64 is returned.
2352 If String is NULL, then ASSERT().
2353 If PcdMaximumAsciiStringLength is not zero,
2354 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
2355 the Null-terminator, then ASSERT().
2357 @param String The pointer to a Null-terminated ASCII string.
2359 @retval Value translated from String.
2364 AsciiStrHexToUint64 (
2365 IN CONST CHAR8
*String
2369 Convert a Null-terminated ASCII string to IPv6 address and prefix length.
2371 This function outputs a value of type IPv6_ADDRESS and may output a value
2372 of type UINT8 by interpreting the contents of the ASCII string specified
2373 by String. The format of the input ASCII string String is as follows:
2377 X contains one to four hexadecimal digit characters in the range [0-9], [a-f] and
2378 [A-F]. X is converted to a value of type UINT16, whose low byte is stored in low
2379 memory address and high byte is stored in high memory address. P contains decimal
2380 digit characters in the range [0-9]. The running zero in the beginning of P will
2381 be ignored. /P is optional.
2383 When /P is not in the String, the function stops at the first character that is
2384 not a valid hexadecimal digit character after eight X's are converted.
2386 When /P is in the String, the function stops at the first character that is not
2387 a valid decimal digit character after P is converted.
2389 "::" can be used to compress one or more groups of X when X contains only 0.
2390 The "::" can only appear once in the String.
2392 If String is NULL, then ASSERT().
2394 If Address is NULL, then ASSERT().
2396 If EndPointer is not NULL and Address is translated from String, a pointer
2397 to the character that stopped the scan is stored at the location pointed to
2400 @param String Pointer to a Null-terminated ASCII string.
2401 @param EndPointer Pointer to character that stops scan.
2402 @param Address Pointer to the converted IPv6 address.
2403 @param PrefixLength Pointer to the converted IPv6 address prefix
2404 length. MAX_UINT8 is returned when /P is
2407 @retval RETURN_SUCCESS Address is translated from String.
2408 @retval RETURN_INVALID_PARAMETER If String is NULL.
2410 @retval RETURN_UNSUPPORTED If X contains more than four hexadecimal
2412 If String contains "::" and number of X
2414 If P starts with character that is not a
2415 valid decimal digit character.
2416 If the decimal number converted from P
2422 AsciiStrToIpv6Address (
2423 IN CONST CHAR8
*String
,
2424 OUT CHAR8
**EndPointer
, OPTIONAL
2425 OUT IPv6_ADDRESS
*Address
,
2426 OUT UINT8
*PrefixLength OPTIONAL
2430 Convert a Null-terminated ASCII string to IPv4 address and prefix length.
2432 This function outputs a value of type IPv4_ADDRESS and may output a value
2433 of type UINT8 by interpreting the contents of the ASCII string specified
2434 by String. The format of the input ASCII string String is as follows:
2438 D and P are decimal digit characters in the range [0-9]. The running zero in
2439 the beginning of D and P will be ignored. /P is optional.
2441 When /P is not in the String, the function stops at the first character that is
2442 not a valid decimal digit character after four D's are converted.
2444 When /P is in the String, the function stops at the first character that is not
2445 a valid decimal digit character after P is converted.
2447 If String is NULL, then ASSERT().
2449 If Address is NULL, then ASSERT().
2451 If EndPointer is not NULL and Address is translated from String, a pointer
2452 to the character that stopped the scan is stored at the location pointed to
2455 @param String Pointer to a Null-terminated ASCII string.
2456 @param EndPointer Pointer to character that stops scan.
2457 @param Address Pointer to the converted IPv4 address.
2458 @param PrefixLength Pointer to the converted IPv4 address prefix
2459 length. MAX_UINT8 is returned when /P is
2462 @retval RETURN_SUCCESS Address is translated from String.
2463 @retval RETURN_INVALID_PARAMETER If String is NULL.
2465 @retval RETURN_UNSUPPORTED If String is not in the correct format.
2466 If any decimal number converted from D
2468 If the decimal number converted from P
2474 AsciiStrToIpv4Address (
2475 IN CONST CHAR8
*String
,
2476 OUT CHAR8
**EndPointer
, OPTIONAL
2477 OUT IPv4_ADDRESS
*Address
,
2478 OUT UINT8
*PrefixLength OPTIONAL
2482 Convert a Null-terminated ASCII GUID string to a value of type
2485 This function outputs a GUID value by interpreting the contents of
2486 the ASCII string specified by String. The format of the input
2487 ASCII string String consists of 36 characters, as follows:
2489 aabbccdd-eeff-gghh-iijj-kkllmmnnoopp
2491 The pairs aa - pp are two characters in the range [0-9], [a-f] and
2492 [A-F], with each pair representing a single byte hexadecimal value.
2494 The mapping between String and the EFI_GUID structure is as follows:
2512 If String is NULL, then ASSERT().
2513 If Guid is NULL, then ASSERT().
2515 @param String Pointer to a Null-terminated ASCII string.
2516 @param Guid Pointer to the converted GUID.
2518 @retval RETURN_SUCCESS Guid is translated from String.
2519 @retval RETURN_INVALID_PARAMETER If String is NULL.
2521 @retval RETURN_UNSUPPORTED If String is not as the above format.
2527 IN CONST CHAR8
*String
,
2532 Convert a Null-terminated ASCII hexadecimal string to a byte array.
2534 This function outputs a byte array by interpreting the contents of
2535 the ASCII string specified by String in hexadecimal format. The format of
2536 the input ASCII string String is:
2540 X is a hexadecimal digit character in the range [0-9], [a-f] and [A-F].
2541 The function decodes every two hexadecimal digit characters as one byte. The
2542 decoding stops after Length of characters and outputs Buffer containing
2545 If String is NULL, then ASSERT().
2547 If Buffer is NULL, then ASSERT().
2549 If Length is not multiple of 2, then ASSERT().
2551 If PcdMaximumAsciiStringLength is not zero and Length is greater than
2552 PcdMaximumAsciiStringLength, then ASSERT().
2554 If MaxBufferSize is less than (Length / 2), then ASSERT().
2556 @param String Pointer to a Null-terminated ASCII string.
2557 @param Length The number of ASCII characters to decode.
2558 @param Buffer Pointer to the converted bytes array.
2559 @param MaxBufferSize The maximum size of Buffer.
2561 @retval RETURN_SUCCESS Buffer is translated from String.
2562 @retval RETURN_INVALID_PARAMETER If String is NULL.
2564 If Length is not multiple of 2.
2565 If PcdMaximumAsciiStringLength is not zero,
2566 and Length is greater than
2567 PcdMaximumAsciiStringLength.
2568 @retval RETURN_UNSUPPORTED If Length of characters from String contain
2569 a character that is not valid hexadecimal
2570 digit characters, or a Null-terminator.
2571 @retval RETURN_BUFFER_TOO_SMALL If MaxBufferSize is less than (Length / 2).
2575 AsciiStrHexToBytes (
2576 IN CONST CHAR8
*String
,
2579 IN UINTN MaxBufferSize
2582 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
2585 [ATTENTION] This function is deprecated for security reason.
2587 Convert one Null-terminated ASCII string to a Null-terminated
2588 Unicode string and returns the Unicode string.
2590 This function converts the contents of the ASCII string Source to the Unicode
2591 string Destination, and returns Destination. The function terminates the
2592 Unicode string Destination by appending a Null-terminator character at the end.
2593 The caller is responsible to make sure Destination points to a buffer with size
2594 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
2596 If Destination is NULL, then ASSERT().
2597 If Destination is not aligned on a 16-bit boundary, then ASSERT().
2598 If Source is NULL, then ASSERT().
2599 If Source and Destination overlap, then ASSERT().
2600 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
2601 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
2603 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
2604 PcdMaximumUnicodeStringLength ASCII characters not including the
2605 Null-terminator, then ASSERT().
2607 @param Source The pointer to a Null-terminated ASCII string.
2608 @param Destination The pointer to a Null-terminated Unicode string.
2610 @return Destination.
2615 AsciiStrToUnicodeStr (
2616 IN CONST CHAR8
*Source
,
2617 OUT CHAR16
*Destination
2620 #endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES)
2623 Convert one Null-terminated ASCII string to a Null-terminated
2626 This function is similar to StrCpyS.
2628 This function converts the contents of the ASCII string Source to the Unicode
2629 string Destination. The function terminates the Unicode string Destination by
2630 appending a Null-terminator character at the end.
2632 The caller is responsible to make sure Destination points to a buffer with size
2633 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
2635 If Destination is not aligned on a 16-bit boundary, then ASSERT().
2636 If an error would be returned, then the function will also ASSERT().
2638 If an error is returned, then the Destination is unmodified.
2640 @param Source The pointer to a Null-terminated ASCII string.
2641 @param Destination The pointer to a Null-terminated Unicode string.
2642 @param DestMax The maximum number of Destination Unicode
2643 char, including terminating null char.
2645 @retval RETURN_SUCCESS String is converted.
2646 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
2647 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
2649 If PcdMaximumUnicodeStringLength is not zero,
2650 and DestMax is greater than
2651 PcdMaximumUnicodeStringLength.
2652 If PcdMaximumAsciiStringLength is not zero,
2653 and DestMax is greater than
2654 PcdMaximumAsciiStringLength.
2656 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
2661 AsciiStrToUnicodeStrS (
2662 IN CONST CHAR8
*Source
,
2663 OUT CHAR16
*Destination
,
2668 Convert not more than Length successive characters from a Null-terminated
2669 Ascii string to a Null-terminated Unicode string. If no null char is copied
2670 from Source, then Destination[Length] is always set to null.
2672 This function converts not more than Length successive characters from the
2673 Ascii string Source to the Unicode string Destination. The function
2674 terminates the Unicode string Destination by appending a Null-terminator
2675 character at the end.
2677 The caller is responsible to make sure Destination points to a buffer with
2678 size not smaller than
2679 ((MIN(AsciiStrLen(Source), Length) + 1) * sizeof (CHAR8)) in bytes.
2681 If Destination is not aligned on a 16-bit boundary, then ASSERT().
2682 If an error would be returned, then the function will also ASSERT().
2684 If an error is returned, then Destination and DestinationLength are
2687 @param Source The pointer to a Null-terminated Ascii string.
2688 @param Length The maximum number of Ascii characters to convert.
2689 @param Destination The pointer to a Null-terminated Unicode string.
2690 @param DestMax The maximum number of Destination Unicode char,
2691 including terminating null char.
2692 @param DestinationLength The number of Ascii characters converted.
2694 @retval RETURN_SUCCESS String is converted.
2695 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
2697 If DestinationLength is NULL.
2698 If PcdMaximumUnicodeStringLength is not
2699 zero, and Length or DestMax is greater than
2700 PcdMaximumUnicodeStringLength.
2701 If PcdMaximumAsciiStringLength is not zero,
2702 and Length or DestMax is greater than
2703 PcdMaximumAsciiStringLength.
2705 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than
2706 MIN(AsciiStrLen(Source), Length).
2707 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
2712 AsciiStrnToUnicodeStrS (
2713 IN CONST CHAR8
*Source
,
2715 OUT CHAR16
*Destination
,
2717 OUT UINTN
*DestinationLength
2721 Convert a Unicode character to upper case only if
2722 it maps to a valid small-case ASCII character.
2724 This internal function only deal with Unicode character
2725 which maps to a valid small-case ASCII character, i.e.
2726 L'a' to L'z'. For other Unicode character, the input character
2727 is returned directly.
2729 @param Char The character to convert.
2731 @retval LowerCharacter If the Char is with range L'a' to L'z'.
2732 @retval Unchanged Otherwise.
2742 Converts a lowercase Ascii character to upper one.
2744 If Chr is lowercase Ascii character, then converts it to upper one.
2746 If Value >= 0xA0, then ASSERT().
2747 If (Value & 0x0F) >= 0x0A, then ASSERT().
2749 @param Chr one Ascii character
2751 @return The uppercase value of Ascii character
2761 Convert binary data to a Base64 encoded ascii string based on RFC4648.
2763 Produce a Null-terminated Ascii string in the output buffer specified by Destination and DestinationSize.
2764 The Ascii string is produced by converting the data string specified by Source and SourceLength.
2766 @param Source Input UINT8 data
2767 @param SourceLength Number of UINT8 bytes of data
2768 @param Destination Pointer to output string buffer
2769 @param DestinationSize Size of ascii buffer. Set to 0 to get the size needed.
2770 Caller is responsible for passing in buffer of DestinationSize
2772 @retval RETURN_SUCCESS When ascii buffer is filled in.
2773 @retval RETURN_INVALID_PARAMETER If Source is NULL or DestinationSize is NULL.
2774 @retval RETURN_INVALID_PARAMETER If SourceLength or DestinationSize is bigger than (MAX_ADDRESS - (UINTN)Destination).
2775 @retval RETURN_BUFFER_TOO_SMALL If SourceLength is 0 and DestinationSize is <1.
2776 @retval RETURN_BUFFER_TOO_SMALL If Destination is NULL or DestinationSize is smaller than required buffersize.
2782 IN CONST UINT8
*Source
,
2783 IN UINTN SourceLength
,
2784 OUT CHAR8
*Destination OPTIONAL
,
2785 IN OUT UINTN
*DestinationSize
2789 Decode Base64 ASCII encoded data to 8-bit binary representation, based on
2792 Decoding occurs according to "Table 1: The Base 64 Alphabet" in RFC4648.
2794 Whitespace is ignored at all positions:
2795 - 0x09 ('\t') horizontal tab
2796 - 0x0A ('\n') new line
2797 - 0x0B ('\v') vertical tab
2798 - 0x0C ('\f') form feed
2799 - 0x0D ('\r') carriage return
2802 The minimum amount of required padding (with ASCII 0x3D, '=') is tolerated
2803 and enforced at the end of the Base64 ASCII encoded data, and only there.
2805 Other characters outside of the encoding alphabet cause the function to
2806 reject the Base64 ASCII encoded data.
2808 @param[in] Source Array of CHAR8 elements containing the Base64
2809 ASCII encoding. May be NULL if SourceSize is
2812 @param[in] SourceSize Number of CHAR8 elements in Source.
2814 @param[out] Destination Array of UINT8 elements receiving the decoded
2815 8-bit binary representation. Allocated by the
2816 caller. May be NULL if DestinationSize is
2817 zero on input. If NULL, decoding is
2818 performed, but the 8-bit binary
2819 representation is not stored. If non-NULL and
2820 the function returns an error, the contents
2821 of Destination are indeterminate.
2823 @param[in,out] DestinationSize On input, the number of UINT8 elements that
2824 the caller allocated for Destination. On
2825 output, if the function returns
2826 RETURN_SUCCESS or RETURN_BUFFER_TOO_SMALL,
2827 the number of UINT8 elements that are
2828 required for decoding the Base64 ASCII
2829 representation. If the function returns a
2830 value different from both RETURN_SUCCESS and
2831 RETURN_BUFFER_TOO_SMALL, then DestinationSize
2832 is indeterminate on output.
2834 @retval RETURN_SUCCESS SourceSize CHAR8 elements at Source have
2835 been decoded to on-output DestinationSize
2836 UINT8 elements at Destination. Note that
2837 RETURN_SUCCESS covers the case when
2838 DestinationSize is zero on input, and
2839 Source decodes to zero bytes (due to
2840 containing at most ignored whitespace).
2842 @retval RETURN_BUFFER_TOO_SMALL The input value of DestinationSize is not
2843 large enough for decoding SourceSize CHAR8
2844 elements at Source. The required number of
2845 UINT8 elements has been stored to
2848 @retval RETURN_INVALID_PARAMETER DestinationSize is NULL.
2850 @retval RETURN_INVALID_PARAMETER Source is NULL, but SourceSize is not zero.
2852 @retval RETURN_INVALID_PARAMETER Destination is NULL, but DestinationSize is
2855 @retval RETURN_INVALID_PARAMETER Source is non-NULL, and (Source +
2856 SourceSize) would wrap around MAX_ADDRESS.
2858 @retval RETURN_INVALID_PARAMETER Destination is non-NULL, and (Destination +
2859 DestinationSize) would wrap around
2860 MAX_ADDRESS, as specified on input.
2862 @retval RETURN_INVALID_PARAMETER None of Source and Destination are NULL,
2863 and CHAR8[SourceSize] at Source overlaps
2864 UINT8[DestinationSize] at Destination, as
2867 @retval RETURN_INVALID_PARAMETER Invalid CHAR8 element encountered in
2873 IN CONST CHAR8
*Source OPTIONAL
,
2874 IN UINTN SourceSize
,
2875 OUT UINT8
*Destination OPTIONAL
,
2876 IN OUT UINTN
*DestinationSize
2880 Converts an 8-bit value to an 8-bit BCD value.
2882 Converts the 8-bit value specified by Value to BCD. The BCD value is
2885 If Value >= 100, then ASSERT().
2887 @param Value The 8-bit value to convert to BCD. Range 0..99.
2889 @return The BCD value.
2900 Converts an 8-bit BCD value to an 8-bit value.
2902 Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit
2905 If Value >= 0xA0, then ASSERT().
2906 If (Value & 0x0F) >= 0x0A, then ASSERT().
2908 @param Value The 8-bit BCD value to convert to an 8-bit value.
2910 @return The 8-bit value is returned.
2920 // File Path Manipulation Functions
2924 Removes the last directory or file entry in a path.
2926 @param[in, out] Path The pointer to the path to modify.
2928 @retval FALSE Nothing was found to remove.
2929 @retval TRUE A directory or file was removed.
2938 Function to clean up paths.
2939 - Single periods in the path are removed.
2940 - Double periods in the path are removed along with a single parent directory.
2941 - Forward slashes L'/' are converted to backward slashes L'\'.
2943 This will be done inline and the existing buffer may be larger than required
2946 @param[in] Path The pointer to the string containing the path.
2948 @return Returns Path, otherwise returns NULL to indicate that an error has occurred.
2952 PathCleanUpDirectories(
2957 // Linked List Functions and Macros
2961 Initializes the head node of a doubly linked list that is declared as a
2962 global variable in a module.
2964 Initializes the forward and backward links of a new linked list. After
2965 initializing a linked list with this macro, the other linked list functions
2966 may be used to add and remove nodes from the linked list. This macro results
2967 in smaller executables by initializing the linked list in the data section,
2968 instead if calling the InitializeListHead() function to perform the
2969 equivalent operation.
2971 @param ListHead The head note of a list to initialize.
2974 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&(ListHead), &(ListHead)}
2977 Iterates over each node in a doubly linked list using each node's forward link.
2979 @param Entry A pointer to a list node used as a loop cursor during iteration
2980 @param ListHead The head node of the doubly linked list
2983 #define BASE_LIST_FOR_EACH(Entry, ListHead) \
2984 for(Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = Entry->ForwardLink)
2987 Iterates over each node in a doubly linked list using each node's forward link
2988 with safety against node removal.
2990 This macro uses NextEntry to temporarily store the next list node so the node
2991 pointed to by Entry may be deleted in the current loop iteration step and
2992 iteration can continue from the node pointed to by NextEntry.
2994 @param Entry A pointer to a list node used as a loop cursor during iteration
2995 @param NextEntry A pointer to a list node used to temporarily store the next node
2996 @param ListHead The head node of the doubly linked list
2999 #define BASE_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead) \
3000 for(Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink;\
3001 Entry != (ListHead); Entry = NextEntry, NextEntry = Entry->ForwardLink)
3004 Checks whether FirstEntry and SecondEntry are part of the same doubly-linked
3007 If FirstEntry is NULL, then ASSERT().
3008 If FirstEntry->ForwardLink is NULL, then ASSERT().
3009 If FirstEntry->BackLink is NULL, then ASSERT().
3010 If SecondEntry is NULL, then ASSERT();
3011 If PcdMaximumLinkedListLength is not zero, and List contains more than
3012 PcdMaximumLinkedListLength nodes, then ASSERT().
3014 @param FirstEntry A pointer to a node in a linked list.
3015 @param SecondEntry A pointer to the node to locate.
3017 @retval TRUE SecondEntry is in the same doubly-linked list as FirstEntry.
3018 @retval FALSE SecondEntry isn't in the same doubly-linked list as FirstEntry,
3019 or FirstEntry is invalid.
3025 IN CONST LIST_ENTRY
*FirstEntry
,
3026 IN CONST LIST_ENTRY
*SecondEntry
3031 Initializes the head node of a doubly linked list, and returns the pointer to
3032 the head node of the doubly linked list.
3034 Initializes the forward and backward links of a new linked list. After
3035 initializing a linked list with this function, the other linked list
3036 functions may be used to add and remove nodes from the linked list. It is up
3037 to the caller of this function to allocate the memory for ListHead.
3039 If ListHead is NULL, then ASSERT().
3041 @param ListHead A pointer to the head node of a new doubly linked list.
3048 InitializeListHead (
3049 IN OUT LIST_ENTRY
*ListHead
3054 Adds a node to the beginning of a doubly linked list, and returns the pointer
3055 to the head node of the doubly linked list.
3057 Adds the node Entry at the beginning of the doubly linked list denoted by
3058 ListHead, and returns ListHead.
3060 If ListHead is NULL, then ASSERT().
3061 If Entry is NULL, then ASSERT().
3062 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
3063 InitializeListHead(), then ASSERT().
3064 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
3065 of nodes in ListHead, including the ListHead node, is greater than or
3066 equal to PcdMaximumLinkedListLength, then ASSERT().
3068 @param ListHead A pointer to the head node of a doubly linked list.
3069 @param Entry A pointer to a node that is to be inserted at the beginning
3070 of a doubly linked list.
3078 IN OUT LIST_ENTRY
*ListHead
,
3079 IN OUT LIST_ENTRY
*Entry
3084 Adds a node to the end of a doubly linked list, and returns the pointer to
3085 the head node of the doubly linked list.
3087 Adds the node Entry to the end of the doubly linked list denoted by ListHead,
3088 and returns ListHead.
3090 If ListHead is NULL, then ASSERT().
3091 If Entry is NULL, then ASSERT().
3092 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
3093 InitializeListHead(), then ASSERT().
3094 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
3095 of nodes in ListHead, including the ListHead node, is greater than or
3096 equal to PcdMaximumLinkedListLength, then ASSERT().
3098 @param ListHead A pointer to the head node of a doubly linked list.
3099 @param Entry A pointer to a node that is to be added at the end of the
3108 IN OUT LIST_ENTRY
*ListHead
,
3109 IN OUT LIST_ENTRY
*Entry
3114 Retrieves the first node of a doubly linked list.
3116 Returns the first node of a doubly linked list. List must have been
3117 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
3118 If List is empty, then List is returned.
3120 If List is NULL, then ASSERT().
3121 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
3122 InitializeListHead(), then ASSERT().
3123 If PcdMaximumLinkedListLength is not zero, and the number of nodes
3124 in List, including the List node, is greater than or equal to
3125 PcdMaximumLinkedListLength, then ASSERT().
3127 @param List A pointer to the head node of a doubly linked list.
3129 @return The first node of a doubly linked list.
3130 @retval List The list is empty.
3136 IN CONST LIST_ENTRY
*List
3141 Retrieves the next node of a doubly linked list.
3143 Returns the node of a doubly linked list that follows Node.
3144 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
3145 or InitializeListHead(). If List is empty, then List is returned.
3147 If List is NULL, then ASSERT().
3148 If Node is NULL, then ASSERT().
3149 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
3150 InitializeListHead(), then ASSERT().
3151 If PcdMaximumLinkedListLength is not zero, and List contains more than
3152 PcdMaximumLinkedListLength nodes, then ASSERT().
3153 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
3155 @param List A pointer to the head node of a doubly linked list.
3156 @param Node A pointer to a node in the doubly linked list.
3158 @return The pointer to the next node if one exists. Otherwise List is returned.
3164 IN CONST LIST_ENTRY
*List
,
3165 IN CONST LIST_ENTRY
*Node
3170 Retrieves the previous node of a doubly linked list.
3172 Returns the node of a doubly linked list that precedes Node.
3173 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
3174 or InitializeListHead(). If List is empty, then List is returned.
3176 If List is NULL, then ASSERT().
3177 If Node is NULL, then ASSERT().
3178 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
3179 InitializeListHead(), then ASSERT().
3180 If PcdMaximumLinkedListLength is not zero, and List contains more than
3181 PcdMaximumLinkedListLength nodes, then ASSERT().
3182 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
3184 @param List A pointer to the head node of a doubly linked list.
3185 @param Node A pointer to a node in the doubly linked list.
3187 @return The pointer to the previous node if one exists. Otherwise List is returned.
3193 IN CONST LIST_ENTRY
*List
,
3194 IN CONST LIST_ENTRY
*Node
3199 Checks to see if a doubly linked list is empty or not.
3201 Checks to see if the doubly linked list is empty. If the linked list contains
3202 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
3204 If ListHead is NULL, then ASSERT().
3205 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
3206 InitializeListHead(), then ASSERT().
3207 If PcdMaximumLinkedListLength is not zero, and the number of nodes
3208 in List, including the List node, is greater than or equal to
3209 PcdMaximumLinkedListLength, then ASSERT().
3211 @param ListHead A pointer to the head node of a doubly linked list.
3213 @retval TRUE The linked list is empty.
3214 @retval FALSE The linked list is not empty.
3220 IN CONST LIST_ENTRY
*ListHead
3225 Determines if a node in a doubly linked list is the head node of a the same
3226 doubly linked list. This function is typically used to terminate a loop that
3227 traverses all the nodes in a doubly linked list starting with the head node.
3229 Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the
3230 nodes in the doubly linked list specified by List. List must have been
3231 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
3233 If List is NULL, then ASSERT().
3234 If Node is NULL, then ASSERT().
3235 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(),
3237 If PcdMaximumLinkedListLength is not zero, and the number of nodes
3238 in List, including the List node, is greater than or equal to
3239 PcdMaximumLinkedListLength, then ASSERT().
3240 If PcdVerifyNodeInList is TRUE and Node is not a node in List the and Node is not equal
3241 to List, then ASSERT().
3243 @param List A pointer to the head node of a doubly linked list.
3244 @param Node A pointer to a node in the doubly linked list.
3246 @retval TRUE Node is the head of the doubly-linked list pointed by List.
3247 @retval FALSE Node is not the head of the doubly-linked list pointed by List.
3253 IN CONST LIST_ENTRY
*List
,
3254 IN CONST LIST_ENTRY
*Node
3259 Determines if a node the last node in a doubly linked list.
3261 Returns TRUE if Node is the last node in the doubly linked list specified by
3262 List. Otherwise, FALSE is returned. List must have been initialized with
3263 INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
3265 If List is NULL, then ASSERT().
3266 If Node is NULL, then ASSERT().
3267 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
3268 InitializeListHead(), then ASSERT().
3269 If PcdMaximumLinkedListLength is not zero, and the number of nodes
3270 in List, including the List node, is greater than or equal to
3271 PcdMaximumLinkedListLength, then ASSERT().
3272 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
3274 @param List A pointer to the head node of a doubly linked list.
3275 @param Node A pointer to a node in the doubly linked list.
3277 @retval TRUE Node is the last node in the linked list.
3278 @retval FALSE Node is not the last node in the linked list.
3284 IN CONST LIST_ENTRY
*List
,
3285 IN CONST LIST_ENTRY
*Node
3290 Swaps the location of two nodes in a doubly linked list, and returns the
3291 first node after the swap.
3293 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
3294 Otherwise, the location of the FirstEntry node is swapped with the location
3295 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
3296 same double linked list as FirstEntry and that double linked list must have
3297 been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
3298 SecondEntry is returned after the nodes are swapped.
3300 If FirstEntry is NULL, then ASSERT().
3301 If SecondEntry is NULL, then ASSERT().
3302 If PcdVerifyNodeInList is TRUE and SecondEntry and FirstEntry are not in the
3303 same linked list, then ASSERT().
3304 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
3305 linked list containing the FirstEntry and SecondEntry nodes, including
3306 the FirstEntry and SecondEntry nodes, is greater than or equal to
3307 PcdMaximumLinkedListLength, then ASSERT().
3309 @param FirstEntry A pointer to a node in a linked list.
3310 @param SecondEntry A pointer to another node in the same linked list.
3312 @return SecondEntry.
3318 IN OUT LIST_ENTRY
*FirstEntry
,
3319 IN OUT LIST_ENTRY
*SecondEntry
3324 Removes a node from a doubly linked list, and returns the node that follows
3327 Removes the node Entry from a doubly linked list. It is up to the caller of
3328 this function to release the memory used by this node if that is required. On
3329 exit, the node following Entry in the doubly linked list is returned. If
3330 Entry is the only node in the linked list, then the head node of the linked
3333 If Entry is NULL, then ASSERT().
3334 If Entry is the head node of an empty list, then ASSERT().
3335 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
3336 linked list containing Entry, including the Entry node, is greater than
3337 or equal to PcdMaximumLinkedListLength, then ASSERT().
3339 @param Entry A pointer to a node in a linked list.
3347 IN CONST LIST_ENTRY
*Entry
3355 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
3356 with zeros. The shifted value is returned.
3358 This function shifts the 64-bit value Operand to the left by Count bits. The
3359 low Count bits are set to zero. The shifted value is returned.
3361 If Count is greater than 63, then ASSERT().
3363 @param Operand The 64-bit operand to shift left.
3364 @param Count The number of bits to shift left.
3366 @return Operand << Count.
3378 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
3379 filled with zeros. The shifted value is returned.
3381 This function shifts the 64-bit value Operand to the right by Count bits. The
3382 high Count bits are set to zero. The shifted value is returned.
3384 If Count is greater than 63, then ASSERT().
3386 @param Operand The 64-bit operand to shift right.
3387 @param Count The number of bits to shift right.
3389 @return Operand >> Count
3401 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
3402 with original integer's bit 63. The shifted value is returned.
3404 This function shifts the 64-bit value Operand to the right by Count bits. The
3405 high Count bits are set to bit 63 of Operand. The shifted value is returned.
3407 If Count is greater than 63, then ASSERT().
3409 @param Operand The 64-bit operand to shift right.
3410 @param Count The number of bits to shift right.
3412 @return Operand >> Count
3424 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
3425 with the high bits that were rotated.
3427 This function rotates the 32-bit value Operand to the left by Count bits. The
3428 low Count bits are fill with the high Count bits of Operand. The rotated
3431 If Count is greater than 31, then ASSERT().
3433 @param Operand The 32-bit operand to rotate left.
3434 @param Count The number of bits to rotate left.
3436 @return Operand << Count
3448 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
3449 with the low bits that were rotated.
3451 This function rotates the 32-bit value Operand to the right by Count bits.
3452 The high Count bits are fill with the low Count bits of Operand. The rotated
3455 If Count is greater than 31, then ASSERT().
3457 @param Operand The 32-bit operand to rotate right.
3458 @param Count The number of bits to rotate right.
3460 @return Operand >> Count
3472 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
3473 with the high bits that were rotated.
3475 This function rotates the 64-bit value Operand to the left by Count bits. The
3476 low Count bits are fill with the high Count bits of Operand. The rotated
3479 If Count is greater than 63, then ASSERT().
3481 @param Operand The 64-bit operand to rotate left.
3482 @param Count The number of bits to rotate left.
3484 @return Operand << Count
3496 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
3497 with the high low bits that were rotated.
3499 This function rotates the 64-bit value Operand to the right by Count bits.
3500 The high Count bits are fill with the low Count bits of Operand. The rotated
3503 If Count is greater than 63, then ASSERT().
3505 @param Operand The 64-bit operand to rotate right.
3506 @param Count The number of bits to rotate right.
3508 @return Operand >> Count
3520 Returns the bit position of the lowest bit set in a 32-bit value.
3522 This function computes the bit position of the lowest bit set in the 32-bit
3523 value specified by Operand. If Operand is zero, then -1 is returned.
3524 Otherwise, a value between 0 and 31 is returned.
3526 @param Operand The 32-bit operand to evaluate.
3528 @retval 0..31 The lowest bit set in Operand was found.
3529 @retval -1 Operand is zero.
3540 Returns the bit position of the lowest bit set in a 64-bit value.
3542 This function computes the bit position of the lowest bit set in the 64-bit
3543 value specified by Operand. If Operand is zero, then -1 is returned.
3544 Otherwise, a value between 0 and 63 is returned.
3546 @param Operand The 64-bit operand to evaluate.
3548 @retval 0..63 The lowest bit set in Operand was found.
3549 @retval -1 Operand is zero.
3561 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
3564 This function computes the bit position of the highest bit set in the 32-bit
3565 value specified by Operand. If Operand is zero, then -1 is returned.
3566 Otherwise, a value between 0 and 31 is returned.
3568 @param Operand The 32-bit operand to evaluate.
3570 @retval 0..31 Position of the highest bit set in Operand if found.
3571 @retval -1 Operand is zero.
3582 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
3585 This function computes the bit position of the highest bit set in the 64-bit
3586 value specified by Operand. If Operand is zero, then -1 is returned.
3587 Otherwise, a value between 0 and 63 is returned.
3589 @param Operand The 64-bit operand to evaluate.
3591 @retval 0..63 Position of the highest bit set in Operand if found.
3592 @retval -1 Operand is zero.
3603 Returns the value of the highest bit set in a 32-bit value. Equivalent to
3606 This function computes the value of the highest bit set in the 32-bit value
3607 specified by Operand. If Operand is zero, then zero is returned.
3609 @param Operand The 32-bit operand to evaluate.
3611 @return 1 << HighBitSet32(Operand)
3612 @retval 0 Operand is zero.
3623 Returns the value of the highest bit set in a 64-bit value. Equivalent to
3626 This function computes the value of the highest bit set in the 64-bit value
3627 specified by Operand. If Operand is zero, then zero is returned.
3629 @param Operand The 64-bit operand to evaluate.
3631 @return 1 << HighBitSet64(Operand)
3632 @retval 0 Operand is zero.
3643 Switches the endianness of a 16-bit integer.
3645 This function swaps the bytes in a 16-bit unsigned value to switch the value
3646 from little endian to big endian or vice versa. The byte swapped value is
3649 @param Value A 16-bit unsigned value.
3651 @return The byte swapped Value.
3662 Switches the endianness of a 32-bit integer.
3664 This function swaps the bytes in a 32-bit unsigned value to switch the value
3665 from little endian to big endian or vice versa. The byte swapped value is
3668 @param Value A 32-bit unsigned value.
3670 @return The byte swapped Value.
3681 Switches the endianness of a 64-bit integer.
3683 This function swaps the bytes in a 64-bit unsigned value to switch the value
3684 from little endian to big endian or vice versa. The byte swapped value is
3687 @param Value A 64-bit unsigned value.
3689 @return The byte swapped Value.
3700 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
3701 generates a 64-bit unsigned result.
3703 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
3704 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
3705 bit unsigned result is returned.
3707 @param Multiplicand A 64-bit unsigned value.
3708 @param Multiplier A 32-bit unsigned value.
3710 @return Multiplicand * Multiplier
3716 IN UINT64 Multiplicand
,
3717 IN UINT32 Multiplier
3722 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
3723 generates a 64-bit unsigned result.
3725 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
3726 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
3727 bit unsigned result is returned.
3729 @param Multiplicand A 64-bit unsigned value.
3730 @param Multiplier A 64-bit unsigned value.
3732 @return Multiplicand * Multiplier.
3738 IN UINT64 Multiplicand
,
3739 IN UINT64 Multiplier
3744 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
3745 64-bit signed result.
3747 This function multiples the 64-bit signed value Multiplicand by the 64-bit
3748 signed value Multiplier and generates a 64-bit signed result. This 64-bit
3749 signed result is returned.
3751 @param Multiplicand A 64-bit signed value.
3752 @param Multiplier A 64-bit signed value.
3754 @return Multiplicand * Multiplier
3760 IN INT64 Multiplicand
,
3766 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
3767 a 64-bit unsigned result.
3769 This function divides the 64-bit unsigned value Dividend by the 32-bit
3770 unsigned value Divisor and generates a 64-bit unsigned quotient. This
3771 function returns the 64-bit unsigned quotient.
3773 If Divisor is 0, then ASSERT().
3775 @param Dividend A 64-bit unsigned value.
3776 @param Divisor A 32-bit unsigned value.
3778 @return Dividend / Divisor.
3790 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
3791 a 32-bit unsigned remainder.
3793 This function divides the 64-bit unsigned value Dividend by the 32-bit
3794 unsigned value Divisor and generates a 32-bit remainder. This function
3795 returns the 32-bit unsigned remainder.
3797 If Divisor is 0, then ASSERT().
3799 @param Dividend A 64-bit unsigned value.
3800 @param Divisor A 32-bit unsigned value.
3802 @return Dividend % Divisor.
3814 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
3815 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
3817 This function divides the 64-bit unsigned value Dividend by the 32-bit
3818 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
3819 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
3820 This function returns the 64-bit unsigned quotient.
3822 If Divisor is 0, then ASSERT().
3824 @param Dividend A 64-bit unsigned value.
3825 @param Divisor A 32-bit unsigned value.
3826 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
3827 optional and may be NULL.
3829 @return Dividend / Divisor.
3834 DivU64x32Remainder (
3837 OUT UINT32
*Remainder OPTIONAL
3842 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
3843 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
3845 This function divides the 64-bit unsigned value Dividend by the 64-bit
3846 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
3847 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
3848 This function returns the 64-bit unsigned quotient.
3850 If Divisor is 0, then ASSERT().
3852 @param Dividend A 64-bit unsigned value.
3853 @param Divisor A 64-bit unsigned value.
3854 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
3855 optional and may be NULL.
3857 @return Dividend / Divisor.
3862 DivU64x64Remainder (
3865 OUT UINT64
*Remainder OPTIONAL
3870 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
3871 64-bit signed result and a optional 64-bit signed remainder.
3873 This function divides the 64-bit signed value Dividend by the 64-bit signed
3874 value Divisor and generates a 64-bit signed quotient. If Remainder is not
3875 NULL, then the 64-bit signed remainder is returned in Remainder. This
3876 function returns the 64-bit signed quotient.
3878 It is the caller's responsibility to not call this function with a Divisor of 0.
3879 If Divisor is 0, then the quotient and remainder should be assumed to be
3880 the largest negative integer.
3882 If Divisor is 0, then ASSERT().
3884 @param Dividend A 64-bit signed value.
3885 @param Divisor A 64-bit signed value.
3886 @param Remainder A pointer to a 64-bit signed value. This parameter is
3887 optional and may be NULL.
3889 @return Dividend / Divisor.
3894 DivS64x64Remainder (
3897 OUT INT64
*Remainder OPTIONAL
3902 Reads a 16-bit value from memory that may be unaligned.
3904 This function returns the 16-bit value pointed to by Buffer. The function
3905 guarantees that the read operation does not produce an alignment fault.
3907 If the Buffer is NULL, then ASSERT().
3909 @param Buffer The pointer to a 16-bit value that may be unaligned.
3911 @return The 16-bit value read from Buffer.
3917 IN CONST UINT16
*Buffer
3922 Writes a 16-bit value to memory that may be unaligned.
3924 This function writes the 16-bit value specified by Value to Buffer. Value is
3925 returned. The function guarantees that the write operation does not produce
3928 If the Buffer is NULL, then ASSERT().
3930 @param Buffer The pointer to a 16-bit value that may be unaligned.
3931 @param Value 16-bit value to write to Buffer.
3933 @return The 16-bit value to write to Buffer.
3945 Reads a 24-bit value from memory that may be unaligned.
3947 This function returns the 24-bit value pointed to by Buffer. The function
3948 guarantees that the read operation does not produce an alignment fault.
3950 If the Buffer is NULL, then ASSERT().
3952 @param Buffer The pointer to a 24-bit value that may be unaligned.
3954 @return The 24-bit value read from Buffer.
3960 IN CONST UINT32
*Buffer
3965 Writes a 24-bit value to memory that may be unaligned.
3967 This function writes the 24-bit value specified by Value to Buffer. Value is
3968 returned. The function guarantees that the write operation does not produce
3971 If the Buffer is NULL, then ASSERT().
3973 @param Buffer The pointer to a 24-bit value that may be unaligned.
3974 @param Value 24-bit value to write to Buffer.
3976 @return The 24-bit value to write to Buffer.
3988 Reads a 32-bit value from memory that may be unaligned.
3990 This function returns the 32-bit value pointed to by Buffer. The function
3991 guarantees that the read operation does not produce an alignment fault.
3993 If the Buffer is NULL, then ASSERT().
3995 @param Buffer The pointer to a 32-bit value that may be unaligned.
3997 @return The 32-bit value read from Buffer.
4003 IN CONST UINT32
*Buffer
4008 Writes a 32-bit value to memory that may be unaligned.
4010 This function writes the 32-bit value specified by Value to Buffer. Value is
4011 returned. The function guarantees that the write operation does not produce
4014 If the Buffer is NULL, then ASSERT().
4016 @param Buffer The pointer to a 32-bit value that may be unaligned.
4017 @param Value 32-bit value to write to Buffer.
4019 @return The 32-bit value to write to Buffer.
4031 Reads a 64-bit value from memory that may be unaligned.
4033 This function returns the 64-bit value pointed to by Buffer. The function
4034 guarantees that the read operation does not produce an alignment fault.
4036 If the Buffer is NULL, then ASSERT().
4038 @param Buffer The pointer to a 64-bit value that may be unaligned.
4040 @return The 64-bit value read from Buffer.
4046 IN CONST UINT64
*Buffer
4051 Writes a 64-bit value to memory that may be unaligned.
4053 This function writes the 64-bit value specified by Value to Buffer. Value is
4054 returned. The function guarantees that the write operation does not produce
4057 If the Buffer is NULL, then ASSERT().
4059 @param Buffer The pointer to a 64-bit value that may be unaligned.
4060 @param Value 64-bit value to write to Buffer.
4062 @return The 64-bit value to write to Buffer.
4074 // Bit Field Functions
4078 Returns a bit field from an 8-bit value.
4080 Returns the bitfield specified by the StartBit and the EndBit from Operand.
4082 If 8-bit operations are not supported, then ASSERT().
4083 If StartBit is greater than 7, then ASSERT().
4084 If EndBit is greater than 7, then ASSERT().
4085 If EndBit is less than StartBit, then ASSERT().
4087 @param Operand Operand on which to perform the bitfield operation.
4088 @param StartBit The ordinal of the least significant bit in the bit field.
4090 @param EndBit The ordinal of the most significant bit in the bit field.
4093 @return The bit field read.
4106 Writes a bit field to an 8-bit value, and returns the result.
4108 Writes Value to the bit field specified by the StartBit and the EndBit in
4109 Operand. All other bits in Operand are preserved. The new 8-bit value is
4112 If 8-bit operations are not supported, then ASSERT().
4113 If StartBit is greater than 7, then ASSERT().
4114 If EndBit is greater than 7, then ASSERT().
4115 If EndBit is less than StartBit, then ASSERT().
4116 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4118 @param Operand Operand on which to perform the bitfield operation.
4119 @param StartBit The ordinal of the least significant bit in the bit field.
4121 @param EndBit The ordinal of the most significant bit in the bit field.
4123 @param Value New value of the bit field.
4125 @return The new 8-bit value.
4139 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
4142 Performs a bitwise OR between the bit field specified by StartBit
4143 and EndBit in Operand and the value specified by OrData. All other bits in
4144 Operand are preserved. The new 8-bit value is returned.
4146 If 8-bit operations are not supported, then ASSERT().
4147 If StartBit is greater than 7, then ASSERT().
4148 If EndBit is greater than 7, then ASSERT().
4149 If EndBit is less than StartBit, then ASSERT().
4150 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4152 @param Operand Operand on which to perform the bitfield operation.
4153 @param StartBit The ordinal of the least significant bit in the bit field.
4155 @param EndBit The ordinal of the most significant bit in the bit field.
4157 @param OrData The value to OR with the read value from the value
4159 @return The new 8-bit value.
4173 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
4176 Performs a bitwise AND between the bit field specified by StartBit and EndBit
4177 in Operand and the value specified by AndData. All other bits in Operand are
4178 preserved. The new 8-bit value is returned.
4180 If 8-bit operations are not supported, then ASSERT().
4181 If StartBit is greater than 7, then ASSERT().
4182 If EndBit is greater than 7, then ASSERT().
4183 If EndBit is less than StartBit, then ASSERT().
4184 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4186 @param Operand Operand on which to perform the bitfield operation.
4187 @param StartBit The ordinal of the least significant bit in the bit field.
4189 @param EndBit The ordinal of the most significant bit in the bit field.
4191 @param AndData The value to AND with the read value from the value.
4193 @return The new 8-bit value.
4207 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
4208 bitwise OR, and returns the result.
4210 Performs a bitwise AND between the bit field specified by StartBit and EndBit
4211 in Operand and the value specified by AndData, followed by a bitwise
4212 OR with value specified by OrData. All other bits in Operand are
4213 preserved. The new 8-bit value is returned.
4215 If 8-bit operations are not supported, then ASSERT().
4216 If StartBit is greater than 7, then ASSERT().
4217 If EndBit is greater than 7, then ASSERT().
4218 If EndBit is less than StartBit, then ASSERT().
4219 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4220 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4222 @param Operand Operand on which to perform the bitfield operation.
4223 @param StartBit The ordinal of the least significant bit in the bit field.
4225 @param EndBit The ordinal of the most significant bit in the bit field.
4227 @param AndData The value to AND with the read value from the value.
4228 @param OrData The value to OR with the result of the AND operation.
4230 @return The new 8-bit value.
4235 BitFieldAndThenOr8 (
4245 Returns a bit field from a 16-bit value.
4247 Returns the bitfield specified by the StartBit and the EndBit from Operand.
4249 If 16-bit operations are not supported, then ASSERT().
4250 If StartBit is greater than 15, then ASSERT().
4251 If EndBit is greater than 15, then ASSERT().
4252 If EndBit is less than StartBit, then ASSERT().
4254 @param Operand Operand on which to perform the bitfield operation.
4255 @param StartBit The ordinal of the least significant bit in the bit field.
4257 @param EndBit The ordinal of the most significant bit in the bit field.
4260 @return The bit field read.
4273 Writes a bit field to a 16-bit value, and returns the result.
4275 Writes Value to the bit field specified by the StartBit and the EndBit in
4276 Operand. All other bits in Operand are preserved. The new 16-bit value is
4279 If 16-bit operations are not supported, then ASSERT().
4280 If StartBit is greater than 15, then ASSERT().
4281 If EndBit is greater than 15, then ASSERT().
4282 If EndBit is less than StartBit, then ASSERT().
4283 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4285 @param Operand Operand on which to perform the bitfield operation.
4286 @param StartBit The ordinal of the least significant bit in the bit field.
4288 @param EndBit The ordinal of the most significant bit in the bit field.
4290 @param Value New value of the bit field.
4292 @return The new 16-bit value.
4306 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
4309 Performs a bitwise OR between the bit field specified by StartBit
4310 and EndBit in Operand and the value specified by OrData. All other bits in
4311 Operand are preserved. The new 16-bit value is returned.
4313 If 16-bit operations are not supported, then ASSERT().
4314 If StartBit is greater than 15, then ASSERT().
4315 If EndBit is greater than 15, then ASSERT().
4316 If EndBit is less than StartBit, then ASSERT().
4317 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4319 @param Operand Operand on which to perform the bitfield operation.
4320 @param StartBit The ordinal of the least significant bit in the bit field.
4322 @param EndBit The ordinal of the most significant bit in the bit field.
4324 @param OrData The value to OR with the read value from the value
4326 @return The new 16-bit value.
4340 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
4343 Performs a bitwise AND between the bit field specified by StartBit and EndBit
4344 in Operand and the value specified by AndData. All other bits in Operand are
4345 preserved. The new 16-bit value is returned.
4347 If 16-bit operations are not supported, then ASSERT().
4348 If StartBit is greater than 15, then ASSERT().
4349 If EndBit is greater than 15, then ASSERT().
4350 If EndBit is less than StartBit, then ASSERT().
4351 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4353 @param Operand Operand on which to perform the bitfield operation.
4354 @param StartBit The ordinal of the least significant bit in the bit field.
4356 @param EndBit The ordinal of the most significant bit in the bit field.
4358 @param AndData The value to AND with the read value from the value
4360 @return The new 16-bit value.
4374 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
4375 bitwise OR, and returns the result.
4377 Performs a bitwise AND between the bit field specified by StartBit and EndBit
4378 in Operand and the value specified by AndData, followed by a bitwise
4379 OR with value specified by OrData. All other bits in Operand are
4380 preserved. The new 16-bit value is returned.
4382 If 16-bit operations are not supported, then ASSERT().
4383 If StartBit is greater than 15, then ASSERT().
4384 If EndBit is greater than 15, then ASSERT().
4385 If EndBit is less than StartBit, then ASSERT().
4386 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4387 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4389 @param Operand Operand on which to perform the bitfield operation.
4390 @param StartBit The ordinal of the least significant bit in the bit field.
4392 @param EndBit The ordinal of the most significant bit in the bit field.
4394 @param AndData The value to AND with the read value from the value.
4395 @param OrData The value to OR with the result of the AND operation.
4397 @return The new 16-bit value.
4402 BitFieldAndThenOr16 (
4412 Returns a bit field from a 32-bit value.
4414 Returns the bitfield specified by the StartBit and the EndBit from Operand.
4416 If 32-bit operations are not supported, then ASSERT().
4417 If StartBit is greater than 31, then ASSERT().
4418 If EndBit is greater than 31, then ASSERT().
4419 If EndBit is less than StartBit, then ASSERT().
4421 @param Operand Operand on which to perform the bitfield operation.
4422 @param StartBit The ordinal of the least significant bit in the bit field.
4424 @param EndBit The ordinal of the most significant bit in the bit field.
4427 @return The bit field read.
4440 Writes a bit field to a 32-bit value, and returns the result.
4442 Writes Value to the bit field specified by the StartBit and the EndBit in
4443 Operand. All other bits in Operand are preserved. The new 32-bit value is
4446 If 32-bit operations are not supported, then ASSERT().
4447 If StartBit is greater than 31, then ASSERT().
4448 If EndBit is greater than 31, then ASSERT().
4449 If EndBit is less than StartBit, then ASSERT().
4450 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4452 @param Operand Operand on which to perform the bitfield operation.
4453 @param StartBit The ordinal of the least significant bit in the bit field.
4455 @param EndBit The ordinal of the most significant bit in the bit field.
4457 @param Value New value of the bit field.
4459 @return The new 32-bit value.
4473 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
4476 Performs a bitwise OR between the bit field specified by StartBit
4477 and EndBit in Operand and the value specified by OrData. All other bits in
4478 Operand are preserved. The new 32-bit value is returned.
4480 If 32-bit operations are not supported, then ASSERT().
4481 If StartBit is greater than 31, then ASSERT().
4482 If EndBit is greater than 31, then ASSERT().
4483 If EndBit is less than StartBit, then ASSERT().
4484 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4486 @param Operand Operand on which to perform the bitfield operation.
4487 @param StartBit The ordinal of the least significant bit in the bit field.
4489 @param EndBit The ordinal of the most significant bit in the bit field.
4491 @param OrData The value to OR with the read value from the value.
4493 @return The new 32-bit value.
4507 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
4510 Performs a bitwise AND between the bit field specified by StartBit and EndBit
4511 in Operand and the value specified by AndData. All other bits in Operand are
4512 preserved. The new 32-bit value is returned.
4514 If 32-bit operations are not supported, then ASSERT().
4515 If StartBit is greater than 31, then ASSERT().
4516 If EndBit is greater than 31, then ASSERT().
4517 If EndBit is less than StartBit, then ASSERT().
4518 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4520 @param Operand Operand on which to perform the bitfield operation.
4521 @param StartBit The ordinal of the least significant bit in the bit field.
4523 @param EndBit The ordinal of the most significant bit in the bit field.
4525 @param AndData The value to AND with the read value from the value
4527 @return The new 32-bit value.
4541 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
4542 bitwise OR, and returns the result.
4544 Performs a bitwise AND between the bit field specified by StartBit and EndBit
4545 in Operand and the value specified by AndData, followed by a bitwise
4546 OR with value specified by OrData. All other bits in Operand are
4547 preserved. The new 32-bit value is returned.
4549 If 32-bit operations are not supported, then ASSERT().
4550 If StartBit is greater than 31, then ASSERT().
4551 If EndBit is greater than 31, then ASSERT().
4552 If EndBit is less than StartBit, then ASSERT().
4553 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4554 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4556 @param Operand Operand on which to perform the bitfield operation.
4557 @param StartBit The ordinal of the least significant bit in the bit field.
4559 @param EndBit The ordinal of the most significant bit in the bit field.
4561 @param AndData The value to AND with the read value from the value.
4562 @param OrData The value to OR with the result of the AND operation.
4564 @return The new 32-bit value.
4569 BitFieldAndThenOr32 (
4579 Returns a bit field from a 64-bit value.
4581 Returns the bitfield specified by the StartBit and the EndBit from Operand.
4583 If 64-bit operations are not supported, then ASSERT().
4584 If StartBit is greater than 63, then ASSERT().
4585 If EndBit is greater than 63, then ASSERT().
4586 If EndBit is less than StartBit, then ASSERT().
4588 @param Operand Operand on which to perform the bitfield operation.
4589 @param StartBit The ordinal of the least significant bit in the bit field.
4591 @param EndBit The ordinal of the most significant bit in the bit field.
4594 @return The bit field read.
4607 Writes a bit field to a 64-bit value, and returns the result.
4609 Writes Value to the bit field specified by the StartBit and the EndBit in
4610 Operand. All other bits in Operand are preserved. The new 64-bit value is
4613 If 64-bit operations are not supported, then ASSERT().
4614 If StartBit is greater than 63, then ASSERT().
4615 If EndBit is greater than 63, then ASSERT().
4616 If EndBit is less than StartBit, then ASSERT().
4617 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4619 @param Operand Operand on which to perform the bitfield operation.
4620 @param StartBit The ordinal of the least significant bit in the bit field.
4622 @param EndBit The ordinal of the most significant bit in the bit field.
4624 @param Value New value of the bit field.
4626 @return The new 64-bit value.
4640 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
4643 Performs a bitwise OR between the bit field specified by StartBit
4644 and EndBit in Operand and the value specified by OrData. All other bits in
4645 Operand are preserved. The new 64-bit value is returned.
4647 If 64-bit operations are not supported, then ASSERT().
4648 If StartBit is greater than 63, then ASSERT().
4649 If EndBit is greater than 63, then ASSERT().
4650 If EndBit is less than StartBit, then ASSERT().
4651 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4653 @param Operand Operand on which to perform the bitfield operation.
4654 @param StartBit The ordinal of the least significant bit in the bit field.
4656 @param EndBit The ordinal of the most significant bit in the bit field.
4658 @param OrData The value to OR with the read value from the value
4660 @return The new 64-bit value.
4674 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
4677 Performs a bitwise AND between the bit field specified by StartBit and EndBit
4678 in Operand and the value specified by AndData. All other bits in Operand are
4679 preserved. The new 64-bit value is returned.
4681 If 64-bit operations are not supported, then ASSERT().
4682 If StartBit is greater than 63, then ASSERT().
4683 If EndBit is greater than 63, then ASSERT().
4684 If EndBit is less than StartBit, then ASSERT().
4685 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4687 @param Operand Operand on which to perform the bitfield operation.
4688 @param StartBit The ordinal of the least significant bit in the bit field.
4690 @param EndBit The ordinal of the most significant bit in the bit field.
4692 @param AndData The value to AND with the read value from the value
4694 @return The new 64-bit value.
4708 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
4709 bitwise OR, and returns the result.
4711 Performs a bitwise AND between the bit field specified by StartBit and EndBit
4712 in Operand and the value specified by AndData, followed by a bitwise
4713 OR with value specified by OrData. All other bits in Operand are
4714 preserved. The new 64-bit value is returned.
4716 If 64-bit operations are not supported, then ASSERT().
4717 If StartBit is greater than 63, then ASSERT().
4718 If EndBit is greater than 63, then ASSERT().
4719 If EndBit is less than StartBit, then ASSERT().
4720 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4721 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4723 @param Operand Operand on which to perform the bitfield operation.
4724 @param StartBit The ordinal of the least significant bit in the bit field.
4726 @param EndBit The ordinal of the most significant bit in the bit field.
4728 @param AndData The value to AND with the read value from the value.
4729 @param OrData The value to OR with the result of the AND operation.
4731 @return The new 64-bit value.
4736 BitFieldAndThenOr64 (
4745 Reads a bit field from a 32-bit value, counts and returns
4746 the number of set bits.
4748 Counts the number of set bits in the bit field specified by
4749 StartBit and EndBit in Operand. The count is returned.
4751 If StartBit is greater than 31, then ASSERT().
4752 If EndBit is greater than 31, then ASSERT().
4753 If EndBit is less than StartBit, then ASSERT().
4755 @param Operand Operand on which to perform the bitfield operation.
4756 @param StartBit The ordinal of the least significant bit in the bit field.
4758 @param EndBit The ordinal of the most significant bit in the bit field.
4761 @return The number of bits set between StartBit and EndBit.
4766 BitFieldCountOnes32 (
4773 Reads a bit field from a 64-bit value, counts and returns
4774 the number of set bits.
4776 Counts the number of set bits in the bit field specified by
4777 StartBit and EndBit in Operand. The count is returned.
4779 If StartBit is greater than 63, then ASSERT().
4780 If EndBit is greater than 63, then ASSERT().
4781 If EndBit is less than StartBit, then ASSERT().
4783 @param Operand Operand on which to perform the bitfield operation.
4784 @param StartBit The ordinal of the least significant bit in the bit field.
4786 @param EndBit The ordinal of the most significant bit in the bit field.
4789 @return The number of bits set between StartBit and EndBit.
4794 BitFieldCountOnes64 (
4801 // Base Library Checksum Functions
4805 Returns the sum of all elements in a buffer in unit of UINT8.
4806 During calculation, the carry bits are dropped.
4808 This function calculates the sum of all elements in a buffer
4809 in unit of UINT8. The carry bits in result of addition are dropped.
4810 The result is returned as UINT8. If Length is Zero, then Zero is
4813 If Buffer is NULL, then ASSERT().
4814 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4816 @param Buffer The pointer to the buffer to carry out the sum operation.
4817 @param Length The size, in bytes, of Buffer.
4819 @return Sum The sum of Buffer with carry bits dropped during additions.
4825 IN CONST UINT8
*Buffer
,
4831 Returns the two's complement checksum of all elements in a buffer
4834 This function first calculates the sum of the 8-bit values in the
4835 buffer specified by Buffer and Length. The carry bits in the result
4836 of addition are dropped. Then, the two's complement of the sum is
4837 returned. If Length is 0, then 0 is returned.
4839 If Buffer is NULL, then ASSERT().
4840 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4842 @param Buffer The pointer to the buffer to carry out the checksum operation.
4843 @param Length The size, in bytes, of Buffer.
4845 @return Checksum The two's complement checksum of Buffer.
4850 CalculateCheckSum8 (
4851 IN CONST UINT8
*Buffer
,
4857 Returns the sum of all elements in a buffer of 16-bit values. During
4858 calculation, the carry bits are dropped.
4860 This function calculates the sum of the 16-bit values in the buffer
4861 specified by Buffer and Length. The carry bits in result of addition are dropped.
4862 The 16-bit result is returned. If Length is 0, then 0 is returned.
4864 If Buffer is NULL, then ASSERT().
4865 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
4866 If Length is not aligned on a 16-bit boundary, then ASSERT().
4867 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4869 @param Buffer The pointer to the buffer to carry out the sum operation.
4870 @param Length The size, in bytes, of Buffer.
4872 @return Sum The sum of Buffer with carry bits dropped during additions.
4878 IN CONST UINT16
*Buffer
,
4884 Returns the two's complement checksum of all elements in a buffer of
4887 This function first calculates the sum of the 16-bit values in the buffer
4888 specified by Buffer and Length. The carry bits in the result of addition
4889 are dropped. Then, the two's complement of the sum is returned. If Length
4890 is 0, then 0 is returned.
4892 If Buffer is NULL, then ASSERT().
4893 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
4894 If Length is not aligned on a 16-bit boundary, then ASSERT().
4895 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4897 @param Buffer The pointer to the buffer to carry out the checksum operation.
4898 @param Length The size, in bytes, of Buffer.
4900 @return Checksum The two's complement checksum of Buffer.
4905 CalculateCheckSum16 (
4906 IN CONST UINT16
*Buffer
,
4912 Returns the sum of all elements in a buffer of 32-bit values. During
4913 calculation, the carry bits are dropped.
4915 This function calculates the sum of the 32-bit values in the buffer
4916 specified by Buffer and Length. The carry bits in result of addition are dropped.
4917 The 32-bit result is returned. If Length is 0, then 0 is returned.
4919 If Buffer is NULL, then ASSERT().
4920 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
4921 If Length is not aligned on a 32-bit boundary, then ASSERT().
4922 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4924 @param Buffer The pointer to the buffer to carry out the sum operation.
4925 @param Length The size, in bytes, of Buffer.
4927 @return Sum The sum of Buffer with carry bits dropped during additions.
4933 IN CONST UINT32
*Buffer
,
4939 Returns the two's complement checksum of all elements in a buffer of
4942 This function first calculates the sum of the 32-bit values in the buffer
4943 specified by Buffer and Length. The carry bits in the result of addition
4944 are dropped. Then, the two's complement of the sum is returned. If Length
4945 is 0, then 0 is returned.
4947 If Buffer is NULL, then ASSERT().
4948 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
4949 If Length is not aligned on a 32-bit boundary, then ASSERT().
4950 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4952 @param Buffer The pointer to the buffer to carry out the checksum operation.
4953 @param Length The size, in bytes, of Buffer.
4955 @return Checksum The two's complement checksum of Buffer.
4960 CalculateCheckSum32 (
4961 IN CONST UINT32
*Buffer
,
4967 Returns the sum of all elements in a buffer of 64-bit values. During
4968 calculation, the carry bits are dropped.
4970 This function calculates the sum of the 64-bit values in the buffer
4971 specified by Buffer and Length. The carry bits in result of addition are dropped.
4972 The 64-bit result is returned. If Length is 0, then 0 is returned.
4974 If Buffer is NULL, then ASSERT().
4975 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
4976 If Length is not aligned on a 64-bit boundary, then ASSERT().
4977 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4979 @param Buffer The pointer to the buffer to carry out the sum operation.
4980 @param Length The size, in bytes, of Buffer.
4982 @return Sum The sum of Buffer with carry bits dropped during additions.
4988 IN CONST UINT64
*Buffer
,
4994 Returns the two's complement checksum of all elements in a buffer of
4997 This function first calculates the sum of the 64-bit values in the buffer
4998 specified by Buffer and Length. The carry bits in the result of addition
4999 are dropped. Then, the two's complement of the sum is returned. If Length
5000 is 0, then 0 is returned.
5002 If Buffer is NULL, then ASSERT().
5003 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
5004 If Length is not aligned on a 64-bit boundary, then ASSERT().
5005 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
5007 @param Buffer The pointer to the buffer to carry out the checksum operation.
5008 @param Length The size, in bytes, of Buffer.
5010 @return Checksum The two's complement checksum of Buffer.
5015 CalculateCheckSum64 (
5016 IN CONST UINT64
*Buffer
,
5021 Computes and returns a 32-bit CRC for a data buffer.
5022 CRC32 value bases on ITU-T V.42.
5024 If Buffer is NULL, then ASSERT().
5025 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
5027 @param[in] Buffer A pointer to the buffer on which the 32-bit CRC is to be computed.
5028 @param[in] Length The number of bytes in the buffer Data.
5030 @retval Crc32 The 32-bit CRC was computed for the data buffer.
5041 // Base Library CPU Functions
5045 Function entry point used when a stack switch is requested with SwitchStack()
5047 @param Context1 Context1 parameter passed into SwitchStack().
5048 @param Context2 Context2 parameter passed into SwitchStack().
5053 (EFIAPI
*SWITCH_STACK_ENTRY_POINT
)(
5054 IN VOID
*Context1
, OPTIONAL
5055 IN VOID
*Context2 OPTIONAL
5060 Used to serialize load and store operations.
5062 All loads and stores that proceed calls to this function are guaranteed to be
5063 globally visible when this function returns.
5074 Saves the current CPU context that can be restored with a call to LongJump()
5077 Saves the current CPU context in the buffer specified by JumpBuffer and
5078 returns 0. The initial call to SetJump() must always return 0. Subsequent
5079 calls to LongJump() cause a non-zero value to be returned by SetJump().
5081 If JumpBuffer is NULL, then ASSERT().
5082 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
5084 NOTE: The structure BASE_LIBRARY_JUMP_BUFFER is CPU architecture specific.
5085 The same structure must never be used for more than one CPU architecture context.
5086 For example, a BASE_LIBRARY_JUMP_BUFFER allocated by an IA-32 module must never be used from an x64 module.
5087 SetJump()/LongJump() is not currently supported for the EBC processor type.
5089 @param JumpBuffer A pointer to CPU context buffer.
5091 @retval 0 Indicates a return from SetJump().
5098 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
5103 Restores the CPU context that was saved with SetJump().
5105 Restores the CPU context from the buffer specified by JumpBuffer. This
5106 function never returns to the caller. Instead is resumes execution based on
5107 the state of JumpBuffer.
5109 If JumpBuffer is NULL, then ASSERT().
5110 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
5111 If Value is 0, then ASSERT().
5113 @param JumpBuffer A pointer to CPU context buffer.
5114 @param Value The value to return when the SetJump() context is
5115 restored and must be non-zero.
5121 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
5127 Enables CPU interrupts.
5138 Disables CPU interrupts.
5149 Disables CPU interrupts and returns the interrupt state prior to the disable
5152 @retval TRUE CPU interrupts were enabled on entry to this call.
5153 @retval FALSE CPU interrupts were disabled on entry to this call.
5158 SaveAndDisableInterrupts (
5164 Enables CPU interrupts for the smallest window required to capture any
5170 EnableDisableInterrupts (
5176 Retrieves the current CPU interrupt state.
5178 Returns TRUE if interrupts are currently enabled. Otherwise
5181 @retval TRUE CPU interrupts are enabled.
5182 @retval FALSE CPU interrupts are disabled.
5193 Set the current CPU interrupt state.
5195 Sets the current CPU interrupt state to the state specified by
5196 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
5197 InterruptState is FALSE, then interrupts are disabled. InterruptState is
5200 @param InterruptState TRUE if interrupts should enabled. FALSE if
5201 interrupts should be disabled.
5203 @return InterruptState
5209 IN BOOLEAN InterruptState
5214 Requests CPU to pause for a short period of time.
5216 Requests CPU to pause for a short period of time. Typically used in MP
5217 systems to prevent memory starvation while waiting for a spin lock.
5228 Transfers control to a function starting with a new stack.
5230 Transfers control to the function specified by EntryPoint using the
5231 new stack specified by NewStack and passing in the parameters specified
5232 by Context1 and Context2. Context1 and Context2 are optional and may
5233 be NULL. The function EntryPoint must never return. This function
5234 supports a variable number of arguments following the NewStack parameter.
5235 These additional arguments are ignored on IA-32, x64, and EBC architectures.
5236 Itanium processors expect one additional parameter of type VOID * that specifies
5237 the new backing store pointer.
5239 If EntryPoint is NULL, then ASSERT().
5240 If NewStack is NULL, then ASSERT().
5242 @param EntryPoint A pointer to function to call with the new stack.
5243 @param Context1 A pointer to the context to pass into the EntryPoint
5245 @param Context2 A pointer to the context to pass into the EntryPoint
5247 @param NewStack A pointer to the new stack to use for the EntryPoint
5249 @param ... This variable argument list is ignored for IA-32, x64, and
5250 EBC architectures. For Itanium processors, this variable
5251 argument list is expected to contain a single parameter of
5252 type VOID * that specifies the new backing store pointer.
5259 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
5260 IN VOID
*Context1
, OPTIONAL
5261 IN VOID
*Context2
, OPTIONAL
5268 Generates a breakpoint on the CPU.
5270 Generates a breakpoint on the CPU. The breakpoint must be implemented such
5271 that code can resume normal execution after the breakpoint.
5282 Executes an infinite loop.
5284 Forces the CPU to execute an infinite loop. A debugger may be used to skip
5285 past the loop and the code that follows the loop must execute properly. This
5286 implies that the infinite loop must not cause the code that follow it to be
5298 Uses as a barrier to stop speculative execution.
5300 Ensures that no later instruction will execute speculatively, until all prior
5301 instructions have completed.
5306 SpeculationBarrier (
5311 #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
5313 /// IA32 and x64 Specific Functions.
5314 /// Byte packed structure for 16-bit Real Mode EFLAGS.
5318 UINT32 CF
:1; ///< Carry Flag.
5319 UINT32 Reserved_0
:1; ///< Reserved.
5320 UINT32 PF
:1; ///< Parity Flag.
5321 UINT32 Reserved_1
:1; ///< Reserved.
5322 UINT32 AF
:1; ///< Auxiliary Carry Flag.
5323 UINT32 Reserved_2
:1; ///< Reserved.
5324 UINT32 ZF
:1; ///< Zero Flag.
5325 UINT32 SF
:1; ///< Sign Flag.
5326 UINT32 TF
:1; ///< Trap Flag.
5327 UINT32 IF
:1; ///< Interrupt Enable Flag.
5328 UINT32 DF
:1; ///< Direction Flag.
5329 UINT32 OF
:1; ///< Overflow Flag.
5330 UINT32 IOPL
:2; ///< I/O Privilege Level.
5331 UINT32 NT
:1; ///< Nested Task.
5332 UINT32 Reserved_3
:1; ///< Reserved.
5338 /// Byte packed structure for EFLAGS/RFLAGS.
5339 /// 32-bits on IA-32.
5340 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5344 UINT32 CF
:1; ///< Carry Flag.
5345 UINT32 Reserved_0
:1; ///< Reserved.
5346 UINT32 PF
:1; ///< Parity Flag.
5347 UINT32 Reserved_1
:1; ///< Reserved.
5348 UINT32 AF
:1; ///< Auxiliary Carry Flag.
5349 UINT32 Reserved_2
:1; ///< Reserved.
5350 UINT32 ZF
:1; ///< Zero Flag.
5351 UINT32 SF
:1; ///< Sign Flag.
5352 UINT32 TF
:1; ///< Trap Flag.
5353 UINT32 IF
:1; ///< Interrupt Enable Flag.
5354 UINT32 DF
:1; ///< Direction Flag.
5355 UINT32 OF
:1; ///< Overflow Flag.
5356 UINT32 IOPL
:2; ///< I/O Privilege Level.
5357 UINT32 NT
:1; ///< Nested Task.
5358 UINT32 Reserved_3
:1; ///< Reserved.
5359 UINT32 RF
:1; ///< Resume Flag.
5360 UINT32 VM
:1; ///< Virtual 8086 Mode.
5361 UINT32 AC
:1; ///< Alignment Check.
5362 UINT32 VIF
:1; ///< Virtual Interrupt Flag.
5363 UINT32 VIP
:1; ///< Virtual Interrupt Pending.
5364 UINT32 ID
:1; ///< ID Flag.
5365 UINT32 Reserved_4
:10; ///< Reserved.
5371 /// Byte packed structure for Control Register 0 (CR0).
5372 /// 32-bits on IA-32.
5373 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5377 UINT32 PE
:1; ///< Protection Enable.
5378 UINT32 MP
:1; ///< Monitor Coprocessor.
5379 UINT32 EM
:1; ///< Emulation.
5380 UINT32 TS
:1; ///< Task Switched.
5381 UINT32 ET
:1; ///< Extension Type.
5382 UINT32 NE
:1; ///< Numeric Error.
5383 UINT32 Reserved_0
:10; ///< Reserved.
5384 UINT32 WP
:1; ///< Write Protect.
5385 UINT32 Reserved_1
:1; ///< Reserved.
5386 UINT32 AM
:1; ///< Alignment Mask.
5387 UINT32 Reserved_2
:10; ///< Reserved.
5388 UINT32 NW
:1; ///< Mot Write-through.
5389 UINT32 CD
:1; ///< Cache Disable.
5390 UINT32 PG
:1; ///< Paging.
5396 /// Byte packed structure for Control Register 4 (CR4).
5397 /// 32-bits on IA-32.
5398 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5402 UINT32 VME
:1; ///< Virtual-8086 Mode Extensions.
5403 UINT32 PVI
:1; ///< Protected-Mode Virtual Interrupts.
5404 UINT32 TSD
:1; ///< Time Stamp Disable.
5405 UINT32 DE
:1; ///< Debugging Extensions.
5406 UINT32 PSE
:1; ///< Page Size Extensions.
5407 UINT32 PAE
:1; ///< Physical Address Extension.
5408 UINT32 MCE
:1; ///< Machine Check Enable.
5409 UINT32 PGE
:1; ///< Page Global Enable.
5410 UINT32 PCE
:1; ///< Performance Monitoring Counter
5412 UINT32 OSFXSR
:1; ///< Operating System Support for
5413 ///< FXSAVE and FXRSTOR instructions
5414 UINT32 OSXMMEXCPT
:1; ///< Operating System Support for
5415 ///< Unmasked SIMD Floating Point
5417 UINT32 UMIP
:1; ///< User-Mode Instruction Prevention.
5418 UINT32 LA57
:1; ///< Linear Address 57bit.
5419 UINT32 VMXE
:1; ///< VMX Enable.
5420 UINT32 SMXE
:1; ///< SMX Enable.
5421 UINT32 Reserved_3
:1; ///< Reserved.
5422 UINT32 FSGSBASE
:1; ///< FSGSBASE Enable.
5423 UINT32 PCIDE
:1; ///< PCID Enable.
5424 UINT32 OSXSAVE
:1; ///< XSAVE and Processor Extended States Enable.
5425 UINT32 Reserved_4
:1; ///< Reserved.
5426 UINT32 SMEP
:1; ///< SMEP Enable.
5427 UINT32 SMAP
:1; ///< SMAP Enable.
5428 UINT32 PKE
:1; ///< Protection-Key Enable.
5429 UINT32 Reserved_5
:9; ///< Reserved.
5435 /// Byte packed structure for a segment descriptor in a GDT/LDT.
5454 } IA32_SEGMENT_DESCRIPTOR
;
5457 /// Byte packed structure for an IDTR, GDTR, LDTR descriptor.
5466 #define IA32_IDT_GATE_TYPE_TASK 0x85
5467 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
5468 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
5469 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
5470 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
5472 #define IA32_GDT_TYPE_TSS 0x9
5473 #define IA32_GDT_ALIGNMENT 8
5475 #if defined (MDE_CPU_IA32)
5477 /// Byte packed structure for an IA-32 Interrupt Gate Descriptor.
5481 UINT32 OffsetLow
:16; ///< Offset bits 15..0.
5482 UINT32 Selector
:16; ///< Selector.
5483 UINT32 Reserved_0
:8; ///< Reserved.
5484 UINT32 GateType
:8; ///< Gate Type. See #defines above.
5485 UINT32 OffsetHigh
:16; ///< Offset bits 31..16.
5488 } IA32_IDT_GATE_DESCRIPTOR
;
5492 // IA32 Task-State Segment Definition
5495 UINT16 PreviousTaskLink
;
5529 UINT16 LDTSegmentSelector
;
5532 UINT16 IOMapBaseAddress
;
5533 } IA32_TASK_STATE_SEGMENT
;
5537 UINT32 LimitLow
:16; ///< Segment Limit 15..00
5538 UINT32 BaseLow
:16; ///< Base Address 15..00
5539 UINT32 BaseMid
:8; ///< Base Address 23..16
5540 UINT32 Type
:4; ///< Type (1 0 B 1)
5541 UINT32 Reserved_43
:1; ///< 0
5542 UINT32 DPL
:2; ///< Descriptor Privilege Level
5543 UINT32 P
:1; ///< Segment Present
5544 UINT32 LimitHigh
:4; ///< Segment Limit 19..16
5545 UINT32 AVL
:1; ///< Available for use by system software
5546 UINT32 Reserved_52
:2; ///< 0 0
5547 UINT32 G
:1; ///< Granularity
5548 UINT32 BaseHigh
:8; ///< Base Address 31..24
5551 } IA32_TSS_DESCRIPTOR
;
5554 #endif // defined (MDE_CPU_IA32)
5556 #if defined (MDE_CPU_X64)
5558 /// Byte packed structure for an x64 Interrupt Gate Descriptor.
5562 UINT32 OffsetLow
:16; ///< Offset bits 15..0.
5563 UINT32 Selector
:16; ///< Selector.
5564 UINT32 Reserved_0
:8; ///< Reserved.
5565 UINT32 GateType
:8; ///< Gate Type. See #defines above.
5566 UINT32 OffsetHigh
:16; ///< Offset bits 31..16.
5567 UINT32 OffsetUpper
:32; ///< Offset bits 63..32.
5568 UINT32 Reserved_1
:32; ///< Reserved.
5574 } IA32_IDT_GATE_DESCRIPTOR
;
5578 // IA32 Task-State Segment Definition
5588 UINT16 Reserved_100
;
5589 UINT16 IOMapBaseAddress
;
5590 } IA32_TASK_STATE_SEGMENT
;
5594 UINT32 LimitLow
:16; ///< Segment Limit 15..00
5595 UINT32 BaseLow
:16; ///< Base Address 15..00
5596 UINT32 BaseMidl
:8; ///< Base Address 23..16
5597 UINT32 Type
:4; ///< Type (1 0 B 1)
5598 UINT32 Reserved_43
:1; ///< 0
5599 UINT32 DPL
:2; ///< Descriptor Privilege Level
5600 UINT32 P
:1; ///< Segment Present
5601 UINT32 LimitHigh
:4; ///< Segment Limit 19..16
5602 UINT32 AVL
:1; ///< Available for use by system software
5603 UINT32 Reserved_52
:2; ///< 0 0
5604 UINT32 G
:1; ///< Granularity
5605 UINT32 BaseMidh
:8; ///< Base Address 31..24
5606 UINT32 BaseHigh
:32; ///< Base Address 63..32
5607 UINT32 Reserved_96
:32; ///< Reserved
5613 } IA32_TSS_DESCRIPTOR
;
5616 #endif // defined (MDE_CPU_X64)
5619 /// Byte packed structure for an FP/SSE/SSE2 context.
5626 /// Structures for the 16-bit real mode thunks.
5679 IA32_EFLAGS32 EFLAGS
;
5689 } IA32_REGISTER_SET
;
5692 /// Byte packed structure for an 16-bit real mode thunks.
5695 IA32_REGISTER_SET
*RealModeState
;
5696 VOID
*RealModeBuffer
;
5697 UINT32 RealModeBufferSize
;
5698 UINT32 ThunkAttributes
;
5701 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
5702 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
5703 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
5706 /// Type definition for representing labels in NASM source code that allow for
5707 /// the patching of immediate operands of IA32 and X64 instructions.
5709 /// While the type is technically defined as a function type (note: not a
5710 /// pointer-to-function type), such labels in NASM source code never stand for
5711 /// actual functions, and identifiers declared with this function type should
5712 /// never be called. This is also why the EFIAPI calling convention specifier
5713 /// is missing from the typedef, and why the typedef does not follow the usual
5714 /// edk2 coding style for function (or pointer-to-function) typedefs. The VOID
5715 /// return type and the VOID argument list are merely artifacts.
5717 typedef VOID (X86_ASSEMBLY_PATCH_LABEL
) (VOID
);
5720 Retrieves CPUID information.
5722 Executes the CPUID instruction with EAX set to the value specified by Index.
5723 This function always returns Index.
5724 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5725 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5726 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5727 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5728 This function is only available on IA-32 and x64.
5730 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
5732 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
5733 instruction. This is an optional parameter that may be NULL.
5734 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
5735 instruction. This is an optional parameter that may be NULL.
5736 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
5737 instruction. This is an optional parameter that may be NULL.
5738 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
5739 instruction. This is an optional parameter that may be NULL.
5748 OUT UINT32
*Eax
, OPTIONAL
5749 OUT UINT32
*Ebx
, OPTIONAL
5750 OUT UINT32
*Ecx
, OPTIONAL
5751 OUT UINT32
*Edx OPTIONAL
5756 Retrieves CPUID information using an extended leaf identifier.
5758 Executes the CPUID instruction with EAX set to the value specified by Index
5759 and ECX set to the value specified by SubIndex. This function always returns
5760 Index. This function is only available on IA-32 and x64.
5762 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5763 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5764 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5765 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5767 @param Index The 32-bit value to load into EAX prior to invoking the
5769 @param SubIndex The 32-bit value to load into ECX prior to invoking the
5771 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
5772 instruction. This is an optional parameter that may be
5774 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
5775 instruction. This is an optional parameter that may be
5777 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
5778 instruction. This is an optional parameter that may be
5780 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
5781 instruction. This is an optional parameter that may be
5792 OUT UINT32
*Eax
, OPTIONAL
5793 OUT UINT32
*Ebx
, OPTIONAL
5794 OUT UINT32
*Ecx
, OPTIONAL
5795 OUT UINT32
*Edx OPTIONAL
5800 Set CD bit and clear NW bit of CR0 followed by a WBINVD.
5802 Disables the caches by setting the CD bit of CR0 to 1, clearing the NW bit of CR0 to 0,
5803 and executing a WBINVD instruction. This function is only available on IA-32 and x64.
5814 Perform a WBINVD and clear both the CD and NW bits of CR0.
5816 Enables the caches by executing a WBINVD instruction and then clear both the CD and NW
5817 bits of CR0 to 0. This function is only available on IA-32 and x64.
5828 Returns the lower 32-bits of a Machine Specific Register(MSR).
5830 Reads and returns the lower 32-bits of the MSR specified by Index.
5831 No parameter checking is performed on Index, and some Index values may cause
5832 CPU exceptions. The caller must either guarantee that Index is valid, or the
5833 caller must set up exception handlers to catch the exceptions. This function
5834 is only available on IA-32 and x64.
5836 @param Index The 32-bit MSR index to read.
5838 @return The lower 32 bits of the MSR identified by Index.
5849 Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.
5850 The upper 32-bits of the MSR are set to zero.
5852 Writes the 32-bit value specified by Value to the MSR specified by Index. The
5853 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
5854 the MSR is returned. No parameter checking is performed on Index or Value,
5855 and some of these may cause CPU exceptions. The caller must either guarantee
5856 that Index and Value are valid, or the caller must establish proper exception
5857 handlers. This function is only available on IA-32 and x64.
5859 @param Index The 32-bit MSR index to write.
5860 @param Value The 32-bit value to write to the MSR.
5874 Reads a 64-bit MSR, performs a bitwise OR on the lower 32-bits, and
5875 writes the result back to the 64-bit MSR.
5877 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5878 between the lower 32-bits of the read result and the value specified by
5879 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
5880 32-bits of the value written to the MSR is returned. No parameter checking is
5881 performed on Index or OrData, and some of these may cause CPU exceptions. The
5882 caller must either guarantee that Index and OrData are valid, or the caller
5883 must establish proper exception handlers. This function is only available on
5886 @param Index The 32-bit MSR index to write.
5887 @param OrData The value to OR with the read value from the MSR.
5889 @return The lower 32-bit value written to the MSR.
5901 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
5902 the result back to the 64-bit MSR.
5904 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5905 lower 32-bits of the read result and the value specified by AndData, and
5906 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
5907 the value written to the MSR is returned. No parameter checking is performed
5908 on Index or AndData, and some of these may cause CPU exceptions. The caller
5909 must either guarantee that Index and AndData are valid, or the caller must
5910 establish proper exception handlers. This function is only available on IA-32
5913 @param Index The 32-bit MSR index to write.
5914 @param AndData The value to AND with the read value from the MSR.
5916 @return The lower 32-bit value written to the MSR.
5928 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise OR
5929 on the lower 32-bits, and writes the result back to the 64-bit MSR.
5931 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5932 lower 32-bits of the read result and the value specified by AndData
5933 preserving the upper 32-bits, performs a bitwise OR between the
5934 result of the AND operation and the value specified by OrData, and writes the
5935 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
5936 written to the MSR is returned. No parameter checking is performed on Index,
5937 AndData, or OrData, and some of these may cause CPU exceptions. The caller
5938 must either guarantee that Index, AndData, and OrData are valid, or the
5939 caller must establish proper exception handlers. This function is only
5940 available on IA-32 and x64.
5942 @param Index The 32-bit MSR index to write.
5943 @param AndData The value to AND with the read value from the MSR.
5944 @param OrData The value to OR with the result of the AND operation.
5946 @return The lower 32-bit value written to the MSR.
5959 Reads a bit field of an MSR.
5961 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
5962 specified by the StartBit and the EndBit. The value of the bit field is
5963 returned. The caller must either guarantee that Index is valid, or the caller
5964 must set up exception handlers to catch the exceptions. This function is only
5965 available on IA-32 and x64.
5967 If StartBit is greater than 31, then ASSERT().
5968 If EndBit is greater than 31, then ASSERT().
5969 If EndBit is less than StartBit, then ASSERT().
5971 @param Index The 32-bit MSR index to read.
5972 @param StartBit The ordinal of the least significant bit in the bit field.
5974 @param EndBit The ordinal of the most significant bit in the bit field.
5977 @return The bit field read from the MSR.
5982 AsmMsrBitFieldRead32 (
5990 Writes a bit field to an MSR.
5992 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
5993 field is specified by the StartBit and the EndBit. All other bits in the
5994 destination MSR are preserved. The lower 32-bits of the MSR written is
5995 returned. The caller must either guarantee that Index and the data written
5996 is valid, or the caller must set up exception handlers to catch the exceptions.
5997 This function is only available on IA-32 and x64.
5999 If StartBit is greater than 31, then ASSERT().
6000 If EndBit is greater than 31, then ASSERT().
6001 If EndBit is less than StartBit, then ASSERT().
6002 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6004 @param Index The 32-bit MSR index to write.
6005 @param StartBit The ordinal of the least significant bit in the bit field.
6007 @param EndBit The ordinal of the most significant bit in the bit field.
6009 @param Value New value of the bit field.
6011 @return The lower 32-bit of the value written to the MSR.
6016 AsmMsrBitFieldWrite32 (
6025 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
6026 result back to the bit field in the 64-bit MSR.
6028 Reads the 64-bit MSR specified by Index, performs a bitwise OR
6029 between the read result and the value specified by OrData, and writes the
6030 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
6031 written to the MSR are returned. Extra left bits in OrData are stripped. The
6032 caller must either guarantee that Index and the data written is valid, or
6033 the caller must set up exception handlers to catch the exceptions. This
6034 function is only available on IA-32 and x64.
6036 If StartBit is greater than 31, then ASSERT().
6037 If EndBit is greater than 31, then ASSERT().
6038 If EndBit is less than StartBit, then ASSERT().
6039 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6041 @param Index The 32-bit MSR index to write.
6042 @param StartBit The ordinal of the least significant bit in the bit field.
6044 @param EndBit The ordinal of the most significant bit in the bit field.
6046 @param OrData The value to OR with the read value from the MSR.
6048 @return The lower 32-bit of the value written to the MSR.
6053 AsmMsrBitFieldOr32 (
6062 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
6063 result back to the bit field in the 64-bit MSR.
6065 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
6066 read result and the value specified by AndData, and writes the result to the
6067 64-bit MSR specified by Index. The lower 32-bits of the value written to the
6068 MSR are returned. Extra left bits in AndData are stripped. The caller must
6069 either guarantee that Index and the data written is valid, or the caller must
6070 set up exception handlers to catch the exceptions. This function is only
6071 available on IA-32 and x64.
6073 If StartBit is greater than 31, then ASSERT().
6074 If EndBit is greater than 31, then ASSERT().
6075 If EndBit is less than StartBit, then ASSERT().
6076 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6078 @param Index The 32-bit MSR index to write.
6079 @param StartBit The ordinal of the least significant bit in the bit field.
6081 @param EndBit The ordinal of the most significant bit in the bit field.
6083 @param AndData The value to AND with the read value from the MSR.
6085 @return The lower 32-bit of the value written to the MSR.
6090 AsmMsrBitFieldAnd32 (
6099 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
6100 bitwise OR, and writes the result back to the bit field in the
6103 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
6104 bitwise OR between the read result and the value specified by
6105 AndData, and writes the result to the 64-bit MSR specified by Index. The
6106 lower 32-bits of the value written to the MSR are returned. Extra left bits
6107 in both AndData and OrData are stripped. The caller must either guarantee
6108 that Index and the data written is valid, or the caller must set up exception
6109 handlers to catch the exceptions. This function is only available on IA-32
6112 If StartBit is greater than 31, then ASSERT().
6113 If EndBit is greater than 31, then ASSERT().
6114 If EndBit is less than StartBit, then ASSERT().
6115 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6116 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6118 @param Index The 32-bit MSR index to write.
6119 @param StartBit The ordinal of the least significant bit in the bit field.
6121 @param EndBit The ordinal of the most significant bit in the bit field.
6123 @param AndData The value to AND with the read value from the MSR.
6124 @param OrData The value to OR with the result of the AND operation.
6126 @return The lower 32-bit of the value written to the MSR.
6131 AsmMsrBitFieldAndThenOr32 (
6141 Returns a 64-bit Machine Specific Register(MSR).
6143 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
6144 performed on Index, and some Index values may cause CPU exceptions. The
6145 caller must either guarantee that Index is valid, or the caller must set up
6146 exception handlers to catch the exceptions. This function is only available
6149 @param Index The 32-bit MSR index to read.
6151 @return The value of the MSR identified by Index.
6162 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
6165 Writes the 64-bit value specified by Value to the MSR specified by Index. The
6166 64-bit value written to the MSR is returned. No parameter checking is
6167 performed on Index or Value, and some of these may cause CPU exceptions. The
6168 caller must either guarantee that Index and Value are valid, or the caller
6169 must establish proper exception handlers. This function is only available on
6172 @param Index The 32-bit MSR index to write.
6173 @param Value The 64-bit value to write to the MSR.
6187 Reads a 64-bit MSR, performs a bitwise OR, and writes the result
6188 back to the 64-bit MSR.
6190 Reads the 64-bit MSR specified by Index, performs a bitwise OR
6191 between the read result and the value specified by OrData, and writes the
6192 result to the 64-bit MSR specified by Index. The value written to the MSR is
6193 returned. No parameter checking is performed on Index or OrData, and some of
6194 these may cause CPU exceptions. The caller must either guarantee that Index
6195 and OrData are valid, or the caller must establish proper exception handlers.
6196 This function is only available on IA-32 and x64.
6198 @param Index The 32-bit MSR index to write.
6199 @param OrData The value to OR with the read value from the MSR.
6201 @return The value written back to the MSR.
6213 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
6216 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
6217 read result and the value specified by OrData, and writes the result to the
6218 64-bit MSR specified by Index. The value written to the MSR is returned. No
6219 parameter checking is performed on Index or OrData, and some of these may
6220 cause CPU exceptions. The caller must either guarantee that Index and OrData
6221 are valid, or the caller must establish proper exception handlers. This
6222 function is only available on IA-32 and x64.
6224 @param Index The 32-bit MSR index to write.
6225 @param AndData The value to AND with the read value from the MSR.
6227 @return The value written back to the MSR.
6239 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise
6240 OR, and writes the result back to the 64-bit MSR.
6242 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
6243 result and the value specified by AndData, performs a bitwise OR
6244 between the result of the AND operation and the value specified by OrData,
6245 and writes the result to the 64-bit MSR specified by Index. The value written
6246 to the MSR is returned. No parameter checking is performed on Index, AndData,
6247 or OrData, and some of these may cause CPU exceptions. The caller must either
6248 guarantee that Index, AndData, and OrData are valid, or the caller must
6249 establish proper exception handlers. This function is only available on IA-32
6252 @param Index The 32-bit MSR index to write.
6253 @param AndData The value to AND with the read value from the MSR.
6254 @param OrData The value to OR with the result of the AND operation.
6256 @return The value written back to the MSR.
6269 Reads a bit field of an MSR.
6271 Reads the bit field in the 64-bit MSR. The bit field is specified by the
6272 StartBit and the EndBit. The value of the bit field is returned. The caller
6273 must either guarantee that Index is valid, or the caller must set up
6274 exception handlers to catch the exceptions. This function is only available
6277 If StartBit is greater than 63, then ASSERT().
6278 If EndBit is greater than 63, then ASSERT().
6279 If EndBit is less than StartBit, then ASSERT().
6281 @param Index The 32-bit MSR index to read.
6282 @param StartBit The ordinal of the least significant bit in the bit field.
6284 @param EndBit The ordinal of the most significant bit in the bit field.
6287 @return The value read from the MSR.
6292 AsmMsrBitFieldRead64 (
6300 Writes a bit field to an MSR.
6302 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
6303 the StartBit and the EndBit. All other bits in the destination MSR are
6304 preserved. The MSR written is returned. The caller must either guarantee
6305 that Index and the data written is valid, or the caller must set up exception
6306 handlers to catch the exceptions. This function is only available on IA-32 and x64.
6308 If StartBit is greater than 63, then ASSERT().
6309 If EndBit is greater than 63, then ASSERT().
6310 If EndBit is less than StartBit, then ASSERT().
6311 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6313 @param Index The 32-bit MSR index to write.
6314 @param StartBit The ordinal of the least significant bit in the bit field.
6316 @param EndBit The ordinal of the most significant bit in the bit field.
6318 @param Value New value of the bit field.
6320 @return The value written back to the MSR.
6325 AsmMsrBitFieldWrite64 (
6334 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and
6335 writes the result back to the bit field in the 64-bit MSR.
6337 Reads the 64-bit MSR specified by Index, performs a bitwise OR
6338 between the read result and the value specified by OrData, and writes the
6339 result to the 64-bit MSR specified by Index. The value written to the MSR is
6340 returned. Extra left bits in OrData are stripped. The caller must either
6341 guarantee that Index and the data written is valid, or the caller must set up
6342 exception handlers to catch the exceptions. This function is only available
6345 If StartBit is greater than 63, then ASSERT().
6346 If EndBit is greater than 63, then ASSERT().
6347 If EndBit is less than StartBit, then ASSERT().
6348 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6350 @param Index The 32-bit MSR index to write.
6351 @param StartBit The ordinal of the least significant bit in the bit field.
6353 @param EndBit The ordinal of the most significant bit in the bit field.
6355 @param OrData The value to OR with the read value from the bit field.
6357 @return The value written back to the MSR.
6362 AsmMsrBitFieldOr64 (
6371 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
6372 result back to the bit field in the 64-bit MSR.
6374 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
6375 read result and the value specified by AndData, and writes the result to the
6376 64-bit MSR specified by Index. The value written to the MSR is returned.
6377 Extra left bits in AndData are stripped. The caller must either guarantee
6378 that Index and the data written is valid, or the caller must set up exception
6379 handlers to catch the exceptions. This function is only available on IA-32
6382 If StartBit is greater than 63, then ASSERT().
6383 If EndBit is greater than 63, then ASSERT().
6384 If EndBit is less than StartBit, then ASSERT().
6385 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6387 @param Index The 32-bit MSR index to write.
6388 @param StartBit The ordinal of the least significant bit in the bit field.
6390 @param EndBit The ordinal of the most significant bit in the bit field.
6392 @param AndData The value to AND with the read value from the bit field.
6394 @return The value written back to the MSR.
6399 AsmMsrBitFieldAnd64 (
6408 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
6409 bitwise OR, and writes the result back to the bit field in the
6412 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
6413 a bitwise OR between the read result and the value specified by
6414 AndData, and writes the result to the 64-bit MSR specified by Index. The
6415 value written to the MSR is returned. Extra left bits in both AndData and
6416 OrData are stripped. The caller must either guarantee that Index and the data
6417 written is valid, or the caller must set up exception handlers to catch the
6418 exceptions. This function is only available on IA-32 and x64.
6420 If StartBit is greater than 63, then ASSERT().
6421 If EndBit is greater than 63, then ASSERT().
6422 If EndBit is less than StartBit, then ASSERT().
6423 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6424 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6426 @param Index The 32-bit MSR index to write.
6427 @param StartBit The ordinal of the least significant bit in the bit field.
6429 @param EndBit The ordinal of the most significant bit in the bit field.
6431 @param AndData The value to AND with the read value from the bit field.
6432 @param OrData The value to OR with the result of the AND operation.
6434 @return The value written back to the MSR.
6439 AsmMsrBitFieldAndThenOr64 (
6449 Reads the current value of the EFLAGS register.
6451 Reads and returns the current value of the EFLAGS register. This function is
6452 only available on IA-32 and x64. This returns a 32-bit value on IA-32 and a
6453 64-bit value on x64.
6455 @return EFLAGS on IA-32 or RFLAGS on x64.
6466 Reads the current value of the Control Register 0 (CR0).
6468 Reads and returns the current value of CR0. This function is only available
6469 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6472 @return The value of the Control Register 0 (CR0).
6483 Reads the current value of the Control Register 2 (CR2).
6485 Reads and returns the current value of CR2. This function is only available
6486 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6489 @return The value of the Control Register 2 (CR2).
6500 Reads the current value of the Control Register 3 (CR3).
6502 Reads and returns the current value of CR3. This function is only available
6503 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6506 @return The value of the Control Register 3 (CR3).
6517 Reads the current value of the Control Register 4 (CR4).
6519 Reads and returns the current value of CR4. This function is only available
6520 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6523 @return The value of the Control Register 4 (CR4).
6534 Writes a value to Control Register 0 (CR0).
6536 Writes and returns a new value to CR0. This function is only available on
6537 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6539 @param Cr0 The value to write to CR0.
6541 @return The value written to CR0.
6552 Writes a value to Control Register 2 (CR2).
6554 Writes and returns a new value to CR2. This function is only available on
6555 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6557 @param Cr2 The value to write to CR2.
6559 @return The value written to CR2.
6570 Writes a value to Control Register 3 (CR3).
6572 Writes and returns a new value to CR3. This function is only available on
6573 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6575 @param Cr3 The value to write to CR3.
6577 @return The value written to CR3.
6588 Writes a value to Control Register 4 (CR4).
6590 Writes and returns a new value to CR4. This function is only available on
6591 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6593 @param Cr4 The value to write to CR4.
6595 @return The value written to CR4.
6606 Reads the current value of Debug Register 0 (DR0).
6608 Reads and returns the current value of DR0. This function is only available
6609 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6612 @return The value of Debug Register 0 (DR0).
6623 Reads the current value of Debug Register 1 (DR1).
6625 Reads and returns the current value of DR1. This function is only available
6626 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6629 @return The value of Debug Register 1 (DR1).
6640 Reads the current value of Debug Register 2 (DR2).
6642 Reads and returns the current value of DR2. This function is only available
6643 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6646 @return The value of Debug Register 2 (DR2).
6657 Reads the current value of Debug Register 3 (DR3).
6659 Reads and returns the current value of DR3. This function is only available
6660 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6663 @return The value of Debug Register 3 (DR3).
6674 Reads the current value of Debug Register 4 (DR4).
6676 Reads and returns the current value of DR4. This function is only available
6677 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6680 @return The value of Debug Register 4 (DR4).
6691 Reads the current value of Debug Register 5 (DR5).
6693 Reads and returns the current value of DR5. This function is only available
6694 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6697 @return The value of Debug Register 5 (DR5).
6708 Reads the current value of Debug Register 6 (DR6).
6710 Reads and returns the current value of DR6. This function is only available
6711 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6714 @return The value of Debug Register 6 (DR6).
6725 Reads the current value of Debug Register 7 (DR7).
6727 Reads and returns the current value of DR7. This function is only available
6728 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6731 @return The value of Debug Register 7 (DR7).
6742 Writes a value to Debug Register 0 (DR0).
6744 Writes and returns a new value to DR0. This function is only available on
6745 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6747 @param Dr0 The value to write to Dr0.
6749 @return The value written to Debug Register 0 (DR0).
6760 Writes a value to Debug Register 1 (DR1).
6762 Writes and returns a new value to DR1. This function is only available on
6763 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6765 @param Dr1 The value to write to Dr1.
6767 @return The value written to Debug Register 1 (DR1).
6778 Writes a value to Debug Register 2 (DR2).
6780 Writes and returns a new value to DR2. This function is only available on
6781 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6783 @param Dr2 The value to write to Dr2.
6785 @return The value written to Debug Register 2 (DR2).
6796 Writes a value to Debug Register 3 (DR3).
6798 Writes and returns a new value to DR3. This function is only available on
6799 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6801 @param Dr3 The value to write to Dr3.
6803 @return The value written to Debug Register 3 (DR3).
6814 Writes a value to Debug Register 4 (DR4).
6816 Writes and returns a new value to DR4. This function is only available on
6817 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6819 @param Dr4 The value to write to Dr4.
6821 @return The value written to Debug Register 4 (DR4).
6832 Writes a value to Debug Register 5 (DR5).
6834 Writes and returns a new value to DR5. This function is only available on
6835 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6837 @param Dr5 The value to write to Dr5.
6839 @return The value written to Debug Register 5 (DR5).
6850 Writes a value to Debug Register 6 (DR6).
6852 Writes and returns a new value to DR6. This function is only available on
6853 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6855 @param Dr6 The value to write to Dr6.
6857 @return The value written to Debug Register 6 (DR6).
6868 Writes a value to Debug Register 7 (DR7).
6870 Writes and returns a new value to DR7. This function is only available on
6871 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6873 @param Dr7 The value to write to Dr7.
6875 @return The value written to Debug Register 7 (DR7).
6886 Reads the current value of Code Segment Register (CS).
6888 Reads and returns the current value of CS. This function is only available on
6891 @return The current value of CS.
6902 Reads the current value of Data Segment Register (DS).
6904 Reads and returns the current value of DS. This function is only available on
6907 @return The current value of DS.
6918 Reads the current value of Extra Segment Register (ES).
6920 Reads and returns the current value of ES. This function is only available on
6923 @return The current value of ES.
6934 Reads the current value of FS Data Segment Register (FS).
6936 Reads and returns the current value of FS. This function is only available on
6939 @return The current value of FS.
6950 Reads the current value of GS Data Segment Register (GS).
6952 Reads and returns the current value of GS. This function is only available on
6955 @return The current value of GS.
6966 Reads the current value of Stack Segment Register (SS).
6968 Reads and returns the current value of SS. This function is only available on
6971 @return The current value of SS.
6982 Reads the current value of Task Register (TR).
6984 Reads and returns the current value of TR. This function is only available on
6987 @return The current value of TR.
6998 Reads the current Global Descriptor Table Register(GDTR) descriptor.
7000 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
7001 function is only available on IA-32 and x64.
7003 If Gdtr is NULL, then ASSERT().
7005 @param Gdtr The pointer to a GDTR descriptor.
7011 OUT IA32_DESCRIPTOR
*Gdtr
7016 Writes the current Global Descriptor Table Register (GDTR) descriptor.
7018 Writes and the current GDTR descriptor specified by Gdtr. This function is
7019 only available on IA-32 and x64.
7021 If Gdtr is NULL, then ASSERT().
7023 @param Gdtr The pointer to a GDTR descriptor.
7029 IN CONST IA32_DESCRIPTOR
*Gdtr
7034 Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.
7036 Reads and returns the current IDTR descriptor and returns it in Idtr. This
7037 function is only available on IA-32 and x64.
7039 If Idtr is NULL, then ASSERT().
7041 @param Idtr The pointer to a IDTR descriptor.
7047 OUT IA32_DESCRIPTOR
*Idtr
7052 Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.
7054 Writes the current IDTR descriptor and returns it in Idtr. This function is
7055 only available on IA-32 and x64.
7057 If Idtr is NULL, then ASSERT().
7059 @param Idtr The pointer to a IDTR descriptor.
7065 IN CONST IA32_DESCRIPTOR
*Idtr
7070 Reads the current Local Descriptor Table Register(LDTR) selector.
7072 Reads and returns the current 16-bit LDTR descriptor value. This function is
7073 only available on IA-32 and x64.
7075 @return The current selector of LDT.
7086 Writes the current Local Descriptor Table Register (LDTR) selector.
7088 Writes and the current LDTR descriptor specified by Ldtr. This function is
7089 only available on IA-32 and x64.
7091 @param Ldtr 16-bit LDTR selector value.
7102 Save the current floating point/SSE/SSE2 context to a buffer.
7104 Saves the current floating point/SSE/SSE2 state to the buffer specified by
7105 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
7106 available on IA-32 and x64.
7108 If Buffer is NULL, then ASSERT().
7109 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
7111 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
7117 OUT IA32_FX_BUFFER
*Buffer
7122 Restores the current floating point/SSE/SSE2 context from a buffer.
7124 Restores the current floating point/SSE/SSE2 state from the buffer specified
7125 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
7126 only available on IA-32 and x64.
7128 If Buffer is NULL, then ASSERT().
7129 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
7130 If Buffer was not saved with AsmFxSave(), then ASSERT().
7132 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
7138 IN CONST IA32_FX_BUFFER
*Buffer
7143 Reads the current value of 64-bit MMX Register #0 (MM0).
7145 Reads and returns the current value of MM0. This function is only available
7148 @return The current value of MM0.
7159 Reads the current value of 64-bit MMX Register #1 (MM1).
7161 Reads and returns the current value of MM1. This function is only available
7164 @return The current value of MM1.
7175 Reads the current value of 64-bit MMX Register #2 (MM2).
7177 Reads and returns the current value of MM2. This function is only available
7180 @return The current value of MM2.
7191 Reads the current value of 64-bit MMX Register #3 (MM3).
7193 Reads and returns the current value of MM3. This function is only available
7196 @return The current value of MM3.
7207 Reads the current value of 64-bit MMX Register #4 (MM4).
7209 Reads and returns the current value of MM4. This function is only available
7212 @return The current value of MM4.
7223 Reads the current value of 64-bit MMX Register #5 (MM5).
7225 Reads and returns the current value of MM5. This function is only available
7228 @return The current value of MM5.
7239 Reads the current value of 64-bit MMX Register #6 (MM6).
7241 Reads and returns the current value of MM6. This function is only available
7244 @return The current value of MM6.
7255 Reads the current value of 64-bit MMX Register #7 (MM7).
7257 Reads and returns the current value of MM7. This function is only available
7260 @return The current value of MM7.
7271 Writes the current value of 64-bit MMX Register #0 (MM0).
7273 Writes the current value of MM0. This function is only available on IA32 and
7276 @param Value The 64-bit value to write to MM0.
7287 Writes the current value of 64-bit MMX Register #1 (MM1).
7289 Writes the current value of MM1. This function is only available on IA32 and
7292 @param Value The 64-bit value to write to MM1.
7303 Writes the current value of 64-bit MMX Register #2 (MM2).
7305 Writes the current value of MM2. This function is only available on IA32 and
7308 @param Value The 64-bit value to write to MM2.
7319 Writes the current value of 64-bit MMX Register #3 (MM3).
7321 Writes the current value of MM3. This function is only available on IA32 and
7324 @param Value The 64-bit value to write to MM3.
7335 Writes the current value of 64-bit MMX Register #4 (MM4).
7337 Writes the current value of MM4. This function is only available on IA32 and
7340 @param Value The 64-bit value to write to MM4.
7351 Writes the current value of 64-bit MMX Register #5 (MM5).
7353 Writes the current value of MM5. This function is only available on IA32 and
7356 @param Value The 64-bit value to write to MM5.
7367 Writes the current value of 64-bit MMX Register #6 (MM6).
7369 Writes the current value of MM6. This function is only available on IA32 and
7372 @param Value The 64-bit value to write to MM6.
7383 Writes the current value of 64-bit MMX Register #7 (MM7).
7385 Writes the current value of MM7. This function is only available on IA32 and
7388 @param Value The 64-bit value to write to MM7.
7399 Reads the current value of Time Stamp Counter (TSC).
7401 Reads and returns the current value of TSC. This function is only available
7404 @return The current value of TSC
7415 Reads the current value of a Performance Counter (PMC).
7417 Reads and returns the current value of performance counter specified by
7418 Index. This function is only available on IA-32 and x64.
7420 @param Index The 32-bit Performance Counter index to read.
7422 @return The value of the PMC specified by Index.
7433 Sets up a monitor buffer that is used by AsmMwait().
7435 Executes a MONITOR instruction with the register state specified by Eax, Ecx
7436 and Edx. Returns Eax. This function is only available on IA-32 and x64.
7438 @param Eax The value to load into EAX or RAX before executing the MONITOR
7440 @param Ecx The value to load into ECX or RCX before executing the MONITOR
7442 @param Edx The value to load into EDX or RDX before executing the MONITOR
7458 Executes an MWAIT instruction.
7460 Executes an MWAIT instruction with the register state specified by Eax and
7461 Ecx. Returns Eax. This function is only available on IA-32 and x64.
7463 @param Eax The value to load into EAX or RAX before executing the MONITOR
7465 @param Ecx The value to load into ECX or RCX before executing the MONITOR
7480 Executes a WBINVD instruction.
7482 Executes a WBINVD instruction. This function is only available on IA-32 and
7494 Executes a INVD instruction.
7496 Executes a INVD instruction. This function is only available on IA-32 and
7508 Flushes a cache line from all the instruction and data caches within the
7509 coherency domain of the CPU.
7511 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
7512 This function is only available on IA-32 and x64.
7514 @param LinearAddress The address of the cache line to flush. If the CPU is
7515 in a physical addressing mode, then LinearAddress is a
7516 physical address. If the CPU is in a virtual
7517 addressing mode, then LinearAddress is a virtual
7520 @return LinearAddress.
7525 IN VOID
*LinearAddress
7530 Enables the 32-bit paging mode on the CPU.
7532 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
7533 must be properly initialized prior to calling this service. This function
7534 assumes the current execution mode is 32-bit protected mode. This function is
7535 only available on IA-32. After the 32-bit paging mode is enabled, control is
7536 transferred to the function specified by EntryPoint using the new stack
7537 specified by NewStack and passing in the parameters specified by Context1 and
7538 Context2. Context1 and Context2 are optional and may be NULL. The function
7539 EntryPoint must never return.
7541 If the current execution mode is not 32-bit protected mode, then ASSERT().
7542 If EntryPoint is NULL, then ASSERT().
7543 If NewStack is NULL, then ASSERT().
7545 There are a number of constraints that must be followed before calling this
7547 1) Interrupts must be disabled.
7548 2) The caller must be in 32-bit protected mode with flat descriptors. This
7549 means all descriptors must have a base of 0 and a limit of 4GB.
7550 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
7552 4) CR3 must point to valid page tables that will be used once the transition
7553 is complete, and those page tables must guarantee that the pages for this
7554 function and the stack are identity mapped.
7556 @param EntryPoint A pointer to function to call with the new stack after
7558 @param Context1 A pointer to the context to pass into the EntryPoint
7559 function as the first parameter after paging is enabled.
7560 @param Context2 A pointer to the context to pass into the EntryPoint
7561 function as the second parameter after paging is enabled.
7562 @param NewStack A pointer to the new stack to use for the EntryPoint
7563 function after paging is enabled.
7569 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
7570 IN VOID
*Context1
, OPTIONAL
7571 IN VOID
*Context2
, OPTIONAL
7577 Disables the 32-bit paging mode on the CPU.
7579 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
7580 mode. This function assumes the current execution mode is 32-paged protected
7581 mode. This function is only available on IA-32. After the 32-bit paging mode
7582 is disabled, control is transferred to the function specified by EntryPoint
7583 using the new stack specified by NewStack and passing in the parameters
7584 specified by Context1 and Context2. Context1 and Context2 are optional and
7585 may be NULL. The function EntryPoint must never return.
7587 If the current execution mode is not 32-bit paged mode, then ASSERT().
7588 If EntryPoint is NULL, then ASSERT().
7589 If NewStack is NULL, then ASSERT().
7591 There are a number of constraints that must be followed before calling this
7593 1) Interrupts must be disabled.
7594 2) The caller must be in 32-bit paged mode.
7595 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
7596 4) CR3 must point to valid page tables that guarantee that the pages for
7597 this function and the stack are identity mapped.
7599 @param EntryPoint A pointer to function to call with the new stack after
7601 @param Context1 A pointer to the context to pass into the EntryPoint
7602 function as the first parameter after paging is disabled.
7603 @param Context2 A pointer to the context to pass into the EntryPoint
7604 function as the second parameter after paging is
7606 @param NewStack A pointer to the new stack to use for the EntryPoint
7607 function after paging is disabled.
7612 AsmDisablePaging32 (
7613 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
7614 IN VOID
*Context1
, OPTIONAL
7615 IN VOID
*Context2
, OPTIONAL
7621 Enables the 64-bit paging mode on the CPU.
7623 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
7624 must be properly initialized prior to calling this service. This function
7625 assumes the current execution mode is 32-bit protected mode with flat
7626 descriptors. This function is only available on IA-32. After the 64-bit
7627 paging mode is enabled, control is transferred to the function specified by
7628 EntryPoint using the new stack specified by NewStack and passing in the
7629 parameters specified by Context1 and Context2. Context1 and Context2 are
7630 optional and may be 0. The function EntryPoint must never return.
7632 If the current execution mode is not 32-bit protected mode with flat
7633 descriptors, then ASSERT().
7634 If EntryPoint is 0, then ASSERT().
7635 If NewStack is 0, then ASSERT().
7637 @param Cs The 16-bit selector to load in the CS before EntryPoint
7638 is called. The descriptor in the GDT that this selector
7639 references must be setup for long mode.
7640 @param EntryPoint The 64-bit virtual address of the function to call with
7641 the new stack after paging is enabled.
7642 @param Context1 The 64-bit virtual address of the context to pass into
7643 the EntryPoint function as the first parameter after
7645 @param Context2 The 64-bit virtual address of the context to pass into
7646 the EntryPoint function as the second parameter after
7648 @param NewStack The 64-bit virtual address of the new stack to use for
7649 the EntryPoint function after paging is enabled.
7656 IN UINT64 EntryPoint
,
7657 IN UINT64 Context1
, OPTIONAL
7658 IN UINT64 Context2
, OPTIONAL
7664 Disables the 64-bit paging mode on the CPU.
7666 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
7667 mode. This function assumes the current execution mode is 64-paging mode.
7668 This function is only available on x64. After the 64-bit paging mode is
7669 disabled, control is transferred to the function specified by EntryPoint
7670 using the new stack specified by NewStack and passing in the parameters
7671 specified by Context1 and Context2. Context1 and Context2 are optional and
7672 may be 0. The function EntryPoint must never return.
7674 If the current execution mode is not 64-bit paged mode, then ASSERT().
7675 If EntryPoint is 0, then ASSERT().
7676 If NewStack is 0, then ASSERT().
7678 @param Cs The 16-bit selector to load in the CS before EntryPoint
7679 is called. The descriptor in the GDT that this selector
7680 references must be setup for 32-bit protected mode.
7681 @param EntryPoint The 64-bit virtual address of the function to call with
7682 the new stack after paging is disabled.
7683 @param Context1 The 64-bit virtual address of the context to pass into
7684 the EntryPoint function as the first parameter after
7686 @param Context2 The 64-bit virtual address of the context to pass into
7687 the EntryPoint function as the second parameter after
7689 @param NewStack The 64-bit virtual address of the new stack to use for
7690 the EntryPoint function after paging is disabled.
7695 AsmDisablePaging64 (
7697 IN UINT32 EntryPoint
,
7698 IN UINT32 Context1
, OPTIONAL
7699 IN UINT32 Context2
, OPTIONAL
7705 // 16-bit thunking services
7709 Retrieves the properties for 16-bit thunk functions.
7711 Computes the size of the buffer and stack below 1MB required to use the
7712 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
7713 buffer size is returned in RealModeBufferSize, and the stack size is returned
7714 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
7715 then the actual minimum stack size is ExtraStackSize plus the maximum number
7716 of bytes that need to be passed to the 16-bit real mode code.
7718 If RealModeBufferSize is NULL, then ASSERT().
7719 If ExtraStackSize is NULL, then ASSERT().
7721 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
7722 required to use the 16-bit thunk functions.
7723 @param ExtraStackSize A pointer to the extra size of stack below 1MB
7724 that the 16-bit thunk functions require for
7725 temporary storage in the transition to and from
7731 AsmGetThunk16Properties (
7732 OUT UINT32
*RealModeBufferSize
,
7733 OUT UINT32
*ExtraStackSize
7738 Prepares all structures a code required to use AsmThunk16().
7740 Prepares all structures and code required to use AsmThunk16().
7742 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7743 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7745 If ThunkContext is NULL, then ASSERT().
7747 @param ThunkContext A pointer to the context structure that describes the
7748 16-bit real mode code to call.
7754 IN OUT THUNK_CONTEXT
*ThunkContext
7759 Transfers control to a 16-bit real mode entry point and returns the results.
7761 Transfers control to a 16-bit real mode entry point and returns the results.
7762 AsmPrepareThunk16() must be called with ThunkContext before this function is used.
7763 This function must be called with interrupts disabled.
7765 The register state from the RealModeState field of ThunkContext is restored just prior
7766 to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState,
7767 which is used to set the interrupt state when a 16-bit real mode entry point is called.
7768 Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.
7769 The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to
7770 the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function.
7771 The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,
7772 so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment
7773 and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry
7774 point must exit with a RETF instruction. The register state is captured into RealModeState immediately
7775 after the RETF instruction is executed.
7777 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7778 or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure
7779 the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode.
7781 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7782 then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode.
7783 This includes the base vectors, the interrupt masks, and the edge/level trigger mode.
7785 If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code
7786 is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.
7788 If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7789 ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to
7790 disable the A20 mask.
7792 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in
7793 ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails,
7794 then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7796 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in
7797 ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7799 If ThunkContext is NULL, then ASSERT().
7800 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
7801 If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7802 ThunkAttributes, then ASSERT().
7804 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7805 virtual to physical mappings for ThunkContext.RealModeBuffer are mapped 1:1.
7807 @param ThunkContext A pointer to the context structure that describes the
7808 16-bit real mode code to call.
7814 IN OUT THUNK_CONTEXT
*ThunkContext
7819 Prepares all structures and code for a 16-bit real mode thunk, transfers
7820 control to a 16-bit real mode entry point, and returns the results.
7822 Prepares all structures and code for a 16-bit real mode thunk, transfers
7823 control to a 16-bit real mode entry point, and returns the results. If the
7824 caller only need to perform a single 16-bit real mode thunk, then this
7825 service should be used. If the caller intends to make more than one 16-bit
7826 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
7827 once and AsmThunk16() can be called for each 16-bit real mode thunk.
7829 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7830 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7832 See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.
7834 @param ThunkContext A pointer to the context structure that describes the
7835 16-bit real mode code to call.
7840 AsmPrepareAndThunk16 (
7841 IN OUT THUNK_CONTEXT
*ThunkContext
7845 Generates a 16-bit random number through RDRAND instruction.
7847 if Rand is NULL, then ASSERT().
7849 @param[out] Rand Buffer pointer to store the random result.
7851 @retval TRUE RDRAND call was successful.
7852 @retval FALSE Failed attempts to call RDRAND.
7862 Generates a 32-bit random number through RDRAND instruction.
7864 if Rand is NULL, then ASSERT().
7866 @param[out] Rand Buffer pointer to store the random result.
7868 @retval TRUE RDRAND call was successful.
7869 @retval FALSE Failed attempts to call RDRAND.
7879 Generates a 64-bit random number through RDRAND instruction.
7881 if Rand is NULL, then ASSERT().
7883 @param[out] Rand Buffer pointer to store the random result.
7885 @retval TRUE RDRAND call was successful.
7886 @retval FALSE Failed attempts to call RDRAND.
7896 Load given selector into TR register.
7898 @param[in] Selector Task segment selector
7907 Performs a serializing operation on all load-from-memory instructions that
7908 were issued prior the AsmLfence function.
7910 Executes a LFENCE instruction. This function is only available on IA-32 and x64.
7920 Patch the immediate operand of an IA32 or X64 instruction such that the byte,
7921 word, dword or qword operand is encoded at the end of the instruction's
7922 binary representation.
7924 This function should be used to update object code that was compiled with
7925 NASM from assembly source code. Example:
7929 mov eax, strict dword 0 ; the imm32 zero operand will be patched
7935 X86_ASSEMBLY_PATCH_LABEL gPatchCr3;
7936 PatchInstructionX86 (gPatchCr3, AsmReadCr3 (), 4);
7938 @param[out] InstructionEnd Pointer right past the instruction to patch. The
7939 immediate operand to patch is expected to
7940 comprise the trailing bytes of the instruction.
7941 If InstructionEnd is closer to address 0 than
7942 ValueSize permits, then ASSERT().
7944 @param[in] PatchValue The constant to write to the immediate operand.
7945 The caller is responsible for ensuring that
7946 PatchValue can be represented in the byte, word,
7947 dword or qword operand (as indicated through
7948 ValueSize); otherwise ASSERT().
7950 @param[in] ValueSize The size of the operand in bytes; must be 1, 2,
7951 4, or 8. ASSERT() otherwise.
7955 PatchInstructionX86 (
7956 OUT X86_ASSEMBLY_PATCH_LABEL
*InstructionEnd
,
7957 IN UINT64 PatchValue
,
7961 #endif // defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
7962 #endif // !defined (__BASE_LIB__)