2 Provides string functions, linked list functions, math functions, synchronization
3 functions, and CPU architecture specific functions.
5 Copyright (c) 2006 - 2008, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20 /// Definitions for SPIN_LOCK
22 typedef volatile UINTN SPIN_LOCK
;
25 // Definitions for architecture specific types
27 #if defined (MDE_CPU_IA32)
29 /// IA32 context buffer used by SetJump() and LongJump()
38 } BASE_LIBRARY_JUMP_BUFFER
;
40 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4
42 #elif defined (MDE_CPU_IPF)
45 /// IPF context buffer used by SetJump() and LongJump()
80 UINT64 AfterSpillUNAT
;
86 } BASE_LIBRARY_JUMP_BUFFER
;
88 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 0x10
90 #elif defined (MDE_CPU_X64)
92 /// X64 context buffer used by SetJump() and LongJump()
105 } BASE_LIBRARY_JUMP_BUFFER
;
107 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
109 #elif defined (MDE_CPU_EBC)
111 /// EBC context buffer used by SetJump() and LongJump()
119 } BASE_LIBRARY_JUMP_BUFFER
;
121 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
124 #error Unknown Processor Type
132 Copies one Null-terminated Unicode string to another Null-terminated Unicode
133 string and returns the new Unicode string.
135 This function copies the contents of the Unicode string Source to the Unicode
136 string Destination, and returns Destination. If Source and Destination
137 overlap, then the results are undefined.
139 If Destination is NULL, then ASSERT().
140 If Destination is not aligned on a 16-bit boundary, then ASSERT().
141 If Source is NULL, then ASSERT().
142 If Source is not aligned on a 16-bit boundary, then ASSERT().
143 If Source and Destination overlap, then ASSERT().
144 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
145 PcdMaximumUnicodeStringLength Unicode characters not including the
146 Null-terminator, then ASSERT().
148 @param Destination Pointer to a Null-terminated Unicode string.
149 @param Source Pointer to a Null-terminated Unicode string.
157 OUT CHAR16
*Destination
,
158 IN CONST CHAR16
*Source
163 Copies up to a specified length from one Null-terminated Unicode string to
164 another Null-terminated Unicode string and returns the new Unicode string.
166 This function copies the contents of the Unicode string Source to the Unicode
167 string Destination, and returns Destination. At most, Length Unicode
168 characters are copied from Source to Destination. If Length is 0, then
169 Destination is returned unmodified. If Length is greater that the number of
170 Unicode characters in Source, then Destination is padded with Null Unicode
171 characters. If Source and Destination overlap, then the results are
174 If Length > 0 and Destination is NULL, then ASSERT().
175 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
176 If Length > 0 and Source is NULL, then ASSERT().
177 If Length > 0 and Source is not aligned on a 16-bit bounadry, then ASSERT().
178 If Source and Destination overlap, then ASSERT().
179 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
180 PcdMaximumUnicodeStringLength Unicode characters not including the
181 Null-terminator, then ASSERT().
183 @param Destination Pointer to a Null-terminated Unicode string.
184 @param Source Pointer to a Null-terminated Unicode string.
185 @param Length Maximum number of Unicode characters to copy.
193 OUT CHAR16
*Destination
,
194 IN CONST CHAR16
*Source
,
200 Returns the length of a Null-terminated Unicode string.
202 This function returns the number of Unicode characters in the Null-terminated
203 Unicode string specified by String.
205 If String is NULL, then ASSERT().
206 If String is not aligned on a 16-bit boundary, then ASSERT().
207 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
208 PcdMaximumUnicodeStringLength Unicode characters not including the
209 Null-terminator, then ASSERT().
211 @param String Pointer to a Null-terminated Unicode string.
213 @return The length of String.
219 IN CONST CHAR16
*String
224 Returns the size of a Null-terminated Unicode string in bytes, including the
227 This function returns the size, in bytes, of the Null-terminated Unicode string
230 If String is NULL, then ASSERT().
231 If String is not aligned on a 16-bit boundary, then ASSERT().
232 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
233 PcdMaximumUnicodeStringLength Unicode characters not including the
234 Null-terminator, then ASSERT().
236 @param String Pointer to a Null-terminated Unicode string.
238 @return The size of String.
244 IN CONST CHAR16
*String
249 Compares two Null-terminated Unicode strings, and returns the difference
250 between the first mismatched Unicode characters.
252 This function compares the Null-terminated Unicode string FirstString to the
253 Null-terminated Unicode string SecondString. If FirstString is identical to
254 SecondString, then 0 is returned. Otherwise, the value returned is the first
255 mismatched Unicode character in SecondString subtracted from the first
256 mismatched Unicode character in FirstString.
258 If FirstString is NULL, then ASSERT().
259 If FirstString is not aligned on a 16-bit boundary, then ASSERT().
260 If SecondString is NULL, then ASSERT().
261 If SecondString is not aligned on a 16-bit boundary, then ASSERT().
262 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
263 than PcdMaximumUnicodeStringLength Unicode characters not including the
264 Null-terminator, then ASSERT().
265 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
266 than PcdMaximumUnicodeStringLength Unicode characters not including the
267 Null-terminator, then ASSERT().
269 @param FirstString Pointer to a Null-terminated Unicode string.
270 @param SecondString Pointer to a Null-terminated Unicode string.
272 @retval 0 FirstString is identical to SecondString.
273 @return others FirstString is not identical to SecondString.
279 IN CONST CHAR16
*FirstString
,
280 IN CONST CHAR16
*SecondString
285 Compares up to a specified length the contents of two Null-terminated Unicode strings,
286 and returns the difference between the first mismatched Unicode characters.
288 This function compares the Null-terminated Unicode string FirstString to the
289 Null-terminated Unicode string SecondString. At most, Length Unicode
290 characters will be compared. If Length is 0, then 0 is returned. If
291 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
292 value returned is the first mismatched Unicode character in SecondString
293 subtracted from the first mismatched Unicode character in FirstString.
295 If Length > 0 and FirstString is NULL, then ASSERT().
296 If Length > 0 and FirstString is not aligned on a 16-bit bounadary, then ASSERT().
297 If Length > 0 and SecondString is NULL, then ASSERT().
298 If Length > 0 and SecondString is not aligned on a 16-bit bounadary, then ASSERT().
299 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
300 than PcdMaximumUnicodeStringLength Unicode characters not including the
301 Null-terminator, then ASSERT().
302 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
303 than PcdMaximumUnicodeStringLength Unicode characters not including the
304 Null-terminator, then ASSERT().
306 @param FirstString Pointer to a Null-terminated Unicode string.
307 @param SecondString Pointer to a Null-terminated Unicode string.
308 @param Length Maximum number of Unicode characters to compare.
310 @retval 0 FirstString is identical to SecondString.
311 @return others FirstString is not identical to SecondString.
317 IN CONST CHAR16
*FirstString
,
318 IN CONST CHAR16
*SecondString
,
324 Concatenates one Null-terminated Unicode string to another Null-terminated
325 Unicode string, and returns the concatenated Unicode string.
327 This function concatenates two Null-terminated Unicode strings. The contents
328 of Null-terminated Unicode string Source are concatenated to the end of
329 Null-terminated Unicode string Destination. The Null-terminated concatenated
330 Unicode String is returned. If Source and Destination overlap, then the
331 results are undefined.
333 If Destination is NULL, then ASSERT().
334 If Destination is not aligned on a 16-bit bounadary, then ASSERT().
335 If Source is NULL, then ASSERT().
336 If Source is not aligned on a 16-bit bounadary, then ASSERT().
337 If Source and Destination overlap, then ASSERT().
338 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
339 than PcdMaximumUnicodeStringLength Unicode characters not including the
340 Null-terminator, then ASSERT().
341 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
342 PcdMaximumUnicodeStringLength Unicode characters not including the
343 Null-terminator, then ASSERT().
344 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
345 and Source results in a Unicode string with more than
346 PcdMaximumUnicodeStringLength Unicode characters not including the
347 Null-terminator, then ASSERT().
349 @param Destination Pointer to a Null-terminated Unicode string.
350 @param Source Pointer to a Null-terminated Unicode string.
358 IN OUT CHAR16
*Destination
,
359 IN CONST CHAR16
*Source
364 Concatenates up to a specified length one Null-terminated Unicode to the end
365 of another Null-terminated Unicode string, and returns the concatenated
368 This function concatenates two Null-terminated Unicode strings. The contents
369 of Null-terminated Unicode string Source are concatenated to the end of
370 Null-terminated Unicode string Destination, and Destination is returned. At
371 most, Length Unicode characters are concatenated from Source to the end of
372 Destination, and Destination is always Null-terminated. If Length is 0, then
373 Destination is returned unmodified. If Source and Destination overlap, then
374 the results are undefined.
376 If Destination is NULL, then ASSERT().
377 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
378 If Length > 0 and Source is NULL, then ASSERT().
379 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
380 If Source and Destination overlap, then ASSERT().
381 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
382 than PcdMaximumUnicodeStringLength Unicode characters not including the
383 Null-terminator, then ASSERT().
384 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
385 PcdMaximumUnicodeStringLength Unicode characters not including the
386 Null-terminator, then ASSERT().
387 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
388 and Source results in a Unicode string with more than
389 PcdMaximumUnicodeStringLength Unicode characters not including the
390 Null-terminator, then ASSERT().
392 @param Destination Pointer to a Null-terminated Unicode string.
393 @param Source Pointer to a Null-terminated Unicode string.
394 @param Length Maximum number of Unicode characters to concatenate from
403 IN OUT CHAR16
*Destination
,
404 IN CONST CHAR16
*Source
,
409 Returns the first occurrence of a Null-terminated Unicode sub-string
410 in a Null-terminated Unicode string.
412 This function scans the contents of the Null-terminated Unicode string
413 specified by String and returns the first occurrence of SearchString.
414 If SearchString is not found in String, then NULL is returned. If
415 the length of SearchString is zero, then String is
418 If String is NULL, then ASSERT().
419 If String is not aligned on a 16-bit boundary, then ASSERT().
420 If SearchString is NULL, then ASSERT().
421 If SearchString is not aligned on a 16-bit boundary, then ASSERT().
423 If PcdMaximumUnicodeStringLength is not zero, and SearchString
424 or String contains more than PcdMaximumUnicodeStringLength Unicode
425 characters not including the Null-terminator, then ASSERT().
427 @param String Pointer to a Null-terminated Unicode string.
428 @param SearchString Pointer to a Null-terminated Unicode string to search for.
430 @retval NULL If the SearchString does not appear in String.
431 @return others If there is a match.
437 IN CONST CHAR16
*String
,
438 IN CONST CHAR16
*SearchString
442 Convert a Null-terminated Unicode decimal string to a value of
445 This function returns a value of type UINTN by interpreting the contents
446 of the Unicode string specified by String as a decimal number. The format
447 of the input Unicode string String is:
449 [spaces] [decimal digits].
451 The valid decimal digit character is in the range [0-9]. The
452 function will ignore the pad space, which includes spaces or
453 tab characters, before [decimal digits]. The running zero in the
454 beginning of [decimal digits] will be ignored. Then, the function
455 stops at the first character that is a not a valid decimal character
456 or a Null-terminator, whichever one comes first.
458 If String is NULL, then ASSERT().
459 If String is not aligned in a 16-bit boundary, then ASSERT().
460 If String has only pad spaces, then 0 is returned.
461 If String has no pad spaces or valid decimal digits,
463 If the number represented by String overflows according
464 to the range defined by UINTN, then ASSERT().
466 If PcdMaximumUnicodeStringLength is not zero, and String contains
467 more than PcdMaximumUnicodeStringLength Unicode characters not including
468 the Null-terminator, then ASSERT().
470 @param String Pointer to a Null-terminated Unicode string.
472 @retval Value translated from String.
478 IN CONST CHAR16
*String
482 Convert a Null-terminated Unicode decimal string to a value of
485 This function returns a value of type UINT64 by interpreting the contents
486 of the Unicode string specified by String as a decimal number. The format
487 of the input Unicode string String is:
489 [spaces] [decimal digits].
491 The valid decimal digit character is in the range [0-9]. The
492 function will ignore the pad space, which includes spaces or
493 tab characters, before [decimal digits]. The running zero in the
494 beginning of [decimal digits] will be ignored. Then, the function
495 stops at the first character that is a not a valid decimal character
496 or a Null-terminator, whichever one comes first.
498 If String is NULL, then ASSERT().
499 If String is not aligned in a 16-bit boundary, then ASSERT().
500 If String has only pad spaces, then 0 is returned.
501 If String has no pad spaces or valid decimal digits,
503 If the number represented by String overflows according
504 to the range defined by UINT64, then ASSERT().
506 If PcdMaximumUnicodeStringLength is not zero, and String contains
507 more than PcdMaximumUnicodeStringLength Unicode characters not including
508 the Null-terminator, then ASSERT().
510 @param String Pointer to a Null-terminated Unicode string.
512 @retval Value translated from String.
518 IN CONST CHAR16
*String
523 Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.
525 This function returns a value of type UINTN by interpreting the contents
526 of the Unicode string specified by String as a hexadecimal number.
527 The format of the input Unicode string String is:
529 [spaces][zeros][x][hexadecimal digits].
531 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
532 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
533 If "x" appears in the input string, it must be prefixed with at least one 0.
534 The function will ignore the pad space, which includes spaces or tab characters,
535 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
536 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
537 first valid hexadecimal digit. Then, the function stops at the first character that is
538 a not a valid hexadecimal character or NULL, whichever one comes first.
540 If String is NULL, then ASSERT().
541 If String is not aligned in a 16-bit boundary, then ASSERT().
542 If String has only pad spaces, then zero is returned.
543 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
544 then zero is returned.
545 If the number represented by String overflows according to the range defined by
546 UINTN, then ASSERT().
548 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
549 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
552 @param String Pointer to a Null-terminated Unicode string.
554 @retval Value translated from String.
560 IN CONST CHAR16
*String
565 Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.
567 This function returns a value of type UINT64 by interpreting the contents
568 of the Unicode string specified by String as a hexadecimal number.
569 The format of the input Unicode string String is
571 [spaces][zeros][x][hexadecimal digits].
573 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
574 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
575 If "x" appears in the input string, it must be prefixed with at least one 0.
576 The function will ignore the pad space, which includes spaces or tab characters,
577 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
578 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
579 first valid hexadecimal digit. Then, the function stops at the first character that is
580 a not a valid hexadecimal character or NULL, whichever one comes first.
582 If String is NULL, then ASSERT().
583 If String is not aligned in a 16-bit boundary, then ASSERT().
584 If String has only pad spaces, then zero is returned.
585 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
586 then zero is returned.
587 If the number represented by String overflows according to the range defined by
588 UINT64, then ASSERT().
590 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
591 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
594 @param String Pointer to a Null-terminated Unicode string.
596 @retval Value translated from String.
602 IN CONST CHAR16
*String
606 Convert a nibble in the low 4 bits of a byte to a Unicode hexadecimal character.
608 This function converts a nibble in the low 4 bits of a byte to a Unicode hexadecimal
609 character For example, the nibble 0x01 and 0x0A will converted to L'1' and L'A'
612 The upper nibble in the input byte will be masked off.
614 @param Nibble The nibble which is in the low 4 bits of the input byte.
616 @retval CHAR16 The Unicode hexadecimal character.
626 Convert binary buffer to a Unicode String in a specified sequence.
628 This function converts bytes in the memory block pointed by Buffer to a Unicode String Str.
629 Each byte will be represented by two Unicode characters. For example, byte 0xA1 will
630 be converted into two Unicode character L'A' and L'1'. In the output String, the Unicode Character
631 for the Most Significant Nibble will be put before the Unicode Character for the Least Significant
632 Nibble. The output string for the buffer containing a single byte 0xA1 will be L"A1".
633 For a buffer with multiple bytes, the Unicode character produced by the first byte will be put into the
634 the last character in the output string. The one next to first byte will be put into the
635 character before the last character. This rules applies to the rest of the bytes. The Unicode
636 character by the last byte will be put into the first character in the output string. For example,
637 the input buffer for a 64-bits unsigned integer 0x12345678abcdef1234 will be converted to
638 a Unicode string equal to L"12345678abcdef1234".
640 @param String On input, String is pointed to the buffer allocated for the convertion.
641 @param StringLen The Length of String buffer to hold the output String. The length must include the tailing '\0' character.
642 The StringLen required to convert a N bytes Buffer will be a least equal to or greater
644 @param Buffer The pointer to a input buffer.
645 @param BufferSizeInBytes Length in bytes of the input buffer.
648 @retval EFI_SUCCESS The convertion is successful. All bytes in Buffer has been convert to the corresponding
649 Unicode character and placed into the right place in String.
650 @retval EFI_BUFFER_TOO_SMALL StringSizeInBytes is smaller than 2 * N + 1the number of bytes required to
651 complete the convertion.
656 IN OUT CHAR16
*String
,
657 IN OUT UINTN
*StringLen
,
658 IN CONST UINT8
*Buffer
,
659 IN UINTN BufferSizeInBytes
664 Convert a Unicode string consisting of hexadecimal characters to a output byte buffer.
666 This function converts a Unicode string consisting of characters in the range of Hexadecimal
667 character (L'0' to L'9', L'A' to L'F' and L'a' to L'f') to a output byte buffer. The function will stop
668 at the first non-hexadecimal character or the NULL character. The convertion process can be
669 simply viewed as the reverse operations defined by BufToHexString. Two Unicode characters will be
670 converted into one byte. The first Unicode character represents the Most Significant Nibble and the
671 second Unicode character represents the Least Significant Nibble in the output byte.
672 The first pair of Unicode characters represents the last byte in the output buffer. The second pair of Unicode
673 characters represent the the byte preceding the last byte. This rule applies to the rest pairs of bytes.
674 The last pair represent the first byte in the output buffer.
676 For example, a Unciode String L"12345678" will be converted into a buffer wil the following bytes
677 (first byte is the byte in the lowest memory address): "0x78, 0x56, 0x34, 0x12".
679 If String has N valid hexadecimal characters for conversion, the caller must make sure Buffer is at least
680 N/2 (if N is even) or (N+1)/2 (if N if odd) bytes.
682 @param Buffer The output buffer allocated by the caller.
683 @param BufferSizeInBytes On input, the size in bytes of Buffer. On output, it is updated to
684 contain the size of the Buffer which is actually used for the converstion.
685 For Unicode string with 2*N hexadecimal characters (not including the
686 tailing NULL character), N bytes of Buffer will be used for the output.
687 @param String The input hexadecimal string.
688 @param ConvertedStrLen The number of hexadecimal characters used to produce content in output
691 @retval RETURN_BUFFER_TOO_SMALL The input BufferSizeInBytes is too small to hold the output. BufferSizeInBytes
692 will be updated to the size required for the converstion.
693 @retval RETURN_SUCCESS The convertion is successful or the first Unicode character from String
694 is hexadecimal. If ConvertedStrLen is not NULL, it is updated
695 to the number of hexadecimal character used for the converstion.
701 IN OUT UINTN
*BufferSizeInBytes
,
702 IN CONST CHAR16
*String
,
703 OUT UINTN
*ConvertedStrLen OPTIONAL
708 Test if a Unicode character is a hexadecimal digit. If true, the input
709 Unicode character is converted to a byte.
711 This function tests if a Unicode character is a hexadecimal digit. If true, the input
712 Unicode character is converted to a byte. For example, Unicode character
713 L'A' will be converted to 0x0A.
715 If Digit is NULL, then ASSERT.
717 @param Digit The output hexadecimal digit.
719 @param Char The input Unicode character.
721 @retval TRUE Char is in the range of Hexadecimal number. Digit is updated
722 to the byte value of the number.
723 @retval FALSE Char is not in the range of Hexadecimal number. Digit is keep
735 Convert a Null-terminated Unicode string to a Null-terminated
736 ASCII string and returns the ASCII string.
738 This function converts the content of the Unicode string Source
739 to the ASCII string Destination by copying the lower 8 bits of
740 each Unicode character. It returns Destination.
742 If any Unicode characters in Source contain non-zero value in
743 the upper 8 bits, then ASSERT().
745 If Destination is NULL, then ASSERT().
746 If Source is NULL, then ASSERT().
747 If Source is not aligned on a 16-bit boundary, then ASSERT().
748 If Source and Destination overlap, then ASSERT().
750 If PcdMaximumUnicodeStringLength is not zero, and Source contains
751 more than PcdMaximumUnicodeStringLength Unicode characters not including
752 the Null-terminator, then ASSERT().
754 If PcdMaximumAsciiStringLength is not zero, and Source contains more
755 than PcdMaximumAsciiStringLength Unicode characters not including the
756 Null-terminator, then ASSERT().
758 @param Source Pointer to a Null-terminated Unicode string.
759 @param Destination Pointer to a Null-terminated ASCII string.
766 UnicodeStrToAsciiStr (
767 IN CONST CHAR16
*Source
,
768 OUT CHAR8
*Destination
773 Copies one Null-terminated ASCII string to another Null-terminated ASCII
774 string and returns the new ASCII string.
776 This function copies the contents of the ASCII string Source to the ASCII
777 string Destination, and returns Destination. If Source and Destination
778 overlap, then the results are undefined.
780 If Destination is NULL, then ASSERT().
781 If Source is NULL, then ASSERT().
782 If Source and Destination overlap, then ASSERT().
783 If PcdMaximumAsciiStringLength is not zero and Source contains more than
784 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
787 @param Destination Pointer to a Null-terminated ASCII string.
788 @param Source Pointer to a Null-terminated ASCII string.
796 OUT CHAR8
*Destination
,
797 IN CONST CHAR8
*Source
802 Copies up to a specified length one Null-terminated ASCII string to another
803 Null-terminated ASCII string and returns the new ASCII string.
805 This function copies the contents of the ASCII string Source to the ASCII
806 string Destination, and returns Destination. At most, Length ASCII characters
807 are copied from Source to Destination. If Length is 0, then Destination is
808 returned unmodified. If Length is greater that the number of ASCII characters
809 in Source, then Destination is padded with Null ASCII characters. If Source
810 and Destination overlap, then the results are undefined.
812 If Destination is NULL, then ASSERT().
813 If Source is NULL, then ASSERT().
814 If Source and Destination overlap, then ASSERT().
815 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
816 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
819 @param Destination Pointer to a Null-terminated ASCII string.
820 @param Source Pointer to a Null-terminated ASCII string.
821 @param Length Maximum number of ASCII characters to copy.
829 OUT CHAR8
*Destination
,
830 IN CONST CHAR8
*Source
,
836 Returns the length of a Null-terminated ASCII string.
838 This function returns the number of ASCII characters in the Null-terminated
839 ASCII string specified by String.
841 If Length > 0 and Destination is NULL, then ASSERT().
842 If Length > 0 and Source is NULL, then ASSERT().
843 If PcdMaximumAsciiStringLength is not zero and String contains more than
844 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
847 @param String Pointer to a Null-terminated ASCII string.
849 @return The length of String.
855 IN CONST CHAR8
*String
860 Returns the size of a Null-terminated ASCII string in bytes, including the
863 This function returns the size, in bytes, of the Null-terminated ASCII string
866 If String is NULL, then ASSERT().
867 If PcdMaximumAsciiStringLength is not zero and String contains more than
868 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
871 @param String Pointer to a Null-terminated ASCII string.
873 @return The size of String.
879 IN CONST CHAR8
*String
884 Compares two Null-terminated ASCII strings, and returns the difference
885 between the first mismatched ASCII characters.
887 This function compares the Null-terminated ASCII string FirstString to the
888 Null-terminated ASCII string SecondString. If FirstString is identical to
889 SecondString, then 0 is returned. Otherwise, the value returned is the first
890 mismatched ASCII character in SecondString subtracted from the first
891 mismatched ASCII character in FirstString.
893 If FirstString is NULL, then ASSERT().
894 If SecondString is NULL, then ASSERT().
895 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
896 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
898 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
899 than PcdMaximumAsciiStringLength ASCII characters not including the
900 Null-terminator, then ASSERT().
902 @param FirstString Pointer to a Null-terminated ASCII string.
903 @param SecondString Pointer to a Null-terminated ASCII string.
905 @retval ==0 FirstString is identical to SecondString.
906 @retval !=0 FirstString is not identical to SecondString.
912 IN CONST CHAR8
*FirstString
,
913 IN CONST CHAR8
*SecondString
918 Performs a case insensitive comparison of two Null-terminated ASCII strings,
919 and returns the difference between the first mismatched ASCII characters.
921 This function performs a case insensitive comparison of the Null-terminated
922 ASCII string FirstString to the Null-terminated ASCII string SecondString. If
923 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
924 value returned is the first mismatched lower case ASCII character in
925 SecondString subtracted from the first mismatched lower case ASCII character
928 If FirstString is NULL, then ASSERT().
929 If SecondString is NULL, then ASSERT().
930 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
931 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
933 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
934 than PcdMaximumAsciiStringLength ASCII characters not including the
935 Null-terminator, then ASSERT().
937 @param FirstString Pointer to a Null-terminated ASCII string.
938 @param SecondString Pointer to a Null-terminated ASCII string.
940 @retval ==0 FirstString is identical to SecondString using case insensitive
942 @retval !=0 FirstString is not identical to SecondString using case
943 insensitive comparisons.
949 IN CONST CHAR8
*FirstString
,
950 IN CONST CHAR8
*SecondString
955 Compares two Null-terminated ASCII strings with maximum lengths, and returns
956 the difference between the first mismatched ASCII characters.
958 This function compares the Null-terminated ASCII string FirstString to the
959 Null-terminated ASCII string SecondString. At most, Length ASCII characters
960 will be compared. If Length is 0, then 0 is returned. If FirstString is
961 identical to SecondString, then 0 is returned. Otherwise, the value returned
962 is the first mismatched ASCII character in SecondString subtracted from the
963 first mismatched ASCII character in FirstString.
965 If Length > 0 and FirstString is NULL, then ASSERT().
966 If Length > 0 and SecondString is NULL, then ASSERT().
967 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
968 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
970 If PcdMaximumAsciiStringLength is not zero and SecondString contains more than
971 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
974 @param FirstString Pointer to a Null-terminated ASCII string.
975 @param SecondString Pointer to a Null-terminated ASCII string.
976 @param Length Maximum number of ASCII characters for compare.
978 @retval ==0 FirstString is identical to SecondString.
979 @retval !=0 FirstString is not identical to SecondString.
985 IN CONST CHAR8
*FirstString
,
986 IN CONST CHAR8
*SecondString
,
992 Concatenates one Null-terminated ASCII string to another Null-terminated
993 ASCII string, and returns the concatenated ASCII string.
995 This function concatenates two Null-terminated ASCII strings. The contents of
996 Null-terminated ASCII string Source are concatenated to the end of Null-
997 terminated ASCII string Destination. The Null-terminated concatenated ASCII
1000 If Destination is NULL, then ASSERT().
1001 If Source is NULL, then ASSERT().
1002 If PcdMaximumAsciiStringLength is not zero and Destination contains more than
1003 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1005 If PcdMaximumAsciiStringLength is not zero and Source contains more than
1006 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1008 If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
1009 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
1010 ASCII characters, then ASSERT().
1012 @param Destination Pointer to a Null-terminated ASCII string.
1013 @param Source Pointer to a Null-terminated ASCII string.
1021 IN OUT CHAR8
*Destination
,
1022 IN CONST CHAR8
*Source
1027 Concatenates up to a specified length one Null-terminated ASCII string to
1028 the end of another Null-terminated ASCII string, and returns the
1029 concatenated ASCII string.
1031 This function concatenates two Null-terminated ASCII strings. The contents
1032 of Null-terminated ASCII string Source are concatenated to the end of Null-
1033 terminated ASCII string Destination, and Destination is returned. At most,
1034 Length ASCII characters are concatenated from Source to the end of
1035 Destination, and Destination is always Null-terminated. If Length is 0, then
1036 Destination is returned unmodified. If Source and Destination overlap, then
1037 the results are undefined.
1039 If Length > 0 and Destination is NULL, then ASSERT().
1040 If Length > 0 and Source is NULL, then ASSERT().
1041 If Source and Destination overlap, then ASSERT().
1042 If PcdMaximumAsciiStringLength is not zero, and Destination contains more than
1043 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1045 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1046 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1048 If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
1049 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
1050 ASCII characters not including the Null-terminator, then ASSERT().
1052 @param Destination Pointer to a Null-terminated ASCII string.
1053 @param Source Pointer to a Null-terminated ASCII string.
1054 @param Length Maximum number of ASCII characters to concatenate from
1063 IN OUT CHAR8
*Destination
,
1064 IN CONST CHAR8
*Source
,
1070 Returns the first occurrence of a Null-terminated ASCII sub-string
1071 in a Null-terminated ASCII string.
1073 This function scans the contents of the ASCII string specified by String
1074 and returns the first occurrence of SearchString. If SearchString is not
1075 found in String, then NULL is returned. If the length of SearchString is zero,
1076 then String is returned.
1078 If String is NULL, then ASSERT().
1079 If SearchString is NULL, then ASSERT().
1081 If PcdMaximumAsciiStringLength is not zero, and SearchString or
1082 String contains more than PcdMaximumAsciiStringLength Unicode characters
1083 not including the Null-terminator, then ASSERT().
1085 @param String Pointer to a Null-terminated ASCII string.
1086 @param SearchString Pointer to a Null-terminated ASCII string to search for.
1088 @retval NULL If the SearchString does not appear in String.
1089 @retval others If there is a match return the first occurrence of SearchingString.
1090 If the length of SearchString is zero,return String.
1096 IN CONST CHAR8
*String
,
1097 IN CONST CHAR8
*SearchString
1102 Convert a Null-terminated ASCII decimal string to a value of type
1105 This function returns a value of type UINTN by interpreting the contents
1106 of the ASCII string String as a decimal number. The format of the input
1107 ASCII string String is:
1109 [spaces] [decimal digits].
1111 The valid decimal digit character is in the range [0-9]. The function will
1112 ignore the pad space, which includes spaces or tab characters, before the digits.
1113 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1114 function stops at the first character that is a not a valid decimal character or
1115 Null-terminator, whichever on comes first.
1117 If String has only pad spaces, then 0 is returned.
1118 If String has no pad spaces or valid decimal digits, then 0 is returned.
1119 If the number represented by String overflows according to the range defined by
1120 UINTN, then ASSERT().
1121 If String is NULL, then ASSERT().
1122 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1123 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1126 @param String Pointer to a Null-terminated ASCII string.
1128 @retval Value translated from String.
1133 AsciiStrDecimalToUintn (
1134 IN CONST CHAR8
*String
1139 Convert a Null-terminated ASCII decimal string to a value of type
1142 This function returns a value of type UINT64 by interpreting the contents
1143 of the ASCII string String as a decimal number. The format of the input
1144 ASCII string String is:
1146 [spaces] [decimal digits].
1148 The valid decimal digit character is in the range [0-9]. The function will
1149 ignore the pad space, which includes spaces or tab characters, before the digits.
1150 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1151 function stops at the first character that is a not a valid decimal character or
1152 Null-terminator, whichever on comes first.
1154 If String has only pad spaces, then 0 is returned.
1155 If String has no pad spaces or valid decimal digits, then 0 is returned.
1156 If the number represented by String overflows according to the range defined by
1157 UINT64, then ASSERT().
1158 If String is NULL, then ASSERT().
1159 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1160 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1163 @param String Pointer to a Null-terminated ASCII string.
1165 @retval Value translated from String.
1170 AsciiStrDecimalToUint64 (
1171 IN CONST CHAR8
*String
1176 Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.
1178 This function returns a value of type UINTN by interpreting the contents of
1179 the ASCII string String as a hexadecimal number. The format of the input ASCII
1182 [spaces][zeros][x][hexadecimal digits].
1184 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1185 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1186 appears in the input string, it must be prefixed with at least one 0. The function
1187 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1188 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1189 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1190 digit. Then, the function stops at the first character that is a not a valid
1191 hexadecimal character or Null-terminator, whichever on comes first.
1193 If String has only pad spaces, then 0 is returned.
1194 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1197 If the number represented by String overflows according to the range defined by UINTN,
1199 If String is NULL, then ASSERT().
1200 If PcdMaximumAsciiStringLength is not zero,
1201 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1202 the Null-terminator, then ASSERT().
1204 @param String Pointer to a Null-terminated ASCII string.
1206 @retval Value translated from String.
1211 AsciiStrHexToUintn (
1212 IN CONST CHAR8
*String
1217 Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.
1219 This function returns a value of type UINT64 by interpreting the contents of
1220 the ASCII string String as a hexadecimal number. The format of the input ASCII
1223 [spaces][zeros][x][hexadecimal digits].
1225 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1226 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1227 appears in the input string, it must be prefixed with at least one 0. The function
1228 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1229 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1230 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1231 digit. Then, the function stops at the first character that is a not a valid
1232 hexadecimal character or Null-terminator, whichever on comes first.
1234 If String has only pad spaces, then 0 is returned.
1235 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1238 If the number represented by String overflows according to the range defined by UINT64,
1240 If String is NULL, then ASSERT().
1241 If PcdMaximumAsciiStringLength is not zero,
1242 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1243 the Null-terminator, then ASSERT().
1245 @param String Pointer to a Null-terminated ASCII string.
1247 @retval Value translated from String.
1252 AsciiStrHexToUint64 (
1253 IN CONST CHAR8
*String
1258 Convert one Null-terminated ASCII string to a Null-terminated
1259 Unicode string and returns the Unicode string.
1261 This function converts the contents of the ASCII string Source to the Unicode
1262 string Destination, and returns Destination. The function terminates the
1263 Unicode string Destination by appending a Null-terminator character at the end.
1264 The caller is responsible to make sure Destination points to a buffer with size
1265 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
1267 If Destination is NULL, then ASSERT().
1268 If Destination is not aligned on a 16-bit boundary, then ASSERT().
1269 If Source is NULL, then ASSERT().
1270 If Source and Destination overlap, then ASSERT().
1271 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1272 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1274 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1275 PcdMaximumUnicodeStringLength ASCII characters not including the
1276 Null-terminator, then ASSERT().
1278 @param Source Pointer to a Null-terminated ASCII string.
1279 @param Destination Pointer to a Null-terminated Unicode string.
1281 @return Destination.
1286 AsciiStrToUnicodeStr (
1287 IN CONST CHAR8
*Source
,
1288 OUT CHAR16
*Destination
1293 Converts an 8-bit value to an 8-bit BCD value.
1295 Converts the 8-bit value specified by Value to BCD. The BCD value is
1298 If Value >= 100, then ASSERT().
1300 @param Value The 8-bit value to convert to BCD. Range 0..99.
1302 @return The BCD value.
1313 Converts an 8-bit BCD value to an 8-bit value.
1315 Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit
1318 If Value >= 0xA0, then ASSERT().
1319 If (Value & 0x0F) >= 0x0A, then ASSERT().
1321 @param Value The 8-bit BCD value to convert to an 8-bit value.
1323 @return The 8-bit value is returned.
1334 // Linked List Functions and Macros
1338 Initializes the head node of a doubly linked list that is declared as a
1339 global variable in a module.
1341 Initializes the forward and backward links of a new linked list. After
1342 initializing a linked list with this macro, the other linked list functions
1343 may be used to add and remove nodes from the linked list. This macro results
1344 in smaller executables by initializing the linked list in the data section,
1345 instead if calling the InitializeListHead() function to perform the
1346 equivalent operation.
1348 @param ListHead The head note of a list to initiailize.
1351 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&(ListHead), &(ListHead)}
1355 Initializes the head node of a doubly linked list, and returns the pointer to
1356 the head node of the doubly linked list.
1358 Initializes the forward and backward links of a new linked list. After
1359 initializing a linked list with this function, the other linked list
1360 functions may be used to add and remove nodes from the linked list. It is up
1361 to the caller of this function to allocate the memory for ListHead.
1363 If ListHead is NULL, then ASSERT().
1365 @param ListHead A pointer to the head node of a new doubly linked list.
1372 InitializeListHead (
1373 IN OUT LIST_ENTRY
*ListHead
1378 Adds a node to the beginning of a doubly linked list, and returns the pointer
1379 to the head node of the doubly linked list.
1381 Adds the node Entry at the beginning of the doubly linked list denoted by
1382 ListHead, and returns ListHead.
1384 If ListHead is NULL, then ASSERT().
1385 If Entry is NULL, then ASSERT().
1386 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1387 InitializeListHead(), then ASSERT().
1388 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
1389 of nodes in ListHead, including the ListHead node, is greater than or
1390 equal to PcdMaximumLinkedListLength, then ASSERT().
1392 @param ListHead A pointer to the head node of a doubly linked list.
1393 @param Entry A pointer to a node that is to be inserted at the beginning
1394 of a doubly linked list.
1402 IN OUT LIST_ENTRY
*ListHead
,
1403 IN OUT LIST_ENTRY
*Entry
1408 Adds a node to the end of a doubly linked list, and returns the pointer to
1409 the head node of the doubly linked list.
1411 Adds the node Entry to the end of the doubly linked list denoted by ListHead,
1412 and returns ListHead.
1414 If ListHead is NULL, then ASSERT().
1415 If Entry is NULL, then ASSERT().
1416 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1417 InitializeListHead(), then ASSERT().
1418 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
1419 of nodes in ListHead, including the ListHead node, is greater than or
1420 equal to PcdMaximumLinkedListLength, then ASSERT().
1422 @param ListHead A pointer to the head node of a doubly linked list.
1423 @param Entry A pointer to a node that is to be added at the end of the
1432 IN OUT LIST_ENTRY
*ListHead
,
1433 IN OUT LIST_ENTRY
*Entry
1438 Retrieves the first node of a doubly linked list.
1440 Returns the first node of a doubly linked list. List must have been
1441 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1442 If List is empty, then List is returned.
1444 If List is NULL, then ASSERT().
1445 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1446 InitializeListHead(), then ASSERT().
1447 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1448 in List, including the List node, is greater than or equal to
1449 PcdMaximumLinkedListLength, then ASSERT().
1451 @param List A pointer to the head node of a doubly linked list.
1453 @return The first node of a doubly linked list.
1454 @retval NULL The list is empty.
1460 IN CONST LIST_ENTRY
*List
1465 Retrieves the next node of a doubly linked list.
1467 Returns the node of a doubly linked list that follows Node.
1468 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
1469 or InitializeListHead(). If List is empty, then List is returned.
1471 If List is NULL, then ASSERT().
1472 If Node is NULL, then ASSERT().
1473 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1474 InitializeListHead(), then ASSERT().
1475 If PcdMaximumLinkedListLenth is not zero, and List contains more than
1476 PcdMaximumLinkedListLenth nodes, then ASSERT().
1477 If Node is not a node in List, then ASSERT().
1479 @param List A pointer to the head node of a doubly linked list.
1480 @param Node A pointer to a node in the doubly linked list.
1482 @return Pointer to the next node if one exists. Otherwise a null value which
1483 is actually List is returned.
1489 IN CONST LIST_ENTRY
*List
,
1490 IN CONST LIST_ENTRY
*Node
1495 Checks to see if a doubly linked list is empty or not.
1497 Checks to see if the doubly linked list is empty. If the linked list contains
1498 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
1500 If ListHead is NULL, then ASSERT().
1501 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1502 InitializeListHead(), then ASSERT().
1503 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1504 in List, including the List node, is greater than or equal to
1505 PcdMaximumLinkedListLength, then ASSERT().
1507 @param ListHead A pointer to the head node of a doubly linked list.
1509 @retval TRUE The linked list is empty.
1510 @retval FALSE The linked list is not empty.
1516 IN CONST LIST_ENTRY
*ListHead
1521 Determines if a node in a doubly linked list is the head node of a the same
1522 doubly linked list. This function is typically used to terminate a loop that
1523 traverses all the nodes in a doubly linked list starting with the head node.
1525 Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the
1526 nodes in the doubly linked list specified by List. List must have been
1527 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1529 If List is NULL, then ASSERT().
1530 If Node is NULL, then ASSERT().
1531 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(),
1533 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1534 in List, including the List node, is greater than or equal to
1535 PcdMaximumLinkedListLength, then ASSERT().
1536 If Node is not a node in List and Node is not equal to List, then ASSERT().
1538 @param List A pointer to the head node of a doubly linked list.
1539 @param Node A pointer to a node in the doubly linked list.
1541 @retval TRUE Node is one of the nodes in the doubly linked list.
1542 @retval FALSE Node is not one of the nodes in the doubly linked list.
1548 IN CONST LIST_ENTRY
*List
,
1549 IN CONST LIST_ENTRY
*Node
1554 Determines if a node the last node in a doubly linked list.
1556 Returns TRUE if Node is the last node in the doubly linked list specified by
1557 List. Otherwise, FALSE is returned. List must have been initialized with
1558 INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1560 If List is NULL, then ASSERT().
1561 If Node is NULL, then ASSERT().
1562 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1563 InitializeListHead(), then ASSERT().
1564 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1565 in List, including the List node, is greater than or equal to
1566 PcdMaximumLinkedListLength, then ASSERT().
1567 If Node is not a node in List, then ASSERT().
1569 @param List A pointer to the head node of a doubly linked list.
1570 @param Node A pointer to a node in the doubly linked list.
1572 @retval TRUE Node is the last node in the linked list.
1573 @retval FALSE Node is not the last node in the linked list.
1579 IN CONST LIST_ENTRY
*List
,
1580 IN CONST LIST_ENTRY
*Node
1585 Swaps the location of two nodes in a doubly linked list, and returns the
1586 first node after the swap.
1588 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
1589 Otherwise, the location of the FirstEntry node is swapped with the location
1590 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
1591 same double linked list as FirstEntry and that double linked list must have
1592 been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1593 SecondEntry is returned after the nodes are swapped.
1595 If FirstEntry is NULL, then ASSERT().
1596 If SecondEntry is NULL, then ASSERT().
1597 If SecondEntry and FirstEntry are not in the same linked list, then ASSERT().
1598 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1599 linked list containing the FirstEntry and SecondEntry nodes, including
1600 the FirstEntry and SecondEntry nodes, is greater than or equal to
1601 PcdMaximumLinkedListLength, then ASSERT().
1603 @param FirstEntry A pointer to a node in a linked list.
1604 @param SecondEntry A pointer to another node in the same linked list.
1606 @return SecondEntry.
1612 IN OUT LIST_ENTRY
*FirstEntry
,
1613 IN OUT LIST_ENTRY
*SecondEntry
1618 Removes a node from a doubly linked list, and returns the node that follows
1621 Removes the node Entry from a doubly linked list. It is up to the caller of
1622 this function to release the memory used by this node if that is required. On
1623 exit, the node following Entry in the doubly linked list is returned. If
1624 Entry is the only node in the linked list, then the head node of the linked
1627 If Entry is NULL, then ASSERT().
1628 If Entry is the head node of an empty list, then ASSERT().
1629 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1630 linked list containing Entry, including the Entry node, is greater than
1631 or equal to PcdMaximumLinkedListLength, then ASSERT().
1633 @param Entry A pointer to a node in a linked list.
1641 IN CONST LIST_ENTRY
*Entry
1649 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
1650 with zeros. The shifted value is returned.
1652 This function shifts the 64-bit value Operand to the left by Count bits. The
1653 low Count bits are set to zero. The shifted value is returned.
1655 If Count is greater than 63, then ASSERT().
1657 @param Operand The 64-bit operand to shift left.
1658 @param Count The number of bits to shift left.
1660 @return Operand << Count.
1672 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
1673 filled with zeros. The shifted value is returned.
1675 This function shifts the 64-bit value Operand to the right by Count bits. The
1676 high Count bits are set to zero. The shifted value is returned.
1678 If Count is greater than 63, then ASSERT().
1680 @param Operand The 64-bit operand to shift right.
1681 @param Count The number of bits to shift right.
1683 @return Operand >> Count
1695 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
1696 with original integer's bit 63. The shifted value is returned.
1698 This function shifts the 64-bit value Operand to the right by Count bits. The
1699 high Count bits are set to bit 63 of Operand. The shifted value is returned.
1701 If Count is greater than 63, then ASSERT().
1703 @param Operand The 64-bit operand to shift right.
1704 @param Count The number of bits to shift right.
1706 @return Operand >> Count
1718 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
1719 with the high bits that were rotated.
1721 This function rotates the 32-bit value Operand to the left by Count bits. The
1722 low Count bits are fill with the high Count bits of Operand. The rotated
1725 If Count is greater than 31, then ASSERT().
1727 @param Operand The 32-bit operand to rotate left.
1728 @param Count The number of bits to rotate left.
1730 @return Operand << Count
1742 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
1743 with the low bits that were rotated.
1745 This function rotates the 32-bit value Operand to the right by Count bits.
1746 The high Count bits are fill with the low Count bits of Operand. The rotated
1749 If Count is greater than 31, then ASSERT().
1751 @param Operand The 32-bit operand to rotate right.
1752 @param Count The number of bits to rotate right.
1754 @return Operand >>> Count
1766 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
1767 with the high bits that were rotated.
1769 This function rotates the 64-bit value Operand to the left by Count bits. The
1770 low Count bits are fill with the high Count bits of Operand. The rotated
1773 If Count is greater than 63, then ASSERT().
1775 @param Operand The 64-bit operand to rotate left.
1776 @param Count The number of bits to rotate left.
1778 @return Operand << Count
1790 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
1791 with the high low bits that were rotated.
1793 This function rotates the 64-bit value Operand to the right by Count bits.
1794 The high Count bits are fill with the low Count bits of Operand. The rotated
1797 If Count is greater than 63, then ASSERT().
1799 @param Operand The 64-bit operand to rotate right.
1800 @param Count The number of bits to rotate right.
1802 @return Operand >> Count
1814 Returns the bit position of the lowest bit set in a 32-bit value.
1816 This function computes the bit position of the lowest bit set in the 32-bit
1817 value specified by Operand. If Operand is zero, then -1 is returned.
1818 Otherwise, a value between 0 and 31 is returned.
1820 @param Operand The 32-bit operand to evaluate.
1822 @retval 0..31 The lowest bit set in Operand was found.
1823 @retval -1 Operand is zero.
1834 Returns the bit position of the lowest bit set in a 64-bit value.
1836 This function computes the bit position of the lowest bit set in the 64-bit
1837 value specified by Operand. If Operand is zero, then -1 is returned.
1838 Otherwise, a value between 0 and 63 is returned.
1840 @param Operand The 64-bit operand to evaluate.
1842 @retval 0..63 The lowest bit set in Operand was found.
1843 @retval -1 Operand is zero.
1855 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
1858 This function computes the bit position of the highest bit set in the 32-bit
1859 value specified by Operand. If Operand is zero, then -1 is returned.
1860 Otherwise, a value between 0 and 31 is returned.
1862 @param Operand The 32-bit operand to evaluate.
1864 @retval 0..31 Position of the highest bit set in Operand if found.
1865 @retval -1 Operand is zero.
1876 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
1879 This function computes the bit position of the highest bit set in the 64-bit
1880 value specified by Operand. If Operand is zero, then -1 is returned.
1881 Otherwise, a value between 0 and 63 is returned.
1883 @param Operand The 64-bit operand to evaluate.
1885 @retval 0..63 Position of the highest bit set in Operand if found.
1886 @retval -1 Operand is zero.
1897 Returns the value of the highest bit set in a 32-bit value. Equivalent to
1900 This function computes the value of the highest bit set in the 32-bit value
1901 specified by Operand. If Operand is zero, then zero is returned.
1903 @param Operand The 32-bit operand to evaluate.
1905 @return 1 << HighBitSet32(Operand)
1906 @retval 0 Operand is zero.
1917 Returns the value of the highest bit set in a 64-bit value. Equivalent to
1920 This function computes the value of the highest bit set in the 64-bit value
1921 specified by Operand. If Operand is zero, then zero is returned.
1923 @param Operand The 64-bit operand to evaluate.
1925 @return 1 << HighBitSet64(Operand)
1926 @retval 0 Operand is zero.
1937 Switches the endianess of a 16-bit integer.
1939 This function swaps the bytes in a 16-bit unsigned value to switch the value
1940 from little endian to big endian or vice versa. The byte swapped value is
1943 @param Value Operand A 16-bit unsigned value.
1945 @return The byte swapped Operand.
1956 Switches the endianess of a 32-bit integer.
1958 This function swaps the bytes in a 32-bit unsigned value to switch the value
1959 from little endian to big endian or vice versa. The byte swapped value is
1962 @param Value Operand A 32-bit unsigned value.
1964 @return The byte swapped Operand.
1975 Switches the endianess of a 64-bit integer.
1977 This function swaps the bytes in a 64-bit unsigned value to switch the value
1978 from little endian to big endian or vice versa. The byte swapped value is
1981 @param Value Operand A 64-bit unsigned value.
1983 @return The byte swapped Operand.
1994 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
1995 generates a 64-bit unsigned result.
1997 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
1998 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1999 bit unsigned result is returned.
2001 @param Multiplicand A 64-bit unsigned value.
2002 @param Multiplier A 32-bit unsigned value.
2004 @return Multiplicand * Multiplier
2010 IN UINT64 Multiplicand
,
2011 IN UINT32 Multiplier
2016 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
2017 generates a 64-bit unsigned result.
2019 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
2020 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
2021 bit unsigned result is returned.
2023 If the result overflows, then ASSERT().
2025 @param Multiplicand A 64-bit unsigned value.
2026 @param Multiplier A 64-bit unsigned value.
2028 @return Multiplicand * Multiplier
2034 IN UINT64 Multiplicand
,
2035 IN UINT64 Multiplier
2040 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
2041 64-bit signed result.
2043 This function multiples the 64-bit signed value Multiplicand by the 64-bit
2044 signed value Multiplier and generates a 64-bit signed result. This 64-bit
2045 signed result is returned.
2047 @param Multiplicand A 64-bit signed value.
2048 @param Multiplier A 64-bit signed value.
2050 @return Multiplicand * Multiplier
2056 IN INT64 Multiplicand
,
2062 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2063 a 64-bit unsigned result.
2065 This function divides the 64-bit unsigned value Dividend by the 32-bit
2066 unsigned value Divisor and generates a 64-bit unsigned quotient. This
2067 function returns the 64-bit unsigned quotient.
2069 If Divisor is 0, then ASSERT().
2071 @param Dividend A 64-bit unsigned value.
2072 @param Divisor A 32-bit unsigned value.
2074 @return Dividend / Divisor
2086 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2087 a 32-bit unsigned remainder.
2089 This function divides the 64-bit unsigned value Dividend by the 32-bit
2090 unsigned value Divisor and generates a 32-bit remainder. This function
2091 returns the 32-bit unsigned remainder.
2093 If Divisor is 0, then ASSERT().
2095 @param Dividend A 64-bit unsigned value.
2096 @param Divisor A 32-bit unsigned value.
2098 @return Dividend % Divisor
2110 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2111 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
2113 This function divides the 64-bit unsigned value Dividend by the 32-bit
2114 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2115 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
2116 This function returns the 64-bit unsigned quotient.
2118 If Divisor is 0, then ASSERT().
2120 @param Dividend A 64-bit unsigned value.
2121 @param Divisor A 32-bit unsigned value.
2122 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
2123 optional and may be NULL.
2125 @return Dividend / Divisor
2130 DivU64x32Remainder (
2133 OUT UINT32
*Remainder OPTIONAL
2138 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
2139 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
2141 This function divides the 64-bit unsigned value Dividend by the 64-bit
2142 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2143 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
2144 This function returns the 64-bit unsigned quotient.
2146 If Divisor is 0, then ASSERT().
2148 @param Dividend A 64-bit unsigned value.
2149 @param Divisor A 64-bit unsigned value.
2150 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
2151 optional and may be NULL.
2153 @return Dividend / Divisor
2158 DivU64x64Remainder (
2161 OUT UINT64
*Remainder OPTIONAL
2166 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
2167 64-bit signed result and a optional 64-bit signed remainder.
2169 This function divides the 64-bit signed value Dividend by the 64-bit signed
2170 value Divisor and generates a 64-bit signed quotient. If Remainder is not
2171 NULL, then the 64-bit signed remainder is returned in Remainder. This
2172 function returns the 64-bit signed quotient.
2174 It is the caller's responsibility to not call this function with a Divisor of 0.
2175 If Divisor is 0, then the quotient and remainder should be assumed to be
2176 the largest negative integer.
2178 If Divisor is 0, then ASSERT().
2180 @param Dividend A 64-bit signed value.
2181 @param Divisor A 64-bit signed value.
2182 @param Remainder A pointer to a 64-bit signed value. This parameter is
2183 optional and may be NULL.
2185 @return Dividend / Divisor
2190 DivS64x64Remainder (
2193 OUT INT64
*Remainder OPTIONAL
2198 Reads a 16-bit value from memory that may be unaligned.
2200 This function returns the 16-bit value pointed to by Buffer. The function
2201 guarantees that the read operation does not produce an alignment fault.
2203 If the Buffer is NULL, then ASSERT().
2205 @param Buffer Pointer to a 16-bit value that may be unaligned.
2207 @return The 16-bit value read from Buffer.
2213 IN CONST UINT16
*Buffer
2218 Writes a 16-bit value to memory that may be unaligned.
2220 This function writes the 16-bit value specified by Value to Buffer. Value is
2221 returned. The function guarantees that the write operation does not produce
2224 If the Buffer is NULL, then ASSERT().
2226 @param Buffer Pointer to a 16-bit value that may be unaligned.
2227 @param Value 16-bit value to write to Buffer.
2229 @return The 16-bit value to write to Buffer.
2241 Reads a 24-bit value from memory that may be unaligned.
2243 This function returns the 24-bit value pointed to by Buffer. The function
2244 guarantees that the read operation does not produce an alignment fault.
2246 If the Buffer is NULL, then ASSERT().
2248 @param Buffer Pointer to a 24-bit value that may be unaligned.
2250 @return The 24-bit value read from Buffer.
2256 IN CONST UINT32
*Buffer
2261 Writes a 24-bit value to memory that may be unaligned.
2263 This function writes the 24-bit value specified by Value to Buffer. Value is
2264 returned. The function guarantees that the write operation does not produce
2267 If the Buffer is NULL, then ASSERT().
2269 @param Buffer Pointer to a 24-bit value that may be unaligned.
2270 @param Value 24-bit value to write to Buffer.
2272 @return The 24-bit value to write to Buffer.
2284 Reads a 32-bit value from memory that may be unaligned.
2286 This function returns the 32-bit value pointed to by Buffer. The function
2287 guarantees that the read operation does not produce an alignment fault.
2289 If the Buffer is NULL, then ASSERT().
2291 @param Buffer Pointer to a 32-bit value that may be unaligned.
2293 @return The 32-bit value read from Buffer.
2299 IN CONST UINT32
*Buffer
2304 Writes a 32-bit value to memory that may be unaligned.
2306 This function writes the 32-bit value specified by Value to Buffer. Value is
2307 returned. The function guarantees that the write operation does not produce
2310 If the Buffer is NULL, then ASSERT().
2312 @param Buffer Pointer to a 32-bit value that may be unaligned.
2313 @param Value 32-bit value to write to Buffer.
2315 @return The 32-bit value to write to Buffer.
2327 Reads a 64-bit value from memory that may be unaligned.
2329 This function returns the 64-bit value pointed to by Buffer. The function
2330 guarantees that the read operation does not produce an alignment fault.
2332 If the Buffer is NULL, then ASSERT().
2334 @param Buffer Pointer to a 64-bit value that may be unaligned.
2336 @return The 64-bit value read from Buffer.
2342 IN CONST UINT64
*Buffer
2347 Writes a 64-bit value to memory that may be unaligned.
2349 This function writes the 64-bit value specified by Value to Buffer. Value is
2350 returned. The function guarantees that the write operation does not produce
2353 If the Buffer is NULL, then ASSERT().
2355 @param Buffer Pointer to a 64-bit value that may be unaligned.
2356 @param Value 64-bit value to write to Buffer.
2358 @return The 64-bit value to write to Buffer.
2370 // Bit Field Functions
2374 Returns a bit field from an 8-bit value.
2376 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2378 If 8-bit operations are not supported, then ASSERT().
2379 If StartBit is greater than 7, then ASSERT().
2380 If EndBit is greater than 7, then ASSERT().
2381 If EndBit is less than StartBit, then ASSERT().
2383 @param Operand Operand on which to perform the bitfield operation.
2384 @param StartBit The ordinal of the least significant bit in the bit field.
2386 @param EndBit The ordinal of the most significant bit in the bit field.
2389 @return The bit field read.
2402 Writes a bit field to an 8-bit value, and returns the result.
2404 Writes Value to the bit field specified by the StartBit and the EndBit in
2405 Operand. All other bits in Operand are preserved. The new 8-bit value is
2408 If 8-bit operations are not supported, then ASSERT().
2409 If StartBit is greater than 7, then ASSERT().
2410 If EndBit is greater than 7, then ASSERT().
2411 If EndBit is less than StartBit, then ASSERT().
2413 @param Operand Operand on which to perform the bitfield operation.
2414 @param StartBit The ordinal of the least significant bit in the bit field.
2416 @param EndBit The ordinal of the most significant bit in the bit field.
2418 @param Value New value of the bit field.
2420 @return The new 8-bit value.
2434 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
2437 Performs a bitwise inclusive OR between the bit field specified by StartBit
2438 and EndBit in Operand and the value specified by OrData. All other bits in
2439 Operand are preserved. The new 8-bit value is returned.
2441 If 8-bit operations are not supported, then ASSERT().
2442 If StartBit is greater than 7, then ASSERT().
2443 If EndBit is greater than 7, then ASSERT().
2444 If EndBit is less than StartBit, then ASSERT().
2446 @param Operand Operand on which to perform the bitfield operation.
2447 @param StartBit The ordinal of the least significant bit in the bit field.
2449 @param EndBit The ordinal of the most significant bit in the bit field.
2451 @param OrData The value to OR with the read value from the value
2453 @return The new 8-bit value.
2467 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
2470 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2471 in Operand and the value specified by AndData. All other bits in Operand are
2472 preserved. The new 8-bit value is returned.
2474 If 8-bit operations are not supported, then ASSERT().
2475 If StartBit is greater than 7, then ASSERT().
2476 If EndBit is greater than 7, then ASSERT().
2477 If EndBit is less than StartBit, then ASSERT().
2479 @param Operand Operand on which to perform the bitfield operation.
2480 @param StartBit The ordinal of the least significant bit in the bit field.
2482 @param EndBit The ordinal of the most significant bit in the bit field.
2484 @param AndData The value to AND with the read value from the value.
2486 @return The new 8-bit value.
2500 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
2501 bitwise OR, and returns the result.
2503 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2504 in Operand and the value specified by AndData, followed by a bitwise
2505 inclusive OR with value specified by OrData. All other bits in Operand are
2506 preserved. The new 8-bit value is returned.
2508 If 8-bit operations are not supported, then ASSERT().
2509 If StartBit is greater than 7, then ASSERT().
2510 If EndBit is greater than 7, then ASSERT().
2511 If EndBit is less than StartBit, then ASSERT().
2513 @param Operand Operand on which to perform the bitfield operation.
2514 @param StartBit The ordinal of the least significant bit in the bit field.
2516 @param EndBit The ordinal of the most significant bit in the bit field.
2518 @param AndData The value to AND with the read value from the value.
2519 @param OrData The value to OR with the result of the AND operation.
2521 @return The new 8-bit value.
2526 BitFieldAndThenOr8 (
2536 Returns a bit field from a 16-bit value.
2538 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2540 If 16-bit operations are not supported, then ASSERT().
2541 If StartBit is greater than 15, then ASSERT().
2542 If EndBit is greater than 15, then ASSERT().
2543 If EndBit is less than StartBit, then ASSERT().
2545 @param Operand Operand on which to perform the bitfield operation.
2546 @param StartBit The ordinal of the least significant bit in the bit field.
2548 @param EndBit The ordinal of the most significant bit in the bit field.
2551 @return The bit field read.
2564 Writes a bit field to a 16-bit value, and returns the result.
2566 Writes Value to the bit field specified by the StartBit and the EndBit in
2567 Operand. All other bits in Operand are preserved. The new 16-bit value is
2570 If 16-bit operations are not supported, then ASSERT().
2571 If StartBit is greater than 15, then ASSERT().
2572 If EndBit is greater than 15, then ASSERT().
2573 If EndBit is less than StartBit, then ASSERT().
2575 @param Operand Operand on which to perform the bitfield operation.
2576 @param StartBit The ordinal of the least significant bit in the bit field.
2578 @param EndBit The ordinal of the most significant bit in the bit field.
2580 @param Value New value of the bit field.
2582 @return The new 16-bit value.
2596 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
2599 Performs a bitwise inclusive OR between the bit field specified by StartBit
2600 and EndBit in Operand and the value specified by OrData. All other bits in
2601 Operand are preserved. The new 16-bit value is returned.
2603 If 16-bit operations are not supported, then ASSERT().
2604 If StartBit is greater than 15, then ASSERT().
2605 If EndBit is greater than 15, then ASSERT().
2606 If EndBit is less than StartBit, then ASSERT().
2608 @param Operand Operand on which to perform the bitfield operation.
2609 @param StartBit The ordinal of the least significant bit in the bit field.
2611 @param EndBit The ordinal of the most significant bit in the bit field.
2613 @param OrData The value to OR with the read value from the value
2615 @return The new 16-bit value.
2629 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
2632 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2633 in Operand and the value specified by AndData. All other bits in Operand are
2634 preserved. The new 16-bit value is returned.
2636 If 16-bit operations are not supported, then ASSERT().
2637 If StartBit is greater than 15, then ASSERT().
2638 If EndBit is greater than 15, then ASSERT().
2639 If EndBit is less than StartBit, then ASSERT().
2641 @param Operand Operand on which to perform the bitfield operation.
2642 @param StartBit The ordinal of the least significant bit in the bit field.
2644 @param EndBit The ordinal of the most significant bit in the bit field.
2646 @param AndData The value to AND with the read value from the value
2648 @return The new 16-bit value.
2662 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
2663 bitwise OR, and returns the result.
2665 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2666 in Operand and the value specified by AndData, followed by a bitwise
2667 inclusive OR with value specified by OrData. All other bits in Operand are
2668 preserved. The new 16-bit value is returned.
2670 If 16-bit operations are not supported, then ASSERT().
2671 If StartBit is greater than 15, then ASSERT().
2672 If EndBit is greater than 15, then ASSERT().
2673 If EndBit is less than StartBit, then ASSERT().
2675 @param Operand Operand on which to perform the bitfield operation.
2676 @param StartBit The ordinal of the least significant bit in the bit field.
2678 @param EndBit The ordinal of the most significant bit in the bit field.
2680 @param AndData The value to AND with the read value from the value.
2681 @param OrData The value to OR with the result of the AND operation.
2683 @return The new 16-bit value.
2688 BitFieldAndThenOr16 (
2698 Returns a bit field from a 32-bit value.
2700 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2702 If 32-bit operations are not supported, then ASSERT().
2703 If StartBit is greater than 31, then ASSERT().
2704 If EndBit is greater than 31, then ASSERT().
2705 If EndBit is less than StartBit, then ASSERT().
2707 @param Operand Operand on which to perform the bitfield operation.
2708 @param StartBit The ordinal of the least significant bit in the bit field.
2710 @param EndBit The ordinal of the most significant bit in the bit field.
2713 @return The bit field read.
2726 Writes a bit field to a 32-bit value, and returns the result.
2728 Writes Value to the bit field specified by the StartBit and the EndBit in
2729 Operand. All other bits in Operand are preserved. The new 32-bit value is
2732 If 32-bit operations are not supported, then ASSERT().
2733 If StartBit is greater than 31, then ASSERT().
2734 If EndBit is greater than 31, then ASSERT().
2735 If EndBit is less than StartBit, then ASSERT().
2737 @param Operand Operand on which to perform the bitfield operation.
2738 @param StartBit The ordinal of the least significant bit in the bit field.
2740 @param EndBit The ordinal of the most significant bit in the bit field.
2742 @param Value New value of the bit field.
2744 @return The new 32-bit value.
2758 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
2761 Performs a bitwise inclusive OR between the bit field specified by StartBit
2762 and EndBit in Operand and the value specified by OrData. All other bits in
2763 Operand are preserved. The new 32-bit value is returned.
2765 If 32-bit operations are not supported, then ASSERT().
2766 If StartBit is greater than 31, then ASSERT().
2767 If EndBit is greater than 31, then ASSERT().
2768 If EndBit is less than StartBit, then ASSERT().
2770 @param Operand Operand on which to perform the bitfield operation.
2771 @param StartBit The ordinal of the least significant bit in the bit field.
2773 @param EndBit The ordinal of the most significant bit in the bit field.
2775 @param OrData The value to OR with the read value from the value
2777 @return The new 32-bit value.
2791 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
2794 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2795 in Operand and the value specified by AndData. All other bits in Operand are
2796 preserved. The new 32-bit value is returned.
2798 If 32-bit operations are not supported, then ASSERT().
2799 If StartBit is greater than 31, then ASSERT().
2800 If EndBit is greater than 31, then ASSERT().
2801 If EndBit is less than StartBit, then ASSERT().
2803 @param Operand Operand on which to perform the bitfield operation.
2804 @param StartBit The ordinal of the least significant bit in the bit field.
2806 @param EndBit The ordinal of the most significant bit in the bit field.
2808 @param AndData The value to AND with the read value from the value
2810 @return The new 32-bit value.
2824 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
2825 bitwise OR, and returns the result.
2827 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2828 in Operand and the value specified by AndData, followed by a bitwise
2829 inclusive OR with value specified by OrData. All other bits in Operand are
2830 preserved. The new 32-bit value is returned.
2832 If 32-bit operations are not supported, then ASSERT().
2833 If StartBit is greater than 31, then ASSERT().
2834 If EndBit is greater than 31, then ASSERT().
2835 If EndBit is less than StartBit, then ASSERT().
2837 @param Operand Operand on which to perform the bitfield operation.
2838 @param StartBit The ordinal of the least significant bit in the bit field.
2840 @param EndBit The ordinal of the most significant bit in the bit field.
2842 @param AndData The value to AND with the read value from the value.
2843 @param OrData The value to OR with the result of the AND operation.
2845 @return The new 32-bit value.
2850 BitFieldAndThenOr32 (
2860 Returns a bit field from a 64-bit value.
2862 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2864 If 64-bit operations are not supported, then ASSERT().
2865 If StartBit is greater than 63, then ASSERT().
2866 If EndBit is greater than 63, then ASSERT().
2867 If EndBit is less than StartBit, then ASSERT().
2869 @param Operand Operand on which to perform the bitfield operation.
2870 @param StartBit The ordinal of the least significant bit in the bit field.
2872 @param EndBit The ordinal of the most significant bit in the bit field.
2875 @return The bit field read.
2888 Writes a bit field to a 64-bit value, and returns the result.
2890 Writes Value to the bit field specified by the StartBit and the EndBit in
2891 Operand. All other bits in Operand are preserved. The new 64-bit value is
2894 If 64-bit operations are not supported, then ASSERT().
2895 If StartBit is greater than 63, then ASSERT().
2896 If EndBit is greater than 63, then ASSERT().
2897 If EndBit is less than StartBit, then ASSERT().
2899 @param Operand Operand on which to perform the bitfield operation.
2900 @param StartBit The ordinal of the least significant bit in the bit field.
2902 @param EndBit The ordinal of the most significant bit in the bit field.
2904 @param Value New value of the bit field.
2906 @return The new 64-bit value.
2920 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
2923 Performs a bitwise inclusive OR between the bit field specified by StartBit
2924 and EndBit in Operand and the value specified by OrData. All other bits in
2925 Operand are preserved. The new 64-bit value is returned.
2927 If 64-bit operations are not supported, then ASSERT().
2928 If StartBit is greater than 63, then ASSERT().
2929 If EndBit is greater than 63, then ASSERT().
2930 If EndBit is less than StartBit, then ASSERT().
2932 @param Operand Operand on which to perform the bitfield operation.
2933 @param StartBit The ordinal of the least significant bit in the bit field.
2935 @param EndBit The ordinal of the most significant bit in the bit field.
2937 @param OrData The value to OR with the read value from the value
2939 @return The new 64-bit value.
2953 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
2956 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2957 in Operand and the value specified by AndData. All other bits in Operand are
2958 preserved. The new 64-bit value is returned.
2960 If 64-bit operations are not supported, then ASSERT().
2961 If StartBit is greater than 63, then ASSERT().
2962 If EndBit is greater than 63, then ASSERT().
2963 If EndBit is less than StartBit, then ASSERT().
2965 @param Operand Operand on which to perform the bitfield operation.
2966 @param StartBit The ordinal of the least significant bit in the bit field.
2968 @param EndBit The ordinal of the most significant bit in the bit field.
2970 @param AndData The value to AND with the read value from the value
2972 @return The new 64-bit value.
2986 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
2987 bitwise OR, and returns the result.
2989 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2990 in Operand and the value specified by AndData, followed by a bitwise
2991 inclusive OR with value specified by OrData. All other bits in Operand are
2992 preserved. The new 64-bit value is returned.
2994 If 64-bit operations are not supported, then ASSERT().
2995 If StartBit is greater than 63, then ASSERT().
2996 If EndBit is greater than 63, then ASSERT().
2997 If EndBit is less than StartBit, then ASSERT().
2999 @param Operand Operand on which to perform the bitfield operation.
3000 @param StartBit The ordinal of the least significant bit in the bit field.
3002 @param EndBit The ordinal of the most significant bit in the bit field.
3004 @param AndData The value to AND with the read value from the value.
3005 @param OrData The value to OR with the result of the AND operation.
3007 @return The new 64-bit value.
3012 BitFieldAndThenOr64 (
3022 // Base Library Synchronization Functions
3026 Retrieves the architecture specific spin lock alignment requirements for
3027 optimal spin lock performance.
3029 This function retrieves the spin lock alignment requirements for optimal
3030 performance on a given CPU architecture. The spin lock alignment must be a
3031 power of two and is returned by this function. If there are no alignment
3032 requirements, then 1 must be returned. The spin lock synchronization
3033 functions must function correctly if the spin lock size and alignment values
3034 returned by this function are not used at all. These values are hints to the
3035 consumers of the spin lock synchronization functions to obtain optimal spin
3038 @return The architecture specific spin lock alignment.
3043 GetSpinLockProperties (
3049 Initializes a spin lock to the released state and returns the spin lock.
3051 This function initializes the spin lock specified by SpinLock to the released
3052 state, and returns SpinLock. Optimal performance can be achieved by calling
3053 GetSpinLockProperties() to determine the size and alignment requirements for
3056 If SpinLock is NULL, then ASSERT().
3058 @param SpinLock A pointer to the spin lock to initialize to the released
3061 @return SpinLock in release state.
3066 InitializeSpinLock (
3067 OUT SPIN_LOCK
*SpinLock
3072 Waits until a spin lock can be placed in the acquired state.
3074 This function checks the state of the spin lock specified by SpinLock. If
3075 SpinLock is in the released state, then this function places SpinLock in the
3076 acquired state and returns SpinLock. Otherwise, this function waits
3077 indefinitely for the spin lock to be released, and then places it in the
3078 acquired state and returns SpinLock. All state transitions of SpinLock must
3079 be performed using MP safe mechanisms.
3081 If SpinLock is NULL, then ASSERT().
3082 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
3083 If PcdSpinLockTimeout is not zero, and SpinLock is can not be acquired in
3084 PcdSpinLockTimeout microseconds, then ASSERT().
3086 @param SpinLock A pointer to the spin lock to place in the acquired state.
3088 @return SpinLock acquired lock.
3094 IN OUT SPIN_LOCK
*SpinLock
3099 Attempts to place a spin lock in the acquired state.
3101 This function checks the state of the spin lock specified by SpinLock. If
3102 SpinLock is in the released state, then this function places SpinLock in the
3103 acquired state and returns TRUE. Otherwise, FALSE is returned. All state
3104 transitions of SpinLock must be performed using MP safe mechanisms.
3106 If SpinLock is NULL, then ASSERT().
3107 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
3109 @param SpinLock A pointer to the spin lock to place in the acquired state.
3111 @retval TRUE SpinLock was placed in the acquired state.
3112 @retval FALSE SpinLock could not be acquired.
3117 AcquireSpinLockOrFail (
3118 IN OUT SPIN_LOCK
*SpinLock
3123 Releases a spin lock.
3125 This function places the spin lock specified by SpinLock in the release state
3126 and returns SpinLock.
3128 If SpinLock is NULL, then ASSERT().
3129 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
3131 @param SpinLock A pointer to the spin lock to release.
3133 @return SpinLock released lock.
3139 IN OUT SPIN_LOCK
*SpinLock
3144 Performs an atomic increment of an 32-bit unsigned integer.
3146 Performs an atomic increment of the 32-bit unsigned integer specified by
3147 Value and returns the incremented value. The increment operation must be
3148 performed using MP safe mechanisms. The state of the return value is not
3149 guaranteed to be MP safe.
3151 If Value is NULL, then ASSERT().
3153 @param Value A pointer to the 32-bit value to increment.
3155 @return The incremented value.
3160 InterlockedIncrement (
3166 Performs an atomic decrement of an 32-bit unsigned integer.
3168 Performs an atomic decrement of the 32-bit unsigned integer specified by
3169 Value and returns the decremented value. The decrement operation must be
3170 performed using MP safe mechanisms. The state of the return value is not
3171 guaranteed to be MP safe.
3173 If Value is NULL, then ASSERT().
3175 @param Value A pointer to the 32-bit value to decrement.
3177 @return The decremented value.
3182 InterlockedDecrement (
3188 Performs an atomic compare exchange operation on a 32-bit unsigned integer.
3190 Performs an atomic compare exchange operation on the 32-bit unsigned integer
3191 specified by Value. If Value is equal to CompareValue, then Value is set to
3192 ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,
3193 then Value is returned. The compare exchange operation must be performed using
3196 If Value is NULL, then ASSERT().
3198 @param Value A pointer to the 32-bit value for the compare exchange
3200 @param CompareValue 32-bit value used in compare operation.
3201 @param ExchangeValue 32-bit value used in exchange operation.
3203 @return The original *Value before exchange.
3208 InterlockedCompareExchange32 (
3209 IN OUT UINT32
*Value
,
3210 IN UINT32 CompareValue
,
3211 IN UINT32 ExchangeValue
3216 Performs an atomic compare exchange operation on a 64-bit unsigned integer.
3218 Performs an atomic compare exchange operation on the 64-bit unsigned integer specified
3219 by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and
3220 CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.
3221 The compare exchange operation must be performed using MP safe mechanisms.
3223 If Value is NULL, then ASSERT().
3225 @param Value A pointer to the 64-bit value for the compare exchange
3227 @param CompareValue 64-bit value used in compare operation.
3228 @param ExchangeValue 64-bit value used in exchange operation.
3230 @return The original *Value before exchange.
3235 InterlockedCompareExchange64 (
3236 IN OUT UINT64
*Value
,
3237 IN UINT64 CompareValue
,
3238 IN UINT64 ExchangeValue
3243 Performs an atomic compare exchange operation on a pointer value.
3245 Performs an atomic compare exchange operation on the pointer value specified
3246 by Value. If Value is equal to CompareValue, then Value is set to
3247 ExchangeValue and CompareValue is returned. If Value is not equal to
3248 CompareValue, then Value is returned. The compare exchange operation must be
3249 performed using MP safe mechanisms.
3251 If Value is NULL, then ASSERT().
3253 @param Value A pointer to the pointer value for the compare exchange
3255 @param CompareValue Pointer value used in compare operation.
3256 @param ExchangeValue Pointer value used in exchange operation.
3258 @return The original *Value before exchange.
3262 InterlockedCompareExchangePointer (
3263 IN OUT VOID
**Value
,
3264 IN VOID
*CompareValue
,
3265 IN VOID
*ExchangeValue
3270 // Base Library Checksum Functions
3274 Returns the sum of all elements in a buffer in unit of UINT8.
3275 During calculation, the carry bits are dropped.
3277 This function calculates the sum of all elements in a buffer
3278 in unit of UINT8. The carry bits in result of addition are dropped.
3279 The result is returned as UINT8. If Length is Zero, then Zero is
3282 If Buffer is NULL, then ASSERT().
3283 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3285 @param Buffer Pointer to the buffer to carry out the sum operation.
3286 @param Length The size, in bytes, of Buffer.
3288 @return Sum The sum of Buffer with carry bits dropped during additions.
3294 IN CONST UINT8
*Buffer
,
3300 Returns the two's complement checksum of all elements in a buffer
3303 This function first calculates the sum of the 8-bit values in the
3304 buffer specified by Buffer and Length. The carry bits in the result
3305 of addition are dropped. Then, the two's complement of the sum is
3306 returned. If Length is 0, then 0 is returned.
3308 If Buffer is NULL, then ASSERT().
3309 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3311 @param Buffer Pointer to the buffer to carry out the checksum operation.
3312 @param Length The size, in bytes, of Buffer.
3314 @return Checksum The 2's complement checksum of Buffer.
3319 CalculateCheckSum8 (
3320 IN CONST UINT8
*Buffer
,
3326 Returns the sum of all elements in a buffer of 16-bit values. During
3327 calculation, the carry bits are dropped.
3329 This function calculates the sum of the 16-bit values in the buffer
3330 specified by Buffer and Length. The carry bits in result of addition are dropped.
3331 The 16-bit result is returned. If Length is 0, then 0 is returned.
3333 If Buffer is NULL, then ASSERT().
3334 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3335 If Length is not aligned on a 16-bit boundary, then ASSERT().
3336 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3338 @param Buffer Pointer to the buffer to carry out the sum operation.
3339 @param Length The size, in bytes, of Buffer.
3341 @return Sum The sum of Buffer with carry bits dropped during additions.
3347 IN CONST UINT16
*Buffer
,
3353 Returns the two's complement checksum of all elements in a buffer of
3356 This function first calculates the sum of the 16-bit values in the buffer
3357 specified by Buffer and Length. The carry bits in the result of addition
3358 are dropped. Then, the two's complement of the sum is returned. If Length
3359 is 0, then 0 is returned.
3361 If Buffer is NULL, then ASSERT().
3362 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3363 If Length is not aligned on a 16-bit boundary, then ASSERT().
3364 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3366 @param Buffer Pointer to the buffer to carry out the checksum operation.
3367 @param Length The size, in bytes, of Buffer.
3369 @return Checksum The 2's complement checksum of Buffer.
3374 CalculateCheckSum16 (
3375 IN CONST UINT16
*Buffer
,
3381 Returns the sum of all elements in a buffer of 32-bit values. During
3382 calculation, the carry bits are dropped.
3384 This function calculates the sum of the 32-bit values in the buffer
3385 specified by Buffer and Length. The carry bits in result of addition are dropped.
3386 The 32-bit result is returned. If Length is 0, then 0 is returned.
3388 If Buffer is NULL, then ASSERT().
3389 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3390 If Length is not aligned on a 32-bit boundary, then ASSERT().
3391 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3393 @param Buffer Pointer to the buffer to carry out the sum operation.
3394 @param Length The size, in bytes, of Buffer.
3396 @return Sum The sum of Buffer with carry bits dropped during additions.
3402 IN CONST UINT32
*Buffer
,
3408 Returns the two's complement checksum of all elements in a buffer of
3411 This function first calculates the sum of the 32-bit values in the buffer
3412 specified by Buffer and Length. The carry bits in the result of addition
3413 are dropped. Then, the two's complement of the sum is returned. If Length
3414 is 0, then 0 is returned.
3416 If Buffer is NULL, then ASSERT().
3417 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3418 If Length is not aligned on a 32-bit boundary, then ASSERT().
3419 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3421 @param Buffer Pointer to the buffer to carry out the checksum operation.
3422 @param Length The size, in bytes, of Buffer.
3424 @return Checksum The 2's complement checksum of Buffer.
3429 CalculateCheckSum32 (
3430 IN CONST UINT32
*Buffer
,
3436 Returns the sum of all elements in a buffer of 64-bit values. During
3437 calculation, the carry bits are dropped.
3439 This function calculates the sum of the 64-bit values in the buffer
3440 specified by Buffer and Length. The carry bits in result of addition are dropped.
3441 The 64-bit result is returned. If Length is 0, then 0 is returned.
3443 If Buffer is NULL, then ASSERT().
3444 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3445 If Length is not aligned on a 64-bit boundary, then ASSERT().
3446 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3448 @param Buffer Pointer to the buffer to carry out the sum operation.
3449 @param Length The size, in bytes, of Buffer.
3451 @return Sum The sum of Buffer with carry bits dropped during additions.
3457 IN CONST UINT64
*Buffer
,
3463 Returns the two's complement checksum of all elements in a buffer of
3466 This function first calculates the sum of the 64-bit values in the buffer
3467 specified by Buffer and Length. The carry bits in the result of addition
3468 are dropped. Then, the two's complement of the sum is returned. If Length
3469 is 0, then 0 is returned.
3471 If Buffer is NULL, then ASSERT().
3472 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3473 If Length is not aligned on a 64-bit boundary, then ASSERT().
3474 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3476 @param Buffer Pointer to the buffer to carry out the checksum operation.
3477 @param Length The size, in bytes, of Buffer.
3479 @return Checksum The 2's complement checksum of Buffer.
3484 CalculateCheckSum64 (
3485 IN CONST UINT64
*Buffer
,
3491 /// Base Library CPU Functions
3495 (EFIAPI
*SWITCH_STACK_ENTRY_POINT
)(
3496 IN VOID
*Context1
, OPTIONAL
3497 IN VOID
*Context2 OPTIONAL
3502 Used to serialize load and store operations.
3504 All loads and stores that proceed calls to this function are guaranteed to be
3505 globally visible when this function returns.
3516 Saves the current CPU context that can be restored with a call to LongJump()
3519 Saves the current CPU context in the buffer specified by JumpBuffer and
3520 returns 0. The initial call to SetJump() must always return 0. Subsequent
3521 calls to LongJump() cause a non-zero value to be returned by SetJump().
3523 If JumpBuffer is NULL, then ASSERT().
3524 For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3526 NOTE: The structure BASE_LIBRARY_JUMP_BUFFER is CPU architecture specific.
3527 The same structure must never be used for more than one CPU architecture context.
3528 For example, a BASE_LIBRARY_JUMP_BUFFER allocated by an IA-32 module must never be used from an x64 module.
3529 SetJump()/LongJump() is not currently supported for the EBC processor type.
3531 @param JumpBuffer A pointer to CPU context buffer.
3533 @retval 0 Indicates a return from SetJump().
3539 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
3544 Restores the CPU context that was saved with SetJump().
3546 Restores the CPU context from the buffer specified by JumpBuffer. This
3547 function never returns to the caller. Instead is resumes execution based on
3548 the state of JumpBuffer.
3550 If JumpBuffer is NULL, then ASSERT().
3551 For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3552 If Value is 0, then ASSERT().
3554 @param JumpBuffer A pointer to CPU context buffer.
3555 @param Value The value to return when the SetJump() context is
3556 restored and must be non-zero.
3562 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
3568 Enables CPU interrupts.
3579 Disables CPU interrupts.
3590 Disables CPU interrupts and returns the interrupt state prior to the disable
3593 @retval TRUE CPU interrupts were enabled on entry to this call.
3594 @retval FALSE CPU interrupts were disabled on entry to this call.
3599 SaveAndDisableInterrupts (
3605 Enables CPU interrupts for the smallest window required to capture any
3611 EnableDisableInterrupts (
3617 Retrieves the current CPU interrupt state.
3619 Returns TRUE is interrupts are currently enabled. Otherwise
3622 @retval TRUE CPU interrupts are enabled.
3623 @retval FALSE CPU interrupts are disabled.
3634 Set the current CPU interrupt state.
3636 Sets the current CPU interrupt state to the state specified by
3637 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
3638 InterruptState is FALSE, then interrupts are disabled. InterruptState is
3641 @param InterruptState TRUE if interrupts should enabled. FALSE if
3642 interrupts should be disabled.
3644 @return InterruptState
3650 IN BOOLEAN InterruptState
3655 Requests CPU to pause for a short period of time.
3657 Requests CPU to pause for a short period of time. Typically used in MP
3658 systems to prevent memory starvation while waiting for a spin lock.
3669 Transfers control to a function starting with a new stack.
3671 Transfers control to the function specified by EntryPoint using the
3672 new stack specified by NewStack and passing in the parameters specified
3673 by Context1 and Context2. Context1 and Context2 are optional and may
3674 be NULL. The function EntryPoint must never return. This function
3675 supports a variable number of arguments following the NewStack parameter.
3676 These additional arguments are ignored on IA-32, x64, and EBC.
3677 IPF CPUs expect one additional parameter of type VOID * that specifies
3678 the new backing store pointer.
3680 If EntryPoint is NULL, then ASSERT().
3681 If NewStack is NULL, then ASSERT().
3683 @param EntryPoint A pointer to function to call with the new stack.
3684 @param Context1 A pointer to the context to pass into the EntryPoint
3686 @param Context2 A pointer to the context to pass into the EntryPoint
3688 @param NewStack A pointer to the new stack to use for the EntryPoint
3690 @param ... This variable argument list is ignored for IA32, x64, and EBC.
3691 For IPF, this variable argument list is expected to contain
3692 a single parameter of type VOID * that specifies the new backing
3700 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
3701 IN VOID
*Context1
, OPTIONAL
3702 IN VOID
*Context2
, OPTIONAL
3709 Generates a breakpoint on the CPU.
3711 Generates a breakpoint on the CPU. The breakpoint must be implemented such
3712 that code can resume normal execution after the breakpoint.
3723 Executes an infinite loop.
3725 Forces the CPU to execute an infinite loop. A debugger may be used to skip
3726 past the loop and the code that follows the loop must execute properly. This
3727 implies that the infinite loop must not cause the code that follow it to be
3737 #if defined (MDE_CPU_IPF)
3740 Flush a range of cache lines in the cache coherency domain of the calling
3743 Invalidates the cache lines specified by Address and Length. If Address is
3744 not aligned on a cache line boundary, then entire cache line containing
3745 Address is invalidated. If Address + Length is not aligned on a cache line
3746 boundary, then the entire instruction cache line containing Address + Length
3747 -1 is invalidated. This function may choose to invalidate the entire
3748 instruction cache if that is more efficient than invalidating the specified
3749 range. If Length is 0, the no instruction cache lines are invalidated.
3750 Address is returned.
3752 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
3754 @param Address The base address of the instruction lines to invalidate. If
3755 the CPU is in a physical addressing mode, then Address is a
3756 physical address. If the CPU is in a virtual addressing mode,
3757 then Address is a virtual address.
3759 @param Length The number of bytes to invalidate from the instruction cache.
3766 IpfFlushCacheRange (
3773 Executes a FC instruction
3774 Executes a FC instruction on the cache line specified by Address.
3775 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3776 An implementation may flush a larger region. This function is only available on IPF.
3778 @param Address The Address of cache line to be flushed.
3780 @return The address of FC instruction executed.
3791 Executes a FC.I instruction.
3792 Executes a FC.I instruction on the cache line specified by Address.
3793 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3794 An implementation may flush a larger region. This function is only available on IPF.
3796 @param Address The Address of cache line to be flushed.
3798 @return The address of FC.I instruction executed.
3809 Reads the current value of a Processor Identifier Register (CPUID).
3811 Reads and returns the current value of Processor Identifier Register specified by Index.
3812 The Index of largest implemented CPUID (One less than the number of implemented CPUID
3813 registers) is determined by CPUID [3] bits {7:0}.
3814 No parameter checking is performed on Index. If the Index value is beyond the
3815 implemented CPUID register range, a Reserved Register/Field fault may occur. The caller
3816 must either guarantee that Index is valid, or the caller must set up fault handlers to
3817 catch the faults. This function is only available on IPF.
3819 @param Index The 8-bit Processor Identifier Register index to read.
3821 @return The current value of Processor Identifier Register specified by Index.
3832 Reads the current value of 64-bit Processor Status Register (PSR).
3833 This function is only available on IPF.
3835 @return The current value of PSR.
3846 Writes the current value of 64-bit Processor Status Register (PSR).
3848 No parameter checking is performed on Value. All bits of Value corresponding to
3849 reserved fields of PSR must be 0 or a Reserved Register/Field fault may occur.
3850 The caller must either guarantee that Value is valid, or the caller must set up
3851 fault handlers to catch the faults. This function is only available on IPF.
3853 @param Value The 64-bit value to write to PSR.
3855 @return The 64-bit value written to the PSR.
3866 Reads the current value of 64-bit Kernel Register #0 (KR0).
3867 This function is only available on IPF.
3869 @return The current value of KR0.
3880 Reads the current value of 64-bit Kernel Register #1 (KR1).
3881 This function is only available on IPF.
3883 @return The current value of KR1.
3894 Reads the current value of 64-bit Kernel Register #2 (KR2).
3895 This function is only available on IPF.
3897 @return The current value of KR2.
3908 Reads the current value of 64-bit Kernel Register #3 (KR3).
3909 This function is only available on IPF.
3911 @return The current value of KR3.
3922 Reads the current value of 64-bit Kernel Register #4 (KR4).
3923 This function is only available on IPF.
3925 @return The current value of KR4.
3936 Reads the current value of 64-bit Kernel Register #5 (KR5).
3937 This function is only available on IPF.
3939 @return The current value of KR5.
3950 Reads the current value of 64-bit Kernel Register #6 (KR6).
3951 This function is only available on IPF.
3953 @return The current value of KR6.
3964 Reads the current value of 64-bit Kernel Register #7 (KR7).
3965 This function is only available on IPF.
3967 @return The current value of KR7.
3978 Write the current value of 64-bit Kernel Register #0 (KR0).
3979 This function is only available on IPF.
3981 @param Value The 64-bit value to write to KR0.
3983 @return The 64-bit value written to the KR0.
3994 Write the current value of 64-bit Kernel Register #1 (KR1).
3995 This function is only available on IPF.
3997 @param Value The 64-bit value to write to KR1.
3999 @return The 64-bit value written to the KR1.
4010 Write the current value of 64-bit Kernel Register #2 (KR2).
4011 This function is only available on IPF.
4013 @param Value The 64-bit value to write to KR2.
4015 @return The 64-bit value written to the KR2.
4026 Write the current value of 64-bit Kernel Register #3 (KR3).
4027 This function is only available on IPF.
4029 @param Value The 64-bit value to write to KR3.
4031 @return The 64-bit value written to the KR3.
4042 Write the current value of 64-bit Kernel Register #4 (KR4).
4043 This function is only available on IPF.
4045 @param Value The 64-bit value to write to KR4.
4047 @return The 64-bit value written to the KR4.
4058 Write the current value of 64-bit Kernel Register #5 (KR5).
4059 This function is only available on IPF.
4061 @param Value The 64-bit value to write to KR5.
4063 @return The 64-bit value written to the KR5.
4074 Write the current value of 64-bit Kernel Register #6 (KR6).
4075 This function is only available on IPF.
4077 @param Value The 64-bit value to write to KR6.
4079 @return The 64-bit value written to the KR6.
4090 Write the current value of 64-bit Kernel Register #7 (KR7).
4091 This function is only available on IPF.
4093 @param Value The 64-bit value to write to KR7.
4095 @return The 64-bit value written to the KR7.
4106 Reads the current value of Interval Timer Counter Register (ITC).
4107 This function is only available on IPF.
4109 @return The current value of ITC.
4120 Reads the current value of Interval Timer Vector Register (ITV).
4121 This function is only available on IPF.
4123 @return The current value of ITV.
4134 Reads the current value of Interval Timer Match Register (ITM).
4135 This function is only available on IPF.
4137 @return The current value of ITM.
4147 Writes the current value of 64-bit Interval Timer Counter Register (ITC).
4148 This function is only available on IPF.
4150 @param Value The 64-bit value to write to ITC.
4152 @return The 64-bit value written to the ITC.
4163 Writes the current value of 64-bit Interval Timer Match Register (ITM).
4164 This function is only available on IPF.
4166 @param Value The 64-bit value to write to ITM.
4168 @return The 64-bit value written to the ITM.
4179 Writes the current value of 64-bit Interval Timer Vector Register (ITV).
4180 No parameter checking is performed on Value. All bits of Value corresponding to
4181 reserved fields of ITV must be 0 or a Reserved Register/Field fault may occur.
4182 The caller must either guarantee that Value is valid, or the caller must set up
4183 fault handlers to catch the faults.
4184 This function is only available on IPF.
4186 @param Value The 64-bit value to write to ITV.
4188 @return The 64-bit value written to the ITV.
4199 Reads the current value of Default Control Register (DCR).
4200 This function is only available on IPF.
4202 @return The current value of DCR.
4213 Reads the current value of Interruption Vector Address Register (IVA).
4214 This function is only available on IPF.
4216 @return The current value of IVA.
4226 Reads the current value of Page Table Address Register (PTA).
4227 This function is only available on IPF.
4229 @return The current value of PTA.
4240 Writes the current value of 64-bit Default Control Register (DCR).
4241 No parameter checking is performed on Value. All bits of Value corresponding to
4242 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4243 The caller must either guarantee that Value is valid, or the caller must set up
4244 fault handlers to catch the faults.
4245 This function is only available on IPF.
4247 @param Value The 64-bit value to write to DCR.
4249 @return The 64-bit value written to the DCR.
4260 Writes the current value of 64-bit Interruption Vector Address Register (IVA).
4261 The size of vector table is 32 K bytes and is 32 K bytes aligned
4262 the low 15 bits of Value is ignored when written.
4263 This function is only available on IPF.
4265 @param Value The 64-bit value to write to IVA.
4267 @return The 64-bit value written to the IVA.
4278 Writes the current value of 64-bit Page Table Address Register (PTA).
4279 No parameter checking is performed on Value. All bits of Value corresponding to
4280 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4281 The caller must either guarantee that Value is valid, or the caller must set up
4282 fault handlers to catch the faults.
4283 This function is only available on IPF.
4285 @param Value The 64-bit value to write to PTA.
4287 @return The 64-bit value written to the PTA.
4297 Reads the current value of Local Interrupt ID Register (LID).
4298 This function is only available on IPF.
4300 @return The current value of LID.
4311 Reads the current value of External Interrupt Vector Register (IVR).
4312 This function is only available on IPF.
4314 @return The current value of IVR.
4325 Reads the current value of Task Priority Register (TPR).
4326 This function is only available on IPF.
4328 @return The current value of TPR.
4339 Reads the current value of External Interrupt Request Register #0 (IRR0).
4340 This function is only available on IPF.
4342 @return The current value of IRR0.
4353 Reads the current value of External Interrupt Request Register #1 (IRR1).
4354 This function is only available on IPF.
4356 @return The current value of IRR1.
4367 Reads the current value of External Interrupt Request Register #2 (IRR2).
4368 This function is only available on IPF.
4370 @return The current value of IRR2.
4381 Reads the current value of External Interrupt Request Register #3 (IRR3).
4382 This function is only available on IPF.
4384 @return The current value of IRR3.
4395 Reads the current value of Performance Monitor Vector Register (PMV).
4396 This function is only available on IPF.
4398 @return The current value of PMV.
4409 Reads the current value of Corrected Machine Check Vector Register (CMCV).
4410 This function is only available on IPF.
4412 @return The current value of CMCV.
4423 Reads the current value of Local Redirection Register #0 (LRR0).
4424 This function is only available on IPF.
4426 @return The current value of LRR0.
4437 Reads the current value of Local Redirection Register #1 (LRR1).
4438 This function is only available on IPF.
4440 @return The current value of LRR1.
4451 Writes the current value of 64-bit Page Local Interrupt ID Register (LID).
4452 No parameter checking is performed on Value. All bits of Value corresponding to
4453 reserved fields of LID must be 0 or a Reserved Register/Field fault may occur.
4454 The caller must either guarantee that Value is valid, or the caller must set up
4455 fault handlers to catch the faults.
4456 This function is only available on IPF.
4458 @param Value The 64-bit value to write to LID.
4460 @return The 64-bit value written to the LID.
4471 Writes the current value of 64-bit Task Priority Register (TPR).
4472 No parameter checking is performed on Value. All bits of Value corresponding to
4473 reserved fields of TPR must be 0 or a Reserved Register/Field fault may occur.
4474 The caller must either guarantee that Value is valid, or the caller must set up
4475 fault handlers to catch the faults.
4476 This function is only available on IPF.
4478 @param Value The 64-bit value to write to TPR.
4480 @return The 64-bit value written to the TPR.
4491 Performs a write operation on End OF External Interrupt Register (EOI).
4492 Writes a value of 0 to the EOI Register. This function is only available on IPF.
4503 Writes the current value of 64-bit Performance Monitor Vector Register (PMV).
4504 No parameter checking is performed on Value. All bits of Value corresponding
4505 to reserved fields of PMV must be 0 or a Reserved Register/Field fault may occur.
4506 The caller must either guarantee that Value is valid, or the caller must set up
4507 fault handlers to catch the faults.
4508 This function is only available on IPF.
4510 @param Value The 64-bit value to write to PMV.
4512 @return The 64-bit value written to the PMV.
4523 Writes the current value of 64-bit Corrected Machine Check Vector Register (CMCV).
4524 No parameter checking is performed on Value. All bits of Value corresponding
4525 to reserved fields of CMCV must be 0 or a Reserved Register/Field fault may occur.
4526 The caller must either guarantee that Value is valid, or the caller must set up
4527 fault handlers to catch the faults.
4528 This function is only available on IPF.
4530 @param Value The 64-bit value to write to CMCV.
4532 @return The 64-bit value written to the CMCV.
4543 Writes the current value of 64-bit Local Redirection Register #0 (LRR0).
4544 No parameter checking is performed on Value. All bits of Value corresponding
4545 to reserved fields of LRR0 must be 0 or a Reserved Register/Field fault may occur.
4546 The caller must either guarantee that Value is valid, or the caller must set up
4547 fault handlers to catch the faults.
4548 This function is only available on IPF.
4550 @param Value The 64-bit value to write to LRR0.
4552 @return The 64-bit value written to the LRR0.
4563 Writes the current value of 64-bit Local Redirection Register #1 (LRR1).
4564 No parameter checking is performed on Value. All bits of Value corresponding
4565 to reserved fields of LRR1 must be 0 or a Reserved Register/Field fault may occur.
4566 The caller must either guarantee that Value is valid, or the caller must
4567 set up fault handlers to catch the faults.
4568 This function is only available on IPF.
4570 @param Value The 64-bit value to write to LRR1.
4572 @return The 64-bit value written to the LRR1.
4583 Reads the current value of Instruction Breakpoint Register (IBR).
4585 The Instruction Breakpoint Registers are used in pairs. The even numbered
4586 registers contain breakpoint addresses, and the odd numbered registers contain
4587 breakpoint mask conditions. At least 4 instruction registers pairs are implemented
4588 on all processor models. Implemented registers are contiguous starting with
4589 register 0. No parameter checking is performed on Index, and if the Index value
4590 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4591 occur. The caller must either guarantee that Index is valid, or the caller must
4592 set up fault handlers to catch the faults.
4593 This function is only available on IPF.
4595 @param Index The 8-bit Instruction Breakpoint Register index to read.
4597 @return The current value of Instruction Breakpoint Register specified by Index.
4608 Reads the current value of Data Breakpoint Register (DBR).
4610 The Data Breakpoint Registers are used in pairs. The even numbered registers
4611 contain breakpoint addresses, and odd numbered registers contain breakpoint
4612 mask conditions. At least 4 data registers pairs are implemented on all processor
4613 models. Implemented registers are contiguous starting with register 0.
4614 No parameter checking is performed on Index. If the Index value is beyond
4615 the implemented DBR register range, a Reserved Register/Field fault may occur.
4616 The caller must either guarantee that Index is valid, or the caller must set up
4617 fault handlers to catch the faults.
4618 This function is only available on IPF.
4620 @param Index The 8-bit Data Breakpoint Register index to read.
4622 @return The current value of Data Breakpoint Register specified by Index.
4633 Reads the current value of Performance Monitor Configuration Register (PMC).
4635 All processor implementations provide at least 4 performance counters
4636 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow
4637 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4638 additional implementation-dependent PMC and PMD to increase the number of
4639 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4640 register set is implementation dependent. No parameter checking is performed
4641 on Index. If the Index value is beyond the implemented PMC register range,
4642 zero value will be returned.
4643 This function is only available on IPF.
4645 @param Index The 8-bit Performance Monitor Configuration Register index to read.
4647 @return The current value of Performance Monitor Configuration Register
4659 Reads the current value of Performance Monitor Data Register (PMD).
4661 All processor implementations provide at least 4 performance counters
4662 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter
4663 overflow status registers (PMC [0]... PMC [3]). Processor implementations may
4664 provide additional implementation-dependent PMC and PMD to increase the number
4665 of 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4666 register set is implementation dependent. No parameter checking is performed
4667 on Index. If the Index value is beyond the implemented PMD register range,
4668 zero value will be returned.
4669 This function is only available on IPF.
4671 @param Index The 8-bit Performance Monitor Data Register index to read.
4673 @return The current value of Performance Monitor Data Register specified by Index.
4684 Writes the current value of 64-bit Instruction Breakpoint Register (IBR).
4686 Writes current value of Instruction Breakpoint Register specified by Index.
4687 The Instruction Breakpoint Registers are used in pairs. The even numbered
4688 registers contain breakpoint addresses, and odd numbered registers contain
4689 breakpoint mask conditions. At least 4 instruction registers pairs are implemented
4690 on all processor models. Implemented registers are contiguous starting with
4691 register 0. No parameter checking is performed on Index. If the Index value
4692 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4693 occur. The caller must either guarantee that Index is valid, or the caller must
4694 set up fault handlers to catch the faults.
4695 This function is only available on IPF.
4697 @param Index The 8-bit Instruction Breakpoint Register index to write.
4698 @param Value The 64-bit value to write to IBR.
4700 @return The 64-bit value written to the IBR.
4712 Writes the current value of 64-bit Data Breakpoint Register (DBR).
4714 Writes current value of Data Breakpoint Register specified by Index.
4715 The Data Breakpoint Registers are used in pairs. The even numbered registers
4716 contain breakpoint addresses, and odd numbered registers contain breakpoint
4717 mask conditions. At least 4 data registers pairs are implemented on all processor
4718 models. Implemented registers are contiguous starting with register 0. No parameter
4719 checking is performed on Index. If the Index value is beyond the implemented
4720 DBR register range, a Reserved Register/Field fault may occur. The caller must
4721 either guarantee that Index is valid, or the caller must set up fault handlers to
4723 This function is only available on IPF.
4725 @param Index The 8-bit Data Breakpoint Register index to write.
4726 @param Value The 64-bit value to write to DBR.
4728 @return The 64-bit value written to the DBR.
4740 Writes the current value of 64-bit Performance Monitor Configuration Register (PMC).
4742 Writes current value of Performance Monitor Configuration Register specified by Index.
4743 All processor implementations provide at least 4 performance counters
4744 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow status
4745 registers (PMC [0]... PMC [3]). Processor implementations may provide additional
4746 implementation-dependent PMC and PMD to increase the number of 'generic' performance
4747 counters (PMC/PMD pairs). The remainder of PMC and PMD register set is implementation
4748 dependent. No parameter checking is performed on Index. If the Index value is
4749 beyond the implemented PMC register range, the write is ignored.
4750 This function is only available on IPF.
4752 @param Index The 8-bit Performance Monitor Configuration Register index to write.
4753 @param Value The 64-bit value to write to PMC.
4755 @return The 64-bit value written to the PMC.
4767 Writes the current value of 64-bit Performance Monitor Data Register (PMD).
4769 Writes current value of Performance Monitor Data Register specified by Index.
4770 All processor implementations provide at least 4 performance counters
4771 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow
4772 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4773 additional implementation-dependent PMC and PMD to increase the number of 'generic'
4774 performance counters (PMC/PMD pairs). The remainder of PMC and PMD register set
4775 is implementation dependent. No parameter checking is performed on Index. If the
4776 Index value is beyond the implemented PMD register range, the write is ignored.
4777 This function is only available on IPF.
4779 @param Index The 8-bit Performance Monitor Data Register index to write.
4780 @param Value The 64-bit value to write to PMD.
4782 @return The 64-bit value written to the PMD.
4794 Reads the current value of 64-bit Global Pointer (GP).
4796 Reads and returns the current value of GP.
4797 This function is only available on IPF.
4799 @return The current value of GP.
4810 Write the current value of 64-bit Global Pointer (GP).
4812 Writes the current value of GP. The 64-bit value written to the GP is returned.
4813 No parameter checking is performed on Value.
4814 This function is only available on IPF.
4816 @param Value The 64-bit value to write to GP.
4818 @return The 64-bit value written to the GP.
4829 Reads the current value of 64-bit Stack Pointer (SP).
4831 Reads and returns the current value of SP.
4832 This function is only available on IPF.
4834 @return The current value of SP.
4845 Determines if the CPU is currently executing in virtual, physical, or mixed mode.
4847 Determines the current execution mode of the CPU.
4848 If the CPU is in virtual mode(PSR.RT=1, PSR.DT=1, PSR.IT=1), then 1 is returned.
4849 If the CPU is in physical mode(PSR.RT=0, PSR.DT=0, PSR.IT=0), then 0 is returned.
4850 If the CPU is not in physical mode or virtual mode, then it is in mixed mode,
4852 This function is only available on IPF.
4854 @retval 1 The CPU is in virtual mode.
4855 @retval 0 The CPU is in physical mode.
4856 @retval -1 The CPU is in mixed mode.
4867 Makes a PAL procedure call.
4869 This is a wrapper function to make a PAL procedure call. Based on the Index
4870 value this API will make static or stacked PAL call. The following table
4871 describes the usage of PAL Procedure Index Assignment. Architected procedures
4872 may be designated as required or optional. If a PAL procedure is specified
4873 as optional, a unique return code of 0xFFFFFFFFFFFFFFFF is returned in the
4874 Status field of the PAL_CALL_RETURN structure.
4875 This indicates that the procedure is not present in this PAL implementation.
4876 It is the caller's responsibility to check for this return code after calling
4877 any optional PAL procedure.
4878 No parameter checking is performed on the 5 input parameters, but there are
4879 some common rules that the caller should follow when making a PAL call. Any
4880 address passed to PAL as buffers for return parameters must be 8-byte aligned.
4881 Unaligned addresses may cause undefined results. For those parameters defined
4882 as reserved or some fields defined as reserved must be zero filled or the invalid
4883 argument return value may be returned or undefined result may occur during the
4884 execution of the procedure. If the PalEntryPoint does not point to a valid
4885 PAL entry point then the system behavior is undefined. This function is only
4888 @param PalEntryPoint The PAL procedure calls entry point.
4889 @param Index The PAL procedure Index number.
4890 @param Arg2 The 2nd parameter for PAL procedure calls.
4891 @param Arg3 The 3rd parameter for PAL procedure calls.
4892 @param Arg4 The 4th parameter for PAL procedure calls.
4894 @return structure returned from the PAL Call procedure, including the status and return value.
4900 IN UINT64 PalEntryPoint
,
4909 Transfers control to a function starting with a new stack.
4911 Transfers control to the function specified by EntryPoint using the new stack
4912 specified by NewStack and passing in the parameters specified by Context1 and
4913 Context2. Context1 and Context2 are optional and may be NULL. The function
4914 EntryPoint must never return.
4916 If EntryPoint is NULL, then ASSERT().
4917 If NewStack is NULL, then ASSERT().
4919 @param EntryPoint A pointer to function to call with the new stack.
4920 @param Context1 A pointer to the context to pass into the EntryPoint
4922 @param Context2 A pointer to the context to pass into the EntryPoint
4924 @param NewStack A pointer to the new stack to use for the EntryPoint
4926 @param NewBsp A pointer to the new memory location for RSE backing
4932 AsmSwitchStackAndBackingStore (
4933 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
4934 IN VOID
*Context1
, OPTIONAL
4935 IN VOID
*Context2
, OPTIONAL
4941 @todo This call should be removed after the PalCall
4942 Instance issue has been fixed.
4944 Performs a PAL call using static calling convention.
4946 An internal function to perform a PAL call using static calling convention.
4948 @param PalEntryPoint The entry point address of PAL. The address in ar.kr5
4949 would be used if this parameter were NULL on input.
4950 @param Arg1 The first argument of a PAL call.
4951 @param Arg2 The second argument of a PAL call.
4952 @param Arg3 The third argument of a PAL call.
4953 @param Arg4 The fourth argument of a PAL call.
4955 @return The values returned in r8, r9, r10 and r11.
4960 IN CONST VOID
*PalEntryPoint
,
4969 #elif defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
4971 /// IA32 and X64 Specific Functions
4972 /// Byte packed structure for 16-bit Real Mode EFLAGS
4976 UINT32 CF
:1; /// Carry Flag
4977 UINT32 Reserved_0
:1; /// Reserved
4978 UINT32 PF
:1; /// Parity Flag
4979 UINT32 Reserved_1
:1; /// Reserved
4980 UINT32 AF
:1; /// Auxiliary Carry Flag
4981 UINT32 Reserved_2
:1; /// Reserved
4982 UINT32 ZF
:1; /// Zero Flag
4983 UINT32 SF
:1; /// Sign Flag
4984 UINT32 TF
:1; /// Trap Flag
4985 UINT32 IF
:1; /// Interrupt Enable Flag
4986 UINT32 DF
:1; /// Direction Flag
4987 UINT32 OF
:1; /// Overflow Flag
4988 UINT32 IOPL
:2; /// I/O Privilege Level
4989 UINT32 NT
:1; /// Nested Task
4990 UINT32 Reserved_3
:1; /// Reserved
4996 /// Byte packed structure for EFLAGS/RFLAGS
4997 /// 32-bits on IA-32
4998 /// 64-bits on X64. The upper 32-bits on X64 are reserved
5002 UINT32 CF
:1; /// Carry Flag
5003 UINT32 Reserved_0
:1; /// Reserved
5004 UINT32 PF
:1; /// Parity Flag
5005 UINT32 Reserved_1
:1; /// Reserved
5006 UINT32 AF
:1; /// Auxiliary Carry Flag
5007 UINT32 Reserved_2
:1; /// Reserved
5008 UINT32 ZF
:1; /// Zero Flag
5009 UINT32 SF
:1; /// Sign Flag
5010 UINT32 TF
:1; /// Trap Flag
5011 UINT32 IF
:1; /// Interrupt Enable Flag
5012 UINT32 DF
:1; /// Direction Flag
5013 UINT32 OF
:1; /// Overflow Flag
5014 UINT32 IOPL
:2; /// I/O Privilege Level
5015 UINT32 NT
:1; /// Nested Task
5016 UINT32 Reserved_3
:1; /// Reserved
5017 UINT32 RF
:1; /// Resume Flag
5018 UINT32 VM
:1; /// Virtual 8086 Mode
5019 UINT32 AC
:1; /// Alignment Check
5020 UINT32 VIF
:1; /// Virtual Interrupt Flag
5021 UINT32 VIP
:1; /// Virtual Interrupt Pending
5022 UINT32 ID
:1; /// ID Flag
5023 UINT32 Reserved_4
:10; /// Reserved
5029 /// Byte packed structure for Control Register 0 (CR0)
5030 /// 32-bits on IA-32
5031 /// 64-bits on X64. The upper 32-bits on X64 are reserved
5035 UINT32 PE
:1; /// Protection Enable
5036 UINT32 MP
:1; /// Monitor Coprocessor
5037 UINT32 EM
:1; /// Emulation
5038 UINT32 TS
:1; /// Task Switched
5039 UINT32 ET
:1; /// Extension Type
5040 UINT32 NE
:1; /// Numeric Error
5041 UINT32 Reserved_0
:10; /// Reserved
5042 UINT32 WP
:1; /// Write Protect
5043 UINT32 Reserved_1
:1; /// Reserved
5044 UINT32 AM
:1; /// Alignment Mask
5045 UINT32 Reserved_2
:10; /// Reserved
5046 UINT32 NW
:1; /// Mot Write-through
5047 UINT32 CD
:1; /// Cache Disable
5048 UINT32 PG
:1; /// Paging
5054 /// Byte packed structure for Control Register 4 (CR4)
5055 /// 32-bits on IA-32
5056 /// 64-bits on X64. The upper 32-bits on X64 are reserved
5060 UINT32 VME
:1; /// Virtual-8086 Mode Extensions
5061 UINT32 PVI
:1; /// Protected-Mode Virtual Interrupts
5062 UINT32 TSD
:1; /// Time Stamp Disable
5063 UINT32 DE
:1; /// Debugging Extensions
5064 UINT32 PSE
:1; /// Page Size Extensions
5065 UINT32 PAE
:1; /// Physical Address Extension
5066 UINT32 MCE
:1; /// Machine Check Enable
5067 UINT32 PGE
:1; /// Page Global Enable
5068 UINT32 PCE
:1; /// Performance Monitoring Counter
5070 UINT32 OSFXSR
:1; /// Operating System Support for
5071 /// FXSAVE and FXRSTOR instructions
5072 UINT32 OSXMMEXCPT
:1; /// Operating System Support for
5073 /// Unmasked SIMD Floating Point
5075 UINT32 Reserved_0
:2; /// Reserved
5076 UINT32 VMXE
:1; /// VMX Enable
5077 UINT32 Reserved_1
:18; /// Reseved
5083 /// Byte packed structure for an IDTR, GDTR, LDTR descriptor
5084 /// @todo How to make this structure byte-packed in a compiler independent way?
5093 #define IA32_IDT_GATE_TYPE_TASK 0x85
5094 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
5095 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
5096 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
5097 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
5100 /// Byte packed structure for an Interrupt Gate Descriptor
5102 #if defined (MDE_CPU_IA32)
5106 UINT32 OffsetLow
:16; // Offset bits 15..0
5107 UINT32 Selector
:16; // Selector
5108 UINT32 Reserved_0
:8; // Reserved
5109 UINT32 GateType
:8; // Gate Type. See #defines above
5110 UINT32 OffsetHigh
:16; // Offset bits 31..16
5113 } IA32_IDT_GATE_DESCRIPTOR
;
5117 #if defined (MDE_CPU_X64)
5121 UINT32 OffsetLow
:16; // Offset bits 15..0
5122 UINT32 Selector
:16; // Selector
5123 UINT32 Reserved_0
:8; // Reserved
5124 UINT32 GateType
:8; // Gate Type. See #defines above
5125 UINT32 OffsetHigh
:16; // Offset bits 31..16
5126 UINT32 OffsetUpper
:32; // Offset bits 63..32
5127 UINT32 Reserved_1
:32; // Reserved
5131 } IA32_IDT_GATE_DESCRIPTOR
;
5136 /// Byte packed structure for an FP/SSE/SSE2 context
5143 /// Structures for the 16-bit real mode thunks
5196 IA32_EFLAGS32 EFLAGS
;
5206 } IA32_REGISTER_SET
;
5209 /// Byte packed structure for an 16-bit real mode thunks
5212 IA32_REGISTER_SET
*RealModeState
;
5213 VOID
*RealModeBuffer
;
5214 UINT32 RealModeBufferSize
;
5215 UINT32 ThunkAttributes
;
5218 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
5219 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
5220 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
5223 Retrieves CPUID information.
5225 Executes the CPUID instruction with EAX set to the value specified by Index.
5226 This function always returns Index.
5227 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5228 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5229 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5230 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5231 This function is only available on IA-32 and X64.
5233 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
5235 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
5236 instruction. This is an optional parameter that may be NULL.
5237 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
5238 instruction. This is an optional parameter that may be NULL.
5239 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
5240 instruction. This is an optional parameter that may be NULL.
5241 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
5242 instruction. This is an optional parameter that may be NULL.
5251 OUT UINT32
*Eax
, OPTIONAL
5252 OUT UINT32
*Ebx
, OPTIONAL
5253 OUT UINT32
*Ecx
, OPTIONAL
5254 OUT UINT32
*Edx OPTIONAL
5259 Retrieves CPUID information using an extended leaf identifier.
5261 Executes the CPUID instruction with EAX set to the value specified by Index
5262 and ECX set to the value specified by SubIndex. This function always returns
5263 Index. This function is only available on IA-32 and x64.
5265 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5266 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5267 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5268 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5270 @param Index The 32-bit value to load into EAX prior to invoking the
5272 @param SubIndex The 32-bit value to load into ECX prior to invoking the
5274 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
5275 instruction. This is an optional parameter that may be
5277 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
5278 instruction. This is an optional parameter that may be
5280 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
5281 instruction. This is an optional parameter that may be
5283 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
5284 instruction. This is an optional parameter that may be
5295 OUT UINT32
*Eax
, OPTIONAL
5296 OUT UINT32
*Ebx
, OPTIONAL
5297 OUT UINT32
*Ecx
, OPTIONAL
5298 OUT UINT32
*Edx OPTIONAL
5303 Returns the lower 32-bits of a Machine Specific Register(MSR).
5305 Reads and returns the lower 32-bits of the MSR specified by Index.
5306 No parameter checking is performed on Index, and some Index values may cause
5307 CPU exceptions. The caller must either guarantee that Index is valid, or the
5308 caller must set up exception handlers to catch the exceptions. This function
5309 is only available on IA-32 and X64.
5311 @param Index The 32-bit MSR index to read.
5313 @return The lower 32 bits of the MSR identified by Index.
5324 Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.
5325 The upper 32-bits of the MSR are set to zero.
5327 Writes the 32-bit value specified by Value to the MSR specified by Index. The
5328 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
5329 the MSR is returned. No parameter checking is performed on Index or Value,
5330 and some of these may cause CPU exceptions. The caller must either guarantee
5331 that Index and Value are valid, or the caller must establish proper exception
5332 handlers. This function is only available on IA-32 and X64.
5334 @param Index The 32-bit MSR index to write.
5335 @param Value The 32-bit value to write to the MSR.
5349 Reads a 64-bit MSR, performs a bitwise inclusive OR on the lower 32-bits, and
5350 writes the result back to the 64-bit MSR.
5352 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
5353 between the lower 32-bits of the read result and the value specified by
5354 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
5355 32-bits of the value written to the MSR is returned. No parameter checking is
5356 performed on Index or OrData, and some of these may cause CPU exceptions. The
5357 caller must either guarantee that Index and OrData are valid, or the caller
5358 must establish proper exception handlers. This function is only available on
5361 @param Index The 32-bit MSR index to write.
5362 @param OrData The value to OR with the read value from the MSR.
5364 @return The lower 32-bit value written to the MSR.
5376 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
5377 the result back to the 64-bit MSR.
5379 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5380 lower 32-bits of the read result and the value specified by AndData, and
5381 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
5382 the value written to the MSR is returned. No parameter checking is performed
5383 on Index or AndData, and some of these may cause CPU exceptions. The caller
5384 must either guarantee that Index and AndData are valid, or the caller must
5385 establish proper exception handlers. This function is only available on IA-32
5388 @param Index The 32-bit MSR index to write.
5389 @param AndData The value to AND with the read value from the MSR.
5391 @return The lower 32-bit value written to the MSR.
5403 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive OR
5404 on the lower 32-bits, and writes the result back to the 64-bit MSR.
5406 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5407 lower 32-bits of the read result and the value specified by AndData
5408 preserving the upper 32-bits, performs a bitwise inclusive OR between the
5409 result of the AND operation and the value specified by OrData, and writes the
5410 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
5411 written to the MSR is returned. No parameter checking is performed on Index,
5412 AndData, or OrData, and some of these may cause CPU exceptions. The caller
5413 must either guarantee that Index, AndData, and OrData are valid, or the
5414 caller must establish proper exception handlers. This function is only
5415 available on IA-32 and X64.
5417 @param Index The 32-bit MSR index to write.
5418 @param AndData The value to AND with the read value from the MSR.
5419 @param OrData The value to OR with the result of the AND operation.
5421 @return The lower 32-bit value written to the MSR.
5434 Reads a bit field of an MSR.
5436 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
5437 specified by the StartBit and the EndBit. The value of the bit field is
5438 returned. The caller must either guarantee that Index is valid, or the caller
5439 must set up exception handlers to catch the exceptions. This function is only
5440 available on IA-32 and X64.
5442 If StartBit is greater than 31, then ASSERT().
5443 If EndBit is greater than 31, then ASSERT().
5444 If EndBit is less than StartBit, then ASSERT().
5446 @param Index The 32-bit MSR index to read.
5447 @param StartBit The ordinal of the least significant bit in the bit field.
5449 @param EndBit The ordinal of the most significant bit in the bit field.
5452 @return The bit field read from the MSR.
5457 AsmMsrBitFieldRead32 (
5465 Writes a bit field to an MSR.
5467 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
5468 field is specified by the StartBit and the EndBit. All other bits in the
5469 destination MSR are preserved. The lower 32-bits of the MSR written is
5470 returned. Extra left bits in Value are stripped. The caller must either
5471 guarantee that Index and the data written is valid, or the caller must set up
5472 exception handlers to catch the exceptions. This function is only available
5475 If StartBit is greater than 31, then ASSERT().
5476 If EndBit is greater than 31, then ASSERT().
5477 If EndBit is less than StartBit, then ASSERT().
5479 @param Index The 32-bit MSR index to write.
5480 @param StartBit The ordinal of the least significant bit in the bit field.
5482 @param EndBit The ordinal of the most significant bit in the bit field.
5484 @param Value New value of the bit field.
5486 @return The lower 32-bit of the value written to the MSR.
5491 AsmMsrBitFieldWrite32 (
5500 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
5501 result back to the bit field in the 64-bit MSR.
5503 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
5504 between the read result and the value specified by OrData, and writes the
5505 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
5506 written to the MSR are returned. Extra left bits in OrData are stripped. The
5507 caller must either guarantee that Index and the data written is valid, or
5508 the caller must set up exception handlers to catch the exceptions. This
5509 function is only available on IA-32 and X64.
5511 If StartBit is greater than 31, then ASSERT().
5512 If EndBit is greater than 31, then ASSERT().
5513 If EndBit is less than StartBit, then ASSERT().
5515 @param Index The 32-bit MSR index to write.
5516 @param StartBit The ordinal of the least significant bit in the bit field.
5518 @param EndBit The ordinal of the most significant bit in the bit field.
5520 @param OrData The value to OR with the read value from the MSR.
5522 @return The lower 32-bit of the value written to the MSR.
5527 AsmMsrBitFieldOr32 (
5536 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5537 result back to the bit field in the 64-bit MSR.
5539 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5540 read result and the value specified by AndData, and writes the result to the
5541 64-bit MSR specified by Index. The lower 32-bits of the value written to the
5542 MSR are returned. Extra left bits in AndData are stripped. The caller must
5543 either guarantee that Index and the data written is valid, or the caller must
5544 set up exception handlers to catch the exceptions. This function is only
5545 available on IA-32 and X64.
5547 If StartBit is greater than 31, then ASSERT().
5548 If EndBit is greater than 31, then ASSERT().
5549 If EndBit is less than StartBit, then ASSERT().
5551 @param Index The 32-bit MSR index to write.
5552 @param StartBit The ordinal of the least significant bit in the bit field.
5554 @param EndBit The ordinal of the most significant bit in the bit field.
5556 @param AndData The value to AND with the read value from the MSR.
5558 @return The lower 32-bit of the value written to the MSR.
5563 AsmMsrBitFieldAnd32 (
5572 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5573 bitwise inclusive OR, and writes the result back to the bit field in the
5576 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
5577 bitwise inclusive OR between the read result and the value specified by
5578 AndData, and writes the result to the 64-bit MSR specified by Index. The
5579 lower 32-bits of the value written to the MSR are returned. Extra left bits
5580 in both AndData and OrData are stripped. The caller must either guarantee
5581 that Index and the data written is valid, or the caller must set up exception
5582 handlers to catch the exceptions. This function is only available on IA-32
5585 If StartBit is greater than 31, then ASSERT().
5586 If EndBit is greater than 31, then ASSERT().
5587 If EndBit is less than StartBit, then ASSERT().
5589 @param Index The 32-bit MSR index to write.
5590 @param StartBit The ordinal of the least significant bit in the bit field.
5592 @param EndBit The ordinal of the most significant bit in the bit field.
5594 @param AndData The value to AND with the read value from the MSR.
5595 @param OrData The value to OR with the result of the AND operation.
5597 @return The lower 32-bit of the value written to the MSR.
5602 AsmMsrBitFieldAndThenOr32 (
5612 Returns a 64-bit Machine Specific Register(MSR).
5614 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
5615 performed on Index, and some Index values may cause CPU exceptions. The
5616 caller must either guarantee that Index is valid, or the caller must set up
5617 exception handlers to catch the exceptions. This function is only available
5620 @param Index The 32-bit MSR index to read.
5622 @return The value of the MSR identified by Index.
5633 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
5636 Writes the 64-bit value specified by Value to the MSR specified by Index. The
5637 64-bit value written to the MSR is returned. No parameter checking is
5638 performed on Index or Value, and some of these may cause CPU exceptions. The
5639 caller must either guarantee that Index and Value are valid, or the caller
5640 must establish proper exception handlers. This function is only available on
5643 @param Index The 32-bit MSR index to write.
5644 @param Value The 64-bit value to write to the MSR.
5658 Reads a 64-bit MSR, performs a bitwise inclusive OR, and writes the result
5659 back to the 64-bit MSR.
5661 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
5662 between the read result and the value specified by OrData, and writes the
5663 result to the 64-bit MSR specified by Index. The value written to the MSR is
5664 returned. No parameter checking is performed on Index or OrData, and some of
5665 these may cause CPU exceptions. The caller must either guarantee that Index
5666 and OrData are valid, or the caller must establish proper exception handlers.
5667 This function is only available on IA-32 and X64.
5669 @param Index The 32-bit MSR index to write.
5670 @param OrData The value to OR with the read value from the MSR.
5672 @return The value written back to the MSR.
5684 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
5687 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5688 read result and the value specified by OrData, and writes the result to the
5689 64-bit MSR specified by Index. The value written to the MSR is returned. No
5690 parameter checking is performed on Index or OrData, and some of these may
5691 cause CPU exceptions. The caller must either guarantee that Index and OrData
5692 are valid, or the caller must establish proper exception handlers. This
5693 function is only available on IA-32 and X64.
5695 @param Index The 32-bit MSR index to write.
5696 @param AndData The value to AND with the read value from the MSR.
5698 @return The value written back to the MSR.
5710 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive
5711 OR, and writes the result back to the 64-bit MSR.
5713 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
5714 result and the value specified by AndData, performs a bitwise inclusive OR
5715 between the result of the AND operation and the value specified by OrData,
5716 and writes the result to the 64-bit MSR specified by Index. The value written
5717 to the MSR is returned. No parameter checking is performed on Index, AndData,
5718 or OrData, and some of these may cause CPU exceptions. The caller must either
5719 guarantee that Index, AndData, and OrData are valid, or the caller must
5720 establish proper exception handlers. This function is only available on IA-32
5723 @param Index The 32-bit MSR index to write.
5724 @param AndData The value to AND with the read value from the MSR.
5725 @param OrData The value to OR with the result of the AND operation.
5727 @return The value written back to the MSR.
5740 Reads a bit field of an MSR.
5742 Reads the bit field in the 64-bit MSR. The bit field is specified by the
5743 StartBit and the EndBit. The value of the bit field is returned. The caller
5744 must either guarantee that Index is valid, or the caller must set up
5745 exception handlers to catch the exceptions. This function is only available
5748 If StartBit is greater than 63, then ASSERT().
5749 If EndBit is greater than 63, then ASSERT().
5750 If EndBit is less than StartBit, then ASSERT().
5752 @param Index The 32-bit MSR index to read.
5753 @param StartBit The ordinal of the least significant bit in the bit field.
5755 @param EndBit The ordinal of the most significant bit in the bit field.
5758 @return The value read from the MSR.
5763 AsmMsrBitFieldRead64 (
5771 Writes a bit field to an MSR.
5773 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
5774 the StartBit and the EndBit. All other bits in the destination MSR are
5775 preserved. The MSR written is returned. Extra left bits in Value are
5776 stripped. The caller must either guarantee that Index and the data written is
5777 valid, or the caller must set up exception handlers to catch the exceptions.
5778 This function is only available on IA-32 and X64.
5780 If StartBit is greater than 63, then ASSERT().
5781 If EndBit is greater than 63, then ASSERT().
5782 If EndBit is less than StartBit, then ASSERT().
5784 @param Index The 32-bit MSR index to write.
5785 @param StartBit The ordinal of the least significant bit in the bit field.
5787 @param EndBit The ordinal of the most significant bit in the bit field.
5789 @param Value New value of the bit field.
5791 @return The value written back to the MSR.
5796 AsmMsrBitFieldWrite64 (
5805 Reads a bit field in a 64-bit MSR, performs a bitwise inclusive OR, and
5806 writes the result back to the bit field in the 64-bit MSR.
5808 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
5809 between the read result and the value specified by OrData, and writes the
5810 result to the 64-bit MSR specified by Index. The value written to the MSR is
5811 returned. Extra left bits in OrData are stripped. The caller must either
5812 guarantee that Index and the data written is valid, or the caller must set up
5813 exception handlers to catch the exceptions. This function is only available
5816 If StartBit is greater than 63, then ASSERT().
5817 If EndBit is greater than 63, then ASSERT().
5818 If EndBit is less than StartBit, then ASSERT().
5820 @param Index The 32-bit MSR index to write.
5821 @param StartBit The ordinal of the least significant bit in the bit field.
5823 @param EndBit The ordinal of the most significant bit in the bit field.
5825 @param OrData The value to OR with the read value from the bit field.
5827 @return The value written back to the MSR.
5832 AsmMsrBitFieldOr64 (
5841 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5842 result back to the bit field in the 64-bit MSR.
5844 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5845 read result and the value specified by AndData, and writes the result to the
5846 64-bit MSR specified by Index. The value written to the MSR is returned.
5847 Extra left bits in AndData are stripped. The caller must either guarantee
5848 that Index and the data written is valid, or the caller must set up exception
5849 handlers to catch the exceptions. This function is only available on IA-32
5852 If StartBit is greater than 63, then ASSERT().
5853 If EndBit is greater than 63, then ASSERT().
5854 If EndBit is less than StartBit, 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 AndData The value to AND with the read value from the bit field.
5863 @return The value written back to the MSR.
5868 AsmMsrBitFieldAnd64 (
5877 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5878 bitwise inclusive OR, and writes the result back to the bit field in the
5881 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
5882 a bitwise inclusive OR between the read result and the value specified by
5883 AndData, and writes the result to the 64-bit MSR specified by Index. The
5884 value written to the MSR is returned. Extra left bits in both AndData and
5885 OrData are stripped. The caller must either guarantee that Index and the data
5886 written is valid, or the caller must set up exception handlers to catch the
5887 exceptions. This function is only available on IA-32 and X64.
5889 If StartBit is greater than 63, then ASSERT().
5890 If EndBit is greater than 63, then ASSERT().
5891 If EndBit is less than StartBit, 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.
5899 @param OrData The value to OR with the result of the AND operation.
5901 @return The value written back to the MSR.
5906 AsmMsrBitFieldAndThenOr64 (
5916 Reads the current value of the EFLAGS register.
5918 Reads and returns the current value of the EFLAGS register. This function is
5919 only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a
5920 64-bit value on X64.
5922 @return EFLAGS on IA-32 or RFLAGS on X64.
5933 Reads the current value of the Control Register 0 (CR0).
5935 Reads and returns the current value of CR0. This function is only available
5936 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5939 @return The value of the Control Register 0 (CR0).
5950 Reads the current value of the Control Register 2 (CR2).
5952 Reads and returns the current value of CR2. This function is only available
5953 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5956 @return The value of the Control Register 2 (CR2).
5967 Reads the current value of the Control Register 3 (CR3).
5969 Reads and returns the current value of CR3. This function is only available
5970 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5973 @return The value of the Control Register 3 (CR3).
5984 Reads the current value of the Control Register 4 (CR4).
5986 Reads and returns the current value of CR4. This function is only available
5987 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5990 @return The value of the Control Register 4 (CR4).
6001 Writes a value to Control Register 0 (CR0).
6003 Writes and returns a new value to CR0. This function is only available on
6004 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6006 @param Cr0 The value to write to CR0.
6008 @return The value written to CR0.
6019 Writes a value to Control Register 2 (CR2).
6021 Writes and returns a new value to CR2. This function is only available on
6022 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6024 @param Cr2 The value to write to CR2.
6026 @return The value written to CR2.
6037 Writes a value to Control Register 3 (CR3).
6039 Writes and returns a new value to CR3. This function is only available on
6040 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6042 @param Cr3 The value to write to CR3.
6044 @return The value written to CR3.
6055 Writes a value to Control Register 4 (CR4).
6057 Writes and returns a new value to CR4. This function is only available on
6058 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6060 @param Cr4 The value to write to CR4.
6062 @return The value written to CR4.
6073 Reads the current value of Debug Register 0 (DR0).
6075 Reads and returns the current value of DR0. This function is only available
6076 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6079 @return The value of Debug Register 0 (DR0).
6090 Reads the current value of Debug Register 1 (DR1).
6092 Reads and returns the current value of DR1. This function is only available
6093 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6096 @return The value of Debug Register 1 (DR1).
6107 Reads the current value of Debug Register 2 (DR2).
6109 Reads and returns the current value of DR2. This function is only available
6110 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6113 @return The value of Debug Register 2 (DR2).
6124 Reads the current value of Debug Register 3 (DR3).
6126 Reads and returns the current value of DR3. This function is only available
6127 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6130 @return The value of Debug Register 3 (DR3).
6141 Reads the current value of Debug Register 4 (DR4).
6143 Reads and returns the current value of DR4. This function is only available
6144 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6147 @return The value of Debug Register 4 (DR4).
6158 Reads the current value of Debug Register 5 (DR5).
6160 Reads and returns the current value of DR5. This function is only available
6161 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6164 @return The value of Debug Register 5 (DR5).
6175 Reads the current value of Debug Register 6 (DR6).
6177 Reads and returns the current value of DR6. This function is only available
6178 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6181 @return The value of Debug Register 6 (DR6).
6192 Reads the current value of Debug Register 7 (DR7).
6194 Reads and returns the current value of DR7. This function is only available
6195 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6198 @return The value of Debug Register 7 (DR7).
6209 Writes a value to Debug Register 0 (DR0).
6211 Writes and returns a new value to DR0. This function is only available on
6212 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6214 @param Dr0 The value to write to Dr0.
6216 @return The value written to Debug Register 0 (DR0).
6227 Writes a value to Debug Register 1 (DR1).
6229 Writes and returns a new value to DR1. This function is only available on
6230 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6232 @param Dr1 The value to write to Dr1.
6234 @return The value written to Debug Register 1 (DR1).
6245 Writes a value to Debug Register 2 (DR2).
6247 Writes and returns a new value to DR2. This function is only available on
6248 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6250 @param Dr2 The value to write to Dr2.
6252 @return The value written to Debug Register 2 (DR2).
6263 Writes a value to Debug Register 3 (DR3).
6265 Writes and returns a new value to DR3. This function is only available on
6266 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6268 @param Dr3 The value to write to Dr3.
6270 @return The value written to Debug Register 3 (DR3).
6281 Writes a value to Debug Register 4 (DR4).
6283 Writes and returns a new value to DR4. This function is only available on
6284 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6286 @param Dr4 The value to write to Dr4.
6288 @return The value written to Debug Register 4 (DR4).
6299 Writes a value to Debug Register 5 (DR5).
6301 Writes and returns a new value to DR5. This function is only available on
6302 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6304 @param Dr5 The value to write to Dr5.
6306 @return The value written to Debug Register 5 (DR5).
6317 Writes a value to Debug Register 6 (DR6).
6319 Writes and returns a new value to DR6. This function is only available on
6320 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6322 @param Dr6 The value to write to Dr6.
6324 @return The value written to Debug Register 6 (DR6).
6335 Writes a value to Debug Register 7 (DR7).
6337 Writes and returns a new value to DR7. This function is only available on
6338 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6340 @param Dr7 The value to write to Dr7.
6342 @return The value written to Debug Register 7 (DR7).
6353 Reads the current value of Code Segment Register (CS).
6355 Reads and returns the current value of CS. This function is only available on
6358 @return The current value of CS.
6369 Reads the current value of Data Segment Register (DS).
6371 Reads and returns the current value of DS. This function is only available on
6374 @return The current value of DS.
6385 Reads the current value of Extra Segment Register (ES).
6387 Reads and returns the current value of ES. This function is only available on
6390 @return The current value of ES.
6401 Reads the current value of FS Data Segment Register (FS).
6403 Reads and returns the current value of FS. This function is only available on
6406 @return The current value of FS.
6417 Reads the current value of GS Data Segment Register (GS).
6419 Reads and returns the current value of GS. This function is only available on
6422 @return The current value of GS.
6433 Reads the current value of Stack Segment Register (SS).
6435 Reads and returns the current value of SS. This function is only available on
6438 @return The current value of SS.
6449 Reads the current value of Task Register (TR).
6451 Reads and returns the current value of TR. This function is only available on
6454 @return The current value of TR.
6465 Reads the current Global Descriptor Table Register(GDTR) descriptor.
6467 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
6468 function is only available on IA-32 and X64.
6470 If Gdtr is NULL, then ASSERT().
6472 @param Gdtr Pointer to a GDTR descriptor.
6478 OUT IA32_DESCRIPTOR
*Gdtr
6483 Writes the current Global Descriptor Table Register (GDTR) descriptor.
6485 Writes and the current GDTR descriptor specified by Gdtr. This function is
6486 only available on IA-32 and X64.
6488 If Gdtr is NULL, then ASSERT().
6490 @param Gdtr Pointer to a GDTR descriptor.
6496 IN CONST IA32_DESCRIPTOR
*Gdtr
6501 Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.
6503 Reads and returns the current IDTR descriptor and returns it in Idtr. This
6504 function is only available on IA-32 and X64.
6506 If Idtr is NULL, then ASSERT().
6508 @param Idtr Pointer to a IDTR descriptor.
6514 OUT IA32_DESCRIPTOR
*Idtr
6519 Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.
6521 Writes the current IDTR descriptor and returns it in Idtr. This function is
6522 only available on IA-32 and X64.
6524 If Idtr is NULL, then ASSERT().
6526 @param Idtr Pointer to a IDTR descriptor.
6532 IN CONST IA32_DESCRIPTOR
*Idtr
6537 Reads the current Local Descriptor Table Register(LDTR) selector.
6539 Reads and returns the current 16-bit LDTR descriptor value. This function is
6540 only available on IA-32 and X64.
6542 @return The current selector of LDT.
6553 Writes the current Local Descriptor Table Register (LDTR) selector.
6555 Writes and the current LDTR descriptor specified by Ldtr. This function is
6556 only available on IA-32 and X64.
6558 @param Ldtr 16-bit LDTR selector value.
6569 Save the current floating point/SSE/SSE2 context to a buffer.
6571 Saves the current floating point/SSE/SSE2 state to the buffer specified by
6572 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
6573 available on IA-32 and X64.
6575 If Buffer is NULL, then ASSERT().
6576 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6578 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
6584 OUT IA32_FX_BUFFER
*Buffer
6589 Restores the current floating point/SSE/SSE2 context from a buffer.
6591 Restores the current floating point/SSE/SSE2 state from the buffer specified
6592 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
6593 only available on IA-32 and X64.
6595 If Buffer is NULL, then ASSERT().
6596 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6597 If Buffer was not saved with AsmFxSave(), then ASSERT().
6599 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
6605 IN CONST IA32_FX_BUFFER
*Buffer
6610 Reads the current value of 64-bit MMX Register #0 (MM0).
6612 Reads and returns the current value of MM0. This function is only available
6615 @return The current value of MM0.
6626 Reads the current value of 64-bit MMX Register #1 (MM1).
6628 Reads and returns the current value of MM1. This function is only available
6631 @return The current value of MM1.
6642 Reads the current value of 64-bit MMX Register #2 (MM2).
6644 Reads and returns the current value of MM2. This function is only available
6647 @return The current value of MM2.
6658 Reads the current value of 64-bit MMX Register #3 (MM3).
6660 Reads and returns the current value of MM3. This function is only available
6663 @return The current value of MM3.
6674 Reads the current value of 64-bit MMX Register #4 (MM4).
6676 Reads and returns the current value of MM4. This function is only available
6679 @return The current value of MM4.
6690 Reads the current value of 64-bit MMX Register #5 (MM5).
6692 Reads and returns the current value of MM5. This function is only available
6695 @return The current value of MM5.
6706 Reads the current value of 64-bit MMX Register #6 (MM6).
6708 Reads and returns the current value of MM6. This function is only available
6711 @return The current value of MM6.
6722 Reads the current value of 64-bit MMX Register #7 (MM7).
6724 Reads and returns the current value of MM7. This function is only available
6727 @return The current value of MM7.
6738 Writes the current value of 64-bit MMX Register #0 (MM0).
6740 Writes the current value of MM0. This function is only available on IA32 and
6743 @param Value The 64-bit value to write to MM0.
6754 Writes the current value of 64-bit MMX Register #1 (MM1).
6756 Writes the current value of MM1. This function is only available on IA32 and
6759 @param Value The 64-bit value to write to MM1.
6770 Writes the current value of 64-bit MMX Register #2 (MM2).
6772 Writes the current value of MM2. This function is only available on IA32 and
6775 @param Value The 64-bit value to write to MM2.
6786 Writes the current value of 64-bit MMX Register #3 (MM3).
6788 Writes the current value of MM3. This function is only available on IA32 and
6791 @param Value The 64-bit value to write to MM3.
6802 Writes the current value of 64-bit MMX Register #4 (MM4).
6804 Writes the current value of MM4. This function is only available on IA32 and
6807 @param Value The 64-bit value to write to MM4.
6818 Writes the current value of 64-bit MMX Register #5 (MM5).
6820 Writes the current value of MM5. This function is only available on IA32 and
6823 @param Value The 64-bit value to write to MM5.
6834 Writes the current value of 64-bit MMX Register #6 (MM6).
6836 Writes the current value of MM6. This function is only available on IA32 and
6839 @param Value The 64-bit value to write to MM6.
6850 Writes the current value of 64-bit MMX Register #7 (MM7).
6852 Writes the current value of MM7. This function is only available on IA32 and
6855 @param Value The 64-bit value to write to MM7.
6866 Reads the current value of Time Stamp Counter (TSC).
6868 Reads and returns the current value of TSC. This function is only available
6871 @return The current value of TSC
6882 Reads the current value of a Performance Counter (PMC).
6884 Reads and returns the current value of performance counter specified by
6885 Index. This function is only available on IA-32 and X64.
6887 @param Index The 32-bit Performance Counter index to read.
6889 @return The value of the PMC specified by Index.
6900 Sets up a monitor buffer that is used by AsmMwait().
6902 Executes a MONITOR instruction with the register state specified by Eax, Ecx
6903 and Edx. Returns Eax. This function is only available on IA-32 and X64.
6905 @param Eax The value to load into EAX or RAX before executing the MONITOR
6907 @param Ecx The value to load into ECX or RCX before executing the MONITOR
6909 @param Edx The value to load into EDX or RDX before executing the MONITOR
6925 Executes an MWAIT instruction.
6927 Executes an MWAIT instruction with the register state specified by Eax and
6928 Ecx. Returns Eax. This function is only available on IA-32 and X64.
6930 @param Eax The value to load into EAX or RAX before executing the MONITOR
6932 @param Ecx The value to load into ECX or RCX before executing the MONITOR
6947 Executes a WBINVD instruction.
6949 Executes a WBINVD instruction. This function is only available on IA-32 and
6961 Executes a INVD instruction.
6963 Executes a INVD instruction. This function is only available on IA-32 and
6975 Flushes a cache line from all the instruction and data caches within the
6976 coherency domain of the CPU.
6978 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
6979 This function is only available on IA-32 and X64.
6981 @param LinearAddress The address of the cache line to flush. If the CPU is
6982 in a physical addressing mode, then LinearAddress is a
6983 physical address. If the CPU is in a virtual
6984 addressing mode, then LinearAddress is a virtual
6987 @return LinearAddress
6992 IN VOID
*LinearAddress
6997 Enables the 32-bit paging mode on the CPU.
6999 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
7000 must be properly initialized prior to calling this service. This function
7001 assumes the current execution mode is 32-bit protected mode. This function is
7002 only available on IA-32. After the 32-bit paging mode is enabled, control is
7003 transferred to the function specified by EntryPoint using the new stack
7004 specified by NewStack and passing in the parameters specified by Context1 and
7005 Context2. Context1 and Context2 are optional and may be NULL. The function
7006 EntryPoint must never return.
7008 If the current execution mode is not 32-bit protected mode, then ASSERT().
7009 If EntryPoint is NULL, then ASSERT().
7010 If NewStack is NULL, then ASSERT().
7012 There are a number of constraints that must be followed before calling this
7014 1) Interrupts must be disabled.
7015 2) The caller must be in 32-bit protected mode with flat descriptors. This
7016 means all descriptors must have a base of 0 and a limit of 4GB.
7017 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
7019 4) CR3 must point to valid page tables that will be used once the transition
7020 is complete, and those page tables must guarantee that the pages for this
7021 function and the stack are identity mapped.
7023 @param EntryPoint A pointer to function to call with the new stack after
7025 @param Context1 A pointer to the context to pass into the EntryPoint
7026 function as the first parameter after paging is enabled.
7027 @param Context2 A pointer to the context to pass into the EntryPoint
7028 function as the second parameter after paging is enabled.
7029 @param NewStack A pointer to the new stack to use for the EntryPoint
7030 function after paging is enabled.
7036 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
7037 IN VOID
*Context1
, OPTIONAL
7038 IN VOID
*Context2
, OPTIONAL
7044 Disables the 32-bit paging mode on the CPU.
7046 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
7047 mode. This function assumes the current execution mode is 32-paged protected
7048 mode. This function is only available on IA-32. After the 32-bit paging mode
7049 is disabled, control is transferred to the function specified by EntryPoint
7050 using the new stack specified by NewStack and passing in the parameters
7051 specified by Context1 and Context2. Context1 and Context2 are optional and
7052 may be NULL. The function EntryPoint must never return.
7054 If the current execution mode is not 32-bit paged mode, then ASSERT().
7055 If EntryPoint is NULL, then ASSERT().
7056 If NewStack is NULL, then ASSERT().
7058 There are a number of constraints that must be followed before calling this
7060 1) Interrupts must be disabled.
7061 2) The caller must be in 32-bit paged mode.
7062 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
7063 4) CR3 must point to valid page tables that guarantee that the pages for
7064 this function and the stack are identity mapped.
7066 @param EntryPoint A pointer to function to call with the new stack after
7068 @param Context1 A pointer to the context to pass into the EntryPoint
7069 function as the first parameter after paging is disabled.
7070 @param Context2 A pointer to the context to pass into the EntryPoint
7071 function as the second parameter after paging is
7073 @param NewStack A pointer to the new stack to use for the EntryPoint
7074 function after paging is disabled.
7079 AsmDisablePaging32 (
7080 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
7081 IN VOID
*Context1
, OPTIONAL
7082 IN VOID
*Context2
, OPTIONAL
7088 Enables the 64-bit paging mode on the CPU.
7090 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
7091 must be properly initialized prior to calling this service. This function
7092 assumes the current execution mode is 32-bit protected mode with flat
7093 descriptors. This function is only available on IA-32. After the 64-bit
7094 paging mode is enabled, control is transferred to the function specified by
7095 EntryPoint using the new stack specified by NewStack and passing in the
7096 parameters specified by Context1 and Context2. Context1 and Context2 are
7097 optional and may be 0. The function EntryPoint must never return.
7099 If the current execution mode is not 32-bit protected mode with flat
7100 descriptors, then ASSERT().
7101 If EntryPoint is 0, then ASSERT().
7102 If NewStack is 0, then ASSERT().
7104 @param Cs The 16-bit selector to load in the CS before EntryPoint
7105 is called. The descriptor in the GDT that this selector
7106 references must be setup for long mode.
7107 @param EntryPoint The 64-bit virtual address of the function to call with
7108 the new stack after paging is enabled.
7109 @param Context1 The 64-bit virtual address of the context to pass into
7110 the EntryPoint function as the first parameter after
7112 @param Context2 The 64-bit virtual address of the context to pass into
7113 the EntryPoint function as the second parameter after
7115 @param NewStack The 64-bit virtual address of the new stack to use for
7116 the EntryPoint function after paging is enabled.
7123 IN UINT64 EntryPoint
,
7124 IN UINT64 Context1
, OPTIONAL
7125 IN UINT64 Context2
, OPTIONAL
7131 Disables the 64-bit paging mode on the CPU.
7133 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
7134 mode. This function assumes the current execution mode is 64-paging mode.
7135 This function is only available on X64. After the 64-bit paging mode is
7136 disabled, control is transferred to the function specified by EntryPoint
7137 using the new stack specified by NewStack and passing in the parameters
7138 specified by Context1 and Context2. Context1 and Context2 are optional and
7139 may be 0. The function EntryPoint must never return.
7141 If the current execution mode is not 64-bit paged mode, then ASSERT().
7142 If EntryPoint is 0, then ASSERT().
7143 If NewStack is 0, then ASSERT().
7145 @param Cs The 16-bit selector to load in the CS before EntryPoint
7146 is called. The descriptor in the GDT that this selector
7147 references must be setup for 32-bit protected mode.
7148 @param EntryPoint The 64-bit virtual address of the function to call with
7149 the new stack after paging is disabled.
7150 @param Context1 The 64-bit virtual address of the context to pass into
7151 the EntryPoint function as the first parameter after
7153 @param Context2 The 64-bit virtual address of the context to pass into
7154 the EntryPoint function as the second parameter after
7156 @param NewStack The 64-bit virtual address of the new stack to use for
7157 the EntryPoint function after paging is disabled.
7162 AsmDisablePaging64 (
7164 IN UINT32 EntryPoint
,
7165 IN UINT32 Context1
, OPTIONAL
7166 IN UINT32 Context2
, OPTIONAL
7172 // 16-bit thunking services
7176 Retrieves the properties for 16-bit thunk functions.
7178 Computes the size of the buffer and stack below 1MB required to use the
7179 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
7180 buffer size is returned in RealModeBufferSize, and the stack size is returned
7181 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
7182 then the actual minimum stack size is ExtraStackSize plus the maximum number
7183 of bytes that need to be passed to the 16-bit real mode code.
7185 If RealModeBufferSize is NULL, then ASSERT().
7186 If ExtraStackSize is NULL, then ASSERT().
7188 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
7189 required to use the 16-bit thunk functions.
7190 @param ExtraStackSize A pointer to the extra size of stack below 1MB
7191 that the 16-bit thunk functions require for
7192 temporary storage in the transition to and from
7198 AsmGetThunk16Properties (
7199 OUT UINT32
*RealModeBufferSize
,
7200 OUT UINT32
*ExtraStackSize
7205 Prepares all structures a code required to use AsmThunk16().
7207 Prepares all structures and code required to use AsmThunk16().
7209 If ThunkContext is NULL, then ASSERT().
7211 @param ThunkContext A pointer to the context structure that describes the
7212 16-bit real mode code to call.
7218 OUT THUNK_CONTEXT
*ThunkContext
7223 Transfers control to a 16-bit real mode entry point and returns the results.
7225 Transfers control to a 16-bit real mode entry point and returns the results.
7226 AsmPrepareThunk16() must be called with ThunkContext before this function is used.
7227 This function must be called with interrupts disabled.
7229 The register state from the RealModeState field of ThunkContext is restored just prior
7230 to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState,
7231 which is used to set the interrupt state when a 16-bit real mode entry point is called.
7232 Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.
7233 The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to
7234 the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function.
7235 The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,
7236 so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment
7237 and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry
7238 point must exit with a RETF instruction. The register state is captured into RealModeState immediately
7239 after the RETF instruction is executed.
7241 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7242 or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure
7243 the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode.
7245 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7246 then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode.
7247 This includes the base vectors, the interrupt masks, and the edge/level trigger mode.
7249 If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code
7250 is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.
7252 If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7253 ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to
7254 disable the A20 mask.
7256 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in
7257 ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails,
7258 then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7260 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in
7261 ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7263 If ThunkContext is NULL, then ASSERT().
7264 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
7265 If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7266 ThunkAttributes, then ASSERT().
7268 @param ThunkContext A pointer to the context structure that describes the
7269 16-bit real mode code to call.
7275 IN OUT THUNK_CONTEXT
*ThunkContext
7280 Prepares all structures and code for a 16-bit real mode thunk, transfers
7281 control to a 16-bit real mode entry point, and returns the results.
7283 Prepares all structures and code for a 16-bit real mode thunk, transfers
7284 control to a 16-bit real mode entry point, and returns the results. If the
7285 caller only need to perform a single 16-bit real mode thunk, then this
7286 service should be used. If the caller intends to make more than one 16-bit
7287 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
7288 once and AsmThunk16() can be called for each 16-bit real mode thunk.
7290 See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.
7292 @param ThunkContext A pointer to the context structure that describes the
7293 16-bit real mode code to call.
7298 AsmPrepareAndThunk16 (
7299 IN OUT THUNK_CONTEXT
*ThunkContext