2 Memory-only library functions with no library constructor/destructor
4 Copyright (c) 2006 - 2007, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 // Definitions for architecture specific types
20 // These include SPIN_LOCK and BASE_LIBRARY_JUMP_BUFFER
26 typedef volatile UINTN SPIN_LOCK
;
28 #if defined (MDE_CPU_IA32)
30 /// IA32 context buffer used by SetJump() and LongJump()
39 } BASE_LIBRARY_JUMP_BUFFER
;
41 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4
43 #elif defined (MDE_CPU_IPF)
46 /// IPF context buffer used by SetJump() and LongJump()
81 UINT64 AfterSpillUNAT
;
87 } BASE_LIBRARY_JUMP_BUFFER
;
89 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 0x10
91 #elif defined (MDE_CPU_X64)
93 /// X64 context buffer used by SetJump() and LongJump()
106 } BASE_LIBRARY_JUMP_BUFFER
;
108 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
110 #elif defined (MDE_CPU_EBC)
112 /// EBC context buffer used by SetJump() and LongJump()
120 } BASE_LIBRARY_JUMP_BUFFER
;
122 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
125 #error Unknown Processor Type
133 Copies one Null-terminated Unicode string to another Null-terminated Unicode
134 string and returns the new Unicode string.
136 This function copies the contents of the Unicode string Source to the Unicode
137 string Destination, and returns Destination. If Source and Destination
138 overlap, then the results are undefined.
140 If Destination is NULL, then ASSERT().
141 If Destination is not aligned on a 16-bit boundary, then ASSERT().
142 If Source is NULL, then ASSERT().
143 If Source is not aligned on a 16-bit boundary, then ASSERT().
144 If Source and Destination overlap, then ASSERT().
145 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
146 PcdMaximumUnicodeStringLength Unicode characters not including the
147 Null-terminator, then ASSERT().
149 @param Destination Pointer to a Null-terminated Unicode string.
150 @param Source Pointer to a Null-terminated Unicode string.
158 OUT CHAR16
*Destination
,
159 IN CONST CHAR16
*Source
164 Copies one Null-terminated Unicode string with a maximum length to another
165 Null-terminated Unicode string with a maximum length and returns the new
168 This function copies the contents of the Unicode string Source to the Unicode
169 string Destination, and returns Destination. At most, Length Unicode
170 characters are copied from Source to Destination. If Length is 0, then
171 Destination is returned unmodified. If Length is greater that the number of
172 Unicode characters in Source, then Destination is padded with Null Unicode
173 characters. If Source and Destination overlap, then the results are
176 If Length > 0 and Destination is NULL, then ASSERT().
177 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
178 If Length > 0 and Source is NULL, then ASSERT().
179 If Length > 0 and Source is not aligned on a 16-bit bounadry, then ASSERT().
180 If Source and Destination overlap, then ASSERT().
181 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
182 PcdMaximumUnicodeStringLength Unicode characters not including the
183 Null-terminator, then ASSERT().
185 @param Destination Pointer to a Null-terminated Unicode string.
186 @param Source Pointer to a Null-terminated Unicode string.
187 @param Length Maximum number of Unicode characters to copy.
195 OUT CHAR16
*Destination
,
196 IN CONST CHAR16
*Source
,
202 Returns the length of a Null-terminated Unicode string.
204 This function returns the number of Unicode characters in the Null-terminated
205 Unicode string specified by String.
207 If String is NULL, then ASSERT().
208 If String is not aligned on a 16-bit boundary, then ASSERT().
209 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
210 PcdMaximumUnicodeStringLength Unicode characters not including the
211 Null-terminator, then ASSERT().
213 @param String Pointer to a Null-terminated Unicode string.
215 @return The length of String.
221 IN CONST CHAR16
*String
226 Returns the size of a Null-terminated Unicode string in bytes, including the
229 This function returns the size, in bytes, of the Null-terminated Unicode
230 string specified by String.
232 If String is NULL, then ASSERT().
233 If String is not aligned on a 16-bit boundary, then ASSERT().
234 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
235 PcdMaximumUnicodeStringLength Unicode characters not including the
236 Null-terminator, then ASSERT().
238 @param String Pointer to a Null-terminated Unicode string.
240 @return The size of String.
246 IN CONST CHAR16
*String
251 Compares two Null-terminated Unicode strings, and returns the difference
252 between the first mismatched Unicode characters.
254 This function compares the Null-terminated Unicode string FirstString to the
255 Null-terminated Unicode string SecondString. If FirstString is identical to
256 SecondString, then 0 is returned. Otherwise, the value returned is the first
257 mismatched Unicode character in SecondString subtracted from the first
258 mismatched Unicode character in FirstString.
260 If FirstString is NULL, then ASSERT().
261 If FirstString is not aligned on a 16-bit boundary, then ASSERT().
262 If SecondString is NULL, then ASSERT().
263 If SecondString is not aligned on a 16-bit boundary, then ASSERT().
264 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
265 than PcdMaximumUnicodeStringLength Unicode characters not including the
266 Null-terminator, then ASSERT().
267 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
268 than PcdMaximumUnicodeStringLength Unicode characters not including the
269 Null-terminator, then ASSERT().
271 @param FirstString Pointer to a Null-terminated Unicode string.
272 @param SecondString Pointer to a Null-terminated Unicode string.
274 @retval 0 FirstString is identical to SecondString.
275 @retval !=0 FirstString is not identical to SecondString.
281 IN CONST CHAR16
*FirstString
,
282 IN CONST CHAR16
*SecondString
287 Compares two Null-terminated Unicode strings with maximum lengths, and
288 returns the difference between the first mismatched Unicode characters.
290 This function compares the Null-terminated Unicode string FirstString to the
291 Null-terminated Unicode string SecondString. At most, Length Unicode
292 characters will be compared. If Length is 0, then 0 is returned. If
293 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
294 value returned is the first mismatched Unicode character in SecondString
295 subtracted from the first mismatched Unicode character in FirstString.
297 If Length > 0 and FirstString is NULL, then ASSERT().
298 If Length > 0 and FirstString is not aligned on a 16-bit bounadary, then ASSERT().
299 If Length > 0 and SecondString is NULL, then ASSERT().
300 If Length > 0 and SecondString is not aligned on a 16-bit bounadary, then ASSERT().
301 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
302 than PcdMaximumUnicodeStringLength Unicode characters not including the
303 Null-terminator, then ASSERT().
304 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
305 than PcdMaximumUnicodeStringLength Unicode characters not including the
306 Null-terminator, then ASSERT().
308 @param FirstString Pointer to a Null-terminated Unicode string.
309 @param SecondString Pointer to a Null-terminated Unicode string.
310 @param Length Maximum number of Unicode characters to compare.
312 @retval 0 FirstString is identical to SecondString.
313 @retval !=0 FirstString is not identical to SecondString.
319 IN CONST CHAR16
*FirstString
,
320 IN CONST CHAR16
*SecondString
,
326 Concatenates one Null-terminated Unicode string to another Null-terminated
327 Unicode string, and returns the concatenated Unicode string.
329 This function concatenates two Null-terminated Unicode strings. The contents
330 of Null-terminated Unicode string Source are concatenated to the end of
331 Null-terminated Unicode string Destination. The Null-terminated concatenated
332 Unicode String is returned. If Source and Destination overlap, then the
333 results are undefined.
335 If Destination is NULL, then ASSERT().
336 If Destination is not aligned on a 16-bit bounadary, then ASSERT().
337 If Source is NULL, then ASSERT().
338 If Source is not aligned on a 16-bit bounadary, then ASSERT().
339 If Source and Destination overlap, then ASSERT().
340 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
341 than PcdMaximumUnicodeStringLength Unicode characters not including the
342 Null-terminator, then ASSERT().
343 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
344 PcdMaximumUnicodeStringLength Unicode characters not including the
345 Null-terminator, then ASSERT().
346 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
347 and Source results in a Unicode string with more than
348 PcdMaximumUnicodeStringLength Unicode characters not including the
349 Null-terminator, then ASSERT().
351 @param Destination Pointer to a Null-terminated Unicode string.
352 @param Source Pointer to a Null-terminated Unicode string.
360 IN OUT CHAR16
*Destination
,
361 IN CONST CHAR16
*Source
366 Concatenates one Null-terminated Unicode string with a maximum length to the
367 end of another Null-terminated Unicode string, and returns the concatenated
370 This function concatenates two Null-terminated Unicode strings. The contents
371 of Null-terminated Unicode string Source are concatenated to the end of
372 Null-terminated Unicode string Destination, and Destination is returned. At
373 most, Length Unicode characters are concatenated from Source to the end of
374 Destination, and Destination is always Null-terminated. If Length is 0, then
375 Destination is returned unmodified. If Source and Destination overlap, then
376 the results are undefined.
378 If Destination is NULL, then ASSERT().
379 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
380 If Length > 0 and Source is NULL, then ASSERT().
381 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
382 If Source and Destination overlap, then ASSERT().
383 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
384 than PcdMaximumUnicodeStringLength Unicode characters not including the
385 Null-terminator, then ASSERT().
386 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
387 PcdMaximumUnicodeStringLength Unicode characters not including the
388 Null-terminator, then ASSERT().
389 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
390 and Source results in a Unicode string with more than
391 PcdMaximumUnicodeStringLength Unicode characters not including the
392 Null-terminator, then ASSERT().
394 @param Destination Pointer to a Null-terminated Unicode string.
395 @param Source Pointer to a Null-terminated Unicode string.
396 @param Length Maximum number of Unicode characters to concatenate from
405 IN OUT CHAR16
*Destination
,
406 IN CONST CHAR16
*Source
,
411 Returns the first occurance of a Null-terminated Unicode sub-string
412 in a Null-terminated Unicode string.
414 This function scans the contents of the Null-terminated Unicode string
415 specified by String and returns the first occurrence of SearchString.
416 If SearchString is not found in String, then NULL is returned. If
417 the length of SearchString is zero, then String is
420 If String is NULL, then ASSERT().
421 If String is not aligned on a 16-bit boundary, then ASSERT().
422 If SearchString is NULL, then ASSERT().
423 If SearchString is not aligned on a 16-bit boundary, then ASSERT().
425 If PcdMaximumUnicodeStringLength is not zero, and SearchString
426 or String contains more than PcdMaximumUnicodeStringLength Unicode
427 characters not including the Null-terminator, then ASSERT().
429 @param String Pointer to a Null-terminated Unicode string.
430 @param SearchString Pointer to a Null-terminated Unicode string to search for.
432 @retval NULL If the SearchString does not appear in String.
433 @retval !NULL If there is a match.
439 IN CONST CHAR16
*String
,
440 IN CONST CHAR16
*SearchString
444 Convert a Null-terminated Unicode decimal string to a value of
447 This function returns a value of type UINTN by interpreting the contents
448 of the Unicode string specified by String as a decimal number. The format
449 of the input Unicode string String is:
451 [spaces] [decimal digits].
453 The valid decimal digit character is in the range [0-9]. The
454 function will ignore the pad space, which includes spaces or
455 tab characters, before [decimal digits]. The running zero in the
456 beginning of [decimal digits] will be ignored. Then, the function
457 stops at the first character that is a not a valid decimal character
458 or a Null-terminator, whichever one comes first.
460 If String is NULL, then ASSERT().
461 If String is not aligned in a 16-bit boundary, then ASSERT().
462 If String has only pad spaces, then 0 is returned.
463 If String has no pad spaces or valid decimal digits,
465 If the number represented by String overflows according
466 to the range defined by UINTN, then ASSERT().
468 If PcdMaximumUnicodeStringLength is not zero, and String contains
469 more than PcdMaximumUnicodeStringLength Unicode characters not including
470 the Null-terminator, then ASSERT().
472 @param String Pointer to a Null-terminated Unicode string.
474 @retval Value translated from String.
480 IN CONST CHAR16
*String
484 Convert a Null-terminated Unicode decimal string to a value of
487 This function returns a value of type UINT64 by interpreting the contents
488 of the Unicode string specified by String as a decimal number. The format
489 of the input Unicode string String is:
491 [spaces] [decimal digits].
493 The valid decimal digit character is in the range [0-9]. The
494 function will ignore the pad space, which includes spaces or
495 tab characters, before [decimal digits]. The running zero in the
496 beginning of [decimal digits] will be ignored. Then, the function
497 stops at the first character that is a not a valid decimal character
498 or a Null-terminator, whichever one comes first.
500 If String is NULL, then ASSERT().
501 If String is not aligned in a 16-bit boundary, then ASSERT().
502 If String has only pad spaces, then 0 is returned.
503 If String has no pad spaces or valid decimal digits,
505 If the number represented by String overflows according
506 to the range defined by UINT64, then ASSERT().
508 If PcdMaximumUnicodeStringLength is not zero, and String contains
509 more than PcdMaximumUnicodeStringLength Unicode characters not including
510 the Null-terminator, then ASSERT().
512 @param String Pointer to a Null-terminated Unicode string.
514 @retval Value translated from String.
520 IN CONST CHAR16
*String
525 Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.
527 This function returns a value of type UINTN by interpreting the contents
528 of the Unicode string specified by String as a hexadecimal number.
529 The format of the input Unicode string String is:
531 [spaces][zeros][x][hexadecimal digits].
533 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
534 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
535 If "x" appears in the input string, it must be prefixed with at least one 0.
536 The function will ignore the pad space, which includes spaces or tab characters,
537 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
538 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
539 first valid hexadecimal digit. Then, the function stops at the first character that is
540 a not a valid hexadecimal character or NULL, whichever one comes first.
542 If String is NULL, then ASSERT().
543 If String is not aligned in a 16-bit boundary, then ASSERT().
544 If String has only pad spaces, then zero is returned.
545 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
546 then zero is returned.
547 If the number represented by String overflows according to the range defined by
548 UINTN, then ASSERT().
550 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
551 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
554 @param String Pointer to a Null-terminated Unicode string.
556 @retval Value translated from String.
562 IN CONST CHAR16
*String
567 Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.
569 This function returns a value of type UINT64 by interpreting the contents
570 of the Unicode string specified by String as a hexadecimal number.
571 The format of the input Unicode string String is
573 [spaces][zeros][x][hexadecimal digits].
575 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
576 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
577 If "x" appears in the input string, it must be prefixed with at least one 0.
578 The function will ignore the pad space, which includes spaces or tab characters,
579 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
580 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
581 first valid hexadecimal digit. Then, the function stops at the first character that is
582 a not a valid hexadecimal character or NULL, whichever one comes first.
584 If String is NULL, then ASSERT().
585 If String is not aligned in a 16-bit boundary, then ASSERT().
586 If String has only pad spaces, then zero is returned.
587 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
588 then zero is returned.
589 If the number represented by String overflows according to the range defined by
590 UINT64, then ASSERT().
592 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
593 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
596 @param String Pointer to a Null-terminated Unicode string.
598 @retval Value translated from String.
604 IN CONST CHAR16
*String
608 Convert a nibble in the low 4 bits of a byte to a Unicode hexadecimal character.
610 This function converts a nibble in the low 4 bits of a byte to a Unicode hexadecimal
611 character For example, the nibble 0x01 and 0x0A will converted to L'1' and L'A'
614 The upper nibble in the input byte will be masked off.
616 @param Nibble The nibble which is in the low 4 bits of the input byte.
618 @retval CHAR16 The Unicode hexadecimal character.
628 Convert binary buffer to a Unicode String in a specified sequence.
630 This function converts bytes in the binary Buffer Buf to a Unicode String Str.
631 Each byte will be represented by two Unicode characters. For example, byte 0xA1 will
632 be converted into two Unicode character L'A' and L'1'. In the output String, the Unicode Character
633 for the Most Significant Nibble will be put before the Unicode Character for the Least Significant
634 Nibble. The output string for the buffer containing a single byte 0xA1 will be L"A1".
635 For a buffer with multiple bytes, the Unicode character produced by the first byte will be put into the
636 the last character in the output string. The one next to first byte will be put into the
637 character before the last character. This rules applies to the rest of the bytes. The Unicode
638 character by the last byte will be put into the first character in the output string. For example,
639 the input buffer for a 64-bits unsigned integrer 0x12345678abcdef1234 will be converted to
640 a Unicode string equal to L"12345678abcdef1234".
642 @param String On input, String is pointed to the buffer allocated for the convertion.
643 @param StringLen The Length of String buffer to hold the output String. The length must include the tailing '\0' character.
644 The StringLen required to convert a N bytes Buffer will be a least equal to or greater
646 @param Buffer The pointer to a input buffer.
647 @param BufferSizeInBytes Lenth in bytes of the input buffer.
650 @retval EFI_SUCCESS The convertion is successfull. All bytes in Buffer has been convert to the corresponding
651 Unicode character and placed into the right place in String.
652 @retval EFI_BUFFER_TOO_SMALL StringSizeInBytes is smaller than 2 * N + 1the number of bytes required to
653 complete the convertion.
658 IN OUT CHAR16
*String
,
659 IN OUT UINTN
*StringLen
,
660 IN CONST UINT8
*Buffer
,
661 IN UINTN BufferSizeInBytes
666 Convert a Unicode string consisting of hexadecimal characters to a output byte buffer.
668 This function converts a Unicode string consisting of characters in the range of Hexadecimal
669 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
670 at the first non-hexadecimal character or the NULL character. The convertion process can be
671 simply viewed as the reverse operations defined by BufToHexString. Two Unicode characters will be
672 converted into one byte. The first Unicode character represents the Most Significant Nibble and the
673 second Unicode character represents the Least Significant Nibble in the output byte.
674 The first pair of Unicode characters represents the last byte in the output buffer. The second pair of Unicode
675 characters represent the the byte preceding the last byte. This rule applies to the rest pairs of bytes.
676 The last pair represent the first byte in the output buffer.
678 For example, a Unciode String L"12345678" will be converted into a buffer wil the following bytes
679 (first byte is the byte in the lowest memory address): "0x78, 0x56, 0x34, 0x12".
681 If String has N valid hexadecimal characters for conversion, the caller must make sure Buffer is at least
682 N/2 (if N is even) or (N+1)/2 (if N if odd) bytes.
684 @param Buffer The output buffer allocated by the caller.
685 @param BufferSizeInBytes On input, the size in bytes of Buffer. On output, it is updated to
686 contain the size of the Buffer which is actually used for the converstion.
687 For Unicode string with 2*N hexadecimal characters (not including the
688 tailing NULL character), N bytes of Buffer will be used for the output.
689 @param String The input hexadecimal string.
690 @param ConvertedStrLen The number of hexadecimal characters used to produce content in output
693 @retval RETURN_BUFFER_TOO_SMALL The input BufferSizeInBytes is too small to hold the output. BufferSizeInBytes
694 will be updated to the size required for the converstion.
695 @retval RETURN_SUCCESS The convertion is successful or the first Unicode character from String
696 is hexadecimal. If ConvertedStrLen is not NULL, it is updated
697 to the number of hexadecimal character used for the converstion.
703 IN OUT UINTN
*BufferSizeInBytes
,
704 IN CONST CHAR16
*String
,
705 OUT UINTN
*ConvertedStrLen OPTIONAL
710 Test if a Unicode character is a hexadecimal digit. If true, the input
711 Unicode character is converted to a byte.
713 This function tests if a Unicode character is a hexadecimal digit. If true, the input
714 Unicode character is converted to a byte. For example, Unicode character
715 L'A' will be converted to 0x0A.
717 If Digit is NULL, then ASSERT.
719 @retval TRUE Char is in the range of Hexadecimal number. Digit is updated
720 to the byte value of the number.
721 @retval FALSE Char is not in the range of Hexadecimal number. Digit is keep
733 Convert one Null-terminated Unicode string to a Null-terminated
734 ASCII string and returns the ASCII string.
736 This function converts the content of the Unicode string Source
737 to the ASCII string Destination by copying the lower 8 bits of
738 each Unicode character. It returns Destination.
740 If any Unicode characters in Source contain non-zero value in
741 the upper 8 bits, then ASSERT().
743 If Destination is NULL, then ASSERT().
744 If Source is NULL, then ASSERT().
745 If Source is not aligned on a 16-bit boundary, then ASSERT().
746 If Source and Destination overlap, then ASSERT().
748 If PcdMaximumUnicodeStringLength is not zero, and Source contains
749 more than PcdMaximumUnicodeStringLength Unicode characters not including
750 the Null-terminator, then ASSERT().
752 If PcdMaximumAsciiStringLength is not zero, and Source contains more
753 than PcdMaximumAsciiStringLength Unicode characters not including the
754 Null-terminator, then ASSERT().
756 @param Source Pointer to a Null-terminated Unicode string.
757 @param Destination Pointer to a Null-terminated ASCII string.
764 UnicodeStrToAsciiStr (
765 IN CONST CHAR16
*Source
,
766 OUT CHAR8
*Destination
771 Copies one Null-terminated ASCII string to another Null-terminated ASCII
772 string and returns the new ASCII string.
774 This function copies the contents of the ASCII string Source to the ASCII
775 string Destination, and returns Destination. If Source and Destination
776 overlap, then the results are undefined.
778 If Destination is NULL, then ASSERT().
779 If Source is NULL, then ASSERT().
780 If Source and Destination overlap, then ASSERT().
781 If PcdMaximumAsciiStringLength is not zero and Source contains more than
782 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
785 @param Destination Pointer to a Null-terminated ASCII string.
786 @param Source Pointer to a Null-terminated ASCII string.
794 OUT CHAR8
*Destination
,
795 IN CONST CHAR8
*Source
800 Copies one Null-terminated ASCII string with a maximum length to another
801 Null-terminated ASCII string with a maximum length and returns the new ASCII
804 This function copies the contents of the ASCII string Source to the ASCII
805 string Destination, and returns Destination. At most, Length ASCII characters
806 are copied from Source to Destination. If Length is 0, then Destination is
807 returned unmodified. If Length is greater that the number of ASCII characters
808 in Source, then Destination is padded with Null ASCII characters. If Source
809 and Destination overlap, then the results are undefined.
811 If Destination is NULL, then ASSERT().
812 If Source is NULL, then ASSERT().
813 If Source and Destination overlap, then ASSERT().
814 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
815 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
818 @param Destination Pointer to a Null-terminated ASCII string.
819 @param Source Pointer to a Null-terminated ASCII string.
820 @param Length Maximum number of ASCII characters to copy.
828 OUT CHAR8
*Destination
,
829 IN CONST CHAR8
*Source
,
835 Returns the length of a Null-terminated ASCII string.
837 This function returns the number of ASCII characters in the Null-terminated
838 ASCII string specified by String.
840 If Length > 0 and Destination is NULL, then ASSERT().
841 If Length > 0 and Source is NULL, then ASSERT().
842 If PcdMaximumAsciiStringLength is not zero and String contains more than
843 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
846 @param String Pointer to a Null-terminated ASCII string.
848 @return The length of String.
854 IN CONST CHAR8
*String
859 Returns the size of a Null-terminated ASCII string in bytes, including the
862 This function returns the size, in bytes, of the Null-terminated ASCII string
865 If String is NULL, then ASSERT().
866 If PcdMaximumAsciiStringLength is not zero and String contains more than
867 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
870 @param String Pointer to a Null-terminated ASCII string.
872 @return The size of String.
878 IN CONST CHAR8
*String
883 Compares two Null-terminated ASCII strings, and returns the difference
884 between the first mismatched ASCII characters.
886 This function compares the Null-terminated ASCII string FirstString to the
887 Null-terminated ASCII string SecondString. If FirstString is identical to
888 SecondString, then 0 is returned. Otherwise, the value returned is the first
889 mismatched ASCII character in SecondString subtracted from the first
890 mismatched ASCII character in FirstString.
892 If FirstString is NULL, then ASSERT().
893 If SecondString is NULL, then ASSERT().
894 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
895 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
897 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
898 than PcdMaximumAsciiStringLength ASCII characters not including the
899 Null-terminator, then ASSERT().
901 @param FirstString Pointer to a Null-terminated ASCII string.
902 @param SecondString Pointer to a Null-terminated ASCII string.
904 @retval 0 FirstString is identical to SecondString.
905 @retval !=0 FirstString is not identical to SecondString.
911 IN CONST CHAR8
*FirstString
,
912 IN CONST CHAR8
*SecondString
917 Performs a case insensitive comparison of two Null-terminated ASCII strings,
918 and returns the difference between the first mismatched ASCII characters.
920 This function performs a case insensitive comparison of the Null-terminated
921 ASCII string FirstString to the Null-terminated ASCII string SecondString. If
922 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
923 value returned is the first mismatched lower case ASCII character in
924 SecondString subtracted from the first mismatched lower case ASCII character
927 If FirstString is NULL, then ASSERT().
928 If SecondString is NULL, then ASSERT().
929 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
930 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
932 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
933 than PcdMaximumAsciiStringLength ASCII characters not including the
934 Null-terminator, then ASSERT().
936 @param FirstString Pointer to a Null-terminated ASCII string.
937 @param SecondString Pointer to a Null-terminated ASCII string.
939 @retval 0 FirstString is identical to SecondString using case insensitive
941 @retval !=0 FirstString is not identical to SecondString using case
942 insensitive comparisons.
948 IN CONST CHAR8
*FirstString
,
949 IN CONST CHAR8
*SecondString
954 Compares two Null-terminated ASCII strings with maximum lengths, and returns
955 the difference between the first mismatched ASCII characters.
957 This function compares the Null-terminated ASCII string FirstString to the
958 Null-terminated ASCII string SecondString. At most, Length ASCII characters
959 will be compared. If Length is 0, then 0 is returned. If FirstString is
960 identical to SecondString, then 0 is returned. Otherwise, the value returned
961 is the first mismatched ASCII character in SecondString subtracted from the
962 first mismatched ASCII character in FirstString.
964 If Length > 0 and FirstString is NULL, then ASSERT().
965 If Length > 0 and SecondString is NULL, then ASSERT().
966 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
967 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
969 If PcdMaximumAsciiStringLength is not zero and SecondString contains more than
970 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
973 @param FirstString Pointer to a Null-terminated ASCII string.
974 @param SecondString Pointer to a Null-terminated ASCII string.
975 @param Length Maximum number of ASCII characters for compare.
977 @retval 0 FirstString is identical to SecondString.
978 @retval !=0 FirstString is not identical to SecondString.
984 IN CONST CHAR8
*FirstString
,
985 IN CONST CHAR8
*SecondString
,
991 Concatenates one Null-terminated ASCII string to another Null-terminated
992 ASCII string, and returns the concatenated ASCII string.
994 This function concatenates two Null-terminated ASCII strings. The contents of
995 Null-terminated ASCII string Source are concatenated to the end of Null-
996 terminated ASCII string Destination. The Null-terminated concatenated ASCII
999 If Destination is NULL, then ASSERT().
1000 If Source is NULL, then ASSERT().
1001 If PcdMaximumAsciiStringLength is not zero and Destination contains more than
1002 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1004 If PcdMaximumAsciiStringLength is not zero and Source contains more than
1005 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1007 If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
1008 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
1009 ASCII characters, then ASSERT().
1011 @param Destination Pointer to a Null-terminated ASCII string.
1012 @param Source Pointer to a Null-terminated ASCII string.
1020 IN OUT CHAR8
*Destination
,
1021 IN CONST CHAR8
*Source
1026 Concatenates one Null-terminated ASCII string with a maximum length to the
1027 end of another Null-terminated ASCII string, and returns the concatenated
1030 This function concatenates two Null-terminated ASCII strings. The contents
1031 of Null-terminated ASCII string Source are concatenated to the end of Null-
1032 terminated ASCII string Destination, and Destination is returned. At most,
1033 Length ASCII characters are concatenated from Source to the end of
1034 Destination, and Destination is always Null-terminated. If Length is 0, then
1035 Destination is returned unmodified. If Source and Destination overlap, then
1036 the results are undefined.
1038 If Length > 0 and Destination is NULL, then ASSERT().
1039 If Length > 0 and Source is NULL, then ASSERT().
1040 If Source and Destination overlap, then ASSERT().
1041 If PcdMaximumAsciiStringLength is not zero, and Destination contains more than
1042 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1044 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1045 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1047 If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
1048 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
1049 ASCII characters not including the Null-terminator, then ASSERT().
1051 @param Destination Pointer to a Null-terminated ASCII string.
1052 @param Source Pointer to a Null-terminated ASCII string.
1053 @param Length Maximum number of ASCII characters to concatenate from
1062 IN OUT CHAR8
*Destination
,
1063 IN CONST CHAR8
*Source
,
1069 Returns the first occurance of a Null-terminated ASCII sub-string
1070 in a Null-terminated ASCII string.
1072 This function scans the contents of the ASCII string specified by String
1073 and returns the first occurrence of SearchString. If SearchString is not
1074 found in String, then NULL is returned. If the length of SearchString is zero,
1075 then String is returned.
1077 If String is NULL, then ASSERT().
1078 If SearchString is NULL, then ASSERT().
1080 If PcdMaximumAsciiStringLength is not zero, and SearchString or
1081 String contains more than PcdMaximumAsciiStringLength Unicode characters
1082 not including the Null-terminator, then ASSERT().
1084 @param String Pointer to a Null-terminated ASCII string.
1085 @param SearchString Pointer to a Null-terminated ASCII string to search for.
1087 @retval NULL If the SearchString does not appear in String.
1088 @retval !NULL If there is a match.
1094 IN CONST CHAR8
*String
,
1095 IN CONST CHAR8
*SearchString
1100 Convert a Null-terminated ASCII decimal string to a value of type
1103 This function returns a value of type UINTN by interpreting the contents
1104 of the ASCII string String as a decimal number. The format of the input
1105 ASCII string String is:
1107 [spaces] [decimal digits].
1109 The valid decimal digit character is in the range [0-9]. The function will
1110 ignore the pad space, which includes spaces or tab characters, before the digits.
1111 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1112 function stops at the first character that is a not a valid decimal character or
1113 Null-terminator, whichever on comes first.
1115 If String has only pad spaces, then 0 is returned.
1116 If String has no pad spaces or valid decimal digits, then 0 is returned.
1117 If the number represented by String overflows according to the range defined by
1118 UINTN, then ASSERT().
1119 If String is NULL, then ASSERT().
1120 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1121 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1124 @param String Pointer to a Null-terminated ASCII string.
1126 @retval Value translated from String.
1131 AsciiStrDecimalToUintn (
1132 IN CONST CHAR8
*String
1137 Convert a Null-terminated ASCII decimal string to a value of type
1140 This function returns a value of type UINT64 by interpreting the contents
1141 of the ASCII string String as a decimal number. The format of the input
1142 ASCII string String is:
1144 [spaces] [decimal digits].
1146 The valid decimal digit character is in the range [0-9]. The function will
1147 ignore the pad space, which includes spaces or tab characters, before the digits.
1148 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1149 function stops at the first character that is a not a valid decimal character or
1150 Null-terminator, whichever on comes first.
1152 If String has only pad spaces, then 0 is returned.
1153 If String has no pad spaces or valid decimal digits, then 0 is returned.
1154 If the number represented by String overflows according to the range defined by
1155 UINT64, then ASSERT().
1156 If String is NULL, then ASSERT().
1157 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1158 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1161 @param String Pointer to a Null-terminated ASCII string.
1163 @retval Value translated from String.
1168 AsciiStrDecimalToUint64 (
1169 IN CONST CHAR8
*String
1174 Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.
1176 This function returns a value of type UINTN by interpreting the contents of
1177 the ASCII string String as a hexadecimal number. The format of the input ASCII
1180 [spaces][zeros][x][hexadecimal digits].
1182 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1183 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1184 appears in the input string, it must be prefixed with at least one 0. The function
1185 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1186 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1187 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1188 digit. Then, the function stops at the first character that is a not a valid
1189 hexadecimal character or Null-terminator, whichever on comes first.
1191 If String has only pad spaces, then 0 is returned.
1192 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1195 If the number represented by String overflows according to the range defined by UINTN,
1197 If String is NULL, then ASSERT().
1198 If PcdMaximumAsciiStringLength is not zero,
1199 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1200 the Null-terminator, then ASSERT().
1202 @param String Pointer to a Null-terminated ASCII string.
1204 @retval Value translated from String.
1209 AsciiStrHexToUintn (
1210 IN CONST CHAR8
*String
1215 Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.
1217 This function returns a value of type UINT64 by interpreting the contents of
1218 the ASCII string String as a hexadecimal number. The format of the input ASCII
1221 [spaces][zeros][x][hexadecimal digits].
1223 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1224 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1225 appears in the input string, it must be prefixed with at least one 0. The function
1226 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1227 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1228 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1229 digit. Then, the function stops at the first character that is a not a valid
1230 hexadecimal character or Null-terminator, whichever on comes first.
1232 If String has only pad spaces, then 0 is returned.
1233 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1236 If the number represented by String overflows according to the range defined by UINT64,
1238 If String is NULL, then ASSERT().
1239 If PcdMaximumAsciiStringLength is not zero,
1240 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1241 the Null-terminator, then ASSERT().
1243 @param String Pointer to a Null-terminated ASCII string.
1245 @retval Value translated from String.
1250 AsciiStrHexToUint64 (
1251 IN CONST CHAR8
*String
1256 Convert one Null-terminated ASCII string to a Null-terminated
1257 Unicode string and returns the Unicode string.
1259 This function converts the contents of the ASCII string Source to the Unicode
1260 string Destination, and returns Destination. The function terminates the
1261 Unicode string Destination by appending a Null-terminator character at the end.
1262 The caller is responsible to make sure Destination points to a buffer with size
1263 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
1265 If Destination is NULL, then ASSERT().
1266 If Destination is not aligned on a 16-bit boundary, then ASSERT().
1267 If Source is NULL, then ASSERT().
1268 If Source and Destination overlap, then ASSERT().
1269 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1270 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1272 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1273 PcdMaximumUnicodeStringLength ASCII characters not including the
1274 Null-terminator, then ASSERT().
1276 @param Source Pointer to a Null-terminated ASCII string.
1277 @param Destination Pointer to a Null-terminated Unicode string.
1284 AsciiStrToUnicodeStr (
1285 IN CONST CHAR8
*Source
,
1286 OUT CHAR16
*Destination
1291 Converts an 8-bit value to an 8-bit BCD value.
1293 Converts the 8-bit value specified by Value to BCD. The BCD value is
1296 If Value >= 100, then ASSERT().
1298 @param Value The 8-bit value to convert to BCD. Range 0..99.
1300 @return The BCD value
1311 Converts an 8-bit BCD value to an 8-bit value.
1313 Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit
1316 If Value >= 0xA0, then ASSERT().
1317 If (Value & 0x0F) >= 0x0A, then ASSERT().
1319 @param Value The 8-bit BCD value to convert to an 8-bit value.
1321 @return The 8-bit value is returned.
1332 // Linked List Functions and Macros
1336 Initializes the head node of a doubly linked list that is declared as a
1337 global variable in a module.
1339 Initializes the forward and backward links of a new linked list. After
1340 initializing a linked list with this macro, the other linked list functions
1341 may be used to add and remove nodes from the linked list. This macro results
1342 in smaller executables by initializing the linked list in the data section,
1343 instead if calling the InitializeListHead() function to perform the
1344 equivalent operation.
1346 @param ListHead The head note of a list to initiailize.
1349 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&ListHead, &ListHead}
1353 Initializes the head node of a doubly linked list, and returns the pointer to
1354 the head node of the doubly linked list.
1356 Initializes the forward and backward links of a new linked list. After
1357 initializing a linked list with this function, the other linked list
1358 functions may be used to add and remove nodes from the linked list. It is up
1359 to the caller of this function to allocate the memory for ListHead.
1361 If ListHead is NULL, then ASSERT().
1363 @param ListHead A pointer to the head node of a new doubly linked list.
1370 InitializeListHead (
1371 IN LIST_ENTRY
*ListHead
1376 Adds a node to the beginning of a doubly linked list, and returns the pointer
1377 to the head node of the doubly linked list.
1379 Adds the node Entry at the beginning of the doubly linked list denoted by
1380 ListHead, and returns ListHead.
1382 If ListHead is NULL, then ASSERT().
1383 If Entry is NULL, then ASSERT().
1384 If ListHead was not initialized with InitializeListHead(), then ASSERT().
1385 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
1386 of nodes in ListHead, including the ListHead node, is greater than or
1387 equal to PcdMaximumLinkedListLength, then ASSERT().
1389 @param ListHead A pointer to the head node of a doubly linked list.
1390 @param Entry A pointer to a node that is to be inserted at the beginning
1391 of a doubly linked list.
1399 IN LIST_ENTRY
*ListHead
,
1400 IN LIST_ENTRY
*Entry
1405 Adds a node to the end of a doubly linked list, and returns the pointer to
1406 the head node of the doubly linked list.
1408 Adds the node Entry to the end of the doubly linked list denoted by ListHead,
1409 and returns ListHead.
1411 If ListHead is NULL, then ASSERT().
1412 If Entry is NULL, then ASSERT().
1413 If ListHead was not initialized with InitializeListHead(), then ASSERT().
1414 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
1415 of nodes in ListHead, including the ListHead node, is greater than or
1416 equal to PcdMaximumLinkedListLength, then ASSERT().
1418 @param ListHead A pointer to the head node of a doubly linked list.
1419 @param Entry A pointer to a node that is to be added at the end of the
1428 IN LIST_ENTRY
*ListHead
,
1429 IN LIST_ENTRY
*Entry
1434 Retrieves the first node of a doubly linked list.
1436 Returns the first node of a doubly linked list. List must have been
1437 initialized with InitializeListHead(). If List is empty, then NULL is
1440 If List is NULL, then ASSERT().
1441 If List was not initialized with InitializeListHead(), then ASSERT().
1442 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1443 in List, including the List node, is greater than or equal to
1444 PcdMaximumLinkedListLength, then ASSERT().
1446 @param List A pointer to the head node of a doubly linked list.
1448 @return The first node of a doubly linked list.
1449 @retval NULL The list is empty.
1455 IN CONST LIST_ENTRY
*List
1460 Retrieves the next node of a doubly linked list.
1462 Returns the node of a doubly linked list that follows Node. List must have
1463 been initialized with InitializeListHead(). If List is empty, then List is
1466 If List is NULL, then ASSERT().
1467 If Node is NULL, then ASSERT().
1468 If List was not initialized with InitializeListHead(), then ASSERT().
1469 If PcdMaximumLinkedListLenth is not zero, and List contains more than
1470 PcdMaximumLinkedListLenth nodes, then ASSERT().
1471 If Node is not a node in List, then ASSERT().
1473 @param List A pointer to the head node of a doubly linked list.
1474 @param Node A pointer to a node in the doubly linked list.
1476 @return Pointer to the next node if one exists. Otherwise a null value which
1477 is actually List is returned.
1483 IN CONST LIST_ENTRY
*List
,
1484 IN CONST LIST_ENTRY
*Node
1489 Checks to see if a doubly linked list is empty or not.
1491 Checks to see if the doubly linked list is empty. If the linked list contains
1492 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
1494 If ListHead is NULL, then ASSERT().
1495 If ListHead was not initialized with InitializeListHead(), then ASSERT().
1496 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1497 in List, including the List node, is greater than or equal to
1498 PcdMaximumLinkedListLength, then ASSERT().
1500 @param ListHead A pointer to the head node of a doubly linked list.
1502 @retval TRUE The linked list is empty.
1503 @retval FALSE The linked list is not empty.
1509 IN CONST LIST_ENTRY
*ListHead
1514 Determines if a node in a doubly linked list is null.
1516 Returns FALSE if Node is one of the nodes in the doubly linked list specified
1517 by List. Otherwise, TRUE is returned. List must have been initialized with
1518 InitializeListHead().
1520 If List is NULL, then ASSERT().
1521 If Node is NULL, then ASSERT().
1522 If List was not initialized with InitializeListHead(), then ASSERT().
1523 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1524 in List, including the List node, is greater than or equal to
1525 PcdMaximumLinkedListLength, then ASSERT().
1526 If Node is not a node in List and Node is not equal to List, then ASSERT().
1528 @param List A pointer to the head node of a doubly linked list.
1529 @param Node A pointer to a node in the doubly linked list.
1531 @retval TRUE Node is one of the nodes in the doubly linked list.
1532 @retval FALSE Node is not one of the nodes in the doubly linked list.
1538 IN CONST LIST_ENTRY
*List
,
1539 IN CONST LIST_ENTRY
*Node
1544 Determines if a node the last node in a doubly linked list.
1546 Returns TRUE if Node is the last node in the doubly linked list specified by
1547 List. Otherwise, FALSE is returned. List must have been initialized with
1548 InitializeListHead().
1550 If List is NULL, then ASSERT().
1551 If Node is NULL, then ASSERT().
1552 If List was not initialized with InitializeListHead(), then ASSERT().
1553 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1554 in List, including the List node, is greater than or equal to
1555 PcdMaximumLinkedListLength, then ASSERT().
1556 If Node is not a node in List, then ASSERT().
1558 @param List A pointer to the head node of a doubly linked list.
1559 @param Node A pointer to a node in the doubly linked list.
1561 @retval TRUE Node is the last node in the linked list.
1562 @retval FALSE Node is not the last node in the linked list.
1568 IN CONST LIST_ENTRY
*List
,
1569 IN CONST LIST_ENTRY
*Node
1574 Swaps the location of two nodes in a doubly linked list, and returns the
1575 first node after the swap.
1577 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
1578 Otherwise, the location of the FirstEntry node is swapped with the location
1579 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
1580 same double linked list as FirstEntry and that double linked list must have
1581 been initialized with InitializeListHead(). SecondEntry is returned after the
1584 If FirstEntry is NULL, then ASSERT().
1585 If SecondEntry is NULL, then ASSERT().
1586 If SecondEntry and FirstEntry are not in the same linked list, then ASSERT().
1587 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1588 linked list containing the FirstEntry and SecondEntry nodes, including
1589 the FirstEntry and SecondEntry nodes, is greater than or equal to
1590 PcdMaximumLinkedListLength, then ASSERT().
1592 @param FirstEntry A pointer to a node in a linked list.
1593 @param SecondEntry A pointer to another node in the same linked list.
1601 IN LIST_ENTRY
*FirstEntry
,
1602 IN LIST_ENTRY
*SecondEntry
1607 Removes a node from a doubly linked list, and returns the node that follows
1610 Removes the node Entry from a doubly linked list. It is up to the caller of
1611 this function to release the memory used by this node if that is required. On
1612 exit, the node following Entry in the doubly linked list is returned. If
1613 Entry is the only node in the linked list, then the head node of the linked
1616 If Entry is NULL, then ASSERT().
1617 If Entry is the head node of an empty list, then ASSERT().
1618 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1619 linked list containing Entry, including the Entry node, is greater than
1620 or equal to PcdMaximumLinkedListLength, then ASSERT().
1622 @param Entry A pointer to a node in a linked list
1630 IN CONST LIST_ENTRY
*Entry
1638 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
1639 with zeros. The shifted value is returned.
1641 This function shifts the 64-bit value Operand to the left by Count bits. The
1642 low Count bits are set to zero. The shifted value is returned.
1644 If Count is greater than 63, then ASSERT().
1646 @param Operand The 64-bit operand to shift left.
1647 @param Count The number of bits to shift left.
1649 @return Operand << Count
1661 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
1662 filled with zeros. The shifted value is returned.
1664 This function shifts the 64-bit value Operand to the right by Count bits. The
1665 high Count bits are set to zero. The shifted value is returned.
1667 If Count is greater than 63, then ASSERT().
1669 @param Operand The 64-bit operand to shift right.
1670 @param Count The number of bits to shift right.
1672 @return Operand >> Count
1684 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
1685 with original integer's bit 63. The shifted value is returned.
1687 This function shifts the 64-bit value Operand to the right by Count bits. The
1688 high Count bits are set to bit 63 of Operand. The shifted value is returned.
1690 If Count is greater than 63, then ASSERT().
1692 @param Operand The 64-bit operand to shift right.
1693 @param Count The number of bits to shift right.
1695 @return Operand >> Count
1707 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
1708 with the high bits that were rotated.
1710 This function rotates the 32-bit value Operand to the left by Count bits. The
1711 low Count bits are fill with the high Count bits of Operand. The rotated
1714 If Count is greater than 31, then ASSERT().
1716 @param Operand The 32-bit operand to rotate left.
1717 @param Count The number of bits to rotate left.
1719 @return Operand <<< Count
1731 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
1732 with the low bits that were rotated.
1734 This function rotates the 32-bit value Operand to the right by Count bits.
1735 The high Count bits are fill with the low Count bits of Operand. The rotated
1738 If Count is greater than 31, then ASSERT().
1740 @param Operand The 32-bit operand to rotate right.
1741 @param Count The number of bits to rotate right.
1743 @return Operand >>> Count
1755 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
1756 with the high bits that were rotated.
1758 This function rotates the 64-bit value Operand to the left by Count bits. The
1759 low Count bits are fill with the high Count bits of Operand. The rotated
1762 If Count is greater than 63, then ASSERT().
1764 @param Operand The 64-bit operand to rotate left.
1765 @param Count The number of bits to rotate left.
1767 @return Operand <<< Count
1779 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
1780 with the high low bits that were rotated.
1782 This function rotates the 64-bit value Operand to the right by Count bits.
1783 The high Count bits are fill with the low Count bits of Operand. The rotated
1786 If Count is greater than 63, then ASSERT().
1788 @param Operand The 64-bit operand to rotate right.
1789 @param Count The number of bits to rotate right.
1791 @return Operand >>> Count
1803 Returns the bit position of the lowest bit set in a 32-bit value.
1805 This function computes the bit position of the lowest bit set in the 32-bit
1806 value specified by Operand. If Operand is zero, then -1 is returned.
1807 Otherwise, a value between 0 and 31 is returned.
1809 @param Operand The 32-bit operand to evaluate.
1811 @return Position of the lowest bit set in Operand if found.
1812 @retval -1 Operand is zero.
1823 Returns the bit position of the lowest bit set in a 64-bit value.
1825 This function computes the bit position of the lowest bit set in the 64-bit
1826 value specified by Operand. If Operand is zero, then -1 is returned.
1827 Otherwise, a value between 0 and 63 is returned.
1829 @param Operand The 64-bit operand to evaluate.
1831 @return Position of the lowest bit set in Operand if found.
1832 @retval -1 Operand is zero.
1843 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
1846 This function computes the bit position of the highest bit set in the 32-bit
1847 value specified by Operand. If Operand is zero, then -1 is returned.
1848 Otherwise, a value between 0 and 31 is returned.
1850 @param Operand The 32-bit operand to evaluate.
1852 @return Position of the highest bit set in Operand if found.
1853 @retval -1 Operand is zero.
1864 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
1867 This function computes the bit position of the highest bit set in the 64-bit
1868 value specified by Operand. If Operand is zero, then -1 is returned.
1869 Otherwise, a value between 0 and 63 is returned.
1871 @param Operand The 64-bit operand to evaluate.
1873 @return Position of the highest bit set in Operand if found.
1874 @retval -1 Operand is zero.
1885 Returns the value of the highest bit set in a 32-bit value. Equivalent to
1886 1 << HighBitSet32(x).
1888 This function computes the value of the highest bit set in the 32-bit value
1889 specified by Operand. If Operand is zero, then zero is returned.
1891 @param Operand The 32-bit operand to evaluate.
1893 @return 1 << HighBitSet32(Operand)
1894 @retval 0 Operand is zero.
1905 Returns the value of the highest bit set in a 64-bit value. Equivalent to
1906 1 << HighBitSet64(x).
1908 This function computes the value of the highest bit set in the 64-bit value
1909 specified by Operand. If Operand is zero, then zero is returned.
1911 @param Operand The 64-bit operand to evaluate.
1913 @return 1 << HighBitSet64(Operand)
1914 @retval 0 Operand is zero.
1925 Switches the endianess of a 16-bit integer.
1927 This function swaps the bytes in a 16-bit unsigned value to switch the value
1928 from little endian to big endian or vice versa. The byte swapped value is
1931 @param Value Operand A 16-bit unsigned value.
1933 @return The byte swaped Operand.
1944 Switches the endianess of a 32-bit integer.
1946 This function swaps the bytes in a 32-bit unsigned value to switch the value
1947 from little endian to big endian or vice versa. The byte swapped value is
1950 @param Value Operand A 32-bit unsigned value.
1952 @return The byte swaped Operand.
1963 Switches the endianess of a 64-bit integer.
1965 This function swaps the bytes in a 64-bit unsigned value to switch the value
1966 from little endian to big endian or vice versa. The byte swapped value is
1969 @param Value Operand A 64-bit unsigned value.
1971 @return The byte swaped Operand.
1982 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
1983 generates a 64-bit unsigned result.
1985 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
1986 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1987 bit unsigned result is returned.
1989 If the result overflows, then ASSERT().
1991 @param Multiplicand A 64-bit unsigned value.
1992 @param Multiplier A 32-bit unsigned value.
1994 @return Multiplicand * Multiplier
2000 IN UINT64 Multiplicand
,
2001 IN UINT32 Multiplier
2006 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
2007 generates a 64-bit unsigned result.
2009 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
2010 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
2011 bit unsigned result is returned.
2013 If the result overflows, then ASSERT().
2015 @param Multiplicand A 64-bit unsigned value.
2016 @param Multiplier A 64-bit unsigned value.
2018 @return Multiplicand * Multiplier
2024 IN UINT64 Multiplicand
,
2025 IN UINT64 Multiplier
2030 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
2031 64-bit signed result.
2033 This function multiples the 64-bit signed value Multiplicand by the 64-bit
2034 signed value Multiplier and generates a 64-bit signed result. This 64-bit
2035 signed result is returned.
2037 If the result overflows, then ASSERT().
2039 @param Multiplicand A 64-bit signed value.
2040 @param Multiplier A 64-bit signed value.
2042 @return Multiplicand * Multiplier
2048 IN INT64 Multiplicand
,
2054 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2055 a 64-bit unsigned result.
2057 This function divides the 64-bit unsigned value Dividend by the 32-bit
2058 unsigned value Divisor and generates a 64-bit unsigned quotient. This
2059 function returns the 64-bit unsigned quotient.
2061 If Divisor is 0, then ASSERT().
2063 @param Dividend A 64-bit unsigned value.
2064 @param Divisor A 32-bit unsigned value.
2066 @return Dividend / Divisor
2078 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2079 a 32-bit unsigned remainder.
2081 This function divides the 64-bit unsigned value Dividend by the 32-bit
2082 unsigned value Divisor and generates a 32-bit remainder. This function
2083 returns the 32-bit unsigned remainder.
2085 If Divisor is 0, then ASSERT().
2087 @param Dividend A 64-bit unsigned value.
2088 @param Divisor A 32-bit unsigned value.
2090 @return Dividend % Divisor
2102 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2103 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
2105 This function divides the 64-bit unsigned value Dividend by the 32-bit
2106 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2107 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
2108 This function returns the 64-bit unsigned quotient.
2110 If Divisor is 0, then ASSERT().
2112 @param Dividend A 64-bit unsigned value.
2113 @param Divisor A 32-bit unsigned value.
2114 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
2115 optional and may be NULL.
2117 @return Dividend / Divisor
2122 DivU64x32Remainder (
2125 OUT UINT32
*Remainder OPTIONAL
2130 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
2131 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
2133 This function divides the 64-bit unsigned value Dividend by the 64-bit
2134 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2135 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
2136 This function returns the 64-bit unsigned quotient.
2138 If Divisor is 0, then ASSERT().
2140 @param Dividend A 64-bit unsigned value.
2141 @param Divisor A 64-bit unsigned value.
2142 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
2143 optional and may be NULL.
2145 @return Dividend / Divisor
2150 DivU64x64Remainder (
2153 OUT UINT64
*Remainder OPTIONAL
2158 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
2159 64-bit signed result and a optional 64-bit signed remainder.
2161 This function divides the 64-bit signed value Dividend by the 64-bit signed
2162 value Divisor and generates a 64-bit signed quotient. If Remainder is not
2163 NULL, then the 64-bit signed remainder is returned in Remainder. This
2164 function returns the 64-bit signed quotient.
2166 If Divisor is 0, then ASSERT().
2168 @param Dividend A 64-bit signed value.
2169 @param Divisor A 64-bit signed value.
2170 @param Remainder A pointer to a 64-bit signed value. This parameter is
2171 optional and may be NULL.
2173 @return Dividend / Divisor
2178 DivS64x64Remainder (
2181 OUT INT64
*Remainder OPTIONAL
2186 Reads a 16-bit value from memory that may be unaligned.
2188 This function returns the 16-bit value pointed to by Buffer. The function
2189 guarantees that the read operation does not produce an alignment fault.
2191 If the Buffer is NULL, then ASSERT().
2193 @param Uint16 Pointer to a 16-bit value that may be unaligned.
2201 IN CONST UINT16
*Uint16
2206 Writes a 16-bit value to memory that may be unaligned.
2208 This function writes the 16-bit value specified by Value to Buffer. Value is
2209 returned. The function guarantees that the write operation does not produce
2212 If the Buffer is NULL, then ASSERT().
2214 @param Uint16 Pointer to a 16-bit value that may be unaligned.
2215 @param Value 16-bit value to write to Buffer.
2229 Reads a 24-bit value from memory that may be unaligned.
2231 This function returns the 24-bit value pointed to by Buffer. The function
2232 guarantees that the read operation does not produce an alignment fault.
2234 If the Buffer is NULL, then ASSERT().
2236 @param Buffer Pointer to a 24-bit value that may be unaligned.
2238 @return The value read from Buffer.
2244 IN CONST UINT32
*Buffer
2249 Writes a 24-bit value to memory that may be unaligned.
2251 This function writes the 24-bit value specified by Value to Buffer. Value is
2252 returned. The function guarantees that the write operation does not produce
2255 If the Buffer is NULL, then ASSERT().
2257 @param Buffer Pointer to a 24-bit value that may be unaligned.
2258 @param Value 24-bit value to write to Buffer.
2260 @return The value written to Buffer.
2272 Reads a 32-bit value from memory that may be unaligned.
2274 This function returns the 32-bit value pointed to by Buffer. The function
2275 guarantees that the read operation does not produce an alignment fault.
2277 If the Buffer is NULL, then ASSERT().
2279 @param Uint32 Pointer to a 32-bit value that may be unaligned.
2281 @return Value read from Uint32
2287 IN CONST UINT32
*Uint32
2292 Writes a 32-bit value to memory that may be unaligned.
2294 This function writes the 32-bit value specified by Value to Buffer. Value is
2295 returned. The function guarantees that the write operation does not produce
2298 If the Buffer is NULL, then ASSERT().
2300 @param Uint32 Pointer to a 32-bit value that may be unaligned.
2301 @param Value 32-bit value to write to Buffer.
2303 @return Value written to Uint32.
2315 Reads a 64-bit value from memory that may be unaligned.
2317 This function returns the 64-bit value pointed to by Buffer. The function
2318 guarantees that the read operation does not produce an alignment fault.
2320 If the Buffer is NULL, then ASSERT().
2322 @param Uint64 Pointer to a 64-bit value that may be unaligned.
2324 @return Value read from Uint64.
2330 IN CONST UINT64
*Uint64
2335 Writes a 64-bit value to memory that may be unaligned.
2337 This function writes the 64-bit value specified by Value to Buffer. Value is
2338 returned. The function guarantees that the write operation does not produce
2341 If the Buffer is NULL, then ASSERT().
2343 @param Uint64 Pointer to a 64-bit value that may be unaligned.
2344 @param Value 64-bit value to write to Buffer.
2346 @return Value written to Uint64.
2358 // Bit Field Functions
2362 Returns a bit field from an 8-bit value.
2364 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2366 If 8-bit operations are not supported, then ASSERT().
2367 If StartBit is greater than 7, then ASSERT().
2368 If EndBit is greater than 7, then ASSERT().
2369 If EndBit is less than StartBit, then ASSERT().
2371 @param Operand Operand on which to perform the bitfield operation.
2372 @param StartBit The ordinal of the least significant bit in the bit field.
2374 @param EndBit The ordinal of the most significant bit in the bit field.
2377 @return The bit field read.
2390 Writes a bit field to an 8-bit value, and returns the result.
2392 Writes Value to the bit field specified by the StartBit and the EndBit in
2393 Operand. All other bits in Operand are preserved. The new 8-bit value is
2396 If 8-bit operations are not supported, then ASSERT().
2397 If StartBit is greater than 7, then ASSERT().
2398 If EndBit is greater than 7, then ASSERT().
2399 If EndBit is less than StartBit, then ASSERT().
2401 @param Operand Operand on which to perform the bitfield operation.
2402 @param StartBit The ordinal of the least significant bit in the bit field.
2404 @param EndBit The ordinal of the most significant bit in the bit field.
2406 @param Value New value of the bit field.
2408 @return The new 8-bit value.
2422 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
2425 Performs a bitwise inclusive OR between the bit field specified by StartBit
2426 and EndBit in Operand and the value specified by OrData. All other bits in
2427 Operand are preserved. The new 8-bit value is returned.
2429 If 8-bit operations are not supported, then ASSERT().
2430 If StartBit is greater than 7, then ASSERT().
2431 If EndBit is greater than 7, then ASSERT().
2432 If EndBit is less than StartBit, then ASSERT().
2434 @param Operand Operand on which to perform the bitfield operation.
2435 @param StartBit The ordinal of the least significant bit in the bit field.
2437 @param EndBit The ordinal of the most significant bit in the bit field.
2439 @param OrData The value to OR with the read value from the value
2441 @return The new 8-bit value.
2455 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
2458 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2459 in Operand and the value specified by AndData. All other bits in Operand are
2460 preserved. The new 8-bit value is returned.
2462 If 8-bit operations are not supported, then ASSERT().
2463 If StartBit is greater than 7, then ASSERT().
2464 If EndBit is greater than 7, then ASSERT().
2465 If EndBit is less than StartBit, then ASSERT().
2467 @param Operand Operand on which to perform the bitfield operation.
2468 @param StartBit The ordinal of the least significant bit in the bit field.
2470 @param EndBit The ordinal of the most significant bit in the bit field.
2472 @param AndData The value to AND with the read value from the value.
2474 @return The new 8-bit value.
2488 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
2489 bitwise OR, and returns the result.
2491 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2492 in Operand and the value specified by AndData, followed by a bitwise
2493 inclusive OR with value specified by OrData. All other bits in Operand are
2494 preserved. The new 8-bit value is returned.
2496 If 8-bit operations are not supported, then ASSERT().
2497 If StartBit is greater than 7, then ASSERT().
2498 If EndBit is greater than 7, then ASSERT().
2499 If EndBit is less than StartBit, then ASSERT().
2501 @param Operand Operand on which to perform the bitfield operation.
2502 @param StartBit The ordinal of the least significant bit in the bit field.
2504 @param EndBit The ordinal of the most significant bit in the bit field.
2506 @param AndData The value to AND with the read value from the value.
2507 @param OrData The value to OR with the result of the AND operation.
2509 @return The new 8-bit value.
2514 BitFieldAndThenOr8 (
2524 Returns a bit field from a 16-bit value.
2526 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2528 If 16-bit operations are not supported, then ASSERT().
2529 If StartBit is greater than 15, then ASSERT().
2530 If EndBit is greater than 15, then ASSERT().
2531 If EndBit is less than StartBit, then ASSERT().
2533 @param Operand Operand on which to perform the bitfield operation.
2534 @param StartBit The ordinal of the least significant bit in the bit field.
2536 @param EndBit The ordinal of the most significant bit in the bit field.
2539 @return The bit field read.
2552 Writes a bit field to a 16-bit value, and returns the result.
2554 Writes Value to the bit field specified by the StartBit and the EndBit in
2555 Operand. All other bits in Operand are preserved. The new 16-bit value is
2558 If 16-bit operations are not supported, then ASSERT().
2559 If StartBit is greater than 15, then ASSERT().
2560 If EndBit is greater than 15, then ASSERT().
2561 If EndBit is less than StartBit, then ASSERT().
2563 @param Operand Operand on which to perform the bitfield operation.
2564 @param StartBit The ordinal of the least significant bit in the bit field.
2566 @param EndBit The ordinal of the most significant bit in the bit field.
2568 @param Value New value of the bit field.
2570 @return The new 16-bit value.
2584 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
2587 Performs a bitwise inclusive OR between the bit field specified by StartBit
2588 and EndBit in Operand and the value specified by OrData. All other bits in
2589 Operand are preserved. The new 16-bit value is returned.
2591 If 16-bit operations are not supported, then ASSERT().
2592 If StartBit is greater than 15, then ASSERT().
2593 If EndBit is greater than 15, then ASSERT().
2594 If EndBit is less than StartBit, then ASSERT().
2596 @param Operand Operand on which to perform the bitfield operation.
2597 @param StartBit The ordinal of the least significant bit in the bit field.
2599 @param EndBit The ordinal of the most significant bit in the bit field.
2601 @param OrData The value to OR with the read value from the value
2603 @return The new 16-bit value.
2617 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
2620 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2621 in Operand and the value specified by AndData. All other bits in Operand are
2622 preserved. The new 16-bit value is returned.
2624 If 16-bit operations are not supported, then ASSERT().
2625 If StartBit is greater than 15, then ASSERT().
2626 If EndBit is greater than 15, then ASSERT().
2627 If EndBit is less than StartBit, then ASSERT().
2629 @param Operand Operand on which to perform the bitfield operation.
2630 @param StartBit The ordinal of the least significant bit in the bit field.
2632 @param EndBit The ordinal of the most significant bit in the bit field.
2634 @param AndData The value to AND with the read value from the value
2636 @return The new 16-bit value.
2650 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
2651 bitwise OR, and returns the result.
2653 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2654 in Operand and the value specified by AndData, followed by a bitwise
2655 inclusive OR with value specified by OrData. All other bits in Operand are
2656 preserved. The new 16-bit value is returned.
2658 If 16-bit operations are not supported, then ASSERT().
2659 If StartBit is greater than 15, then ASSERT().
2660 If EndBit is greater than 15, then ASSERT().
2661 If EndBit is less than StartBit, then ASSERT().
2663 @param Operand Operand on which to perform the bitfield operation.
2664 @param StartBit The ordinal of the least significant bit in the bit field.
2666 @param EndBit The ordinal of the most significant bit in the bit field.
2668 @param AndData The value to AND with the read value from the value.
2669 @param OrData The value to OR with the result of the AND operation.
2671 @return The new 16-bit value.
2676 BitFieldAndThenOr16 (
2686 Returns a bit field from a 32-bit value.
2688 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2690 If 32-bit operations are not supported, then ASSERT().
2691 If StartBit is greater than 31, then ASSERT().
2692 If EndBit is greater than 31, then ASSERT().
2693 If EndBit is less than StartBit, then ASSERT().
2695 @param Operand Operand on which to perform the bitfield operation.
2696 @param StartBit The ordinal of the least significant bit in the bit field.
2698 @param EndBit The ordinal of the most significant bit in the bit field.
2701 @return The bit field read.
2714 Writes a bit field to a 32-bit value, and returns the result.
2716 Writes Value to the bit field specified by the StartBit and the EndBit in
2717 Operand. All other bits in Operand are preserved. The new 32-bit value is
2720 If 32-bit operations are not supported, then ASSERT().
2721 If StartBit is greater than 31, then ASSERT().
2722 If EndBit is greater than 31, then ASSERT().
2723 If EndBit is less than StartBit, then ASSERT().
2725 @param Operand Operand on which to perform the bitfield operation.
2726 @param StartBit The ordinal of the least significant bit in the bit field.
2728 @param EndBit The ordinal of the most significant bit in the bit field.
2730 @param Value New value of the bit field.
2732 @return The new 32-bit value.
2746 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
2749 Performs a bitwise inclusive OR between the bit field specified by StartBit
2750 and EndBit in Operand and the value specified by OrData. All other bits in
2751 Operand are preserved. The new 32-bit value is returned.
2753 If 32-bit operations are not supported, then ASSERT().
2754 If StartBit is greater than 31, then ASSERT().
2755 If EndBit is greater than 31, then ASSERT().
2756 If EndBit is less than StartBit, then ASSERT().
2758 @param Operand Operand on which to perform the bitfield operation.
2759 @param StartBit The ordinal of the least significant bit in the bit field.
2761 @param EndBit The ordinal of the most significant bit in the bit field.
2763 @param OrData The value to OR with the read value from the value
2765 @return The new 32-bit value.
2779 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
2782 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2783 in Operand and the value specified by AndData. All other bits in Operand are
2784 preserved. The new 32-bit value is returned.
2786 If 32-bit operations are not supported, then ASSERT().
2787 If StartBit is greater than 31, then ASSERT().
2788 If EndBit is greater than 31, then ASSERT().
2789 If EndBit is less than StartBit, then ASSERT().
2791 @param Operand Operand on which to perform the bitfield operation.
2792 @param StartBit The ordinal of the least significant bit in the bit field.
2794 @param EndBit The ordinal of the most significant bit in the bit field.
2796 @param AndData The value to AND with the read value from the value
2798 @return The new 32-bit value.
2812 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
2813 bitwise OR, and returns the result.
2815 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2816 in Operand and the value specified by AndData, followed by a bitwise
2817 inclusive OR with value specified by OrData. All other bits in Operand are
2818 preserved. The new 32-bit value is returned.
2820 If 32-bit operations are not supported, then ASSERT().
2821 If StartBit is greater than 31, then ASSERT().
2822 If EndBit is greater than 31, then ASSERT().
2823 If EndBit is less than StartBit, then ASSERT().
2825 @param Operand Operand on which to perform the bitfield operation.
2826 @param StartBit The ordinal of the least significant bit in the bit field.
2828 @param EndBit The ordinal of the most significant bit in the bit field.
2830 @param AndData The value to AND with the read value from the value.
2831 @param OrData The value to OR with the result of the AND operation.
2833 @return The new 32-bit value.
2838 BitFieldAndThenOr32 (
2848 Returns a bit field from a 64-bit value.
2850 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2852 If 64-bit operations are not supported, then ASSERT().
2853 If StartBit is greater than 63, then ASSERT().
2854 If EndBit is greater than 63, then ASSERT().
2855 If EndBit is less than StartBit, then ASSERT().
2857 @param Operand Operand on which to perform the bitfield operation.
2858 @param StartBit The ordinal of the least significant bit in the bit field.
2860 @param EndBit The ordinal of the most significant bit in the bit field.
2863 @return The bit field read.
2876 Writes a bit field to a 64-bit value, and returns the result.
2878 Writes Value to the bit field specified by the StartBit and the EndBit in
2879 Operand. All other bits in Operand are preserved. The new 64-bit value is
2882 If 64-bit operations are not supported, then ASSERT().
2883 If StartBit is greater than 63, then ASSERT().
2884 If EndBit is greater than 63, then ASSERT().
2885 If EndBit is less than StartBit, then ASSERT().
2887 @param Operand Operand on which to perform the bitfield operation.
2888 @param StartBit The ordinal of the least significant bit in the bit field.
2890 @param EndBit The ordinal of the most significant bit in the bit field.
2892 @param Value New value of the bit field.
2894 @return The new 64-bit value.
2908 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
2911 Performs a bitwise inclusive OR between the bit field specified by StartBit
2912 and EndBit in Operand and the value specified by OrData. All other bits in
2913 Operand are preserved. The new 64-bit value is returned.
2915 If 64-bit operations are not supported, then ASSERT().
2916 If StartBit is greater than 63, then ASSERT().
2917 If EndBit is greater than 63, then ASSERT().
2918 If EndBit is less than StartBit, then ASSERT().
2920 @param Operand Operand on which to perform the bitfield operation.
2921 @param StartBit The ordinal of the least significant bit in the bit field.
2923 @param EndBit The ordinal of the most significant bit in the bit field.
2925 @param OrData The value to OR with the read value from the value
2927 @return The new 64-bit value.
2941 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
2944 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2945 in Operand and the value specified by AndData. All other bits in Operand are
2946 preserved. The new 64-bit value is returned.
2948 If 64-bit operations are not supported, then ASSERT().
2949 If StartBit is greater than 63, then ASSERT().
2950 If EndBit is greater than 63, then ASSERT().
2951 If EndBit is less than StartBit, then ASSERT().
2953 @param Operand Operand on which to perform the bitfield operation.
2954 @param StartBit The ordinal of the least significant bit in the bit field.
2956 @param EndBit The ordinal of the most significant bit in the bit field.
2958 @param AndData The value to AND with the read value from the value
2960 @return The new 64-bit value.
2974 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
2975 bitwise OR, and returns the result.
2977 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2978 in Operand and the value specified by AndData, followed by a bitwise
2979 inclusive OR with value specified by OrData. All other bits in Operand are
2980 preserved. The new 64-bit value is returned.
2982 If 64-bit operations are not supported, then ASSERT().
2983 If StartBit is greater than 63, then ASSERT().
2984 If EndBit is greater than 63, then ASSERT().
2985 If EndBit is less than StartBit, then ASSERT().
2987 @param Operand Operand on which to perform the bitfield operation.
2988 @param StartBit The ordinal of the least significant bit in the bit field.
2990 @param EndBit The ordinal of the most significant bit in the bit field.
2992 @param AndData The value to AND with the read value from the value.
2993 @param OrData The value to OR with the result of the AND operation.
2995 @return The new 64-bit value.
3000 BitFieldAndThenOr64 (
3010 // Base Library Synchronization Functions
3014 Retrieves the architecture specific spin lock alignment requirements for
3015 optimal spin lock performance.
3017 This function retrieves the spin lock alignment requirements for optimal
3018 performance on a given CPU architecture. The spin lock alignment must be a
3019 power of two and is returned by this function. If there are no alignment
3020 requirements, then 1 must be returned. The spin lock synchronization
3021 functions must function correctly if the spin lock size and alignment values
3022 returned by this function are not used at all. These values are hints to the
3023 consumers of the spin lock synchronization functions to obtain optimal spin
3026 @return The architecture specific spin lock alignment.
3031 GetSpinLockProperties (
3037 Initializes a spin lock to the released state and returns the spin lock.
3039 This function initializes the spin lock specified by SpinLock to the released
3040 state, and returns SpinLock. Optimal performance can be achieved by calling
3041 GetSpinLockProperties() to determine the size and alignment requirements for
3044 If SpinLock is NULL, then ASSERT().
3046 @param SpinLock A pointer to the spin lock to initialize to the released
3049 @return SpinLock in release state.
3054 InitializeSpinLock (
3055 IN SPIN_LOCK
*SpinLock
3060 Waits until a spin lock can be placed in the acquired state.
3062 This function checks the state of the spin lock specified by SpinLock. If
3063 SpinLock is in the released state, then this function places SpinLock in the
3064 acquired state and returns SpinLock. Otherwise, this function waits
3065 indefinitely for the spin lock to be released, and then places it in the
3066 acquired state and returns SpinLock. All state transitions of SpinLock must
3067 be performed using MP safe mechanisms.
3069 If SpinLock is NULL, then ASSERT().
3070 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
3071 If PcdSpinLockTimeout is not zero, and SpinLock is can not be acquired in
3072 PcdSpinLockTimeout microseconds, then ASSERT().
3074 @param SpinLock A pointer to the spin lock to place in the acquired state.
3076 @return SpinLock accquired lock.
3082 IN SPIN_LOCK
*SpinLock
3087 Attempts to place a spin lock in the acquired state.
3089 This function checks the state of the spin lock specified by SpinLock. If
3090 SpinLock is in the released state, then this function places SpinLock in the
3091 acquired state and returns TRUE. Otherwise, FALSE is returned. All state
3092 transitions of SpinLock must be performed using MP safe mechanisms.
3094 If SpinLock is NULL, then ASSERT().
3095 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
3097 @param SpinLock A pointer to the spin lock to place in the acquired state.
3099 @retval TRUE SpinLock was placed in the acquired state.
3100 @retval FALSE SpinLock could not be acquired.
3105 AcquireSpinLockOrFail (
3106 IN SPIN_LOCK
*SpinLock
3111 Releases a spin lock.
3113 This function places the spin lock specified by SpinLock in the release state
3114 and returns SpinLock.
3116 If SpinLock is NULL, then ASSERT().
3117 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
3119 @param SpinLock A pointer to the spin lock to release.
3121 @return SpinLock released lock.
3127 IN SPIN_LOCK
*SpinLock
3132 Performs an atomic increment of an 32-bit unsigned integer.
3134 Performs an atomic increment of the 32-bit unsigned integer specified by
3135 Value and returns the incremented value. The increment operation must be
3136 performed using MP safe mechanisms. The state of the return value is not
3137 guaranteed to be MP safe.
3139 If Value is NULL, then ASSERT().
3141 @param Value A pointer to the 32-bit value to increment.
3143 @return The incremented value.
3148 InterlockedIncrement (
3154 Performs an atomic decrement of an 32-bit unsigned integer.
3156 Performs an atomic decrement of the 32-bit unsigned integer specified by
3157 Value and returns the decremented value. The decrement operation must be
3158 performed using MP safe mechanisms. The state of the return value is not
3159 guaranteed to be MP safe.
3161 If Value is NULL, then ASSERT().
3163 @param Value A pointer to the 32-bit value to decrement.
3165 @return The decremented value.
3170 InterlockedDecrement (
3176 Performs an atomic compare exchange operation on a 32-bit unsigned integer.
3178 Performs an atomic compare exchange operation on the 32-bit unsigned integer
3179 specified by Value. If Value is equal to CompareValue, then Value is set to
3180 ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,
3181 then Value is returned. The compare exchange operation must be performed using
3184 If Value is NULL, then ASSERT().
3186 @param Value A pointer to the 32-bit value for the compare exchange
3188 @param CompareValue 32-bit value used in compare operation.
3189 @param ExchangeValue 32-bit value used in exchange operation.
3191 @return The original *Value before exchange.
3196 InterlockedCompareExchange32 (
3197 IN OUT UINT32
*Value
,
3198 IN UINT32 CompareValue
,
3199 IN UINT32 ExchangeValue
3204 Performs an atomic compare exchange operation on a 64-bit unsigned integer.
3206 Performs an atomic compare exchange operation on the 64-bit unsigned integer specified
3207 by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and
3208 CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.
3209 The compare exchange operation must be performed using MP safe mechanisms.
3211 If Value is NULL, then ASSERT().
3213 @param Value A pointer to the 64-bit value for the compare exchange
3215 @param CompareValue 64-bit value used in compare operation.
3216 @param ExchangeValue 64-bit value used in exchange operation.
3218 @return The original *Value before exchange.
3223 InterlockedCompareExchange64 (
3224 IN OUT UINT64
*Value
,
3225 IN UINT64 CompareValue
,
3226 IN UINT64 ExchangeValue
3231 Performs an atomic compare exchange operation on a pointer value.
3233 Performs an atomic compare exchange operation on the pointer value specified
3234 by Value. If Value is equal to CompareValue, then Value is set to
3235 ExchangeValue and CompareValue is returned. If Value is not equal to
3236 CompareValue, then Value is returned. The compare exchange operation must be
3237 performed using MP safe mechanisms.
3239 If Value is NULL, then ASSERT().
3241 @param Value A pointer to the pointer value for the compare exchange
3243 @param CompareValue Pointer value used in compare operation.
3244 @param ExchangeValue Pointer value used in exchange operation.
3246 @return The original *Value before exchange.
3250 InterlockedCompareExchangePointer (
3251 IN OUT VOID
**Value
,
3252 IN VOID
*CompareValue
,
3253 IN VOID
*ExchangeValue
3258 // Base Library Checksum Functions
3262 Calculate the sum of all elements in a buffer in unit of UINT8.
3263 During calculation, the carry bits are dropped.
3265 This function calculates the sum of all elements in a buffer
3266 in unit of UINT8. The carry bits in result of addition are dropped.
3267 The result is returned as UINT8. If Length is Zero, then Zero is
3270 If Buffer is NULL, then ASSERT().
3271 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3273 @param Buffer Pointer to the buffer to carry out the sum operation.
3274 @param Length The size, in bytes, of Buffer .
3276 @return Sum The sum of Buffer with carry bits dropped during additions.
3282 IN CONST UINT8
*Buffer
,
3288 Returns the two's complement checksum of all elements in a buffer
3291 This function first calculates the sum of the 8-bit values in the
3292 buffer specified by Buffer and Length. The carry bits in the result
3293 of addition are dropped. Then, the two's complement of the sum is
3294 returned. If Length is 0, then 0 is returned.
3296 If Buffer is NULL, then ASSERT().
3297 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3300 @param Buffer Pointer to the buffer to carry out the checksum operation.
3301 @param Length The size, in bytes, of Buffer.
3303 @return Checksum The 2's complement checksum of Buffer.
3308 CalculateCheckSum8 (
3309 IN CONST UINT8
*Buffer
,
3315 Returns the sum of all elements in a buffer of 16-bit values. During
3316 calculation, the carry bits are dropped.
3318 This function calculates the sum of the 16-bit values in the buffer
3319 specified by Buffer and Length. The carry bits in result of addition are dropped.
3320 The 16-bit result is returned. If Length is 0, then 0 is returned.
3322 If Buffer is NULL, then ASSERT().
3323 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3324 If Length is not aligned on a 16-bit boundary, then ASSERT().
3325 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3327 @param Buffer Pointer to the buffer to carry out the sum operation.
3328 @param Length The size, in bytes, of Buffer.
3330 @return Sum The sum of Buffer with carry bits dropped during additions.
3336 IN CONST UINT16
*Buffer
,
3342 Returns the two's complement checksum of all elements in a buffer of
3345 This function first calculates the sum of the 16-bit values in the buffer
3346 specified by Buffer and Length. The carry bits in the result of addition
3347 are dropped. Then, the two's complement of the sum is returned. If Length
3348 is 0, then 0 is returned.
3350 If Buffer is NULL, then ASSERT().
3351 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3352 If Length is not aligned on a 16-bit boundary, then ASSERT().
3353 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3355 @param Buffer Pointer to the buffer to carry out the checksum operation.
3356 @param Length The size, in bytes, of Buffer.
3358 @return Checksum The 2's complement checksum of Buffer.
3363 CalculateCheckSum16 (
3364 IN CONST UINT16
*Buffer
,
3370 Returns the sum of all elements in a buffer of 32-bit values. During
3371 calculation, the carry bits are dropped.
3373 This function calculates the sum of the 32-bit values in the buffer
3374 specified by Buffer and Length. The carry bits in result of addition are dropped.
3375 The 32-bit result is returned. If Length is 0, then 0 is returned.
3377 If Buffer is NULL, then ASSERT().
3378 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3379 If Length is not aligned on a 32-bit boundary, then ASSERT().
3380 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3382 @param Buffer Pointer to the buffer to carry out the sum operation.
3383 @param Length The size, in bytes, of Buffer.
3385 @return Sum The sum of Buffer with carry bits dropped during additions.
3391 IN CONST UINT32
*Buffer
,
3397 Returns the two's complement checksum of all elements in a buffer of
3400 This function first calculates the sum of the 32-bit values in the buffer
3401 specified by Buffer and Length. The carry bits in the result of addition
3402 are dropped. Then, the two's complement of the sum is returned. If Length
3403 is 0, then 0 is returned.
3405 If Buffer is NULL, then ASSERT().
3406 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3407 If Length is not aligned on a 32-bit boundary, then ASSERT().
3408 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3410 @param Buffer Pointer to the buffer to carry out the checksum operation.
3411 @param Length The size, in bytes, of Buffer.
3413 @return Checksum The 2's complement checksum of Buffer.
3418 CalculateCheckSum32 (
3419 IN CONST UINT32
*Buffer
,
3425 Returns the sum of all elements in a buffer of 64-bit values. During
3426 calculation, the carry bits are dropped.
3428 This function calculates the sum of the 64-bit values in the buffer
3429 specified by Buffer and Length. The carry bits in result of addition are dropped.
3430 The 64-bit result is returned. If Length is 0, then 0 is returned.
3432 If Buffer is NULL, then ASSERT().
3433 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3434 If Length is not aligned on a 64-bit boundary, then ASSERT().
3435 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3437 @param Buffer Pointer to the buffer to carry out the sum operation.
3438 @param Length The size, in bytes, of Buffer.
3440 @return Sum The sum of Buffer with carry bits dropped during additions.
3446 IN CONST UINT64
*Buffer
,
3452 Returns the two's complement checksum of all elements in a buffer of
3455 This function first calculates the sum of the 64-bit values in the buffer
3456 specified by Buffer and Length. The carry bits in the result of addition
3457 are dropped. Then, the two's complement of the sum is returned. If Length
3458 is 0, then 0 is returned.
3460 If Buffer is NULL, then ASSERT().
3461 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3462 If Length is not aligned on a 64-bit boundary, then ASSERT().
3463 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3465 @param Buffer Pointer to the buffer to carry out the checksum operation.
3466 @param Length The size, in bytes, of Buffer.
3468 @return Checksum The 2's complement checksum of Buffer.
3473 CalculateCheckSum64 (
3474 IN CONST UINT64
*Buffer
,
3480 // Base Library CPU Functions
3484 (EFIAPI
*SWITCH_STACK_ENTRY_POINT
)(
3485 IN VOID
*Context1
, OPTIONAL
3486 IN VOID
*Context2 OPTIONAL
3491 Used to serialize load and store operations.
3493 All loads and stores that proceed calls to this function are guaranteed to be
3494 globally visible when this function returns.
3505 Saves the current CPU context that can be restored with a call to LongJump()
3508 Saves the current CPU context in the buffer specified by JumpBuffer and
3509 returns 0. The initial call to SetJump() must always return 0. Subsequent
3510 calls to LongJump() cause a non-zero value to be returned by SetJump().
3512 If JumpBuffer is NULL, then ASSERT().
3513 For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3515 @param JumpBuffer A pointer to CPU context buffer.
3517 @retval 0 Indicates a return from SetJump().
3523 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
3528 Restores the CPU context that was saved with SetJump().
3530 Restores the CPU context from the buffer specified by JumpBuffer. This
3531 function never returns to the caller. Instead is resumes execution based on
3532 the state of JumpBuffer.
3534 If JumpBuffer is NULL, then ASSERT().
3535 For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3536 If Value is 0, then ASSERT().
3538 @param JumpBuffer A pointer to CPU context buffer.
3539 @param Value The value to return when the SetJump() context is
3540 restored and must be non-zero.
3546 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
3552 Enables CPU interrupts.
3563 Disables CPU interrupts.
3574 Disables CPU interrupts and returns the interrupt state prior to the disable
3577 @retval TRUE CPU interrupts were enabled on entry to this call.
3578 @retval FALSE CPU interrupts were disabled on entry to this call.
3583 SaveAndDisableInterrupts (
3589 Enables CPU interrupts for the smallest window required to capture any
3595 EnableDisableInterrupts (
3601 Retrieves the current CPU interrupt state.
3603 Returns TRUE is interrupts are currently enabled. Otherwise
3606 @retval TRUE CPU interrupts are enabled.
3607 @retval FALSE CPU interrupts are disabled.
3618 Set the current CPU interrupt state.
3620 Sets the current CPU interrupt state to the state specified by
3621 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
3622 InterruptState is FALSE, then interrupts are disabled. InterruptState is
3625 @param InterruptState TRUE if interrupts should enabled. FALSE if
3626 interrupts should be disabled.
3628 @return InterruptState
3634 IN BOOLEAN InterruptState
3639 Requests CPU to pause for a short period of time.
3641 Requests CPU to pause for a short period of time. Typically used in MP
3642 systems to prevent memory starvation while waiting for a spin lock.
3653 Transfers control to a function starting with a new stack.
3655 Transfers control to the function specified by EntryPoint using the
3656 new stack specified by NewStack and passing in the parameters specified
3657 by Context1 and Context2. Context1 and Context2 are optional and may
3658 be NULL. The function EntryPoint must never return. This function
3659 supports a variable number of arguments following the NewStack parameter.
3660 These additional arguments are ignored on IA-32, x64, and EBC.
3661 IPF CPUs expect one additional parameter of type VOID * that specifies
3662 the new backing store pointer.
3664 If EntryPoint is NULL, then ASSERT().
3665 If NewStack is NULL, then ASSERT().
3667 @param EntryPoint A pointer to function to call with the new stack.
3668 @param Context1 A pointer to the context to pass into the EntryPoint
3670 @param Context2 A pointer to the context to pass into the EntryPoint
3672 @param NewStack A pointer to the new stack to use for the EntryPoint
3674 @param ... Extended parameters.
3681 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
3682 IN VOID
*Context1
, OPTIONAL
3683 IN VOID
*Context2
, OPTIONAL
3690 Generates a breakpoint on the CPU.
3692 Generates a breakpoint on the CPU. The breakpoint must be implemented such
3693 that code can resume normal execution after the breakpoint.
3704 Executes an infinite loop.
3706 Forces the CPU to execute an infinite loop. A debugger may be used to skip
3707 past the loop and the code that follows the loop must execute properly. This
3708 implies that the infinite loop must not cause the code that follow it to be
3719 #if defined (MDE_CPU_IPF)
3722 Flush a range of cache lines in the cache coherency domain of the calling
3725 Invalidates the cache lines specified by Address and Length. If Address is
3726 not aligned on a cache line boundary, then entire cache line containing
3727 Address is invalidated. If Address + Length is not aligned on a cache line
3728 boundary, then the entire instruction cache line containing Address + Length
3729 -1 is invalidated. This function may choose to invalidate the entire
3730 instruction cache if that is more efficient than invalidating the specified
3731 range. If Length is 0, the no instruction cache lines are invalidated.
3732 Address is returned.
3734 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
3736 @param Address The base address of the instruction lines to invalidate. If
3737 the CPU is in a physical addressing mode, then Address is a
3738 physical address. If the CPU is in a virtual addressing mode,
3739 then Address is a virtual address.
3741 @param Length The number of bytes to invalidate from the instruction cache.
3748 IpfFlushCacheRange (
3755 Executes a FC instruction
3756 Executes a FC instruction on the cache line specified by Address.
3757 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3758 An implementation may flush a larger region. This function is only available on IPF.
3760 @param Address The Address of cache line to be flushed.
3762 @return The address of FC instruction executed.
3773 Executes a FC.I instruction.
3774 Executes a FC.I 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.I instruction executed.
3791 Reads the current value of a Processor Identifier Register (CPUID).
3792 The Index of largest implemented CPUID (One less than the number of implemented CPUID
3793 registers) is determined by CPUID [3] bits {7:0}.
3794 No parameter checking is performed on Index. If the Index value is beyond the
3795 implemented CPUID register range, a Reserved Register/Field fault may occur. The caller
3796 must either guarantee that Index is valid, or the caller must set up fault handlers to
3797 catch the faults. This function is only available on IPF.
3799 @param Index The 8-bit Processor Identifier Register index to read.
3801 @return The current value of Processor Identifier Register specified by Index.
3812 Reads the current value of 64-bit Processor Status Register (PSR).
3813 This function is only available on IPF.
3815 @return The current value of PSR.
3826 Writes the current value of 64-bit Processor Status Register (PSR).
3827 No parameter checking is performed on Value. All bits of Value corresponding to
3828 reserved fields of PSR must be 0 or a Reserved Register/Field fault may occur. The caller must either guarantee that Value is valid, or the caller must set up fault handlers to catch the faults.
3829 This function is only available on IPF.
3831 @param Value The 64-bit value to write to PSR.
3833 @return The 64-bit value written to the PSR.
3844 Reads the current value of 64-bit Kernel Register #0 (KR0).
3845 This function is only available on IPF.
3847 @return The current value of KR0.
3858 Reads the current value of 64-bit Kernel Register #1 (KR1).
3859 This function is only available on IPF.
3861 @return The current value of KR1.
3872 Reads the current value of 64-bit Kernel Register #2 (KR2).
3873 This function is only available on IPF.
3875 @return The current value of KR2.
3886 Reads the current value of 64-bit Kernel Register #3 (KR3).
3887 This function is only available on IPF.
3889 @return The current value of KR3.
3900 Reads the current value of 64-bit Kernel Register #4 (KR4).
3901 This function is only available on IPF.
3903 @return The current value of KR4.
3914 Reads the current value of 64-bit Kernel Register #5 (KR5).
3915 This function is only available on IPF.
3917 @return The current value of KR5.
3928 Reads the current value of 64-bit Kernel Register #6 (KR6).
3929 This function is only available on IPF.
3931 @return The current value of KR6.
3942 Reads the current value of 64-bit Kernel Register #7 (KR7).
3943 This function is only available on IPF.
3945 @return The current value of KR7.
3956 Write the current value of 64-bit Kernel Register #0 (KR0).
3957 This function is only available on IPF.
3959 @param Value The 64-bit value to write to KR0.
3961 @return The 64-bit value written to the KR0.
3972 Write the current value of 64-bit Kernel Register #1 (KR1).
3973 This function is only available on IPF.
3975 @param Value The 64-bit value to write to KR1.
3977 @return The 64-bit value written to the KR1.
3988 Write the current value of 64-bit Kernel Register #2 (KR2).
3989 This function is only available on IPF.
3991 @param Value The 64-bit value to write to KR2.
3993 @return The 64-bit value written to the KR2.
4004 Write the current value of 64-bit Kernel Register #3 (KR3).
4005 This function is only available on IPF.
4007 @param Value The 64-bit value to write to KR3.
4009 @return The 64-bit value written to the KR3.
4020 Write the current value of 64-bit Kernel Register #4 (KR4).
4021 This function is only available on IPF.
4023 @param Value The 64-bit value to write to KR4.
4025 @return The 64-bit value written to the KR4.
4036 Write the current value of 64-bit Kernel Register #5 (KR5).
4037 This function is only available on IPF.
4039 @param Value The 64-bit value to write to KR5.
4041 @return The 64-bit value written to the KR5.
4052 Write the current value of 64-bit Kernel Register #6 (KR6).
4053 This function is only available on IPF.
4055 @param Value The 64-bit value to write to KR6.
4057 @return The 64-bit value written to the KR6.
4068 Write the current value of 64-bit Kernel Register #7 (KR7).
4069 This function is only available on IPF.
4071 @param Value The 64-bit value to write to KR7.
4073 @return The 64-bit value written to the KR7.
4084 Reads the current value of Interval Timer Counter Register (ITC).
4085 This function is only available on IPF.
4087 @return The current value of ITC.
4098 Reads the current value of Interval Timer Vector Register (ITV).
4099 This function is only available on IPF.
4101 @return The current value of ITV.
4112 Reads the current value of Interval Timer Match Register (ITM).
4113 This function is only available on IPF.
4115 @return The current value of ITM.
4125 Writes the current value of 64-bit Interval Timer Counter Register (ITC).
4126 This function is only available on IPF.
4128 @param Value The 64-bit value to write to ITC.
4130 @return The 64-bit value written to the ITC.
4141 Writes the current value of 64-bit Interval Timer Match Register (ITM).
4142 This function is only available on IPF.
4144 @param Value The 64-bit value to write to ITM.
4146 @return The 64-bit value written to the ITM.
4157 Writes the current value of 64-bit Interval Timer Vector Register (ITV).
4158 No parameter checking is performed on Value. All bits of Value corresponding to
4159 reserved fields of ITV must be 0 or a Reserved Register/Field fault may occur.
4160 The caller must either guarantee that Value is valid, or the caller must set up
4161 fault handlers to catch the faults.
4162 This function is only available on IPF.
4164 @param Value The 64-bit value to write to ITV.
4166 @return The 64-bit value written to the ITV.
4177 Reads the current value of Default Control Register (DCR).
4178 This function is only available on IPF.
4180 @return The current value of DCR.
4191 Reads the current value of Interruption Vector Address Register (IVA).
4192 This function is only available on IPF.
4194 @return The current value of IVA.
4204 Reads the current value of Page Table Address Register (PTA).
4205 This function is only available on IPF.
4207 @return The current value of PTA.
4218 Writes the current value of 64-bit Default Control Register (DCR).
4219 No parameter checking is performed on Value. All bits of Value corresponding to
4220 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4221 The caller must either guarantee that Value is valid, or the caller must set up
4222 fault handlers to catch the faults.
4223 This function is only available on IPF.
4225 @param Value The 64-bit value to write to DCR.
4227 @return The 64-bit value written to the DCR.
4238 Writes the current value of 64-bit Interruption Vector Address Register (IVA).
4239 The size of vector table is 32 K bytes and is 32 K bytes aligned
4240 the low 15 bits of Value is ignored when written.
4241 This function is only available on IPF.
4243 @param Value The 64-bit value to write to IVA.
4245 @return The 64-bit value written to the IVA.
4256 Writes the current value of 64-bit Page Table Address Register (PTA).
4257 No parameter checking is performed on Value. All bits of Value corresponding to
4258 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4259 The caller must either guarantee that Value is valid, or the caller must set up
4260 fault handlers to catch the faults.
4261 This function is only available on IPF.
4263 @param Value The 64-bit value to write to PTA.
4265 @return The 64-bit value written to the PTA.
4275 Reads the current value of Local Interrupt ID Register (LID).
4276 This function is only available on IPF.
4278 @return The current value of LID.
4289 Reads the current value of External Interrupt Vector Register (IVR).
4290 This function is only available on IPF.
4292 @return The current value of IVR.
4303 Reads the current value of Task Priority Register (TPR).
4304 This function is only available on IPF.
4306 @return The current value of TPR.
4317 Reads the current value of External Interrupt Request Register #0 (IRR0).
4318 This function is only available on IPF.
4320 @return The current value of IRR0.
4331 Reads the current value of External Interrupt Request Register #1 (IRR1).
4332 This function is only available on IPF.
4334 @return The current value of IRR1.
4345 Reads the current value of External Interrupt Request Register #2 (IRR2).
4346 This function is only available on IPF.
4348 @return The current value of IRR2.
4359 Reads the current value of External Interrupt Request Register #3 (IRR3).
4360 This function is only available on IPF.
4362 @return The current value of IRR3.
4373 Reads the current value of Performance Monitor Vector Register (PMV).
4374 This function is only available on IPF.
4376 @return The current value of PMV.
4387 Reads the current value of Corrected Machine Check Vector Register (CMCV).
4388 This function is only available on IPF.
4390 @return The current value of CMCV.
4401 Reads the current value of Local Redirection Register #0 (LRR0).
4402 This function is only available on IPF.
4404 @return The current value of LRR0.
4415 Reads the current value of Local Redirection Register #1 (LRR1).
4416 This function is only available on IPF.
4418 @return The current value of LRR1.
4429 Writes the current value of 64-bit Page Local Interrupt ID Register (LID).
4430 No parameter checking is performed on Value. All bits of Value corresponding to
4431 reserved fields of LID must be 0 or a Reserved Register/Field fault may occur.
4432 The caller must either guarantee that Value is valid, or the caller must set up
4433 fault handlers to catch the faults.
4434 This function is only available on IPF.
4436 @param Value The 64-bit value to write to LID.
4438 @return The 64-bit value written to the LID.
4449 Writes the current value of 64-bit Task Priority Register (TPR).
4450 No parameter checking is performed on Value. All bits of Value corresponding to
4451 reserved fields of TPR must be 0 or a Reserved Register/Field fault may occur.
4452 The caller must either guarantee that Value is valid, or the caller must set up
4453 fault handlers to catch the faults.
4454 This function is only available on IPF.
4456 @param Value The 64-bit value to write to TPR.
4458 @return The 64-bit value written to the TPR.
4469 Performs a write operation on End OF External Interrupt Register (EOI).
4470 Writes a value of 0 to the EOI Register. This function is only available on IPF.
4481 Writes the current value of 64-bit Performance Monitor Vector Register (PMV).
4482 No parameter checking is performed on Value. All bits of Value corresponding
4483 to reserved fields of PMV must be 0 or a Reserved Register/Field fault may occur.
4484 The caller must either guarantee that Value is valid, or the caller must set up
4485 fault handlers to catch the faults.
4486 This function is only available on IPF.
4488 @param Value The 64-bit value to write to PMV.
4490 @return The 64-bit value written to the PMV.
4501 Writes the current value of 64-bit Corrected Machine Check Vector Register (CMCV).
4502 No parameter checking is performed on Value. All bits of Value corresponding
4503 to reserved fields of CMCV must be 0 or a Reserved Register/Field fault may occur.
4504 The caller must either guarantee that Value is valid, or the caller must set up
4505 fault handlers to catch the faults.
4506 This function is only available on IPF.
4508 @param Value The 64-bit value to write to CMCV.
4510 @return The 64-bit value written to the CMCV.
4521 Writes the current value of 64-bit Local Redirection Register #0 (LRR0).
4522 No parameter checking is performed on Value. All bits of Value corresponding
4523 to reserved fields of LRR0 must be 0 or a Reserved Register/Field fault may occur.
4524 The caller must either guarantee that Value is valid, or the caller must set up
4525 fault handlers to catch the faults.
4526 This function is only available on IPF.
4528 @param Value The 64-bit value to write to LRR0.
4530 @return The 64-bit value written to the LRR0.
4541 Writes the current value of 64-bit Local Redirection Register #1 (LRR1).
4542 No parameter checking is performed on Value. All bits of Value corresponding
4543 to reserved fields of LRR1 must be 0 or a Reserved Register/Field fault may occur.
4544 The caller must either guarantee that Value is valid, or the caller must
4545 set up fault handlers to catch the faults.
4546 This function is only available on IPF.
4548 @param Value The 64-bit value to write to LRR1.
4550 @return The 64-bit value written to the LRR1.
4561 Reads the current value of Instruction Breakpoint Register (IBR).
4563 The Instruction Breakpoint Registers are used in pairs. The even numbered
4564 registers contain breakpoint addresses, and the odd numbered registers contain
4565 breakpoint mask conditions. At least 4 instruction registers pairs are implemented
4566 on all processor models. Implemented registers are contiguous starting with
4567 register 0. No parameter checking is performed on Index, and if the Index value
4568 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4569 occur. The caller must either guarantee that Index is valid, or the caller must
4570 set up fault handlers to catch the faults.
4571 This function is only available on IPF.
4573 @param Index The 8-bit Instruction Breakpoint Register index to read.
4575 @return The current value of Instruction Breakpoint Register specified by Index.
4586 Reads the current value of Data Breakpoint Register (DBR).
4588 The Data Breakpoint Registers are used in pairs. The even numbered registers
4589 contain breakpoint addresses, and odd numbered registers contain breakpoint
4590 mask conditions. At least 4 data registers pairs are implemented on all processor
4591 models. Implemented registers are contiguous starting with register 0.
4592 No parameter checking is performed on Index. If the Index value is beyond
4593 the implemented DBR register range, a Reserved Register/Field fault may occur.
4594 The caller must either guarantee that Index is valid, or the caller must set up
4595 fault handlers to catch the faults.
4596 This function is only available on IPF.
4598 @param Index The 8-bit Data Breakpoint Register index to read.
4600 @return The current value of Data Breakpoint Register specified by Index.
4611 Reads the current value of Performance Monitor Configuration Register (PMC).
4613 All processor implementations provide at least 4 performance counters
4614 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow
4615 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4616 additional implementation-dependent PMC and PMD to increase the number of
4617 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4618 register set is implementation dependent. No parameter checking is performed
4619 on Index. If the Index value is beyond the implemented PMC register range,
4620 zero value will be returned.
4621 This function is only available on IPF.
4623 @param Index The 8-bit Performance Monitor Configuration Register index to read.
4625 @return The current value of Performance Monitor Configuration Register
4637 Reads the current value of Performance Monitor Data Register (PMD).
4639 All processor implementations provide at least 4 performance counters
4640 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter
4641 overflow status registers (PMC [0]... PMC [3]). Processor implementations may
4642 provide additional implementation-dependent PMC and PMD to increase the number
4643 of 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4644 register set is implementation dependent. No parameter checking is performed
4645 on Index. If the Index value is beyond the implemented PMD register range,
4646 zero value will be returned.
4647 This function is only available on IPF.
4649 @param Index The 8-bit Performance Monitor Data Register index to read.
4651 @return The current value of Performance Monitor Data Register specified by Index.
4662 Writes the current value of 64-bit Instruction Breakpoint Register (IBR).
4664 Writes current value of Instruction Breakpoint Register specified by Index.
4665 The Instruction Breakpoint Registers are used in pairs. The even numbered
4666 registers contain breakpoint addresses, and odd numbered registers contain
4667 breakpoint mask conditions. At least 4 instruction registers pairs are implemented
4668 on all processor models. Implemented registers are contiguous starting with
4669 register 0. No parameter checking is performed on Index. If the Index value
4670 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4671 occur. The caller must either guarantee that Index is valid, or the caller must
4672 set up fault handlers to catch the faults.
4673 This function is only available on IPF.
4675 @param Index The 8-bit Instruction Breakpoint Register index to write.
4676 @param Value The 64-bit value to write to IBR.
4678 @return The 64-bit value written to the IBR.
4690 Writes the current value of 64-bit Data Breakpoint Register (DBR).
4692 Writes current value of Data Breakpoint Register specified by Index.
4693 The Data Breakpoint Registers are used in pairs. The even numbered registers
4694 contain breakpoint addresses, and odd numbered registers contain breakpoint
4695 mask conditions. At least 4 data registers pairs are implemented on all processor
4696 models. Implemented registers are contiguous starting with register 0. No parameter
4697 checking is performed on Index. If the Index value is beyond the implemented
4698 DBR register range, a Reserved Register/Field fault may occur. The caller must
4699 either guarantee that Index is valid, or the caller must set up fault handlers to
4701 This function is only available on IPF.
4703 @param Index The 8-bit Data Breakpoint Register index to write.
4704 @param Value The 64-bit value to write to DBR.
4706 @return The 64-bit value written to the DBR.
4718 Writes the current value of 64-bit Performance Monitor Configuration Register (PMC).
4720 Writes current value of Performance Monitor Configuration Register specified by Index.
4721 All processor implementations provide at least 4 performance counters
4722 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow status
4723 registers (PMC [0]... PMC [3]). Processor implementations may provide additional
4724 implementation-dependent PMC and PMD to increase the number of 'generic' performance
4725 counters (PMC/PMD pairs). The remainder of PMC and PMD register set is implementation
4726 dependent. No parameter checking is performed on Index. If the Index value is
4727 beyond the implemented PMC register range, the write is ignored.
4728 This function is only available on IPF.
4730 @param Index The 8-bit Performance Monitor Configuration Register index to write.
4731 @param Value The 64-bit value to write to PMC.
4733 @return The 64-bit value written to the PMC.
4745 Writes the current value of 64-bit Performance Monitor Data Register (PMD).
4747 Writes current value of Performance Monitor Data Register specified by Index.
4748 All processor implementations provide at least 4 performance counters
4749 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow
4750 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4751 additional implementation-dependent PMC and PMD to increase the number of 'generic'
4752 performance counters (PMC/PMD pairs). The remainder of PMC and PMD register set
4753 is implementation dependent. No parameter checking is performed on Index. If the
4754 Index value is beyond the implemented PMD register range, the write is ignored.
4755 This function is only available on IPF.
4757 @param Index The 8-bit Performance Monitor Data Register index to write.
4758 @param Value The 64-bit value to write to PMD.
4760 @return The 64-bit value written to the PMD.
4772 Reads the current value of 64-bit Global Pointer (GP).
4774 Reads and returns the current value of GP.
4775 This function is only available on IPF.
4777 @return The current value of GP.
4788 Write the current value of 64-bit Global Pointer (GP).
4790 Writes the current value of GP. The 64-bit value written to the GP is returned.
4791 No parameter checking is performed on Value.
4792 This function is only available on IPF.
4794 @param Value The 64-bit value to write to GP.
4796 @return The 64-bit value written to the GP.
4807 Reads the current value of 64-bit Stack Pointer (SP).
4809 Reads and returns the current value of SP.
4810 This function is only available on IPF.
4812 @return The current value of SP.
4823 Determines if the CPU is currently executing in virtual, physical, or mixed mode.
4825 Determines the current execution mode of the CPU.
4826 If the CPU is in virtual mode(PSR.RT=1, PSR.DT=1, PSR.IT=1), then 1 is returned.
4827 If the CPU is in physical mode(PSR.RT=0, PSR.DT=0, PSR.IT=0), then 0 is returned.
4828 If the CPU is not in physical mode or virtual mode, then it is in mixed mode,
4830 This function is only available on IPF.
4832 @return 1 The CPU is in virtual mode.
4833 @return 0 The CPU is in physical mode.
4834 @return -1 The CPU is in mixed mode.
4845 Makes a PAL procedure call.
4847 This is a wrapper function to make a PAL procedure call. Based on the Index
4848 value this API will make static or stacked PAL call. The following table
4849 describes the usage of PAL Procedure Index Assignment. Architected procedures
4850 may be designated as required or optional. If a PAL procedure is specified
4851 as optional, a unique return code of 0xFFFFFFFFFFFFFFFF is returned in the
4852 Status field of the PAL_CALL_RETURN structure.
4853 This indicates that the procedure is not present in this PAL implementation.
4854 It is the caller's responsibility to check for this return code after calling
4855 any optional PAL procedure.
4856 No parameter checking is performed on the 5 input parameters, but there are
4857 some common rules that the caller should follow when making a PAL call. Any
4858 address passed to PAL as buffers for return parameters must be 8-byte aligned.
4859 Unaligned addresses may cause undefined results. For those parameters defined
4860 as reserved or some fields defined as reserved must be zero filled or the invalid
4861 argument return value may be returned or undefined result may occur during the
4862 execution of the procedure. If the PalEntryPoint does not point to a valid
4863 PAL entry point then the system behavior is undefined. This function is only
4866 @param PalEntryPoint The PAL procedure calls entry point.
4867 @param Index The PAL procedure Index number.
4868 @param Arg2 The 2nd parameter for PAL procedure calls.
4869 @param Arg3 The 3rd parameter for PAL procedure calls.
4870 @param Arg4 The 4th parameter for PAL procedure calls.
4872 @return structure returned from the PAL Call procedure, including the status and return value.
4878 IN UINT64 PalEntryPoint
,
4887 Transfers control to a function starting with a new stack.
4889 Transfers control to the function specified by EntryPoint using the new stack
4890 specified by NewStack and passing in the parameters specified by Context1 and
4891 Context2. Context1 and Context2 are optional and may be NULL. The function
4892 EntryPoint must never return.
4894 If EntryPoint is NULL, then ASSERT().
4895 If NewStack is NULL, then ASSERT().
4897 @param EntryPoint A pointer to function to call with the new stack.
4898 @param Context1 A pointer to the context to pass into the EntryPoint
4900 @param Context2 A pointer to the context to pass into the EntryPoint
4902 @param NewStack A pointer to the new stack to use for the EntryPoint
4904 @param NewBsp A pointer to the new memory location for RSE backing
4910 AsmSwitchStackAndBackingStore (
4911 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
4912 IN VOID
*Context1
, OPTIONAL
4913 IN VOID
*Context2
, OPTIONAL
4920 // Bugbug: This call should be removed after
4921 // the PalCall Instance issue has been fixed.
4924 Performs a PAL call using static calling convention.
4926 An internal function to perform a PAL call using static calling convention.
4928 @param PalEntryPoint The entry point address of PAL. The address in ar.kr5
4929 would be used if this parameter were NULL on input.
4930 @param Arg1 The first argument of a PAL call.
4931 @param Arg2 The second argument of a PAL call.
4932 @param Arg3 The third argument of a PAL call.
4933 @param Arg4 The fourth argument of a PAL call.
4935 @return The values returned in r8, r9, r10 and r11.
4940 IN CONST VOID
*PalEntryPoint
,
4948 #elif defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
4950 // IA32 and X64 Specific Functions
4953 // Byte packed structure for 16-bit Real Mode EFLAGS
4957 UINT32 CF
:1; // Carry Flag
4958 UINT32 Reserved_0
:1; // Reserved
4959 UINT32 PF
:1; // Parity Flag
4960 UINT32 Reserved_1
:1; // Reserved
4961 UINT32 AF
:1; // Auxiliary Carry Flag
4962 UINT32 Reserved_2
:1; // Reserved
4963 UINT32 ZF
:1; // Zero Flag
4964 UINT32 SF
:1; // Sign Flag
4965 UINT32 TF
:1; // Trap Flag
4966 UINT32 IF
:1; // Interrupt Enable Flag
4967 UINT32 DF
:1; // Direction Flag
4968 UINT32 OF
:1; // Overflow Flag
4969 UINT32 IOPL
:2; // I/O Privilege Level
4970 UINT32 NT
:1; // Nested Task
4971 UINT32 Reserved_3
:1; // Reserved
4977 // Byte packed structure for EFLAGS/RFLAGS
4979 // 64-bits on X64. The upper 32-bits on X64 are reserved
4983 UINT32 CF
:1; // Carry Flag
4984 UINT32 Reserved_0
:1; // Reserved
4985 UINT32 PF
:1; // Parity Flag
4986 UINT32 Reserved_1
:1; // Reserved
4987 UINT32 AF
:1; // Auxiliary Carry Flag
4988 UINT32 Reserved_2
:1; // Reserved
4989 UINT32 ZF
:1; // Zero Flag
4990 UINT32 SF
:1; // Sign Flag
4991 UINT32 TF
:1; // Trap Flag
4992 UINT32 IF
:1; // Interrupt Enable Flag
4993 UINT32 DF
:1; // Direction Flag
4994 UINT32 OF
:1; // Overflow Flag
4995 UINT32 IOPL
:2; // I/O Privilege Level
4996 UINT32 NT
:1; // Nested Task
4997 UINT32 Reserved_3
:1; // Reserved
4998 UINT32 RF
:1; // Resume Flag
4999 UINT32 VM
:1; // Virtual 8086 Mode
5000 UINT32 AC
:1; // Alignment Check
5001 UINT32 VIF
:1; // Virtual Interrupt Flag
5002 UINT32 VIP
:1; // Virtual Interrupt Pending
5003 UINT32 ID
:1; // ID Flag
5004 UINT32 Reserved_4
:10; // Reserved
5010 // Byte packed structure for Control Register 0 (CR0)
5012 // 64-bits on X64. The upper 32-bits on X64 are reserved
5016 UINT32 PE
:1; // Protection Enable
5017 UINT32 MP
:1; // Monitor Coprocessor
5018 UINT32 EM
:1; // Emulation
5019 UINT32 TS
:1; // Task Switched
5020 UINT32 ET
:1; // Extension Type
5021 UINT32 NE
:1; // Numeric Error
5022 UINT32 Reserved_0
:10; // Reserved
5023 UINT32 WP
:1; // Write Protect
5024 UINT32 Reserved_1
:1; // Reserved
5025 UINT32 AM
:1; // Alignment Mask
5026 UINT32 Reserved_2
:10; // Reserved
5027 UINT32 NW
:1; // Mot Write-through
5028 UINT32 CD
:1; // Cache Disable
5029 UINT32 PG
:1; // Paging
5035 // Byte packed structure for Control Register 4 (CR4)
5037 // 64-bits on X64. The upper 32-bits on X64 are reserved
5041 UINT32 VME
:1; // Virtual-8086 Mode Extensions
5042 UINT32 PVI
:1; // Protected-Mode Virtual Interrupts
5043 UINT32 TSD
:1; // Time Stamp Disable
5044 UINT32 DE
:1; // Debugging Extensions
5045 UINT32 PSE
:1; // Page Size Extensions
5046 UINT32 PAE
:1; // Physical Address Extension
5047 UINT32 MCE
:1; // Machine Check Enable
5048 UINT32 PGE
:1; // Page Global Enable
5049 UINT32 PCE
:1; // Performance Monitoring Counter
5051 UINT32 OSFXSR
:1; // Operating System Support for
5052 // FXSAVE and FXRSTOR instructions
5053 UINT32 OSXMMEXCPT
:1; // Operating System Support for
5054 // Unmasked SIMD Floating Point
5056 UINT32 Reserved_0
:2; // Reserved
5057 UINT32 VMXE
:1; // VMX Enable
5058 UINT32 Reserved_1
:18; // Reseved
5064 // Byte packed structure for an IDTR, GDTR, LDTR descriptor
5065 /// @bug How to make this structure byte-packed in a compiler independent way?
5074 #define IA32_IDT_GATE_TYPE_TASK 0x85
5075 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
5076 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
5077 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
5078 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
5081 // Byte packed structure for an Interrupt Gate Descriptor
5085 UINT32 OffsetLow
:16; // Offset bits 15..0
5086 UINT32 Selector
:16; // Selector
5087 UINT32 Reserved_0
:8; // Reserved
5088 UINT32 GateType
:8; // Gate Type. See #defines above
5089 UINT32 OffsetHigh
:16; // Offset bits 31..16
5092 } IA32_IDT_GATE_DESCRIPTOR
;
5095 // Byte packed structure for an FP/SSE/SSE2 context
5102 // Structures for the 16-bit real mode thunks
5155 IA32_EFLAGS32 EFLAGS
;
5165 } IA32_REGISTER_SET
;
5168 // Byte packed structure for an 16-bit real mode thunks
5171 IA32_REGISTER_SET
*RealModeState
;
5172 VOID
*RealModeBuffer
;
5173 UINT32 RealModeBufferSize
;
5174 UINT32 ThunkAttributes
;
5177 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
5178 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
5179 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
5182 Retrieves CPUID information.
5184 Executes the CPUID instruction with EAX set to the value specified by Index.
5185 This function always returns Index.
5186 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5187 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5188 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5189 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5190 This function is only available on IA-32 and X64.
5192 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
5194 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
5195 instruction. This is an optional parameter that may be NULL.
5196 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
5197 instruction. This is an optional parameter that may be NULL.
5198 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
5199 instruction. This is an optional parameter that may be NULL.
5200 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
5201 instruction. This is an optional parameter that may be NULL.
5210 OUT UINT32
*Eax
, OPTIONAL
5211 OUT UINT32
*Ebx
, OPTIONAL
5212 OUT UINT32
*Ecx
, OPTIONAL
5213 OUT UINT32
*Edx OPTIONAL
5218 Retrieves CPUID information using an extended leaf identifier.
5220 Executes the CPUID instruction with EAX set to the value specified by Index
5221 and ECX set to the value specified by SubIndex. This function always returns
5222 Index. This function is only available on IA-32 and x64.
5224 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5225 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5226 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5227 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5229 @param Index The 32-bit value to load into EAX prior to invoking the
5231 @param SubIndex The 32-bit value to load into ECX prior to invoking the
5233 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
5234 instruction. This is an optional parameter that may be
5236 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
5237 instruction. This is an optional parameter that may be
5239 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
5240 instruction. This is an optional parameter that may be
5242 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
5243 instruction. This is an optional parameter that may be
5254 OUT UINT32
*Eax
, OPTIONAL
5255 OUT UINT32
*Ebx
, OPTIONAL
5256 OUT UINT32
*Ecx
, OPTIONAL
5257 OUT UINT32
*Edx OPTIONAL
5262 Returns the lower 32-bits of a Machine Specific Register(MSR).
5264 Reads and returns the lower 32-bits of the MSR specified by Index.
5265 No parameter checking is performed on Index, and some Index values may cause
5266 CPU exceptions. The caller must either guarantee that Index is valid, or the
5267 caller must set up exception handlers to catch the exceptions. This function
5268 is only available on IA-32 and X64.
5270 @param Index The 32-bit MSR index to read.
5272 @return The lower 32 bits of the MSR identified by Index.
5283 Zero-extend a 32-bit value and writes it to a Machine Specific Register(MSR).
5285 Writes the 32-bit value specified by Value to the MSR specified by Index. The
5286 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
5287 the MSR is returned. No parameter checking is performed on Index or Value,
5288 and some of these may cause CPU exceptions. The caller must either guarantee
5289 that Index and Value are valid, or the caller must establish proper exception
5290 handlers. This function is only available on IA-32 and X64.
5292 @param Index The 32-bit MSR index to write.
5293 @param Value The 32-bit value to write to the MSR.
5307 Reads a 64-bit MSR, performs a bitwise inclusive OR on the lower 32-bits, and
5308 writes the result back to the 64-bit MSR.
5310 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
5311 between the lower 32-bits of the read result and the value specified by
5312 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
5313 32-bits of the value written to the MSR is returned. No parameter checking is
5314 performed on Index or OrData, and some of these may cause CPU exceptions. The
5315 caller must either guarantee that Index and OrData are valid, or the caller
5316 must establish proper exception handlers. This function is only available on
5319 @param Index The 32-bit MSR index to write.
5320 @param OrData The value to OR with the read value from the MSR.
5322 @return The lower 32-bit value written to the MSR.
5334 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
5335 the result back to the 64-bit MSR.
5337 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5338 lower 32-bits of the read result and the value specified by AndData, and
5339 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
5340 the value written to the MSR is returned. No parameter checking is performed
5341 on Index or AndData, and some of these may cause CPU exceptions. The caller
5342 must either guarantee that Index and AndData are valid, or the caller must
5343 establish proper exception handlers. This function is only available on IA-32
5346 @param Index The 32-bit MSR index to write.
5347 @param AndData The value to AND with the read value from the MSR.
5349 @return The lower 32-bit value written to the MSR.
5361 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive OR
5362 on the lower 32-bits, and writes the result back to the 64-bit MSR.
5364 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5365 lower 32-bits of the read result and the value specified by AndData
5366 preserving the upper 32-bits, performs a bitwise inclusive OR between the
5367 result of the AND operation and the value specified by OrData, and writes the
5368 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
5369 written to the MSR is returned. No parameter checking is performed on Index,
5370 AndData, or OrData, and some of these may cause CPU exceptions. The caller
5371 must either guarantee that Index, AndData, and OrData are valid, or the
5372 caller must establish proper exception handlers. This function is only
5373 available on IA-32 and X64.
5375 @param Index The 32-bit MSR index to write.
5376 @param AndData The value to AND with the read value from the MSR.
5377 @param OrData The value to OR with the result of the AND operation.
5379 @return The lower 32-bit value written to the MSR.
5392 Reads a bit field of an MSR.
5394 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
5395 specified by the StartBit and the EndBit. The value of the bit field is
5396 returned. The caller must either guarantee that Index is valid, or the caller
5397 must set up exception handlers to catch the exceptions. This function is only
5398 available on IA-32 and X64.
5400 If StartBit is greater than 31, then ASSERT().
5401 If EndBit is greater than 31, then ASSERT().
5402 If EndBit is less than StartBit, then ASSERT().
5404 @param Index The 32-bit MSR index to read.
5405 @param StartBit The ordinal of the least significant bit in the bit field.
5407 @param EndBit The ordinal of the most significant bit in the bit field.
5410 @return The bit field read from the MSR.
5415 AsmMsrBitFieldRead32 (
5423 Writes a bit field to an MSR.
5425 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
5426 field is specified by the StartBit and the EndBit. All other bits in the
5427 destination MSR are preserved. The lower 32-bits of the MSR written is
5428 returned. Extra left bits in Value are stripped. The caller must either
5429 guarantee that Index and the data written is valid, or the caller must set up
5430 exception handlers to catch the exceptions. This function is only available
5433 If StartBit is greater than 31, then ASSERT().
5434 If EndBit is greater than 31, then ASSERT().
5435 If EndBit is less than StartBit, then ASSERT().
5437 @param Index The 32-bit MSR index to write.
5438 @param StartBit The ordinal of the least significant bit in the bit field.
5440 @param EndBit The ordinal of the most significant bit in the bit field.
5442 @param Value New value of the bit field.
5444 @return The lower 32-bit of the value written to the MSR.
5449 AsmMsrBitFieldWrite32 (
5458 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
5459 result back to the bit field in the 64-bit MSR.
5461 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
5462 between the read result and the value specified by OrData, and writes the
5463 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
5464 written to the MSR are returned. Extra left bits in OrData are stripped. The
5465 caller must either guarantee that Index and the data written is valid, or
5466 the caller must set up exception handlers to catch the exceptions. This
5467 function is only available on IA-32 and X64.
5469 If StartBit is greater than 31, then ASSERT().
5470 If EndBit is greater than 31, then ASSERT().
5471 If EndBit is less than StartBit, then ASSERT().
5473 @param Index The 32-bit MSR index to write.
5474 @param StartBit The ordinal of the least significant bit in the bit field.
5476 @param EndBit The ordinal of the most significant bit in the bit field.
5478 @param OrData The value to OR with the read value from the MSR.
5480 @return The lower 32-bit of the value written to the MSR.
5485 AsmMsrBitFieldOr32 (
5494 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5495 result back to the bit field in the 64-bit MSR.
5497 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5498 read result and the value specified by AndData, and writes the result to the
5499 64-bit MSR specified by Index. The lower 32-bits of the value written to the
5500 MSR are returned. Extra left bits in AndData are stripped. The caller must
5501 either guarantee that Index and the data written is valid, or the caller must
5502 set up exception handlers to catch the exceptions. This function is only
5503 available on IA-32 and X64.
5505 If StartBit is greater than 31, then ASSERT().
5506 If EndBit is greater than 31, then ASSERT().
5507 If EndBit is less than StartBit, then ASSERT().
5509 @param Index The 32-bit MSR index to write.
5510 @param StartBit The ordinal of the least significant bit in the bit field.
5512 @param EndBit The ordinal of the most significant bit in the bit field.
5514 @param AndData The value to AND with the read value from the MSR.
5516 @return The lower 32-bit of the value written to the MSR.
5521 AsmMsrBitFieldAnd32 (
5530 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5531 bitwise inclusive OR, and writes the result back to the bit field in the
5534 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
5535 bitwise inclusive OR between the read result and the value specified by
5536 AndData, and writes the result to the 64-bit MSR specified by Index. The
5537 lower 32-bits of the value written to the MSR are returned. Extra left bits
5538 in both AndData and OrData are stripped. The caller must either guarantee
5539 that Index and the data written is valid, or the caller must set up exception
5540 handlers to catch the exceptions. This function is only available on IA-32
5543 If StartBit is greater than 31, then ASSERT().
5544 If EndBit is greater than 31, then ASSERT().
5545 If EndBit is less than StartBit, then ASSERT().
5547 @param Index The 32-bit MSR index to write.
5548 @param StartBit The ordinal of the least significant bit in the bit field.
5550 @param EndBit The ordinal of the most significant bit in the bit field.
5552 @param AndData The value to AND with the read value from the MSR.
5553 @param OrData The value to OR with the result of the AND operation.
5555 @return The lower 32-bit of the value written to the MSR.
5560 AsmMsrBitFieldAndThenOr32 (
5570 Returns a 64-bit Machine Specific Register(MSR).
5572 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
5573 performed on Index, and some Index values may cause CPU exceptions. The
5574 caller must either guarantee that Index is valid, or the caller must set up
5575 exception handlers to catch the exceptions. This function is only available
5578 @param Index The 32-bit MSR index to read.
5580 @return The value of the MSR identified by Index.
5591 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
5594 Writes the 64-bit value specified by Value to the MSR specified by Index. The
5595 64-bit value written to the MSR is returned. No parameter checking is
5596 performed on Index or Value, and some of these may cause CPU exceptions. The
5597 caller must either guarantee that Index and Value are valid, or the caller
5598 must establish proper exception handlers. This function is only available on
5601 @param Index The 32-bit MSR index to write.
5602 @param Value The 64-bit value to write to the MSR.
5616 Reads a 64-bit MSR, performs a bitwise inclusive OR, and writes the result
5617 back to the 64-bit MSR.
5619 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
5620 between the read result and the value specified by OrData, and writes the
5621 result to the 64-bit MSR specified by Index. The value written to the MSR is
5622 returned. No parameter checking is performed on Index or OrData, and some of
5623 these may cause CPU exceptions. The caller must either guarantee that Index
5624 and OrData are valid, or the caller must establish proper exception handlers.
5625 This function is only available on IA-32 and X64.
5627 @param Index The 32-bit MSR index to write.
5628 @param OrData The value to OR with the read value from the MSR.
5630 @return The value written back to the MSR.
5642 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
5645 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5646 read result and the value specified by OrData, and writes the result to the
5647 64-bit MSR specified by Index. The value written to the MSR is returned. No
5648 parameter checking is performed on Index or OrData, and some of these may
5649 cause CPU exceptions. The caller must either guarantee that Index and OrData
5650 are valid, or the caller must establish proper exception handlers. This
5651 function is only available on IA-32 and X64.
5653 @param Index The 32-bit MSR index to write.
5654 @param AndData The value to AND with the read value from the MSR.
5656 @return The value written back to the MSR.
5668 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive
5669 OR, and writes the result back to the 64-bit MSR.
5671 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
5672 result and the value specified by AndData, performs a bitwise inclusive OR
5673 between the result of the AND operation and the value specified by OrData,
5674 and writes the result to the 64-bit MSR specified by Index. The value written
5675 to the MSR is returned. No parameter checking is performed on Index, AndData,
5676 or OrData, and some of these may cause CPU exceptions. The caller must either
5677 guarantee that Index, AndData, and OrData are valid, or the caller must
5678 establish proper exception handlers. This function is only available on IA-32
5681 @param Index The 32-bit MSR index to write.
5682 @param AndData The value to AND with the read value from the MSR.
5683 @param OrData The value to OR with the result of the AND operation.
5685 @return The value written back to the MSR.
5698 Reads a bit field of an MSR.
5700 Reads the bit field in the 64-bit MSR. The bit field is specified by the
5701 StartBit and the EndBit. The value of the bit field is returned. The caller
5702 must either guarantee that Index is valid, or the caller must set up
5703 exception handlers to catch the exceptions. This function is only available
5706 If StartBit is greater than 63, then ASSERT().
5707 If EndBit is greater than 63, then ASSERT().
5708 If EndBit is less than StartBit, then ASSERT().
5710 @param Index The 32-bit MSR index to read.
5711 @param StartBit The ordinal of the least significant bit in the bit field.
5713 @param EndBit The ordinal of the most significant bit in the bit field.
5716 @return The value read from the MSR.
5721 AsmMsrBitFieldRead64 (
5729 Writes a bit field to an MSR.
5731 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
5732 the StartBit and the EndBit. All other bits in the destination MSR are
5733 preserved. The MSR written is returned. Extra left bits in Value are
5734 stripped. The caller must either guarantee that Index and the data written is
5735 valid, or the caller must set up exception handlers to catch the exceptions.
5736 This function is only available on IA-32 and X64.
5738 If StartBit is greater than 63, then ASSERT().
5739 If EndBit is greater than 63, then ASSERT().
5740 If EndBit is less than StartBit, then ASSERT().
5742 @param Index The 32-bit MSR index to write.
5743 @param StartBit The ordinal of the least significant bit in the bit field.
5745 @param EndBit The ordinal of the most significant bit in the bit field.
5747 @param Value New value of the bit field.
5749 @return The value written back to the MSR.
5754 AsmMsrBitFieldWrite64 (
5763 Reads a bit field in a 64-bit MSR, performs a bitwise inclusive OR, and
5764 writes the result back to the bit field in the 64-bit MSR.
5766 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
5767 between the read result and the value specified by OrData, and writes the
5768 result to the 64-bit MSR specified by Index. The value written to the MSR is
5769 returned. Extra left bits in OrData are stripped. The caller must either
5770 guarantee that Index and the data written is valid, or the caller must set up
5771 exception handlers to catch the exceptions. This function is only available
5774 If StartBit is greater than 63, then ASSERT().
5775 If EndBit is greater than 63, then ASSERT().
5776 If EndBit is less than StartBit, then ASSERT().
5778 @param Index The 32-bit MSR index to write.
5779 @param StartBit The ordinal of the least significant bit in the bit field.
5781 @param EndBit The ordinal of the most significant bit in the bit field.
5783 @param OrData The value to OR with the read value from the bit field.
5785 @return The value written back to the MSR.
5790 AsmMsrBitFieldOr64 (
5799 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5800 result back to the bit field in the 64-bit MSR.
5802 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5803 read result and the value specified by AndData, and writes the result to the
5804 64-bit MSR specified by Index. The value written to the MSR is returned.
5805 Extra left bits in AndData are stripped. The caller must either guarantee
5806 that Index and the data written is valid, or the caller must set up exception
5807 handlers to catch the exceptions. This function is only available on IA-32
5810 If StartBit is greater than 63, then ASSERT().
5811 If EndBit is greater than 63, then ASSERT().
5812 If EndBit is less than StartBit, then ASSERT().
5814 @param Index The 32-bit MSR index to write.
5815 @param StartBit The ordinal of the least significant bit in the bit field.
5817 @param EndBit The ordinal of the most significant bit in the bit field.
5819 @param AndData The value to AND with the read value from the bit field.
5821 @return The value written back to the MSR.
5826 AsmMsrBitFieldAnd64 (
5835 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5836 bitwise inclusive OR, and writes the result back to the bit field in the
5839 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
5840 a bitwise inclusive OR between the read result and the value specified by
5841 AndData, and writes the result to the 64-bit MSR specified by Index. The
5842 value written to the MSR is returned. Extra left bits in both AndData and
5843 OrData are stripped. The caller must either guarantee that Index and the data
5844 written is valid, or the caller must set up exception handlers to catch the
5845 exceptions. This function is only available on IA-32 and X64.
5847 If StartBit is greater than 63, then ASSERT().
5848 If EndBit is greater than 63, then ASSERT().
5849 If EndBit is less than StartBit, then ASSERT().
5851 @param Index The 32-bit MSR index to write.
5852 @param StartBit The ordinal of the least significant bit in the bit field.
5854 @param EndBit The ordinal of the most significant bit in the bit field.
5856 @param AndData The value to AND with the read value from the bit field.
5857 @param OrData The value to OR with the result of the AND operation.
5859 @return The value written back to the MSR.
5864 AsmMsrBitFieldAndThenOr64 (
5874 Reads the current value of the EFLAGS register.
5876 Reads and returns the current value of the EFLAGS register. This function is
5877 only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a
5878 64-bit value on X64.
5880 @return EFLAGS on IA-32 or RFLAGS on X64.
5891 Reads the current value of the Control Register 0 (CR0).
5893 Reads and returns the current value of CR0. This function is only available
5894 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5897 @return The value of the Control Register 0 (CR0).
5908 Reads the current value of the Control Register 2 (CR2).
5910 Reads and returns the current value of CR2. This function is only available
5911 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5914 @return The value of the Control Register 2 (CR2).
5925 Reads the current value of the Control Register 3 (CR3).
5927 Reads and returns the current value of CR3. This function is only available
5928 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5931 @return The value of the Control Register 3 (CR3).
5942 Reads the current value of the Control Register 4 (CR4).
5944 Reads and returns the current value of CR4. This function is only available
5945 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5948 @return The value of the Control Register 4 (CR4).
5959 Writes a value to Control Register 0 (CR0).
5961 Writes and returns a new value to CR0. This function is only available on
5962 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
5964 @param Cr0 The value to write to CR0.
5966 @return The value written to CR0.
5977 Writes a value to Control Register 2 (CR2).
5979 Writes and returns a new value to CR2. This function is only available on
5980 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
5982 @param Cr2 The value to write to CR2.
5984 @return The value written to CR2.
5995 Writes a value to Control Register 3 (CR3).
5997 Writes and returns a new value to CR3. This function is only available on
5998 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6000 @param Cr3 The value to write to CR3.
6002 @return The value written to CR3.
6013 Writes a value to Control Register 4 (CR4).
6015 Writes and returns a new value to CR4. This function is only available on
6016 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6018 @param Cr4 The value to write to CR4.
6020 @return The value written to CR4.
6031 Reads the current value of Debug Register 0 (DR0).
6033 Reads and returns the current value of DR0. This function is only available
6034 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6037 @return The value of Debug Register 0 (DR0).
6048 Reads the current value of Debug Register 1 (DR1).
6050 Reads and returns the current value of DR1. This function is only available
6051 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6054 @return The value of Debug Register 1 (DR1).
6065 Reads the current value of Debug Register 2 (DR2).
6067 Reads and returns the current value of DR2. This function is only available
6068 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6071 @return The value of Debug Register 2 (DR2).
6082 Reads the current value of Debug Register 3 (DR3).
6084 Reads and returns the current value of DR3. This function is only available
6085 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6088 @return The value of Debug Register 3 (DR3).
6099 Reads the current value of Debug Register 4 (DR4).
6101 Reads and returns the current value of DR4. This function is only available
6102 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6105 @return The value of Debug Register 4 (DR4).
6116 Reads the current value of Debug Register 5 (DR5).
6118 Reads and returns the current value of DR5. This function is only available
6119 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6122 @return The value of Debug Register 5 (DR5).
6133 Reads the current value of Debug Register 6 (DR6).
6135 Reads and returns the current value of DR6. This function is only available
6136 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6139 @return The value of Debug Register 6 (DR6).
6150 Reads the current value of Debug Register 7 (DR7).
6152 Reads and returns the current value of DR7. This function is only available
6153 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6156 @return The value of Debug Register 7 (DR7).
6167 Writes a value to Debug Register 0 (DR0).
6169 Writes and returns a new value to DR0. This function is only available on
6170 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6172 @param Dr0 The value to write to Dr0.
6174 @return The value written to Debug Register 0 (DR0).
6185 Writes a value to Debug Register 1 (DR1).
6187 Writes and returns a new value to DR1. This function is only available on
6188 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6190 @param Dr1 The value to write to Dr1.
6192 @return The value written to Debug Register 1 (DR1).
6203 Writes a value to Debug Register 2 (DR2).
6205 Writes and returns a new value to DR2. This function is only available on
6206 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6208 @param Dr2 The value to write to Dr2.
6210 @return The value written to Debug Register 2 (DR2).
6221 Writes a value to Debug Register 3 (DR3).
6223 Writes and returns a new value to DR3. This function is only available on
6224 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6226 @param Dr3 The value to write to Dr3.
6228 @return The value written to Debug Register 3 (DR3).
6239 Writes a value to Debug Register 4 (DR4).
6241 Writes and returns a new value to DR4. This function is only available on
6242 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6244 @param Dr4 The value to write to Dr4.
6246 @return The value written to Debug Register 4 (DR4).
6257 Writes a value to Debug Register 5 (DR5).
6259 Writes and returns a new value to DR5. This function is only available on
6260 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6262 @param Dr5 The value to write to Dr5.
6264 @return The value written to Debug Register 5 (DR5).
6275 Writes a value to Debug Register 6 (DR6).
6277 Writes and returns a new value to DR6. This function is only available on
6278 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6280 @param Dr6 The value to write to Dr6.
6282 @return The value written to Debug Register 6 (DR6).
6293 Writes a value to Debug Register 7 (DR7).
6295 Writes and returns a new value to DR7. This function is only available on
6296 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6298 @param Dr7 The value to write to Dr7.
6300 @return The value written to Debug Register 7 (DR7).
6311 Reads the current value of Code Segment Register (CS).
6313 Reads and returns the current value of CS. This function is only available on
6316 @return The current value of CS.
6327 Reads the current value of Data Segment Register (DS).
6329 Reads and returns the current value of DS. This function is only available on
6332 @return The current value of DS.
6343 Reads the current value of Extra Segment Register (ES).
6345 Reads and returns the current value of ES. This function is only available on
6348 @return The current value of ES.
6359 Reads the current value of FS Data Segment Register (FS).
6361 Reads and returns the current value of FS. This function is only available on
6364 @return The current value of FS.
6375 Reads the current value of GS Data Segment Register (GS).
6377 Reads and returns the current value of GS. This function is only available on
6380 @return The current value of GS.
6391 Reads the current value of Stack Segment Register (SS).
6393 Reads and returns the current value of SS. This function is only available on
6396 @return The current value of SS.
6407 Reads the current value of Task Register (TR).
6409 Reads and returns the current value of TR. This function is only available on
6412 @return The current value of TR.
6423 Reads the current Global Descriptor Table Register(GDTR) descriptor.
6425 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
6426 function is only available on IA-32 and X64.
6428 If Gdtr is NULL, then ASSERT().
6430 @param Gdtr Pointer to a GDTR descriptor.
6436 OUT IA32_DESCRIPTOR
*Gdtr
6441 Writes the current Global Descriptor Table Register (GDTR) descriptor.
6443 Writes and the current GDTR descriptor specified by Gdtr. This function is
6444 only available on IA-32 and X64.
6446 If Gdtr is NULL, then ASSERT().
6448 @param Gdtr Pointer to a GDTR descriptor.
6454 IN CONST IA32_DESCRIPTOR
*Gdtr
6459 Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.
6461 Reads and returns the current IDTR descriptor and returns it in Idtr. This
6462 function is only available on IA-32 and X64.
6464 If Idtr is NULL, then ASSERT().
6466 @param Idtr Pointer to a IDTR descriptor.
6472 OUT IA32_DESCRIPTOR
*Idtr
6477 Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.
6479 Writes the current IDTR descriptor and returns it in Idtr. This function is
6480 only available on IA-32 and X64.
6482 If Idtr is NULL, then ASSERT().
6484 @param Idtr Pointer to a IDTR descriptor.
6490 IN CONST IA32_DESCRIPTOR
*Idtr
6495 Reads the current Local Descriptor Table Register(LDTR) selector.
6497 Reads and returns the current 16-bit LDTR descriptor value. This function is
6498 only available on IA-32 and X64.
6500 @return The current selector of LDT.
6511 Writes the current Local Descriptor Table Register (GDTR) selector.
6513 Writes and the current LDTR descriptor specified by Ldtr. This function is
6514 only available on IA-32 and X64.
6516 @param Ldtr 16-bit LDTR selector value.
6527 Save the current floating point/SSE/SSE2 context to a buffer.
6529 Saves the current floating point/SSE/SSE2 state to the buffer specified by
6530 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
6531 available on IA-32 and X64.
6533 If Buffer is NULL, then ASSERT().
6534 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6536 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
6542 OUT IA32_FX_BUFFER
*Buffer
6547 Restores the current floating point/SSE/SSE2 context from a buffer.
6549 Restores the current floating point/SSE/SSE2 state from the buffer specified
6550 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
6551 only available on IA-32 and X64.
6553 If Buffer is NULL, then ASSERT().
6554 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6555 If Buffer was not saved with AsmFxSave(), then ASSERT().
6557 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
6563 IN CONST IA32_FX_BUFFER
*Buffer
6568 Reads the current value of 64-bit MMX Register #0 (MM0).
6570 Reads and returns the current value of MM0. This function is only available
6573 @return The current value of MM0.
6584 Reads the current value of 64-bit MMX Register #1 (MM1).
6586 Reads and returns the current value of MM1. This function is only available
6589 @return The current value of MM1.
6600 Reads the current value of 64-bit MMX Register #2 (MM2).
6602 Reads and returns the current value of MM2. This function is only available
6605 @return The current value of MM2.
6616 Reads the current value of 64-bit MMX Register #3 (MM3).
6618 Reads and returns the current value of MM3. This function is only available
6621 @return The current value of MM3.
6632 Reads the current value of 64-bit MMX Register #4 (MM4).
6634 Reads and returns the current value of MM4. This function is only available
6637 @return The current value of MM4.
6648 Reads the current value of 64-bit MMX Register #5 (MM5).
6650 Reads and returns the current value of MM5. This function is only available
6653 @return The current value of MM5.
6664 Reads the current value of 64-bit MMX Register #6 (MM6).
6666 Reads and returns the current value of MM6. This function is only available
6669 @return The current value of MM6.
6680 Reads the current value of 64-bit MMX Register #7 (MM7).
6682 Reads and returns the current value of MM7. This function is only available
6685 @return The current value of MM7.
6696 Writes the current value of 64-bit MMX Register #0 (MM0).
6698 Writes the current value of MM0. This function is only available on IA32 and
6701 @param Value The 64-bit value to write to MM0.
6712 Writes the current value of 64-bit MMX Register #1 (MM1).
6714 Writes the current value of MM1. This function is only available on IA32 and
6717 @param Value The 64-bit value to write to MM1.
6728 Writes the current value of 64-bit MMX Register #2 (MM2).
6730 Writes the current value of MM2. This function is only available on IA32 and
6733 @param Value The 64-bit value to write to MM2.
6744 Writes the current value of 64-bit MMX Register #3 (MM3).
6746 Writes the current value of MM3. This function is only available on IA32 and
6749 @param Value The 64-bit value to write to MM3.
6760 Writes the current value of 64-bit MMX Register #4 (MM4).
6762 Writes the current value of MM4. This function is only available on IA32 and
6765 @param Value The 64-bit value to write to MM4.
6776 Writes the current value of 64-bit MMX Register #5 (MM5).
6778 Writes the current value of MM5. This function is only available on IA32 and
6781 @param Value The 64-bit value to write to MM5.
6792 Writes the current value of 64-bit MMX Register #6 (MM6).
6794 Writes the current value of MM6. This function is only available on IA32 and
6797 @param Value The 64-bit value to write to MM6.
6808 Writes the current value of 64-bit MMX Register #7 (MM7).
6810 Writes the current value of MM7. This function is only available on IA32 and
6813 @param Value The 64-bit value to write to MM7.
6824 Reads the current value of Time Stamp Counter (TSC).
6826 Reads and returns the current value of TSC. This function is only available
6829 @return The current value of TSC
6840 Reads the current value of a Performance Counter (PMC).
6842 Reads and returns the current value of performance counter specified by
6843 Index. This function is only available on IA-32 and X64.
6845 @param Index The 32-bit Performance Counter index to read.
6847 @return The value of the PMC specified by Index.
6858 Sets up a monitor buffer that is used by AsmMwait().
6860 Executes a MONITOR instruction with the register state specified by Eax, Ecx
6861 and Edx. Returns Eax. This function is only available on IA-32 and X64.
6863 @param Eax The value to load into EAX or RAX before executing the MONITOR
6865 @param Ecx The value to load into ECX or RCX before executing the MONITOR
6867 @param Edx The value to load into EDX or RDX before executing the MONITOR
6883 Executes an MWAIT instruction.
6885 Executes an MWAIT instruction with the register state specified by Eax and
6886 Ecx. Returns Eax. This function is only available on IA-32 and X64.
6888 @param Eax The value to load into EAX or RAX before executing the MONITOR
6890 @param Ecx The value to load into ECX or RCX before executing the MONITOR
6905 Executes a WBINVD instruction.
6907 Executes a WBINVD instruction. This function is only available on IA-32 and
6919 Executes a INVD instruction.
6921 Executes a INVD instruction. This function is only available on IA-32 and
6933 Flushes a cache line from all the instruction and data caches within the
6934 coherency domain of the CPU.
6936 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
6937 This function is only available on IA-32 and X64.
6939 @param LinearAddress The address of the cache line to flush. If the CPU is
6940 in a physical addressing mode, then LinearAddress is a
6941 physical address. If the CPU is in a virtual
6942 addressing mode, then LinearAddress is a virtual
6945 @return LinearAddress
6950 IN VOID
*LinearAddress
6955 Enables the 32-bit paging mode on the CPU.
6957 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
6958 must be properly initialized prior to calling this service. This function
6959 assumes the current execution mode is 32-bit protected mode. This function is
6960 only available on IA-32. After the 32-bit paging mode is enabled, control is
6961 transferred to the function specified by EntryPoint using the new stack
6962 specified by NewStack and passing in the parameters specified by Context1 and
6963 Context2. Context1 and Context2 are optional and may be NULL. The function
6964 EntryPoint must never return.
6966 If the current execution mode is not 32-bit protected mode, then ASSERT().
6967 If EntryPoint is NULL, then ASSERT().
6968 If NewStack is NULL, then ASSERT().
6970 There are a number of constraints that must be followed before calling this
6972 1) Interrupts must be disabled.
6973 2) The caller must be in 32-bit protected mode with flat descriptors. This
6974 means all descriptors must have a base of 0 and a limit of 4GB.
6975 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
6977 4) CR3 must point to valid page tables that will be used once the transition
6978 is complete, and those page tables must guarantee that the pages for this
6979 function and the stack are identity mapped.
6981 @param EntryPoint A pointer to function to call with the new stack after
6983 @param Context1 A pointer to the context to pass into the EntryPoint
6984 function as the first parameter after paging is enabled.
6985 @param Context2 A pointer to the context to pass into the EntryPoint
6986 function as the second parameter after paging is enabled.
6987 @param NewStack A pointer to the new stack to use for the EntryPoint
6988 function after paging is enabled.
6994 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
6995 IN VOID
*Context1
, OPTIONAL
6996 IN VOID
*Context2
, OPTIONAL
7002 Disables the 32-bit paging mode on the CPU.
7004 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
7005 mode. This function assumes the current execution mode is 32-paged protected
7006 mode. This function is only available on IA-32. After the 32-bit paging mode
7007 is disabled, control is transferred to the function specified by EntryPoint
7008 using the new stack specified by NewStack and passing in the parameters
7009 specified by Context1 and Context2. Context1 and Context2 are optional and
7010 may be NULL. The function EntryPoint must never return.
7012 If the current execution mode is not 32-bit paged mode, then ASSERT().
7013 If EntryPoint is NULL, then ASSERT().
7014 If NewStack is NULL, then ASSERT().
7016 There are a number of constraints that must be followed before calling this
7018 1) Interrupts must be disabled.
7019 2) The caller must be in 32-bit paged mode.
7020 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
7021 4) CR3 must point to valid page tables that guarantee that the pages for
7022 this function and the stack are identity mapped.
7024 @param EntryPoint A pointer to function to call with the new stack after
7026 @param Context1 A pointer to the context to pass into the EntryPoint
7027 function as the first parameter after paging is disabled.
7028 @param Context2 A pointer to the context to pass into the EntryPoint
7029 function as the second parameter after paging is
7031 @param NewStack A pointer to the new stack to use for the EntryPoint
7032 function after paging is disabled.
7037 AsmDisablePaging32 (
7038 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
7039 IN VOID
*Context1
, OPTIONAL
7040 IN VOID
*Context2
, OPTIONAL
7046 Enables the 64-bit paging mode on the CPU.
7048 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
7049 must be properly initialized prior to calling this service. This function
7050 assumes the current execution mode is 32-bit protected mode with flat
7051 descriptors. This function is only available on IA-32. After the 64-bit
7052 paging mode is enabled, control is transferred to the function specified by
7053 EntryPoint using the new stack specified by NewStack and passing in the
7054 parameters specified by Context1 and Context2. Context1 and Context2 are
7055 optional and may be 0. The function EntryPoint must never return.
7057 If the current execution mode is not 32-bit protected mode with flat
7058 descriptors, then ASSERT().
7059 If EntryPoint is 0, then ASSERT().
7060 If NewStack is 0, then ASSERT().
7062 @param CodeSelector The 16-bit selector to load in the CS before EntryPoint
7063 is called. The descriptor in the GDT that this selector
7064 references must be setup for long mode.
7065 @param EntryPoint The 64-bit virtual address of the function to call with
7066 the new stack after paging is enabled.
7067 @param Context1 The 64-bit virtual address of the context to pass into
7068 the EntryPoint function as the first parameter after
7070 @param Context2 The 64-bit virtual address of the context to pass into
7071 the EntryPoint function as the second parameter after
7073 @param NewStack The 64-bit virtual address of the new stack to use for
7074 the EntryPoint function after paging is enabled.
7080 IN UINT16 CodeSelector
,
7081 IN UINT64 EntryPoint
,
7082 IN UINT64 Context1
, OPTIONAL
7083 IN UINT64 Context2
, OPTIONAL
7089 Disables the 64-bit paging mode on the CPU.
7091 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
7092 mode. This function assumes the current execution mode is 64-paging mode.
7093 This function is only available on X64. After the 64-bit paging mode is
7094 disabled, control is transferred to the function specified by EntryPoint
7095 using the new stack specified by NewStack and passing in the parameters
7096 specified by Context1 and Context2. Context1 and Context2 are optional and
7097 may be 0. The function EntryPoint must never return.
7099 If the current execution mode is not 64-bit paged mode, then ASSERT().
7100 If EntryPoint is 0, then ASSERT().
7101 If NewStack is 0, then ASSERT().
7103 @param CodeSelector The 16-bit selector to load in the CS before EntryPoint
7104 is called. The descriptor in the GDT that this selector
7105 references must be setup for 32-bit protected mode.
7106 @param EntryPoint The 64-bit virtual address of the function to call with
7107 the new stack after paging is disabled.
7108 @param Context1 The 64-bit virtual address of the context to pass into
7109 the EntryPoint function as the first parameter after
7111 @param Context2 The 64-bit virtual address of the context to pass into
7112 the EntryPoint function as the second parameter after
7114 @param NewStack The 64-bit virtual address of the new stack to use for
7115 the EntryPoint function after paging is disabled.
7120 AsmDisablePaging64 (
7121 IN UINT16 CodeSelector
,
7122 IN UINT32 EntryPoint
,
7123 IN UINT32 Context1
, OPTIONAL
7124 IN UINT32 Context2
, OPTIONAL
7130 // 16-bit thunking services
7134 Retrieves the properties for 16-bit thunk functions.
7136 Computes the size of the buffer and stack below 1MB required to use the
7137 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
7138 buffer size is returned in RealModeBufferSize, and the stack size is returned
7139 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
7140 then the actual minimum stack size is ExtraStackSize plus the maximum number
7141 of bytes that need to be passed to the 16-bit real mode code.
7143 If RealModeBufferSize is NULL, then ASSERT().
7144 If ExtraStackSize is NULL, then ASSERT().
7146 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
7147 required to use the 16-bit thunk functions.
7148 @param ExtraStackSize A pointer to the extra size of stack below 1MB
7149 that the 16-bit thunk functions require for
7150 temporary storage in the transition to and from
7156 AsmGetThunk16Properties (
7157 OUT UINT32
*RealModeBufferSize
,
7158 OUT UINT32
*ExtraStackSize
7163 Prepares all structures a code required to use AsmThunk16().
7165 Prepares all structures and code required to use AsmThunk16().
7167 If ThunkContext is NULL, then ASSERT().
7169 @param ThunkContext A pointer to the context structure that describes the
7170 16-bit real mode code to call.
7176 OUT THUNK_CONTEXT
*ThunkContext
7181 Transfers control to a 16-bit real mode entry point and returns the results.
7183 Transfers control to a 16-bit real mode entry point and returns the results.
7184 AsmPrepareThunk16() must be called with ThunkContext before this function is
7187 If ThunkContext is NULL, then ASSERT().
7188 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
7190 @param ThunkContext A pointer to the context structure that describes the
7191 16-bit real mode code to call.
7197 IN OUT THUNK_CONTEXT
*ThunkContext
7202 Prepares all structures and code for a 16-bit real mode thunk, transfers
7203 control to a 16-bit real mode entry point, and returns the results.
7205 Prepares all structures and code for a 16-bit real mode thunk, transfers
7206 control to a 16-bit real mode entry point, and returns the results. If the
7207 caller only need to perform a single 16-bit real mode thunk, then this
7208 service should be used. If the caller intends to make more than one 16-bit
7209 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
7210 once and AsmThunk16() can be called for each 16-bit real mode thunk.
7212 If ThunkContext is NULL, then ASSERT().
7214 @param ThunkContext A pointer to the context structure that describes the
7215 16-bit real mode code to call.
7220 AsmPrepareAndThunk16 (
7221 IN OUT THUNK_CONTEXT
*ThunkContext