2 Provides string functions, linked list functions, math functions, synchronization
3 functions, file path functions, and CPU architecture-specific functions.
5 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
6 Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php.
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 // Definitions for architecture-specific types
23 #if defined (MDE_CPU_IA32)
25 /// The IA-32 architecture context buffer used by SetJump() and LongJump().
34 } BASE_LIBRARY_JUMP_BUFFER
;
36 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4
38 #endif // defined (MDE_CPU_IA32)
40 #if defined (MDE_CPU_X64)
42 /// The x64 architecture context buffer used by SetJump() and LongJump().
56 UINT8 XmmBuffer
[160]; ///< XMM6-XMM15.
57 } BASE_LIBRARY_JUMP_BUFFER
;
59 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
61 #endif // defined (MDE_CPU_X64)
63 #if defined (MDE_CPU_EBC)
65 /// The EBC context buffer used by SetJump() and LongJump().
73 } BASE_LIBRARY_JUMP_BUFFER
;
75 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
77 #endif // defined (MDE_CPU_EBC)
79 #if defined (MDE_CPU_ARM)
82 UINT32 R3
; ///< A copy of R13.
93 } BASE_LIBRARY_JUMP_BUFFER
;
95 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4
97 #endif // defined (MDE_CPU_ARM)
99 #if defined (MDE_CPU_AARCH64)
125 } BASE_LIBRARY_JUMP_BUFFER
;
127 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
129 #endif // defined (MDE_CPU_AARCH64)
138 Returns the length of a Null-terminated Unicode string.
140 This function is similar as strlen_s defined in C11.
142 If String is not aligned on a 16-bit boundary, then ASSERT().
144 @param String A pointer to a Null-terminated Unicode string.
145 @param MaxSize The maximum number of Destination Unicode
146 char, including terminating null char.
148 @retval 0 If String is NULL.
149 @retval MaxSize If there is no null character in the first MaxSize characters of String.
150 @return The number of characters that percede the terminating null character.
156 IN CONST CHAR16
*String
,
161 Returns the size of a Null-terminated Unicode string in bytes, including the
164 This function returns the size of the Null-terminated Unicode string
165 specified by String in bytes, including the Null terminator.
167 If String is not aligned on a 16-bit boundary, then ASSERT().
169 @param String A pointer to a Null-terminated Unicode string.
170 @param MaxSize The maximum number of Destination Unicode
171 char, including the Null terminator.
173 @retval 0 If String is NULL.
174 @retval (sizeof (CHAR16) * (MaxSize + 1))
175 If there is no Null terminator in the first MaxSize characters of
177 @return The size of the Null-terminated Unicode string in bytes, including
184 IN CONST CHAR16
*String
,
189 Copies the string pointed to by Source (including the terminating null char)
190 to the array pointed to by Destination.
192 This function is similar as strcpy_s defined in C11.
194 If Destination is not aligned on a 16-bit boundary, then ASSERT().
195 If Source is not aligned on a 16-bit boundary, then ASSERT().
196 If an error would be returned, then the function will also ASSERT().
198 If an error is returned, then the Destination is unmodified.
200 @param Destination A pointer to a Null-terminated Unicode string.
201 @param DestMax The maximum number of Destination Unicode
202 char, including terminating null char.
203 @param Source A pointer to a Null-terminated Unicode string.
205 @retval RETURN_SUCCESS String is copied.
206 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
207 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
209 If PcdMaximumUnicodeStringLength is not zero,
210 and DestMax is greater than
211 PcdMaximumUnicodeStringLength.
213 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
218 OUT CHAR16
*Destination
,
220 IN CONST CHAR16
*Source
224 Copies not more than Length successive char from the string pointed to by
225 Source to the array pointed to by Destination. If no null char is copied from
226 Source, then Destination[Length] is always set to null.
228 This function is similar as strncpy_s defined in C11.
230 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
231 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
232 If an error would be returned, then the function will also ASSERT().
234 If an error is returned, then the Destination is unmodified.
236 @param Destination A pointer to a Null-terminated Unicode string.
237 @param DestMax The maximum number of Destination Unicode
238 char, including terminating null char.
239 @param Source A pointer to a Null-terminated Unicode string.
240 @param Length The maximum number of Unicode characters to copy.
242 @retval RETURN_SUCCESS String is copied.
243 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than
244 MIN(StrLen(Source), Length).
245 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
247 If PcdMaximumUnicodeStringLength is not zero,
248 and DestMax is greater than
249 PcdMaximumUnicodeStringLength.
251 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
256 OUT CHAR16
*Destination
,
258 IN CONST CHAR16
*Source
,
263 Appends a copy of the string pointed to by Source (including the terminating
264 null char) to the end of the string pointed to by Destination.
266 This function is similar as strcat_s defined in C11.
268 If Destination is not aligned on a 16-bit boundary, then ASSERT().
269 If Source is not aligned on a 16-bit boundary, then ASSERT().
270 If an error would be returned, then the function will also ASSERT().
272 If an error is returned, then the Destination is unmodified.
274 @param Destination A pointer to a Null-terminated Unicode string.
275 @param DestMax The maximum number of Destination Unicode
276 char, including terminating null char.
277 @param Source A pointer to a Null-terminated Unicode string.
279 @retval RETURN_SUCCESS String is appended.
280 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
282 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
283 greater than StrLen(Source).
284 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
286 If PcdMaximumUnicodeStringLength is not zero,
287 and DestMax is greater than
288 PcdMaximumUnicodeStringLength.
290 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
295 IN OUT CHAR16
*Destination
,
297 IN CONST CHAR16
*Source
301 Appends not more than Length successive char from the string pointed to by
302 Source to the end of the string pointed to by Destination. If no null char is
303 copied from Source, then Destination[StrLen(Destination) + Length] is always
306 This function is similar as strncat_s defined in C11.
308 If Destination is not aligned on a 16-bit boundary, then ASSERT().
309 If Source is not aligned on a 16-bit boundary, then ASSERT().
310 If an error would be returned, then the function will also ASSERT().
312 If an error is returned, then the Destination is unmodified.
314 @param Destination A pointer to a Null-terminated Unicode string.
315 @param DestMax The maximum number of Destination Unicode
316 char, including terminating null char.
317 @param Source A pointer to a Null-terminated Unicode string.
318 @param Length The maximum number of Unicode characters to copy.
320 @retval RETURN_SUCCESS String is appended.
321 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
323 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
324 greater than MIN(StrLen(Source), Length).
325 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
327 If PcdMaximumUnicodeStringLength is not zero,
328 and DestMax is greater than
329 PcdMaximumUnicodeStringLength.
331 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
336 IN OUT CHAR16
*Destination
,
338 IN CONST CHAR16
*Source
,
343 Convert a Null-terminated Unicode decimal string to a value of type UINTN.
345 This function outputs a value of type UINTN by interpreting the contents of
346 the Unicode string specified by String as a decimal number. The format of the
347 input Unicode string String is:
349 [spaces] [decimal digits].
351 The valid decimal digit character is in the range [0-9]. The function will
352 ignore the pad space, which includes spaces or tab characters, before
353 [decimal digits]. The running zero in the beginning of [decimal digits] will
354 be ignored. Then, the function stops at the first character that is a not a
355 valid decimal character or a Null-terminator, whichever one comes first.
357 If String is NULL, then ASSERT().
358 If Data is NULL, then ASSERT().
359 If String is not aligned in a 16-bit boundary, then ASSERT().
360 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
361 PcdMaximumUnicodeStringLength Unicode characters, not including the
362 Null-terminator, then ASSERT().
364 If String has no valid decimal digits in the above format, then 0 is stored
365 at the location pointed to by Data.
366 If the number represented by String exceeds the range defined by UINTN, then
367 MAX_UINTN is stored at the location pointed to by Data.
369 If EndPointer is not NULL, a pointer to the character that stopped the scan
370 is stored at the location pointed to by EndPointer. If String has no valid
371 decimal digits right after the optional pad spaces, the value of String is
372 stored at the location pointed to by EndPointer.
374 @param String Pointer to a Null-terminated Unicode string.
375 @param EndPointer Pointer to character that stops scan.
376 @param Data Pointer to the converted value.
378 @retval RETURN_SUCCESS Value is translated from String.
379 @retval RETURN_INVALID_PARAMETER If String is NULL.
381 If PcdMaximumUnicodeStringLength is not
382 zero, and String contains more than
383 PcdMaximumUnicodeStringLength Unicode
384 characters, not including the
386 @retval RETURN_UNSUPPORTED If the number represented by String exceeds
387 the range defined by UINTN.
393 IN CONST CHAR16
*String
,
394 OUT CHAR16
**EndPointer
, OPTIONAL
399 Convert a Null-terminated Unicode decimal string to a value of type UINT64.
401 This function outputs a value of type UINT64 by interpreting the contents of
402 the Unicode string specified by String as a decimal number. The format of the
403 input Unicode string String is:
405 [spaces] [decimal digits].
407 The valid decimal digit character is in the range [0-9]. The function will
408 ignore the pad space, which includes spaces or tab characters, before
409 [decimal digits]. The running zero in the beginning of [decimal digits] will
410 be ignored. Then, the function stops at the first character that is a not a
411 valid decimal character or a Null-terminator, whichever one comes first.
413 If String is NULL, then ASSERT().
414 If Data is NULL, then ASSERT().
415 If String is not aligned in a 16-bit boundary, then ASSERT().
416 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
417 PcdMaximumUnicodeStringLength Unicode characters, not including the
418 Null-terminator, then ASSERT().
420 If String has no valid decimal digits in the above format, then 0 is stored
421 at the location pointed to by Data.
422 If the number represented by String exceeds the range defined by UINT64, then
423 MAX_UINT64 is stored at the location pointed to by Data.
425 If EndPointer is not NULL, a pointer to the character that stopped the scan
426 is stored at the location pointed to by EndPointer. If String has no valid
427 decimal digits right after the optional pad spaces, the value of String is
428 stored at the location pointed to by EndPointer.
430 @param String Pointer to a Null-terminated Unicode string.
431 @param EndPointer Pointer to character that stops scan.
432 @param Data Pointer to the converted value.
434 @retval RETURN_SUCCESS Value is translated from String.
435 @retval RETURN_INVALID_PARAMETER If String is NULL.
437 If PcdMaximumUnicodeStringLength is not
438 zero, and String contains more than
439 PcdMaximumUnicodeStringLength Unicode
440 characters, not including the
442 @retval RETURN_UNSUPPORTED If the number represented by String exceeds
443 the range defined by UINT64.
448 StrDecimalToUint64S (
449 IN CONST CHAR16
*String
,
450 OUT CHAR16
**EndPointer
, OPTIONAL
455 Convert a Null-terminated Unicode hexadecimal string to a value of type
458 This function outputs a value of type UINTN by interpreting the contents of
459 the Unicode string specified by String as a hexadecimal number. The format of
460 the input Unicode string String is:
462 [spaces][zeros][x][hexadecimal digits].
464 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
465 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
466 If "x" appears in the input string, it must be prefixed with at least one 0.
467 The function will ignore the pad space, which includes spaces or tab
468 characters, before [zeros], [x] or [hexadecimal digit]. The running zero
469 before [x] or [hexadecimal digit] will be ignored. Then, the decoding starts
470 after [x] or the first valid hexadecimal digit. Then, the function stops at
471 the first character that is a not a valid hexadecimal character or NULL,
472 whichever one comes first.
474 If String is NULL, then ASSERT().
475 If Data is NULL, then ASSERT().
476 If String is not aligned in a 16-bit boundary, then ASSERT().
477 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
478 PcdMaximumUnicodeStringLength Unicode characters, not including the
479 Null-terminator, then ASSERT().
481 If String has no valid hexadecimal digits in the above format, then 0 is
482 stored at the location pointed to by Data.
483 If the number represented by String exceeds the range defined by UINTN, then
484 MAX_UINTN is stored at the location pointed to by Data.
486 If EndPointer is not NULL, a pointer to the character that stopped the scan
487 is stored at the location pointed to by EndPointer. If String has no valid
488 hexadecimal digits right after the optional pad spaces, the value of String
489 is stored at the location pointed to by EndPointer.
491 @param String Pointer to a Null-terminated Unicode string.
492 @param EndPointer Pointer to character that stops scan.
493 @param Data Pointer to the converted value.
495 @retval RETURN_SUCCESS Value is translated from String.
496 @retval RETURN_INVALID_PARAMETER If String is NULL.
498 If PcdMaximumUnicodeStringLength is not
499 zero, and String contains more than
500 PcdMaximumUnicodeStringLength Unicode
501 characters, not including the
503 @retval RETURN_UNSUPPORTED If the number represented by String exceeds
504 the range defined by UINTN.
510 IN CONST CHAR16
*String
,
511 OUT CHAR16
**EndPointer
, OPTIONAL
516 Convert a Null-terminated Unicode hexadecimal string to a value of type
519 This function outputs a value of type UINT64 by interpreting the contents of
520 the Unicode string specified by String as a hexadecimal number. The format of
521 the input Unicode string String is:
523 [spaces][zeros][x][hexadecimal digits].
525 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
526 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
527 If "x" appears in the input string, it must be prefixed with at least one 0.
528 The function will ignore the pad space, which includes spaces or tab
529 characters, before [zeros], [x] or [hexadecimal digit]. The running zero
530 before [x] or [hexadecimal digit] will be ignored. Then, the decoding starts
531 after [x] or the first valid hexadecimal digit. Then, the function stops at
532 the first character that is a not a valid hexadecimal character or NULL,
533 whichever one comes first.
535 If String is NULL, then ASSERT().
536 If Data is NULL, then ASSERT().
537 If String is not aligned in a 16-bit boundary, then ASSERT().
538 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
539 PcdMaximumUnicodeStringLength Unicode characters, not including the
540 Null-terminator, then ASSERT().
542 If String has no valid hexadecimal digits in the above format, then 0 is
543 stored at the location pointed to by Data.
544 If the number represented by String exceeds the range defined by UINT64, then
545 MAX_UINT64 is stored at the location pointed to by Data.
547 If EndPointer is not NULL, a pointer to the character that stopped the scan
548 is stored at the location pointed to by EndPointer. If String has no valid
549 hexadecimal digits right after the optional pad spaces, the value of String
550 is stored at the location pointed to by EndPointer.
552 @param String Pointer to a Null-terminated Unicode string.
553 @param EndPointer Pointer to character that stops scan.
554 @param Data Pointer to the converted value.
556 @retval RETURN_SUCCESS Value is translated from String.
557 @retval RETURN_INVALID_PARAMETER If String is NULL.
559 If PcdMaximumUnicodeStringLength is not
560 zero, and String contains more than
561 PcdMaximumUnicodeStringLength Unicode
562 characters, not including the
564 @retval RETURN_UNSUPPORTED If the number represented by String exceeds
565 the range defined by UINT64.
571 IN CONST CHAR16
*String
,
572 OUT CHAR16
**EndPointer
, OPTIONAL
577 Returns the length of a Null-terminated Ascii string.
579 This function is similar as strlen_s defined in C11.
581 @param String A pointer to a Null-terminated Ascii string.
582 @param MaxSize The maximum number of Destination Ascii
583 char, including terminating null char.
585 @retval 0 If String is NULL.
586 @retval MaxSize If there is no null character in the first MaxSize characters of String.
587 @return The number of characters that percede the terminating null character.
593 IN CONST CHAR8
*String
,
598 Returns the size of a Null-terminated Ascii string in bytes, including the
601 This function returns the size of the Null-terminated Ascii string specified
602 by String in bytes, including the Null terminator.
604 @param String A pointer to a Null-terminated Ascii string.
605 @param MaxSize The maximum number of Destination Ascii
606 char, including the Null terminator.
608 @retval 0 If String is NULL.
609 @retval (sizeof (CHAR8) * (MaxSize + 1))
610 If there is no Null terminator in the first MaxSize characters of
612 @return The size of the Null-terminated Ascii string in bytes, including the
619 IN CONST CHAR8
*String
,
624 Copies the string pointed to by Source (including the terminating null char)
625 to the array pointed to by Destination.
627 This function is similar as strcpy_s defined in C11.
629 If an error would be returned, then the function will also ASSERT().
631 If an error is returned, then the Destination is unmodified.
633 @param Destination A pointer to a Null-terminated Ascii string.
634 @param DestMax The maximum number of Destination Ascii
635 char, including terminating null char.
636 @param Source A pointer to a Null-terminated Ascii string.
638 @retval RETURN_SUCCESS String is copied.
639 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
640 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
642 If PcdMaximumAsciiStringLength is not zero,
643 and DestMax is greater than
644 PcdMaximumAsciiStringLength.
646 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
651 OUT CHAR8
*Destination
,
653 IN CONST CHAR8
*Source
657 Copies not more than Length successive char from the string pointed to by
658 Source to the array pointed to by Destination. If no null char is copied from
659 Source, then Destination[Length] is always set to null.
661 This function is similar as strncpy_s defined in C11.
663 If an error would be returned, then the function will also ASSERT().
665 If an error is returned, then the Destination is unmodified.
667 @param Destination A pointer to a Null-terminated Ascii string.
668 @param DestMax The maximum number of Destination Ascii
669 char, including terminating null char.
670 @param Source A pointer to a Null-terminated Ascii string.
671 @param Length The maximum number of Ascii characters to copy.
673 @retval RETURN_SUCCESS String is copied.
674 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than
675 MIN(StrLen(Source), Length).
676 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
678 If PcdMaximumAsciiStringLength is not zero,
679 and DestMax is greater than
680 PcdMaximumAsciiStringLength.
682 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
687 OUT CHAR8
*Destination
,
689 IN CONST CHAR8
*Source
,
694 Appends a copy of the string pointed to by Source (including the terminating
695 null char) to the end of the string pointed to by Destination.
697 This function is similar as strcat_s defined in C11.
699 If an error would be returned, then the function will also ASSERT().
701 If an error is returned, then the Destination is unmodified.
703 @param Destination A pointer to a Null-terminated Ascii string.
704 @param DestMax The maximum number of Destination Ascii
705 char, including terminating null char.
706 @param Source A pointer to a Null-terminated Ascii string.
708 @retval RETURN_SUCCESS String is appended.
709 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
711 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
712 greater than StrLen(Source).
713 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
715 If PcdMaximumAsciiStringLength is not zero,
716 and DestMax is greater than
717 PcdMaximumAsciiStringLength.
719 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
724 IN OUT CHAR8
*Destination
,
726 IN CONST CHAR8
*Source
730 Appends not more than Length successive char from the string pointed to by
731 Source to the end of the string pointed to by Destination. If no null char is
732 copied from Source, then Destination[StrLen(Destination) + Length] is always
735 This function is similar as strncat_s defined in C11.
737 If an error would be returned, then the function will also ASSERT().
739 If an error is returned, then the Destination is unmodified.
741 @param Destination A pointer to a Null-terminated Ascii string.
742 @param DestMax The maximum number of Destination Ascii
743 char, including terminating null char.
744 @param Source A pointer to a Null-terminated Ascii string.
745 @param Length The maximum number of Ascii characters to copy.
747 @retval RETURN_SUCCESS String is appended.
748 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
750 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
751 greater than MIN(StrLen(Source), Length).
752 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
754 If PcdMaximumAsciiStringLength is not zero,
755 and DestMax is greater than
756 PcdMaximumAsciiStringLength.
758 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
763 IN OUT CHAR8
*Destination
,
765 IN CONST CHAR8
*Source
,
770 Convert a Null-terminated Ascii decimal string to a value of type UINTN.
772 This function outputs a value of type UINTN by interpreting the contents of
773 the Ascii string specified by String as a decimal number. The format of the
774 input Ascii string String is:
776 [spaces] [decimal digits].
778 The valid decimal digit character is in the range [0-9]. The function will
779 ignore the pad space, which includes spaces or tab characters, before
780 [decimal digits]. The running zero in the beginning of [decimal digits] will
781 be ignored. Then, the function stops at the first character that is a not a
782 valid decimal character or a Null-terminator, whichever one comes first.
784 If String is NULL, then ASSERT().
785 If Data is NULL, then ASSERT().
786 If PcdMaximumAsciiStringLength is not zero, and String contains more than
787 PcdMaximumAsciiStringLength Ascii characters, not including the
788 Null-terminator, then ASSERT().
790 If String has no valid decimal digits in the above format, then 0 is stored
791 at the location pointed to by Data.
792 If the number represented by String exceeds the range defined by UINTN, then
793 MAX_UINTN is stored at the location pointed to by Data.
795 If EndPointer is not NULL, a pointer to the character that stopped the scan
796 is stored at the location pointed to by EndPointer. If String has no valid
797 decimal digits right after the optional pad spaces, the value of String is
798 stored at the location pointed to by EndPointer.
800 @param String Pointer to a Null-terminated Ascii string.
801 @param EndPointer Pointer to character that stops scan.
802 @param Data Pointer to the converted value.
804 @retval RETURN_SUCCESS Value is translated from String.
805 @retval RETURN_INVALID_PARAMETER If String is NULL.
807 If PcdMaximumAsciiStringLength is not zero,
808 and String contains more than
809 PcdMaximumAsciiStringLength Ascii
810 characters, not including the
812 @retval RETURN_UNSUPPORTED If the number represented by String exceeds
813 the range defined by UINTN.
818 AsciiStrDecimalToUintnS (
819 IN CONST CHAR8
*String
,
820 OUT CHAR8
**EndPointer
, OPTIONAL
825 Convert a Null-terminated Ascii decimal string to a value of type UINT64.
827 This function outputs a value of type UINT64 by interpreting the contents of
828 the Ascii string specified by String as a decimal number. The format of the
829 input Ascii string String is:
831 [spaces] [decimal digits].
833 The valid decimal digit character is in the range [0-9]. The function will
834 ignore the pad space, which includes spaces or tab characters, before
835 [decimal digits]. The running zero in the beginning of [decimal digits] will
836 be ignored. Then, the function stops at the first character that is a not a
837 valid decimal character or a Null-terminator, whichever one comes first.
839 If String is NULL, then ASSERT().
840 If Data is NULL, then ASSERT().
841 If PcdMaximumAsciiStringLength is not zero, and String contains more than
842 PcdMaximumAsciiStringLength Ascii characters, not including the
843 Null-terminator, then ASSERT().
845 If String has no valid decimal digits in the above format, then 0 is stored
846 at the location pointed to by Data.
847 If the number represented by String exceeds the range defined by UINT64, then
848 MAX_UINT64 is stored at the location pointed to by Data.
850 If EndPointer is not NULL, a pointer to the character that stopped the scan
851 is stored at the location pointed to by EndPointer. If String has no valid
852 decimal digits right after the optional pad spaces, the value of String is
853 stored at the location pointed to by EndPointer.
855 @param String Pointer to a Null-terminated Ascii string.
856 @param EndPointer Pointer to character that stops scan.
857 @param Data Pointer to the converted value.
859 @retval RETURN_SUCCESS Value is translated from String.
860 @retval RETURN_INVALID_PARAMETER If String is NULL.
862 If PcdMaximumAsciiStringLength is not zero,
863 and String contains more than
864 PcdMaximumAsciiStringLength Ascii
865 characters, not including the
867 @retval RETURN_UNSUPPORTED If the number represented by String exceeds
868 the range defined by UINT64.
873 AsciiStrDecimalToUint64S (
874 IN CONST CHAR8
*String
,
875 OUT CHAR8
**EndPointer
, OPTIONAL
880 Convert a Null-terminated Ascii hexadecimal string to a value of type UINTN.
882 This function outputs a value of type UINTN by interpreting the contents of
883 the Ascii string specified by String as a hexadecimal number. The format of
884 the input Ascii string String is:
886 [spaces][zeros][x][hexadecimal digits].
888 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
889 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If
890 "x" appears in the input string, it must be prefixed with at least one 0. The
891 function will ignore the pad space, which includes spaces or tab characters,
892 before [zeros], [x] or [hexadecimal digits]. The running zero before [x] or
893 [hexadecimal digits] will be ignored. Then, the decoding starts after [x] or
894 the first valid hexadecimal digit. Then, the function stops at the first
895 character that is a not a valid hexadecimal character or Null-terminator,
896 whichever on comes first.
898 If String is NULL, then ASSERT().
899 If Data is NULL, then ASSERT().
900 If PcdMaximumAsciiStringLength is not zero, and String contains more than
901 PcdMaximumAsciiStringLength Ascii characters, not including the
902 Null-terminator, then ASSERT().
904 If String has no valid hexadecimal digits in the above format, then 0 is
905 stored at the location pointed to by Data.
906 If the number represented by String exceeds the range defined by UINTN, then
907 MAX_UINTN is stored at the location pointed to by Data.
909 If EndPointer is not NULL, a pointer to the character that stopped the scan
910 is stored at the location pointed to by EndPointer. If String has no valid
911 hexadecimal digits right after the optional pad spaces, the value of String
912 is stored at the location pointed to by EndPointer.
914 @param String Pointer to a Null-terminated Ascii string.
915 @param EndPointer Pointer to character that stops scan.
916 @param Data Pointer to the converted value.
918 @retval RETURN_SUCCESS Value is translated from String.
919 @retval RETURN_INVALID_PARAMETER If String is NULL.
921 If PcdMaximumAsciiStringLength is not zero,
922 and String contains more than
923 PcdMaximumAsciiStringLength Ascii
924 characters, not including the
926 @retval RETURN_UNSUPPORTED If the number represented by String exceeds
927 the range defined by UINTN.
932 AsciiStrHexToUintnS (
933 IN CONST CHAR8
*String
,
934 OUT CHAR8
**EndPointer
, OPTIONAL
939 Convert a Null-terminated Ascii hexadecimal string to a value of type UINT64.
941 This function outputs a value of type UINT64 by interpreting the contents of
942 the Ascii string specified by String as a hexadecimal number. The format of
943 the input Ascii string String is:
945 [spaces][zeros][x][hexadecimal digits].
947 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
948 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If
949 "x" appears in the input string, it must be prefixed with at least one 0. The
950 function will ignore the pad space, which includes spaces or tab characters,
951 before [zeros], [x] or [hexadecimal digits]. The running zero before [x] or
952 [hexadecimal digits] will be ignored. Then, the decoding starts after [x] or
953 the first valid hexadecimal digit. Then, the function stops at the first
954 character that is a not a valid hexadecimal character or Null-terminator,
955 whichever on comes first.
957 If String is NULL, then ASSERT().
958 If Data is NULL, then ASSERT().
959 If PcdMaximumAsciiStringLength is not zero, and String contains more than
960 PcdMaximumAsciiStringLength Ascii characters, not including the
961 Null-terminator, then ASSERT().
963 If String has no valid hexadecimal digits in the above format, then 0 is
964 stored at the location pointed to by Data.
965 If the number represented by String exceeds the range defined by UINT64, then
966 MAX_UINT64 is stored at the location pointed to by Data.
968 If EndPointer is not NULL, a pointer to the character that stopped the scan
969 is stored at the location pointed to by EndPointer. If String has no valid
970 hexadecimal digits right after the optional pad spaces, the value of String
971 is stored at the location pointed to by EndPointer.
973 @param String Pointer to a Null-terminated Ascii string.
974 @param EndPointer Pointer to character that stops scan.
975 @param Data Pointer to the converted value.
977 @retval RETURN_SUCCESS Value is translated from String.
978 @retval RETURN_INVALID_PARAMETER If String is NULL.
980 If PcdMaximumAsciiStringLength is not zero,
981 and String contains more than
982 PcdMaximumAsciiStringLength Ascii
983 characters, not including the
985 @retval RETURN_UNSUPPORTED If the number represented by String exceeds
986 the range defined by UINT64.
991 AsciiStrHexToUint64S (
992 IN CONST CHAR8
*String
,
993 OUT CHAR8
**EndPointer
, OPTIONAL
998 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1001 [ATTENTION] This function is deprecated for security reason.
1003 Copies one Null-terminated Unicode string to another Null-terminated Unicode
1004 string and returns the new Unicode string.
1006 This function copies the contents of the Unicode string Source to the Unicode
1007 string Destination, and returns Destination. If Source and Destination
1008 overlap, then the results are undefined.
1010 If Destination is NULL, then ASSERT().
1011 If Destination is not aligned on a 16-bit boundary, then ASSERT().
1012 If Source is NULL, then ASSERT().
1013 If Source is not aligned on a 16-bit boundary, then ASSERT().
1014 If Source and Destination overlap, then ASSERT().
1015 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1016 PcdMaximumUnicodeStringLength Unicode characters not including the
1017 Null-terminator, then ASSERT().
1019 @param Destination The pointer to a Null-terminated Unicode string.
1020 @param Source The pointer to a Null-terminated Unicode string.
1022 @return Destination.
1028 OUT CHAR16
*Destination
,
1029 IN CONST CHAR16
*Source
1034 [ATTENTION] This function is deprecated for security reason.
1036 Copies up to a specified length from one Null-terminated Unicode string to
1037 another Null-terminated Unicode string and returns the new Unicode string.
1039 This function copies the contents of the Unicode string Source to the Unicode
1040 string Destination, and returns Destination. At most, Length Unicode
1041 characters are copied from Source to Destination. If Length is 0, then
1042 Destination is returned unmodified. If Length is greater that the number of
1043 Unicode characters in Source, then Destination is padded with Null Unicode
1044 characters. If Source and Destination overlap, then the results are
1047 If Length > 0 and Destination is NULL, then ASSERT().
1048 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
1049 If Length > 0 and Source is NULL, then ASSERT().
1050 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
1051 If Source and Destination overlap, then ASSERT().
1052 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
1053 PcdMaximumUnicodeStringLength, then ASSERT().
1054 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1055 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
1058 @param Destination The pointer to a Null-terminated Unicode string.
1059 @param Source The pointer to a Null-terminated Unicode string.
1060 @param Length The maximum number of Unicode characters to copy.
1062 @return Destination.
1068 OUT CHAR16
*Destination
,
1069 IN CONST CHAR16
*Source
,
1072 #endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES)
1075 Returns the length of a Null-terminated Unicode string.
1077 This function returns the number of Unicode characters in the Null-terminated
1078 Unicode string specified by String.
1080 If String is NULL, then ASSERT().
1081 If String is not aligned on a 16-bit boundary, then ASSERT().
1082 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
1083 PcdMaximumUnicodeStringLength Unicode characters not including the
1084 Null-terminator, then ASSERT().
1086 @param String Pointer to a Null-terminated Unicode string.
1088 @return The length of String.
1094 IN CONST CHAR16
*String
1099 Returns the size of a Null-terminated Unicode string in bytes, including the
1102 This function returns the size, in bytes, of the Null-terminated Unicode string
1103 specified by String.
1105 If String is NULL, then ASSERT().
1106 If String is not aligned on a 16-bit boundary, then ASSERT().
1107 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
1108 PcdMaximumUnicodeStringLength Unicode characters not including the
1109 Null-terminator, then ASSERT().
1111 @param String The pointer to a Null-terminated Unicode string.
1113 @return The size of String.
1119 IN CONST CHAR16
*String
1124 Compares two Null-terminated Unicode strings, and returns the difference
1125 between the first mismatched Unicode characters.
1127 This function compares the Null-terminated Unicode string FirstString to the
1128 Null-terminated Unicode string SecondString. If FirstString is identical to
1129 SecondString, then 0 is returned. Otherwise, the value returned is the first
1130 mismatched Unicode character in SecondString subtracted from the first
1131 mismatched Unicode character in FirstString.
1133 If FirstString is NULL, then ASSERT().
1134 If FirstString is not aligned on a 16-bit boundary, then ASSERT().
1135 If SecondString is NULL, then ASSERT().
1136 If SecondString is not aligned on a 16-bit boundary, then ASSERT().
1137 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
1138 than PcdMaximumUnicodeStringLength Unicode characters not including the
1139 Null-terminator, then ASSERT().
1140 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
1141 than PcdMaximumUnicodeStringLength Unicode characters, not including the
1142 Null-terminator, then ASSERT().
1144 @param FirstString The pointer to a Null-terminated Unicode string.
1145 @param SecondString The pointer to a Null-terminated Unicode string.
1147 @retval 0 FirstString is identical to SecondString.
1148 @return others FirstString is not identical to SecondString.
1154 IN CONST CHAR16
*FirstString
,
1155 IN CONST CHAR16
*SecondString
1160 Compares up to a specified length the contents of two Null-terminated Unicode strings,
1161 and returns the difference between the first mismatched Unicode characters.
1163 This function compares the Null-terminated Unicode string FirstString to the
1164 Null-terminated Unicode string SecondString. At most, Length Unicode
1165 characters will be compared. If Length is 0, then 0 is returned. If
1166 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
1167 value returned is the first mismatched Unicode character in SecondString
1168 subtracted from the first mismatched Unicode character in FirstString.
1170 If Length > 0 and FirstString is NULL, then ASSERT().
1171 If Length > 0 and FirstString is not aligned on a 16-bit boundary, then ASSERT().
1172 If Length > 0 and SecondString is NULL, then ASSERT().
1173 If Length > 0 and SecondString is not aligned on a 16-bit boundary, then ASSERT().
1174 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
1175 PcdMaximumUnicodeStringLength, then ASSERT().
1176 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more than
1177 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
1179 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more than
1180 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
1183 @param FirstString The pointer to a Null-terminated Unicode string.
1184 @param SecondString The pointer to a Null-terminated Unicode string.
1185 @param Length The maximum number of Unicode characters to compare.
1187 @retval 0 FirstString is identical to SecondString.
1188 @return others FirstString is not identical to SecondString.
1194 IN CONST CHAR16
*FirstString
,
1195 IN CONST CHAR16
*SecondString
,
1200 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1203 [ATTENTION] This function is deprecated for security reason.
1205 Concatenates one Null-terminated Unicode string to another Null-terminated
1206 Unicode string, and returns the concatenated Unicode string.
1208 This function concatenates two Null-terminated Unicode strings. The contents
1209 of Null-terminated Unicode string Source are concatenated to the end of
1210 Null-terminated Unicode string Destination. The Null-terminated concatenated
1211 Unicode String is returned. If Source and Destination overlap, then the
1212 results are undefined.
1214 If Destination is NULL, then ASSERT().
1215 If Destination is not aligned on a 16-bit boundary, then ASSERT().
1216 If Source is NULL, then ASSERT().
1217 If Source is not aligned on a 16-bit boundary, then ASSERT().
1218 If Source and Destination overlap, then ASSERT().
1219 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
1220 than PcdMaximumUnicodeStringLength Unicode characters, not including the
1221 Null-terminator, then ASSERT().
1222 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1223 PcdMaximumUnicodeStringLength Unicode characters, not including the
1224 Null-terminator, then ASSERT().
1225 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
1226 and Source results in a Unicode string with more than
1227 PcdMaximumUnicodeStringLength Unicode characters, not including the
1228 Null-terminator, then ASSERT().
1230 @param Destination The pointer to a Null-terminated Unicode string.
1231 @param Source The pointer to a Null-terminated Unicode string.
1233 @return Destination.
1239 IN OUT CHAR16
*Destination
,
1240 IN CONST CHAR16
*Source
1245 [ATTENTION] This function is deprecated for security reason.
1247 Concatenates up to a specified length one Null-terminated Unicode to the end
1248 of another Null-terminated Unicode string, and returns the concatenated
1251 This function concatenates two Null-terminated Unicode strings. The contents
1252 of Null-terminated Unicode string Source are concatenated to the end of
1253 Null-terminated Unicode string Destination, and Destination is returned. At
1254 most, Length Unicode characters are concatenated from Source to the end of
1255 Destination, and Destination is always Null-terminated. If Length is 0, then
1256 Destination is returned unmodified. If Source and Destination overlap, then
1257 the results are undefined.
1259 If Destination is NULL, then ASSERT().
1260 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
1261 If Length > 0 and Source is NULL, then ASSERT().
1262 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
1263 If Source and Destination overlap, then ASSERT().
1264 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
1265 PcdMaximumUnicodeStringLength, then ASSERT().
1266 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
1267 than PcdMaximumUnicodeStringLength Unicode characters, not including the
1268 Null-terminator, then ASSERT().
1269 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1270 PcdMaximumUnicodeStringLength Unicode characters, not including the
1271 Null-terminator, then ASSERT().
1272 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
1273 and Source results in a Unicode string with more than PcdMaximumUnicodeStringLength
1274 Unicode characters, not including the Null-terminator, then ASSERT().
1276 @param Destination The pointer to a Null-terminated Unicode string.
1277 @param Source The pointer to a Null-terminated Unicode string.
1278 @param Length The maximum number of Unicode characters to concatenate from
1281 @return Destination.
1287 IN OUT CHAR16
*Destination
,
1288 IN CONST CHAR16
*Source
,
1291 #endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES)
1294 Returns the first occurrence of a Null-terminated Unicode sub-string
1295 in a Null-terminated Unicode string.
1297 This function scans the contents of the Null-terminated Unicode string
1298 specified by String and returns the first occurrence of SearchString.
1299 If SearchString is not found in String, then NULL is returned. If
1300 the length of SearchString is zero, then String is returned.
1302 If String is NULL, then ASSERT().
1303 If String is not aligned on a 16-bit boundary, then ASSERT().
1304 If SearchString is NULL, then ASSERT().
1305 If SearchString is not aligned on a 16-bit boundary, then ASSERT().
1307 If PcdMaximumUnicodeStringLength is not zero, and SearchString
1308 or String contains more than PcdMaximumUnicodeStringLength Unicode
1309 characters, not including the Null-terminator, then ASSERT().
1311 @param String The pointer to a Null-terminated Unicode string.
1312 @param SearchString The pointer to a Null-terminated Unicode string to search for.
1314 @retval NULL If the SearchString does not appear in String.
1315 @return others If there is a match.
1321 IN CONST CHAR16
*String
,
1322 IN CONST CHAR16
*SearchString
1326 Convert a Null-terminated Unicode decimal string to a value of
1329 This function returns a value of type UINTN by interpreting the contents
1330 of the Unicode string specified by String as a decimal number. The format
1331 of the input Unicode string String is:
1333 [spaces] [decimal digits].
1335 The valid decimal digit character is in the range [0-9]. The
1336 function will ignore the pad space, which includes spaces or
1337 tab characters, before [decimal digits]. The running zero in the
1338 beginning of [decimal digits] will be ignored. Then, the function
1339 stops at the first character that is a not a valid decimal character
1340 or a Null-terminator, whichever one comes first.
1342 If String is NULL, then ASSERT().
1343 If String is not aligned in a 16-bit boundary, then ASSERT().
1344 If String has only pad spaces, then 0 is returned.
1345 If String has no pad spaces or valid decimal digits,
1347 If the number represented by String overflows according
1348 to the range defined by UINTN, then MAX_UINTN is returned.
1350 If PcdMaximumUnicodeStringLength is not zero, and String contains
1351 more than PcdMaximumUnicodeStringLength Unicode characters not including
1352 the Null-terminator, then ASSERT().
1354 @param String The pointer to a Null-terminated Unicode string.
1356 @retval Value translated from String.
1362 IN CONST CHAR16
*String
1366 Convert a Null-terminated Unicode decimal string to a value of
1369 This function returns a value of type UINT64 by interpreting the contents
1370 of the Unicode string specified by String as a decimal number. The format
1371 of the input Unicode string String is:
1373 [spaces] [decimal digits].
1375 The valid decimal digit character is in the range [0-9]. The
1376 function will ignore the pad space, which includes spaces or
1377 tab characters, before [decimal digits]. The running zero in the
1378 beginning of [decimal digits] will be ignored. Then, the function
1379 stops at the first character that is a not a valid decimal character
1380 or a Null-terminator, whichever one comes first.
1382 If String is NULL, then ASSERT().
1383 If String is not aligned in a 16-bit boundary, then ASSERT().
1384 If String has only pad spaces, then 0 is returned.
1385 If String has no pad spaces or valid decimal digits,
1387 If the number represented by String overflows according
1388 to the range defined by UINT64, then MAX_UINT64 is returned.
1390 If PcdMaximumUnicodeStringLength is not zero, and String contains
1391 more than PcdMaximumUnicodeStringLength Unicode characters not including
1392 the Null-terminator, then ASSERT().
1394 @param String The pointer to a Null-terminated Unicode string.
1396 @retval Value translated from String.
1401 StrDecimalToUint64 (
1402 IN CONST CHAR16
*String
1407 Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.
1409 This function returns a value of type UINTN by interpreting the contents
1410 of the Unicode string specified by String as a hexadecimal number.
1411 The format of the input Unicode string String is:
1413 [spaces][zeros][x][hexadecimal digits].
1415 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1416 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
1417 If "x" appears in the input string, it must be prefixed with at least one 0.
1418 The function will ignore the pad space, which includes spaces or tab characters,
1419 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
1420 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
1421 first valid hexadecimal digit. Then, the function stops at the first character
1422 that is a not a valid hexadecimal character or NULL, whichever one comes first.
1424 If String is NULL, then ASSERT().
1425 If String is not aligned in a 16-bit boundary, then ASSERT().
1426 If String has only pad spaces, then zero is returned.
1427 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
1428 then zero is returned.
1429 If the number represented by String overflows according to the range defined by
1430 UINTN, then MAX_UINTN is returned.
1432 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
1433 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
1436 @param String The pointer to a Null-terminated Unicode string.
1438 @retval Value translated from String.
1444 IN CONST CHAR16
*String
1449 Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.
1451 This function returns a value of type UINT64 by interpreting the contents
1452 of the Unicode string specified by String as a hexadecimal number.
1453 The format of the input Unicode string String is
1455 [spaces][zeros][x][hexadecimal digits].
1457 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1458 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
1459 If "x" appears in the input string, it must be prefixed with at least one 0.
1460 The function will ignore the pad space, which includes spaces or tab characters,
1461 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
1462 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
1463 first valid hexadecimal digit. Then, the function stops at the first character that is
1464 a not a valid hexadecimal character or NULL, whichever one comes first.
1466 If String is NULL, then ASSERT().
1467 If String is not aligned in a 16-bit boundary, then ASSERT().
1468 If String has only pad spaces, then zero is returned.
1469 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
1470 then zero is returned.
1471 If the number represented by String overflows according to the range defined by
1472 UINT64, then MAX_UINT64 is returned.
1474 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
1475 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
1478 @param String The pointer to a Null-terminated Unicode string.
1480 @retval Value translated from String.
1486 IN CONST CHAR16
*String
1490 Convert a Null-terminated Unicode string to IPv6 address and prefix length.
1492 This function outputs a value of type IPv6_ADDRESS and may output a value
1493 of type UINT8 by interpreting the contents of the Unicode string specified
1494 by String. The format of the input Unicode string String is as follows:
1498 X contains one to four hexadecimal digit characters in the range [0-9], [a-f] and
1499 [A-F]. X is converted to a value of type UINT16, whose low byte is stored in low
1500 memory address and high byte is stored in high memory address. P contains decimal
1501 digit characters in the range [0-9]. The running zero in the beginning of P will
1502 be ignored. /P is optional.
1504 When /P is not in the String, the function stops at the first character that is
1505 not a valid hexadecimal digit character after eight X's are converted.
1507 When /P is in the String, the function stops at the first character that is not
1508 a valid decimal digit character after P is converted.
1510 "::" can be used to compress one or more groups of X when X contains only 0.
1511 The "::" can only appear once in the String.
1513 If String is NULL, then ASSERT().
1515 If Address is NULL, then ASSERT().
1517 If String is not aligned in a 16-bit boundary, then ASSERT().
1519 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
1520 PcdMaximumUnicodeStringLength Unicode characters, not including the
1521 Null-terminator, then ASSERT().
1523 If EndPointer is not NULL and Address is translated from String, a pointer
1524 to the character that stopped the scan is stored at the location pointed to
1527 @param String Pointer to a Null-terminated Unicode string.
1528 @param EndPointer Pointer to character that stops scan.
1529 @param Address Pointer to the converted IPv6 address.
1530 @param PrefixLength Pointer to the converted IPv6 address prefix
1531 length. MAX_UINT8 is returned when /P is
1534 @retval RETURN_SUCCESS Address is translated from String.
1535 @retval RETURN_INVALID_PARAMETER If String is NULL.
1537 @retval RETURN_UNSUPPORTED If X contains more than four hexadecimal
1539 If String contains "::" and number of X
1541 If P starts with character that is not a
1542 valid decimal digit character.
1543 If the decimal number converted from P
1550 IN CONST CHAR16
*String
,
1551 OUT CHAR16
**EndPointer
, OPTIONAL
1552 OUT IPv6_ADDRESS
*Address
,
1553 OUT UINT8
*PrefixLength OPTIONAL
1557 Convert a Null-terminated Unicode string to IPv4 address and prefix length.
1559 This function outputs a value of type IPv4_ADDRESS and may output a value
1560 of type UINT8 by interpreting the contents of the Unicode string specified
1561 by String. The format of the input Unicode string String is as follows:
1565 D and P are decimal digit characters in the range [0-9]. The running zero in
1566 the beginning of D and P will be ignored. /P is optional.
1568 When /P is not in the String, the function stops at the first character that is
1569 not a valid decimal digit character after four D's are converted.
1571 When /P is in the String, the function stops at the first character that is not
1572 a valid decimal digit character after P is converted.
1574 If String is NULL, then ASSERT().
1576 If Address is NULL, then ASSERT().
1578 If String is not aligned in a 16-bit boundary, then ASSERT().
1580 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
1581 PcdMaximumUnicodeStringLength Unicode characters, not including the
1582 Null-terminator, then ASSERT().
1584 If EndPointer is not NULL and Address is translated from String, a pointer
1585 to the character that stopped the scan is stored at the location pointed to
1588 @param String Pointer to a Null-terminated Unicode string.
1589 @param EndPointer Pointer to character that stops scan.
1590 @param Address Pointer to the converted IPv4 address.
1591 @param PrefixLength Pointer to the converted IPv4 address prefix
1592 length. MAX_UINT8 is returned when /P is
1595 @retval RETURN_SUCCESS Address is translated from String.
1596 @retval RETURN_INVALID_PARAMETER If String is NULL.
1598 @retval RETURN_UNSUPPORTED If String is not in the correct format.
1599 If any decimal number converted from D
1601 If the decimal number converted from P
1608 IN CONST CHAR16
*String
,
1609 OUT CHAR16
**EndPointer
, OPTIONAL
1610 OUT IPv4_ADDRESS
*Address
,
1611 OUT UINT8
*PrefixLength OPTIONAL
1614 #define GUID_STRING_LENGTH 36
1617 Convert a Null-terminated Unicode GUID string to a value of type
1620 This function outputs a GUID value by interpreting the contents of
1621 the Unicode string specified by String. The format of the input
1622 Unicode string String consists of 36 characters, as follows:
1624 aabbccdd-eeff-gghh-iijj-kkllmmnnoopp
1626 The pairs aa - pp are two characters in the range [0-9], [a-f] and
1627 [A-F], with each pair representing a single byte hexadecimal value.
1629 The mapping between String and the EFI_GUID structure is as follows:
1647 If String is NULL, then ASSERT().
1648 If Guid is NULL, then ASSERT().
1649 If String is not aligned in a 16-bit boundary, then ASSERT().
1651 @param String Pointer to a Null-terminated Unicode string.
1652 @param Guid Pointer to the converted GUID.
1654 @retval RETURN_SUCCESS Guid is translated from String.
1655 @retval RETURN_INVALID_PARAMETER If String is NULL.
1657 @retval RETURN_UNSUPPORTED If String is not as the above format.
1663 IN CONST CHAR16
*String
,
1668 Convert a Null-terminated Unicode hexadecimal string to a byte array.
1670 This function outputs a byte array by interpreting the contents of
1671 the Unicode string specified by String in hexadecimal format. The format of
1672 the input Unicode string String is:
1676 X is a hexadecimal digit character in the range [0-9], [a-f] and [A-F].
1677 The function decodes every two hexadecimal digit characters as one byte. The
1678 decoding stops after Length of characters and outputs Buffer containing
1681 If String is not aligned in a 16-bit boundary, then ASSERT().
1683 If String is NULL, then ASSERT().
1685 If Buffer is NULL, then ASSERT().
1687 If Length is not multiple of 2, then ASSERT().
1689 If PcdMaximumUnicodeStringLength is not zero and Length is greater than
1690 PcdMaximumUnicodeStringLength, then ASSERT().
1692 If MaxBufferSize is less than (Length / 2), then ASSERT().
1694 @param String Pointer to a Null-terminated Unicode string.
1695 @param Length The number of Unicode characters to decode.
1696 @param Buffer Pointer to the converted bytes array.
1697 @param MaxBufferSize The maximum size of Buffer.
1699 @retval RETURN_SUCCESS Buffer is translated from String.
1700 @retval RETURN_INVALID_PARAMETER If String is NULL.
1702 If Length is not multiple of 2.
1703 If PcdMaximumUnicodeStringLength is not zero,
1704 and Length is greater than
1705 PcdMaximumUnicodeStringLength.
1706 @retval RETURN_UNSUPPORTED If Length of characters from String contain
1707 a character that is not valid hexadecimal
1708 digit characters, or a Null-terminator.
1709 @retval RETURN_BUFFER_TOO_SMALL If MaxBufferSize is less than (Length / 2).
1714 IN CONST CHAR16
*String
,
1717 IN UINTN MaxBufferSize
1720 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1723 [ATTENTION] This function is deprecated for security reason.
1725 Convert a Null-terminated Unicode string to a Null-terminated
1726 ASCII string and returns the ASCII string.
1728 This function converts the content of the Unicode string Source
1729 to the ASCII string Destination by copying the lower 8 bits of
1730 each Unicode character. It returns Destination.
1732 The caller is responsible to make sure Destination points to a buffer with size
1733 equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.
1735 If any Unicode characters in Source contain non-zero value in
1736 the upper 8 bits, then ASSERT().
1738 If Destination is NULL, then ASSERT().
1739 If Source is NULL, then ASSERT().
1740 If Source is not aligned on a 16-bit boundary, then ASSERT().
1741 If Source and Destination overlap, then ASSERT().
1743 If PcdMaximumUnicodeStringLength is not zero, and Source contains
1744 more than PcdMaximumUnicodeStringLength Unicode characters not including
1745 the Null-terminator, then ASSERT().
1747 If PcdMaximumAsciiStringLength is not zero, and Source contains more
1748 than PcdMaximumAsciiStringLength Unicode characters not including the
1749 Null-terminator, then ASSERT().
1751 @param Source The pointer to a Null-terminated Unicode string.
1752 @param Destination The pointer to a Null-terminated ASCII string.
1754 @return Destination.
1759 UnicodeStrToAsciiStr (
1760 IN CONST CHAR16
*Source
,
1761 OUT CHAR8
*Destination
1764 #endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES)
1767 Convert a Null-terminated Unicode string to a Null-terminated
1770 This function is similar to AsciiStrCpyS.
1772 This function converts the content of the Unicode string Source
1773 to the ASCII string Destination by copying the lower 8 bits of
1774 each Unicode character. The function terminates the ASCII string
1775 Destination by appending a Null-terminator character at the end.
1777 The caller is responsible to make sure Destination points to a buffer with size
1778 equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.
1780 If any Unicode characters in Source contain non-zero value in
1781 the upper 8 bits, then ASSERT().
1783 If Source is not aligned on a 16-bit boundary, then ASSERT().
1784 If an error would be returned, then the function will also ASSERT().
1786 If an error is returned, then the Destination is unmodified.
1788 @param Source The pointer to a Null-terminated Unicode string.
1789 @param Destination The pointer to a Null-terminated ASCII string.
1790 @param DestMax The maximum number of Destination Ascii
1791 char, including terminating null char.
1793 @retval RETURN_SUCCESS String is converted.
1794 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
1795 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
1797 If PcdMaximumAsciiStringLength is not zero,
1798 and DestMax is greater than
1799 PcdMaximumAsciiStringLength.
1800 If PcdMaximumUnicodeStringLength is not zero,
1801 and DestMax is greater than
1802 PcdMaximumUnicodeStringLength.
1804 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
1809 UnicodeStrToAsciiStrS (
1810 IN CONST CHAR16
*Source
,
1811 OUT CHAR8
*Destination
,
1816 Convert not more than Length successive characters from a Null-terminated
1817 Unicode string to a Null-terminated Ascii string. If no null char is copied
1818 from Source, then Destination[Length] is always set to null.
1820 This function converts not more than Length successive characters from the
1821 Unicode string Source to the Ascii string Destination by copying the lower 8
1822 bits of each Unicode character. The function terminates the Ascii string
1823 Destination by appending a Null-terminator character at the end.
1825 The caller is responsible to make sure Destination points to a buffer with size
1826 equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.
1828 If any Unicode characters in Source contain non-zero value in the upper 8
1829 bits, then ASSERT().
1830 If Source is not aligned on a 16-bit boundary, then ASSERT().
1831 If an error would be returned, then the function will also ASSERT().
1833 If an error is returned, then the Destination is unmodified.
1835 @param Source The pointer to a Null-terminated Unicode string.
1836 @param Length The maximum number of Unicode characters to
1838 @param Destination The pointer to a Null-terminated Ascii string.
1839 @param DestMax The maximum number of Destination Ascii
1840 char, including terminating null char.
1841 @param DestinationLength The number of Unicode characters converted.
1843 @retval RETURN_SUCCESS String is converted.
1844 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
1846 If DestinationLength is NULL.
1847 If PcdMaximumAsciiStringLength is not zero,
1848 and Length or DestMax is greater than
1849 PcdMaximumAsciiStringLength.
1850 If PcdMaximumUnicodeStringLength is not
1851 zero, and Length or DestMax is greater than
1852 PcdMaximumUnicodeStringLength.
1854 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than
1855 MIN(StrLen(Source), Length).
1856 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
1861 UnicodeStrnToAsciiStrS (
1862 IN CONST CHAR16
*Source
,
1864 OUT CHAR8
*Destination
,
1866 OUT UINTN
*DestinationLength
1869 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1872 [ATTENTION] This function is deprecated for security reason.
1874 Copies one Null-terminated ASCII string to another Null-terminated ASCII
1875 string and returns the new ASCII string.
1877 This function copies the contents of the ASCII string Source to the ASCII
1878 string Destination, and returns Destination. If Source and Destination
1879 overlap, then the results are undefined.
1881 If Destination is NULL, then ASSERT().
1882 If Source is NULL, then ASSERT().
1883 If Source and Destination overlap, then ASSERT().
1884 If PcdMaximumAsciiStringLength is not zero and Source contains more than
1885 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1888 @param Destination The pointer to a Null-terminated ASCII string.
1889 @param Source The pointer to a Null-terminated ASCII string.
1897 OUT CHAR8
*Destination
,
1898 IN CONST CHAR8
*Source
1903 [ATTENTION] This function is deprecated for security reason.
1905 Copies up to a specified length one Null-terminated ASCII string to another
1906 Null-terminated ASCII string and returns the new ASCII string.
1908 This function copies the contents of the ASCII string Source to the ASCII
1909 string Destination, and returns Destination. At most, Length ASCII characters
1910 are copied from Source to Destination. If Length is 0, then Destination is
1911 returned unmodified. If Length is greater that the number of ASCII characters
1912 in Source, then Destination is padded with Null ASCII characters. If Source
1913 and Destination overlap, then the results are undefined.
1915 If Destination is NULL, then ASSERT().
1916 If Source is NULL, then ASSERT().
1917 If Source and Destination overlap, then ASSERT().
1918 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
1919 PcdMaximumAsciiStringLength, then ASSERT().
1920 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1921 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1924 @param Destination The pointer to a Null-terminated ASCII string.
1925 @param Source The pointer to a Null-terminated ASCII string.
1926 @param Length The maximum number of ASCII characters to copy.
1934 OUT CHAR8
*Destination
,
1935 IN CONST CHAR8
*Source
,
1938 #endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES)
1941 Returns the length of a Null-terminated ASCII string.
1943 This function returns the number of ASCII characters in the Null-terminated
1944 ASCII string specified by String.
1946 If Length > 0 and Destination is NULL, then ASSERT().
1947 If Length > 0 and Source is NULL, then ASSERT().
1948 If PcdMaximumAsciiStringLength is not zero and String contains more than
1949 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1952 @param String The pointer to a Null-terminated ASCII string.
1954 @return The length of String.
1960 IN CONST CHAR8
*String
1965 Returns the size of a Null-terminated ASCII string in bytes, including the
1968 This function returns the size, in bytes, of the Null-terminated ASCII string
1969 specified by String.
1971 If String is NULL, then ASSERT().
1972 If PcdMaximumAsciiStringLength is not zero and String contains more than
1973 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1976 @param String The pointer to a Null-terminated ASCII string.
1978 @return The size of String.
1984 IN CONST CHAR8
*String
1989 Compares two Null-terminated ASCII strings, and returns the difference
1990 between the first mismatched ASCII characters.
1992 This function compares the Null-terminated ASCII string FirstString to the
1993 Null-terminated ASCII string SecondString. If FirstString is identical to
1994 SecondString, then 0 is returned. Otherwise, the value returned is the first
1995 mismatched ASCII character in SecondString subtracted from the first
1996 mismatched ASCII character in FirstString.
1998 If FirstString is NULL, then ASSERT().
1999 If SecondString is NULL, then ASSERT().
2000 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
2001 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
2003 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
2004 than PcdMaximumAsciiStringLength ASCII characters not including the
2005 Null-terminator, then ASSERT().
2007 @param FirstString The pointer to a Null-terminated ASCII string.
2008 @param SecondString The pointer to a Null-terminated ASCII string.
2010 @retval ==0 FirstString is identical to SecondString.
2011 @retval !=0 FirstString is not identical to SecondString.
2017 IN CONST CHAR8
*FirstString
,
2018 IN CONST CHAR8
*SecondString
2023 Performs a case insensitive comparison of two Null-terminated ASCII strings,
2024 and returns the difference between the first mismatched ASCII characters.
2026 This function performs a case insensitive comparison of the Null-terminated
2027 ASCII string FirstString to the Null-terminated ASCII string SecondString. If
2028 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
2029 value returned is the first mismatched lower case ASCII character in
2030 SecondString subtracted from the first mismatched lower case ASCII character
2033 If FirstString is NULL, then ASSERT().
2034 If SecondString is NULL, then ASSERT().
2035 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
2036 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
2038 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
2039 than PcdMaximumAsciiStringLength ASCII characters not including the
2040 Null-terminator, then ASSERT().
2042 @param FirstString The pointer to a Null-terminated ASCII string.
2043 @param SecondString The pointer to a Null-terminated ASCII string.
2045 @retval ==0 FirstString is identical to SecondString using case insensitive
2047 @retval !=0 FirstString is not identical to SecondString using case
2048 insensitive comparisons.
2054 IN CONST CHAR8
*FirstString
,
2055 IN CONST CHAR8
*SecondString
2060 Compares two Null-terminated ASCII strings with maximum lengths, and returns
2061 the difference between the first mismatched ASCII characters.
2063 This function compares the Null-terminated ASCII string FirstString to the
2064 Null-terminated ASCII string SecondString. At most, Length ASCII characters
2065 will be compared. If Length is 0, then 0 is returned. If FirstString is
2066 identical to SecondString, then 0 is returned. Otherwise, the value returned
2067 is the first mismatched ASCII character in SecondString subtracted from the
2068 first mismatched ASCII character in FirstString.
2070 If Length > 0 and FirstString is NULL, then ASSERT().
2071 If Length > 0 and SecondString is NULL, then ASSERT().
2072 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
2073 PcdMaximumAsciiStringLength, then ASSERT().
2074 If PcdMaximumAsciiStringLength is not zero, and FirstString contains more than
2075 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
2077 If PcdMaximumAsciiStringLength is not zero, and SecondString contains more than
2078 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
2081 @param FirstString The pointer to a Null-terminated ASCII string.
2082 @param SecondString The pointer to a Null-terminated ASCII string.
2083 @param Length The maximum number of ASCII characters for compare.
2085 @retval ==0 FirstString is identical to SecondString.
2086 @retval !=0 FirstString is not identical to SecondString.
2092 IN CONST CHAR8
*FirstString
,
2093 IN CONST CHAR8
*SecondString
,
2098 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
2101 [ATTENTION] This function is deprecated for security reason.
2103 Concatenates one Null-terminated ASCII string to another Null-terminated
2104 ASCII string, and returns the concatenated ASCII string.
2106 This function concatenates two Null-terminated ASCII strings. The contents of
2107 Null-terminated ASCII string Source are concatenated to the end of Null-
2108 terminated ASCII string Destination. The Null-terminated concatenated ASCII
2111 If Destination is NULL, then ASSERT().
2112 If Source is NULL, then ASSERT().
2113 If PcdMaximumAsciiStringLength is not zero and Destination contains more than
2114 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
2116 If PcdMaximumAsciiStringLength is not zero and Source contains more than
2117 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
2119 If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
2120 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
2121 ASCII characters, then ASSERT().
2123 @param Destination The pointer to a Null-terminated ASCII string.
2124 @param Source The pointer to a Null-terminated ASCII string.
2132 IN OUT CHAR8
*Destination
,
2133 IN CONST CHAR8
*Source
2138 [ATTENTION] This function is deprecated for security reason.
2140 Concatenates up to a specified length one Null-terminated ASCII string to
2141 the end of another Null-terminated ASCII string, and returns the
2142 concatenated ASCII string.
2144 This function concatenates two Null-terminated ASCII strings. The contents
2145 of Null-terminated ASCII string Source are concatenated to the end of Null-
2146 terminated ASCII string Destination, and Destination is returned. At most,
2147 Length ASCII characters are concatenated from Source to the end of
2148 Destination, and Destination is always Null-terminated. If Length is 0, then
2149 Destination is returned unmodified. If Source and Destination overlap, then
2150 the results are undefined.
2152 If Length > 0 and Destination is NULL, then ASSERT().
2153 If Length > 0 and Source is NULL, then ASSERT().
2154 If Source and Destination overlap, then ASSERT().
2155 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
2156 PcdMaximumAsciiStringLength, then ASSERT().
2157 If PcdMaximumAsciiStringLength is not zero, and Destination contains more than
2158 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
2160 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
2161 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
2163 If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
2164 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
2165 ASCII characters, not including the Null-terminator, then ASSERT().
2167 @param Destination The pointer to a Null-terminated ASCII string.
2168 @param Source The pointer to a Null-terminated ASCII string.
2169 @param Length The maximum number of ASCII characters to concatenate from
2178 IN OUT CHAR8
*Destination
,
2179 IN CONST CHAR8
*Source
,
2182 #endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES)
2185 Returns the first occurrence of a Null-terminated ASCII sub-string
2186 in a Null-terminated ASCII string.
2188 This function scans the contents of the ASCII string specified by String
2189 and returns the first occurrence of SearchString. If SearchString is not
2190 found in String, then NULL is returned. If the length of SearchString is zero,
2191 then String is returned.
2193 If String is NULL, then ASSERT().
2194 If SearchString is NULL, then ASSERT().
2196 If PcdMaximumAsciiStringLength is not zero, and SearchString or
2197 String contains more than PcdMaximumAsciiStringLength Unicode characters
2198 not including the Null-terminator, then ASSERT().
2200 @param String The pointer to a Null-terminated ASCII string.
2201 @param SearchString The pointer to a Null-terminated ASCII string to search for.
2203 @retval NULL If the SearchString does not appear in String.
2204 @retval others If there is a match return the first occurrence of SearchingString.
2205 If the length of SearchString is zero,return String.
2211 IN CONST CHAR8
*String
,
2212 IN CONST CHAR8
*SearchString
2217 Convert a Null-terminated ASCII decimal string to a value of type
2220 This function returns a value of type UINTN by interpreting the contents
2221 of the ASCII string String as a decimal number. The format of the input
2222 ASCII string String is:
2224 [spaces] [decimal digits].
2226 The valid decimal digit character is in the range [0-9]. The function will
2227 ignore the pad space, which includes spaces or tab characters, before the digits.
2228 The running zero in the beginning of [decimal digits] will be ignored. Then, the
2229 function stops at the first character that is a not a valid decimal character or
2230 Null-terminator, whichever on comes first.
2232 If String has only pad spaces, then 0 is returned.
2233 If String has no pad spaces or valid decimal digits, then 0 is returned.
2234 If the number represented by String overflows according to the range defined by
2235 UINTN, then MAX_UINTN is returned.
2236 If String is NULL, then ASSERT().
2237 If PcdMaximumAsciiStringLength is not zero, and String contains more than
2238 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
2241 @param String The pointer to a Null-terminated ASCII string.
2243 @retval The value translated from String.
2248 AsciiStrDecimalToUintn (
2249 IN CONST CHAR8
*String
2254 Convert a Null-terminated ASCII decimal string to a value of type
2257 This function returns a value of type UINT64 by interpreting the contents
2258 of the ASCII string String as a decimal number. The format of the input
2259 ASCII string String is:
2261 [spaces] [decimal digits].
2263 The valid decimal digit character is in the range [0-9]. The function will
2264 ignore the pad space, which includes spaces or tab characters, before the digits.
2265 The running zero in the beginning of [decimal digits] will be ignored. Then, the
2266 function stops at the first character that is a not a valid decimal character or
2267 Null-terminator, whichever on comes first.
2269 If String has only pad spaces, then 0 is returned.
2270 If String has no pad spaces or valid decimal digits, then 0 is returned.
2271 If the number represented by String overflows according to the range defined by
2272 UINT64, then MAX_UINT64 is returned.
2273 If String is NULL, then ASSERT().
2274 If PcdMaximumAsciiStringLength is not zero, and String contains more than
2275 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
2278 @param String The pointer to a Null-terminated ASCII string.
2280 @retval Value translated from String.
2285 AsciiStrDecimalToUint64 (
2286 IN CONST CHAR8
*String
2291 Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.
2293 This function returns a value of type UINTN by interpreting the contents of
2294 the ASCII string String as a hexadecimal number. The format of the input ASCII
2297 [spaces][zeros][x][hexadecimal digits].
2299 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
2300 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
2301 appears in the input string, it must be prefixed with at least one 0. The function
2302 will ignore the pad space, which includes spaces or tab characters, before [zeros],
2303 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
2304 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
2305 digit. Then, the function stops at the first character that is a not a valid
2306 hexadecimal character or Null-terminator, whichever on comes first.
2308 If String has only pad spaces, then 0 is returned.
2309 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
2312 If the number represented by String overflows according to the range defined by UINTN,
2313 then MAX_UINTN is returned.
2314 If String is NULL, then ASSERT().
2315 If PcdMaximumAsciiStringLength is not zero,
2316 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
2317 the Null-terminator, then ASSERT().
2319 @param String The pointer to a Null-terminated ASCII string.
2321 @retval Value translated from String.
2326 AsciiStrHexToUintn (
2327 IN CONST CHAR8
*String
2332 Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.
2334 This function returns a value of type UINT64 by interpreting the contents of
2335 the ASCII string String as a hexadecimal number. The format of the input ASCII
2338 [spaces][zeros][x][hexadecimal digits].
2340 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
2341 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
2342 appears in the input string, it must be prefixed with at least one 0. The function
2343 will ignore the pad space, which includes spaces or tab characters, before [zeros],
2344 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
2345 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
2346 digit. Then, the function stops at the first character that is a not a valid
2347 hexadecimal character or Null-terminator, whichever on comes first.
2349 If String has only pad spaces, then 0 is returned.
2350 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
2353 If the number represented by String overflows according to the range defined by UINT64,
2354 then MAX_UINT64 is returned.
2355 If String is NULL, then ASSERT().
2356 If PcdMaximumAsciiStringLength is not zero,
2357 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
2358 the Null-terminator, then ASSERT().
2360 @param String The pointer to a Null-terminated ASCII string.
2362 @retval Value translated from String.
2367 AsciiStrHexToUint64 (
2368 IN CONST CHAR8
*String
2372 Convert a Null-terminated ASCII string to IPv6 address and prefix length.
2374 This function outputs a value of type IPv6_ADDRESS and may output a value
2375 of type UINT8 by interpreting the contents of the ASCII string specified
2376 by String. The format of the input ASCII string String is as follows:
2380 X contains one to four hexadecimal digit characters in the range [0-9], [a-f] and
2381 [A-F]. X is converted to a value of type UINT16, whose low byte is stored in low
2382 memory address and high byte is stored in high memory address. P contains decimal
2383 digit characters in the range [0-9]. The running zero in the beginning of P will
2384 be ignored. /P is optional.
2386 When /P is not in the String, the function stops at the first character that is
2387 not a valid hexadecimal digit character after eight X's are converted.
2389 When /P is in the String, the function stops at the first character that is not
2390 a valid decimal digit character after P is converted.
2392 "::" can be used to compress one or more groups of X when X contains only 0.
2393 The "::" can only appear once in the String.
2395 If String is NULL, then ASSERT().
2397 If Address is NULL, then ASSERT().
2399 If EndPointer is not NULL and Address is translated from String, a pointer
2400 to the character that stopped the scan is stored at the location pointed to
2403 @param String Pointer to a Null-terminated ASCII string.
2404 @param EndPointer Pointer to character that stops scan.
2405 @param Address Pointer to the converted IPv6 address.
2406 @param PrefixLength Pointer to the converted IPv6 address prefix
2407 length. MAX_UINT8 is returned when /P is
2410 @retval RETURN_SUCCESS Address is translated from String.
2411 @retval RETURN_INVALID_PARAMETER If String is NULL.
2413 @retval RETURN_UNSUPPORTED If X contains more than four hexadecimal
2415 If String contains "::" and number of X
2417 If P starts with character that is not a
2418 valid decimal digit character.
2419 If the decimal number converted from P
2425 AsciiStrToIpv6Address (
2426 IN CONST CHAR8
*String
,
2427 OUT CHAR8
**EndPointer
, OPTIONAL
2428 OUT IPv6_ADDRESS
*Address
,
2429 OUT UINT8
*PrefixLength OPTIONAL
2433 Convert a Null-terminated ASCII string to IPv4 address and prefix length.
2435 This function outputs a value of type IPv4_ADDRESS and may output a value
2436 of type UINT8 by interpreting the contents of the ASCII string specified
2437 by String. The format of the input ASCII string String is as follows:
2441 D and P are decimal digit characters in the range [0-9]. The running zero in
2442 the beginning of D and P will be ignored. /P is optional.
2444 When /P is not in the String, the function stops at the first character that is
2445 not a valid decimal digit character after four D's are converted.
2447 When /P is in the String, the function stops at the first character that is not
2448 a valid decimal digit character after P is converted.
2450 If String is NULL, then ASSERT().
2452 If Address is NULL, then ASSERT().
2454 If EndPointer is not NULL and Address is translated from String, a pointer
2455 to the character that stopped the scan is stored at the location pointed to
2458 @param String Pointer to a Null-terminated ASCII string.
2459 @param EndPointer Pointer to character that stops scan.
2460 @param Address Pointer to the converted IPv4 address.
2461 @param PrefixLength Pointer to the converted IPv4 address prefix
2462 length. MAX_UINT8 is returned when /P is
2465 @retval RETURN_SUCCESS Address is translated from String.
2466 @retval RETURN_INVALID_PARAMETER If String is NULL.
2468 @retval RETURN_UNSUPPORTED If String is not in the correct format.
2469 If any decimal number converted from D
2471 If the decimal number converted from P
2477 AsciiStrToIpv4Address (
2478 IN CONST CHAR8
*String
,
2479 OUT CHAR8
**EndPointer
, OPTIONAL
2480 OUT IPv4_ADDRESS
*Address
,
2481 OUT UINT8
*PrefixLength OPTIONAL
2485 Convert a Null-terminated ASCII GUID string to a value of type
2488 This function outputs a GUID value by interpreting the contents of
2489 the ASCII string specified by String. The format of the input
2490 ASCII string String consists of 36 characters, as follows:
2492 aabbccdd-eeff-gghh-iijj-kkllmmnnoopp
2494 The pairs aa - pp are two characters in the range [0-9], [a-f] and
2495 [A-F], with each pair representing a single byte hexadecimal value.
2497 The mapping between String and the EFI_GUID structure is as follows:
2515 If String is NULL, then ASSERT().
2516 If Guid is NULL, then ASSERT().
2518 @param String Pointer to a Null-terminated ASCII string.
2519 @param Guid Pointer to the converted GUID.
2521 @retval RETURN_SUCCESS Guid is translated from String.
2522 @retval RETURN_INVALID_PARAMETER If String is NULL.
2524 @retval RETURN_UNSUPPORTED If String is not as the above format.
2530 IN CONST CHAR8
*String
,
2535 Convert a Null-terminated ASCII hexadecimal string to a byte array.
2537 This function outputs a byte array by interpreting the contents of
2538 the ASCII string specified by String in hexadecimal format. The format of
2539 the input ASCII string String is:
2543 X is a hexadecimal digit character in the range [0-9], [a-f] and [A-F].
2544 The function decodes every two hexadecimal digit characters as one byte. The
2545 decoding stops after Length of characters and outputs Buffer containing
2548 If String is NULL, then ASSERT().
2550 If Buffer is NULL, then ASSERT().
2552 If Length is not multiple of 2, then ASSERT().
2554 If PcdMaximumAsciiStringLength is not zero and Length is greater than
2555 PcdMaximumAsciiStringLength, then ASSERT().
2557 If MaxBufferSize is less than (Length / 2), then ASSERT().
2559 @param String Pointer to a Null-terminated ASCII string.
2560 @param Length The number of ASCII characters to decode.
2561 @param Buffer Pointer to the converted bytes array.
2562 @param MaxBufferSize The maximum size of Buffer.
2564 @retval RETURN_SUCCESS Buffer is translated from String.
2565 @retval RETURN_INVALID_PARAMETER If String is NULL.
2567 If Length is not multiple of 2.
2568 If PcdMaximumAsciiStringLength is not zero,
2569 and Length is greater than
2570 PcdMaximumAsciiStringLength.
2571 @retval RETURN_UNSUPPORTED If Length of characters from String contain
2572 a character that is not valid hexadecimal
2573 digit characters, or a Null-terminator.
2574 @retval RETURN_BUFFER_TOO_SMALL If MaxBufferSize is less than (Length / 2).
2578 AsciiStrHexToBytes (
2579 IN CONST CHAR8
*String
,
2582 IN UINTN MaxBufferSize
2585 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
2588 [ATTENTION] This function is deprecated for security reason.
2590 Convert one Null-terminated ASCII string to a Null-terminated
2591 Unicode string and returns the Unicode string.
2593 This function converts the contents of the ASCII string Source to the Unicode
2594 string Destination, and returns Destination. The function terminates the
2595 Unicode string Destination by appending a Null-terminator character at the end.
2596 The caller is responsible to make sure Destination points to a buffer with size
2597 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
2599 If Destination is NULL, then ASSERT().
2600 If Destination is not aligned on a 16-bit boundary, then ASSERT().
2601 If Source is NULL, then ASSERT().
2602 If Source and Destination overlap, then ASSERT().
2603 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
2604 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
2606 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
2607 PcdMaximumUnicodeStringLength ASCII characters not including the
2608 Null-terminator, then ASSERT().
2610 @param Source The pointer to a Null-terminated ASCII string.
2611 @param Destination The pointer to a Null-terminated Unicode string.
2613 @return Destination.
2618 AsciiStrToUnicodeStr (
2619 IN CONST CHAR8
*Source
,
2620 OUT CHAR16
*Destination
2623 #endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES)
2626 Convert one Null-terminated ASCII string to a Null-terminated
2629 This function is similar to StrCpyS.
2631 This function converts the contents of the ASCII string Source to the Unicode
2632 string Destination. The function terminates the Unicode string Destination by
2633 appending a Null-terminator character at the end.
2635 The caller is responsible to make sure Destination points to a buffer with size
2636 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
2638 If Destination is not aligned on a 16-bit boundary, then ASSERT().
2639 If an error would be returned, then the function will also ASSERT().
2641 If an error is returned, then the Destination is unmodified.
2643 @param Source The pointer to a Null-terminated ASCII string.
2644 @param Destination The pointer to a Null-terminated Unicode string.
2645 @param DestMax The maximum number of Destination Unicode
2646 char, including terminating null char.
2648 @retval RETURN_SUCCESS String is converted.
2649 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
2650 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
2652 If PcdMaximumUnicodeStringLength is not zero,
2653 and DestMax is greater than
2654 PcdMaximumUnicodeStringLength.
2655 If PcdMaximumAsciiStringLength is not zero,
2656 and DestMax is greater than
2657 PcdMaximumAsciiStringLength.
2659 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
2664 AsciiStrToUnicodeStrS (
2665 IN CONST CHAR8
*Source
,
2666 OUT CHAR16
*Destination
,
2671 Convert not more than Length successive characters from a Null-terminated
2672 Ascii string to a Null-terminated Unicode string. If no null char is copied
2673 from Source, then Destination[Length] is always set to null.
2675 This function converts not more than Length successive characters from the
2676 Ascii string Source to the Unicode string Destination. The function
2677 terminates the Unicode string Destination by appending a Null-terminator
2678 character at the end.
2680 The caller is responsible to make sure Destination points to a buffer with
2681 size not smaller than
2682 ((MIN(AsciiStrLen(Source), Length) + 1) * sizeof (CHAR8)) in bytes.
2684 If Destination is not aligned on a 16-bit boundary, then ASSERT().
2685 If an error would be returned, then the function will also ASSERT().
2687 If an error is returned, then Destination and DestinationLength are
2690 @param Source The pointer to a Null-terminated Ascii string.
2691 @param Length The maximum number of Ascii characters to convert.
2692 @param Destination The pointer to a Null-terminated Unicode string.
2693 @param DestMax The maximum number of Destination Unicode char,
2694 including terminating null char.
2695 @param DestinationLength The number of Ascii characters converted.
2697 @retval RETURN_SUCCESS String is converted.
2698 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
2700 If DestinationLength is NULL.
2701 If PcdMaximumUnicodeStringLength is not
2702 zero, and Length or DestMax is greater than
2703 PcdMaximumUnicodeStringLength.
2704 If PcdMaximumAsciiStringLength is not zero,
2705 and Length or DestMax is greater than
2706 PcdMaximumAsciiStringLength.
2708 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than
2709 MIN(AsciiStrLen(Source), Length).
2710 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
2715 AsciiStrnToUnicodeStrS (
2716 IN CONST CHAR8
*Source
,
2718 OUT CHAR16
*Destination
,
2720 OUT UINTN
*DestinationLength
2724 Converts an 8-bit value to an 8-bit BCD value.
2726 Converts the 8-bit value specified by Value to BCD. The BCD value is
2729 If Value >= 100, then ASSERT().
2731 @param Value The 8-bit value to convert to BCD. Range 0..99.
2733 @return The BCD value.
2744 Converts an 8-bit BCD value to an 8-bit value.
2746 Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit
2749 If Value >= 0xA0, then ASSERT().
2750 If (Value & 0x0F) >= 0x0A, then ASSERT().
2752 @param Value The 8-bit BCD value to convert to an 8-bit value.
2754 @return The 8-bit value is returned.
2764 // File Path Manipulation Functions
2768 Removes the last directory or file entry in a path.
2770 @param[in, out] Path The pointer to the path to modify.
2772 @retval FALSE Nothing was found to remove.
2773 @retval TRUE A directory or file was removed.
2782 Function to clean up paths.
2783 - Single periods in the path are removed.
2784 - Double periods in the path are removed along with a single parent directory.
2785 - Forward slashes L'/' are converted to backward slashes L'\'.
2787 This will be done inline and the existing buffer may be larger than required
2790 @param[in] Path The pointer to the string containing the path.
2792 @return Returns Path, otherwise returns NULL to indicate that an error has occurred.
2796 PathCleanUpDirectories(
2801 // Linked List Functions and Macros
2805 Initializes the head node of a doubly linked list that is declared as a
2806 global variable in a module.
2808 Initializes the forward and backward links of a new linked list. After
2809 initializing a linked list with this macro, the other linked list functions
2810 may be used to add and remove nodes from the linked list. This macro results
2811 in smaller executables by initializing the linked list in the data section,
2812 instead if calling the InitializeListHead() function to perform the
2813 equivalent operation.
2815 @param ListHead The head note of a list to initialize.
2818 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&(ListHead), &(ListHead)}
2822 Checks whether FirstEntry and SecondEntry are part of the same doubly-linked
2825 If FirstEntry is NULL, then ASSERT().
2826 If FirstEntry->ForwardLink is NULL, then ASSERT().
2827 If FirstEntry->BackLink is NULL, then ASSERT().
2828 If SecondEntry is NULL, then ASSERT();
2829 If PcdMaximumLinkedListLength is not zero, and List contains more than
2830 PcdMaximumLinkedListLength nodes, then ASSERT().
2832 @param FirstEntry A pointer to a node in a linked list.
2833 @param SecondEntry A pointer to the node to locate.
2835 @retval TRUE SecondEntry is in the same doubly-linked list as FirstEntry.
2836 @retval FALSE SecondEntry isn't in the same doubly-linked list as FirstEntry,
2837 or FirstEntry is invalid.
2843 IN CONST LIST_ENTRY
*FirstEntry
,
2844 IN CONST LIST_ENTRY
*SecondEntry
2849 Initializes the head node of a doubly linked list, and returns the pointer to
2850 the head node of the doubly linked list.
2852 Initializes the forward and backward links of a new linked list. After
2853 initializing a linked list with this function, the other linked list
2854 functions may be used to add and remove nodes from the linked list. It is up
2855 to the caller of this function to allocate the memory for ListHead.
2857 If ListHead is NULL, then ASSERT().
2859 @param ListHead A pointer to the head node of a new doubly linked list.
2866 InitializeListHead (
2867 IN OUT LIST_ENTRY
*ListHead
2872 Adds a node to the beginning of a doubly linked list, and returns the pointer
2873 to the head node of the doubly linked list.
2875 Adds the node Entry at the beginning of the doubly linked list denoted by
2876 ListHead, and returns ListHead.
2878 If ListHead is NULL, then ASSERT().
2879 If Entry is NULL, then ASSERT().
2880 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
2881 InitializeListHead(), then ASSERT().
2882 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
2883 of nodes in ListHead, including the ListHead node, is greater than or
2884 equal to PcdMaximumLinkedListLength, then ASSERT().
2886 @param ListHead A pointer to the head node of a doubly linked list.
2887 @param Entry A pointer to a node that is to be inserted at the beginning
2888 of a doubly linked list.
2896 IN OUT LIST_ENTRY
*ListHead
,
2897 IN OUT LIST_ENTRY
*Entry
2902 Adds a node to the end of a doubly linked list, and returns the pointer to
2903 the head node of the doubly linked list.
2905 Adds the node Entry to the end of the doubly linked list denoted by ListHead,
2906 and returns ListHead.
2908 If ListHead is NULL, then ASSERT().
2909 If Entry is NULL, then ASSERT().
2910 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
2911 InitializeListHead(), then ASSERT().
2912 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
2913 of nodes in ListHead, including the ListHead node, is greater than or
2914 equal to PcdMaximumLinkedListLength, then ASSERT().
2916 @param ListHead A pointer to the head node of a doubly linked list.
2917 @param Entry A pointer to a node that is to be added at the end of the
2926 IN OUT LIST_ENTRY
*ListHead
,
2927 IN OUT LIST_ENTRY
*Entry
2932 Retrieves the first node of a doubly linked list.
2934 Returns the first node of a doubly linked list. List must have been
2935 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
2936 If List is empty, then List is returned.
2938 If List is NULL, then ASSERT().
2939 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
2940 InitializeListHead(), then ASSERT().
2941 If PcdMaximumLinkedListLength is not zero, and the number of nodes
2942 in List, including the List node, is greater than or equal to
2943 PcdMaximumLinkedListLength, then ASSERT().
2945 @param List A pointer to the head node of a doubly linked list.
2947 @return The first node of a doubly linked list.
2948 @retval List The list is empty.
2954 IN CONST LIST_ENTRY
*List
2959 Retrieves the next node of a doubly linked list.
2961 Returns the node of a doubly linked list that follows Node.
2962 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
2963 or InitializeListHead(). If List is empty, then List is returned.
2965 If List is NULL, then ASSERT().
2966 If Node is NULL, then ASSERT().
2967 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
2968 InitializeListHead(), then ASSERT().
2969 If PcdMaximumLinkedListLength is not zero, and List contains more than
2970 PcdMaximumLinkedListLength nodes, then ASSERT().
2971 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
2973 @param List A pointer to the head node of a doubly linked list.
2974 @param Node A pointer to a node in the doubly linked list.
2976 @return The pointer to the next node if one exists. Otherwise List is returned.
2982 IN CONST LIST_ENTRY
*List
,
2983 IN CONST LIST_ENTRY
*Node
2988 Retrieves the previous node of a doubly linked list.
2990 Returns the node of a doubly linked list that precedes Node.
2991 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
2992 or InitializeListHead(). If List is empty, then List is returned.
2994 If List is NULL, then ASSERT().
2995 If Node is NULL, then ASSERT().
2996 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
2997 InitializeListHead(), then ASSERT().
2998 If PcdMaximumLinkedListLength is not zero, and List contains more than
2999 PcdMaximumLinkedListLength nodes, then ASSERT().
3000 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
3002 @param List A pointer to the head node of a doubly linked list.
3003 @param Node A pointer to a node in the doubly linked list.
3005 @return The pointer to the previous node if one exists. Otherwise List is returned.
3011 IN CONST LIST_ENTRY
*List
,
3012 IN CONST LIST_ENTRY
*Node
3017 Checks to see if a doubly linked list is empty or not.
3019 Checks to see if the doubly linked list is empty. If the linked list contains
3020 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
3022 If ListHead is NULL, then ASSERT().
3023 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
3024 InitializeListHead(), then ASSERT().
3025 If PcdMaximumLinkedListLength is not zero, and the number of nodes
3026 in List, including the List node, is greater than or equal to
3027 PcdMaximumLinkedListLength, then ASSERT().
3029 @param ListHead A pointer to the head node of a doubly linked list.
3031 @retval TRUE The linked list is empty.
3032 @retval FALSE The linked list is not empty.
3038 IN CONST LIST_ENTRY
*ListHead
3043 Determines if a node in a doubly linked list is the head node of a the same
3044 doubly linked list. This function is typically used to terminate a loop that
3045 traverses all the nodes in a doubly linked list starting with the head node.
3047 Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the
3048 nodes in the doubly linked list specified by List. List must have been
3049 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
3051 If List is NULL, then ASSERT().
3052 If Node is NULL, then ASSERT().
3053 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(),
3055 If PcdMaximumLinkedListLength is not zero, and the number of nodes
3056 in List, including the List node, is greater than or equal to
3057 PcdMaximumLinkedListLength, then ASSERT().
3058 If PcdVerifyNodeInList is TRUE and Node is not a node in List the and Node is not equal
3059 to List, then ASSERT().
3061 @param List A pointer to the head node of a doubly linked list.
3062 @param Node A pointer to a node in the doubly linked list.
3064 @retval TRUE Node is the head of the doubly-linked list pointed by List.
3065 @retval FALSE Node is not the head of the doubly-linked list pointed by List.
3071 IN CONST LIST_ENTRY
*List
,
3072 IN CONST LIST_ENTRY
*Node
3077 Determines if a node the last node in a doubly linked list.
3079 Returns TRUE if Node is the last node in the doubly linked list specified by
3080 List. Otherwise, FALSE is returned. List must have been initialized with
3081 INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
3083 If List is NULL, then ASSERT().
3084 If Node is NULL, then ASSERT().
3085 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
3086 InitializeListHead(), then ASSERT().
3087 If PcdMaximumLinkedListLength is not zero, and the number of nodes
3088 in List, including the List node, is greater than or equal to
3089 PcdMaximumLinkedListLength, then ASSERT().
3090 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
3092 @param List A pointer to the head node of a doubly linked list.
3093 @param Node A pointer to a node in the doubly linked list.
3095 @retval TRUE Node is the last node in the linked list.
3096 @retval FALSE Node is not the last node in the linked list.
3102 IN CONST LIST_ENTRY
*List
,
3103 IN CONST LIST_ENTRY
*Node
3108 Swaps the location of two nodes in a doubly linked list, and returns the
3109 first node after the swap.
3111 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
3112 Otherwise, the location of the FirstEntry node is swapped with the location
3113 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
3114 same double linked list as FirstEntry and that double linked list must have
3115 been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
3116 SecondEntry is returned after the nodes are swapped.
3118 If FirstEntry is NULL, then ASSERT().
3119 If SecondEntry is NULL, then ASSERT().
3120 If PcdVerifyNodeInList is TRUE and SecondEntry and FirstEntry are not in the
3121 same linked list, then ASSERT().
3122 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
3123 linked list containing the FirstEntry and SecondEntry nodes, including
3124 the FirstEntry and SecondEntry nodes, is greater than or equal to
3125 PcdMaximumLinkedListLength, then ASSERT().
3127 @param FirstEntry A pointer to a node in a linked list.
3128 @param SecondEntry A pointer to another node in the same linked list.
3130 @return SecondEntry.
3136 IN OUT LIST_ENTRY
*FirstEntry
,
3137 IN OUT LIST_ENTRY
*SecondEntry
3142 Removes a node from a doubly linked list, and returns the node that follows
3145 Removes the node Entry from a doubly linked list. It is up to the caller of
3146 this function to release the memory used by this node if that is required. On
3147 exit, the node following Entry in the doubly linked list is returned. If
3148 Entry is the only node in the linked list, then the head node of the linked
3151 If Entry is NULL, then ASSERT().
3152 If Entry is the head node of an empty list, then ASSERT().
3153 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
3154 linked list containing Entry, including the Entry node, is greater than
3155 or equal to PcdMaximumLinkedListLength, then ASSERT().
3157 @param Entry A pointer to a node in a linked list.
3165 IN CONST LIST_ENTRY
*Entry
3173 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
3174 with zeros. The shifted value is returned.
3176 This function shifts the 64-bit value Operand to the left by Count bits. The
3177 low Count bits are set to zero. The shifted value is returned.
3179 If Count is greater than 63, then ASSERT().
3181 @param Operand The 64-bit operand to shift left.
3182 @param Count The number of bits to shift left.
3184 @return Operand << Count.
3196 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
3197 filled with zeros. The shifted value is returned.
3199 This function shifts the 64-bit value Operand to the right by Count bits. The
3200 high Count bits are set to zero. The shifted value is returned.
3202 If Count is greater than 63, then ASSERT().
3204 @param Operand The 64-bit operand to shift right.
3205 @param Count The number of bits to shift right.
3207 @return Operand >> Count
3219 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
3220 with original integer's bit 63. The shifted value is returned.
3222 This function shifts the 64-bit value Operand to the right by Count bits. The
3223 high Count bits are set to bit 63 of Operand. The shifted value is returned.
3225 If Count is greater than 63, then ASSERT().
3227 @param Operand The 64-bit operand to shift right.
3228 @param Count The number of bits to shift right.
3230 @return Operand >> Count
3242 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
3243 with the high bits that were rotated.
3245 This function rotates the 32-bit value Operand to the left by Count bits. The
3246 low Count bits are fill with the high Count bits of Operand. The rotated
3249 If Count is greater than 31, then ASSERT().
3251 @param Operand The 32-bit operand to rotate left.
3252 @param Count The number of bits to rotate left.
3254 @return Operand << Count
3266 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
3267 with the low bits that were rotated.
3269 This function rotates the 32-bit value Operand to the right by Count bits.
3270 The high Count bits are fill with the low Count bits of Operand. The rotated
3273 If Count is greater than 31, then ASSERT().
3275 @param Operand The 32-bit operand to rotate right.
3276 @param Count The number of bits to rotate right.
3278 @return Operand >> Count
3290 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
3291 with the high bits that were rotated.
3293 This function rotates the 64-bit value Operand to the left by Count bits. The
3294 low Count bits are fill with the high Count bits of Operand. The rotated
3297 If Count is greater than 63, then ASSERT().
3299 @param Operand The 64-bit operand to rotate left.
3300 @param Count The number of bits to rotate left.
3302 @return Operand << Count
3314 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
3315 with the high low bits that were rotated.
3317 This function rotates the 64-bit value Operand to the right by Count bits.
3318 The high Count bits are fill with the low Count bits of Operand. The rotated
3321 If Count is greater than 63, then ASSERT().
3323 @param Operand The 64-bit operand to rotate right.
3324 @param Count The number of bits to rotate right.
3326 @return Operand >> Count
3338 Returns the bit position of the lowest bit set in a 32-bit value.
3340 This function computes the bit position of the lowest bit set in the 32-bit
3341 value specified by Operand. If Operand is zero, then -1 is returned.
3342 Otherwise, a value between 0 and 31 is returned.
3344 @param Operand The 32-bit operand to evaluate.
3346 @retval 0..31 The lowest bit set in Operand was found.
3347 @retval -1 Operand is zero.
3358 Returns the bit position of the lowest bit set in a 64-bit value.
3360 This function computes the bit position of the lowest bit set in the 64-bit
3361 value specified by Operand. If Operand is zero, then -1 is returned.
3362 Otherwise, a value between 0 and 63 is returned.
3364 @param Operand The 64-bit operand to evaluate.
3366 @retval 0..63 The lowest bit set in Operand was found.
3367 @retval -1 Operand is zero.
3379 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
3382 This function computes the bit position of the highest bit set in the 32-bit
3383 value specified by Operand. If Operand is zero, then -1 is returned.
3384 Otherwise, a value between 0 and 31 is returned.
3386 @param Operand The 32-bit operand to evaluate.
3388 @retval 0..31 Position of the highest bit set in Operand if found.
3389 @retval -1 Operand is zero.
3400 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
3403 This function computes the bit position of the highest bit set in the 64-bit
3404 value specified by Operand. If Operand is zero, then -1 is returned.
3405 Otherwise, a value between 0 and 63 is returned.
3407 @param Operand The 64-bit operand to evaluate.
3409 @retval 0..63 Position of the highest bit set in Operand if found.
3410 @retval -1 Operand is zero.
3421 Returns the value of the highest bit set in a 32-bit value. Equivalent to
3424 This function computes the value of the highest bit set in the 32-bit value
3425 specified by Operand. If Operand is zero, then zero is returned.
3427 @param Operand The 32-bit operand to evaluate.
3429 @return 1 << HighBitSet32(Operand)
3430 @retval 0 Operand is zero.
3441 Returns the value of the highest bit set in a 64-bit value. Equivalent to
3444 This function computes the value of the highest bit set in the 64-bit value
3445 specified by Operand. If Operand is zero, then zero is returned.
3447 @param Operand The 64-bit operand to evaluate.
3449 @return 1 << HighBitSet64(Operand)
3450 @retval 0 Operand is zero.
3461 Switches the endianness of a 16-bit integer.
3463 This function swaps the bytes in a 16-bit unsigned value to switch the value
3464 from little endian to big endian or vice versa. The byte swapped value is
3467 @param Value A 16-bit unsigned value.
3469 @return The byte swapped Value.
3480 Switches the endianness of a 32-bit integer.
3482 This function swaps the bytes in a 32-bit unsigned value to switch the value
3483 from little endian to big endian or vice versa. The byte swapped value is
3486 @param Value A 32-bit unsigned value.
3488 @return The byte swapped Value.
3499 Switches the endianness of a 64-bit integer.
3501 This function swaps the bytes in a 64-bit unsigned value to switch the value
3502 from little endian to big endian or vice versa. The byte swapped value is
3505 @param Value A 64-bit unsigned value.
3507 @return The byte swapped Value.
3518 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
3519 generates a 64-bit unsigned result.
3521 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
3522 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
3523 bit unsigned result is returned.
3525 @param Multiplicand A 64-bit unsigned value.
3526 @param Multiplier A 32-bit unsigned value.
3528 @return Multiplicand * Multiplier
3534 IN UINT64 Multiplicand
,
3535 IN UINT32 Multiplier
3540 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
3541 generates a 64-bit unsigned result.
3543 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
3544 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
3545 bit unsigned result is returned.
3547 @param Multiplicand A 64-bit unsigned value.
3548 @param Multiplier A 64-bit unsigned value.
3550 @return Multiplicand * Multiplier.
3556 IN UINT64 Multiplicand
,
3557 IN UINT64 Multiplier
3562 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
3563 64-bit signed result.
3565 This function multiples the 64-bit signed value Multiplicand by the 64-bit
3566 signed value Multiplier and generates a 64-bit signed result. This 64-bit
3567 signed result is returned.
3569 @param Multiplicand A 64-bit signed value.
3570 @param Multiplier A 64-bit signed value.
3572 @return Multiplicand * Multiplier
3578 IN INT64 Multiplicand
,
3584 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
3585 a 64-bit unsigned result.
3587 This function divides the 64-bit unsigned value Dividend by the 32-bit
3588 unsigned value Divisor and generates a 64-bit unsigned quotient. This
3589 function returns the 64-bit unsigned quotient.
3591 If Divisor is 0, then ASSERT().
3593 @param Dividend A 64-bit unsigned value.
3594 @param Divisor A 32-bit unsigned value.
3596 @return Dividend / Divisor.
3608 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
3609 a 32-bit unsigned remainder.
3611 This function divides the 64-bit unsigned value Dividend by the 32-bit
3612 unsigned value Divisor and generates a 32-bit remainder. This function
3613 returns the 32-bit unsigned remainder.
3615 If Divisor is 0, then ASSERT().
3617 @param Dividend A 64-bit unsigned value.
3618 @param Divisor A 32-bit unsigned value.
3620 @return Dividend % Divisor.
3632 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
3633 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
3635 This function divides the 64-bit unsigned value Dividend by the 32-bit
3636 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
3637 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
3638 This function returns the 64-bit unsigned quotient.
3640 If Divisor is 0, then ASSERT().
3642 @param Dividend A 64-bit unsigned value.
3643 @param Divisor A 32-bit unsigned value.
3644 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
3645 optional and may be NULL.
3647 @return Dividend / Divisor.
3652 DivU64x32Remainder (
3655 OUT UINT32
*Remainder OPTIONAL
3660 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
3661 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
3663 This function divides the 64-bit unsigned value Dividend by the 64-bit
3664 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
3665 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
3666 This function returns the 64-bit unsigned quotient.
3668 If Divisor is 0, then ASSERT().
3670 @param Dividend A 64-bit unsigned value.
3671 @param Divisor A 64-bit unsigned value.
3672 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
3673 optional and may be NULL.
3675 @return Dividend / Divisor.
3680 DivU64x64Remainder (
3683 OUT UINT64
*Remainder OPTIONAL
3688 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
3689 64-bit signed result and a optional 64-bit signed remainder.
3691 This function divides the 64-bit signed value Dividend by the 64-bit signed
3692 value Divisor and generates a 64-bit signed quotient. If Remainder is not
3693 NULL, then the 64-bit signed remainder is returned in Remainder. This
3694 function returns the 64-bit signed quotient.
3696 It is the caller's responsibility to not call this function with a Divisor of 0.
3697 If Divisor is 0, then the quotient and remainder should be assumed to be
3698 the largest negative integer.
3700 If Divisor is 0, then ASSERT().
3702 @param Dividend A 64-bit signed value.
3703 @param Divisor A 64-bit signed value.
3704 @param Remainder A pointer to a 64-bit signed value. This parameter is
3705 optional and may be NULL.
3707 @return Dividend / Divisor.
3712 DivS64x64Remainder (
3715 OUT INT64
*Remainder OPTIONAL
3720 Reads a 16-bit value from memory that may be unaligned.
3722 This function returns the 16-bit value pointed to by Buffer. The function
3723 guarantees that the read operation does not produce an alignment fault.
3725 If the Buffer is NULL, then ASSERT().
3727 @param Buffer The pointer to a 16-bit value that may be unaligned.
3729 @return The 16-bit value read from Buffer.
3735 IN CONST UINT16
*Buffer
3740 Writes a 16-bit value to memory that may be unaligned.
3742 This function writes the 16-bit value specified by Value to Buffer. Value is
3743 returned. The function guarantees that the write operation does not produce
3746 If the Buffer is NULL, then ASSERT().
3748 @param Buffer The pointer to a 16-bit value that may be unaligned.
3749 @param Value 16-bit value to write to Buffer.
3751 @return The 16-bit value to write to Buffer.
3763 Reads a 24-bit value from memory that may be unaligned.
3765 This function returns the 24-bit value pointed to by Buffer. The function
3766 guarantees that the read operation does not produce an alignment fault.
3768 If the Buffer is NULL, then ASSERT().
3770 @param Buffer The pointer to a 24-bit value that may be unaligned.
3772 @return The 24-bit value read from Buffer.
3778 IN CONST UINT32
*Buffer
3783 Writes a 24-bit value to memory that may be unaligned.
3785 This function writes the 24-bit value specified by Value to Buffer. Value is
3786 returned. The function guarantees that the write operation does not produce
3789 If the Buffer is NULL, then ASSERT().
3791 @param Buffer The pointer to a 24-bit value that may be unaligned.
3792 @param Value 24-bit value to write to Buffer.
3794 @return The 24-bit value to write to Buffer.
3806 Reads a 32-bit value from memory that may be unaligned.
3808 This function returns the 32-bit value pointed to by Buffer. The function
3809 guarantees that the read operation does not produce an alignment fault.
3811 If the Buffer is NULL, then ASSERT().
3813 @param Buffer The pointer to a 32-bit value that may be unaligned.
3815 @return The 32-bit value read from Buffer.
3821 IN CONST UINT32
*Buffer
3826 Writes a 32-bit value to memory that may be unaligned.
3828 This function writes the 32-bit value specified by Value to Buffer. Value is
3829 returned. The function guarantees that the write operation does not produce
3832 If the Buffer is NULL, then ASSERT().
3834 @param Buffer The pointer to a 32-bit value that may be unaligned.
3835 @param Value 32-bit value to write to Buffer.
3837 @return The 32-bit value to write to Buffer.
3849 Reads a 64-bit value from memory that may be unaligned.
3851 This function returns the 64-bit value pointed to by Buffer. The function
3852 guarantees that the read operation does not produce an alignment fault.
3854 If the Buffer is NULL, then ASSERT().
3856 @param Buffer The pointer to a 64-bit value that may be unaligned.
3858 @return The 64-bit value read from Buffer.
3864 IN CONST UINT64
*Buffer
3869 Writes a 64-bit value to memory that may be unaligned.
3871 This function writes the 64-bit value specified by Value to Buffer. Value is
3872 returned. The function guarantees that the write operation does not produce
3875 If the Buffer is NULL, then ASSERT().
3877 @param Buffer The pointer to a 64-bit value that may be unaligned.
3878 @param Value 64-bit value to write to Buffer.
3880 @return The 64-bit value to write to Buffer.
3892 // Bit Field Functions
3896 Returns a bit field from an 8-bit value.
3898 Returns the bitfield specified by the StartBit and the EndBit from Operand.
3900 If 8-bit operations are not supported, then ASSERT().
3901 If StartBit is greater than 7, then ASSERT().
3902 If EndBit is greater than 7, then ASSERT().
3903 If EndBit is less than StartBit, then ASSERT().
3905 @param Operand Operand on which to perform the bitfield operation.
3906 @param StartBit The ordinal of the least significant bit in the bit field.
3908 @param EndBit The ordinal of the most significant bit in the bit field.
3911 @return The bit field read.
3924 Writes a bit field to an 8-bit value, and returns the result.
3926 Writes Value to the bit field specified by the StartBit and the EndBit in
3927 Operand. All other bits in Operand are preserved. The new 8-bit value is
3930 If 8-bit operations are not supported, then ASSERT().
3931 If StartBit is greater than 7, then ASSERT().
3932 If EndBit is greater than 7, then ASSERT().
3933 If EndBit is less than StartBit, then ASSERT().
3934 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3936 @param Operand Operand on which to perform the bitfield operation.
3937 @param StartBit The ordinal of the least significant bit in the bit field.
3939 @param EndBit The ordinal of the most significant bit in the bit field.
3941 @param Value New value of the bit field.
3943 @return The new 8-bit value.
3957 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
3960 Performs a bitwise OR between the bit field specified by StartBit
3961 and EndBit in Operand and the value specified by OrData. All other bits in
3962 Operand are preserved. The new 8-bit value is returned.
3964 If 8-bit operations are not supported, then ASSERT().
3965 If StartBit is greater than 7, then ASSERT().
3966 If EndBit is greater than 7, then ASSERT().
3967 If EndBit is less than StartBit, then ASSERT().
3968 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3970 @param Operand Operand on which to perform the bitfield operation.
3971 @param StartBit The ordinal of the least significant bit in the bit field.
3973 @param EndBit The ordinal of the most significant bit in the bit field.
3975 @param OrData The value to OR with the read value from the value
3977 @return The new 8-bit value.
3991 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
3994 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3995 in Operand and the value specified by AndData. All other bits in Operand are
3996 preserved. The new 8-bit value is returned.
3998 If 8-bit operations are not supported, then ASSERT().
3999 If StartBit is greater than 7, then ASSERT().
4000 If EndBit is greater than 7, then ASSERT().
4001 If EndBit is less than StartBit, then ASSERT().
4002 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4004 @param Operand Operand on which to perform the bitfield operation.
4005 @param StartBit The ordinal of the least significant bit in the bit field.
4007 @param EndBit The ordinal of the most significant bit in the bit field.
4009 @param AndData The value to AND with the read value from the value.
4011 @return The new 8-bit value.
4025 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
4026 bitwise OR, and returns the result.
4028 Performs a bitwise AND between the bit field specified by StartBit and EndBit
4029 in Operand and the value specified by AndData, followed by a bitwise
4030 OR with value specified by OrData. All other bits in Operand are
4031 preserved. The new 8-bit value is returned.
4033 If 8-bit operations are not supported, then ASSERT().
4034 If StartBit is greater than 7, then ASSERT().
4035 If EndBit is greater than 7, then ASSERT().
4036 If EndBit is less than StartBit, then ASSERT().
4037 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4038 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4040 @param Operand Operand on which to perform the bitfield operation.
4041 @param StartBit The ordinal of the least significant bit in the bit field.
4043 @param EndBit The ordinal of the most significant bit in the bit field.
4045 @param AndData The value to AND with the read value from the value.
4046 @param OrData The value to OR with the result of the AND operation.
4048 @return The new 8-bit value.
4053 BitFieldAndThenOr8 (
4063 Returns a bit field from a 16-bit value.
4065 Returns the bitfield specified by the StartBit and the EndBit from Operand.
4067 If 16-bit operations are not supported, then ASSERT().
4068 If StartBit is greater than 15, then ASSERT().
4069 If EndBit is greater than 15, then ASSERT().
4070 If EndBit is less than StartBit, then ASSERT().
4072 @param Operand Operand on which to perform the bitfield operation.
4073 @param StartBit The ordinal of the least significant bit in the bit field.
4075 @param EndBit The ordinal of the most significant bit in the bit field.
4078 @return The bit field read.
4091 Writes a bit field to a 16-bit value, and returns the result.
4093 Writes Value to the bit field specified by the StartBit and the EndBit in
4094 Operand. All other bits in Operand are preserved. The new 16-bit value is
4097 If 16-bit operations are not supported, then ASSERT().
4098 If StartBit is greater than 15, then ASSERT().
4099 If EndBit is greater than 15, then ASSERT().
4100 If EndBit is less than StartBit, then ASSERT().
4101 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4103 @param Operand Operand on which to perform the bitfield operation.
4104 @param StartBit The ordinal of the least significant bit in the bit field.
4106 @param EndBit The ordinal of the most significant bit in the bit field.
4108 @param Value New value of the bit field.
4110 @return The new 16-bit value.
4124 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
4127 Performs a bitwise OR between the bit field specified by StartBit
4128 and EndBit in Operand and the value specified by OrData. All other bits in
4129 Operand are preserved. The new 16-bit value is returned.
4131 If 16-bit operations are not supported, then ASSERT().
4132 If StartBit is greater than 15, then ASSERT().
4133 If EndBit is greater than 15, then ASSERT().
4134 If EndBit is less than StartBit, then ASSERT().
4135 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4137 @param Operand Operand on which to perform the bitfield operation.
4138 @param StartBit The ordinal of the least significant bit in the bit field.
4140 @param EndBit The ordinal of the most significant bit in the bit field.
4142 @param OrData The value to OR with the read value from the value
4144 @return The new 16-bit value.
4158 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
4161 Performs a bitwise AND between the bit field specified by StartBit and EndBit
4162 in Operand and the value specified by AndData. All other bits in Operand are
4163 preserved. The new 16-bit value is returned.
4165 If 16-bit operations are not supported, then ASSERT().
4166 If StartBit is greater than 15, then ASSERT().
4167 If EndBit is greater than 15, then ASSERT().
4168 If EndBit is less than StartBit, then ASSERT().
4169 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4171 @param Operand Operand on which to perform the bitfield operation.
4172 @param StartBit The ordinal of the least significant bit in the bit field.
4174 @param EndBit The ordinal of the most significant bit in the bit field.
4176 @param AndData The value to AND with the read value from the value
4178 @return The new 16-bit value.
4192 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
4193 bitwise OR, and returns the result.
4195 Performs a bitwise AND between the bit field specified by StartBit and EndBit
4196 in Operand and the value specified by AndData, followed by a bitwise
4197 OR with value specified by OrData. All other bits in Operand are
4198 preserved. The new 16-bit value is returned.
4200 If 16-bit operations are not supported, then ASSERT().
4201 If StartBit is greater than 15, then ASSERT().
4202 If EndBit is greater than 15, then ASSERT().
4203 If EndBit is less than StartBit, then ASSERT().
4204 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4205 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4207 @param Operand Operand on which to perform the bitfield operation.
4208 @param StartBit The ordinal of the least significant bit in the bit field.
4210 @param EndBit The ordinal of the most significant bit in the bit field.
4212 @param AndData The value to AND with the read value from the value.
4213 @param OrData The value to OR with the result of the AND operation.
4215 @return The new 16-bit value.
4220 BitFieldAndThenOr16 (
4230 Returns a bit field from a 32-bit value.
4232 Returns the bitfield specified by the StartBit and the EndBit from Operand.
4234 If 32-bit operations are not supported, then ASSERT().
4235 If StartBit is greater than 31, then ASSERT().
4236 If EndBit is greater than 31, then ASSERT().
4237 If EndBit is less than StartBit, then ASSERT().
4239 @param Operand Operand on which to perform the bitfield operation.
4240 @param StartBit The ordinal of the least significant bit in the bit field.
4242 @param EndBit The ordinal of the most significant bit in the bit field.
4245 @return The bit field read.
4258 Writes a bit field to a 32-bit value, and returns the result.
4260 Writes Value to the bit field specified by the StartBit and the EndBit in
4261 Operand. All other bits in Operand are preserved. The new 32-bit value is
4264 If 32-bit operations are not supported, then ASSERT().
4265 If StartBit is greater than 31, then ASSERT().
4266 If EndBit is greater than 31, then ASSERT().
4267 If EndBit is less than StartBit, then ASSERT().
4268 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4270 @param Operand Operand on which to perform the bitfield operation.
4271 @param StartBit The ordinal of the least significant bit in the bit field.
4273 @param EndBit The ordinal of the most significant bit in the bit field.
4275 @param Value New value of the bit field.
4277 @return The new 32-bit value.
4291 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
4294 Performs a bitwise OR between the bit field specified by StartBit
4295 and EndBit in Operand and the value specified by OrData. All other bits in
4296 Operand are preserved. The new 32-bit value is returned.
4298 If 32-bit operations are not supported, then ASSERT().
4299 If StartBit is greater than 31, then ASSERT().
4300 If EndBit is greater than 31, then ASSERT().
4301 If EndBit is less than StartBit, then ASSERT().
4302 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4304 @param Operand Operand on which to perform the bitfield operation.
4305 @param StartBit The ordinal of the least significant bit in the bit field.
4307 @param EndBit The ordinal of the most significant bit in the bit field.
4309 @param OrData The value to OR with the read value from the value.
4311 @return The new 32-bit value.
4325 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
4328 Performs a bitwise AND between the bit field specified by StartBit and EndBit
4329 in Operand and the value specified by AndData. All other bits in Operand are
4330 preserved. The new 32-bit value is returned.
4332 If 32-bit operations are not supported, then ASSERT().
4333 If StartBit is greater than 31, then ASSERT().
4334 If EndBit is greater than 31, then ASSERT().
4335 If EndBit is less than StartBit, then ASSERT().
4336 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4338 @param Operand Operand on which to perform the bitfield operation.
4339 @param StartBit The ordinal of the least significant bit in the bit field.
4341 @param EndBit The ordinal of the most significant bit in the bit field.
4343 @param AndData The value to AND with the read value from the value
4345 @return The new 32-bit value.
4359 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
4360 bitwise OR, and returns the result.
4362 Performs a bitwise AND between the bit field specified by StartBit and EndBit
4363 in Operand and the value specified by AndData, followed by a bitwise
4364 OR with value specified by OrData. All other bits in Operand are
4365 preserved. The new 32-bit value is returned.
4367 If 32-bit operations are not supported, then ASSERT().
4368 If StartBit is greater than 31, then ASSERT().
4369 If EndBit is greater than 31, then ASSERT().
4370 If EndBit is less than StartBit, then ASSERT().
4371 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4372 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4374 @param Operand Operand on which to perform the bitfield operation.
4375 @param StartBit The ordinal of the least significant bit in the bit field.
4377 @param EndBit The ordinal of the most significant bit in the bit field.
4379 @param AndData The value to AND with the read value from the value.
4380 @param OrData The value to OR with the result of the AND operation.
4382 @return The new 32-bit value.
4387 BitFieldAndThenOr32 (
4397 Returns a bit field from a 64-bit value.
4399 Returns the bitfield specified by the StartBit and the EndBit from Operand.
4401 If 64-bit operations are not supported, then ASSERT().
4402 If StartBit is greater than 63, then ASSERT().
4403 If EndBit is greater than 63, then ASSERT().
4404 If EndBit is less than StartBit, then ASSERT().
4406 @param Operand Operand on which to perform the bitfield operation.
4407 @param StartBit The ordinal of the least significant bit in the bit field.
4409 @param EndBit The ordinal of the most significant bit in the bit field.
4412 @return The bit field read.
4425 Writes a bit field to a 64-bit value, and returns the result.
4427 Writes Value to the bit field specified by the StartBit and the EndBit in
4428 Operand. All other bits in Operand are preserved. The new 64-bit value is
4431 If 64-bit operations are not supported, then ASSERT().
4432 If StartBit is greater than 63, then ASSERT().
4433 If EndBit is greater than 63, then ASSERT().
4434 If EndBit is less than StartBit, then ASSERT().
4435 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4437 @param Operand Operand on which to perform the bitfield operation.
4438 @param StartBit The ordinal of the least significant bit in the bit field.
4440 @param EndBit The ordinal of the most significant bit in the bit field.
4442 @param Value New value of the bit field.
4444 @return The new 64-bit value.
4458 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
4461 Performs a bitwise OR between the bit field specified by StartBit
4462 and EndBit in Operand and the value specified by OrData. All other bits in
4463 Operand are preserved. The new 64-bit value is returned.
4465 If 64-bit operations are not supported, then ASSERT().
4466 If StartBit is greater than 63, then ASSERT().
4467 If EndBit is greater than 63, then ASSERT().
4468 If EndBit is less than StartBit, then ASSERT().
4469 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4471 @param Operand Operand on which to perform the bitfield operation.
4472 @param StartBit The ordinal of the least significant bit in the bit field.
4474 @param EndBit The ordinal of the most significant bit in the bit field.
4476 @param OrData The value to OR with the read value from the value
4478 @return The new 64-bit value.
4492 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
4495 Performs a bitwise AND between the bit field specified by StartBit and EndBit
4496 in Operand and the value specified by AndData. All other bits in Operand are
4497 preserved. The new 64-bit value is returned.
4499 If 64-bit operations are not supported, then ASSERT().
4500 If StartBit is greater than 63, then ASSERT().
4501 If EndBit is greater than 63, then ASSERT().
4502 If EndBit is less than StartBit, then ASSERT().
4503 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4505 @param Operand Operand on which to perform the bitfield operation.
4506 @param StartBit The ordinal of the least significant bit in the bit field.
4508 @param EndBit The ordinal of the most significant bit in the bit field.
4510 @param AndData The value to AND with the read value from the value
4512 @return The new 64-bit value.
4526 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
4527 bitwise OR, and returns the result.
4529 Performs a bitwise AND between the bit field specified by StartBit and EndBit
4530 in Operand and the value specified by AndData, followed by a bitwise
4531 OR with value specified by OrData. All other bits in Operand are
4532 preserved. The new 64-bit value is returned.
4534 If 64-bit operations are not supported, then ASSERT().
4535 If StartBit is greater than 63, then ASSERT().
4536 If EndBit is greater than 63, then ASSERT().
4537 If EndBit is less than StartBit, then ASSERT().
4538 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4539 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4541 @param Operand Operand on which to perform the bitfield operation.
4542 @param StartBit The ordinal of the least significant bit in the bit field.
4544 @param EndBit The ordinal of the most significant bit in the bit field.
4546 @param AndData The value to AND with the read value from the value.
4547 @param OrData The value to OR with the result of the AND operation.
4549 @return The new 64-bit value.
4554 BitFieldAndThenOr64 (
4563 Reads a bit field from a 32-bit value, counts and returns
4564 the number of set bits.
4566 Counts the number of set bits in the bit field specified by
4567 StartBit and EndBit in Operand. The count is returned.
4569 If StartBit is greater than 31, then ASSERT().
4570 If EndBit is greater than 31, then ASSERT().
4571 If EndBit is less than StartBit, then ASSERT().
4573 @param Operand Operand on which to perform the bitfield operation.
4574 @param StartBit The ordinal of the least significant bit in the bit field.
4576 @param EndBit The ordinal of the most significant bit in the bit field.
4579 @return The number of bits set between StartBit and EndBit.
4584 BitFieldCountOnes32 (
4591 Reads a bit field from a 64-bit value, counts and returns
4592 the number of set bits.
4594 Counts the number of set bits in the bit field specified by
4595 StartBit and EndBit in Operand. The count is returned.
4597 If StartBit is greater than 63, then ASSERT().
4598 If EndBit is greater than 63, then ASSERT().
4599 If EndBit is less than StartBit, then ASSERT().
4601 @param Operand Operand on which to perform the bitfield operation.
4602 @param StartBit The ordinal of the least significant bit in the bit field.
4604 @param EndBit The ordinal of the most significant bit in the bit field.
4607 @return The number of bits set between StartBit and EndBit.
4612 BitFieldCountOnes64 (
4619 // Base Library Checksum Functions
4623 Returns the sum of all elements in a buffer in unit of UINT8.
4624 During calculation, the carry bits are dropped.
4626 This function calculates the sum of all elements in a buffer
4627 in unit of UINT8. The carry bits in result of addition are dropped.
4628 The result is returned as UINT8. If Length is Zero, then Zero is
4631 If Buffer is NULL, then ASSERT().
4632 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4634 @param Buffer The pointer to the buffer to carry out the sum operation.
4635 @param Length The size, in bytes, of Buffer.
4637 @return Sum The sum of Buffer with carry bits dropped during additions.
4643 IN CONST UINT8
*Buffer
,
4649 Returns the two's complement checksum of all elements in a buffer
4652 This function first calculates the sum of the 8-bit values in the
4653 buffer specified by Buffer and Length. The carry bits in the result
4654 of addition are dropped. Then, the two's complement of the sum is
4655 returned. If Length is 0, then 0 is returned.
4657 If Buffer is NULL, then ASSERT().
4658 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4660 @param Buffer The pointer to the buffer to carry out the checksum operation.
4661 @param Length The size, in bytes, of Buffer.
4663 @return Checksum The two's complement checksum of Buffer.
4668 CalculateCheckSum8 (
4669 IN CONST UINT8
*Buffer
,
4675 Returns the sum of all elements in a buffer of 16-bit values. During
4676 calculation, the carry bits are dropped.
4678 This function calculates the sum of the 16-bit values in the buffer
4679 specified by Buffer and Length. The carry bits in result of addition are dropped.
4680 The 16-bit result is returned. If Length is 0, then 0 is returned.
4682 If Buffer is NULL, then ASSERT().
4683 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
4684 If Length is not aligned on a 16-bit boundary, then ASSERT().
4685 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4687 @param Buffer The pointer to the buffer to carry out the sum operation.
4688 @param Length The size, in bytes, of Buffer.
4690 @return Sum The sum of Buffer with carry bits dropped during additions.
4696 IN CONST UINT16
*Buffer
,
4702 Returns the two's complement checksum of all elements in a buffer of
4705 This function first calculates the sum of the 16-bit values in the buffer
4706 specified by Buffer and Length. The carry bits in the result of addition
4707 are dropped. Then, the two's complement of the sum is returned. If Length
4708 is 0, then 0 is returned.
4710 If Buffer is NULL, then ASSERT().
4711 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
4712 If Length is not aligned on a 16-bit boundary, then ASSERT().
4713 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4715 @param Buffer The pointer to the buffer to carry out the checksum operation.
4716 @param Length The size, in bytes, of Buffer.
4718 @return Checksum The two's complement checksum of Buffer.
4723 CalculateCheckSum16 (
4724 IN CONST UINT16
*Buffer
,
4730 Returns the sum of all elements in a buffer of 32-bit values. During
4731 calculation, the carry bits are dropped.
4733 This function calculates the sum of the 32-bit values in the buffer
4734 specified by Buffer and Length. The carry bits in result of addition are dropped.
4735 The 32-bit result is returned. If Length is 0, then 0 is returned.
4737 If Buffer is NULL, then ASSERT().
4738 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
4739 If Length is not aligned on a 32-bit boundary, then ASSERT().
4740 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4742 @param Buffer The pointer to the buffer to carry out the sum operation.
4743 @param Length The size, in bytes, of Buffer.
4745 @return Sum The sum of Buffer with carry bits dropped during additions.
4751 IN CONST UINT32
*Buffer
,
4757 Returns the two's complement checksum of all elements in a buffer of
4760 This function first calculates the sum of the 32-bit values in the buffer
4761 specified by Buffer and Length. The carry bits in the result of addition
4762 are dropped. Then, the two's complement of the sum is returned. If Length
4763 is 0, then 0 is returned.
4765 If Buffer is NULL, then ASSERT().
4766 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
4767 If Length is not aligned on a 32-bit boundary, then ASSERT().
4768 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4770 @param Buffer The pointer to the buffer to carry out the checksum operation.
4771 @param Length The size, in bytes, of Buffer.
4773 @return Checksum The two's complement checksum of Buffer.
4778 CalculateCheckSum32 (
4779 IN CONST UINT32
*Buffer
,
4785 Returns the sum of all elements in a buffer of 64-bit values. During
4786 calculation, the carry bits are dropped.
4788 This function calculates the sum of the 64-bit values in the buffer
4789 specified by Buffer and Length. The carry bits in result of addition are dropped.
4790 The 64-bit result is returned. If Length is 0, then 0 is returned.
4792 If Buffer is NULL, then ASSERT().
4793 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
4794 If Length is not aligned on a 64-bit boundary, then ASSERT().
4795 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4797 @param Buffer The pointer to the buffer to carry out the sum operation.
4798 @param Length The size, in bytes, of Buffer.
4800 @return Sum The sum of Buffer with carry bits dropped during additions.
4806 IN CONST UINT64
*Buffer
,
4812 Returns the two's complement checksum of all elements in a buffer of
4815 This function first calculates the sum of the 64-bit values in the buffer
4816 specified by Buffer and Length. The carry bits in the result of addition
4817 are dropped. Then, the two's complement of the sum is returned. If Length
4818 is 0, then 0 is returned.
4820 If Buffer is NULL, then ASSERT().
4821 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
4822 If Length is not aligned on a 64-bit boundary, then ASSERT().
4823 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4825 @param Buffer The pointer to the buffer to carry out the checksum operation.
4826 @param Length The size, in bytes, of Buffer.
4828 @return Checksum The two's complement checksum of Buffer.
4833 CalculateCheckSum64 (
4834 IN CONST UINT64
*Buffer
,
4839 Computes and returns a 32-bit CRC for a data buffer.
4840 CRC32 value bases on ITU-T V.42.
4842 If Buffer is NULL, then ASSERT().
4843 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4845 @param[in] Buffer A pointer to the buffer on which the 32-bit CRC is to be computed.
4846 @param[in] Length The number of bytes in the buffer Data.
4848 @retval Crc32 The 32-bit CRC was computed for the data buffer.
4859 // Base Library CPU Functions
4863 Function entry point used when a stack switch is requested with SwitchStack()
4865 @param Context1 Context1 parameter passed into SwitchStack().
4866 @param Context2 Context2 parameter passed into SwitchStack().
4871 (EFIAPI
*SWITCH_STACK_ENTRY_POINT
)(
4872 IN VOID
*Context1
, OPTIONAL
4873 IN VOID
*Context2 OPTIONAL
4878 Used to serialize load and store operations.
4880 All loads and stores that proceed calls to this function are guaranteed to be
4881 globally visible when this function returns.
4892 Saves the current CPU context that can be restored with a call to LongJump()
4895 Saves the current CPU context in the buffer specified by JumpBuffer and
4896 returns 0. The initial call to SetJump() must always return 0. Subsequent
4897 calls to LongJump() cause a non-zero value to be returned by SetJump().
4899 If JumpBuffer is NULL, then ASSERT().
4900 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
4902 NOTE: The structure BASE_LIBRARY_JUMP_BUFFER is CPU architecture specific.
4903 The same structure must never be used for more than one CPU architecture context.
4904 For example, a BASE_LIBRARY_JUMP_BUFFER allocated by an IA-32 module must never be used from an x64 module.
4905 SetJump()/LongJump() is not currently supported for the EBC processor type.
4907 @param JumpBuffer A pointer to CPU context buffer.
4909 @retval 0 Indicates a return from SetJump().
4916 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
4921 Restores the CPU context that was saved with SetJump().
4923 Restores the CPU context from the buffer specified by JumpBuffer. This
4924 function never returns to the caller. Instead is resumes execution based on
4925 the state of JumpBuffer.
4927 If JumpBuffer is NULL, then ASSERT().
4928 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
4929 If Value is 0, then ASSERT().
4931 @param JumpBuffer A pointer to CPU context buffer.
4932 @param Value The value to return when the SetJump() context is
4933 restored and must be non-zero.
4939 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
4945 Enables CPU interrupts.
4956 Disables CPU interrupts.
4967 Disables CPU interrupts and returns the interrupt state prior to the disable
4970 @retval TRUE CPU interrupts were enabled on entry to this call.
4971 @retval FALSE CPU interrupts were disabled on entry to this call.
4976 SaveAndDisableInterrupts (
4982 Enables CPU interrupts for the smallest window required to capture any
4988 EnableDisableInterrupts (
4994 Retrieves the current CPU interrupt state.
4996 Returns TRUE if interrupts are currently enabled. Otherwise
4999 @retval TRUE CPU interrupts are enabled.
5000 @retval FALSE CPU interrupts are disabled.
5011 Set the current CPU interrupt state.
5013 Sets the current CPU interrupt state to the state specified by
5014 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
5015 InterruptState is FALSE, then interrupts are disabled. InterruptState is
5018 @param InterruptState TRUE if interrupts should enabled. FALSE if
5019 interrupts should be disabled.
5021 @return InterruptState
5027 IN BOOLEAN InterruptState
5032 Requests CPU to pause for a short period of time.
5034 Requests CPU to pause for a short period of time. Typically used in MP
5035 systems to prevent memory starvation while waiting for a spin lock.
5046 Transfers control to a function starting with a new stack.
5048 Transfers control to the function specified by EntryPoint using the
5049 new stack specified by NewStack and passing in the parameters specified
5050 by Context1 and Context2. Context1 and Context2 are optional and may
5051 be NULL. The function EntryPoint must never return. This function
5052 supports a variable number of arguments following the NewStack parameter.
5053 These additional arguments are ignored on IA-32, x64, and EBC architectures.
5054 Itanium processors expect one additional parameter of type VOID * that specifies
5055 the new backing store pointer.
5057 If EntryPoint is NULL, then ASSERT().
5058 If NewStack is NULL, then ASSERT().
5060 @param EntryPoint A pointer to function to call with the new stack.
5061 @param Context1 A pointer to the context to pass into the EntryPoint
5063 @param Context2 A pointer to the context to pass into the EntryPoint
5065 @param NewStack A pointer to the new stack to use for the EntryPoint
5067 @param ... This variable argument list is ignored for IA-32, x64, and
5068 EBC architectures. For Itanium processors, this variable
5069 argument list is expected to contain a single parameter of
5070 type VOID * that specifies the new backing store pointer.
5077 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
5078 IN VOID
*Context1
, OPTIONAL
5079 IN VOID
*Context2
, OPTIONAL
5086 Generates a breakpoint on the CPU.
5088 Generates a breakpoint on the CPU. The breakpoint must be implemented such
5089 that code can resume normal execution after the breakpoint.
5100 Executes an infinite loop.
5102 Forces the CPU to execute an infinite loop. A debugger may be used to skip
5103 past the loop and the code that follows the loop must execute properly. This
5104 implies that the infinite loop must not cause the code that follow it to be
5114 #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
5116 /// IA32 and x64 Specific Functions.
5117 /// Byte packed structure for 16-bit Real Mode EFLAGS.
5121 UINT32 CF
:1; ///< Carry Flag.
5122 UINT32 Reserved_0
:1; ///< Reserved.
5123 UINT32 PF
:1; ///< Parity Flag.
5124 UINT32 Reserved_1
:1; ///< Reserved.
5125 UINT32 AF
:1; ///< Auxiliary Carry Flag.
5126 UINT32 Reserved_2
:1; ///< Reserved.
5127 UINT32 ZF
:1; ///< Zero Flag.
5128 UINT32 SF
:1; ///< Sign Flag.
5129 UINT32 TF
:1; ///< Trap Flag.
5130 UINT32 IF
:1; ///< Interrupt Enable Flag.
5131 UINT32 DF
:1; ///< Direction Flag.
5132 UINT32 OF
:1; ///< Overflow Flag.
5133 UINT32 IOPL
:2; ///< I/O Privilege Level.
5134 UINT32 NT
:1; ///< Nested Task.
5135 UINT32 Reserved_3
:1; ///< Reserved.
5141 /// Byte packed structure for EFLAGS/RFLAGS.
5142 /// 32-bits on IA-32.
5143 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5147 UINT32 CF
:1; ///< Carry Flag.
5148 UINT32 Reserved_0
:1; ///< Reserved.
5149 UINT32 PF
:1; ///< Parity Flag.
5150 UINT32 Reserved_1
:1; ///< Reserved.
5151 UINT32 AF
:1; ///< Auxiliary Carry Flag.
5152 UINT32 Reserved_2
:1; ///< Reserved.
5153 UINT32 ZF
:1; ///< Zero Flag.
5154 UINT32 SF
:1; ///< Sign Flag.
5155 UINT32 TF
:1; ///< Trap Flag.
5156 UINT32 IF
:1; ///< Interrupt Enable Flag.
5157 UINT32 DF
:1; ///< Direction Flag.
5158 UINT32 OF
:1; ///< Overflow Flag.
5159 UINT32 IOPL
:2; ///< I/O Privilege Level.
5160 UINT32 NT
:1; ///< Nested Task.
5161 UINT32 Reserved_3
:1; ///< Reserved.
5162 UINT32 RF
:1; ///< Resume Flag.
5163 UINT32 VM
:1; ///< Virtual 8086 Mode.
5164 UINT32 AC
:1; ///< Alignment Check.
5165 UINT32 VIF
:1; ///< Virtual Interrupt Flag.
5166 UINT32 VIP
:1; ///< Virtual Interrupt Pending.
5167 UINT32 ID
:1; ///< ID Flag.
5168 UINT32 Reserved_4
:10; ///< Reserved.
5174 /// Byte packed structure for Control Register 0 (CR0).
5175 /// 32-bits on IA-32.
5176 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5180 UINT32 PE
:1; ///< Protection Enable.
5181 UINT32 MP
:1; ///< Monitor Coprocessor.
5182 UINT32 EM
:1; ///< Emulation.
5183 UINT32 TS
:1; ///< Task Switched.
5184 UINT32 ET
:1; ///< Extension Type.
5185 UINT32 NE
:1; ///< Numeric Error.
5186 UINT32 Reserved_0
:10; ///< Reserved.
5187 UINT32 WP
:1; ///< Write Protect.
5188 UINT32 Reserved_1
:1; ///< Reserved.
5189 UINT32 AM
:1; ///< Alignment Mask.
5190 UINT32 Reserved_2
:10; ///< Reserved.
5191 UINT32 NW
:1; ///< Mot Write-through.
5192 UINT32 CD
:1; ///< Cache Disable.
5193 UINT32 PG
:1; ///< Paging.
5199 /// Byte packed structure for Control Register 4 (CR4).
5200 /// 32-bits on IA-32.
5201 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5205 UINT32 VME
:1; ///< Virtual-8086 Mode Extensions.
5206 UINT32 PVI
:1; ///< Protected-Mode Virtual Interrupts.
5207 UINT32 TSD
:1; ///< Time Stamp Disable.
5208 UINT32 DE
:1; ///< Debugging Extensions.
5209 UINT32 PSE
:1; ///< Page Size Extensions.
5210 UINT32 PAE
:1; ///< Physical Address Extension.
5211 UINT32 MCE
:1; ///< Machine Check Enable.
5212 UINT32 PGE
:1; ///< Page Global Enable.
5213 UINT32 PCE
:1; ///< Performance Monitoring Counter
5215 UINT32 OSFXSR
:1; ///< Operating System Support for
5216 ///< FXSAVE and FXRSTOR instructions
5217 UINT32 OSXMMEXCPT
:1; ///< Operating System Support for
5218 ///< Unmasked SIMD Floating Point
5220 UINT32 Reserved_0
:2; ///< Reserved.
5221 UINT32 VMXE
:1; ///< VMX Enable
5222 UINT32 Reserved_1
:18; ///< Reserved.
5228 /// Byte packed structure for a segment descriptor in a GDT/LDT.
5247 } IA32_SEGMENT_DESCRIPTOR
;
5250 /// Byte packed structure for an IDTR, GDTR, LDTR descriptor.
5259 #define IA32_IDT_GATE_TYPE_TASK 0x85
5260 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
5261 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
5262 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
5263 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
5265 #define IA32_GDT_TYPE_TSS 0x9
5266 #define IA32_GDT_ALIGNMENT 8
5268 #if defined (MDE_CPU_IA32)
5270 /// Byte packed structure for an IA-32 Interrupt Gate Descriptor.
5274 UINT32 OffsetLow
:16; ///< Offset bits 15..0.
5275 UINT32 Selector
:16; ///< Selector.
5276 UINT32 Reserved_0
:8; ///< Reserved.
5277 UINT32 GateType
:8; ///< Gate Type. See #defines above.
5278 UINT32 OffsetHigh
:16; ///< Offset bits 31..16.
5281 } IA32_IDT_GATE_DESCRIPTOR
;
5285 // IA32 Task-State Segment Definition
5288 UINT16 PreviousTaskLink
;
5322 UINT16 LDTSegmentSelector
;
5325 UINT16 IOMapBaseAddress
;
5326 } IA32_TASK_STATE_SEGMENT
;
5330 UINT32 LimitLow
:16; ///< Segment Limit 15..00
5331 UINT32 BaseLow
:16; ///< Base Address 15..00
5332 UINT32 BaseMid
:8; ///< Base Address 23..16
5333 UINT32 Type
:4; ///< Type (1 0 B 1)
5334 UINT32 Reserved_43
:1; ///< 0
5335 UINT32 DPL
:2; ///< Descriptor Privilege Level
5336 UINT32 P
:1; ///< Segment Present
5337 UINT32 LimitHigh
:4; ///< Segment Limit 19..16
5338 UINT32 AVL
:1; ///< Available for use by system software
5339 UINT32 Reserved_52
:2; ///< 0 0
5340 UINT32 G
:1; ///< Granularity
5341 UINT32 BaseHigh
:8; ///< Base Address 31..24
5344 } IA32_TSS_DESCRIPTOR
;
5347 #endif // defined (MDE_CPU_IA32)
5349 #if defined (MDE_CPU_X64)
5351 /// Byte packed structure for an x64 Interrupt Gate Descriptor.
5355 UINT32 OffsetLow
:16; ///< Offset bits 15..0.
5356 UINT32 Selector
:16; ///< Selector.
5357 UINT32 Reserved_0
:8; ///< Reserved.
5358 UINT32 GateType
:8; ///< Gate Type. See #defines above.
5359 UINT32 OffsetHigh
:16; ///< Offset bits 31..16.
5360 UINT32 OffsetUpper
:32; ///< Offset bits 63..32.
5361 UINT32 Reserved_1
:32; ///< Reserved.
5367 } IA32_IDT_GATE_DESCRIPTOR
;
5371 // IA32 Task-State Segment Definition
5381 UINT16 Reserved_100
;
5382 UINT16 IOMapBaseAddress
;
5383 } IA32_TASK_STATE_SEGMENT
;
5387 UINT32 LimitLow
:16; ///< Segment Limit 15..00
5388 UINT32 BaseLow
:16; ///< Base Address 15..00
5389 UINT32 BaseMidl
:8; ///< Base Address 23..16
5390 UINT32 Type
:4; ///< Type (1 0 B 1)
5391 UINT32 Reserved_43
:1; ///< 0
5392 UINT32 DPL
:2; ///< Descriptor Privilege Level
5393 UINT32 P
:1; ///< Segment Present
5394 UINT32 LimitHigh
:4; ///< Segment Limit 19..16
5395 UINT32 AVL
:1; ///< Available for use by system software
5396 UINT32 Reserved_52
:2; ///< 0 0
5397 UINT32 G
:1; ///< Granularity
5398 UINT32 BaseMidh
:8; ///< Base Address 31..24
5399 UINT32 BaseHigh
:32; ///< Base Address 63..32
5400 UINT32 Reserved_96
:32; ///< Reserved
5406 } IA32_TSS_DESCRIPTOR
;
5409 #endif // defined (MDE_CPU_X64)
5412 /// Byte packed structure for an FP/SSE/SSE2 context.
5419 /// Structures for the 16-bit real mode thunks.
5472 IA32_EFLAGS32 EFLAGS
;
5482 } IA32_REGISTER_SET
;
5485 /// Byte packed structure for an 16-bit real mode thunks.
5488 IA32_REGISTER_SET
*RealModeState
;
5489 VOID
*RealModeBuffer
;
5490 UINT32 RealModeBufferSize
;
5491 UINT32 ThunkAttributes
;
5494 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
5495 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
5496 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
5499 /// Type definition for representing labels in NASM source code that allow for
5500 /// the patching of immediate operands of IA32 and X64 instructions.
5502 /// While the type is technically defined as a function type (note: not a
5503 /// pointer-to-function type), such labels in NASM source code never stand for
5504 /// actual functions, and identifiers declared with this function type should
5505 /// never be called. This is also why the EFIAPI calling convention specifier
5506 /// is missing from the typedef, and why the typedef does not follow the usual
5507 /// edk2 coding style for function (or pointer-to-function) typedefs. The VOID
5508 /// return type and the VOID argument list are merely artifacts.
5510 typedef VOID (X86_ASSEMBLY_PATCH_LABEL
) (VOID
);
5513 Retrieves CPUID information.
5515 Executes the CPUID instruction with EAX set to the value specified by Index.
5516 This function always returns Index.
5517 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5518 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5519 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5520 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5521 This function is only available on IA-32 and x64.
5523 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
5525 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
5526 instruction. This is an optional parameter that may be NULL.
5527 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
5528 instruction. This is an optional parameter that may be NULL.
5529 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
5530 instruction. This is an optional parameter that may be NULL.
5531 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
5532 instruction. This is an optional parameter that may be NULL.
5541 OUT UINT32
*Eax
, OPTIONAL
5542 OUT UINT32
*Ebx
, OPTIONAL
5543 OUT UINT32
*Ecx
, OPTIONAL
5544 OUT UINT32
*Edx OPTIONAL
5549 Retrieves CPUID information using an extended leaf identifier.
5551 Executes the CPUID instruction with EAX set to the value specified by Index
5552 and ECX set to the value specified by SubIndex. This function always returns
5553 Index. This function is only available on IA-32 and x64.
5555 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5556 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5557 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5558 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5560 @param Index The 32-bit value to load into EAX prior to invoking the
5562 @param SubIndex The 32-bit value to load into ECX prior to invoking the
5564 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
5565 instruction. This is an optional parameter that may be
5567 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
5568 instruction. This is an optional parameter that may be
5570 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
5571 instruction. This is an optional parameter that may be
5573 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
5574 instruction. This is an optional parameter that may be
5585 OUT UINT32
*Eax
, OPTIONAL
5586 OUT UINT32
*Ebx
, OPTIONAL
5587 OUT UINT32
*Ecx
, OPTIONAL
5588 OUT UINT32
*Edx OPTIONAL
5593 Set CD bit and clear NW bit of CR0 followed by a WBINVD.
5595 Disables the caches by setting the CD bit of CR0 to 1, clearing the NW bit of CR0 to 0,
5596 and executing a WBINVD instruction. This function is only available on IA-32 and x64.
5607 Perform a WBINVD and clear both the CD and NW bits of CR0.
5609 Enables the caches by executing a WBINVD instruction and then clear both the CD and NW
5610 bits of CR0 to 0. This function is only available on IA-32 and x64.
5621 Returns the lower 32-bits of a Machine Specific Register(MSR).
5623 Reads and returns the lower 32-bits of the MSR specified by Index.
5624 No parameter checking is performed on Index, and some Index values may cause
5625 CPU exceptions. The caller must either guarantee that Index is valid, or the
5626 caller must set up exception handlers to catch the exceptions. This function
5627 is only available on IA-32 and x64.
5629 @param Index The 32-bit MSR index to read.
5631 @return The lower 32 bits of the MSR identified by Index.
5642 Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.
5643 The upper 32-bits of the MSR are set to zero.
5645 Writes the 32-bit value specified by Value to the MSR specified by Index. The
5646 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
5647 the MSR is returned. No parameter checking is performed on Index or Value,
5648 and some of these may cause CPU exceptions. The caller must either guarantee
5649 that Index and Value are valid, or the caller must establish proper exception
5650 handlers. This function is only available on IA-32 and x64.
5652 @param Index The 32-bit MSR index to write.
5653 @param Value The 32-bit value to write to the MSR.
5667 Reads a 64-bit MSR, performs a bitwise OR on the lower 32-bits, and
5668 writes the result back to the 64-bit MSR.
5670 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5671 between the lower 32-bits of the read result and the value specified by
5672 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
5673 32-bits of the value written to the MSR is returned. No parameter checking is
5674 performed on Index or OrData, and some of these may cause CPU exceptions. The
5675 caller must either guarantee that Index and OrData are valid, or the caller
5676 must establish proper exception handlers. This function is only available on
5679 @param Index The 32-bit MSR index to write.
5680 @param OrData The value to OR with the read value from the MSR.
5682 @return The lower 32-bit value written to the MSR.
5694 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
5695 the result back to the 64-bit MSR.
5697 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5698 lower 32-bits of the read result and the value specified by AndData, and
5699 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
5700 the value written to the MSR is returned. No parameter checking is performed
5701 on Index or AndData, and some of these may cause CPU exceptions. The caller
5702 must either guarantee that Index and AndData are valid, or the caller must
5703 establish proper exception handlers. This function is only available on IA-32
5706 @param Index The 32-bit MSR index to write.
5707 @param AndData The value to AND with the read value from the MSR.
5709 @return The lower 32-bit value written to the MSR.
5721 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise OR
5722 on the lower 32-bits, and writes the result back to the 64-bit MSR.
5724 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5725 lower 32-bits of the read result and the value specified by AndData
5726 preserving the upper 32-bits, performs a bitwise OR between the
5727 result of the AND operation and the value specified by OrData, and writes the
5728 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
5729 written to the MSR is returned. No parameter checking is performed on Index,
5730 AndData, or OrData, and some of these may cause CPU exceptions. The caller
5731 must either guarantee that Index, AndData, and OrData are valid, or the
5732 caller must establish proper exception handlers. This function is only
5733 available on IA-32 and x64.
5735 @param Index The 32-bit MSR index to write.
5736 @param AndData The value to AND with the read value from the MSR.
5737 @param OrData The value to OR with the result of the AND operation.
5739 @return The lower 32-bit value written to the MSR.
5752 Reads a bit field of an MSR.
5754 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
5755 specified by the StartBit and the EndBit. The value of the bit field is
5756 returned. The caller must either guarantee that Index is valid, or the caller
5757 must set up exception handlers to catch the exceptions. This function is only
5758 available on IA-32 and x64.
5760 If StartBit is greater than 31, then ASSERT().
5761 If EndBit is greater than 31, then ASSERT().
5762 If EndBit is less than StartBit, then ASSERT().
5764 @param Index The 32-bit MSR index to read.
5765 @param StartBit The ordinal of the least significant bit in the bit field.
5767 @param EndBit The ordinal of the most significant bit in the bit field.
5770 @return The bit field read from the MSR.
5775 AsmMsrBitFieldRead32 (
5783 Writes a bit field to an MSR.
5785 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
5786 field is specified by the StartBit and the EndBit. All other bits in the
5787 destination MSR are preserved. The lower 32-bits of the MSR written is
5788 returned. The caller must either guarantee that Index and the data written
5789 is valid, or the caller must set up exception handlers to catch the exceptions.
5790 This function is only available on IA-32 and x64.
5792 If StartBit is greater than 31, then ASSERT().
5793 If EndBit is greater than 31, then ASSERT().
5794 If EndBit is less than StartBit, then ASSERT().
5795 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5797 @param Index The 32-bit MSR index to write.
5798 @param StartBit The ordinal of the least significant bit in the bit field.
5800 @param EndBit The ordinal of the most significant bit in the bit field.
5802 @param Value New value of the bit field.
5804 @return The lower 32-bit of the value written to the MSR.
5809 AsmMsrBitFieldWrite32 (
5818 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
5819 result back to the bit field in the 64-bit MSR.
5821 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5822 between the read result and the value specified by OrData, and writes the
5823 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
5824 written to the MSR are returned. Extra left bits in OrData are stripped. The
5825 caller must either guarantee that Index and the data written is valid, or
5826 the caller must set up exception handlers to catch the exceptions. This
5827 function is only available on IA-32 and x64.
5829 If StartBit is greater than 31, then ASSERT().
5830 If EndBit is greater than 31, then ASSERT().
5831 If EndBit is less than StartBit, then ASSERT().
5832 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5834 @param Index The 32-bit MSR index to write.
5835 @param StartBit The ordinal of the least significant bit in the bit field.
5837 @param EndBit The ordinal of the most significant bit in the bit field.
5839 @param OrData The value to OR with the read value from the MSR.
5841 @return The lower 32-bit of the value written to the MSR.
5846 AsmMsrBitFieldOr32 (
5855 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5856 result back to the bit field in the 64-bit MSR.
5858 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5859 read result and the value specified by AndData, and writes the result to the
5860 64-bit MSR specified by Index. The lower 32-bits of the value written to the
5861 MSR are returned. Extra left bits in AndData are stripped. The caller must
5862 either guarantee that Index and the data written is valid, or the caller must
5863 set up exception handlers to catch the exceptions. This function is only
5864 available on IA-32 and x64.
5866 If StartBit is greater than 31, then ASSERT().
5867 If EndBit is greater than 31, then ASSERT().
5868 If EndBit is less than StartBit, then ASSERT().
5869 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5871 @param Index The 32-bit MSR index to write.
5872 @param StartBit The ordinal of the least significant bit in the bit field.
5874 @param EndBit The ordinal of the most significant bit in the bit field.
5876 @param AndData The value to AND with the read value from the MSR.
5878 @return The lower 32-bit of the value written to the MSR.
5883 AsmMsrBitFieldAnd32 (
5892 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5893 bitwise OR, and writes the result back to the bit field in the
5896 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
5897 bitwise OR between the read result and the value specified by
5898 AndData, and writes the result to the 64-bit MSR specified by Index. The
5899 lower 32-bits of the value written to the MSR are returned. Extra left bits
5900 in both AndData and OrData are stripped. The caller must either guarantee
5901 that Index and the data written is valid, or the caller must set up exception
5902 handlers to catch the exceptions. This function is only available on IA-32
5905 If StartBit is greater than 31, then ASSERT().
5906 If EndBit is greater than 31, then ASSERT().
5907 If EndBit is less than StartBit, then ASSERT().
5908 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5909 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5911 @param Index The 32-bit MSR index to write.
5912 @param StartBit The ordinal of the least significant bit in the bit field.
5914 @param EndBit The ordinal of the most significant bit in the bit field.
5916 @param AndData The value to AND with the read value from the MSR.
5917 @param OrData The value to OR with the result of the AND operation.
5919 @return The lower 32-bit of the value written to the MSR.
5924 AsmMsrBitFieldAndThenOr32 (
5934 Returns a 64-bit Machine Specific Register(MSR).
5936 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
5937 performed on Index, and some Index values may cause CPU exceptions. The
5938 caller must either guarantee that Index is valid, or the caller must set up
5939 exception handlers to catch the exceptions. This function is only available
5942 @param Index The 32-bit MSR index to read.
5944 @return The value of the MSR identified by Index.
5955 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
5958 Writes the 64-bit value specified by Value to the MSR specified by Index. The
5959 64-bit value written to the MSR is returned. No parameter checking is
5960 performed on Index or Value, and some of these may cause CPU exceptions. The
5961 caller must either guarantee that Index and Value are valid, or the caller
5962 must establish proper exception handlers. This function is only available on
5965 @param Index The 32-bit MSR index to write.
5966 @param Value The 64-bit value to write to the MSR.
5980 Reads a 64-bit MSR, performs a bitwise OR, and writes the result
5981 back to the 64-bit MSR.
5983 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5984 between the read result and the value specified by OrData, and writes the
5985 result to the 64-bit MSR specified by Index. The value written to the MSR is
5986 returned. No parameter checking is performed on Index or OrData, and some of
5987 these may cause CPU exceptions. The caller must either guarantee that Index
5988 and OrData are valid, or the caller must establish proper exception handlers.
5989 This function is only available on IA-32 and x64.
5991 @param Index The 32-bit MSR index to write.
5992 @param OrData The value to OR with the read value from the MSR.
5994 @return The value written back to the MSR.
6006 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
6009 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
6010 read result and the value specified by OrData, and writes the result to the
6011 64-bit MSR specified by Index. The value written to the MSR is returned. No
6012 parameter checking is performed on Index or OrData, and some of these may
6013 cause CPU exceptions. The caller must either guarantee that Index and OrData
6014 are valid, or the caller must establish proper exception handlers. This
6015 function is only available on IA-32 and x64.
6017 @param Index The 32-bit MSR index to write.
6018 @param AndData The value to AND with the read value from the MSR.
6020 @return The value written back to the MSR.
6032 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise
6033 OR, and writes the result back to the 64-bit MSR.
6035 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
6036 result and the value specified by AndData, performs a bitwise OR
6037 between the result of the AND operation and the value specified by OrData,
6038 and writes the result to the 64-bit MSR specified by Index. The value written
6039 to the MSR is returned. No parameter checking is performed on Index, AndData,
6040 or OrData, and some of these may cause CPU exceptions. The caller must either
6041 guarantee that Index, AndData, and OrData are valid, or the caller must
6042 establish proper exception handlers. This function is only available on IA-32
6045 @param Index The 32-bit MSR index to write.
6046 @param AndData The value to AND with the read value from the MSR.
6047 @param OrData The value to OR with the result of the AND operation.
6049 @return The value written back to the MSR.
6062 Reads a bit field of an MSR.
6064 Reads the bit field in the 64-bit MSR. The bit field is specified by the
6065 StartBit and the EndBit. The value of the bit field is returned. The caller
6066 must either guarantee that Index is valid, or the caller must set up
6067 exception handlers to catch the exceptions. This function is only available
6070 If StartBit is greater than 63, then ASSERT().
6071 If EndBit is greater than 63, then ASSERT().
6072 If EndBit is less than StartBit, then ASSERT().
6074 @param Index The 32-bit MSR index to read.
6075 @param StartBit The ordinal of the least significant bit in the bit field.
6077 @param EndBit The ordinal of the most significant bit in the bit field.
6080 @return The value read from the MSR.
6085 AsmMsrBitFieldRead64 (
6093 Writes a bit field to an MSR.
6095 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
6096 the StartBit and the EndBit. All other bits in the destination MSR are
6097 preserved. The MSR written is returned. The caller must either guarantee
6098 that Index and the data written is valid, or the caller must set up exception
6099 handlers to catch the exceptions. This function is only available on IA-32 and x64.
6101 If StartBit is greater than 63, then ASSERT().
6102 If EndBit is greater than 63, then ASSERT().
6103 If EndBit is less than StartBit, then ASSERT().
6104 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6106 @param Index The 32-bit MSR index to write.
6107 @param StartBit The ordinal of the least significant bit in the bit field.
6109 @param EndBit The ordinal of the most significant bit in the bit field.
6111 @param Value New value of the bit field.
6113 @return The value written back to the MSR.
6118 AsmMsrBitFieldWrite64 (
6127 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and
6128 writes the result back to the bit field in the 64-bit MSR.
6130 Reads the 64-bit MSR specified by Index, performs a bitwise OR
6131 between the read result and the value specified by OrData, and writes the
6132 result to the 64-bit MSR specified by Index. The value written to the MSR is
6133 returned. Extra left bits in OrData are stripped. The caller must either
6134 guarantee that Index and the data written is valid, or the caller must set up
6135 exception handlers to catch the exceptions. This function is only available
6138 If StartBit is greater than 63, then ASSERT().
6139 If EndBit is greater than 63, then ASSERT().
6140 If EndBit is less than StartBit, then ASSERT().
6141 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6143 @param Index The 32-bit MSR index to write.
6144 @param StartBit The ordinal of the least significant bit in the bit field.
6146 @param EndBit The ordinal of the most significant bit in the bit field.
6148 @param OrData The value to OR with the read value from the bit field.
6150 @return The value written back to the MSR.
6155 AsmMsrBitFieldOr64 (
6164 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
6165 result back to the bit field in the 64-bit MSR.
6167 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
6168 read result and the value specified by AndData, and writes the result to the
6169 64-bit MSR specified by Index. The value written to the MSR is returned.
6170 Extra left bits in AndData are stripped. The caller must either guarantee
6171 that Index and the data written is valid, or the caller must set up exception
6172 handlers to catch the exceptions. This function is only available on IA-32
6175 If StartBit is greater than 63, then ASSERT().
6176 If EndBit is greater than 63, then ASSERT().
6177 If EndBit is less than StartBit, then ASSERT().
6178 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6180 @param Index The 32-bit MSR index to write.
6181 @param StartBit The ordinal of the least significant bit in the bit field.
6183 @param EndBit The ordinal of the most significant bit in the bit field.
6185 @param AndData The value to AND with the read value from the bit field.
6187 @return The value written back to the MSR.
6192 AsmMsrBitFieldAnd64 (
6201 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
6202 bitwise OR, and writes the result back to the bit field in the
6205 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
6206 a bitwise OR between the read result and the value specified by
6207 AndData, and writes the result to the 64-bit MSR specified by Index. The
6208 value written to the MSR is returned. Extra left bits in both AndData and
6209 OrData are stripped. The caller must either guarantee that Index and the data
6210 written is valid, or the caller must set up exception handlers to catch the
6211 exceptions. This function is only available on IA-32 and x64.
6213 If StartBit is greater than 63, then ASSERT().
6214 If EndBit is greater than 63, then ASSERT().
6215 If EndBit is less than StartBit, then ASSERT().
6216 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6217 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6219 @param Index The 32-bit MSR index to write.
6220 @param StartBit The ordinal of the least significant bit in the bit field.
6222 @param EndBit The ordinal of the most significant bit in the bit field.
6224 @param AndData The value to AND with the read value from the bit field.
6225 @param OrData The value to OR with the result of the AND operation.
6227 @return The value written back to the MSR.
6232 AsmMsrBitFieldAndThenOr64 (
6242 Reads the current value of the EFLAGS register.
6244 Reads and returns the current value of the EFLAGS register. This function is
6245 only available on IA-32 and x64. This returns a 32-bit value on IA-32 and a
6246 64-bit value on x64.
6248 @return EFLAGS on IA-32 or RFLAGS on x64.
6259 Reads the current value of the Control Register 0 (CR0).
6261 Reads and returns the current value of CR0. This function is only available
6262 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6265 @return The value of the Control Register 0 (CR0).
6276 Reads the current value of the Control Register 2 (CR2).
6278 Reads and returns the current value of CR2. This function is only available
6279 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6282 @return The value of the Control Register 2 (CR2).
6293 Reads the current value of the Control Register 3 (CR3).
6295 Reads and returns the current value of CR3. This function is only available
6296 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6299 @return The value of the Control Register 3 (CR3).
6310 Reads the current value of the Control Register 4 (CR4).
6312 Reads and returns the current value of CR4. This function is only available
6313 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6316 @return The value of the Control Register 4 (CR4).
6327 Writes a value to Control Register 0 (CR0).
6329 Writes and returns a new value to CR0. This function is only available on
6330 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6332 @param Cr0 The value to write to CR0.
6334 @return The value written to CR0.
6345 Writes a value to Control Register 2 (CR2).
6347 Writes and returns a new value to CR2. This function is only available on
6348 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6350 @param Cr2 The value to write to CR2.
6352 @return The value written to CR2.
6363 Writes a value to Control Register 3 (CR3).
6365 Writes and returns a new value to CR3. This function is only available on
6366 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6368 @param Cr3 The value to write to CR3.
6370 @return The value written to CR3.
6381 Writes a value to Control Register 4 (CR4).
6383 Writes and returns a new value to CR4. This function is only available on
6384 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6386 @param Cr4 The value to write to CR4.
6388 @return The value written to CR4.
6399 Reads the current value of Debug Register 0 (DR0).
6401 Reads and returns the current value of DR0. This function is only available
6402 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6405 @return The value of Debug Register 0 (DR0).
6416 Reads the current value of Debug Register 1 (DR1).
6418 Reads and returns the current value of DR1. This function is only available
6419 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6422 @return The value of Debug Register 1 (DR1).
6433 Reads the current value of Debug Register 2 (DR2).
6435 Reads and returns the current value of DR2. This function is only available
6436 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6439 @return The value of Debug Register 2 (DR2).
6450 Reads the current value of Debug Register 3 (DR3).
6452 Reads and returns the current value of DR3. This function is only available
6453 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6456 @return The value of Debug Register 3 (DR3).
6467 Reads the current value of Debug Register 4 (DR4).
6469 Reads and returns the current value of DR4. This function is only available
6470 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6473 @return The value of Debug Register 4 (DR4).
6484 Reads the current value of Debug Register 5 (DR5).
6486 Reads and returns the current value of DR5. This function is only available
6487 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6490 @return The value of Debug Register 5 (DR5).
6501 Reads the current value of Debug Register 6 (DR6).
6503 Reads and returns the current value of DR6. This function is only available
6504 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6507 @return The value of Debug Register 6 (DR6).
6518 Reads the current value of Debug Register 7 (DR7).
6520 Reads and returns the current value of DR7. This function is only available
6521 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6524 @return The value of Debug Register 7 (DR7).
6535 Writes a value to Debug Register 0 (DR0).
6537 Writes and returns a new value to DR0. This function is only available on
6538 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6540 @param Dr0 The value to write to Dr0.
6542 @return The value written to Debug Register 0 (DR0).
6553 Writes a value to Debug Register 1 (DR1).
6555 Writes and returns a new value to DR1. This function is only available on
6556 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6558 @param Dr1 The value to write to Dr1.
6560 @return The value written to Debug Register 1 (DR1).
6571 Writes a value to Debug Register 2 (DR2).
6573 Writes and returns a new value to DR2. This function is only available on
6574 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6576 @param Dr2 The value to write to Dr2.
6578 @return The value written to Debug Register 2 (DR2).
6589 Writes a value to Debug Register 3 (DR3).
6591 Writes and returns a new value to DR3. This function is only available on
6592 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6594 @param Dr3 The value to write to Dr3.
6596 @return The value written to Debug Register 3 (DR3).
6607 Writes a value to Debug Register 4 (DR4).
6609 Writes and returns a new value to DR4. This function is only available on
6610 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6612 @param Dr4 The value to write to Dr4.
6614 @return The value written to Debug Register 4 (DR4).
6625 Writes a value to Debug Register 5 (DR5).
6627 Writes and returns a new value to DR5. This function is only available on
6628 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6630 @param Dr5 The value to write to Dr5.
6632 @return The value written to Debug Register 5 (DR5).
6643 Writes a value to Debug Register 6 (DR6).
6645 Writes and returns a new value to DR6. This function is only available on
6646 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6648 @param Dr6 The value to write to Dr6.
6650 @return The value written to Debug Register 6 (DR6).
6661 Writes a value to Debug Register 7 (DR7).
6663 Writes and returns a new value to DR7. This function is only available on
6664 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6666 @param Dr7 The value to write to Dr7.
6668 @return The value written to Debug Register 7 (DR7).
6679 Reads the current value of Code Segment Register (CS).
6681 Reads and returns the current value of CS. This function is only available on
6684 @return The current value of CS.
6695 Reads the current value of Data Segment Register (DS).
6697 Reads and returns the current value of DS. This function is only available on
6700 @return The current value of DS.
6711 Reads the current value of Extra Segment Register (ES).
6713 Reads and returns the current value of ES. This function is only available on
6716 @return The current value of ES.
6727 Reads the current value of FS Data Segment Register (FS).
6729 Reads and returns the current value of FS. This function is only available on
6732 @return The current value of FS.
6743 Reads the current value of GS Data Segment Register (GS).
6745 Reads and returns the current value of GS. This function is only available on
6748 @return The current value of GS.
6759 Reads the current value of Stack Segment Register (SS).
6761 Reads and returns the current value of SS. This function is only available on
6764 @return The current value of SS.
6775 Reads the current value of Task Register (TR).
6777 Reads and returns the current value of TR. This function is only available on
6780 @return The current value of TR.
6791 Reads the current Global Descriptor Table Register(GDTR) descriptor.
6793 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
6794 function is only available on IA-32 and x64.
6796 If Gdtr is NULL, then ASSERT().
6798 @param Gdtr The pointer to a GDTR descriptor.
6804 OUT IA32_DESCRIPTOR
*Gdtr
6809 Writes the current Global Descriptor Table Register (GDTR) descriptor.
6811 Writes and the current GDTR descriptor specified by Gdtr. This function is
6812 only available on IA-32 and x64.
6814 If Gdtr is NULL, then ASSERT().
6816 @param Gdtr The pointer to a GDTR descriptor.
6822 IN CONST IA32_DESCRIPTOR
*Gdtr
6827 Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.
6829 Reads and returns the current IDTR descriptor and returns it in Idtr. This
6830 function is only available on IA-32 and x64.
6832 If Idtr is NULL, then ASSERT().
6834 @param Idtr The pointer to a IDTR descriptor.
6840 OUT IA32_DESCRIPTOR
*Idtr
6845 Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.
6847 Writes the current IDTR descriptor and returns it in Idtr. This function is
6848 only available on IA-32 and x64.
6850 If Idtr is NULL, then ASSERT().
6852 @param Idtr The pointer to a IDTR descriptor.
6858 IN CONST IA32_DESCRIPTOR
*Idtr
6863 Reads the current Local Descriptor Table Register(LDTR) selector.
6865 Reads and returns the current 16-bit LDTR descriptor value. This function is
6866 only available on IA-32 and x64.
6868 @return The current selector of LDT.
6879 Writes the current Local Descriptor Table Register (LDTR) selector.
6881 Writes and the current LDTR descriptor specified by Ldtr. This function is
6882 only available on IA-32 and x64.
6884 @param Ldtr 16-bit LDTR selector value.
6895 Save the current floating point/SSE/SSE2 context to a buffer.
6897 Saves the current floating point/SSE/SSE2 state to the buffer specified by
6898 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
6899 available on IA-32 and x64.
6901 If Buffer is NULL, then ASSERT().
6902 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6904 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
6910 OUT IA32_FX_BUFFER
*Buffer
6915 Restores the current floating point/SSE/SSE2 context from a buffer.
6917 Restores the current floating point/SSE/SSE2 state from the buffer specified
6918 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
6919 only available on IA-32 and x64.
6921 If Buffer is NULL, then ASSERT().
6922 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6923 If Buffer was not saved with AsmFxSave(), then ASSERT().
6925 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
6931 IN CONST IA32_FX_BUFFER
*Buffer
6936 Reads the current value of 64-bit MMX Register #0 (MM0).
6938 Reads and returns the current value of MM0. This function is only available
6941 @return The current value of MM0.
6952 Reads the current value of 64-bit MMX Register #1 (MM1).
6954 Reads and returns the current value of MM1. This function is only available
6957 @return The current value of MM1.
6968 Reads the current value of 64-bit MMX Register #2 (MM2).
6970 Reads and returns the current value of MM2. This function is only available
6973 @return The current value of MM2.
6984 Reads the current value of 64-bit MMX Register #3 (MM3).
6986 Reads and returns the current value of MM3. This function is only available
6989 @return The current value of MM3.
7000 Reads the current value of 64-bit MMX Register #4 (MM4).
7002 Reads and returns the current value of MM4. This function is only available
7005 @return The current value of MM4.
7016 Reads the current value of 64-bit MMX Register #5 (MM5).
7018 Reads and returns the current value of MM5. This function is only available
7021 @return The current value of MM5.
7032 Reads the current value of 64-bit MMX Register #6 (MM6).
7034 Reads and returns the current value of MM6. This function is only available
7037 @return The current value of MM6.
7048 Reads the current value of 64-bit MMX Register #7 (MM7).
7050 Reads and returns the current value of MM7. This function is only available
7053 @return The current value of MM7.
7064 Writes the current value of 64-bit MMX Register #0 (MM0).
7066 Writes the current value of MM0. This function is only available on IA32 and
7069 @param Value The 64-bit value to write to MM0.
7080 Writes the current value of 64-bit MMX Register #1 (MM1).
7082 Writes the current value of MM1. This function is only available on IA32 and
7085 @param Value The 64-bit value to write to MM1.
7096 Writes the current value of 64-bit MMX Register #2 (MM2).
7098 Writes the current value of MM2. This function is only available on IA32 and
7101 @param Value The 64-bit value to write to MM2.
7112 Writes the current value of 64-bit MMX Register #3 (MM3).
7114 Writes the current value of MM3. This function is only available on IA32 and
7117 @param Value The 64-bit value to write to MM3.
7128 Writes the current value of 64-bit MMX Register #4 (MM4).
7130 Writes the current value of MM4. This function is only available on IA32 and
7133 @param Value The 64-bit value to write to MM4.
7144 Writes the current value of 64-bit MMX Register #5 (MM5).
7146 Writes the current value of MM5. This function is only available on IA32 and
7149 @param Value The 64-bit value to write to MM5.
7160 Writes the current value of 64-bit MMX Register #6 (MM6).
7162 Writes the current value of MM6. This function is only available on IA32 and
7165 @param Value The 64-bit value to write to MM6.
7176 Writes the current value of 64-bit MMX Register #7 (MM7).
7178 Writes the current value of MM7. This function is only available on IA32 and
7181 @param Value The 64-bit value to write to MM7.
7192 Reads the current value of Time Stamp Counter (TSC).
7194 Reads and returns the current value of TSC. This function is only available
7197 @return The current value of TSC
7208 Reads the current value of a Performance Counter (PMC).
7210 Reads and returns the current value of performance counter specified by
7211 Index. This function is only available on IA-32 and x64.
7213 @param Index The 32-bit Performance Counter index to read.
7215 @return The value of the PMC specified by Index.
7226 Sets up a monitor buffer that is used by AsmMwait().
7228 Executes a MONITOR instruction with the register state specified by Eax, Ecx
7229 and Edx. Returns Eax. This function is only available on IA-32 and x64.
7231 @param Eax The value to load into EAX or RAX before executing the MONITOR
7233 @param Ecx The value to load into ECX or RCX before executing the MONITOR
7235 @param Edx The value to load into EDX or RDX before executing the MONITOR
7251 Executes an MWAIT instruction.
7253 Executes an MWAIT instruction with the register state specified by Eax and
7254 Ecx. Returns Eax. This function is only available on IA-32 and x64.
7256 @param Eax The value to load into EAX or RAX before executing the MONITOR
7258 @param Ecx The value to load into ECX or RCX before executing the MONITOR
7273 Executes a WBINVD instruction.
7275 Executes a WBINVD instruction. This function is only available on IA-32 and
7287 Executes a INVD instruction.
7289 Executes a INVD instruction. This function is only available on IA-32 and
7301 Flushes a cache line from all the instruction and data caches within the
7302 coherency domain of the CPU.
7304 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
7305 This function is only available on IA-32 and x64.
7307 @param LinearAddress The address of the cache line to flush. If the CPU is
7308 in a physical addressing mode, then LinearAddress is a
7309 physical address. If the CPU is in a virtual
7310 addressing mode, then LinearAddress is a virtual
7313 @return LinearAddress.
7318 IN VOID
*LinearAddress
7323 Enables the 32-bit paging mode on the CPU.
7325 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
7326 must be properly initialized prior to calling this service. This function
7327 assumes the current execution mode is 32-bit protected mode. This function is
7328 only available on IA-32. After the 32-bit paging mode is enabled, control is
7329 transferred to the function specified by EntryPoint using the new stack
7330 specified by NewStack and passing in the parameters specified by Context1 and
7331 Context2. Context1 and Context2 are optional and may be NULL. The function
7332 EntryPoint must never return.
7334 If the current execution mode is not 32-bit protected mode, then ASSERT().
7335 If EntryPoint is NULL, then ASSERT().
7336 If NewStack is NULL, then ASSERT().
7338 There are a number of constraints that must be followed before calling this
7340 1) Interrupts must be disabled.
7341 2) The caller must be in 32-bit protected mode with flat descriptors. This
7342 means all descriptors must have a base of 0 and a limit of 4GB.
7343 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
7345 4) CR3 must point to valid page tables that will be used once the transition
7346 is complete, and those page tables must guarantee that the pages for this
7347 function and the stack are identity mapped.
7349 @param EntryPoint A pointer to function to call with the new stack after
7351 @param Context1 A pointer to the context to pass into the EntryPoint
7352 function as the first parameter after paging is enabled.
7353 @param Context2 A pointer to the context to pass into the EntryPoint
7354 function as the second parameter after paging is enabled.
7355 @param NewStack A pointer to the new stack to use for the EntryPoint
7356 function after paging is enabled.
7362 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
7363 IN VOID
*Context1
, OPTIONAL
7364 IN VOID
*Context2
, OPTIONAL
7370 Disables the 32-bit paging mode on the CPU.
7372 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
7373 mode. This function assumes the current execution mode is 32-paged protected
7374 mode. This function is only available on IA-32. After the 32-bit paging mode
7375 is disabled, control is transferred to the function specified by EntryPoint
7376 using the new stack specified by NewStack and passing in the parameters
7377 specified by Context1 and Context2. Context1 and Context2 are optional and
7378 may be NULL. The function EntryPoint must never return.
7380 If the current execution mode is not 32-bit paged mode, then ASSERT().
7381 If EntryPoint is NULL, then ASSERT().
7382 If NewStack is NULL, then ASSERT().
7384 There are a number of constraints that must be followed before calling this
7386 1) Interrupts must be disabled.
7387 2) The caller must be in 32-bit paged mode.
7388 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
7389 4) CR3 must point to valid page tables that guarantee that the pages for
7390 this function and the stack are identity mapped.
7392 @param EntryPoint A pointer to function to call with the new stack after
7394 @param Context1 A pointer to the context to pass into the EntryPoint
7395 function as the first parameter after paging is disabled.
7396 @param Context2 A pointer to the context to pass into the EntryPoint
7397 function as the second parameter after paging is
7399 @param NewStack A pointer to the new stack to use for the EntryPoint
7400 function after paging is disabled.
7405 AsmDisablePaging32 (
7406 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
7407 IN VOID
*Context1
, OPTIONAL
7408 IN VOID
*Context2
, OPTIONAL
7414 Enables the 64-bit paging mode on the CPU.
7416 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
7417 must be properly initialized prior to calling this service. This function
7418 assumes the current execution mode is 32-bit protected mode with flat
7419 descriptors. This function is only available on IA-32. After the 64-bit
7420 paging mode is enabled, control is transferred to the function specified by
7421 EntryPoint using the new stack specified by NewStack and passing in the
7422 parameters specified by Context1 and Context2. Context1 and Context2 are
7423 optional and may be 0. The function EntryPoint must never return.
7425 If the current execution mode is not 32-bit protected mode with flat
7426 descriptors, then ASSERT().
7427 If EntryPoint is 0, then ASSERT().
7428 If NewStack is 0, then ASSERT().
7430 @param Cs The 16-bit selector to load in the CS before EntryPoint
7431 is called. The descriptor in the GDT that this selector
7432 references must be setup for long mode.
7433 @param EntryPoint The 64-bit virtual address of the function to call with
7434 the new stack after paging is enabled.
7435 @param Context1 The 64-bit virtual address of the context to pass into
7436 the EntryPoint function as the first parameter after
7438 @param Context2 The 64-bit virtual address of the context to pass into
7439 the EntryPoint function as the second parameter after
7441 @param NewStack The 64-bit virtual address of the new stack to use for
7442 the EntryPoint function after paging is enabled.
7449 IN UINT64 EntryPoint
,
7450 IN UINT64 Context1
, OPTIONAL
7451 IN UINT64 Context2
, OPTIONAL
7457 Disables the 64-bit paging mode on the CPU.
7459 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
7460 mode. This function assumes the current execution mode is 64-paging mode.
7461 This function is only available on x64. After the 64-bit paging mode is
7462 disabled, control is transferred to the function specified by EntryPoint
7463 using the new stack specified by NewStack and passing in the parameters
7464 specified by Context1 and Context2. Context1 and Context2 are optional and
7465 may be 0. The function EntryPoint must never return.
7467 If the current execution mode is not 64-bit paged mode, then ASSERT().
7468 If EntryPoint is 0, then ASSERT().
7469 If NewStack is 0, then ASSERT().
7471 @param Cs The 16-bit selector to load in the CS before EntryPoint
7472 is called. The descriptor in the GDT that this selector
7473 references must be setup for 32-bit protected mode.
7474 @param EntryPoint The 64-bit virtual address of the function to call with
7475 the new stack after paging is disabled.
7476 @param Context1 The 64-bit virtual address of the context to pass into
7477 the EntryPoint function as the first parameter after
7479 @param Context2 The 64-bit virtual address of the context to pass into
7480 the EntryPoint function as the second parameter after
7482 @param NewStack The 64-bit virtual address of the new stack to use for
7483 the EntryPoint function after paging is disabled.
7488 AsmDisablePaging64 (
7490 IN UINT32 EntryPoint
,
7491 IN UINT32 Context1
, OPTIONAL
7492 IN UINT32 Context2
, OPTIONAL
7498 // 16-bit thunking services
7502 Retrieves the properties for 16-bit thunk functions.
7504 Computes the size of the buffer and stack below 1MB required to use the
7505 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
7506 buffer size is returned in RealModeBufferSize, and the stack size is returned
7507 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
7508 then the actual minimum stack size is ExtraStackSize plus the maximum number
7509 of bytes that need to be passed to the 16-bit real mode code.
7511 If RealModeBufferSize is NULL, then ASSERT().
7512 If ExtraStackSize is NULL, then ASSERT().
7514 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
7515 required to use the 16-bit thunk functions.
7516 @param ExtraStackSize A pointer to the extra size of stack below 1MB
7517 that the 16-bit thunk functions require for
7518 temporary storage in the transition to and from
7524 AsmGetThunk16Properties (
7525 OUT UINT32
*RealModeBufferSize
,
7526 OUT UINT32
*ExtraStackSize
7531 Prepares all structures a code required to use AsmThunk16().
7533 Prepares all structures and code required to use AsmThunk16().
7535 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7536 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7538 If ThunkContext is NULL, then ASSERT().
7540 @param ThunkContext A pointer to the context structure that describes the
7541 16-bit real mode code to call.
7547 IN OUT THUNK_CONTEXT
*ThunkContext
7552 Transfers control to a 16-bit real mode entry point and returns the results.
7554 Transfers control to a 16-bit real mode entry point and returns the results.
7555 AsmPrepareThunk16() must be called with ThunkContext before this function is used.
7556 This function must be called with interrupts disabled.
7558 The register state from the RealModeState field of ThunkContext is restored just prior
7559 to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState,
7560 which is used to set the interrupt state when a 16-bit real mode entry point is called.
7561 Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.
7562 The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to
7563 the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function.
7564 The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,
7565 so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment
7566 and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry
7567 point must exit with a RETF instruction. The register state is captured into RealModeState immediately
7568 after the RETF instruction is executed.
7570 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7571 or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure
7572 the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode.
7574 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7575 then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode.
7576 This includes the base vectors, the interrupt masks, and the edge/level trigger mode.
7578 If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code
7579 is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.
7581 If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7582 ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to
7583 disable the A20 mask.
7585 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in
7586 ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails,
7587 then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7589 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in
7590 ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7592 If ThunkContext is NULL, then ASSERT().
7593 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
7594 If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7595 ThunkAttributes, then ASSERT().
7597 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7598 virtual to physical mappings for ThunkContext.RealModeBuffer are mapped 1:1.
7600 @param ThunkContext A pointer to the context structure that describes the
7601 16-bit real mode code to call.
7607 IN OUT THUNK_CONTEXT
*ThunkContext
7612 Prepares all structures and code for a 16-bit real mode thunk, transfers
7613 control to a 16-bit real mode entry point, and returns the results.
7615 Prepares all structures and code for a 16-bit real mode thunk, transfers
7616 control to a 16-bit real mode entry point, and returns the results. If the
7617 caller only need to perform a single 16-bit real mode thunk, then this
7618 service should be used. If the caller intends to make more than one 16-bit
7619 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
7620 once and AsmThunk16() can be called for each 16-bit real mode thunk.
7622 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7623 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7625 See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.
7627 @param ThunkContext A pointer to the context structure that describes the
7628 16-bit real mode code to call.
7633 AsmPrepareAndThunk16 (
7634 IN OUT THUNK_CONTEXT
*ThunkContext
7638 Generates a 16-bit random number through RDRAND instruction.
7640 if Rand is NULL, then ASSERT().
7642 @param[out] Rand Buffer pointer to store the random result.
7644 @retval TRUE RDRAND call was successful.
7645 @retval FALSE Failed attempts to call RDRAND.
7655 Generates a 32-bit random number through RDRAND instruction.
7657 if Rand is NULL, then ASSERT().
7659 @param[out] Rand Buffer pointer to store the random result.
7661 @retval TRUE RDRAND call was successful.
7662 @retval FALSE Failed attempts to call RDRAND.
7672 Generates a 64-bit random number through RDRAND instruction.
7674 if Rand is NULL, then ASSERT().
7676 @param[out] Rand Buffer pointer to store the random result.
7678 @retval TRUE RDRAND call was successful.
7679 @retval FALSE Failed attempts to call RDRAND.
7689 Load given selector into TR register.
7691 @param[in] Selector Task segment selector
7700 Patch the immediate operand of an IA32 or X64 instruction such that the byte,
7701 word, dword or qword operand is encoded at the end of the instruction's
7702 binary representation.
7704 This function should be used to update object code that was compiled with
7705 NASM from assembly source code. Example:
7709 mov eax, strict dword 0 ; the imm32 zero operand will be patched
7715 X86_ASSEMBLY_PATCH_LABEL gPatchCr3;
7716 PatchInstructionX86 (gPatchCr3, AsmReadCr3 (), 4);
7718 @param[out] InstructionEnd Pointer right past the instruction to patch. The
7719 immediate operand to patch is expected to
7720 comprise the trailing bytes of the instruction.
7721 If InstructionEnd is closer to address 0 than
7722 ValueSize permits, then ASSERT().
7724 @param[in] PatchValue The constant to write to the immediate operand.
7725 The caller is responsible for ensuring that
7726 PatchValue can be represented in the byte, word,
7727 dword or qword operand (as indicated through
7728 ValueSize); otherwise ASSERT().
7730 @param[in] ValueSize The size of the operand in bytes; must be 1, 2,
7731 4, or 8. ASSERT() otherwise.
7735 PatchInstructionX86 (
7736 OUT X86_ASSEMBLY_PATCH_LABEL
*InstructionEnd
,
7737 IN UINT64 PatchValue
,
7741 #endif // defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
7742 #endif // !defined (__BASE_LIB__)