2 Provides string functions, linked list functions, math functions, synchronization
3 functions, file path functions, and CPU architecture-specific functions.
5 Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
6 Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
7 Copyright (c) Microsoft Corporation.<BR>
8 Portions Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
10 SPDX-License-Identifier: BSD-2-Clause-Patent
18 // Definitions for architecture-specific types
20 #if defined (MDE_CPU_IA32)
22 /// The IA-32 architecture context buffer used by SetJump() and LongJump().
32 } BASE_LIBRARY_JUMP_BUFFER
;
34 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4
36 #endif // defined (MDE_CPU_IA32)
38 #if defined (MDE_CPU_X64)
40 /// The x64 architecture context buffer used by SetJump() and LongJump().
54 UINT8 XmmBuffer
[160]; ///< XMM6-XMM15.
56 } BASE_LIBRARY_JUMP_BUFFER
;
58 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
60 #endif // defined (MDE_CPU_X64)
62 #if defined (MDE_CPU_EBC)
64 /// The EBC context buffer used by SetJump() and LongJump().
72 } BASE_LIBRARY_JUMP_BUFFER
;
74 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
76 #endif // defined (MDE_CPU_EBC)
78 #if defined (MDE_CPU_ARM)
81 UINT32 R3
; ///< A copy of R13.
92 } BASE_LIBRARY_JUMP_BUFFER
;
94 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4
96 #endif // defined (MDE_CPU_ARM)
98 #if defined (MDE_CPU_AARCH64)
124 } BASE_LIBRARY_JUMP_BUFFER
;
126 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
128 #endif // defined (MDE_CPU_AARCH64)
130 #if defined (MDE_CPU_RISCV64)
132 /// The RISC-V architecture context buffer used by SetJump() and LongJump().
149 } BASE_LIBRARY_JUMP_BUFFER
;
151 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
153 #endif // defined (MDE_CPU_RISCV64)
161 Returns the length of a Null-terminated Unicode string.
163 This function is similar as strlen_s defined in C11.
165 If String is not aligned on a 16-bit boundary, then ASSERT().
167 @param String A pointer to a Null-terminated Unicode string.
168 @param MaxSize The maximum number of Destination Unicode
169 char, including terminating null char.
171 @retval 0 If String is NULL.
172 @retval MaxSize If there is no null character in the first MaxSize characters of String.
173 @return The number of characters that percede the terminating null character.
179 IN CONST CHAR16
*String
,
184 Returns the size of a Null-terminated Unicode string in bytes, including the
187 This function returns the size of the Null-terminated Unicode string
188 specified by String in bytes, including the Null terminator.
190 If String is not aligned on a 16-bit boundary, then ASSERT().
192 @param String A pointer to a Null-terminated Unicode string.
193 @param MaxSize The maximum number of Destination Unicode
194 char, including the Null terminator.
196 @retval 0 If String is NULL.
197 @retval (sizeof (CHAR16) * (MaxSize + 1))
198 If there is no Null terminator in the first MaxSize characters of
200 @return The size of the Null-terminated Unicode string in bytes, including
207 IN CONST CHAR16
*String
,
212 Copies the string pointed to by Source (including the terminating null char)
213 to the array pointed to by Destination.
215 This function is similar as strcpy_s defined in C11.
217 If Destination is not aligned on a 16-bit boundary, then ASSERT().
218 If Source is not aligned on a 16-bit boundary, then ASSERT().
220 If an error is returned, then the Destination is unmodified.
222 @param Destination A pointer to a Null-terminated Unicode string.
223 @param DestMax The maximum number of Destination Unicode
224 char, including terminating null char.
225 @param Source A pointer to a Null-terminated Unicode string.
227 @retval RETURN_SUCCESS String is copied.
228 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
229 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
231 If PcdMaximumUnicodeStringLength is not zero,
232 and DestMax is greater than
233 PcdMaximumUnicodeStringLength.
235 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
240 OUT CHAR16
*Destination
,
242 IN CONST CHAR16
*Source
246 Copies not more than Length successive char from the string pointed to by
247 Source to the array pointed to by Destination. If no null char is copied from
248 Source, then Destination[Length] is always set to null.
250 This function is similar as strncpy_s defined in C11.
252 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
253 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
255 If an error is returned, then the Destination is unmodified.
257 @param Destination A pointer to a Null-terminated Unicode string.
258 @param DestMax The maximum number of Destination Unicode
259 char, including terminating null char.
260 @param Source A pointer to a Null-terminated Unicode string.
261 @param Length The maximum number of Unicode characters to copy.
263 @retval RETURN_SUCCESS String is copied.
264 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than
265 MIN(StrLen(Source), Length).
266 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
268 If PcdMaximumUnicodeStringLength is not zero,
269 and DestMax is greater than
270 PcdMaximumUnicodeStringLength.
272 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
277 OUT CHAR16
*Destination
,
279 IN CONST CHAR16
*Source
,
284 Appends a copy of the string pointed to by Source (including the terminating
285 null char) to the end of the string pointed to by Destination.
287 This function is similar as strcat_s defined in C11.
289 If Destination is not aligned on a 16-bit boundary, then ASSERT().
290 If Source is not aligned on a 16-bit boundary, then ASSERT().
292 If an error is returned, then the Destination is unmodified.
294 @param Destination A pointer to a Null-terminated Unicode string.
295 @param DestMax The maximum number of Destination Unicode
296 char, including terminating null char.
297 @param Source A pointer to a Null-terminated Unicode string.
299 @retval RETURN_SUCCESS String is appended.
300 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
302 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
303 greater than StrLen(Source).
304 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
306 If PcdMaximumUnicodeStringLength is not zero,
307 and DestMax is greater than
308 PcdMaximumUnicodeStringLength.
310 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
315 IN OUT CHAR16
*Destination
,
317 IN CONST CHAR16
*Source
321 Appends not more than Length successive char from the string pointed to by
322 Source to the end of the string pointed to by Destination. If no null char is
323 copied from Source, then Destination[StrLen(Destination) + Length] is always
326 This function is similar as strncat_s defined in C11.
328 If Destination is not aligned on a 16-bit boundary, then ASSERT().
329 If Source is not aligned on a 16-bit boundary, then ASSERT().
331 If an error is returned, then the Destination is unmodified.
333 @param Destination A pointer to a Null-terminated Unicode string.
334 @param DestMax The maximum number of Destination Unicode
335 char, including terminating null char.
336 @param Source A pointer to a Null-terminated Unicode string.
337 @param Length The maximum number of Unicode characters to copy.
339 @retval RETURN_SUCCESS String is appended.
340 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
342 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
343 greater than MIN(StrLen(Source), Length).
344 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
346 If PcdMaximumUnicodeStringLength is not zero,
347 and DestMax is greater than
348 PcdMaximumUnicodeStringLength.
350 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
355 IN OUT CHAR16
*Destination
,
357 IN CONST CHAR16
*Source
,
362 Convert a Null-terminated Unicode decimal string to a value of type UINTN.
364 This function outputs a value of type UINTN by interpreting the contents of
365 the Unicode string specified by String as a decimal number. The format of the
366 input Unicode string String is:
368 [spaces] [decimal digits].
370 The valid decimal digit character is in the range [0-9]. The function will
371 ignore the pad space, which includes spaces or tab characters, before
372 [decimal digits]. The running zero in the beginning of [decimal digits] will
373 be ignored. Then, the function stops at the first character that is a not a
374 valid decimal character or a Null-terminator, whichever one comes first.
376 If String is not aligned in a 16-bit boundary, then ASSERT().
378 If String has no valid decimal digits in the above format, then 0 is stored
379 at the location pointed to by Data.
380 If the number represented by String exceeds the range defined by UINTN, then
381 MAX_UINTN is stored at the location pointed to by Data.
383 If EndPointer is not NULL, a pointer to the character that stopped the scan
384 is stored at the location pointed to by EndPointer. If String has no valid
385 decimal digits right after the optional pad spaces, the value of String is
386 stored at the location pointed to by EndPointer.
388 @param String Pointer to a Null-terminated Unicode string.
389 @param EndPointer Pointer to character that stops scan.
390 @param Data Pointer to the converted value.
392 @retval RETURN_SUCCESS Value is translated from String.
393 @retval RETURN_INVALID_PARAMETER If String is NULL.
395 If PcdMaximumUnicodeStringLength is not
396 zero, and String contains more than
397 PcdMaximumUnicodeStringLength Unicode
398 characters, not including the
400 @retval RETURN_UNSUPPORTED If the number represented by String exceeds
401 the range defined by UINTN.
407 IN CONST CHAR16
*String
,
408 OUT CHAR16
**EndPointer
, OPTIONAL
413 Convert a Null-terminated Unicode decimal string to a value of type UINT64.
415 This function outputs a value of type UINT64 by interpreting the contents of
416 the Unicode string specified by String as a decimal number. The format of the
417 input Unicode string String is:
419 [spaces] [decimal digits].
421 The valid decimal digit character is in the range [0-9]. The function will
422 ignore the pad space, which includes spaces or tab characters, before
423 [decimal digits]. The running zero in the beginning of [decimal digits] will
424 be ignored. Then, the function stops at the first character that is a not a
425 valid decimal character or a Null-terminator, whichever one comes first.
427 If String is not aligned in a 16-bit boundary, then ASSERT().
429 If String has no valid decimal digits in the above format, then 0 is stored
430 at the location pointed to by Data.
431 If the number represented by String exceeds the range defined by UINT64, then
432 MAX_UINT64 is stored at the location pointed to by Data.
434 If EndPointer is not NULL, a pointer to the character that stopped the scan
435 is stored at the location pointed to by EndPointer. If String has no valid
436 decimal digits right after the optional pad spaces, the value of String is
437 stored at the location pointed to by EndPointer.
439 @param String Pointer to a Null-terminated Unicode string.
440 @param EndPointer Pointer to character that stops scan.
441 @param Data Pointer to the converted value.
443 @retval RETURN_SUCCESS Value is translated from String.
444 @retval RETURN_INVALID_PARAMETER If String is NULL.
446 If PcdMaximumUnicodeStringLength is not
447 zero, and String contains more than
448 PcdMaximumUnicodeStringLength Unicode
449 characters, not including the
451 @retval RETURN_UNSUPPORTED If the number represented by String exceeds
452 the range defined by UINT64.
457 StrDecimalToUint64S (
458 IN CONST CHAR16
*String
,
459 OUT CHAR16
**EndPointer
, OPTIONAL
464 Convert a Null-terminated Unicode hexadecimal string to a value of type
467 This function outputs a value of type UINTN by interpreting the contents of
468 the Unicode string specified by String as a hexadecimal number. The format of
469 the input Unicode string String is:
471 [spaces][zeros][x][hexadecimal digits].
473 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
474 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
475 If "x" appears in the input string, it must be prefixed with at least one 0.
476 The function will ignore the pad space, which includes spaces or tab
477 characters, before [zeros], [x] or [hexadecimal digit]. The running zero
478 before [x] or [hexadecimal digit] will be ignored. Then, the decoding starts
479 after [x] or the first valid hexadecimal digit. Then, the function stops at
480 the first character that is a not a valid hexadecimal character or NULL,
481 whichever one comes first.
483 If String is not aligned in a 16-bit boundary, then ASSERT().
485 If String has no valid hexadecimal digits in the above format, then 0 is
486 stored at the location pointed to by Data.
487 If the number represented by String exceeds the range defined by UINTN, then
488 MAX_UINTN is stored at the location pointed to by Data.
490 If EndPointer is not NULL, a pointer to the character that stopped the scan
491 is stored at the location pointed to by EndPointer. If String has no valid
492 hexadecimal digits right after the optional pad spaces, the value of String
493 is stored at the location pointed to by EndPointer.
495 @param String Pointer to a Null-terminated Unicode string.
496 @param EndPointer Pointer to character that stops scan.
497 @param Data Pointer to the converted value.
499 @retval RETURN_SUCCESS Value is translated from String.
500 @retval RETURN_INVALID_PARAMETER If String is NULL.
502 If PcdMaximumUnicodeStringLength is not
503 zero, and String contains more than
504 PcdMaximumUnicodeStringLength Unicode
505 characters, not including the
507 @retval RETURN_UNSUPPORTED If the number represented by String exceeds
508 the range defined by UINTN.
514 IN CONST CHAR16
*String
,
515 OUT CHAR16
**EndPointer
, OPTIONAL
520 Convert a Null-terminated Unicode hexadecimal string to a value of type
523 This function outputs a value of type UINT64 by interpreting the contents of
524 the Unicode string specified by String as a hexadecimal number. The format of
525 the input Unicode string String is:
527 [spaces][zeros][x][hexadecimal digits].
529 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
530 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
531 If "x" appears in the input string, it must be prefixed with at least one 0.
532 The function will ignore the pad space, which includes spaces or tab
533 characters, before [zeros], [x] or [hexadecimal digit]. The running zero
534 before [x] or [hexadecimal digit] will be ignored. Then, the decoding starts
535 after [x] or the first valid hexadecimal digit. Then, the function stops at
536 the first character that is a not a valid hexadecimal character or NULL,
537 whichever one comes first.
539 If String is not aligned in a 16-bit boundary, then ASSERT().
541 If String has no valid hexadecimal digits in the above format, then 0 is
542 stored at the location pointed to by Data.
543 If the number represented by String exceeds the range defined by UINT64, then
544 MAX_UINT64 is stored at the location pointed to by Data.
546 If EndPointer is not NULL, a pointer to the character that stopped the scan
547 is stored at the location pointed to by EndPointer. If String has no valid
548 hexadecimal digits right after the optional pad spaces, the value of String
549 is stored at the location pointed to by EndPointer.
551 @param String Pointer to a Null-terminated Unicode string.
552 @param EndPointer Pointer to character that stops scan.
553 @param Data Pointer to the converted value.
555 @retval RETURN_SUCCESS Value is translated from String.
556 @retval RETURN_INVALID_PARAMETER If String is NULL.
558 If PcdMaximumUnicodeStringLength is not
559 zero, and String contains more than
560 PcdMaximumUnicodeStringLength Unicode
561 characters, not including the
563 @retval RETURN_UNSUPPORTED If the number represented by String exceeds
564 the range defined by UINT64.
570 IN CONST CHAR16
*String
,
571 OUT CHAR16
**EndPointer
, OPTIONAL
576 Returns the length of a Null-terminated Ascii string.
578 This function is similar as strlen_s defined in C11.
580 @param String A pointer to a Null-terminated Ascii string.
581 @param MaxSize The maximum number of Destination Ascii
582 char, including terminating null char.
584 @retval 0 If String is NULL.
585 @retval MaxSize If there is no null character in the first MaxSize characters of String.
586 @return The number of characters that percede the terminating null character.
592 IN CONST CHAR8
*String
,
597 Returns the size of a Null-terminated Ascii string in bytes, including the
600 This function returns the size of the Null-terminated Ascii string specified
601 by String in bytes, including the Null terminator.
603 @param String A pointer to a Null-terminated Ascii string.
604 @param MaxSize The maximum number of Destination Ascii
605 char, including the Null terminator.
607 @retval 0 If String is NULL.
608 @retval (sizeof (CHAR8) * (MaxSize + 1))
609 If there is no Null terminator in the first MaxSize characters of
611 @return The size of the Null-terminated Ascii string in bytes, including the
618 IN CONST CHAR8
*String
,
623 Copies the string pointed to by Source (including the terminating null char)
624 to the array pointed to by Destination.
626 This function is similar as strcpy_s defined in C11.
628 If an error is returned, then the Destination is unmodified.
630 @param Destination A pointer to a Null-terminated Ascii string.
631 @param DestMax The maximum number of Destination Ascii
632 char, including terminating null char.
633 @param Source A pointer to a Null-terminated Ascii string.
635 @retval RETURN_SUCCESS String is copied.
636 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
637 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
639 If PcdMaximumAsciiStringLength is not zero,
640 and DestMax is greater than
641 PcdMaximumAsciiStringLength.
643 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
648 OUT CHAR8
*Destination
,
650 IN CONST CHAR8
*Source
654 Copies not more than Length successive char from the string pointed to by
655 Source to the array pointed to by Destination. If no null char is copied from
656 Source, then Destination[Length] is always set to null.
658 This function is similar as strncpy_s defined in C11.
660 If an error is returned, then the Destination is unmodified.
662 @param Destination A pointer to a Null-terminated Ascii string.
663 @param DestMax The maximum number of Destination Ascii
664 char, including terminating null char.
665 @param Source A pointer to a Null-terminated Ascii string.
666 @param Length The maximum number of Ascii characters to copy.
668 @retval RETURN_SUCCESS String is copied.
669 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than
670 MIN(StrLen(Source), Length).
671 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
673 If PcdMaximumAsciiStringLength is not zero,
674 and DestMax is greater than
675 PcdMaximumAsciiStringLength.
677 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
682 OUT CHAR8
*Destination
,
684 IN CONST CHAR8
*Source
,
689 Appends a copy of the string pointed to by Source (including the terminating
690 null char) to the end of the string pointed to by Destination.
692 This function is similar as strcat_s defined in C11.
694 If an error is returned, then the Destination is unmodified.
696 @param Destination A pointer to a Null-terminated Ascii string.
697 @param DestMax The maximum number of Destination Ascii
698 char, including terminating null char.
699 @param Source A pointer to a Null-terminated Ascii string.
701 @retval RETURN_SUCCESS String is appended.
702 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
704 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
705 greater than StrLen(Source).
706 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
708 If PcdMaximumAsciiStringLength is not zero,
709 and DestMax is greater than
710 PcdMaximumAsciiStringLength.
712 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
717 IN OUT CHAR8
*Destination
,
719 IN CONST CHAR8
*Source
723 Appends not more than Length successive char from the string pointed to by
724 Source to the end of the string pointed to by Destination. If no null char is
725 copied from Source, then Destination[StrLen(Destination) + Length] is always
728 This function is similar as strncat_s defined in C11.
730 If an error is returned, then the Destination is unmodified.
732 @param Destination A pointer to a Null-terminated Ascii string.
733 @param DestMax The maximum number of Destination Ascii
734 char, including terminating null char.
735 @param Source A pointer to a Null-terminated Ascii string.
736 @param Length The maximum number of Ascii characters to copy.
738 @retval RETURN_SUCCESS String is appended.
739 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
741 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
742 greater than MIN(StrLen(Source), Length).
743 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
745 If PcdMaximumAsciiStringLength is not zero,
746 and DestMax is greater than
747 PcdMaximumAsciiStringLength.
749 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
754 IN OUT CHAR8
*Destination
,
756 IN CONST CHAR8
*Source
,
761 Convert a Null-terminated Ascii decimal string to a value of type UINTN.
763 This function outputs a value of type UINTN by interpreting the contents of
764 the Ascii string specified by String as a decimal number. The format of the
765 input Ascii string String is:
767 [spaces] [decimal digits].
769 The valid decimal digit character is in the range [0-9]. The function will
770 ignore the pad space, which includes spaces or tab characters, before
771 [decimal digits]. The running zero in the beginning of [decimal digits] will
772 be ignored. Then, the function stops at the first character that is a not a
773 valid decimal character or a Null-terminator, whichever one comes first.
775 If String has no valid decimal digits in the above format, then 0 is stored
776 at the location pointed to by Data.
777 If the number represented by String exceeds the range defined by UINTN, then
778 MAX_UINTN is stored at the location pointed to by Data.
780 If EndPointer is not NULL, a pointer to the character that stopped the scan
781 is stored at the location pointed to by EndPointer. If String has no valid
782 decimal digits right after the optional pad spaces, the value of String is
783 stored at the location pointed to by EndPointer.
785 @param String Pointer to a Null-terminated Ascii string.
786 @param EndPointer Pointer to character that stops scan.
787 @param Data Pointer to the converted value.
789 @retval RETURN_SUCCESS Value is translated from String.
790 @retval RETURN_INVALID_PARAMETER If String is NULL.
792 If PcdMaximumAsciiStringLength is not zero,
793 and String contains more than
794 PcdMaximumAsciiStringLength Ascii
795 characters, not including the
797 @retval RETURN_UNSUPPORTED If the number represented by String exceeds
798 the range defined by UINTN.
803 AsciiStrDecimalToUintnS (
804 IN CONST CHAR8
*String
,
805 OUT CHAR8
**EndPointer
, OPTIONAL
810 Convert a Null-terminated Ascii decimal string to a value of type UINT64.
812 This function outputs a value of type UINT64 by interpreting the contents of
813 the Ascii string specified by String as a decimal number. The format of the
814 input Ascii string String is:
816 [spaces] [decimal digits].
818 The valid decimal digit character is in the range [0-9]. The function will
819 ignore the pad space, which includes spaces or tab characters, before
820 [decimal digits]. The running zero in the beginning of [decimal digits] will
821 be ignored. Then, the function stops at the first character that is a not a
822 valid decimal character or a Null-terminator, whichever one comes first.
824 If String has no valid decimal digits in the above format, then 0 is stored
825 at the location pointed to by Data.
826 If the number represented by String exceeds the range defined by UINT64, then
827 MAX_UINT64 is stored at the location pointed to by Data.
829 If EndPointer is not NULL, a pointer to the character that stopped the scan
830 is stored at the location pointed to by EndPointer. If String has no valid
831 decimal digits right after the optional pad spaces, the value of String is
832 stored at the location pointed to by EndPointer.
834 @param String Pointer to a Null-terminated Ascii string.
835 @param EndPointer Pointer to character that stops scan.
836 @param Data Pointer to the converted value.
838 @retval RETURN_SUCCESS Value is translated from String.
839 @retval RETURN_INVALID_PARAMETER If String is NULL.
841 If PcdMaximumAsciiStringLength is not zero,
842 and String contains more than
843 PcdMaximumAsciiStringLength Ascii
844 characters, not including the
846 @retval RETURN_UNSUPPORTED If the number represented by String exceeds
847 the range defined by UINT64.
852 AsciiStrDecimalToUint64S (
853 IN CONST CHAR8
*String
,
854 OUT CHAR8
**EndPointer
, OPTIONAL
859 Convert a Null-terminated Ascii hexadecimal string to a value of type UINTN.
861 This function outputs a value of type UINTN by interpreting the contents of
862 the Ascii string specified by String as a hexadecimal number. The format of
863 the input Ascii string String is:
865 [spaces][zeros][x][hexadecimal digits].
867 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
868 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If
869 "x" appears in the input string, it must be prefixed with at least one 0. The
870 function will ignore the pad space, which includes spaces or tab characters,
871 before [zeros], [x] or [hexadecimal digits]. The running zero before [x] or
872 [hexadecimal digits] will be ignored. Then, the decoding starts after [x] or
873 the first valid hexadecimal digit. Then, the function stops at the first
874 character that is a not a valid hexadecimal character or Null-terminator,
875 whichever on comes first.
877 If String has no valid hexadecimal digits in the above format, then 0 is
878 stored at the location pointed to by Data.
879 If the number represented by String exceeds the range defined by UINTN, then
880 MAX_UINTN is stored at the location pointed to by Data.
882 If EndPointer is not NULL, a pointer to the character that stopped the scan
883 is stored at the location pointed to by EndPointer. If String has no valid
884 hexadecimal digits right after the optional pad spaces, the value of String
885 is stored at the location pointed to by EndPointer.
887 @param String Pointer to a Null-terminated Ascii string.
888 @param EndPointer Pointer to character that stops scan.
889 @param Data Pointer to the converted value.
891 @retval RETURN_SUCCESS Value is translated from String.
892 @retval RETURN_INVALID_PARAMETER If String is NULL.
894 If PcdMaximumAsciiStringLength is not zero,
895 and String contains more than
896 PcdMaximumAsciiStringLength Ascii
897 characters, not including the
899 @retval RETURN_UNSUPPORTED If the number represented by String exceeds
900 the range defined by UINTN.
905 AsciiStrHexToUintnS (
906 IN CONST CHAR8
*String
,
907 OUT CHAR8
**EndPointer
, OPTIONAL
912 Convert a Null-terminated Ascii hexadecimal string to a value of type UINT64.
914 This function outputs a value of type UINT64 by interpreting the contents of
915 the Ascii string specified by String as a hexadecimal number. The format of
916 the input Ascii string String is:
918 [spaces][zeros][x][hexadecimal digits].
920 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
921 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If
922 "x" appears in the input string, it must be prefixed with at least one 0. The
923 function will ignore the pad space, which includes spaces or tab characters,
924 before [zeros], [x] or [hexadecimal digits]. The running zero before [x] or
925 [hexadecimal digits] will be ignored. Then, the decoding starts after [x] or
926 the first valid hexadecimal digit. Then, the function stops at the first
927 character that is a not a valid hexadecimal character or Null-terminator,
928 whichever on comes first.
930 If String has no valid hexadecimal digits in the above format, then 0 is
931 stored at the location pointed to by Data.
932 If the number represented by String exceeds the range defined by UINT64, then
933 MAX_UINT64 is stored at the location pointed to by Data.
935 If EndPointer is not NULL, a pointer to the character that stopped the scan
936 is stored at the location pointed to by EndPointer. If String has no valid
937 hexadecimal digits right after the optional pad spaces, the value of String
938 is stored at the location pointed to by EndPointer.
940 @param String Pointer to a Null-terminated Ascii string.
941 @param EndPointer Pointer to character that stops scan.
942 @param Data Pointer to the converted value.
944 @retval RETURN_SUCCESS Value is translated from String.
945 @retval RETURN_INVALID_PARAMETER If String is NULL.
947 If PcdMaximumAsciiStringLength is not zero,
948 and String contains more than
949 PcdMaximumAsciiStringLength Ascii
950 characters, not including the
952 @retval RETURN_UNSUPPORTED If the number represented by String exceeds
953 the range defined by UINT64.
958 AsciiStrHexToUint64S (
959 IN CONST CHAR8
*String
,
960 OUT CHAR8
**EndPointer
, OPTIONAL
966 Returns the length of a Null-terminated Unicode string.
968 This function returns the number of Unicode characters in the Null-terminated
969 Unicode string specified by String.
971 If String is NULL, then ASSERT().
972 If String is not aligned on a 16-bit boundary, then ASSERT().
973 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
974 PcdMaximumUnicodeStringLength Unicode characters not including the
975 Null-terminator, then ASSERT().
977 @param String Pointer to a Null-terminated Unicode string.
979 @return The length of String.
985 IN CONST CHAR16
*String
990 Returns the size of a Null-terminated Unicode string in bytes, including the
993 This function returns the size, in bytes, of the Null-terminated Unicode string
996 If String is NULL, then ASSERT().
997 If String is not aligned on a 16-bit boundary, then ASSERT().
998 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
999 PcdMaximumUnicodeStringLength Unicode characters not including the
1000 Null-terminator, then ASSERT().
1002 @param String The pointer to a Null-terminated Unicode string.
1004 @return The size of String.
1010 IN CONST CHAR16
*String
1015 Compares two Null-terminated Unicode strings, and returns the difference
1016 between the first mismatched Unicode characters.
1018 This function compares the Null-terminated Unicode string FirstString to the
1019 Null-terminated Unicode string SecondString. If FirstString is identical to
1020 SecondString, then 0 is returned. Otherwise, the value returned is the first
1021 mismatched Unicode character in SecondString subtracted from the first
1022 mismatched Unicode character in FirstString.
1024 If FirstString is NULL, then ASSERT().
1025 If FirstString is not aligned on a 16-bit boundary, then ASSERT().
1026 If SecondString is NULL, then ASSERT().
1027 If SecondString is not aligned on a 16-bit boundary, then ASSERT().
1028 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
1029 than PcdMaximumUnicodeStringLength Unicode characters not including the
1030 Null-terminator, then ASSERT().
1031 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
1032 than PcdMaximumUnicodeStringLength Unicode characters, not including the
1033 Null-terminator, then ASSERT().
1035 @param FirstString The pointer to a Null-terminated Unicode string.
1036 @param SecondString The pointer to a Null-terminated Unicode string.
1038 @retval 0 FirstString is identical to SecondString.
1039 @return others FirstString is not identical to SecondString.
1045 IN CONST CHAR16
*FirstString
,
1046 IN CONST CHAR16
*SecondString
1051 Compares up to a specified length the contents of two Null-terminated Unicode strings,
1052 and returns the difference between the first mismatched Unicode characters.
1054 This function compares the Null-terminated Unicode string FirstString to the
1055 Null-terminated Unicode string SecondString. At most, Length Unicode
1056 characters will be compared. If Length is 0, then 0 is returned. If
1057 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
1058 value returned is the first mismatched Unicode character in SecondString
1059 subtracted from the first mismatched Unicode character in FirstString.
1061 If Length > 0 and FirstString is NULL, then ASSERT().
1062 If Length > 0 and FirstString is not aligned on a 16-bit boundary, then ASSERT().
1063 If Length > 0 and SecondString is NULL, then ASSERT().
1064 If Length > 0 and SecondString is not aligned on a 16-bit boundary, then ASSERT().
1065 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
1066 PcdMaximumUnicodeStringLength, then ASSERT().
1067 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more than
1068 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
1070 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more than
1071 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
1074 @param FirstString The pointer to a Null-terminated Unicode string.
1075 @param SecondString The pointer to a Null-terminated Unicode string.
1076 @param Length The maximum number of Unicode characters to compare.
1078 @retval 0 FirstString is identical to SecondString.
1079 @return others FirstString is not identical to SecondString.
1085 IN CONST CHAR16
*FirstString
,
1086 IN CONST CHAR16
*SecondString
,
1092 Returns the first occurrence of a Null-terminated Unicode sub-string
1093 in a Null-terminated Unicode string.
1095 This function scans the contents of the Null-terminated Unicode string
1096 specified by String and returns the first occurrence of SearchString.
1097 If SearchString is not found in String, then NULL is returned. If
1098 the length of SearchString is zero, then String is returned.
1100 If String is NULL, then ASSERT().
1101 If String is not aligned on a 16-bit boundary, then ASSERT().
1102 If SearchString is NULL, then ASSERT().
1103 If SearchString is not aligned on a 16-bit boundary, then ASSERT().
1105 If PcdMaximumUnicodeStringLength is not zero, and SearchString
1106 or String contains more than PcdMaximumUnicodeStringLength Unicode
1107 characters, not including the Null-terminator, then ASSERT().
1109 @param String The pointer to a Null-terminated Unicode string.
1110 @param SearchString The pointer to a Null-terminated Unicode string to search for.
1112 @retval NULL If the SearchString does not appear in String.
1113 @return others If there is a match.
1119 IN CONST CHAR16
*String
,
1120 IN CONST CHAR16
*SearchString
1124 Convert a Null-terminated Unicode decimal string to a value of
1127 This function returns a value of type UINTN by interpreting the contents
1128 of the Unicode string specified by String as a decimal number. The format
1129 of the input Unicode string String is:
1131 [spaces] [decimal digits].
1133 The valid decimal digit character is in the range [0-9]. The
1134 function will ignore the pad space, which includes spaces or
1135 tab characters, before [decimal digits]. The running zero in the
1136 beginning of [decimal digits] will be ignored. Then, the function
1137 stops at the first character that is a not a valid decimal character
1138 or a Null-terminator, whichever one comes first.
1140 If String is NULL, then ASSERT().
1141 If String is not aligned in a 16-bit boundary, then ASSERT().
1142 If String has only pad spaces, then 0 is returned.
1143 If String has no pad spaces or valid decimal digits,
1145 If the number represented by String overflows according
1146 to the range defined by UINTN, then MAX_UINTN is returned.
1148 If PcdMaximumUnicodeStringLength is not zero, and String contains
1149 more than PcdMaximumUnicodeStringLength Unicode characters not including
1150 the Null-terminator, then ASSERT().
1152 @param String The pointer to a Null-terminated Unicode string.
1154 @retval Value translated from String.
1160 IN CONST CHAR16
*String
1164 Convert a Null-terminated Unicode decimal string to a value of
1167 This function returns a value of type UINT64 by interpreting the contents
1168 of the Unicode string specified by String as a decimal number. The format
1169 of the input Unicode string String is:
1171 [spaces] [decimal digits].
1173 The valid decimal digit character is in the range [0-9]. The
1174 function will ignore the pad space, which includes spaces or
1175 tab characters, before [decimal digits]. The running zero in the
1176 beginning of [decimal digits] will be ignored. Then, the function
1177 stops at the first character that is a not a valid decimal character
1178 or a Null-terminator, whichever one comes first.
1180 If String is NULL, then ASSERT().
1181 If String is not aligned in a 16-bit boundary, then ASSERT().
1182 If String has only pad spaces, then 0 is returned.
1183 If String has no pad spaces or valid decimal digits,
1185 If the number represented by String overflows according
1186 to the range defined by UINT64, then MAX_UINT64 is returned.
1188 If PcdMaximumUnicodeStringLength is not zero, and String contains
1189 more than PcdMaximumUnicodeStringLength Unicode characters not including
1190 the Null-terminator, then ASSERT().
1192 @param String The pointer to a Null-terminated Unicode string.
1194 @retval Value translated from String.
1199 StrDecimalToUint64 (
1200 IN CONST CHAR16
*String
1205 Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.
1207 This function returns a value of type UINTN by interpreting the contents
1208 of the Unicode string specified by String as a hexadecimal number.
1209 The format of the input Unicode string String is:
1211 [spaces][zeros][x][hexadecimal digits].
1213 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1214 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
1215 If "x" appears in the input string, it must be prefixed with at least one 0.
1216 The function will ignore the pad space, which includes spaces or tab characters,
1217 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
1218 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
1219 first valid hexadecimal digit. Then, the function stops at the first character
1220 that is a not a valid hexadecimal character or NULL, whichever one comes first.
1222 If String is NULL, then ASSERT().
1223 If String is not aligned in a 16-bit boundary, then ASSERT().
1224 If String has only pad spaces, then zero is returned.
1225 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
1226 then zero is returned.
1227 If the number represented by String overflows according to the range defined by
1228 UINTN, then MAX_UINTN is returned.
1230 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
1231 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
1234 @param String The pointer to a Null-terminated Unicode string.
1236 @retval Value translated from String.
1242 IN CONST CHAR16
*String
1247 Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.
1249 This function returns a value of type UINT64 by interpreting the contents
1250 of the Unicode string specified by String as a hexadecimal number.
1251 The format of the input Unicode string String is
1253 [spaces][zeros][x][hexadecimal digits].
1255 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1256 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
1257 If "x" appears in the input string, it must be prefixed with at least one 0.
1258 The function will ignore the pad space, which includes spaces or tab characters,
1259 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
1260 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
1261 first valid hexadecimal digit. Then, the function stops at the first character that is
1262 a not a valid hexadecimal character or NULL, whichever one comes first.
1264 If String is NULL, then ASSERT().
1265 If String is not aligned in a 16-bit boundary, then ASSERT().
1266 If String has only pad spaces, then zero is returned.
1267 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
1268 then zero is returned.
1269 If the number represented by String overflows according to the range defined by
1270 UINT64, then MAX_UINT64 is returned.
1272 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
1273 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
1276 @param String The pointer to a Null-terminated Unicode string.
1278 @retval Value translated from String.
1284 IN CONST CHAR16
*String
1288 Convert a Null-terminated Unicode string to IPv6 address and prefix length.
1290 This function outputs a value of type IPv6_ADDRESS and may output a value
1291 of type UINT8 by interpreting the contents of the Unicode string specified
1292 by String. The format of the input Unicode string String is as follows:
1296 X contains one to four hexadecimal digit characters in the range [0-9], [a-f] and
1297 [A-F]. X is converted to a value of type UINT16, whose low byte is stored in low
1298 memory address and high byte is stored in high memory address. P contains decimal
1299 digit characters in the range [0-9]. The running zero in the beginning of P will
1300 be ignored. /P is optional.
1302 When /P is not in the String, the function stops at the first character that is
1303 not a valid hexadecimal digit character after eight X's are converted.
1305 When /P is in the String, the function stops at the first character that is not
1306 a valid decimal digit character after P is converted.
1308 "::" can be used to compress one or more groups of X when X contains only 0.
1309 The "::" can only appear once in the String.
1311 If String is not aligned in a 16-bit boundary, then ASSERT().
1313 If EndPointer is not NULL and Address is translated from String, a pointer
1314 to the character that stopped the scan is stored at the location pointed to
1317 @param String Pointer to a Null-terminated Unicode string.
1318 @param EndPointer Pointer to character that stops scan.
1319 @param Address Pointer to the converted IPv6 address.
1320 @param PrefixLength Pointer to the converted IPv6 address prefix
1321 length. MAX_UINT8 is returned when /P is
1324 @retval RETURN_SUCCESS Address is translated from String.
1325 @retval RETURN_INVALID_PARAMETER If String is NULL.
1327 @retval RETURN_UNSUPPORTED If X contains more than four hexadecimal
1329 If String contains "::" and number of X
1331 If P starts with character that is not a
1332 valid decimal digit character.
1333 If the decimal number converted from P
1340 IN CONST CHAR16
*String
,
1341 OUT CHAR16
**EndPointer
, OPTIONAL
1342 OUT IPv6_ADDRESS
*Address
,
1343 OUT UINT8
*PrefixLength OPTIONAL
1347 Convert a Null-terminated Unicode string to IPv4 address and prefix length.
1349 This function outputs a value of type IPv4_ADDRESS and may output a value
1350 of type UINT8 by interpreting the contents of the Unicode string specified
1351 by String. The format of the input Unicode string String is as follows:
1355 D and P are decimal digit characters in the range [0-9]. The running zero in
1356 the beginning of D and P will be ignored. /P is optional.
1358 When /P is not in the String, the function stops at the first character that is
1359 not a valid decimal digit character after four D's are converted.
1361 When /P is in the String, the function stops at the first character that is not
1362 a valid decimal digit character after P is converted.
1364 If String is not aligned in a 16-bit boundary, then ASSERT().
1366 If EndPointer is not NULL and Address is translated from String, a pointer
1367 to the character that stopped the scan is stored at the location pointed to
1370 @param String Pointer to a Null-terminated Unicode string.
1371 @param EndPointer Pointer to character that stops scan.
1372 @param Address Pointer to the converted IPv4 address.
1373 @param PrefixLength Pointer to the converted IPv4 address prefix
1374 length. MAX_UINT8 is returned when /P is
1377 @retval RETURN_SUCCESS Address is translated from String.
1378 @retval RETURN_INVALID_PARAMETER If String is NULL.
1380 @retval RETURN_UNSUPPORTED If String is not in the correct format.
1381 If any decimal number converted from D
1383 If the decimal number converted from P
1390 IN CONST CHAR16
*String
,
1391 OUT CHAR16
**EndPointer
, OPTIONAL
1392 OUT IPv4_ADDRESS
*Address
,
1393 OUT UINT8
*PrefixLength OPTIONAL
1396 #define GUID_STRING_LENGTH 36
1399 Convert a Null-terminated Unicode GUID string to a value of type
1402 This function outputs a GUID value by interpreting the contents of
1403 the Unicode string specified by String. The format of the input
1404 Unicode string String consists of 36 characters, as follows:
1406 aabbccdd-eeff-gghh-iijj-kkllmmnnoopp
1408 The pairs aa - pp are two characters in the range [0-9], [a-f] and
1409 [A-F], with each pair representing a single byte hexadecimal value.
1411 The mapping between String and the EFI_GUID structure is as follows:
1429 If String is not aligned in a 16-bit boundary, then ASSERT().
1431 @param String Pointer to a Null-terminated Unicode string.
1432 @param Guid Pointer to the converted GUID.
1434 @retval RETURN_SUCCESS Guid is translated from String.
1435 @retval RETURN_INVALID_PARAMETER If String is NULL.
1437 @retval RETURN_UNSUPPORTED If String is not as the above format.
1443 IN CONST CHAR16
*String
,
1448 Convert a Null-terminated Unicode hexadecimal string to a byte array.
1450 This function outputs a byte array by interpreting the contents of
1451 the Unicode string specified by String in hexadecimal format. The format of
1452 the input Unicode string String is:
1456 X is a hexadecimal digit character in the range [0-9], [a-f] and [A-F].
1457 The function decodes every two hexadecimal digit characters as one byte. The
1458 decoding stops after Length of characters and outputs Buffer containing
1461 If String is not aligned in a 16-bit boundary, then ASSERT().
1463 @param String Pointer to a Null-terminated Unicode string.
1464 @param Length The number of Unicode characters to decode.
1465 @param Buffer Pointer to the converted bytes array.
1466 @param MaxBufferSize The maximum size of Buffer.
1468 @retval RETURN_SUCCESS Buffer is translated from String.
1469 @retval RETURN_INVALID_PARAMETER If String is NULL.
1471 If Length is not multiple of 2.
1472 If PcdMaximumUnicodeStringLength is not zero,
1473 and Length is greater than
1474 PcdMaximumUnicodeStringLength.
1475 @retval RETURN_UNSUPPORTED If Length of characters from String contain
1476 a character that is not valid hexadecimal
1477 digit characters, or a Null-terminator.
1478 @retval RETURN_BUFFER_TOO_SMALL If MaxBufferSize is less than (Length / 2).
1483 IN CONST CHAR16
*String
,
1486 IN UINTN MaxBufferSize
1491 Convert a Null-terminated Unicode string to a Null-terminated
1494 This function is similar to AsciiStrCpyS.
1496 This function converts the content of the Unicode string Source
1497 to the ASCII string Destination by copying the lower 8 bits of
1498 each Unicode character. The function terminates the ASCII string
1499 Destination by appending a Null-terminator character at the end.
1501 The caller is responsible to make sure Destination points to a buffer with size
1502 equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.
1504 If any Unicode characters in Source contain non-zero value in
1505 the upper 8 bits, then ASSERT().
1507 If Source is not aligned on a 16-bit boundary, then ASSERT().
1509 If an error is returned, then the Destination is unmodified.
1511 @param Source The pointer to a Null-terminated Unicode string.
1512 @param Destination The pointer to a Null-terminated ASCII string.
1513 @param DestMax The maximum number of Destination Ascii
1514 char, including terminating null char.
1516 @retval RETURN_SUCCESS String is converted.
1517 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
1518 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
1520 If PcdMaximumAsciiStringLength is not zero,
1521 and DestMax is greater than
1522 PcdMaximumAsciiStringLength.
1523 If PcdMaximumUnicodeStringLength is not zero,
1524 and DestMax is greater than
1525 PcdMaximumUnicodeStringLength.
1527 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
1532 UnicodeStrToAsciiStrS (
1533 IN CONST CHAR16
*Source
,
1534 OUT CHAR8
*Destination
,
1539 Convert not more than Length successive characters from a Null-terminated
1540 Unicode string to a Null-terminated Ascii string. If no null char is copied
1541 from Source, then Destination[Length] is always set to null.
1543 This function converts not more than Length successive characters from the
1544 Unicode string Source to the Ascii string Destination by copying the lower 8
1545 bits of each Unicode character. The function terminates the Ascii string
1546 Destination by appending a Null-terminator character at the end.
1548 The caller is responsible to make sure Destination points to a buffer with size
1549 equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.
1551 If any Unicode characters in Source contain non-zero value in the upper 8
1552 bits, then ASSERT().
1553 If Source is not aligned on a 16-bit boundary, then ASSERT().
1555 If an error is returned, then the Destination is unmodified.
1557 @param Source The pointer to a Null-terminated Unicode string.
1558 @param Length The maximum number of Unicode characters to
1560 @param Destination The pointer to a Null-terminated Ascii string.
1561 @param DestMax The maximum number of Destination Ascii
1562 char, including terminating null char.
1563 @param DestinationLength The number of Unicode characters converted.
1565 @retval RETURN_SUCCESS String is converted.
1566 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
1568 If DestinationLength is NULL.
1569 If PcdMaximumAsciiStringLength is not zero,
1570 and Length or DestMax is greater than
1571 PcdMaximumAsciiStringLength.
1572 If PcdMaximumUnicodeStringLength is not
1573 zero, and Length or DestMax is greater than
1574 PcdMaximumUnicodeStringLength.
1576 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than
1577 MIN(StrLen(Source), Length).
1578 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
1583 UnicodeStrnToAsciiStrS (
1584 IN CONST CHAR16
*Source
,
1586 OUT CHAR8
*Destination
,
1588 OUT UINTN
*DestinationLength
1593 Returns the length of a Null-terminated ASCII string.
1595 This function returns the number of ASCII characters in the Null-terminated
1596 ASCII string specified by String.
1598 If Length > 0 and Destination is NULL, then ASSERT().
1599 If Length > 0 and Source is NULL, then ASSERT().
1600 If PcdMaximumAsciiStringLength is not zero and String contains more than
1601 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1604 @param String The pointer to a Null-terminated ASCII string.
1606 @return The length of String.
1612 IN CONST CHAR8
*String
1617 Returns the size of a Null-terminated ASCII string in bytes, including the
1620 This function returns the size, in bytes, of the Null-terminated ASCII string
1621 specified by String.
1623 If String is NULL, then ASSERT().
1624 If PcdMaximumAsciiStringLength is not zero and String contains more than
1625 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1628 @param String The pointer to a Null-terminated ASCII string.
1630 @return The size of String.
1636 IN CONST CHAR8
*String
1641 Compares two Null-terminated ASCII strings, and returns the difference
1642 between the first mismatched ASCII characters.
1644 This function compares the Null-terminated ASCII string FirstString to the
1645 Null-terminated ASCII string SecondString. If FirstString is identical to
1646 SecondString, then 0 is returned. Otherwise, the value returned is the first
1647 mismatched ASCII character in SecondString subtracted from the first
1648 mismatched ASCII character in FirstString.
1650 If FirstString is NULL, then ASSERT().
1651 If SecondString is NULL, then ASSERT().
1652 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
1653 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1655 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
1656 than PcdMaximumAsciiStringLength ASCII characters not including the
1657 Null-terminator, then ASSERT().
1659 @param FirstString The pointer to a Null-terminated ASCII string.
1660 @param SecondString The pointer to a Null-terminated ASCII string.
1662 @retval ==0 FirstString is identical to SecondString.
1663 @retval !=0 FirstString is not identical to SecondString.
1669 IN CONST CHAR8
*FirstString
,
1670 IN CONST CHAR8
*SecondString
1675 Performs a case insensitive comparison of two Null-terminated ASCII strings,
1676 and returns the difference between the first mismatched ASCII characters.
1678 This function performs a case insensitive comparison of the Null-terminated
1679 ASCII string FirstString to the Null-terminated ASCII string SecondString. If
1680 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
1681 value returned is the first mismatched lower case ASCII character in
1682 SecondString subtracted from the first mismatched lower case ASCII character
1685 If FirstString is NULL, then ASSERT().
1686 If SecondString is NULL, then ASSERT().
1687 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
1688 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1690 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
1691 than PcdMaximumAsciiStringLength ASCII characters not including the
1692 Null-terminator, then ASSERT().
1694 @param FirstString The pointer to a Null-terminated ASCII string.
1695 @param SecondString The pointer to a Null-terminated ASCII string.
1697 @retval ==0 FirstString is identical to SecondString using case insensitive
1699 @retval !=0 FirstString is not identical to SecondString using case
1700 insensitive comparisons.
1706 IN CONST CHAR8
*FirstString
,
1707 IN CONST CHAR8
*SecondString
1712 Compares two Null-terminated ASCII strings with maximum lengths, and returns
1713 the difference between the first mismatched ASCII characters.
1715 This function compares the Null-terminated ASCII string FirstString to the
1716 Null-terminated ASCII string SecondString. At most, Length ASCII characters
1717 will be compared. If Length is 0, then 0 is returned. If FirstString is
1718 identical to SecondString, then 0 is returned. Otherwise, the value returned
1719 is the first mismatched ASCII character in SecondString subtracted from the
1720 first mismatched ASCII character in FirstString.
1722 If Length > 0 and FirstString is NULL, then ASSERT().
1723 If Length > 0 and SecondString is NULL, then ASSERT().
1724 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
1725 PcdMaximumAsciiStringLength, then ASSERT().
1726 If PcdMaximumAsciiStringLength is not zero, and FirstString contains more than
1727 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1729 If PcdMaximumAsciiStringLength is not zero, and SecondString contains more than
1730 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1733 @param FirstString The pointer to a Null-terminated ASCII string.
1734 @param SecondString The pointer to a Null-terminated ASCII string.
1735 @param Length The maximum number of ASCII characters for compare.
1737 @retval ==0 FirstString is identical to SecondString.
1738 @retval !=0 FirstString is not identical to SecondString.
1744 IN CONST CHAR8
*FirstString
,
1745 IN CONST CHAR8
*SecondString
,
1751 Returns the first occurrence of a Null-terminated ASCII sub-string
1752 in a Null-terminated ASCII string.
1754 This function scans the contents of the ASCII string specified by String
1755 and returns the first occurrence of SearchString. If SearchString is not
1756 found in String, then NULL is returned. If the length of SearchString is zero,
1757 then String is returned.
1759 If String is NULL, then ASSERT().
1760 If SearchString is NULL, then ASSERT().
1762 If PcdMaximumAsciiStringLength is not zero, and SearchString or
1763 String contains more than PcdMaximumAsciiStringLength Unicode characters
1764 not including the Null-terminator, then ASSERT().
1766 @param String The pointer to a Null-terminated ASCII string.
1767 @param SearchString The pointer to a Null-terminated ASCII string to search for.
1769 @retval NULL If the SearchString does not appear in String.
1770 @retval others If there is a match return the first occurrence of SearchingString.
1771 If the length of SearchString is zero,return String.
1777 IN CONST CHAR8
*String
,
1778 IN CONST CHAR8
*SearchString
1783 Convert a Null-terminated ASCII decimal string to a value of type
1786 This function returns a value of type UINTN by interpreting the contents
1787 of the ASCII string String as a decimal number. The format of the input
1788 ASCII string String is:
1790 [spaces] [decimal digits].
1792 The valid decimal digit character is in the range [0-9]. The function will
1793 ignore the pad space, which includes spaces or tab characters, before the digits.
1794 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1795 function stops at the first character that is a not a valid decimal character or
1796 Null-terminator, whichever on comes first.
1798 If String has only pad spaces, then 0 is returned.
1799 If String has no pad spaces or valid decimal digits, then 0 is returned.
1800 If the number represented by String overflows according to the range defined by
1801 UINTN, then MAX_UINTN is returned.
1802 If String is NULL, then ASSERT().
1803 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1804 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1807 @param String The pointer to a Null-terminated ASCII string.
1809 @retval The value translated from String.
1814 AsciiStrDecimalToUintn (
1815 IN CONST CHAR8
*String
1820 Convert a Null-terminated ASCII decimal string to a value of type
1823 This function returns a value of type UINT64 by interpreting the contents
1824 of the ASCII string String as a decimal number. The format of the input
1825 ASCII string String is:
1827 [spaces] [decimal digits].
1829 The valid decimal digit character is in the range [0-9]. The function will
1830 ignore the pad space, which includes spaces or tab characters, before the digits.
1831 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1832 function stops at the first character that is a not a valid decimal character or
1833 Null-terminator, whichever on comes first.
1835 If String has only pad spaces, then 0 is returned.
1836 If String has no pad spaces or valid decimal digits, then 0 is returned.
1837 If the number represented by String overflows according to the range defined by
1838 UINT64, then MAX_UINT64 is returned.
1839 If String is NULL, then ASSERT().
1840 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1841 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1844 @param String The pointer to a Null-terminated ASCII string.
1846 @retval Value translated from String.
1851 AsciiStrDecimalToUint64 (
1852 IN CONST CHAR8
*String
1857 Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.
1859 This function returns a value of type UINTN by interpreting the contents of
1860 the ASCII string String as a hexadecimal number. The format of the input ASCII
1863 [spaces][zeros][x][hexadecimal digits].
1865 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1866 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1867 appears in the input string, it must be prefixed with at least one 0. The function
1868 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1869 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1870 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1871 digit. Then, the function stops at the first character that is a not a valid
1872 hexadecimal character or Null-terminator, whichever on comes first.
1874 If String has only pad spaces, then 0 is returned.
1875 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1878 If the number represented by String overflows according to the range defined by UINTN,
1879 then MAX_UINTN is returned.
1880 If String is NULL, then ASSERT().
1881 If PcdMaximumAsciiStringLength is not zero,
1882 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1883 the Null-terminator, then ASSERT().
1885 @param String The pointer to a Null-terminated ASCII string.
1887 @retval Value translated from String.
1892 AsciiStrHexToUintn (
1893 IN CONST CHAR8
*String
1898 Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.
1900 This function returns a value of type UINT64 by interpreting the contents of
1901 the ASCII string String as a hexadecimal number. The format of the input ASCII
1904 [spaces][zeros][x][hexadecimal digits].
1906 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1907 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1908 appears in the input string, it must be prefixed with at least one 0. The function
1909 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1910 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1911 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1912 digit. Then, the function stops at the first character that is a not a valid
1913 hexadecimal character or Null-terminator, whichever on comes first.
1915 If String has only pad spaces, then 0 is returned.
1916 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1919 If the number represented by String overflows according to the range defined by UINT64,
1920 then MAX_UINT64 is returned.
1921 If String is NULL, then ASSERT().
1922 If PcdMaximumAsciiStringLength is not zero,
1923 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1924 the Null-terminator, then ASSERT().
1926 @param String The pointer to a Null-terminated ASCII string.
1928 @retval Value translated from String.
1933 AsciiStrHexToUint64 (
1934 IN CONST CHAR8
*String
1938 Convert a Null-terminated ASCII string to IPv6 address and prefix length.
1940 This function outputs a value of type IPv6_ADDRESS and may output a value
1941 of type UINT8 by interpreting the contents of the ASCII string specified
1942 by String. The format of the input ASCII string String is as follows:
1946 X contains one to four hexadecimal digit characters in the range [0-9], [a-f] and
1947 [A-F]. X is converted to a value of type UINT16, whose low byte is stored in low
1948 memory address and high byte is stored in high memory address. P contains decimal
1949 digit characters in the range [0-9]. The running zero in the beginning of P will
1950 be ignored. /P is optional.
1952 When /P is not in the String, the function stops at the first character that is
1953 not a valid hexadecimal digit character after eight X's are converted.
1955 When /P is in the String, the function stops at the first character that is not
1956 a valid decimal digit character after P is converted.
1958 "::" can be used to compress one or more groups of X when X contains only 0.
1959 The "::" can only appear once in the String.
1961 If EndPointer is not NULL and Address is translated from String, a pointer
1962 to the character that stopped the scan is stored at the location pointed to
1965 @param String Pointer to a Null-terminated ASCII string.
1966 @param EndPointer Pointer to character that stops scan.
1967 @param Address Pointer to the converted IPv6 address.
1968 @param PrefixLength Pointer to the converted IPv6 address prefix
1969 length. MAX_UINT8 is returned when /P is
1972 @retval RETURN_SUCCESS Address is translated from String.
1973 @retval RETURN_INVALID_PARAMETER If String is NULL.
1975 @retval RETURN_UNSUPPORTED If X contains more than four hexadecimal
1977 If String contains "::" and number of X
1979 If P starts with character that is not a
1980 valid decimal digit character.
1981 If the decimal number converted from P
1987 AsciiStrToIpv6Address (
1988 IN CONST CHAR8
*String
,
1989 OUT CHAR8
**EndPointer
, OPTIONAL
1990 OUT IPv6_ADDRESS
*Address
,
1991 OUT UINT8
*PrefixLength OPTIONAL
1995 Convert a Null-terminated ASCII string to IPv4 address and prefix length.
1997 This function outputs a value of type IPv4_ADDRESS and may output a value
1998 of type UINT8 by interpreting the contents of the ASCII string specified
1999 by String. The format of the input ASCII string String is as follows:
2003 D and P are decimal digit characters in the range [0-9]. The running zero in
2004 the beginning of D and P will be ignored. /P is optional.
2006 When /P is not in the String, the function stops at the first character that is
2007 not a valid decimal digit character after four D's are converted.
2009 When /P is in the String, the function stops at the first character that is not
2010 a valid decimal digit character after P is converted.
2012 If EndPointer is not NULL and Address is translated from String, a pointer
2013 to the character that stopped the scan is stored at the location pointed to
2016 @param String Pointer to a Null-terminated ASCII string.
2017 @param EndPointer Pointer to character that stops scan.
2018 @param Address Pointer to the converted IPv4 address.
2019 @param PrefixLength Pointer to the converted IPv4 address prefix
2020 length. MAX_UINT8 is returned when /P is
2023 @retval RETURN_SUCCESS Address is translated from String.
2024 @retval RETURN_INVALID_PARAMETER If String is NULL.
2026 @retval RETURN_UNSUPPORTED If String is not in the correct format.
2027 If any decimal number converted from D
2029 If the decimal number converted from P
2035 AsciiStrToIpv4Address (
2036 IN CONST CHAR8
*String
,
2037 OUT CHAR8
**EndPointer
, OPTIONAL
2038 OUT IPv4_ADDRESS
*Address
,
2039 OUT UINT8
*PrefixLength OPTIONAL
2043 Convert a Null-terminated ASCII GUID string to a value of type
2046 This function outputs a GUID value by interpreting the contents of
2047 the ASCII string specified by String. The format of the input
2048 ASCII string String consists of 36 characters, as follows:
2050 aabbccdd-eeff-gghh-iijj-kkllmmnnoopp
2052 The pairs aa - pp are two characters in the range [0-9], [a-f] and
2053 [A-F], with each pair representing a single byte hexadecimal value.
2055 The mapping between String and the EFI_GUID structure is as follows:
2073 @param String Pointer to a Null-terminated ASCII string.
2074 @param Guid Pointer to the converted GUID.
2076 @retval RETURN_SUCCESS Guid is translated from String.
2077 @retval RETURN_INVALID_PARAMETER If String is NULL.
2079 @retval RETURN_UNSUPPORTED If String is not as the above format.
2085 IN CONST CHAR8
*String
,
2090 Convert a Null-terminated ASCII hexadecimal string to a byte array.
2092 This function outputs a byte array by interpreting the contents of
2093 the ASCII string specified by String in hexadecimal format. The format of
2094 the input ASCII string String is:
2098 X is a hexadecimal digit character in the range [0-9], [a-f] and [A-F].
2099 The function decodes every two hexadecimal digit characters as one byte. The
2100 decoding stops after Length of characters and outputs Buffer containing
2103 @param String Pointer to a Null-terminated ASCII string.
2104 @param Length The number of ASCII characters to decode.
2105 @param Buffer Pointer to the converted bytes array.
2106 @param MaxBufferSize The maximum size of Buffer.
2108 @retval RETURN_SUCCESS Buffer is translated from String.
2109 @retval RETURN_INVALID_PARAMETER If String is NULL.
2111 If Length is not multiple of 2.
2112 If PcdMaximumAsciiStringLength is not zero,
2113 and Length is greater than
2114 PcdMaximumAsciiStringLength.
2115 @retval RETURN_UNSUPPORTED If Length of characters from String contain
2116 a character that is not valid hexadecimal
2117 digit characters, or a Null-terminator.
2118 @retval RETURN_BUFFER_TOO_SMALL If MaxBufferSize is less than (Length / 2).
2122 AsciiStrHexToBytes (
2123 IN CONST CHAR8
*String
,
2126 IN UINTN MaxBufferSize
2131 Convert one Null-terminated ASCII string to a Null-terminated
2134 This function is similar to StrCpyS.
2136 This function converts the contents of the ASCII string Source to the Unicode
2137 string Destination. The function terminates the Unicode string Destination by
2138 appending a Null-terminator character at the end.
2140 The caller is responsible to make sure Destination points to a buffer with size
2141 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
2143 If Destination is not aligned on a 16-bit boundary, then ASSERT().
2145 If an error is returned, then the Destination is unmodified.
2147 @param Source The pointer to a Null-terminated ASCII string.
2148 @param Destination The pointer to a Null-terminated Unicode string.
2149 @param DestMax The maximum number of Destination Unicode
2150 char, including terminating null char.
2152 @retval RETURN_SUCCESS String is converted.
2153 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
2154 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
2156 If PcdMaximumUnicodeStringLength is not zero,
2157 and DestMax is greater than
2158 PcdMaximumUnicodeStringLength.
2159 If PcdMaximumAsciiStringLength is not zero,
2160 and DestMax is greater than
2161 PcdMaximumAsciiStringLength.
2163 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
2168 AsciiStrToUnicodeStrS (
2169 IN CONST CHAR8
*Source
,
2170 OUT CHAR16
*Destination
,
2175 Convert not more than Length successive characters from a Null-terminated
2176 Ascii string to a Null-terminated Unicode string. If no null char is copied
2177 from Source, then Destination[Length] is always set to null.
2179 This function converts not more than Length successive characters from the
2180 Ascii string Source to the Unicode string Destination. The function
2181 terminates the Unicode string Destination by appending a Null-terminator
2182 character at the end.
2184 The caller is responsible to make sure Destination points to a buffer with
2185 size not smaller than
2186 ((MIN(AsciiStrLen(Source), Length) + 1) * sizeof (CHAR8)) in bytes.
2188 If Destination is not aligned on a 16-bit boundary, then ASSERT().
2190 If an error is returned, then Destination and DestinationLength are
2193 @param Source The pointer to a Null-terminated Ascii string.
2194 @param Length The maximum number of Ascii characters to convert.
2195 @param Destination The pointer to a Null-terminated Unicode string.
2196 @param DestMax The maximum number of Destination Unicode char,
2197 including terminating null char.
2198 @param DestinationLength The number of Ascii characters converted.
2200 @retval RETURN_SUCCESS String is converted.
2201 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
2203 If DestinationLength is NULL.
2204 If PcdMaximumUnicodeStringLength is not
2205 zero, and Length or DestMax is greater than
2206 PcdMaximumUnicodeStringLength.
2207 If PcdMaximumAsciiStringLength is not zero,
2208 and Length or DestMax is greater than
2209 PcdMaximumAsciiStringLength.
2211 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than
2212 MIN(AsciiStrLen(Source), Length).
2213 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
2218 AsciiStrnToUnicodeStrS (
2219 IN CONST CHAR8
*Source
,
2221 OUT CHAR16
*Destination
,
2223 OUT UINTN
*DestinationLength
2227 Convert a Unicode character to upper case only if
2228 it maps to a valid small-case ASCII character.
2230 This internal function only deal with Unicode character
2231 which maps to a valid small-case ASCII character, i.e.
2232 L'a' to L'z'. For other Unicode character, the input character
2233 is returned directly.
2235 @param Char The character to convert.
2237 @retval LowerCharacter If the Char is with range L'a' to L'z'.
2238 @retval Unchanged Otherwise.
2248 Converts a lowercase Ascii character to upper one.
2250 If Chr is lowercase Ascii character, then converts it to upper one.
2252 If Value >= 0xA0, then ASSERT().
2253 If (Value & 0x0F) >= 0x0A, then ASSERT().
2255 @param Chr one Ascii character
2257 @return The uppercase value of Ascii character
2267 Convert binary data to a Base64 encoded ascii string based on RFC4648.
2269 Produce a Null-terminated Ascii string in the output buffer specified by Destination and DestinationSize.
2270 The Ascii string is produced by converting the data string specified by Source and SourceLength.
2272 @param Source Input UINT8 data
2273 @param SourceLength Number of UINT8 bytes of data
2274 @param Destination Pointer to output string buffer
2275 @param DestinationSize Size of ascii buffer. Set to 0 to get the size needed.
2276 Caller is responsible for passing in buffer of DestinationSize
2278 @retval RETURN_SUCCESS When ascii buffer is filled in.
2279 @retval RETURN_INVALID_PARAMETER If Source is NULL or DestinationSize is NULL.
2280 @retval RETURN_INVALID_PARAMETER If SourceLength or DestinationSize is bigger than (MAX_ADDRESS - (UINTN)Destination).
2281 @retval RETURN_BUFFER_TOO_SMALL If SourceLength is 0 and DestinationSize is <1.
2282 @retval RETURN_BUFFER_TOO_SMALL If Destination is NULL or DestinationSize is smaller than required buffersize.
2288 IN CONST UINT8
*Source
,
2289 IN UINTN SourceLength
,
2290 OUT CHAR8
*Destination OPTIONAL
,
2291 IN OUT UINTN
*DestinationSize
2295 Decode Base64 ASCII encoded data to 8-bit binary representation, based on
2298 Decoding occurs according to "Table 1: The Base 64 Alphabet" in RFC4648.
2300 Whitespace is ignored at all positions:
2301 - 0x09 ('\t') horizontal tab
2302 - 0x0A ('\n') new line
2303 - 0x0B ('\v') vertical tab
2304 - 0x0C ('\f') form feed
2305 - 0x0D ('\r') carriage return
2308 The minimum amount of required padding (with ASCII 0x3D, '=') is tolerated
2309 and enforced at the end of the Base64 ASCII encoded data, and only there.
2311 Other characters outside of the encoding alphabet cause the function to
2312 reject the Base64 ASCII encoded data.
2314 @param[in] Source Array of CHAR8 elements containing the Base64
2315 ASCII encoding. May be NULL if SourceSize is
2318 @param[in] SourceSize Number of CHAR8 elements in Source.
2320 @param[out] Destination Array of UINT8 elements receiving the decoded
2321 8-bit binary representation. Allocated by the
2322 caller. May be NULL if DestinationSize is
2323 zero on input. If NULL, decoding is
2324 performed, but the 8-bit binary
2325 representation is not stored. If non-NULL and
2326 the function returns an error, the contents
2327 of Destination are indeterminate.
2329 @param[in,out] DestinationSize On input, the number of UINT8 elements that
2330 the caller allocated for Destination. On
2331 output, if the function returns
2332 RETURN_SUCCESS or RETURN_BUFFER_TOO_SMALL,
2333 the number of UINT8 elements that are
2334 required for decoding the Base64 ASCII
2335 representation. If the function returns a
2336 value different from both RETURN_SUCCESS and
2337 RETURN_BUFFER_TOO_SMALL, then DestinationSize
2338 is indeterminate on output.
2340 @retval RETURN_SUCCESS SourceSize CHAR8 elements at Source have
2341 been decoded to on-output DestinationSize
2342 UINT8 elements at Destination. Note that
2343 RETURN_SUCCESS covers the case when
2344 DestinationSize is zero on input, and
2345 Source decodes to zero bytes (due to
2346 containing at most ignored whitespace).
2348 @retval RETURN_BUFFER_TOO_SMALL The input value of DestinationSize is not
2349 large enough for decoding SourceSize CHAR8
2350 elements at Source. The required number of
2351 UINT8 elements has been stored to
2354 @retval RETURN_INVALID_PARAMETER DestinationSize is NULL.
2356 @retval RETURN_INVALID_PARAMETER Source is NULL, but SourceSize is not zero.
2358 @retval RETURN_INVALID_PARAMETER Destination is NULL, but DestinationSize is
2361 @retval RETURN_INVALID_PARAMETER Source is non-NULL, and (Source +
2362 SourceSize) would wrap around MAX_ADDRESS.
2364 @retval RETURN_INVALID_PARAMETER Destination is non-NULL, and (Destination +
2365 DestinationSize) would wrap around
2366 MAX_ADDRESS, as specified on input.
2368 @retval RETURN_INVALID_PARAMETER None of Source and Destination are NULL,
2369 and CHAR8[SourceSize] at Source overlaps
2370 UINT8[DestinationSize] at Destination, as
2373 @retval RETURN_INVALID_PARAMETER Invalid CHAR8 element encountered in
2379 IN CONST CHAR8
*Source OPTIONAL
,
2380 IN UINTN SourceSize
,
2381 OUT UINT8
*Destination OPTIONAL
,
2382 IN OUT UINTN
*DestinationSize
2386 Converts an 8-bit value to an 8-bit BCD value.
2388 Converts the 8-bit value specified by Value to BCD. The BCD value is
2391 If Value >= 100, then ASSERT().
2393 @param Value The 8-bit value to convert to BCD. Range 0..99.
2395 @return The BCD value.
2406 Converts an 8-bit BCD value to an 8-bit value.
2408 Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit
2411 If Value >= 0xA0, then ASSERT().
2412 If (Value & 0x0F) >= 0x0A, then ASSERT().
2414 @param Value The 8-bit BCD value to convert to an 8-bit value.
2416 @return The 8-bit value is returned.
2426 // File Path Manipulation Functions
2430 Removes the last directory or file entry in a path.
2432 @param[in, out] Path The pointer to the path to modify.
2434 @retval FALSE Nothing was found to remove.
2435 @retval TRUE A directory or file was removed.
2444 Function to clean up paths.
2445 - Single periods in the path are removed.
2446 - Double periods in the path are removed along with a single parent directory.
2447 - Forward slashes L'/' are converted to backward slashes L'\'.
2449 This will be done inline and the existing buffer may be larger than required
2452 @param[in] Path The pointer to the string containing the path.
2454 @return Returns Path, otherwise returns NULL to indicate that an error has occurred.
2458 PathCleanUpDirectories(
2463 // Linked List Functions and Macros
2467 Initializes the head node of a doubly linked list that is declared as a
2468 global variable in a module.
2470 Initializes the forward and backward links of a new linked list. After
2471 initializing a linked list with this macro, the other linked list functions
2472 may be used to add and remove nodes from the linked list. This macro results
2473 in smaller executables by initializing the linked list in the data section,
2474 instead if calling the InitializeListHead() function to perform the
2475 equivalent operation.
2477 @param ListHead The head note of a list to initialize.
2480 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&(ListHead), &(ListHead)}
2483 Iterates over each node in a doubly linked list using each node's forward link.
2485 @param Entry A pointer to a list node used as a loop cursor during iteration
2486 @param ListHead The head node of the doubly linked list
2489 #define BASE_LIST_FOR_EACH(Entry, ListHead) \
2490 for(Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = Entry->ForwardLink)
2493 Iterates over each node in a doubly linked list using each node's forward link
2494 with safety against node removal.
2496 This macro uses NextEntry to temporarily store the next list node so the node
2497 pointed to by Entry may be deleted in the current loop iteration step and
2498 iteration can continue from the node pointed to by NextEntry.
2500 @param Entry A pointer to a list node used as a loop cursor during iteration
2501 @param NextEntry A pointer to a list node used to temporarily store the next node
2502 @param ListHead The head node of the doubly linked list
2505 #define BASE_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead) \
2506 for(Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink;\
2507 Entry != (ListHead); Entry = NextEntry, NextEntry = Entry->ForwardLink)
2510 Checks whether FirstEntry and SecondEntry are part of the same doubly-linked
2513 If FirstEntry is NULL, then ASSERT().
2514 If FirstEntry->ForwardLink is NULL, then ASSERT().
2515 If FirstEntry->BackLink is NULL, then ASSERT().
2516 If SecondEntry is NULL, then ASSERT();
2517 If PcdMaximumLinkedListLength is not zero, and List contains more than
2518 PcdMaximumLinkedListLength nodes, then ASSERT().
2520 @param FirstEntry A pointer to a node in a linked list.
2521 @param SecondEntry A pointer to the node to locate.
2523 @retval TRUE SecondEntry is in the same doubly-linked list as FirstEntry.
2524 @retval FALSE SecondEntry isn't in the same doubly-linked list as FirstEntry,
2525 or FirstEntry is invalid.
2531 IN CONST LIST_ENTRY
*FirstEntry
,
2532 IN CONST LIST_ENTRY
*SecondEntry
2537 Initializes the head node of a doubly linked list, and returns the pointer to
2538 the head node of the doubly linked list.
2540 Initializes the forward and backward links of a new linked list. After
2541 initializing a linked list with this function, the other linked list
2542 functions may be used to add and remove nodes from the linked list. It is up
2543 to the caller of this function to allocate the memory for ListHead.
2545 If ListHead is NULL, then ASSERT().
2547 @param ListHead A pointer to the head node of a new doubly linked list.
2554 InitializeListHead (
2555 IN OUT LIST_ENTRY
*ListHead
2560 Adds a node to the beginning of a doubly linked list, and returns the pointer
2561 to the head node of the doubly linked list.
2563 Adds the node Entry at the beginning of the doubly linked list denoted by
2564 ListHead, and returns ListHead.
2566 If ListHead is NULL, then ASSERT().
2567 If Entry is NULL, then ASSERT().
2568 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
2569 InitializeListHead(), then ASSERT().
2570 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
2571 of nodes in ListHead, including the ListHead node, is greater than or
2572 equal to PcdMaximumLinkedListLength, then ASSERT().
2574 @param ListHead A pointer to the head node of a doubly linked list.
2575 @param Entry A pointer to a node that is to be inserted at the beginning
2576 of a doubly linked list.
2584 IN OUT LIST_ENTRY
*ListHead
,
2585 IN OUT LIST_ENTRY
*Entry
2590 Adds a node to the end of a doubly linked list, and returns the pointer to
2591 the head node of the doubly linked list.
2593 Adds the node Entry to the end of the doubly linked list denoted by ListHead,
2594 and returns ListHead.
2596 If ListHead is NULL, then ASSERT().
2597 If Entry is NULL, then ASSERT().
2598 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
2599 InitializeListHead(), then ASSERT().
2600 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
2601 of nodes in ListHead, including the ListHead node, is greater than or
2602 equal to PcdMaximumLinkedListLength, then ASSERT().
2604 @param ListHead A pointer to the head node of a doubly linked list.
2605 @param Entry A pointer to a node that is to be added at the end of the
2614 IN OUT LIST_ENTRY
*ListHead
,
2615 IN OUT LIST_ENTRY
*Entry
2620 Retrieves the first node of a doubly linked list.
2622 Returns the first node of a doubly linked list. List must have been
2623 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
2624 If List is empty, then List is returned.
2626 If List is NULL, then ASSERT().
2627 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
2628 InitializeListHead(), then ASSERT().
2629 If PcdMaximumLinkedListLength is not zero, and the number of nodes
2630 in List, including the List node, is greater than or equal to
2631 PcdMaximumLinkedListLength, then ASSERT().
2633 @param List A pointer to the head node of a doubly linked list.
2635 @return The first node of a doubly linked list.
2636 @retval List The list is empty.
2642 IN CONST LIST_ENTRY
*List
2647 Retrieves the next node of a doubly linked list.
2649 Returns the node of a doubly linked list that follows Node.
2650 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
2651 or InitializeListHead(). If List is empty, then List is returned.
2653 If List is NULL, then ASSERT().
2654 If Node is NULL, then ASSERT().
2655 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
2656 InitializeListHead(), then ASSERT().
2657 If PcdMaximumLinkedListLength is not zero, and List contains more than
2658 PcdMaximumLinkedListLength nodes, then ASSERT().
2659 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
2661 @param List A pointer to the head node of a doubly linked list.
2662 @param Node A pointer to a node in the doubly linked list.
2664 @return The pointer to the next node if one exists. Otherwise List is returned.
2670 IN CONST LIST_ENTRY
*List
,
2671 IN CONST LIST_ENTRY
*Node
2676 Retrieves the previous node of a doubly linked list.
2678 Returns the node of a doubly linked list that precedes Node.
2679 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
2680 or InitializeListHead(). If List is empty, then List is returned.
2682 If List is NULL, then ASSERT().
2683 If Node is NULL, then ASSERT().
2684 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
2685 InitializeListHead(), then ASSERT().
2686 If PcdMaximumLinkedListLength is not zero, and List contains more than
2687 PcdMaximumLinkedListLength nodes, then ASSERT().
2688 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
2690 @param List A pointer to the head node of a doubly linked list.
2691 @param Node A pointer to a node in the doubly linked list.
2693 @return The pointer to the previous node if one exists. Otherwise List is returned.
2699 IN CONST LIST_ENTRY
*List
,
2700 IN CONST LIST_ENTRY
*Node
2705 Checks to see if a doubly linked list is empty or not.
2707 Checks to see if the doubly linked list is empty. If the linked list contains
2708 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
2710 If ListHead is NULL, then ASSERT().
2711 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
2712 InitializeListHead(), then ASSERT().
2713 If PcdMaximumLinkedListLength is not zero, and the number of nodes
2714 in List, including the List node, is greater than or equal to
2715 PcdMaximumLinkedListLength, then ASSERT().
2717 @param ListHead A pointer to the head node of a doubly linked list.
2719 @retval TRUE The linked list is empty.
2720 @retval FALSE The linked list is not empty.
2726 IN CONST LIST_ENTRY
*ListHead
2731 Determines if a node in a doubly linked list is the head node of a the same
2732 doubly linked list. This function is typically used to terminate a loop that
2733 traverses all the nodes in a doubly linked list starting with the head node.
2735 Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the
2736 nodes in the doubly linked list specified by List. List must have been
2737 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
2739 If List is NULL, then ASSERT().
2740 If Node is NULL, then ASSERT().
2741 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(),
2743 If PcdMaximumLinkedListLength is not zero, and the number of nodes
2744 in List, including the List node, is greater than or equal to
2745 PcdMaximumLinkedListLength, then ASSERT().
2746 If PcdVerifyNodeInList is TRUE and Node is not a node in List the and Node is not equal
2747 to List, then ASSERT().
2749 @param List A pointer to the head node of a doubly linked list.
2750 @param Node A pointer to a node in the doubly linked list.
2752 @retval TRUE Node is the head of the doubly-linked list pointed by List.
2753 @retval FALSE Node is not the head of the doubly-linked list pointed by List.
2759 IN CONST LIST_ENTRY
*List
,
2760 IN CONST LIST_ENTRY
*Node
2765 Determines if a node the last node in a doubly linked list.
2767 Returns TRUE if Node is the last node in the doubly linked list specified by
2768 List. Otherwise, FALSE is returned. List must have been initialized with
2769 INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
2771 If List is NULL, then ASSERT().
2772 If Node is NULL, then ASSERT().
2773 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
2774 InitializeListHead(), then ASSERT().
2775 If PcdMaximumLinkedListLength is not zero, and the number of nodes
2776 in List, including the List node, is greater than or equal to
2777 PcdMaximumLinkedListLength, then ASSERT().
2778 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
2780 @param List A pointer to the head node of a doubly linked list.
2781 @param Node A pointer to a node in the doubly linked list.
2783 @retval TRUE Node is the last node in the linked list.
2784 @retval FALSE Node is not the last node in the linked list.
2790 IN CONST LIST_ENTRY
*List
,
2791 IN CONST LIST_ENTRY
*Node
2796 Swaps the location of two nodes in a doubly linked list, and returns the
2797 first node after the swap.
2799 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
2800 Otherwise, the location of the FirstEntry node is swapped with the location
2801 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
2802 same double linked list as FirstEntry and that double linked list must have
2803 been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
2804 SecondEntry is returned after the nodes are swapped.
2806 If FirstEntry is NULL, then ASSERT().
2807 If SecondEntry is NULL, then ASSERT().
2808 If PcdVerifyNodeInList is TRUE and SecondEntry and FirstEntry are not in the
2809 same linked list, then ASSERT().
2810 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
2811 linked list containing the FirstEntry and SecondEntry nodes, including
2812 the FirstEntry and SecondEntry nodes, is greater than or equal to
2813 PcdMaximumLinkedListLength, then ASSERT().
2815 @param FirstEntry A pointer to a node in a linked list.
2816 @param SecondEntry A pointer to another node in the same linked list.
2818 @return SecondEntry.
2824 IN OUT LIST_ENTRY
*FirstEntry
,
2825 IN OUT LIST_ENTRY
*SecondEntry
2830 Removes a node from a doubly linked list, and returns the node that follows
2833 Removes the node Entry from a doubly linked list. It is up to the caller of
2834 this function to release the memory used by this node if that is required. On
2835 exit, the node following Entry in the doubly linked list is returned. If
2836 Entry is the only node in the linked list, then the head node of the linked
2839 If Entry is NULL, then ASSERT().
2840 If Entry is the head node of an empty list, then ASSERT().
2841 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
2842 linked list containing Entry, including the Entry node, is greater than
2843 or equal to PcdMaximumLinkedListLength, then ASSERT().
2845 @param Entry A pointer to a node in a linked list.
2853 IN CONST LIST_ENTRY
*Entry
2861 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
2862 with zeros. The shifted value is returned.
2864 This function shifts the 64-bit value Operand to the left by Count bits. The
2865 low Count bits are set to zero. The shifted value is returned.
2867 If Count is greater than 63, then ASSERT().
2869 @param Operand The 64-bit operand to shift left.
2870 @param Count The number of bits to shift left.
2872 @return Operand << Count.
2884 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
2885 filled with zeros. The shifted value is returned.
2887 This function shifts the 64-bit value Operand to the right by Count bits. The
2888 high Count bits are set to zero. The shifted value is returned.
2890 If Count is greater than 63, then ASSERT().
2892 @param Operand The 64-bit operand to shift right.
2893 @param Count The number of bits to shift right.
2895 @return Operand >> Count
2907 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
2908 with original integer's bit 63. The shifted value is returned.
2910 This function shifts the 64-bit value Operand to the right by Count bits. The
2911 high Count bits are set to bit 63 of Operand. The shifted value is returned.
2913 If Count is greater than 63, then ASSERT().
2915 @param Operand The 64-bit operand to shift right.
2916 @param Count The number of bits to shift right.
2918 @return Operand >> Count
2930 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
2931 with the high bits that were rotated.
2933 This function rotates the 32-bit value Operand to the left by Count bits. The
2934 low Count bits are fill with the high Count bits of Operand. The rotated
2937 If Count is greater than 31, then ASSERT().
2939 @param Operand The 32-bit operand to rotate left.
2940 @param Count The number of bits to rotate left.
2942 @return Operand << Count
2954 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
2955 with the low bits that were rotated.
2957 This function rotates the 32-bit value Operand to the right by Count bits.
2958 The high Count bits are fill with the low Count bits of Operand. The rotated
2961 If Count is greater than 31, then ASSERT().
2963 @param Operand The 32-bit operand to rotate right.
2964 @param Count The number of bits to rotate right.
2966 @return Operand >> Count
2978 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
2979 with the high bits that were rotated.
2981 This function rotates the 64-bit value Operand to the left by Count bits. The
2982 low Count bits are fill with the high Count bits of Operand. The rotated
2985 If Count is greater than 63, then ASSERT().
2987 @param Operand The 64-bit operand to rotate left.
2988 @param Count The number of bits to rotate left.
2990 @return Operand << Count
3002 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
3003 with the high low bits that were rotated.
3005 This function rotates the 64-bit value Operand to the right by Count bits.
3006 The high Count bits are fill with the low Count bits of Operand. The rotated
3009 If Count is greater than 63, then ASSERT().
3011 @param Operand The 64-bit operand to rotate right.
3012 @param Count The number of bits to rotate right.
3014 @return Operand >> Count
3026 Returns the bit position of the lowest bit set in a 32-bit value.
3028 This function computes the bit position of the lowest bit set in the 32-bit
3029 value specified by Operand. If Operand is zero, then -1 is returned.
3030 Otherwise, a value between 0 and 31 is returned.
3032 @param Operand The 32-bit operand to evaluate.
3034 @retval 0..31 The lowest bit set in Operand was found.
3035 @retval -1 Operand is zero.
3046 Returns the bit position of the lowest bit set in a 64-bit value.
3048 This function computes the bit position of the lowest bit set in the 64-bit
3049 value specified by Operand. If Operand is zero, then -1 is returned.
3050 Otherwise, a value between 0 and 63 is returned.
3052 @param Operand The 64-bit operand to evaluate.
3054 @retval 0..63 The lowest bit set in Operand was found.
3055 @retval -1 Operand is zero.
3067 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
3070 This function computes the bit position of the highest bit set in the 32-bit
3071 value specified by Operand. If Operand is zero, then -1 is returned.
3072 Otherwise, a value between 0 and 31 is returned.
3074 @param Operand The 32-bit operand to evaluate.
3076 @retval 0..31 Position of the highest bit set in Operand if found.
3077 @retval -1 Operand is zero.
3088 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
3091 This function computes the bit position of the highest bit set in the 64-bit
3092 value specified by Operand. If Operand is zero, then -1 is returned.
3093 Otherwise, a value between 0 and 63 is returned.
3095 @param Operand The 64-bit operand to evaluate.
3097 @retval 0..63 Position of the highest bit set in Operand if found.
3098 @retval -1 Operand is zero.
3109 Returns the value of the highest bit set in a 32-bit value. Equivalent to
3112 This function computes the value of the highest bit set in the 32-bit value
3113 specified by Operand. If Operand is zero, then zero is returned.
3115 @param Operand The 32-bit operand to evaluate.
3117 @return 1 << HighBitSet32(Operand)
3118 @retval 0 Operand is zero.
3129 Returns the value of the highest bit set in a 64-bit value. Equivalent to
3132 This function computes the value of the highest bit set in the 64-bit value
3133 specified by Operand. If Operand is zero, then zero is returned.
3135 @param Operand The 64-bit operand to evaluate.
3137 @return 1 << HighBitSet64(Operand)
3138 @retval 0 Operand is zero.
3149 Switches the endianness of a 16-bit integer.
3151 This function swaps the bytes in a 16-bit unsigned value to switch the value
3152 from little endian to big endian or vice versa. The byte swapped value is
3155 @param Value A 16-bit unsigned value.
3157 @return The byte swapped Value.
3168 Switches the endianness of a 32-bit integer.
3170 This function swaps the bytes in a 32-bit unsigned value to switch the value
3171 from little endian to big endian or vice versa. The byte swapped value is
3174 @param Value A 32-bit unsigned value.
3176 @return The byte swapped Value.
3187 Switches the endianness of a 64-bit integer.
3189 This function swaps the bytes in a 64-bit unsigned value to switch the value
3190 from little endian to big endian or vice versa. The byte swapped value is
3193 @param Value A 64-bit unsigned value.
3195 @return The byte swapped Value.
3206 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
3207 generates a 64-bit unsigned result.
3209 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
3210 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
3211 bit unsigned result is returned.
3213 @param Multiplicand A 64-bit unsigned value.
3214 @param Multiplier A 32-bit unsigned value.
3216 @return Multiplicand * Multiplier
3222 IN UINT64 Multiplicand
,
3223 IN UINT32 Multiplier
3228 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
3229 generates a 64-bit unsigned result.
3231 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
3232 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
3233 bit unsigned result is returned.
3235 @param Multiplicand A 64-bit unsigned value.
3236 @param Multiplier A 64-bit unsigned value.
3238 @return Multiplicand * Multiplier.
3244 IN UINT64 Multiplicand
,
3245 IN UINT64 Multiplier
3250 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
3251 64-bit signed result.
3253 This function multiples the 64-bit signed value Multiplicand by the 64-bit
3254 signed value Multiplier and generates a 64-bit signed result. This 64-bit
3255 signed result is returned.
3257 @param Multiplicand A 64-bit signed value.
3258 @param Multiplier A 64-bit signed value.
3260 @return Multiplicand * Multiplier
3266 IN INT64 Multiplicand
,
3272 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
3273 a 64-bit unsigned result.
3275 This function divides the 64-bit unsigned value Dividend by the 32-bit
3276 unsigned value Divisor and generates a 64-bit unsigned quotient. This
3277 function returns the 64-bit unsigned quotient.
3279 If Divisor is 0, then ASSERT().
3281 @param Dividend A 64-bit unsigned value.
3282 @param Divisor A 32-bit unsigned value.
3284 @return Dividend / Divisor.
3296 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
3297 a 32-bit unsigned remainder.
3299 This function divides the 64-bit unsigned value Dividend by the 32-bit
3300 unsigned value Divisor and generates a 32-bit remainder. This function
3301 returns the 32-bit unsigned remainder.
3303 If Divisor is 0, then ASSERT().
3305 @param Dividend A 64-bit unsigned value.
3306 @param Divisor A 32-bit unsigned value.
3308 @return Dividend % Divisor.
3320 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
3321 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
3323 This function divides the 64-bit unsigned value Dividend by the 32-bit
3324 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
3325 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
3326 This function returns the 64-bit unsigned quotient.
3328 If Divisor is 0, then ASSERT().
3330 @param Dividend A 64-bit unsigned value.
3331 @param Divisor A 32-bit unsigned value.
3332 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
3333 optional and may be NULL.
3335 @return Dividend / Divisor.
3340 DivU64x32Remainder (
3343 OUT UINT32
*Remainder OPTIONAL
3348 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
3349 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
3351 This function divides the 64-bit unsigned value Dividend by the 64-bit
3352 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
3353 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
3354 This function returns the 64-bit unsigned quotient.
3356 If Divisor is 0, then ASSERT().
3358 @param Dividend A 64-bit unsigned value.
3359 @param Divisor A 64-bit unsigned value.
3360 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
3361 optional and may be NULL.
3363 @return Dividend / Divisor.
3368 DivU64x64Remainder (
3371 OUT UINT64
*Remainder OPTIONAL
3376 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
3377 64-bit signed result and a optional 64-bit signed remainder.
3379 This function divides the 64-bit signed value Dividend by the 64-bit signed
3380 value Divisor and generates a 64-bit signed quotient. If Remainder is not
3381 NULL, then the 64-bit signed remainder is returned in Remainder. This
3382 function returns the 64-bit signed quotient.
3384 It is the caller's responsibility to not call this function with a Divisor of 0.
3385 If Divisor is 0, then the quotient and remainder should be assumed to be
3386 the largest negative integer.
3388 If Divisor is 0, then ASSERT().
3390 @param Dividend A 64-bit signed value.
3391 @param Divisor A 64-bit signed value.
3392 @param Remainder A pointer to a 64-bit signed value. This parameter is
3393 optional and may be NULL.
3395 @return Dividend / Divisor.
3400 DivS64x64Remainder (
3403 OUT INT64
*Remainder OPTIONAL
3408 Reads a 16-bit value from memory that may be unaligned.
3410 This function returns the 16-bit value pointed to by Buffer. The function
3411 guarantees that the read operation does not produce an alignment fault.
3413 If the Buffer is NULL, then ASSERT().
3415 @param Buffer The pointer to a 16-bit value that may be unaligned.
3417 @return The 16-bit value read from Buffer.
3423 IN CONST UINT16
*Buffer
3428 Writes a 16-bit value to memory that may be unaligned.
3430 This function writes the 16-bit value specified by Value to Buffer. Value is
3431 returned. The function guarantees that the write operation does not produce
3434 If the Buffer is NULL, then ASSERT().
3436 @param Buffer The pointer to a 16-bit value that may be unaligned.
3437 @param Value 16-bit value to write to Buffer.
3439 @return The 16-bit value to write to Buffer.
3451 Reads a 24-bit value from memory that may be unaligned.
3453 This function returns the 24-bit value pointed to by Buffer. The function
3454 guarantees that the read operation does not produce an alignment fault.
3456 If the Buffer is NULL, then ASSERT().
3458 @param Buffer The pointer to a 24-bit value that may be unaligned.
3460 @return The 24-bit value read from Buffer.
3466 IN CONST UINT32
*Buffer
3471 Writes a 24-bit value to memory that may be unaligned.
3473 This function writes the 24-bit value specified by Value to Buffer. Value is
3474 returned. The function guarantees that the write operation does not produce
3477 If the Buffer is NULL, then ASSERT().
3479 @param Buffer The pointer to a 24-bit value that may be unaligned.
3480 @param Value 24-bit value to write to Buffer.
3482 @return The 24-bit value to write to Buffer.
3494 Reads a 32-bit value from memory that may be unaligned.
3496 This function returns the 32-bit value pointed to by Buffer. The function
3497 guarantees that the read operation does not produce an alignment fault.
3499 If the Buffer is NULL, then ASSERT().
3501 @param Buffer The pointer to a 32-bit value that may be unaligned.
3503 @return The 32-bit value read from Buffer.
3509 IN CONST UINT32
*Buffer
3514 Writes a 32-bit value to memory that may be unaligned.
3516 This function writes the 32-bit value specified by Value to Buffer. Value is
3517 returned. The function guarantees that the write operation does not produce
3520 If the Buffer is NULL, then ASSERT().
3522 @param Buffer The pointer to a 32-bit value that may be unaligned.
3523 @param Value 32-bit value to write to Buffer.
3525 @return The 32-bit value to write to Buffer.
3537 Reads a 64-bit value from memory that may be unaligned.
3539 This function returns the 64-bit value pointed to by Buffer. The function
3540 guarantees that the read operation does not produce an alignment fault.
3542 If the Buffer is NULL, then ASSERT().
3544 @param Buffer The pointer to a 64-bit value that may be unaligned.
3546 @return The 64-bit value read from Buffer.
3552 IN CONST UINT64
*Buffer
3557 Writes a 64-bit value to memory that may be unaligned.
3559 This function writes the 64-bit value specified by Value to Buffer. Value is
3560 returned. The function guarantees that the write operation does not produce
3563 If the Buffer is NULL, then ASSERT().
3565 @param Buffer The pointer to a 64-bit value that may be unaligned.
3566 @param Value 64-bit value to write to Buffer.
3568 @return The 64-bit value to write to Buffer.
3580 // Bit Field Functions
3584 Returns a bit field from an 8-bit value.
3586 Returns the bitfield specified by the StartBit and the EndBit from Operand.
3588 If 8-bit operations are not supported, then ASSERT().
3589 If StartBit is greater than 7, then ASSERT().
3590 If EndBit is greater than 7, then ASSERT().
3591 If EndBit is less than StartBit, then ASSERT().
3593 @param Operand Operand on which to perform the bitfield operation.
3594 @param StartBit The ordinal of the least significant bit in the bit field.
3596 @param EndBit The ordinal of the most significant bit in the bit field.
3599 @return The bit field read.
3612 Writes a bit field to an 8-bit value, and returns the result.
3614 Writes Value to the bit field specified by the StartBit and the EndBit in
3615 Operand. All other bits in Operand are preserved. The new 8-bit value is
3618 If 8-bit operations are not supported, then ASSERT().
3619 If StartBit is greater than 7, then ASSERT().
3620 If EndBit is greater than 7, then ASSERT().
3621 If EndBit is less than StartBit, then ASSERT().
3622 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3624 @param Operand Operand on which to perform the bitfield operation.
3625 @param StartBit The ordinal of the least significant bit in the bit field.
3627 @param EndBit The ordinal of the most significant bit in the bit field.
3629 @param Value New value of the bit field.
3631 @return The new 8-bit value.
3645 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
3648 Performs a bitwise OR between the bit field specified by StartBit
3649 and EndBit in Operand and the value specified by OrData. All other bits in
3650 Operand are preserved. The new 8-bit value is returned.
3652 If 8-bit operations are not supported, then ASSERT().
3653 If StartBit is greater than 7, then ASSERT().
3654 If EndBit is greater than 7, then ASSERT().
3655 If EndBit is less than StartBit, then ASSERT().
3656 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3658 @param Operand Operand on which to perform the bitfield operation.
3659 @param StartBit The ordinal of the least significant bit in the bit field.
3661 @param EndBit The ordinal of the most significant bit in the bit field.
3663 @param OrData The value to OR with the read value from the value
3665 @return The new 8-bit value.
3679 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
3682 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3683 in Operand and the value specified by AndData. All other bits in Operand are
3684 preserved. The new 8-bit value is returned.
3686 If 8-bit operations are not supported, then ASSERT().
3687 If StartBit is greater than 7, then ASSERT().
3688 If EndBit is greater than 7, then ASSERT().
3689 If EndBit is less than StartBit, then ASSERT().
3690 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3692 @param Operand Operand on which to perform the bitfield operation.
3693 @param StartBit The ordinal of the least significant bit in the bit field.
3695 @param EndBit The ordinal of the most significant bit in the bit field.
3697 @param AndData The value to AND with the read value from the value.
3699 @return The new 8-bit value.
3713 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
3714 bitwise OR, and returns the result.
3716 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3717 in Operand and the value specified by AndData, followed by a bitwise
3718 OR with value specified by OrData. All other bits in Operand are
3719 preserved. The new 8-bit value is returned.
3721 If 8-bit operations are not supported, then ASSERT().
3722 If StartBit is greater than 7, then ASSERT().
3723 If EndBit is greater than 7, then ASSERT().
3724 If EndBit is less than StartBit, then ASSERT().
3725 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3726 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3728 @param Operand Operand on which to perform the bitfield operation.
3729 @param StartBit The ordinal of the least significant bit in the bit field.
3731 @param EndBit The ordinal of the most significant bit in the bit field.
3733 @param AndData The value to AND with the read value from the value.
3734 @param OrData The value to OR with the result of the AND operation.
3736 @return The new 8-bit value.
3741 BitFieldAndThenOr8 (
3751 Returns a bit field from a 16-bit value.
3753 Returns the bitfield specified by the StartBit and the EndBit from Operand.
3755 If 16-bit operations are not supported, then ASSERT().
3756 If StartBit is greater than 15, then ASSERT().
3757 If EndBit is greater than 15, then ASSERT().
3758 If EndBit is less than StartBit, then ASSERT().
3760 @param Operand Operand on which to perform the bitfield operation.
3761 @param StartBit The ordinal of the least significant bit in the bit field.
3763 @param EndBit The ordinal of the most significant bit in the bit field.
3766 @return The bit field read.
3779 Writes a bit field to a 16-bit value, and returns the result.
3781 Writes Value to the bit field specified by the StartBit and the EndBit in
3782 Operand. All other bits in Operand are preserved. The new 16-bit value is
3785 If 16-bit operations are not supported, then ASSERT().
3786 If StartBit is greater than 15, then ASSERT().
3787 If EndBit is greater than 15, then ASSERT().
3788 If EndBit is less than StartBit, then ASSERT().
3789 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3791 @param Operand Operand on which to perform the bitfield operation.
3792 @param StartBit The ordinal of the least significant bit in the bit field.
3794 @param EndBit The ordinal of the most significant bit in the bit field.
3796 @param Value New value of the bit field.
3798 @return The new 16-bit value.
3812 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
3815 Performs a bitwise OR between the bit field specified by StartBit
3816 and EndBit in Operand and the value specified by OrData. All other bits in
3817 Operand are preserved. The new 16-bit value is returned.
3819 If 16-bit operations are not supported, then ASSERT().
3820 If StartBit is greater than 15, then ASSERT().
3821 If EndBit is greater than 15, then ASSERT().
3822 If EndBit is less than StartBit, then ASSERT().
3823 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3825 @param Operand Operand on which to perform the bitfield operation.
3826 @param StartBit The ordinal of the least significant bit in the bit field.
3828 @param EndBit The ordinal of the most significant bit in the bit field.
3830 @param OrData The value to OR with the read value from the value
3832 @return The new 16-bit value.
3846 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
3849 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3850 in Operand and the value specified by AndData. All other bits in Operand are
3851 preserved. The new 16-bit value is returned.
3853 If 16-bit operations are not supported, then ASSERT().
3854 If StartBit is greater than 15, then ASSERT().
3855 If EndBit is greater than 15, then ASSERT().
3856 If EndBit is less than StartBit, then ASSERT().
3857 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3859 @param Operand Operand on which to perform the bitfield operation.
3860 @param StartBit The ordinal of the least significant bit in the bit field.
3862 @param EndBit The ordinal of the most significant bit in the bit field.
3864 @param AndData The value to AND with the read value from the value
3866 @return The new 16-bit value.
3880 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
3881 bitwise OR, and returns the result.
3883 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3884 in Operand and the value specified by AndData, followed by a bitwise
3885 OR with value specified by OrData. All other bits in Operand are
3886 preserved. The new 16-bit value is returned.
3888 If 16-bit operations are not supported, then ASSERT().
3889 If StartBit is greater than 15, then ASSERT().
3890 If EndBit is greater than 15, then ASSERT().
3891 If EndBit is less than StartBit, then ASSERT().
3892 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3893 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3895 @param Operand Operand on which to perform the bitfield operation.
3896 @param StartBit The ordinal of the least significant bit in the bit field.
3898 @param EndBit The ordinal of the most significant bit in the bit field.
3900 @param AndData The value to AND with the read value from the value.
3901 @param OrData The value to OR with the result of the AND operation.
3903 @return The new 16-bit value.
3908 BitFieldAndThenOr16 (
3918 Returns a bit field from a 32-bit value.
3920 Returns the bitfield specified by the StartBit and the EndBit from Operand.
3922 If 32-bit operations are not supported, then ASSERT().
3923 If StartBit is greater than 31, then ASSERT().
3924 If EndBit is greater than 31, then ASSERT().
3925 If EndBit is less than StartBit, then ASSERT().
3927 @param Operand Operand on which to perform the bitfield operation.
3928 @param StartBit The ordinal of the least significant bit in the bit field.
3930 @param EndBit The ordinal of the most significant bit in the bit field.
3933 @return The bit field read.
3946 Writes a bit field to a 32-bit value, and returns the result.
3948 Writes Value to the bit field specified by the StartBit and the EndBit in
3949 Operand. All other bits in Operand are preserved. The new 32-bit value is
3952 If 32-bit operations are not supported, then ASSERT().
3953 If StartBit is greater than 31, then ASSERT().
3954 If EndBit is greater than 31, then ASSERT().
3955 If EndBit is less than StartBit, then ASSERT().
3956 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3958 @param Operand Operand on which to perform the bitfield operation.
3959 @param StartBit The ordinal of the least significant bit in the bit field.
3961 @param EndBit The ordinal of the most significant bit in the bit field.
3963 @param Value New value of the bit field.
3965 @return The new 32-bit value.
3979 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
3982 Performs a bitwise OR between the bit field specified by StartBit
3983 and EndBit in Operand and the value specified by OrData. All other bits in
3984 Operand are preserved. The new 32-bit value is returned.
3986 If 32-bit operations are not supported, then ASSERT().
3987 If StartBit is greater than 31, then ASSERT().
3988 If EndBit is greater than 31, then ASSERT().
3989 If EndBit is less than StartBit, then ASSERT().
3990 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3992 @param Operand Operand on which to perform the bitfield operation.
3993 @param StartBit The ordinal of the least significant bit in the bit field.
3995 @param EndBit The ordinal of the most significant bit in the bit field.
3997 @param OrData The value to OR with the read value from the value.
3999 @return The new 32-bit value.
4013 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
4016 Performs a bitwise AND between the bit field specified by StartBit and EndBit
4017 in Operand and the value specified by AndData. All other bits in Operand are
4018 preserved. The new 32-bit value is returned.
4020 If 32-bit operations are not supported, then ASSERT().
4021 If StartBit is greater than 31, then ASSERT().
4022 If EndBit is greater than 31, then ASSERT().
4023 If EndBit is less than StartBit, then ASSERT().
4024 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4026 @param Operand Operand on which to perform the bitfield operation.
4027 @param StartBit The ordinal of the least significant bit in the bit field.
4029 @param EndBit The ordinal of the most significant bit in the bit field.
4031 @param AndData The value to AND with the read value from the value
4033 @return The new 32-bit value.
4047 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
4048 bitwise OR, and returns the result.
4050 Performs a bitwise AND between the bit field specified by StartBit and EndBit
4051 in Operand and the value specified by AndData, followed by a bitwise
4052 OR with value specified by OrData. All other bits in Operand are
4053 preserved. The new 32-bit value is returned.
4055 If 32-bit operations are not supported, then ASSERT().
4056 If StartBit is greater than 31, then ASSERT().
4057 If EndBit is greater than 31, then ASSERT().
4058 If EndBit is less than StartBit, then ASSERT().
4059 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4060 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4062 @param Operand Operand on which to perform the bitfield operation.
4063 @param StartBit The ordinal of the least significant bit in the bit field.
4065 @param EndBit The ordinal of the most significant bit in the bit field.
4067 @param AndData The value to AND with the read value from the value.
4068 @param OrData The value to OR with the result of the AND operation.
4070 @return The new 32-bit value.
4075 BitFieldAndThenOr32 (
4085 Returns a bit field from a 64-bit value.
4087 Returns the bitfield specified by the StartBit and the EndBit from Operand.
4089 If 64-bit operations are not supported, then ASSERT().
4090 If StartBit is greater than 63, then ASSERT().
4091 If EndBit is greater than 63, then ASSERT().
4092 If EndBit is less than StartBit, then ASSERT().
4094 @param Operand Operand on which to perform the bitfield operation.
4095 @param StartBit The ordinal of the least significant bit in the bit field.
4097 @param EndBit The ordinal of the most significant bit in the bit field.
4100 @return The bit field read.
4113 Writes a bit field to a 64-bit value, and returns the result.
4115 Writes Value to the bit field specified by the StartBit and the EndBit in
4116 Operand. All other bits in Operand are preserved. The new 64-bit value is
4119 If 64-bit operations are not supported, then ASSERT().
4120 If StartBit is greater than 63, then ASSERT().
4121 If EndBit is greater than 63, then ASSERT().
4122 If EndBit is less than StartBit, then ASSERT().
4123 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4125 @param Operand Operand on which to perform the bitfield operation.
4126 @param StartBit The ordinal of the least significant bit in the bit field.
4128 @param EndBit The ordinal of the most significant bit in the bit field.
4130 @param Value New value of the bit field.
4132 @return The new 64-bit value.
4146 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
4149 Performs a bitwise OR between the bit field specified by StartBit
4150 and EndBit in Operand and the value specified by OrData. All other bits in
4151 Operand are preserved. The new 64-bit value is returned.
4153 If 64-bit operations are not supported, then ASSERT().
4154 If StartBit is greater than 63, then ASSERT().
4155 If EndBit is greater than 63, then ASSERT().
4156 If EndBit is less than StartBit, then ASSERT().
4157 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4159 @param Operand Operand on which to perform the bitfield operation.
4160 @param StartBit The ordinal of the least significant bit in the bit field.
4162 @param EndBit The ordinal of the most significant bit in the bit field.
4164 @param OrData The value to OR with the read value from the value
4166 @return The new 64-bit value.
4180 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
4183 Performs a bitwise AND between the bit field specified by StartBit and EndBit
4184 in Operand and the value specified by AndData. All other bits in Operand are
4185 preserved. The new 64-bit value is returned.
4187 If 64-bit operations are not supported, then ASSERT().
4188 If StartBit is greater than 63, then ASSERT().
4189 If EndBit is greater than 63, then ASSERT().
4190 If EndBit is less than StartBit, then ASSERT().
4191 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4193 @param Operand Operand on which to perform the bitfield operation.
4194 @param StartBit The ordinal of the least significant bit in the bit field.
4196 @param EndBit The ordinal of the most significant bit in the bit field.
4198 @param AndData The value to AND with the read value from the value
4200 @return The new 64-bit value.
4214 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
4215 bitwise OR, and returns the result.
4217 Performs a bitwise AND between the bit field specified by StartBit and EndBit
4218 in Operand and the value specified by AndData, followed by a bitwise
4219 OR with value specified by OrData. All other bits in Operand are
4220 preserved. The new 64-bit value is returned.
4222 If 64-bit operations are not supported, then ASSERT().
4223 If StartBit is greater than 63, then ASSERT().
4224 If EndBit is greater than 63, then ASSERT().
4225 If EndBit is less than StartBit, then ASSERT().
4226 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4227 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4229 @param Operand Operand on which to perform the bitfield operation.
4230 @param StartBit The ordinal of the least significant bit in the bit field.
4232 @param EndBit The ordinal of the most significant bit in the bit field.
4234 @param AndData The value to AND with the read value from the value.
4235 @param OrData The value to OR with the result of the AND operation.
4237 @return The new 64-bit value.
4242 BitFieldAndThenOr64 (
4251 Reads a bit field from a 32-bit value, counts and returns
4252 the number of set bits.
4254 Counts the number of set bits in the bit field specified by
4255 StartBit and EndBit in Operand. The count is returned.
4257 If StartBit is greater than 31, then ASSERT().
4258 If EndBit is greater than 31, then ASSERT().
4259 If EndBit is less than StartBit, then ASSERT().
4261 @param Operand Operand on which to perform the bitfield operation.
4262 @param StartBit The ordinal of the least significant bit in the bit field.
4264 @param EndBit The ordinal of the most significant bit in the bit field.
4267 @return The number of bits set between StartBit and EndBit.
4272 BitFieldCountOnes32 (
4279 Reads a bit field from a 64-bit value, counts and returns
4280 the number of set bits.
4282 Counts the number of set bits in the bit field specified by
4283 StartBit and EndBit in Operand. The count is returned.
4285 If StartBit is greater than 63, then ASSERT().
4286 If EndBit is greater than 63, then ASSERT().
4287 If EndBit is less than StartBit, then ASSERT().
4289 @param Operand Operand on which to perform the bitfield operation.
4290 @param StartBit The ordinal of the least significant bit in the bit field.
4292 @param EndBit The ordinal of the most significant bit in the bit field.
4295 @return The number of bits set between StartBit and EndBit.
4300 BitFieldCountOnes64 (
4307 // Base Library Checksum Functions
4311 Returns the sum of all elements in a buffer in unit of UINT8.
4312 During calculation, the carry bits are dropped.
4314 This function calculates the sum of all elements in a buffer
4315 in unit of UINT8. The carry bits in result of addition are dropped.
4316 The result is returned as UINT8. If Length is Zero, then Zero is
4319 If Buffer is NULL, then ASSERT().
4320 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4322 @param Buffer The pointer to the buffer to carry out the sum operation.
4323 @param Length The size, in bytes, of Buffer.
4325 @return Sum The sum of Buffer with carry bits dropped during additions.
4331 IN CONST UINT8
*Buffer
,
4337 Returns the two's complement checksum of all elements in a buffer
4340 This function first calculates the sum of the 8-bit values in the
4341 buffer specified by Buffer and Length. The carry bits in the result
4342 of addition are dropped. Then, the two's complement of the sum is
4343 returned. If Length is 0, then 0 is returned.
4345 If Buffer is NULL, then ASSERT().
4346 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4348 @param Buffer The pointer to the buffer to carry out the checksum operation.
4349 @param Length The size, in bytes, of Buffer.
4351 @return Checksum The two's complement checksum of Buffer.
4356 CalculateCheckSum8 (
4357 IN CONST UINT8
*Buffer
,
4363 Returns the sum of all elements in a buffer of 16-bit values. During
4364 calculation, the carry bits are dropped.
4366 This function calculates the sum of the 16-bit values in the buffer
4367 specified by Buffer and Length. The carry bits in result of addition are dropped.
4368 The 16-bit result is returned. If Length is 0, then 0 is returned.
4370 If Buffer is NULL, then ASSERT().
4371 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
4372 If Length is not aligned on a 16-bit boundary, then ASSERT().
4373 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4375 @param Buffer The pointer to the buffer to carry out the sum operation.
4376 @param Length The size, in bytes, of Buffer.
4378 @return Sum The sum of Buffer with carry bits dropped during additions.
4384 IN CONST UINT16
*Buffer
,
4390 Returns the two's complement checksum of all elements in a buffer of
4393 This function first calculates the sum of the 16-bit values in the buffer
4394 specified by Buffer and Length. The carry bits in the result of addition
4395 are dropped. Then, the two's complement of the sum is returned. If Length
4396 is 0, then 0 is returned.
4398 If Buffer is NULL, then ASSERT().
4399 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
4400 If Length is not aligned on a 16-bit boundary, then ASSERT().
4401 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4403 @param Buffer The pointer to the buffer to carry out the checksum operation.
4404 @param Length The size, in bytes, of Buffer.
4406 @return Checksum The two's complement checksum of Buffer.
4411 CalculateCheckSum16 (
4412 IN CONST UINT16
*Buffer
,
4418 Returns the sum of all elements in a buffer of 32-bit values. During
4419 calculation, the carry bits are dropped.
4421 This function calculates the sum of the 32-bit values in the buffer
4422 specified by Buffer and Length. The carry bits in result of addition are dropped.
4423 The 32-bit result is returned. If Length is 0, then 0 is returned.
4425 If Buffer is NULL, then ASSERT().
4426 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
4427 If Length is not aligned on a 32-bit boundary, then ASSERT().
4428 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4430 @param Buffer The pointer to the buffer to carry out the sum operation.
4431 @param Length The size, in bytes, of Buffer.
4433 @return Sum The sum of Buffer with carry bits dropped during additions.
4439 IN CONST UINT32
*Buffer
,
4445 Returns the two's complement checksum of all elements in a buffer of
4448 This function first calculates the sum of the 32-bit values in the buffer
4449 specified by Buffer and Length. The carry bits in the result of addition
4450 are dropped. Then, the two's complement of the sum is returned. If Length
4451 is 0, then 0 is returned.
4453 If Buffer is NULL, then ASSERT().
4454 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
4455 If Length is not aligned on a 32-bit boundary, then ASSERT().
4456 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4458 @param Buffer The pointer to the buffer to carry out the checksum operation.
4459 @param Length The size, in bytes, of Buffer.
4461 @return Checksum The two's complement checksum of Buffer.
4466 CalculateCheckSum32 (
4467 IN CONST UINT32
*Buffer
,
4473 Returns the sum of all elements in a buffer of 64-bit values. During
4474 calculation, the carry bits are dropped.
4476 This function calculates the sum of the 64-bit values in the buffer
4477 specified by Buffer and Length. The carry bits in result of addition are dropped.
4478 The 64-bit result is returned. If Length is 0, then 0 is returned.
4480 If Buffer is NULL, then ASSERT().
4481 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
4482 If Length is not aligned on a 64-bit boundary, then ASSERT().
4483 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4485 @param Buffer The pointer to the buffer to carry out the sum operation.
4486 @param Length The size, in bytes, of Buffer.
4488 @return Sum The sum of Buffer with carry bits dropped during additions.
4494 IN CONST UINT64
*Buffer
,
4500 Returns the two's complement checksum of all elements in a buffer of
4503 This function first calculates the sum of the 64-bit values in the buffer
4504 specified by Buffer and Length. The carry bits in the result of addition
4505 are dropped. Then, the two's complement of the sum is returned. If Length
4506 is 0, then 0 is returned.
4508 If Buffer is NULL, then ASSERT().
4509 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
4510 If Length is not aligned on a 64-bit boundary, then ASSERT().
4511 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4513 @param Buffer The pointer to the buffer to carry out the checksum operation.
4514 @param Length The size, in bytes, of Buffer.
4516 @return Checksum The two's complement checksum of Buffer.
4521 CalculateCheckSum64 (
4522 IN CONST UINT64
*Buffer
,
4527 Computes and returns a 32-bit CRC for a data buffer.
4528 CRC32 value bases on ITU-T V.42.
4530 If Buffer is NULL, then ASSERT().
4531 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4533 @param[in] Buffer A pointer to the buffer on which the 32-bit CRC is to be computed.
4534 @param[in] Length The number of bytes in the buffer Data.
4536 @retval Crc32 The 32-bit CRC was computed for the data buffer.
4547 // Base Library CPU Functions
4551 Function entry point used when a stack switch is requested with SwitchStack()
4553 @param Context1 Context1 parameter passed into SwitchStack().
4554 @param Context2 Context2 parameter passed into SwitchStack().
4559 (EFIAPI
*SWITCH_STACK_ENTRY_POINT
)(
4560 IN VOID
*Context1
, OPTIONAL
4561 IN VOID
*Context2 OPTIONAL
4566 Used to serialize load and store operations.
4568 All loads and stores that proceed calls to this function are guaranteed to be
4569 globally visible when this function returns.
4580 Saves the current CPU context that can be restored with a call to LongJump()
4583 Saves the current CPU context in the buffer specified by JumpBuffer and
4584 returns 0. The initial call to SetJump() must always return 0. Subsequent
4585 calls to LongJump() cause a non-zero value to be returned by SetJump().
4587 If JumpBuffer is NULL, then ASSERT().
4588 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
4590 NOTE: The structure BASE_LIBRARY_JUMP_BUFFER is CPU architecture specific.
4591 The same structure must never be used for more than one CPU architecture context.
4592 For example, a BASE_LIBRARY_JUMP_BUFFER allocated by an IA-32 module must never be used from an x64 module.
4593 SetJump()/LongJump() is not currently supported for the EBC processor type.
4595 @param JumpBuffer A pointer to CPU context buffer.
4597 @retval 0 Indicates a return from SetJump().
4604 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
4609 Restores the CPU context that was saved with SetJump().
4611 Restores the CPU context from the buffer specified by JumpBuffer. This
4612 function never returns to the caller. Instead is resumes execution based on
4613 the state of JumpBuffer.
4615 If JumpBuffer is NULL, then ASSERT().
4616 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
4617 If Value is 0, then ASSERT().
4619 @param JumpBuffer A pointer to CPU context buffer.
4620 @param Value The value to return when the SetJump() context is
4621 restored and must be non-zero.
4627 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
4633 Enables CPU interrupts.
4644 Disables CPU interrupts.
4655 Disables CPU interrupts and returns the interrupt state prior to the disable
4658 @retval TRUE CPU interrupts were enabled on entry to this call.
4659 @retval FALSE CPU interrupts were disabled on entry to this call.
4664 SaveAndDisableInterrupts (
4670 Enables CPU interrupts for the smallest window required to capture any
4676 EnableDisableInterrupts (
4682 Retrieves the current CPU interrupt state.
4684 Returns TRUE if interrupts are currently enabled. Otherwise
4687 @retval TRUE CPU interrupts are enabled.
4688 @retval FALSE CPU interrupts are disabled.
4699 Set the current CPU interrupt state.
4701 Sets the current CPU interrupt state to the state specified by
4702 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
4703 InterruptState is FALSE, then interrupts are disabled. InterruptState is
4706 @param InterruptState TRUE if interrupts should enabled. FALSE if
4707 interrupts should be disabled.
4709 @return InterruptState
4715 IN BOOLEAN InterruptState
4720 Requests CPU to pause for a short period of time.
4722 Requests CPU to pause for a short period of time. Typically used in MP
4723 systems to prevent memory starvation while waiting for a spin lock.
4734 Transfers control to a function starting with a new stack.
4736 Transfers control to the function specified by EntryPoint using the
4737 new stack specified by NewStack and passing in the parameters specified
4738 by Context1 and Context2. Context1 and Context2 are optional and may
4739 be NULL. The function EntryPoint must never return. This function
4740 supports a variable number of arguments following the NewStack parameter.
4741 These additional arguments are ignored on IA-32, x64, and EBC architectures.
4742 Itanium processors expect one additional parameter of type VOID * that specifies
4743 the new backing store pointer.
4745 If EntryPoint is NULL, then ASSERT().
4746 If NewStack is NULL, then ASSERT().
4748 @param EntryPoint A pointer to function to call with the new stack.
4749 @param Context1 A pointer to the context to pass into the EntryPoint
4751 @param Context2 A pointer to the context to pass into the EntryPoint
4753 @param NewStack A pointer to the new stack to use for the EntryPoint
4755 @param ... This variable argument list is ignored for IA-32, x64, and
4756 EBC architectures. For Itanium processors, this variable
4757 argument list is expected to contain a single parameter of
4758 type VOID * that specifies the new backing store pointer.
4765 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
4766 IN VOID
*Context1
, OPTIONAL
4767 IN VOID
*Context2
, OPTIONAL
4774 Generates a breakpoint on the CPU.
4776 Generates a breakpoint on the CPU. The breakpoint must be implemented such
4777 that code can resume normal execution after the breakpoint.
4788 Executes an infinite loop.
4790 Forces the CPU to execute an infinite loop. A debugger may be used to skip
4791 past the loop and the code that follows the loop must execute properly. This
4792 implies that the infinite loop must not cause the code that follow it to be
4804 Uses as a barrier to stop speculative execution.
4806 Ensures that no later instruction will execute speculatively, until all prior
4807 instructions have completed.
4812 SpeculationBarrier (
4817 #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
4819 /// IA32 and x64 Specific Functions.
4820 /// Byte packed structure for 16-bit Real Mode EFLAGS.
4824 UINT32 CF
:1; ///< Carry Flag.
4825 UINT32 Reserved_0
:1; ///< Reserved.
4826 UINT32 PF
:1; ///< Parity Flag.
4827 UINT32 Reserved_1
:1; ///< Reserved.
4828 UINT32 AF
:1; ///< Auxiliary Carry Flag.
4829 UINT32 Reserved_2
:1; ///< Reserved.
4830 UINT32 ZF
:1; ///< Zero Flag.
4831 UINT32 SF
:1; ///< Sign Flag.
4832 UINT32 TF
:1; ///< Trap Flag.
4833 UINT32 IF
:1; ///< Interrupt Enable Flag.
4834 UINT32 DF
:1; ///< Direction Flag.
4835 UINT32 OF
:1; ///< Overflow Flag.
4836 UINT32 IOPL
:2; ///< I/O Privilege Level.
4837 UINT32 NT
:1; ///< Nested Task.
4838 UINT32 Reserved_3
:1; ///< Reserved.
4844 /// Byte packed structure for EFLAGS/RFLAGS.
4845 /// 32-bits on IA-32.
4846 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
4850 UINT32 CF
:1; ///< Carry Flag.
4851 UINT32 Reserved_0
:1; ///< Reserved.
4852 UINT32 PF
:1; ///< Parity Flag.
4853 UINT32 Reserved_1
:1; ///< Reserved.
4854 UINT32 AF
:1; ///< Auxiliary Carry Flag.
4855 UINT32 Reserved_2
:1; ///< Reserved.
4856 UINT32 ZF
:1; ///< Zero Flag.
4857 UINT32 SF
:1; ///< Sign Flag.
4858 UINT32 TF
:1; ///< Trap Flag.
4859 UINT32 IF
:1; ///< Interrupt Enable Flag.
4860 UINT32 DF
:1; ///< Direction Flag.
4861 UINT32 OF
:1; ///< Overflow Flag.
4862 UINT32 IOPL
:2; ///< I/O Privilege Level.
4863 UINT32 NT
:1; ///< Nested Task.
4864 UINT32 Reserved_3
:1; ///< Reserved.
4865 UINT32 RF
:1; ///< Resume Flag.
4866 UINT32 VM
:1; ///< Virtual 8086 Mode.
4867 UINT32 AC
:1; ///< Alignment Check.
4868 UINT32 VIF
:1; ///< Virtual Interrupt Flag.
4869 UINT32 VIP
:1; ///< Virtual Interrupt Pending.
4870 UINT32 ID
:1; ///< ID Flag.
4871 UINT32 Reserved_4
:10; ///< Reserved.
4877 /// Byte packed structure for Control Register 0 (CR0).
4878 /// 32-bits on IA-32.
4879 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
4883 UINT32 PE
:1; ///< Protection Enable.
4884 UINT32 MP
:1; ///< Monitor Coprocessor.
4885 UINT32 EM
:1; ///< Emulation.
4886 UINT32 TS
:1; ///< Task Switched.
4887 UINT32 ET
:1; ///< Extension Type.
4888 UINT32 NE
:1; ///< Numeric Error.
4889 UINT32 Reserved_0
:10; ///< Reserved.
4890 UINT32 WP
:1; ///< Write Protect.
4891 UINT32 Reserved_1
:1; ///< Reserved.
4892 UINT32 AM
:1; ///< Alignment Mask.
4893 UINT32 Reserved_2
:10; ///< Reserved.
4894 UINT32 NW
:1; ///< Mot Write-through.
4895 UINT32 CD
:1; ///< Cache Disable.
4896 UINT32 PG
:1; ///< Paging.
4902 /// Byte packed structure for Control Register 4 (CR4).
4903 /// 32-bits on IA-32.
4904 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
4908 UINT32 VME
:1; ///< Virtual-8086 Mode Extensions.
4909 UINT32 PVI
:1; ///< Protected-Mode Virtual Interrupts.
4910 UINT32 TSD
:1; ///< Time Stamp Disable.
4911 UINT32 DE
:1; ///< Debugging Extensions.
4912 UINT32 PSE
:1; ///< Page Size Extensions.
4913 UINT32 PAE
:1; ///< Physical Address Extension.
4914 UINT32 MCE
:1; ///< Machine Check Enable.
4915 UINT32 PGE
:1; ///< Page Global Enable.
4916 UINT32 PCE
:1; ///< Performance Monitoring Counter
4918 UINT32 OSFXSR
:1; ///< Operating System Support for
4919 ///< FXSAVE and FXRSTOR instructions
4920 UINT32 OSXMMEXCPT
:1; ///< Operating System Support for
4921 ///< Unmasked SIMD Floating Point
4923 UINT32 UMIP
:1; ///< User-Mode Instruction Prevention.
4924 UINT32 LA57
:1; ///< Linear Address 57bit.
4925 UINT32 VMXE
:1; ///< VMX Enable.
4926 UINT32 SMXE
:1; ///< SMX Enable.
4927 UINT32 Reserved_3
:1; ///< Reserved.
4928 UINT32 FSGSBASE
:1; ///< FSGSBASE Enable.
4929 UINT32 PCIDE
:1; ///< PCID Enable.
4930 UINT32 OSXSAVE
:1; ///< XSAVE and Processor Extended States Enable.
4931 UINT32 Reserved_4
:1; ///< Reserved.
4932 UINT32 SMEP
:1; ///< SMEP Enable.
4933 UINT32 SMAP
:1; ///< SMAP Enable.
4934 UINT32 PKE
:1; ///< Protection-Key Enable.
4935 UINT32 Reserved_5
:9; ///< Reserved.
4941 /// Byte packed structure for a segment descriptor in a GDT/LDT.
4960 } IA32_SEGMENT_DESCRIPTOR
;
4963 /// Byte packed structure for an IDTR, GDTR, LDTR descriptor.
4972 #define IA32_IDT_GATE_TYPE_TASK 0x85
4973 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
4974 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
4975 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
4976 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
4978 #define IA32_GDT_TYPE_TSS 0x9
4979 #define IA32_GDT_ALIGNMENT 8
4981 #if defined (MDE_CPU_IA32)
4983 /// Byte packed structure for an IA-32 Interrupt Gate Descriptor.
4987 UINT32 OffsetLow
:16; ///< Offset bits 15..0.
4988 UINT32 Selector
:16; ///< Selector.
4989 UINT32 Reserved_0
:8; ///< Reserved.
4990 UINT32 GateType
:8; ///< Gate Type. See #defines above.
4991 UINT32 OffsetHigh
:16; ///< Offset bits 31..16.
4994 } IA32_IDT_GATE_DESCRIPTOR
;
4998 // IA32 Task-State Segment Definition
5001 UINT16 PreviousTaskLink
;
5035 UINT16 LDTSegmentSelector
;
5038 UINT16 IOMapBaseAddress
;
5039 } IA32_TASK_STATE_SEGMENT
;
5043 UINT32 LimitLow
:16; ///< Segment Limit 15..00
5044 UINT32 BaseLow
:16; ///< Base Address 15..00
5045 UINT32 BaseMid
:8; ///< Base Address 23..16
5046 UINT32 Type
:4; ///< Type (1 0 B 1)
5047 UINT32 Reserved_43
:1; ///< 0
5048 UINT32 DPL
:2; ///< Descriptor Privilege Level
5049 UINT32 P
:1; ///< Segment Present
5050 UINT32 LimitHigh
:4; ///< Segment Limit 19..16
5051 UINT32 AVL
:1; ///< Available for use by system software
5052 UINT32 Reserved_52
:2; ///< 0 0
5053 UINT32 G
:1; ///< Granularity
5054 UINT32 BaseHigh
:8; ///< Base Address 31..24
5057 } IA32_TSS_DESCRIPTOR
;
5060 #endif // defined (MDE_CPU_IA32)
5062 #if defined (MDE_CPU_X64)
5064 /// Byte packed structure for an x64 Interrupt Gate Descriptor.
5068 UINT32 OffsetLow
:16; ///< Offset bits 15..0.
5069 UINT32 Selector
:16; ///< Selector.
5070 UINT32 Reserved_0
:8; ///< Reserved.
5071 UINT32 GateType
:8; ///< Gate Type. See #defines above.
5072 UINT32 OffsetHigh
:16; ///< Offset bits 31..16.
5073 UINT32 OffsetUpper
:32; ///< Offset bits 63..32.
5074 UINT32 Reserved_1
:32; ///< Reserved.
5080 } IA32_IDT_GATE_DESCRIPTOR
;
5084 // IA32 Task-State Segment Definition
5094 UINT16 Reserved_100
;
5095 UINT16 IOMapBaseAddress
;
5096 } IA32_TASK_STATE_SEGMENT
;
5100 UINT32 LimitLow
:16; ///< Segment Limit 15..00
5101 UINT32 BaseLow
:16; ///< Base Address 15..00
5102 UINT32 BaseMidl
:8; ///< Base Address 23..16
5103 UINT32 Type
:4; ///< Type (1 0 B 1)
5104 UINT32 Reserved_43
:1; ///< 0
5105 UINT32 DPL
:2; ///< Descriptor Privilege Level
5106 UINT32 P
:1; ///< Segment Present
5107 UINT32 LimitHigh
:4; ///< Segment Limit 19..16
5108 UINT32 AVL
:1; ///< Available for use by system software
5109 UINT32 Reserved_52
:2; ///< 0 0
5110 UINT32 G
:1; ///< Granularity
5111 UINT32 BaseMidh
:8; ///< Base Address 31..24
5112 UINT32 BaseHigh
:32; ///< Base Address 63..32
5113 UINT32 Reserved_96
:32; ///< Reserved
5119 } IA32_TSS_DESCRIPTOR
;
5122 #endif // defined (MDE_CPU_X64)
5125 /// Byte packed structure for an FP/SSE/SSE2 context.
5132 /// Structures for the 16-bit real mode thunks.
5185 IA32_EFLAGS32 EFLAGS
;
5195 } IA32_REGISTER_SET
;
5198 /// Byte packed structure for an 16-bit real mode thunks.
5201 IA32_REGISTER_SET
*RealModeState
;
5202 VOID
*RealModeBuffer
;
5203 UINT32 RealModeBufferSize
;
5204 UINT32 ThunkAttributes
;
5207 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
5208 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
5209 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
5212 /// Type definition for representing labels in NASM source code that allow for
5213 /// the patching of immediate operands of IA32 and X64 instructions.
5215 /// While the type is technically defined as a function type (note: not a
5216 /// pointer-to-function type), such labels in NASM source code never stand for
5217 /// actual functions, and identifiers declared with this function type should
5218 /// never be called. This is also why the EFIAPI calling convention specifier
5219 /// is missing from the typedef, and why the typedef does not follow the usual
5220 /// edk2 coding style for function (or pointer-to-function) typedefs. The VOID
5221 /// return type and the VOID argument list are merely artifacts.
5223 typedef VOID (X86_ASSEMBLY_PATCH_LABEL
) (VOID
);
5226 Retrieves CPUID information.
5228 Executes the CPUID instruction with EAX set to the value specified by Index.
5229 This function always returns Index.
5230 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5231 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5232 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5233 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5234 This function is only available on IA-32 and x64.
5236 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
5238 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
5239 instruction. This is an optional parameter that may be NULL.
5240 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
5241 instruction. This is an optional parameter that may be NULL.
5242 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
5243 instruction. This is an optional parameter that may be NULL.
5244 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
5245 instruction. This is an optional parameter that may be NULL.
5254 OUT UINT32
*Eax
, OPTIONAL
5255 OUT UINT32
*Ebx
, OPTIONAL
5256 OUT UINT32
*Ecx
, OPTIONAL
5257 OUT UINT32
*Edx OPTIONAL
5262 Retrieves CPUID information using an extended leaf identifier.
5264 Executes the CPUID instruction with EAX set to the value specified by Index
5265 and ECX set to the value specified by SubIndex. This function always returns
5266 Index. This function is only available on IA-32 and x64.
5268 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5269 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5270 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5271 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5273 @param Index The 32-bit value to load into EAX prior to invoking the
5275 @param SubIndex The 32-bit value to load into ECX prior to invoking the
5277 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
5278 instruction. This is an optional parameter that may be
5280 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
5281 instruction. This is an optional parameter that may be
5283 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
5284 instruction. This is an optional parameter that may be
5286 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
5287 instruction. This is an optional parameter that may be
5298 OUT UINT32
*Eax
, OPTIONAL
5299 OUT UINT32
*Ebx
, OPTIONAL
5300 OUT UINT32
*Ecx
, OPTIONAL
5301 OUT UINT32
*Edx OPTIONAL
5306 Set CD bit and clear NW bit of CR0 followed by a WBINVD.
5308 Disables the caches by setting the CD bit of CR0 to 1, clearing the NW bit of CR0 to 0,
5309 and executing a WBINVD instruction. This function is only available on IA-32 and x64.
5320 Perform a WBINVD and clear both the CD and NW bits of CR0.
5322 Enables the caches by executing a WBINVD instruction and then clear both the CD and NW
5323 bits of CR0 to 0. This function is only available on IA-32 and x64.
5334 Returns the lower 32-bits of a Machine Specific Register(MSR).
5336 Reads and returns the lower 32-bits of the MSR specified by Index.
5337 No parameter checking is performed on Index, and some Index values may cause
5338 CPU exceptions. The caller must either guarantee that Index is valid, or the
5339 caller must set up exception handlers to catch the exceptions. This function
5340 is only available on IA-32 and x64.
5342 @param Index The 32-bit MSR index to read.
5344 @return The lower 32 bits of the MSR identified by Index.
5355 Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.
5356 The upper 32-bits of the MSR are set to zero.
5358 Writes the 32-bit value specified by Value to the MSR specified by Index. The
5359 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
5360 the MSR is returned. No parameter checking is performed on Index or Value,
5361 and some of these may cause CPU exceptions. The caller must either guarantee
5362 that Index and Value are valid, or the caller must establish proper exception
5363 handlers. This function is only available on IA-32 and x64.
5365 @param Index The 32-bit MSR index to write.
5366 @param Value The 32-bit value to write to the MSR.
5380 Reads a 64-bit MSR, performs a bitwise OR on the lower 32-bits, and
5381 writes the result back to the 64-bit MSR.
5383 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5384 between the lower 32-bits of the read result and the value specified by
5385 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
5386 32-bits of the value written to the MSR is returned. No parameter checking is
5387 performed on Index or OrData, and some of these may cause CPU exceptions. The
5388 caller must either guarantee that Index and OrData are valid, or the caller
5389 must establish proper exception handlers. This function is only available on
5392 @param Index The 32-bit MSR index to write.
5393 @param OrData The value to OR with the read value from the MSR.
5395 @return The lower 32-bit value written to the MSR.
5407 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
5408 the result back to the 64-bit MSR.
5410 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5411 lower 32-bits of the read result and the value specified by AndData, and
5412 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
5413 the value written to the MSR is returned. No parameter checking is performed
5414 on Index or AndData, and some of these may cause CPU exceptions. The caller
5415 must either guarantee that Index and AndData are valid, or the caller must
5416 establish proper exception handlers. This function is only available on IA-32
5419 @param Index The 32-bit MSR index to write.
5420 @param AndData The value to AND with the read value from the MSR.
5422 @return The lower 32-bit value written to the MSR.
5434 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise OR
5435 on the lower 32-bits, and writes the result back to the 64-bit MSR.
5437 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5438 lower 32-bits of the read result and the value specified by AndData
5439 preserving the upper 32-bits, performs a bitwise OR between the
5440 result of the AND operation and the value specified by OrData, and writes the
5441 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
5442 written to the MSR is returned. No parameter checking is performed on Index,
5443 AndData, or OrData, and some of these may cause CPU exceptions. The caller
5444 must either guarantee that Index, AndData, and OrData are valid, or the
5445 caller must establish proper exception handlers. This function is only
5446 available on IA-32 and x64.
5448 @param Index The 32-bit MSR index to write.
5449 @param AndData The value to AND with the read value from the MSR.
5450 @param OrData The value to OR with the result of the AND operation.
5452 @return The lower 32-bit value written to the MSR.
5465 Reads a bit field of an MSR.
5467 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
5468 specified by the StartBit and the EndBit. The value of the bit field is
5469 returned. The caller must either guarantee that Index is valid, or the caller
5470 must set up exception handlers to catch the exceptions. This function is only
5471 available on IA-32 and x64.
5473 If StartBit is greater than 31, then ASSERT().
5474 If EndBit is greater than 31, then ASSERT().
5475 If EndBit is less than StartBit, then ASSERT().
5477 @param Index The 32-bit MSR index to read.
5478 @param StartBit The ordinal of the least significant bit in the bit field.
5480 @param EndBit The ordinal of the most significant bit in the bit field.
5483 @return The bit field read from the MSR.
5488 AsmMsrBitFieldRead32 (
5496 Writes a bit field to an MSR.
5498 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
5499 field is specified by the StartBit and the EndBit. All other bits in the
5500 destination MSR are preserved. The lower 32-bits of the MSR written is
5501 returned. The caller must either guarantee that Index and the data written
5502 is valid, or the caller must set up exception handlers to catch the exceptions.
5503 This function is only available on IA-32 and x64.
5505 If StartBit is greater than 31, then ASSERT().
5506 If EndBit is greater than 31, then ASSERT().
5507 If EndBit is less than StartBit, then ASSERT().
5508 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5510 @param Index The 32-bit MSR index to write.
5511 @param StartBit The ordinal of the least significant bit in the bit field.
5513 @param EndBit The ordinal of the most significant bit in the bit field.
5515 @param Value New value of the bit field.
5517 @return The lower 32-bit of the value written to the MSR.
5522 AsmMsrBitFieldWrite32 (
5531 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
5532 result back to the bit field in the 64-bit MSR.
5534 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5535 between the read result and the value specified by OrData, and writes the
5536 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
5537 written to the MSR are returned. Extra left bits in OrData are stripped. The
5538 caller must either guarantee that Index and the data written is valid, or
5539 the caller must set up exception handlers to catch the exceptions. This
5540 function is only available on IA-32 and x64.
5542 If StartBit is greater than 31, then ASSERT().
5543 If EndBit is greater than 31, then ASSERT().
5544 If EndBit is less than StartBit, then ASSERT().
5545 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5547 @param Index The 32-bit MSR index to write.
5548 @param StartBit The ordinal of the least significant bit in the bit field.
5550 @param EndBit The ordinal of the most significant bit in the bit field.
5552 @param OrData The value to OR with the read value from the MSR.
5554 @return The lower 32-bit of the value written to the MSR.
5559 AsmMsrBitFieldOr32 (
5568 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5569 result back to the bit field in the 64-bit MSR.
5571 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5572 read result and the value specified by AndData, and writes the result to the
5573 64-bit MSR specified by Index. The lower 32-bits of the value written to the
5574 MSR are returned. Extra left bits in AndData are stripped. The caller must
5575 either guarantee that Index and the data written is valid, or the caller must
5576 set up exception handlers to catch the exceptions. This function is only
5577 available on IA-32 and x64.
5579 If StartBit is greater than 31, then ASSERT().
5580 If EndBit is greater than 31, then ASSERT().
5581 If EndBit is less than StartBit, then ASSERT().
5582 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5584 @param Index The 32-bit MSR index to write.
5585 @param StartBit The ordinal of the least significant bit in the bit field.
5587 @param EndBit The ordinal of the most significant bit in the bit field.
5589 @param AndData The value to AND with the read value from the MSR.
5591 @return The lower 32-bit of the value written to the MSR.
5596 AsmMsrBitFieldAnd32 (
5605 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5606 bitwise OR, and writes the result back to the bit field in the
5609 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
5610 bitwise OR between the read result and the value specified by
5611 AndData, and writes the result to the 64-bit MSR specified by Index. The
5612 lower 32-bits of the value written to the MSR are returned. Extra left bits
5613 in both AndData and OrData are stripped. The caller must either guarantee
5614 that Index and the data written is valid, or the caller must set up exception
5615 handlers to catch the exceptions. This function is only available on IA-32
5618 If StartBit is greater than 31, then ASSERT().
5619 If EndBit is greater than 31, then ASSERT().
5620 If EndBit is less than StartBit, then ASSERT().
5621 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5622 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5624 @param Index The 32-bit MSR index to write.
5625 @param StartBit The ordinal of the least significant bit in the bit field.
5627 @param EndBit The ordinal of the most significant bit in the bit field.
5629 @param AndData The value to AND with the read value from the MSR.
5630 @param OrData The value to OR with the result of the AND operation.
5632 @return The lower 32-bit of the value written to the MSR.
5637 AsmMsrBitFieldAndThenOr32 (
5647 Returns a 64-bit Machine Specific Register(MSR).
5649 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
5650 performed on Index, and some Index values may cause CPU exceptions. The
5651 caller must either guarantee that Index is valid, or the caller must set up
5652 exception handlers to catch the exceptions. This function is only available
5655 @param Index The 32-bit MSR index to read.
5657 @return The value of the MSR identified by Index.
5668 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
5671 Writes the 64-bit value specified by Value to the MSR specified by Index. The
5672 64-bit value written to the MSR is returned. No parameter checking is
5673 performed on Index or Value, and some of these may cause CPU exceptions. The
5674 caller must either guarantee that Index and Value are valid, or the caller
5675 must establish proper exception handlers. This function is only available on
5678 @param Index The 32-bit MSR index to write.
5679 @param Value The 64-bit value to write to the MSR.
5693 Reads a 64-bit MSR, performs a bitwise OR, and writes the result
5694 back to the 64-bit MSR.
5696 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5697 between the read result and the value specified by OrData, and writes the
5698 result to the 64-bit MSR specified by Index. The value written to the MSR is
5699 returned. No parameter checking is performed on Index or OrData, and some of
5700 these may cause CPU exceptions. The caller must either guarantee that Index
5701 and OrData are valid, or the caller must establish proper exception handlers.
5702 This function is only available on IA-32 and x64.
5704 @param Index The 32-bit MSR index to write.
5705 @param OrData The value to OR with the read value from the MSR.
5707 @return The value written back to the MSR.
5719 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
5722 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5723 read result and the value specified by OrData, and writes the result to the
5724 64-bit MSR specified by Index. The value written to the MSR is returned. No
5725 parameter checking is performed on Index or OrData, and some of these may
5726 cause CPU exceptions. The caller must either guarantee that Index and OrData
5727 are valid, or the caller must establish proper exception handlers. This
5728 function is only available on IA-32 and x64.
5730 @param Index The 32-bit MSR index to write.
5731 @param AndData The value to AND with the read value from the MSR.
5733 @return The value written back to the MSR.
5745 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise
5746 OR, and writes the result back to the 64-bit MSR.
5748 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
5749 result and the value specified by AndData, performs a bitwise OR
5750 between the result of the AND operation and the value specified by OrData,
5751 and writes the result to the 64-bit MSR specified by Index. The value written
5752 to the MSR is returned. No parameter checking is performed on Index, AndData,
5753 or OrData, and some of these may cause CPU exceptions. The caller must either
5754 guarantee that Index, AndData, and OrData are valid, or the caller must
5755 establish proper exception handlers. This function is only available on IA-32
5758 @param Index The 32-bit MSR index to write.
5759 @param AndData The value to AND with the read value from the MSR.
5760 @param OrData The value to OR with the result of the AND operation.
5762 @return The value written back to the MSR.
5775 Reads a bit field of an MSR.
5777 Reads the bit field in the 64-bit MSR. The bit field is specified by the
5778 StartBit and the EndBit. The value of the bit field is returned. The caller
5779 must either guarantee that Index is valid, or the caller must set up
5780 exception handlers to catch the exceptions. This function is only available
5783 If StartBit is greater than 63, then ASSERT().
5784 If EndBit is greater than 63, then ASSERT().
5785 If EndBit is less than StartBit, then ASSERT().
5787 @param Index The 32-bit MSR index to read.
5788 @param StartBit The ordinal of the least significant bit in the bit field.
5790 @param EndBit The ordinal of the most significant bit in the bit field.
5793 @return The value read from the MSR.
5798 AsmMsrBitFieldRead64 (
5806 Writes a bit field to an MSR.
5808 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
5809 the StartBit and the EndBit. All other bits in the destination MSR are
5810 preserved. The MSR written is returned. The caller must either guarantee
5811 that Index and the data written is valid, or the caller must set up exception
5812 handlers to catch the exceptions. This function is only available on IA-32 and x64.
5814 If StartBit is greater than 63, then ASSERT().
5815 If EndBit is greater than 63, then ASSERT().
5816 If EndBit is less than StartBit, then ASSERT().
5817 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5819 @param Index The 32-bit MSR index to write.
5820 @param StartBit The ordinal of the least significant bit in the bit field.
5822 @param EndBit The ordinal of the most significant bit in the bit field.
5824 @param Value New value of the bit field.
5826 @return The value written back to the MSR.
5831 AsmMsrBitFieldWrite64 (
5840 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and
5841 writes the result back to the bit field in the 64-bit MSR.
5843 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5844 between the read result and the value specified by OrData, and writes the
5845 result to the 64-bit MSR specified by Index. The value written to the MSR is
5846 returned. Extra left bits in OrData are stripped. The caller must either
5847 guarantee that Index and the data written is valid, or the caller must set up
5848 exception handlers to catch the exceptions. This function is only available
5851 If StartBit is greater than 63, then ASSERT().
5852 If EndBit is greater than 63, then ASSERT().
5853 If EndBit is less than StartBit, then ASSERT().
5854 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5856 @param Index The 32-bit MSR index to write.
5857 @param StartBit The ordinal of the least significant bit in the bit field.
5859 @param EndBit The ordinal of the most significant bit in the bit field.
5861 @param OrData The value to OR with the read value from the bit field.
5863 @return The value written back to the MSR.
5868 AsmMsrBitFieldOr64 (
5877 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5878 result back to the bit field in the 64-bit MSR.
5880 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5881 read result and the value specified by AndData, and writes the result to the
5882 64-bit MSR specified by Index. The value written to the MSR is returned.
5883 Extra left bits in AndData are stripped. The caller must either guarantee
5884 that Index and the data written is valid, or the caller must set up exception
5885 handlers to catch the exceptions. This function is only available on IA-32
5888 If StartBit is greater than 63, then ASSERT().
5889 If EndBit is greater than 63, then ASSERT().
5890 If EndBit is less than StartBit, then ASSERT().
5891 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5893 @param Index The 32-bit MSR index to write.
5894 @param StartBit The ordinal of the least significant bit in the bit field.
5896 @param EndBit The ordinal of the most significant bit in the bit field.
5898 @param AndData The value to AND with the read value from the bit field.
5900 @return The value written back to the MSR.
5905 AsmMsrBitFieldAnd64 (
5914 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5915 bitwise OR, and writes the result back to the bit field in the
5918 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
5919 a bitwise OR between the read result and the value specified by
5920 AndData, and writes the result to the 64-bit MSR specified by Index. The
5921 value written to the MSR is returned. Extra left bits in both AndData and
5922 OrData are stripped. The caller must either guarantee that Index and the data
5923 written is valid, or the caller must set up exception handlers to catch the
5924 exceptions. This function is only available on IA-32 and x64.
5926 If StartBit is greater than 63, then ASSERT().
5927 If EndBit is greater than 63, then ASSERT().
5928 If EndBit is less than StartBit, then ASSERT().
5929 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5930 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5932 @param Index The 32-bit MSR index to write.
5933 @param StartBit The ordinal of the least significant bit in the bit field.
5935 @param EndBit The ordinal of the most significant bit in the bit field.
5937 @param AndData The value to AND with the read value from the bit field.
5938 @param OrData The value to OR with the result of the AND operation.
5940 @return The value written back to the MSR.
5945 AsmMsrBitFieldAndThenOr64 (
5955 Reads the current value of the EFLAGS register.
5957 Reads and returns the current value of the EFLAGS register. This function is
5958 only available on IA-32 and x64. This returns a 32-bit value on IA-32 and a
5959 64-bit value on x64.
5961 @return EFLAGS on IA-32 or RFLAGS on x64.
5972 Reads the current value of the Control Register 0 (CR0).
5974 Reads and returns the current value of CR0. This function is only available
5975 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5978 @return The value of the Control Register 0 (CR0).
5989 Reads the current value of the Control Register 2 (CR2).
5991 Reads and returns the current value of CR2. This function is only available
5992 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5995 @return The value of the Control Register 2 (CR2).
6006 Reads the current value of the Control Register 3 (CR3).
6008 Reads and returns the current value of CR3. This function is only available
6009 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6012 @return The value of the Control Register 3 (CR3).
6023 Reads the current value of the Control Register 4 (CR4).
6025 Reads and returns the current value of CR4. This function is only available
6026 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6029 @return The value of the Control Register 4 (CR4).
6040 Writes a value to Control Register 0 (CR0).
6042 Writes and returns a new value to CR0. This function is only available on
6043 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6045 @param Cr0 The value to write to CR0.
6047 @return The value written to CR0.
6058 Writes a value to Control Register 2 (CR2).
6060 Writes and returns a new value to CR2. This function is only available on
6061 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6063 @param Cr2 The value to write to CR2.
6065 @return The value written to CR2.
6076 Writes a value to Control Register 3 (CR3).
6078 Writes and returns a new value to CR3. This function is only available on
6079 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6081 @param Cr3 The value to write to CR3.
6083 @return The value written to CR3.
6094 Writes a value to Control Register 4 (CR4).
6096 Writes and returns a new value to CR4. This function is only available on
6097 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6099 @param Cr4 The value to write to CR4.
6101 @return The value written to CR4.
6112 Reads the current value of Debug Register 0 (DR0).
6114 Reads and returns the current value of DR0. This function is only available
6115 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6118 @return The value of Debug Register 0 (DR0).
6129 Reads the current value of Debug Register 1 (DR1).
6131 Reads and returns the current value of DR1. This function is only available
6132 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6135 @return The value of Debug Register 1 (DR1).
6146 Reads the current value of Debug Register 2 (DR2).
6148 Reads and returns the current value of DR2. This function is only available
6149 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6152 @return The value of Debug Register 2 (DR2).
6163 Reads the current value of Debug Register 3 (DR3).
6165 Reads and returns the current value of DR3. This function is only available
6166 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6169 @return The value of Debug Register 3 (DR3).
6180 Reads the current value of Debug Register 4 (DR4).
6182 Reads and returns the current value of DR4. This function is only available
6183 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6186 @return The value of Debug Register 4 (DR4).
6197 Reads the current value of Debug Register 5 (DR5).
6199 Reads and returns the current value of DR5. This function is only available
6200 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6203 @return The value of Debug Register 5 (DR5).
6214 Reads the current value of Debug Register 6 (DR6).
6216 Reads and returns the current value of DR6. This function is only available
6217 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6220 @return The value of Debug Register 6 (DR6).
6231 Reads the current value of Debug Register 7 (DR7).
6233 Reads and returns the current value of DR7. This function is only available
6234 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6237 @return The value of Debug Register 7 (DR7).
6248 Writes a value to Debug Register 0 (DR0).
6250 Writes and returns a new value to DR0. This function is only available on
6251 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6253 @param Dr0 The value to write to Dr0.
6255 @return The value written to Debug Register 0 (DR0).
6266 Writes a value to Debug Register 1 (DR1).
6268 Writes and returns a new value to DR1. This function is only available on
6269 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6271 @param Dr1 The value to write to Dr1.
6273 @return The value written to Debug Register 1 (DR1).
6284 Writes a value to Debug Register 2 (DR2).
6286 Writes and returns a new value to DR2. This function is only available on
6287 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6289 @param Dr2 The value to write to Dr2.
6291 @return The value written to Debug Register 2 (DR2).
6302 Writes a value to Debug Register 3 (DR3).
6304 Writes and returns a new value to DR3. This function is only available on
6305 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6307 @param Dr3 The value to write to Dr3.
6309 @return The value written to Debug Register 3 (DR3).
6320 Writes a value to Debug Register 4 (DR4).
6322 Writes and returns a new value to DR4. This function is only available on
6323 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6325 @param Dr4 The value to write to Dr4.
6327 @return The value written to Debug Register 4 (DR4).
6338 Writes a value to Debug Register 5 (DR5).
6340 Writes and returns a new value to DR5. This function is only available on
6341 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6343 @param Dr5 The value to write to Dr5.
6345 @return The value written to Debug Register 5 (DR5).
6356 Writes a value to Debug Register 6 (DR6).
6358 Writes and returns a new value to DR6. This function is only available on
6359 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6361 @param Dr6 The value to write to Dr6.
6363 @return The value written to Debug Register 6 (DR6).
6374 Writes a value to Debug Register 7 (DR7).
6376 Writes and returns a new value to DR7. This function is only available on
6377 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6379 @param Dr7 The value to write to Dr7.
6381 @return The value written to Debug Register 7 (DR7).
6392 Reads the current value of Code Segment Register (CS).
6394 Reads and returns the current value of CS. This function is only available on
6397 @return The current value of CS.
6408 Reads the current value of Data Segment Register (DS).
6410 Reads and returns the current value of DS. This function is only available on
6413 @return The current value of DS.
6424 Reads the current value of Extra Segment Register (ES).
6426 Reads and returns the current value of ES. This function is only available on
6429 @return The current value of ES.
6440 Reads the current value of FS Data Segment Register (FS).
6442 Reads and returns the current value of FS. This function is only available on
6445 @return The current value of FS.
6456 Reads the current value of GS Data Segment Register (GS).
6458 Reads and returns the current value of GS. This function is only available on
6461 @return The current value of GS.
6472 Reads the current value of Stack Segment Register (SS).
6474 Reads and returns the current value of SS. This function is only available on
6477 @return The current value of SS.
6488 Reads the current value of Task Register (TR).
6490 Reads and returns the current value of TR. This function is only available on
6493 @return The current value of TR.
6504 Reads the current Global Descriptor Table Register(GDTR) descriptor.
6506 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
6507 function is only available on IA-32 and x64.
6509 If Gdtr is NULL, then ASSERT().
6511 @param Gdtr The pointer to a GDTR descriptor.
6517 OUT IA32_DESCRIPTOR
*Gdtr
6522 Writes the current Global Descriptor Table Register (GDTR) descriptor.
6524 Writes and the current GDTR descriptor specified by Gdtr. This function is
6525 only available on IA-32 and x64.
6527 If Gdtr is NULL, then ASSERT().
6529 @param Gdtr The pointer to a GDTR descriptor.
6535 IN CONST IA32_DESCRIPTOR
*Gdtr
6540 Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.
6542 Reads and returns the current IDTR descriptor and returns it in Idtr. This
6543 function is only available on IA-32 and x64.
6545 If Idtr is NULL, then ASSERT().
6547 @param Idtr The pointer to a IDTR descriptor.
6553 OUT IA32_DESCRIPTOR
*Idtr
6558 Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.
6560 Writes the current IDTR descriptor and returns it in Idtr. This function is
6561 only available on IA-32 and x64.
6563 If Idtr is NULL, then ASSERT().
6565 @param Idtr The pointer to a IDTR descriptor.
6571 IN CONST IA32_DESCRIPTOR
*Idtr
6576 Reads the current Local Descriptor Table Register(LDTR) selector.
6578 Reads and returns the current 16-bit LDTR descriptor value. This function is
6579 only available on IA-32 and x64.
6581 @return The current selector of LDT.
6592 Writes the current Local Descriptor Table Register (LDTR) selector.
6594 Writes and the current LDTR descriptor specified by Ldtr. This function is
6595 only available on IA-32 and x64.
6597 @param Ldtr 16-bit LDTR selector value.
6608 Save the current floating point/SSE/SSE2 context to a buffer.
6610 Saves the current floating point/SSE/SSE2 state to the buffer specified by
6611 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
6612 available on IA-32 and x64.
6614 If Buffer is NULL, then ASSERT().
6615 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6617 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
6623 OUT IA32_FX_BUFFER
*Buffer
6628 Restores the current floating point/SSE/SSE2 context from a buffer.
6630 Restores the current floating point/SSE/SSE2 state from the buffer specified
6631 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
6632 only available on IA-32 and x64.
6634 If Buffer is NULL, then ASSERT().
6635 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6636 If Buffer was not saved with AsmFxSave(), then ASSERT().
6638 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
6644 IN CONST IA32_FX_BUFFER
*Buffer
6649 Reads the current value of 64-bit MMX Register #0 (MM0).
6651 Reads and returns the current value of MM0. This function is only available
6654 @return The current value of MM0.
6665 Reads the current value of 64-bit MMX Register #1 (MM1).
6667 Reads and returns the current value of MM1. This function is only available
6670 @return The current value of MM1.
6681 Reads the current value of 64-bit MMX Register #2 (MM2).
6683 Reads and returns the current value of MM2. This function is only available
6686 @return The current value of MM2.
6697 Reads the current value of 64-bit MMX Register #3 (MM3).
6699 Reads and returns the current value of MM3. This function is only available
6702 @return The current value of MM3.
6713 Reads the current value of 64-bit MMX Register #4 (MM4).
6715 Reads and returns the current value of MM4. This function is only available
6718 @return The current value of MM4.
6729 Reads the current value of 64-bit MMX Register #5 (MM5).
6731 Reads and returns the current value of MM5. This function is only available
6734 @return The current value of MM5.
6745 Reads the current value of 64-bit MMX Register #6 (MM6).
6747 Reads and returns the current value of MM6. This function is only available
6750 @return The current value of MM6.
6761 Reads the current value of 64-bit MMX Register #7 (MM7).
6763 Reads and returns the current value of MM7. This function is only available
6766 @return The current value of MM7.
6777 Writes the current value of 64-bit MMX Register #0 (MM0).
6779 Writes the current value of MM0. This function is only available on IA32 and
6782 @param Value The 64-bit value to write to MM0.
6793 Writes the current value of 64-bit MMX Register #1 (MM1).
6795 Writes the current value of MM1. This function is only available on IA32 and
6798 @param Value The 64-bit value to write to MM1.
6809 Writes the current value of 64-bit MMX Register #2 (MM2).
6811 Writes the current value of MM2. This function is only available on IA32 and
6814 @param Value The 64-bit value to write to MM2.
6825 Writes the current value of 64-bit MMX Register #3 (MM3).
6827 Writes the current value of MM3. This function is only available on IA32 and
6830 @param Value The 64-bit value to write to MM3.
6841 Writes the current value of 64-bit MMX Register #4 (MM4).
6843 Writes the current value of MM4. This function is only available on IA32 and
6846 @param Value The 64-bit value to write to MM4.
6857 Writes the current value of 64-bit MMX Register #5 (MM5).
6859 Writes the current value of MM5. This function is only available on IA32 and
6862 @param Value The 64-bit value to write to MM5.
6873 Writes the current value of 64-bit MMX Register #6 (MM6).
6875 Writes the current value of MM6. This function is only available on IA32 and
6878 @param Value The 64-bit value to write to MM6.
6889 Writes the current value of 64-bit MMX Register #7 (MM7).
6891 Writes the current value of MM7. This function is only available on IA32 and
6894 @param Value The 64-bit value to write to MM7.
6905 Reads the current value of Time Stamp Counter (TSC).
6907 Reads and returns the current value of TSC. This function is only available
6910 @return The current value of TSC
6921 Reads the current value of a Performance Counter (PMC).
6923 Reads and returns the current value of performance counter specified by
6924 Index. This function is only available on IA-32 and x64.
6926 @param Index The 32-bit Performance Counter index to read.
6928 @return The value of the PMC specified by Index.
6939 Sets up a monitor buffer that is used by AsmMwait().
6941 Executes a MONITOR instruction with the register state specified by Eax, Ecx
6942 and Edx. Returns Eax. This function is only available on IA-32 and x64.
6944 @param Eax The value to load into EAX or RAX before executing the MONITOR
6946 @param Ecx The value to load into ECX or RCX before executing the MONITOR
6948 @param Edx The value to load into EDX or RDX before executing the MONITOR
6964 Executes an MWAIT instruction.
6966 Executes an MWAIT instruction with the register state specified by Eax and
6967 Ecx. Returns Eax. This function is only available on IA-32 and x64.
6969 @param Eax The value to load into EAX or RAX before executing the MONITOR
6971 @param Ecx The value to load into ECX or RCX before executing the MONITOR
6986 Executes a WBINVD instruction.
6988 Executes a WBINVD instruction. This function is only available on IA-32 and
7000 Executes a INVD instruction.
7002 Executes a INVD instruction. This function is only available on IA-32 and
7014 Flushes a cache line from all the instruction and data caches within the
7015 coherency domain of the CPU.
7017 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
7018 This function is only available on IA-32 and x64.
7020 @param LinearAddress The address of the cache line to flush. If the CPU is
7021 in a physical addressing mode, then LinearAddress is a
7022 physical address. If the CPU is in a virtual
7023 addressing mode, then LinearAddress is a virtual
7026 @return LinearAddress.
7031 IN VOID
*LinearAddress
7036 Enables the 32-bit paging mode on the CPU.
7038 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
7039 must be properly initialized prior to calling this service. This function
7040 assumes the current execution mode is 32-bit protected mode. This function is
7041 only available on IA-32. After the 32-bit paging mode is enabled, control is
7042 transferred to the function specified by EntryPoint using the new stack
7043 specified by NewStack and passing in the parameters specified by Context1 and
7044 Context2. Context1 and Context2 are optional and may be NULL. The function
7045 EntryPoint must never return.
7047 If the current execution mode is not 32-bit protected mode, then ASSERT().
7048 If EntryPoint is NULL, then ASSERT().
7049 If NewStack is NULL, then ASSERT().
7051 There are a number of constraints that must be followed before calling this
7053 1) Interrupts must be disabled.
7054 2) The caller must be in 32-bit protected mode with flat descriptors. This
7055 means all descriptors must have a base of 0 and a limit of 4GB.
7056 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
7058 4) CR3 must point to valid page tables that will be used once the transition
7059 is complete, and those page tables must guarantee that the pages for this
7060 function and the stack are identity mapped.
7062 @param EntryPoint A pointer to function to call with the new stack after
7064 @param Context1 A pointer to the context to pass into the EntryPoint
7065 function as the first parameter after paging is enabled.
7066 @param Context2 A pointer to the context to pass into the EntryPoint
7067 function as the second parameter after paging is enabled.
7068 @param NewStack A pointer to the new stack to use for the EntryPoint
7069 function after paging is enabled.
7075 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
7076 IN VOID
*Context1
, OPTIONAL
7077 IN VOID
*Context2
, OPTIONAL
7083 Disables the 32-bit paging mode on the CPU.
7085 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
7086 mode. This function assumes the current execution mode is 32-paged protected
7087 mode. This function is only available on IA-32. After the 32-bit paging mode
7088 is disabled, control is transferred to the function specified by EntryPoint
7089 using the new stack specified by NewStack and passing in the parameters
7090 specified by Context1 and Context2. Context1 and Context2 are optional and
7091 may be NULL. The function EntryPoint must never return.
7093 If the current execution mode is not 32-bit paged mode, then ASSERT().
7094 If EntryPoint is NULL, then ASSERT().
7095 If NewStack is NULL, then ASSERT().
7097 There are a number of constraints that must be followed before calling this
7099 1) Interrupts must be disabled.
7100 2) The caller must be in 32-bit paged mode.
7101 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
7102 4) CR3 must point to valid page tables that guarantee that the pages for
7103 this function and the stack are identity mapped.
7105 @param EntryPoint A pointer to function to call with the new stack after
7107 @param Context1 A pointer to the context to pass into the EntryPoint
7108 function as the first parameter after paging is disabled.
7109 @param Context2 A pointer to the context to pass into the EntryPoint
7110 function as the second parameter after paging is
7112 @param NewStack A pointer to the new stack to use for the EntryPoint
7113 function after paging is disabled.
7118 AsmDisablePaging32 (
7119 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
7120 IN VOID
*Context1
, OPTIONAL
7121 IN VOID
*Context2
, OPTIONAL
7127 Enables the 64-bit paging mode on the CPU.
7129 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
7130 must be properly initialized prior to calling this service. This function
7131 assumes the current execution mode is 32-bit protected mode with flat
7132 descriptors. This function is only available on IA-32. After the 64-bit
7133 paging mode is enabled, control is transferred to the function specified by
7134 EntryPoint using the new stack specified by NewStack and passing in the
7135 parameters specified by Context1 and Context2. Context1 and Context2 are
7136 optional and may be 0. The function EntryPoint must never return.
7138 If the current execution mode is not 32-bit protected mode with flat
7139 descriptors, then ASSERT().
7140 If EntryPoint is 0, then ASSERT().
7141 If NewStack is 0, then ASSERT().
7143 @param Cs The 16-bit selector to load in the CS before EntryPoint
7144 is called. The descriptor in the GDT that this selector
7145 references must be setup for long mode.
7146 @param EntryPoint The 64-bit virtual address of the function to call with
7147 the new stack after paging is enabled.
7148 @param Context1 The 64-bit virtual address of the context to pass into
7149 the EntryPoint function as the first parameter after
7151 @param Context2 The 64-bit virtual address of the context to pass into
7152 the EntryPoint function as the second parameter after
7154 @param NewStack The 64-bit virtual address of the new stack to use for
7155 the EntryPoint function after paging is enabled.
7162 IN UINT64 EntryPoint
,
7163 IN UINT64 Context1
, OPTIONAL
7164 IN UINT64 Context2
, OPTIONAL
7170 Disables the 64-bit paging mode on the CPU.
7172 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
7173 mode. This function assumes the current execution mode is 64-paging mode.
7174 This function is only available on x64. After the 64-bit paging mode is
7175 disabled, control is transferred to the function specified by EntryPoint
7176 using the new stack specified by NewStack and passing in the parameters
7177 specified by Context1 and Context2. Context1 and Context2 are optional and
7178 may be 0. The function EntryPoint must never return.
7180 If the current execution mode is not 64-bit paged mode, then ASSERT().
7181 If EntryPoint is 0, then ASSERT().
7182 If NewStack is 0, then ASSERT().
7184 @param Cs The 16-bit selector to load in the CS before EntryPoint
7185 is called. The descriptor in the GDT that this selector
7186 references must be setup for 32-bit protected mode.
7187 @param EntryPoint The 64-bit virtual address of the function to call with
7188 the new stack after paging is disabled.
7189 @param Context1 The 64-bit virtual address of the context to pass into
7190 the EntryPoint function as the first parameter after
7192 @param Context2 The 64-bit virtual address of the context to pass into
7193 the EntryPoint function as the second parameter after
7195 @param NewStack The 64-bit virtual address of the new stack to use for
7196 the EntryPoint function after paging is disabled.
7201 AsmDisablePaging64 (
7203 IN UINT32 EntryPoint
,
7204 IN UINT32 Context1
, OPTIONAL
7205 IN UINT32 Context2
, OPTIONAL
7211 // 16-bit thunking services
7215 Retrieves the properties for 16-bit thunk functions.
7217 Computes the size of the buffer and stack below 1MB required to use the
7218 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
7219 buffer size is returned in RealModeBufferSize, and the stack size is returned
7220 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
7221 then the actual minimum stack size is ExtraStackSize plus the maximum number
7222 of bytes that need to be passed to the 16-bit real mode code.
7224 If RealModeBufferSize is NULL, then ASSERT().
7225 If ExtraStackSize is NULL, then ASSERT().
7227 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
7228 required to use the 16-bit thunk functions.
7229 @param ExtraStackSize A pointer to the extra size of stack below 1MB
7230 that the 16-bit thunk functions require for
7231 temporary storage in the transition to and from
7237 AsmGetThunk16Properties (
7238 OUT UINT32
*RealModeBufferSize
,
7239 OUT UINT32
*ExtraStackSize
7244 Prepares all structures a code required to use AsmThunk16().
7246 Prepares all structures and code required to use AsmThunk16().
7248 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7249 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7251 If ThunkContext is NULL, then ASSERT().
7253 @param ThunkContext A pointer to the context structure that describes the
7254 16-bit real mode code to call.
7260 IN OUT THUNK_CONTEXT
*ThunkContext
7265 Transfers control to a 16-bit real mode entry point and returns the results.
7267 Transfers control to a 16-bit real mode entry point and returns the results.
7268 AsmPrepareThunk16() must be called with ThunkContext before this function is used.
7269 This function must be called with interrupts disabled.
7271 The register state from the RealModeState field of ThunkContext is restored just prior
7272 to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState,
7273 which is used to set the interrupt state when a 16-bit real mode entry point is called.
7274 Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.
7275 The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to
7276 the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function.
7277 The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,
7278 so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment
7279 and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry
7280 point must exit with a RETF instruction. The register state is captured into RealModeState immediately
7281 after the RETF instruction is executed.
7283 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7284 or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure
7285 the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode.
7287 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7288 then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode.
7289 This includes the base vectors, the interrupt masks, and the edge/level trigger mode.
7291 If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code
7292 is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.
7294 If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7295 ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to
7296 disable the A20 mask.
7298 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in
7299 ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails,
7300 then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7302 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in
7303 ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7305 If ThunkContext is NULL, then ASSERT().
7306 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
7307 If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7308 ThunkAttributes, then ASSERT().
7310 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7311 virtual to physical mappings for ThunkContext.RealModeBuffer are mapped 1:1.
7313 @param ThunkContext A pointer to the context structure that describes the
7314 16-bit real mode code to call.
7320 IN OUT THUNK_CONTEXT
*ThunkContext
7325 Prepares all structures and code for a 16-bit real mode thunk, transfers
7326 control to a 16-bit real mode entry point, and returns the results.
7328 Prepares all structures and code for a 16-bit real mode thunk, transfers
7329 control to a 16-bit real mode entry point, and returns the results. If the
7330 caller only need to perform a single 16-bit real mode thunk, then this
7331 service should be used. If the caller intends to make more than one 16-bit
7332 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
7333 once and AsmThunk16() can be called for each 16-bit real mode thunk.
7335 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7336 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7338 See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.
7340 @param ThunkContext A pointer to the context structure that describes the
7341 16-bit real mode code to call.
7346 AsmPrepareAndThunk16 (
7347 IN OUT THUNK_CONTEXT
*ThunkContext
7351 Generates a 16-bit random number through RDRAND instruction.
7353 if Rand is NULL, then ASSERT().
7355 @param[out] Rand Buffer pointer to store the random result.
7357 @retval TRUE RDRAND call was successful.
7358 @retval FALSE Failed attempts to call RDRAND.
7368 Generates a 32-bit random number through RDRAND instruction.
7370 if Rand is NULL, then ASSERT().
7372 @param[out] Rand Buffer pointer to store the random result.
7374 @retval TRUE RDRAND call was successful.
7375 @retval FALSE Failed attempts to call RDRAND.
7385 Generates a 64-bit random number through RDRAND instruction.
7387 if Rand is NULL, then ASSERT().
7389 @param[out] Rand Buffer pointer to store the random result.
7391 @retval TRUE RDRAND call was successful.
7392 @retval FALSE Failed attempts to call RDRAND.
7402 Load given selector into TR register.
7404 @param[in] Selector Task segment selector
7413 Performs a serializing operation on all load-from-memory instructions that
7414 were issued prior the AsmLfence function.
7416 Executes a LFENCE instruction. This function is only available on IA-32 and x64.
7426 Executes a XGETBV instruction
7428 Executes a XGETBV instruction. This function is only available on IA-32 and
7431 @param[in] Index Extended control register index
7433 @return The current value of the extended control register
7443 Executes a VMGEXIT instruction (VMMCALL with a REP prefix)
7445 Executes a VMGEXIT instruction. This function is only available on IA-32 and
7457 Patch the immediate operand of an IA32 or X64 instruction such that the byte,
7458 word, dword or qword operand is encoded at the end of the instruction's
7459 binary representation.
7461 This function should be used to update object code that was compiled with
7462 NASM from assembly source code. Example:
7466 mov eax, strict dword 0 ; the imm32 zero operand will be patched
7472 X86_ASSEMBLY_PATCH_LABEL gPatchCr3;
7473 PatchInstructionX86 (gPatchCr3, AsmReadCr3 (), 4);
7475 @param[out] InstructionEnd Pointer right past the instruction to patch. The
7476 immediate operand to patch is expected to
7477 comprise the trailing bytes of the instruction.
7478 If InstructionEnd is closer to address 0 than
7479 ValueSize permits, then ASSERT().
7481 @param[in] PatchValue The constant to write to the immediate operand.
7482 The caller is responsible for ensuring that
7483 PatchValue can be represented in the byte, word,
7484 dword or qword operand (as indicated through
7485 ValueSize); otherwise ASSERT().
7487 @param[in] ValueSize The size of the operand in bytes; must be 1, 2,
7488 4, or 8. ASSERT() otherwise.
7492 PatchInstructionX86 (
7493 OUT X86_ASSEMBLY_PATCH_LABEL
*InstructionEnd
,
7494 IN UINT64 PatchValue
,
7498 #endif // defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
7499 #endif // !defined (__BASE_LIB__)