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.
13 Module Name: BaseLib.h
21 // Definitions for architecture specific types
22 // These include SPIN_LOCK and BASE_LIBRARY_JUMP_BUFFER
28 typedef UINTN SPIN_LOCK
;
30 #if defined (MDE_CPU_IA32)
32 // IA32 context buffer used by SetJump() and LongJump()
41 } BASE_LIBRARY_JUMP_BUFFER
;
43 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
45 #elif defined (MDE_CPU_IPF)
47 // IPF context buffer used by SetJump() and LongJump()
82 UINT64 AfterSpillUNAT
;
88 } BASE_LIBRARY_JUMP_BUFFER
;
90 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 0x10
92 #elif defined (MDE_CPU_X64)
94 // X64 context buffer used by SetJump() and LongJump()
107 } BASE_LIBRARY_JUMP_BUFFER
;
109 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
111 #elif defined (MDE_CPU_EBC)
113 // EBC context buffer used by SetJump() and LongJump()
121 } BASE_LIBRARY_JUMP_BUFFER
;
123 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
126 #error Unknown Processor Type
134 Copies one Null-terminated Unicode string to another Null-terminated Unicode
135 string and returns the new Unicode string.
137 This function copies the contents of the Unicode string Source to the Unicode
138 string Destination, and returns Destination. If Source and Destination
139 overlap, then the results are undefined.
141 If Destination is NULL, then ASSERT().
142 If Destination is not aligned on a 16-bit boundary, then ASSERT().
143 If Source is NULL, then ASSERT().
144 If Source is not aligned on a 16-bit boundary, then ASSERT().
145 If Source and Destination overlap, then ASSERT().
146 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
147 PcdMaximumUnicodeStringLength Unicode characters not including the
148 Null-terminator, then ASSERT().
150 @param Destination Pointer to a Null-terminated Unicode string.
151 @param Source Pointer to a Null-terminated Unicode string.
159 OUT CHAR16
*Destination
,
160 IN CONST CHAR16
*Source
163 Copies one Null-terminated Unicode string with a maximum length to another
164 Null-terminated Unicode string with a maximum length and returns the new
167 This function copies the contents of the Unicode string Source to the Unicode
168 string Destination, and returns Destination. At most, Length Unicode
169 characters are copied from Source to Destination. If Length is 0, then
170 Destination is returned unmodified. If Length is greater that the number of
171 Unicode characters in Source, then Destination is padded with Null Unicode
172 characters. If Source and Destination overlap, then the results are
175 If Length > 0 and Destination is NULL, then ASSERT().
176 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
177 If Length > 0 and Source is NULL, then ASSERT().
178 If Length > 0 and Source is not aligned on a 16-bit bounadry, then ASSERT().
179 If Source and Destination overlap, then ASSERT().
180 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
181 PcdMaximumUnicodeStringLength Unicode characters not including the
182 Null-terminator, then ASSERT().
184 @param Destination Pointer to a Null-terminated Unicode string.
185 @param Source Pointer to a Null-terminated Unicode string.
186 @param Length Maximum number of Unicode characters to copy.
194 OUT CHAR16
*Destination
,
195 IN CONST CHAR16
*Source
,
199 Returns the length of a Null-terminated Unicode string.
201 This function returns the number of Unicode characters in the Null-terminated
202 Unicode string specified by String.
204 If String is NULL, then ASSERT().
205 If String is not aligned on a 16-bit boundary, then ASSERT().
206 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
207 PcdMaximumUnicodeStringLength Unicode characters not including the
208 Null-terminator, then ASSERT().
210 @param String Pointer to a Null-terminated Unicode string.
212 @return The length of String.
218 IN CONST CHAR16
*String
221 Returns the size of a Null-terminated Unicode string in bytes, including the
224 This function returns the size, in bytes, of the Null-terminated Unicode
225 string specified by String.
227 If String is NULL, then ASSERT().
228 If String is not aligned on a 16-bit boundary, then ASSERT().
229 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
230 PcdMaximumUnicodeStringLength Unicode characters not including the
231 Null-terminator, then ASSERT().
233 @param String Pointer to a Null-terminated Unicode string.
235 @return The size of String.
241 IN CONST CHAR16
*String
244 Compares two Null-terminated Unicode strings, and returns the difference
245 between the first mismatched Unicode characters.
247 This function compares the Null-terminated Unicode string FirstString to the
248 Null-terminated Unicode string SecondString. If FirstString is identical to
249 SecondString, then 0 is returned. Otherwise, the value returned is the first
250 mismatched Unicode character in SecondString subtracted from the first
251 mismatched Unicode character in FirstString.
253 If FirstString is NULL, then ASSERT().
254 If FirstString is not aligned on a 16-bit boundary, then ASSERT().
255 If SecondString is NULL, then ASSERT().
256 If SecondString is not aligned on a 16-bit boundary, then ASSERT().
257 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
258 than PcdMaximumUnicodeStringLength Unicode characters not including the
259 Null-terminator, then ASSERT().
260 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
261 than PcdMaximumUnicodeStringLength Unicode characters not including the
262 Null-terminator, then ASSERT().
264 @param FirstString Pointer to a Null-terminated Unicode string.
265 @param SecondString Pointer to a Null-terminated Unicode string.
267 @retval 0 FirstString is identical to SecondString.
268 @retval !=0 FirstString is not identical to SecondString.
274 IN CONST CHAR16
*FirstString
,
275 IN CONST CHAR16
*SecondString
278 Compares two Null-terminated Unicode strings with maximum lengths, and
279 returns the difference between the first mismatched Unicode characters.
281 This function compares the Null-terminated Unicode string FirstString to the
282 Null-terminated Unicode string SecondString. At most, Length Unicode
283 characters will be compared. If Length is 0, then 0 is returned. If
284 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
285 value returned is the first mismatched Unicode character in SecondString
286 subtracted from the first mismatched Unicode character in FirstString.
288 If Length > 0 and FirstString is NULL, then ASSERT().
289 If Length > 0 and FirstString is not aligned on a 16-bit bounadary, then ASSERT().
290 If Length > 0 and SecondString is NULL, then ASSERT().
291 If Length > 0 and SecondString is not aligned on a 16-bit bounadary, then ASSERT().
292 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
293 than PcdMaximumUnicodeStringLength Unicode characters not including the
294 Null-terminator, then ASSERT().
295 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
296 than PcdMaximumUnicodeStringLength Unicode characters not including the
297 Null-terminator, then ASSERT().
299 @param FirstString Pointer to a Null-terminated Unicode string.
300 @param SecondString Pointer to a Null-terminated Unicode string.
301 @param Length Maximum number of Unicode characters to compare.
303 @retval 0 FirstString is identical to SecondString.
304 @retval !=0 FirstString is not identical to SecondString.
310 IN CONST CHAR16
*FirstString
,
311 IN CONST CHAR16
*SecondString
,
315 Concatenates one Null-terminated Unicode string to another Null-terminated
316 Unicode string, and returns the concatenated Unicode string.
318 This function concatenates two Null-terminated Unicode strings. The contents
319 of Null-terminated Unicode string Source are concatenated to the end of
320 Null-terminated Unicode string Destination. The Null-terminated concatenated
321 Unicode String is returned. If Source and Destination overlap, then the
322 results are undefined.
324 If Destination is NULL, then ASSERT().
325 If Destination is not aligned on a 16-bit bounadary, then ASSERT().
326 If Source is NULL, then ASSERT().
327 If Source is not aligned on a 16-bit bounadary, then ASSERT().
328 If Source and Destination overlap, then ASSERT().
329 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
330 than PcdMaximumUnicodeStringLength Unicode characters not including the
331 Null-terminator, then ASSERT().
332 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
333 PcdMaximumUnicodeStringLength Unicode characters not including the
334 Null-terminator, then ASSERT().
335 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
336 and Source results in a Unicode string with more than
337 PcdMaximumUnicodeStringLength Unicode characters not including the
338 Null-terminator, then ASSERT().
340 @param Destination Pointer to a Null-terminated Unicode string.
341 @param Source Pointer to a Null-terminated Unicode string.
349 IN OUT CHAR16
*Destination
,
350 IN CONST CHAR16
*Source
353 Concatenates one Null-terminated Unicode string with a maximum length to the
354 end of another Null-terminated Unicode string, and returns the concatenated
357 This function concatenates two Null-terminated Unicode strings. The contents
358 of Null-terminated Unicode string Source are concatenated to the end of
359 Null-terminated Unicode string Destination, and Destination is returned. At
360 most, Length Unicode characters are concatenated from Source to the end of
361 Destination, and Destination is always Null-terminated. If Length is 0, then
362 Destination is returned unmodified. If Source and Destination overlap, then
363 the results are undefined.
365 If Destination is NULL, then ASSERT().
366 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
367 If Length > 0 and Source is NULL, then ASSERT().
368 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
369 If Source and Destination overlap, then ASSERT().
370 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
371 than PcdMaximumUnicodeStringLength Unicode characters not including the
372 Null-terminator, then ASSERT().
373 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
374 PcdMaximumUnicodeStringLength Unicode characters not including the
375 Null-terminator, then ASSERT().
376 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
377 and Source results in a Unicode string with more than
378 PcdMaximumUnicodeStringLength Unicode characters not including the
379 Null-terminator, then ASSERT().
381 @param Destination Pointer to a Null-terminated Unicode string.
382 @param Source Pointer to a Null-terminated Unicode string.
383 @param Length Maximum number of Unicode characters to concatenate from
392 IN OUT CHAR16
*Destination
,
393 IN CONST CHAR16
*Source
,
398 Returns the first occurance of a Null-terminated Unicode sub-string
399 in a Null-terminated Unicode string.
401 This function scans the contents of the Null-terminated Unicode string
402 specified by String and returns the first occurrence of SearchString.
403 If SearchString is not found in String, then NULL is returned. If
404 the length of SearchString is zero, then String is
407 If String is NULL, then ASSERT().
408 If String is not aligned on a 16-bit boundary, then ASSERT().
409 If SearchString is NULL, then ASSERT().
410 If SearchString is not aligned on a 16-bit boundary, then ASSERT().
412 If PcdMaximumUnicodeStringLength is not zero, and SearchString
413 or String contains more than PcdMaximumUnicodeStringLength Unicode
414 characters not including the Null-terminator, then ASSERT().
416 @param String Pointer to a Null-terminated Unicode string.
417 @param SearchString Pointer to a Null-terminated Unicode string to search for.
419 @retval NULL If the SearchString does not appear in String.
420 @retval !NULL If there is a match.
426 IN CONST CHAR16
*String
,
427 IN CONST CHAR16
*SearchString
431 Convert a Null-terminated Unicode decimal string to a value of
434 This function returns a value of type UINTN by interpreting the contents
435 of the Unicode string specified by String as a decimal number. The format
436 of the input Unicode string String is:
438 [spaces] [decimal digits].
440 The valid decimal digit character is in the range [0-9]. The
441 function will ignore the pad space, which includes spaces or
442 tab characters, before [decimal digits]. The running zero in the
443 beginning of [decimal digits] will be ignored. Then, the function
444 stops at the first character that is a not a valid decimal character
445 or a Null-terminator, whichever one comes first.
447 If String is NULL, then ASSERT().
448 If String is not aligned in a 16-bit boundary, then ASSERT().
449 If String has only pad spaces, then 0 is returned.
450 If String has no pad spaces or valid decimal digits,
452 If the number represented by String overflows according
453 to the range defined by UINTN, then ASSERT().
455 If PcdMaximumUnicodeStringLength is not zero, and String contains
456 more than PcdMaximumUnicodeStringLength Unicode characters not including
457 the Null-terminator, then ASSERT().
459 @param String Pointer to a Null-terminated Unicode string.
467 IN CONST CHAR16
*String
471 Convert a Null-terminated Unicode decimal string to a value of
474 This function returns a value of type UINT64 by interpreting the contents
475 of the Unicode string specified by String as a decimal number. The format
476 of the input Unicode string String is:
478 [spaces] [decimal digits].
480 The valid decimal digit character is in the range [0-9]. The
481 function will ignore the pad space, which includes spaces or
482 tab characters, before [decimal digits]. The running zero in the
483 beginning of [decimal digits] will be ignored. Then, the function
484 stops at the first character that is a not a valid decimal character
485 or a Null-terminator, whichever one comes first.
487 If String is NULL, then ASSERT().
488 If String is not aligned in a 16-bit boundary, then ASSERT().
489 If String has only pad spaces, then 0 is returned.
490 If String has no pad spaces or valid decimal digits,
492 If the number represented by String overflows according
493 to the range defined by UINT64, then ASSERT().
495 If PcdMaximumUnicodeStringLength is not zero, and String contains
496 more than PcdMaximumUnicodeStringLength Unicode characters not including
497 the Null-terminator, then ASSERT().
499 @param String Pointer to a Null-terminated Unicode string.
507 IN CONST CHAR16
*String
511 Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.
513 This function returns a value of type UINTN by interpreting the contents
514 of the Unicode string specified by String as a hexadecimal number.
515 The format of the input Unicode string String is:
517 [spaces][zeros][x][hexadecimal digits].
519 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
520 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
521 If "x" appears in the input string, it must be prefixed with at least one 0.
522 The function will ignore the pad space, which includes spaces or tab characters,
523 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
524 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
525 first valid hexadecimal digit. Then, the function stops at the first character that is
526 a not a valid hexadecimal character or NULL, whichever one comes first.
528 If String is NULL, then ASSERT().
529 If String is not aligned in a 16-bit boundary, then ASSERT().
530 If String has only pad spaces, then zero is returned.
531 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
532 then zero is returned.
533 If the number represented by String overflows according to the range defined by
534 UINTN, then ASSERT().
536 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
537 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
540 @param String Pointer to a Null-terminated Unicode string.
548 IN CONST CHAR16
*String
552 Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.
554 This function returns a value of type UINT64 by interpreting the contents
555 of the Unicode string specified by String as a hexadecimal number.
556 The format of the input Unicode string String is
558 [spaces][zeros][x][hexadecimal digits].
560 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
561 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
562 If "x" appears in the input string, it must be prefixed with at least one 0.
563 The function will ignore the pad space, which includes spaces or tab characters,
564 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
565 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
566 first valid hexadecimal digit. Then, the function stops at the first character that is
567 a not a valid hexadecimal character or NULL, whichever one comes first.
569 If String is NULL, then ASSERT().
570 If String is not aligned in a 16-bit boundary, then ASSERT().
571 If String has only pad spaces, then zero is returned.
572 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
573 then zero is returned.
574 If the number represented by String overflows according to the range defined by
575 UINT64, then ASSERT().
577 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
578 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
581 @param String Pointer to a Null-terminated Unicode string.
589 IN CONST CHAR16
*String
593 Convert one Null-terminated Unicode string to a Null-terminated
594 ASCII string and returns the ASCII string.
596 This function converts the content of the Unicode string Source
597 to the ASCII string Destination by copying the lower 8 bits of
598 each Unicode character. It returns Destination.
600 If any Unicode characters in Source contain non-zero value in
601 the upper 8 bits, then ASSERT().
603 If Destination is NULL, then ASSERT().
604 If Source is NULL, then ASSERT().
605 If Source is not aligned on a 16-bit boundary, then ASSERT().
606 If Source and Destination overlap, then ASSERT().
608 If PcdMaximumUnicodeStringLength is not zero, and Source contains
609 more than PcdMaximumUnicodeStringLength Unicode characters not including
610 the Null-terminator, then ASSERT().
612 If PcdMaximumAsciiStringLength is not zero, and Source contains more
613 than PcdMaximumAsciiStringLength Unicode characters not including the
614 Null-terminator, then ASSERT().
616 @param Source Pointer to a Null-terminated Unicode string.
617 @param Destination Pointer to a Null-terminated ASCII string.
624 UnicodeStrToAsciiStr (
625 IN CONST CHAR16
*Source
,
626 OUT CHAR8
*Destination
630 Copies one Null-terminated ASCII string to another Null-terminated ASCII
631 string and returns the new ASCII string.
633 This function copies the contents of the ASCII string Source to the ASCII
634 string Destination, and returns Destination. If Source and Destination
635 overlap, then the results are undefined.
637 If Destination is NULL, then ASSERT().
638 If Source is NULL, then ASSERT().
639 If Source and Destination overlap, then ASSERT().
640 If PcdMaximumAsciiStringLength is not zero and Source contains more than
641 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
644 @param Destination Pointer to a Null-terminated ASCII string.
645 @param Source Pointer to a Null-terminated ASCII string.
653 OUT CHAR8
*Destination
,
654 IN CONST CHAR8
*Source
657 Copies one Null-terminated ASCII string with a maximum length to another
658 Null-terminated ASCII string with a maximum length and returns the new ASCII
661 This function copies the contents of the ASCII string Source to the ASCII
662 string Destination, and returns Destination. At most, Length ASCII characters
663 are copied from Source to Destination. If Length is 0, then Destination is
664 returned unmodified. If Length is greater that the number of ASCII characters
665 in Source, then Destination is padded with Null ASCII characters. If Source
666 and Destination overlap, then the results are undefined.
668 If Destination is NULL, then ASSERT().
669 If Source is NULL, then ASSERT().
670 If Source and Destination overlap, then ASSERT().
671 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
672 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
675 @param Destination Pointer to a Null-terminated ASCII string.
676 @param Source Pointer to a Null-terminated ASCII string.
677 @param Length Maximum number of ASCII characters to copy.
685 OUT CHAR8
*Destination
,
686 IN CONST CHAR8
*Source
,
690 Returns the length of a Null-terminated ASCII string.
692 This function returns the number of ASCII characters in the Null-terminated
693 ASCII string specified by String.
695 If Length > 0 and Destination is NULL, then ASSERT().
696 If Length > 0 and Source is NULL, then ASSERT().
697 If PcdMaximumAsciiStringLength is not zero and String contains more than
698 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
701 @param String Pointer to a Null-terminated ASCII string.
703 @return The length of String.
709 IN CONST CHAR8
*String
712 Returns the size of a Null-terminated ASCII string in bytes, including the
715 This function returns the size, in bytes, of the Null-terminated ASCII string
718 If String is NULL, then ASSERT().
719 If PcdMaximumAsciiStringLength is not zero and String contains more than
720 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
723 @param String Pointer to a Null-terminated ASCII string.
725 @return The size of String.
731 IN CONST CHAR8
*String
734 Compares two Null-terminated ASCII strings, and returns the difference
735 between the first mismatched ASCII characters.
737 This function compares the Null-terminated ASCII string FirstString to the
738 Null-terminated ASCII string SecondString. If FirstString is identical to
739 SecondString, then 0 is returned. Otherwise, the value returned is the first
740 mismatched ASCII character in SecondString subtracted from the first
741 mismatched ASCII character in FirstString.
743 If FirstString is NULL, then ASSERT().
744 If SecondString is NULL, then ASSERT().
745 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
746 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
748 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
749 than PcdMaximumAsciiStringLength ASCII characters not including the
750 Null-terminator, then ASSERT().
752 @param FirstString Pointer to a Null-terminated ASCII string.
753 @param SecondString Pointer to a Null-terminated ASCII string.
755 @retval 0 FirstString is identical to SecondString.
756 @retval !=0 FirstString is not identical to SecondString.
762 IN CONST CHAR8
*FirstString
,
763 IN CONST CHAR8
*SecondString
766 Performs a case insensitive comparison of two Null-terminated ASCII strings,
767 and returns the difference between the first mismatched ASCII characters.
769 This function performs a case insensitive comparison of the Null-terminated
770 ASCII string FirstString to the Null-terminated ASCII string SecondString. If
771 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
772 value returned is the first mismatched lower case ASCII character in
773 SecondString subtracted from the first mismatched lower case ASCII character
776 If FirstString is NULL, then ASSERT().
777 If SecondString is NULL, then ASSERT().
778 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
779 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
781 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
782 than PcdMaximumAsciiStringLength ASCII characters not including the
783 Null-terminator, then ASSERT().
785 @param FirstString Pointer to a Null-terminated ASCII string.
786 @param SecondString Pointer to a Null-terminated ASCII string.
788 @retval 0 FirstString is identical to SecondString using case insensitive
790 @retval !=0 FirstString is not identical to SecondString using case
791 insensitive comparisons.
797 IN CONST CHAR8
*FirstString
,
798 IN CONST CHAR8
*SecondString
801 Compares two Null-terminated ASCII strings with maximum lengths, and returns
802 the difference between the first mismatched ASCII characters.
804 This function compares the Null-terminated ASCII string FirstString to the
805 Null-terminated ASCII string SecondString. At most, Length ASCII characters
806 will be compared. If Length is 0, then 0 is returned. If FirstString is
807 identical to SecondString, then 0 is returned. Otherwise, the value returned
808 is the first mismatched ASCII character in SecondString subtracted from the
809 first mismatched ASCII character in FirstString.
811 If Length > 0 and FirstString is NULL, then ASSERT().
812 If Length > 0 and SecondString is NULL, then ASSERT().
813 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
814 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
816 If PcdMaximumAsciiStringLength is not zero and SecondString contains more than
817 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
820 @param FirstString Pointer to a Null-terminated ASCII string.
821 @param SecondString Pointer to a Null-terminated ASCII string.
823 @retval 0 FirstString is identical to SecondString.
824 @retval !=0 FirstString is not identical to SecondString.
830 IN CONST CHAR8
*FirstString
,
831 IN CONST CHAR8
*SecondString
,
835 Concatenates one Null-terminated ASCII string to another Null-terminated
836 ASCII string, and returns the concatenated ASCII string.
838 This function concatenates two Null-terminated ASCII strings. The contents of
839 Null-terminated ASCII string Source are concatenated to the end of Null-
840 terminated ASCII string Destination. The Null-terminated concatenated ASCII
843 If Destination is NULL, then ASSERT().
844 If Source is NULL, then ASSERT().
845 If PcdMaximumAsciiStringLength is not zero and Destination contains more than
846 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
848 If PcdMaximumAsciiStringLength is not zero and Source contains more than
849 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
851 If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
852 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
853 ASCII characters, then ASSERT().
855 @param Destination Pointer to a Null-terminated ASCII string.
856 @param Source Pointer to a Null-terminated ASCII string.
864 IN OUT CHAR8
*Destination
,
865 IN CONST CHAR8
*Source
868 Concatenates one Null-terminated ASCII string with a maximum length to the
869 end of another Null-terminated ASCII string, and returns the concatenated
872 This function concatenates two Null-terminated ASCII strings. The contents
873 of Null-terminated ASCII string Source are concatenated to the end of Null-
874 terminated ASCII string Destination, and Destination is returned. At most,
875 Length ASCII characters are concatenated from Source to the end of
876 Destination, and Destination is always Null-terminated. If Length is 0, then
877 Destination is returned unmodified. If Source and Destination overlap, then
878 the results are undefined.
880 If Length > 0 and Destination is NULL, then ASSERT().
881 If Length > 0 and Source is NULL, then ASSERT().
882 If Source and Destination overlap, then ASSERT().
883 If PcdMaximumAsciiStringLength is not zero, and Destination contains more than
884 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
886 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
887 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
889 If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
890 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
891 ASCII characters not including the Null-terminator, then ASSERT().
893 @param Destination Pointer to a Null-terminated ASCII string.
894 @param Source Pointer to a Null-terminated ASCII string.
895 @param Length Maximum number of ASCII characters to concatenate from
904 IN OUT CHAR8
*Destination
,
905 IN CONST CHAR8
*Source
,
910 Returns the first occurance of a Null-terminated ASCII sub-string
911 in a Null-terminated ASCII string.
913 This function scans the contents of the ASCII string specified by String
914 and returns the first occurrence of SearchString. If SearchString is not
915 found in String, then NULL is returned. If the length of SearchString is zero,
916 then String is returned.
918 If String is NULL, then ASSERT().
919 If SearchString is NULL, then ASSERT().
921 If PcdMaximumAsciiStringLength is not zero, and SearchString or
922 String contains more than PcdMaximumAsciiStringLength Unicode characters
923 not including the Null-terminator, then ASSERT().
925 @param String Pointer to a Null-terminated ASCII string.
926 @param SearchString Pointer to a Null-terminated ASCII string to search for.
928 @retval NULL If the SearchString does not appear in String.
929 @retval !NULL If there is a match.
935 IN CONST CHAR8
*String
,
936 IN CONST CHAR8
*SearchString
940 Convert a Null-terminated ASCII decimal string to a value of type
943 This function returns a value of type UINTN by interpreting the contents
944 of the ASCII string String as a decimal number. The format of the input
945 ASCII string String is:
947 [spaces] [decimal digits].
949 The valid decimal digit character is in the range [0-9]. The function will
950 ignore the pad space, which includes spaces or tab characters, before the digits.
951 The running zero in the beginning of [decimal digits] will be ignored. Then, the
952 function stops at the first character that is a not a valid decimal character or
953 Null-terminator, whichever on comes first.
955 If String has only pad spaces, then 0 is returned.
956 If String has no pad spaces or valid decimal digits, then 0 is returned.
957 If the number represented by String overflows according to the range defined by
958 UINTN, then ASSERT().
959 If String is NULL, then ASSERT().
960 If PcdMaximumAsciiStringLength is not zero, and String contains more than
961 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
964 @param String Pointer to a Null-terminated ASCII string.
971 AsciiStrDecimalToUintn (
972 IN CONST CHAR8
*String
976 Convert a Null-terminated ASCII decimal string to a value of type
979 This function returns a value of type UINT64 by interpreting the contents
980 of the ASCII string String as a decimal number. The format of the input
981 ASCII string String is:
983 [spaces] [decimal digits].
985 The valid decimal digit character is in the range [0-9]. The function will
986 ignore the pad space, which includes spaces or tab characters, before the digits.
987 The running zero in the beginning of [decimal digits] will be ignored. Then, the
988 function stops at the first character that is a not a valid decimal character or
989 Null-terminator, whichever on comes first.
991 If String has only pad spaces, then 0 is returned.
992 If String has no pad spaces or valid decimal digits, then 0 is returned.
993 If the number represented by String overflows according to the range defined by
994 UINT64, then ASSERT().
995 If String is NULL, then ASSERT().
996 If PcdMaximumAsciiStringLength is not zero, and String contains more than
997 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1000 @param String Pointer to a Null-terminated ASCII string.
1007 AsciiStrDecimalToUint64 (
1008 IN CONST CHAR8
*String
1012 Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.
1014 This function returns a value of type UINTN by interpreting the contents of
1015 the ASCII string String as a hexadecimal number. The format of the input ASCII
1018 [spaces][zeros][x][hexadecimal digits].
1020 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1021 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1022 appears in the input string, it must be prefixed with at least one 0. The function
1023 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1024 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1025 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1026 digit. Then, the function stops at the first character that is a not a valid
1027 hexadecimal character or Null-terminator, whichever on comes first.
1029 If String has only pad spaces, then 0 is returned.
1030 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1033 If the number represented by String overflows according to the range defined by UINTN,
1035 If String is NULL, then ASSERT().
1036 If PcdMaximumAsciiStringLength is not zero,
1037 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1038 the Null-terminator, then ASSERT().
1040 @param String Pointer to a Null-terminated ASCII string.
1047 AsciiStrHexToUintn (
1048 IN CONST CHAR8
*String
1052 Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.
1054 This function returns a value of type UINT64 by interpreting the contents of
1055 the ASCII string String as a hexadecimal number. The format of the input ASCII
1058 [spaces][zeros][x][hexadecimal digits].
1060 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1061 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1062 appears in the input string, it must be prefixed with at least one 0. The function
1063 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1064 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1065 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1066 digit. Then, the function stops at the first character that is a not a valid
1067 hexadecimal character or Null-terminator, whichever on comes first.
1069 If String has only pad spaces, then 0 is returned.
1070 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1073 If the number represented by String overflows according to the range defined by UINT64,
1075 If String is NULL, then ASSERT().
1076 If PcdMaximumAsciiStringLength is not zero,
1077 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1078 the Null-terminator, then ASSERT().
1080 @param String Pointer to a Null-terminated ASCII string.
1087 AsciiStrHexToUint64 (
1088 IN CONST CHAR8
*String
1092 Convert one Null-terminated ASCII string to a Null-terminated
1093 Unicode string and returns the Unicode string.
1095 This function converts the contents of the ASCII string Source to the Unicode
1096 string Destination, and returns Destination. The function terminates the
1097 Unicode string Destination by appending a Null-terminator character at the end.
1098 The caller is responsible to make sure Destination points to a buffer with size
1099 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
1101 If Destination is NULL, then ASSERT().
1102 If Destination is not aligned on a 16-bit boundary, then ASSERT().
1103 If Source is NULL, then ASSERT().
1104 If Source and Destination overlap, then ASSERT().
1105 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1106 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1108 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1109 PcdMaximumUnicodeStringLength ASCII characters not including the
1110 Null-terminator, then ASSERT().
1112 @param Source Pointer to a Null-terminated ASCII string.
1113 @param Destination Pointer to a Null-terminated Unicode string.
1120 AsciiStrToUnicodeStr (
1121 IN CONST CHAR8
*Source
,
1122 OUT CHAR16
*Destination
1126 Converts an 8-bit value to an 8-bit BCD value.
1128 Converts the 8-bit value specified by Value to BCD. The BCD value is
1131 If Value >= 100, then ASSERT().
1133 @param Value The 8-bit value to convert to BCD. Range 0..99.
1135 @return The BCD value
1145 Converts an 8-bit BCD value to an 8-bit value.
1147 Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit
1150 If Value >= 0xA0, then ASSERT().
1151 If (Value & 0x0F) >= 0x0A, then ASSERT().
1153 @param Value The 8-bit BCD value to convert to an 8-bit value.
1155 @return The 8-bit value is returned.
1166 // Linked List Functions and Macros
1170 Initializes the head node of a doubly linked list that is declared as a
1171 global variable in a module.
1173 Initializes the forward and backward links of a new linked list. After
1174 initializing a linked list with this macro, the other linked list functions
1175 may be used to add and remove nodes from the linked list. This macro results
1176 in smaller executables by initializing the linked list in the data section,
1177 instead if calling the InitializeListHead() function to perform the
1178 equivalent operation.
1180 @param ListHead The head note of a list to initiailize.
1183 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&ListHead, &ListHead}
1186 Initializes the head node of a doubly linked list, and returns the pointer to
1187 the head node of the doubly linked list.
1189 Initializes the forward and backward links of a new linked list. After
1190 initializing a linked list with this function, the other linked list
1191 functions may be used to add and remove nodes from the linked list. It is up
1192 to the caller of this function to allocate the memory for ListHead.
1194 If ListHead is NULL, then ASSERT().
1196 @param ListHead A pointer to the head node of a new doubly linked list.
1203 InitializeListHead (
1204 IN LIST_ENTRY
*ListHead
1208 Adds a node to the beginning of a doubly linked list, and returns the pointer
1209 to the head node of the doubly linked list.
1211 Adds the node Entry at the beginning of the doubly linked list denoted by
1212 ListHead, and returns ListHead.
1214 If ListHead is NULL, then ASSERT().
1215 If Entry is NULL, then ASSERT().
1216 If ListHead was not initialized with InitializeListHead(), then ASSERT().
1217 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
1218 of nodes in ListHead, including the ListHead node, is greater than or
1219 equal to PcdMaximumLinkedListLength, then ASSERT().
1221 @param ListHead A pointer to the head node of a doubly linked list.
1222 @param Entry A pointer to a node that is to be inserted at the beginning
1223 of a doubly linked list.
1231 IN LIST_ENTRY
*ListHead
,
1232 IN LIST_ENTRY
*Entry
1236 Adds a node to the end of a doubly linked list, and returns the pointer to
1237 the head node of the doubly linked list.
1239 Adds the node Entry to the end of the doubly linked list denoted by ListHead,
1240 and returns ListHead.
1242 If ListHead is NULL, then ASSERT().
1243 If Entry is NULL, then ASSERT().
1244 If ListHead was not initialized with InitializeListHead(), then ASSERT().
1245 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
1246 of nodes in ListHead, including the ListHead node, is greater than or
1247 equal to PcdMaximumLinkedListLength, then ASSERT().
1249 @param ListHead A pointer to the head node of a doubly linked list.
1250 @param Entry A pointer to a node that is to be added at the end of the
1259 IN LIST_ENTRY
*ListHead
,
1260 IN LIST_ENTRY
*Entry
1264 Retrieves the first node of a doubly linked list.
1266 Returns the first node of a doubly linked list. List must have been
1267 initialized with InitializeListHead(). If List is empty, then NULL is
1270 If List is NULL, then ASSERT().
1271 If List was not initialized with InitializeListHead(), then ASSERT().
1272 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1273 in List, including the List node, is greater than or equal to
1274 PcdMaximumLinkedListLength, then ASSERT().
1276 @param List A pointer to the head node of a doubly linked list.
1278 @return The first node of a doubly linked list.
1279 @retval NULL The list is empty.
1285 IN CONST LIST_ENTRY
*List
1289 Retrieves the next node of a doubly linked list.
1291 Returns the node of a doubly linked list that follows Node. List must have
1292 been initialized with InitializeListHead(). If List is empty, then List is
1295 If List is NULL, then ASSERT().
1296 If Node is NULL, then ASSERT().
1297 If List was not initialized with InitializeListHead(), then ASSERT().
1298 If PcdMaximumLinkedListLenth is not zero, and List contains more than
1299 PcdMaximumLinkedListLenth nodes, then ASSERT().
1300 If Node is not a node in List, then ASSERT().
1302 @param List A pointer to the head node of a doubly linked list.
1303 @param Node A pointer to a node in the doubly linked list.
1305 @return Pointer to the next node if one exists. Otherwise a null value which
1306 is actually List is returned.
1312 IN CONST LIST_ENTRY
*List
,
1313 IN CONST LIST_ENTRY
*Node
1317 Checks to see if a doubly linked list is empty or not.
1319 Checks to see if the doubly linked list is empty. If the linked list contains
1320 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
1322 If ListHead is NULL, then ASSERT().
1323 If ListHead was not initialized with InitializeListHead(), then ASSERT().
1324 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1325 in List, including the List node, is greater than or equal to
1326 PcdMaximumLinkedListLength, then ASSERT().
1328 @param ListHead A pointer to the head node of a doubly linked list.
1330 @retval TRUE The linked list is empty.
1331 @retval FALSE The linked list is not empty.
1337 IN CONST LIST_ENTRY
*ListHead
1341 Determines if a node in a doubly linked list is null.
1343 Returns FALSE if Node is one of the nodes in the doubly linked list specified
1344 by List. Otherwise, TRUE is returned. List must have been initialized with
1345 InitializeListHead().
1347 If List is NULL, then ASSERT().
1348 If Node is NULL, then ASSERT().
1349 If List was not initialized with InitializeListHead(), then ASSERT().
1350 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1351 in List, including the List node, is greater than or equal to
1352 PcdMaximumLinkedListLength, then ASSERT().
1353 If Node is not a node in List and Node is not equal to List, then ASSERT().
1355 @param List A pointer to the head node of a doubly linked list.
1356 @param Node A pointer to a node in the doubly linked list.
1358 @retval TRUE Node is one of the nodes in the doubly linked list.
1359 @retval FALSE Node is not one of the nodes in the doubly linked list.
1365 IN CONST LIST_ENTRY
*List
,
1366 IN CONST LIST_ENTRY
*Node
1370 Determines if a node the last node in a doubly linked list.
1372 Returns TRUE if Node is the last node in the doubly linked list specified by
1373 List. Otherwise, FALSE is returned. List must have been initialized with
1374 InitializeListHead().
1376 If List is NULL, then ASSERT().
1377 If Node is NULL, then ASSERT().
1378 If List was not initialized with InitializeListHead(), then ASSERT().
1379 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1380 in List, including the List node, is greater than or equal to
1381 PcdMaximumLinkedListLength, then ASSERT().
1382 If Node is not a node in List, then ASSERT().
1384 @param List A pointer to the head node of a doubly linked list.
1385 @param Node A pointer to a node in the doubly linked list.
1387 @retval TRUE Node is the last node in the linked list.
1388 @retval FALSE Node is not the last node in the linked list.
1394 IN CONST LIST_ENTRY
*List
,
1395 IN CONST LIST_ENTRY
*Node
1399 Swaps the location of two nodes in a doubly linked list, and returns the
1400 first node after the swap.
1402 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
1403 Otherwise, the location of the FirstEntry node is swapped with the location
1404 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
1405 same double linked list as FirstEntry and that double linked list must have
1406 been initialized with InitializeListHead(). SecondEntry is returned after the
1409 If FirstEntry is NULL, then ASSERT().
1410 If SecondEntry is NULL, then ASSERT().
1411 If SecondEntry and FirstEntry are not in the same linked list, then ASSERT().
1412 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1413 linked list containing the FirstEntry and SecondEntry nodes, including
1414 the FirstEntry and SecondEntry nodes, is greater than or equal to
1415 PcdMaximumLinkedListLength, then ASSERT().
1417 @param FirstEntry A pointer to a node in a linked list.
1418 @param SecondEntry A pointer to another node in the same linked list.
1424 IN LIST_ENTRY
*FirstEntry
,
1425 IN LIST_ENTRY
*SecondEntry
1429 Removes a node from a doubly linked list, and returns the node that follows
1432 Removes the node Entry from a doubly linked list. It is up to the caller of
1433 this function to release the memory used by this node if that is required. On
1434 exit, the node following Entry in the doubly linked list is returned. If
1435 Entry is the only node in the linked list, then the head node of the linked
1438 If Entry is NULL, then ASSERT().
1439 If Entry is the head node of an empty list, then ASSERT().
1440 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1441 linked list containing Entry, including the Entry node, is greater than
1442 or equal to PcdMaximumLinkedListLength, then ASSERT().
1444 @param Entry A pointer to a node in a linked list
1452 IN CONST LIST_ENTRY
*Entry
1460 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
1461 with zeros. The shifted value is returned.
1463 This function shifts the 64-bit value Operand to the left by Count bits. The
1464 low Count bits are set to zero. The shifted value is returned.
1466 If Count is greater than 63, then ASSERT().
1468 @param Operand The 64-bit operand to shift left.
1469 @param Count The number of bits to shift left.
1471 @return Operand << Count
1482 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
1483 filled with zeros. The shifted value is returned.
1485 This function shifts the 64-bit value Operand to the right by Count bits. The
1486 high Count bits are set to zero. The shifted value is returned.
1488 If Count is greater than 63, then ASSERT().
1490 @param Operand The 64-bit operand to shift right.
1491 @param Count The number of bits to shift right.
1493 @return Operand >> Count
1504 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
1505 with original integer's bit 63. The shifted value is returned.
1507 This function shifts the 64-bit value Operand to the right by Count bits. The
1508 high Count bits are set to bit 63 of Operand. The shifted value is returned.
1510 If Count is greater than 63, then ASSERT().
1512 @param Operand The 64-bit operand to shift right.
1513 @param Count The number of bits to shift right.
1515 @return Operand >> Count
1526 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
1527 with the high bits that were rotated.
1529 This function rotates the 32-bit value Operand to the left by Count bits. The
1530 low Count bits are fill with the high Count bits of Operand. The rotated
1533 If Count is greater than 31, then ASSERT().
1535 @param Operand The 32-bit operand to rotate left.
1536 @param Count The number of bits to rotate left.
1538 @return Operand <<< Count
1549 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
1550 with the low bits that were rotated.
1552 This function rotates the 32-bit value Operand to the right by Count bits.
1553 The high Count bits are fill with the low Count bits of Operand. The rotated
1556 If Count is greater than 31, then ASSERT().
1558 @param Operand The 32-bit operand to rotate right.
1559 @param Count The number of bits to rotate right.
1561 @return Operand >>> Count
1572 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
1573 with the high bits that were rotated.
1575 This function rotates the 64-bit value Operand to the left by Count bits. The
1576 low Count bits are fill with the high Count bits of Operand. The rotated
1579 If Count is greater than 63, then ASSERT().
1581 @param Operand The 64-bit operand to rotate left.
1582 @param Count The number of bits to rotate left.
1584 @return Operand <<< Count
1595 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
1596 with the high low bits that were rotated.
1598 This function rotates the 64-bit value Operand to the right by Count bits.
1599 The high Count bits are fill with the low Count bits of Operand. The rotated
1602 If Count is greater than 63, then ASSERT().
1604 @param Operand The 64-bit operand to rotate right.
1605 @param Count The number of bits to rotate right.
1607 @return Operand >>> Count
1618 Returns the bit position of the lowest bit set in a 32-bit value.
1620 This function computes the bit position of the lowest bit set in the 32-bit
1621 value specified by Operand. If Operand is zero, then -1 is returned.
1622 Otherwise, a value between 0 and 31 is returned.
1624 @param Operand The 32-bit operand to evaluate.
1626 @return Position of the lowest bit set in Operand if found.
1627 @retval -1 Operand is zero.
1637 Returns the bit position of the lowest bit set in a 64-bit value.
1639 This function computes the bit position of the lowest bit set in the 64-bit
1640 value specified by Operand. If Operand is zero, then -1 is returned.
1641 Otherwise, a value between 0 and 63 is returned.
1643 @param Operand The 64-bit operand to evaluate.
1645 @return Position of the lowest bit set in Operand if found.
1646 @retval -1 Operand is zero.
1656 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
1659 This function computes the bit position of the highest bit set in the 32-bit
1660 value specified by Operand. If Operand is zero, then -1 is returned.
1661 Otherwise, a value between 0 and 31 is returned.
1663 @param Operand The 32-bit operand to evaluate.
1665 @return Position of the highest bit set in Operand if found.
1666 @retval -1 Operand is zero.
1676 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
1679 This function computes the bit position of the highest bit set in the 64-bit
1680 value specified by Operand. If Operand is zero, then -1 is returned.
1681 Otherwise, a value between 0 and 63 is returned.
1683 @param Operand The 64-bit operand to evaluate.
1685 @return Position of the highest bit set in Operand if found.
1686 @retval -1 Operand is zero.
1696 Returns the value of the highest bit set in a 32-bit value. Equivalent to
1697 1 << HighBitSet32(x).
1699 This function computes the value of the highest bit set in the 32-bit value
1700 specified by Operand. If Operand is zero, then zero is returned.
1702 @param Operand The 32-bit operand to evaluate.
1704 @return 1 << HighBitSet32(Operand)
1705 @retval 0 Operand is zero.
1715 Returns the value of the highest bit set in a 64-bit value. Equivalent to
1716 1 << HighBitSet64(x).
1718 This function computes the value of the highest bit set in the 64-bit value
1719 specified by Operand. If Operand is zero, then zero is returned.
1721 @param Operand The 64-bit operand to evaluate.
1723 @return 1 << HighBitSet64(Operand)
1724 @retval 0 Operand is zero.
1734 Switches the endianess of a 16-bit integer.
1736 This function swaps the bytes in a 16-bit unsigned value to switch the value
1737 from little endian to big endian or vice versa. The byte swapped value is
1740 @param Operand A 16-bit unsigned value.
1742 @return The byte swaped Operand.
1752 Switches the endianess of a 32-bit integer.
1754 This function swaps the bytes in a 32-bit unsigned value to switch the value
1755 from little endian to big endian or vice versa. The byte swapped value is
1758 @param Operand A 32-bit unsigned value.
1760 @return The byte swaped Operand.
1770 Switches the endianess of a 64-bit integer.
1772 This function swaps the bytes in a 64-bit unsigned value to switch the value
1773 from little endian to big endian or vice versa. The byte swapped value is
1776 @param Operand A 64-bit unsigned value.
1778 @return The byte swaped Operand.
1788 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
1789 generates a 64-bit unsigned result.
1791 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
1792 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1793 bit unsigned result is returned.
1795 If the result overflows, then ASSERT().
1797 @param Multiplicand A 64-bit unsigned value.
1798 @param Multiplier A 32-bit unsigned value.
1800 @return Multiplicand * Multiplier
1806 IN UINT64 Multiplicand
,
1807 IN UINT32 Multiplier
1811 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
1812 generates a 64-bit unsigned result.
1814 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
1815 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1816 bit unsigned result is returned.
1818 If the result overflows, then ASSERT().
1820 @param Multiplicand A 64-bit unsigned value.
1821 @param Multiplier A 64-bit unsigned value.
1823 @return Multiplicand * Multiplier
1829 IN UINT64 Multiplicand
,
1830 IN UINT64 Multiplier
1834 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
1835 64-bit signed result.
1837 This function multiples the 64-bit signed value Multiplicand by the 64-bit
1838 signed value Multiplier and generates a 64-bit signed result. This 64-bit
1839 signed result is returned.
1841 If the result overflows, then ASSERT().
1843 @param Multiplicand A 64-bit signed value.
1844 @param Multiplier A 64-bit signed value.
1846 @return Multiplicand * Multiplier
1852 IN INT64 Multiplicand
,
1857 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1858 a 64-bit unsigned result.
1860 This function divides the 64-bit unsigned value Dividend by the 32-bit
1861 unsigned value Divisor and generates a 64-bit unsigned quotient. This
1862 function returns the 64-bit unsigned quotient.
1864 If Divisor is 0, then ASSERT().
1866 @param Dividend A 64-bit unsigned value.
1867 @param Divisor A 32-bit unsigned value.
1869 @return Dividend / Divisor
1880 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1881 a 32-bit unsigned remainder.
1883 This function divides the 64-bit unsigned value Dividend by the 32-bit
1884 unsigned value Divisor and generates a 32-bit remainder. This function
1885 returns the 32-bit unsigned remainder.
1887 If Divisor is 0, then ASSERT().
1889 @param Dividend A 64-bit unsigned value.
1890 @param Divisor A 32-bit unsigned value.
1892 @return Dividend % Divisor
1903 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1904 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
1906 This function divides the 64-bit unsigned value Dividend by the 32-bit
1907 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
1908 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
1909 This function returns the 64-bit unsigned quotient.
1911 If Divisor is 0, then ASSERT().
1913 @param Dividend A 64-bit unsigned value.
1914 @param Divisor A 32-bit unsigned value.
1915 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
1916 optional and may be NULL.
1918 @return Dividend / Divisor
1923 DivU64x32Remainder (
1926 OUT UINT32
*Remainder OPTIONAL
1930 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
1931 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
1933 This function divides the 64-bit unsigned value Dividend by the 64-bit
1934 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
1935 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
1936 This function returns the 64-bit unsigned quotient.
1938 If Divisor is 0, then ASSERT().
1940 @param Dividend A 64-bit unsigned value.
1941 @param Divisor A 64-bit unsigned value.
1942 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
1943 optional and may be NULL.
1945 @return Dividend / Divisor
1950 DivU64x64Remainder (
1953 OUT UINT64
*Remainder OPTIONAL
1957 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
1958 64-bit signed result and a optional 64-bit signed remainder.
1960 This function divides the 64-bit signed value Dividend by the 64-bit signed
1961 value Divisor and generates a 64-bit signed quotient. If Remainder is not
1962 NULL, then the 64-bit signed remainder is returned in Remainder. This
1963 function returns the 64-bit signed quotient.
1965 If Divisor is 0, then ASSERT().
1967 @param Dividend A 64-bit signed value.
1968 @param Divisor A 64-bit signed value.
1969 @param Remainder A pointer to a 64-bit signed value. This parameter is
1970 optional and may be NULL.
1972 @return Dividend / Divisor
1977 DivS64x64Remainder (
1980 OUT INT64
*Remainder OPTIONAL
1984 Reads a 16-bit value from memory that may be unaligned.
1986 This function returns the 16-bit value pointed to by Buffer. The function
1987 guarantees that the read operation does not produce an alignment fault.
1989 If the Buffer is NULL, then ASSERT().
1991 @param Buffer Pointer to a 16-bit value that may be unaligned.
1999 IN CONST UINT16
*Uint16
2003 Writes a 16-bit value to memory that may be unaligned.
2005 This function writes the 16-bit value specified by Value to Buffer. Value is
2006 returned. The function guarantees that the write operation does not produce
2009 If the Buffer is NULL, then ASSERT().
2011 @param Buffer Pointer to a 16-bit value that may be unaligned.
2012 @param Value 16-bit value to write to Buffer.
2025 Reads a 24-bit value from memory that may be unaligned.
2027 This function returns the 24-bit value pointed to by Buffer. The function
2028 guarantees that the read operation does not produce an alignment fault.
2030 If the Buffer is NULL, then ASSERT().
2032 @param Buffer Pointer to a 24-bit value that may be unaligned.
2034 @return The value read.
2040 IN CONST UINT32
*Buffer
2044 Writes a 24-bit value to memory that may be unaligned.
2046 This function writes the 24-bit value specified by Value to Buffer. Value is
2047 returned. The function guarantees that the write operation does not produce
2050 If the Buffer is NULL, then ASSERT().
2052 @param Buffer Pointer to a 24-bit value that may be unaligned.
2053 @param Value 24-bit value to write to Buffer.
2055 @return The value written.
2066 Reads a 32-bit value from memory that may be unaligned.
2068 This function returns the 32-bit value pointed to by Buffer. The function
2069 guarantees that the read operation does not produce an alignment fault.
2071 If the Buffer is NULL, then ASSERT().
2073 @param Buffer Pointer to a 32-bit value that may be unaligned.
2081 IN CONST UINT32
*Uint32
2085 Writes a 32-bit value to memory that may be unaligned.
2087 This function writes the 32-bit value specified by Value to Buffer. Value is
2088 returned. The function guarantees that the write operation does not produce
2091 If the Buffer is NULL, then ASSERT().
2093 @param Buffer Pointer to a 32-bit value that may be unaligned.
2094 @param Value 32-bit value to write to Buffer.
2107 Reads a 64-bit value from memory that may be unaligned.
2109 This function returns the 64-bit value pointed to by Buffer. The function
2110 guarantees that the read operation does not produce an alignment fault.
2112 If the Buffer is NULL, then ASSERT().
2114 @param Buffer Pointer to a 64-bit value that may be unaligned.
2122 IN CONST UINT64
*Uint64
2126 Writes a 64-bit value to memory that may be unaligned.
2128 This function writes the 64-bit value specified by Value to Buffer. Value is
2129 returned. The function guarantees that the write operation does not produce
2132 If the Buffer is NULL, then ASSERT().
2134 @param Buffer Pointer to a 64-bit value that may be unaligned.
2135 @param Value 64-bit value to write to Buffer.
2148 // Bit Field Functions
2152 Returns a bit field from an 8-bit value.
2154 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2156 If 8-bit operations are not supported, then ASSERT().
2157 If StartBit is greater than 7, then ASSERT().
2158 If EndBit is greater than 7, then ASSERT().
2159 If EndBit is less than StartBit, then ASSERT().
2161 @param Operand Operand on which to perform the bitfield operation.
2162 @param StartBit The ordinal of the least significant bit in the bit field.
2164 @param EndBit The ordinal of the most significant bit in the bit field.
2167 @return The bit field read.
2179 Writes a bit field to an 8-bit value, and returns the result.
2181 Writes Value to the bit field specified by the StartBit and the EndBit in
2182 Operand. All other bits in Operand are preserved. The new 8-bit value is
2185 If 8-bit operations are not supported, then ASSERT().
2186 If StartBit is greater than 7, then ASSERT().
2187 If EndBit is greater than 7, then ASSERT().
2188 If EndBit is less than StartBit, then ASSERT().
2190 @param Operand Operand on which to perform the bitfield operation.
2191 @param StartBit The ordinal of the least significant bit in the bit field.
2193 @param EndBit The ordinal of the most significant bit in the bit field.
2195 @param Value New value of the bit field.
2197 @return The new 8-bit value.
2210 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
2213 Performs a bitwise inclusive OR between the bit field specified by StartBit
2214 and EndBit in Operand and the value specified by OrData. All other bits in
2215 Operand are preserved. The new 8-bit value is returned.
2217 If 8-bit operations are not supported, then ASSERT().
2218 If StartBit is greater than 7, then ASSERT().
2219 If EndBit is greater than 7, then ASSERT().
2220 If EndBit is less than StartBit, then ASSERT().
2222 @param Operand Operand on which to perform the bitfield operation.
2223 @param StartBit The ordinal of the least significant bit in the bit field.
2225 @param EndBit The ordinal of the most significant bit in the bit field.
2227 @param OrData The value to OR with the read value from the value
2229 @return The new 8-bit value.
2242 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
2245 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2246 in Operand and the value specified by AndData. All other bits in Operand are
2247 preserved. The new 8-bit value is returned.
2249 If 8-bit operations are not supported, then ASSERT().
2250 If StartBit is greater than 7, then ASSERT().
2251 If EndBit is greater than 7, then ASSERT().
2252 If EndBit is less than StartBit, then ASSERT().
2254 @param Operand Operand on which to perform the bitfield operation.
2255 @param StartBit The ordinal of the least significant bit in the bit field.
2257 @param EndBit The ordinal of the most significant bit in the bit field.
2259 @param AndData The value to AND with the read value from the value.
2261 @return The new 8-bit value.
2274 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
2275 bitwise OR, and returns the result.
2277 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2278 in Operand and the value specified by AndData, followed by a bitwise
2279 inclusive OR with value specified by OrData. All other bits in Operand are
2280 preserved. The new 8-bit value is returned.
2282 If 8-bit operations are not supported, then ASSERT().
2283 If StartBit is greater than 7, then ASSERT().
2284 If EndBit is greater than 7, then ASSERT().
2285 If EndBit is less than StartBit, then ASSERT().
2287 @param Operand Operand on which to perform the bitfield operation.
2288 @param StartBit The ordinal of the least significant bit in the bit field.
2290 @param EndBit The ordinal of the most significant bit in the bit field.
2292 @param AndData The value to AND with the read value from the value.
2293 @param OrData The value to OR with the result of the AND operation.
2295 @return The new 8-bit value.
2300 BitFieldAndThenOr8 (
2309 Returns a bit field from a 16-bit value.
2311 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2313 If 16-bit operations are not supported, then ASSERT().
2314 If StartBit is greater than 15, then ASSERT().
2315 If EndBit is greater than 15, then ASSERT().
2316 If EndBit is less than StartBit, then ASSERT().
2318 @param Operand Operand on which to perform the bitfield operation.
2319 @param StartBit The ordinal of the least significant bit in the bit field.
2321 @param EndBit The ordinal of the most significant bit in the bit field.
2324 @return The bit field read.
2336 Writes a bit field to a 16-bit value, and returns the result.
2338 Writes Value to the bit field specified by the StartBit and the EndBit in
2339 Operand. All other bits in Operand are preserved. The new 16-bit value is
2342 If 16-bit operations are not supported, then ASSERT().
2343 If StartBit is greater than 15, then ASSERT().
2344 If EndBit is greater than 15, then ASSERT().
2345 If EndBit is less than StartBit, then ASSERT().
2347 @param Operand Operand on which to perform the bitfield operation.
2348 @param StartBit The ordinal of the least significant bit in the bit field.
2350 @param EndBit The ordinal of the most significant bit in the bit field.
2352 @param Value New value of the bit field.
2354 @return The new 16-bit value.
2367 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
2370 Performs a bitwise inclusive OR between the bit field specified by StartBit
2371 and EndBit in Operand and the value specified by OrData. All other bits in
2372 Operand are preserved. The new 16-bit value is returned.
2374 If 16-bit operations are not supported, then ASSERT().
2375 If StartBit is greater than 15, then ASSERT().
2376 If EndBit is greater than 15, then ASSERT().
2377 If EndBit is less than StartBit, then ASSERT().
2379 @param Operand Operand on which to perform the bitfield operation.
2380 @param StartBit The ordinal of the least significant bit in the bit field.
2382 @param EndBit The ordinal of the most significant bit in the bit field.
2384 @param OrData The value to OR with the read value from the value
2386 @return The new 16-bit value.
2399 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
2402 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2403 in Operand and the value specified by AndData. All other bits in Operand are
2404 preserved. The new 16-bit value is returned.
2406 If 16-bit operations are not supported, then ASSERT().
2407 If StartBit is greater than 15, then ASSERT().
2408 If EndBit is greater than 15, then ASSERT().
2409 If EndBit is less than StartBit, then ASSERT().
2411 @param Operand Operand on which to perform the bitfield operation.
2412 @param StartBit The ordinal of the least significant bit in the bit field.
2414 @param EndBit The ordinal of the most significant bit in the bit field.
2416 @param AndData The value to AND with the read value from the value
2418 @return The new 16-bit value.
2431 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
2432 bitwise OR, and returns the result.
2434 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2435 in Operand and the value specified by AndData, followed by a bitwise
2436 inclusive OR with value specified by OrData. All other bits in Operand are
2437 preserved. The new 16-bit value is returned.
2439 If 16-bit operations are not supported, then ASSERT().
2440 If StartBit is greater than 15, then ASSERT().
2441 If EndBit is greater than 15, then ASSERT().
2442 If EndBit is less than StartBit, then ASSERT().
2444 @param Operand Operand on which to perform the bitfield operation.
2445 @param StartBit The ordinal of the least significant bit in the bit field.
2447 @param EndBit The ordinal of the most significant bit in the bit field.
2449 @param AndData The value to AND with the read value from the value.
2450 @param OrData The value to OR with the result of the AND operation.
2452 @return The new 16-bit value.
2457 BitFieldAndThenOr16 (
2466 Returns a bit field from a 32-bit value.
2468 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2470 If 32-bit operations are not supported, then ASSERT().
2471 If StartBit is greater than 31, then ASSERT().
2472 If EndBit is greater than 31, then ASSERT().
2473 If EndBit is less than StartBit, then ASSERT().
2475 @param Operand Operand on which to perform the bitfield operation.
2476 @param StartBit The ordinal of the least significant bit in the bit field.
2478 @param EndBit The ordinal of the most significant bit in the bit field.
2481 @return The bit field read.
2493 Writes a bit field to a 32-bit value, and returns the result.
2495 Writes Value to the bit field specified by the StartBit and the EndBit in
2496 Operand. All other bits in Operand are preserved. The new 32-bit value is
2499 If 32-bit operations are not supported, then ASSERT().
2500 If StartBit is greater than 31, then ASSERT().
2501 If EndBit is greater than 31, then ASSERT().
2502 If EndBit is less than StartBit, then ASSERT().
2504 @param Operand Operand on which to perform the bitfield operation.
2505 @param StartBit The ordinal of the least significant bit in the bit field.
2507 @param EndBit The ordinal of the most significant bit in the bit field.
2509 @param Value New value of the bit field.
2511 @return The new 32-bit value.
2524 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
2527 Performs a bitwise inclusive OR between the bit field specified by StartBit
2528 and EndBit in Operand and the value specified by OrData. All other bits in
2529 Operand are preserved. The new 32-bit value is returned.
2531 If 32-bit operations are not supported, then ASSERT().
2532 If StartBit is greater than 31, then ASSERT().
2533 If EndBit is greater than 31, then ASSERT().
2534 If EndBit is less than StartBit, then ASSERT().
2536 @param Operand Operand on which to perform the bitfield operation.
2537 @param StartBit The ordinal of the least significant bit in the bit field.
2539 @param EndBit The ordinal of the most significant bit in the bit field.
2541 @param OrData The value to OR with the read value from the value
2543 @return The new 32-bit value.
2556 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
2559 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2560 in Operand and the value specified by AndData. All other bits in Operand are
2561 preserved. The new 32-bit value is returned.
2563 If 32-bit operations are not supported, then ASSERT().
2564 If StartBit is greater than 31, then ASSERT().
2565 If EndBit is greater than 31, then ASSERT().
2566 If EndBit is less than StartBit, then ASSERT().
2568 @param Operand Operand on which to perform the bitfield operation.
2569 @param StartBit The ordinal of the least significant bit in the bit field.
2571 @param EndBit The ordinal of the most significant bit in the bit field.
2573 @param AndData The value to AND with the read value from the value
2575 @return The new 32-bit value.
2588 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
2589 bitwise OR, and returns the result.
2591 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2592 in Operand and the value specified by AndData, followed by a bitwise
2593 inclusive OR with value specified by OrData. All other bits in Operand are
2594 preserved. The new 32-bit value is returned.
2596 If 32-bit operations are not supported, then ASSERT().
2597 If StartBit is greater than 31, then ASSERT().
2598 If EndBit is greater than 31, then ASSERT().
2599 If EndBit is less than StartBit, then ASSERT().
2601 @param Operand Operand on which to perform the bitfield operation.
2602 @param StartBit The ordinal of the least significant bit in the bit field.
2604 @param EndBit The ordinal of the most significant bit in the bit field.
2606 @param AndData The value to AND with the read value from the value.
2607 @param OrData The value to OR with the result of the AND operation.
2609 @return The new 32-bit value.
2614 BitFieldAndThenOr32 (
2623 Returns a bit field from a 64-bit value.
2625 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2627 If 64-bit operations are not supported, then ASSERT().
2628 If StartBit is greater than 63, then ASSERT().
2629 If EndBit is greater than 63, then ASSERT().
2630 If EndBit is less than StartBit, then ASSERT().
2632 @param Operand Operand on which to perform the bitfield operation.
2633 @param StartBit The ordinal of the least significant bit in the bit field.
2635 @param EndBit The ordinal of the most significant bit in the bit field.
2638 @return The bit field read.
2650 Writes a bit field to a 64-bit value, and returns the result.
2652 Writes Value to the bit field specified by the StartBit and the EndBit in
2653 Operand. All other bits in Operand are preserved. The new 64-bit value is
2656 If 64-bit operations are not supported, then ASSERT().
2657 If StartBit is greater than 63, then ASSERT().
2658 If EndBit is greater than 63, then ASSERT().
2659 If EndBit is less than StartBit, then ASSERT().
2661 @param Operand Operand on which to perform the bitfield operation.
2662 @param StartBit The ordinal of the least significant bit in the bit field.
2664 @param EndBit The ordinal of the most significant bit in the bit field.
2666 @param Value New value of the bit field.
2668 @return The new 64-bit value.
2681 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
2684 Performs a bitwise inclusive OR between the bit field specified by StartBit
2685 and EndBit in Operand and the value specified by OrData. All other bits in
2686 Operand are preserved. The new 64-bit value is returned.
2688 If 64-bit operations are not supported, then ASSERT().
2689 If StartBit is greater than 63, then ASSERT().
2690 If EndBit is greater than 63, then ASSERT().
2691 If EndBit is less than StartBit, then ASSERT().
2693 @param Operand Operand on which to perform the bitfield operation.
2694 @param StartBit The ordinal of the least significant bit in the bit field.
2696 @param EndBit The ordinal of the most significant bit in the bit field.
2698 @param OrData The value to OR with the read value from the value
2700 @return The new 64-bit value.
2713 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
2716 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2717 in Operand and the value specified by AndData. All other bits in Operand are
2718 preserved. The new 64-bit value is returned.
2720 If 64-bit operations are not supported, then ASSERT().
2721 If StartBit is greater than 63, then ASSERT().
2722 If EndBit is greater than 63, 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 AndData The value to AND with the read value from the value
2732 @return The new 64-bit value.
2745 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
2746 bitwise OR, and returns the result.
2748 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2749 in Operand and the value specified by AndData, followed by a bitwise
2750 inclusive OR with value specified by OrData. All other bits in Operand are
2751 preserved. The new 64-bit value is returned.
2753 If 64-bit operations are not supported, then ASSERT().
2754 If StartBit is greater than 63, then ASSERT().
2755 If EndBit is greater than 63, 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 AndData The value to AND with the read value from the value.
2764 @param OrData The value to OR with the result of the AND operation.
2766 @return The new 64-bit value.
2771 BitFieldAndThenOr64 (
2780 // Base Library Synchronization Functions
2784 Retrieves the architecture specific spin lock alignment requirements for
2785 optimal spin lock performance.
2787 This function retrieves the spin lock alignment requirements for optimal
2788 performance on a given CPU architecture. The spin lock alignment must be a
2789 power of two and is returned by this function. If there are no alignment
2790 requirements, then 1 must be returned. The spin lock synchronization
2791 functions must function correctly if the spin lock size and alignment values
2792 returned by this function are not used at all. These values are hints to the
2793 consumers of the spin lock synchronization functions to obtain optimal spin
2796 @return The architecture specific spin lock alignment.
2801 GetSpinLockProperties (
2806 Initializes a spin lock to the released state and returns the spin lock.
2808 This function initializes the spin lock specified by SpinLock to the released
2809 state, and returns SpinLock. Optimal performance can be achieved by calling
2810 GetSpinLockProperties() to determine the size and alignment requirements for
2813 If SpinLock is NULL, then ASSERT().
2815 @param SpinLock A pointer to the spin lock to initialize to the released
2823 InitializeSpinLock (
2824 IN SPIN_LOCK
*SpinLock
2828 Waits until a spin lock can be placed in the acquired state.
2830 This function checks the state of the spin lock specified by SpinLock. If
2831 SpinLock is in the released state, then this function places SpinLock in the
2832 acquired state and returns SpinLock. Otherwise, this function waits
2833 indefinitely for the spin lock to be released, and then places it in the
2834 acquired state and returns SpinLock. All state transitions of SpinLock must
2835 be performed using MP safe mechanisms.
2837 If SpinLock is NULL, then ASSERT().
2838 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
2839 If PcdSpinLockTimeout is not zero, and SpinLock is can not be acquired in
2840 PcdSpinLockTimeout microseconds, then ASSERT().
2842 @param SpinLock A pointer to the spin lock to place in the acquired state.
2850 IN SPIN_LOCK
*SpinLock
2854 Attempts to place a spin lock in the acquired state.
2856 This function checks the state of the spin lock specified by SpinLock. If
2857 SpinLock is in the released state, then this function places SpinLock in the
2858 acquired state and returns TRUE. Otherwise, FALSE is returned. All state
2859 transitions of SpinLock must be performed using MP safe mechanisms.
2861 If SpinLock is NULL, then ASSERT().
2862 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
2864 @param SpinLock A pointer to the spin lock to place in the acquired state.
2866 @retval TRUE SpinLock was placed in the acquired state.
2867 @retval FALSE SpinLock could not be acquired.
2872 AcquireSpinLockOrFail (
2873 IN SPIN_LOCK
*SpinLock
2877 Releases a spin lock.
2879 This function places the spin lock specified by SpinLock in the release state
2880 and returns SpinLock.
2882 If SpinLock is NULL, then ASSERT().
2883 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
2885 @param SpinLock A pointer to the spin lock to release.
2893 IN SPIN_LOCK
*SpinLock
2897 Performs an atomic increment of an 32-bit unsigned integer.
2899 Performs an atomic increment of the 32-bit unsigned integer specified by
2900 Value and returns the incremented value. The increment operation must be
2901 performed using MP safe mechanisms. The state of the return value is not
2902 guaranteed to be MP safe.
2904 If Value is NULL, then ASSERT().
2906 @param Value A pointer to the 32-bit value to increment.
2908 @return The incremented value.
2913 InterlockedIncrement (
2918 Performs an atomic decrement of an 32-bit unsigned integer.
2920 Performs an atomic decrement of the 32-bit unsigned integer specified by
2921 Value and returns the decremented value. The decrement operation must be
2922 performed using MP safe mechanisms. The state of the return value is not
2923 guaranteed to be MP safe.
2925 If Value is NULL, then ASSERT().
2927 @param Value A pointer to the 32-bit value to decrement.
2929 @return The decremented value.
2934 InterlockedDecrement (
2939 Performs an atomic compare exchange operation on a 32-bit unsigned integer.
2941 Performs an atomic compare exchange operation on the 32-bit unsigned integer
2942 specified by Value. If Value is equal to CompareValue, then Value is set to
2943 ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,
2944 then Value is returned. The compare exchange operation must be performed using
2947 If Value is NULL, then ASSERT().
2949 @param Value A pointer to the 32-bit value for the compare exchange
2951 @param CompareValue 32-bit value used in compare operation.
2952 @param ExchangeValue 32-bit value used in exchange operation.
2954 @return The original *Value before exchange.
2959 InterlockedCompareExchange32 (
2960 IN OUT UINT32
*Value
,
2961 IN UINT32 CompareValue
,
2962 IN UINT32 ExchangeValue
2966 Performs an atomic compare exchange operation on a 64-bit unsigned integer.
2968 Performs an atomic compare exchange operation on the 64-bit unsigned integer specified
2969 by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and
2970 CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.
2971 The compare exchange operation must be performed using MP safe mechanisms.
2973 If Value is NULL, then ASSERT().
2975 @param Value A pointer to the 64-bit value for the compare exchange
2977 @param CompareValue 64-bit value used in compare operation.
2978 @param ExchangeValue 64-bit value used in exchange operation.
2980 @return The original *Value before exchange.
2985 InterlockedCompareExchange64 (
2986 IN OUT UINT64
*Value
,
2987 IN UINT64 CompareValue
,
2988 IN UINT64 ExchangeValue
2992 Performs an atomic compare exchange operation on a pointer value.
2994 Performs an atomic compare exchange operation on the pointer value specified
2995 by Value. If Value is equal to CompareValue, then Value is set to
2996 ExchangeValue and CompareValue is returned. If Value is not equal to
2997 CompareValue, then Value is returned. The compare exchange operation must be
2998 performed using MP safe mechanisms.
3000 If Value is NULL, then ASSERT().
3002 @param Value A pointer to the pointer value for the compare exchange
3004 @param CompareValue Pointer value used in compare operation.
3005 @param ExchangeValue Pointer value used in exchange operation.
3010 InterlockedCompareExchangePointer (
3011 IN OUT VOID
**Value
,
3012 IN VOID
*CompareValue
,
3013 IN VOID
*ExchangeValue
3017 // Base Library Checksum Functions
3021 Calculate the sum of all elements in a buffer in unit of UINT8.
3022 During calculation, the carry bits are dropped.
3024 This function calculates the sum of all elements in a buffer
3025 in unit of UINT8. The carry bits in result of addition are dropped.
3026 The result is returned as UINT8. If Length is Zero, then Zero is
3029 If Buffer is NULL, then ASSERT().
3030 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3032 @param Buffer Pointer to the buffer to carry out the sum operation.
3033 @param Length The size, in bytes, of Buffer .
3035 @return Sum The sum of Buffer with carry bits dropped during additions.
3041 IN CONST UINT8
*Buffer
,
3047 Returns the two's complement checksum of all elements in a buffer
3050 This function first calculates the sum of the 8-bit values in the
3051 buffer specified by Buffer and Length. The carry bits in the result
3052 of addition are dropped. Then, the two's complement of the sum is
3053 returned. If Length is 0, then 0 is returned.
3055 If Buffer is NULL, then ASSERT().
3056 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3059 @param Buffer Pointer to the buffer to carry out the checksum operation.
3060 @param Length The size, in bytes, of Buffer.
3062 @return Checksum The 2's complement checksum of Buffer.
3067 CalculateCheckSum8 (
3068 IN CONST UINT8
*Buffer
,
3073 Returns the sum of all elements in a buffer of 16-bit values. During
3074 calculation, the carry bits are dropped.
3076 This function calculates the sum of the 16-bit values in the buffer
3077 specified by Buffer and Length. The carry bits in result of addition are dropped.
3078 The 16-bit result is returned. If Length is 0, then 0 is returned.
3080 If Buffer is NULL, then ASSERT().
3081 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3082 If Length is not aligned on a 16-bit boundary, then ASSERT().
3083 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3085 @param Buffer Pointer to the buffer to carry out the sum operation.
3086 @param Length The size, in bytes, of Buffer.
3088 @return Sum The sum of Buffer with carry bits dropped during additions.
3094 IN CONST UINT16
*Buffer
,
3099 Returns the two's complement checksum of all elements in a buffer of
3102 This function first calculates the sum of the 16-bit values in the buffer
3103 specified by Buffer and Length. The carry bits in the result of addition
3104 are dropped. Then, the two's complement of the sum is returned. If Length
3105 is 0, then 0 is returned.
3107 If Buffer is NULL, then ASSERT().
3108 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3109 If Length is not aligned on a 16-bit boundary, then ASSERT().
3110 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3112 @param Buffer Pointer to the buffer to carry out the checksum operation.
3113 @param Length The size, in bytes, of Buffer.
3115 @return Checksum The 2's complement checksum of Buffer.
3120 CalculateCheckSum16 (
3121 IN CONST UINT16
*Buffer
,
3126 Returns the sum of all elements in a buffer of 32-bit values. During
3127 calculation, the carry bits are dropped.
3129 This function calculates the sum of the 32-bit values in the buffer
3130 specified by Buffer and Length. The carry bits in result of addition are dropped.
3131 The 32-bit result is returned. If Length is 0, then 0 is returned.
3133 If Buffer is NULL, then ASSERT().
3134 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3135 If Length is not aligned on a 32-bit boundary, then ASSERT().
3136 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3138 @param Buffer Pointer to the buffer to carry out the sum operation.
3139 @param Length The size, in bytes, of Buffer.
3141 @return Sum The sum of Buffer with carry bits dropped during additions.
3147 IN CONST UINT32
*Buffer
,
3152 Returns the two's complement checksum of all elements in a buffer of
3155 This function first calculates the sum of the 32-bit values in the buffer
3156 specified by Buffer and Length. The carry bits in the result of addition
3157 are dropped. Then, the two's complement of the sum is returned. If Length
3158 is 0, then 0 is returned.
3160 If Buffer is NULL, then ASSERT().
3161 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3162 If Length is not aligned on a 32-bit boundary, then ASSERT().
3163 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3165 @param Buffer Pointer to the buffer to carry out the checksum operation.
3166 @param Length The size, in bytes, of Buffer.
3168 @return Checksum The 2's complement checksum of Buffer.
3173 CalculateCheckSum32 (
3174 IN CONST UINT32
*Buffer
,
3179 Returns the sum of all elements in a buffer of 64-bit values. During
3180 calculation, the carry bits are dropped.
3182 This function calculates the sum of the 64-bit values in the buffer
3183 specified by Buffer and Length. The carry bits in result of addition are dropped.
3184 The 64-bit result is returned. If Length is 0, then 0 is returned.
3186 If Buffer is NULL, then ASSERT().
3187 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3188 If Length is not aligned on a 64-bit boundary, then ASSERT().
3189 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3191 @param Buffer Pointer to the buffer to carry out the sum operation.
3192 @param Length The size, in bytes, of Buffer.
3194 @return Sum The sum of Buffer with carry bits dropped during additions.
3200 IN CONST UINT64
*Buffer
,
3205 Returns the two's complement checksum of all elements in a buffer of
3208 This function first calculates the sum of the 64-bit values in the buffer
3209 specified by Buffer and Length. The carry bits in the result of addition
3210 are dropped. Then, the two's complement of the sum is returned. If Length
3211 is 0, then 0 is returned.
3213 If Buffer is NULL, then ASSERT().
3214 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3215 If Length is not aligned on a 64-bit boundary, then ASSERT().
3216 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3218 @param Buffer Pointer to the buffer to carry out the checksum operation.
3219 @param Length The size, in bytes, of Buffer.
3221 @return Checksum The 2's complement checksum of Buffer.
3226 CalculateCheckSum64 (
3227 IN CONST UINT64
*Buffer
,
3232 // Base Library CPU Functions
3236 (EFIAPI
*SWITCH_STACK_ENTRY_POINT
) (
3237 IN VOID
*Context1
, OPTIONAL
3238 IN VOID
*Context2 OPTIONAL
3242 Used to serialize load and store operations.
3244 All loads and stores that proceed calls to this function are guaranteed to be
3245 globally visible when this function returns.
3255 Saves the current CPU context that can be restored with a call to LongJump()
3258 Saves the current CPU context in the buffer specified by JumpBuffer and
3259 returns 0. The initial call to SetJump() must always return 0. Subsequent
3260 calls to LongJump() cause a non-zero value to be returned by SetJump().
3262 If JumpBuffer is NULL, then ASSERT().
3263 For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3265 @param JumpBuffer A pointer to CPU context buffer.
3267 @retval 0 Indicates a return from SetJump().
3273 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
3277 Restores the CPU context that was saved with SetJump().
3279 Restores the CPU context from the buffer specified by JumpBuffer. This
3280 function never returns to the caller. Instead is resumes execution based on
3281 the state of JumpBuffer.
3283 If JumpBuffer is NULL, then ASSERT().
3284 For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3285 If Value is 0, then ASSERT().
3287 @param JumpBuffer A pointer to CPU context buffer.
3288 @param Value The value to return when the SetJump() context is
3289 restored and must be non-zero.
3295 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
3300 Enables CPU interrupts.
3302 Enables CPU interrupts.
3312 Disables CPU interrupts.
3314 Disables CPU interrupts.
3324 Disables CPU interrupts and returns the interrupt state prior to the disable
3327 Disables CPU interrupts and returns the interrupt state prior to the disable
3330 @retval TRUE CPU interrupts were enabled on entry to this call.
3331 @retval FALSE CPU interrupts were disabled on entry to this call.
3336 SaveAndDisableInterrupts (
3341 Enables CPU interrupts for the smallest window required to capture any
3344 Enables CPU interrupts for the smallest window required to capture any
3350 EnableDisableInterrupts (
3355 Retrieves the current CPU interrupt state.
3357 Retrieves the current CPU interrupt state. Returns TRUE is interrupts are
3358 currently enabled. Otherwise returns FALSE.
3360 @retval TRUE CPU interrupts are enabled.
3361 @retval FALSE CPU interrupts are disabled.
3371 Set the current CPU interrupt state.
3373 Sets the current CPU interrupt state to the state specified by
3374 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
3375 InterruptState is FALSE, then interrupts are disabled. InterruptState is
3378 @param InterruptState TRUE if interrupts should enabled. FALSE if
3379 interrupts should be disabled.
3381 @return InterruptState
3387 IN BOOLEAN InterruptState
3391 Places the CPU in a sleep state until an interrupt is received.
3393 Places the CPU in a sleep state until an interrupt is received. If interrupts
3394 are disabled prior to calling this function, then the CPU will be placed in a
3395 sleep state indefinitely.
3405 Requests CPU to pause for a short period of time.
3407 Requests CPU to pause for a short period of time. Typically used in MP
3408 systems to prevent memory starvation while waiting for a spin lock.
3418 Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU.
3420 Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU.
3430 Transfers control to a function starting with a new stack.
3432 Transfers control to the function specified by EntryPoint using the
3433 new stack specified by NewStack and passing in the parameters specified
3434 by Context1 and Context2. Context1 and Context2 are optional and may
3435 be NULL. The function EntryPoint must never return. This function
3436 supports a variable number of arguments following the NewStack parameter.
3437 These additional arguments are ignored on IA-32, x64, and EBC.
3438 IPF CPUs expect one additional parameter of type VOID * that specifies
3439 the new backing store pointer.
3441 If EntryPoint is NULL, then ASSERT().
3442 If NewStack is NULL, then ASSERT().
3444 @param EntryPoint A pointer to function to call with the new stack.
3445 @param Context1 A pointer to the context to pass into the EntryPoint
3447 @param Context2 A pointer to the context to pass into the EntryPoint
3449 @param NewStack A pointer to the new stack to use for the EntryPoint
3456 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
3457 IN VOID
*Context1
, OPTIONAL
3458 IN VOID
*Context2
, OPTIONAL
3464 Generates a breakpoint on the CPU.
3466 Generates a breakpoint on the CPU. The breakpoint must be implemented such
3467 that code can resume normal execution after the breakpoint.
3477 Executes an infinite loop.
3479 Forces the CPU to execute an infinite loop. A debugger may be used to skip
3480 past the loop and the code that follows the loop must execute properly. This
3481 implies that the infinite loop must not cause the code that follow it to be
3492 // IA32 and X64 Specific Functions
3495 // Byte packed structure for 16-bit Real Mode EFLAGS
3499 UINT32 CF
:1; // Carry Flag
3500 UINT32 Reserved_0
:1; // Reserved
3501 UINT32 PF
:1; // Parity Flag
3502 UINT32 Reserved_1
:1; // Reserved
3503 UINT32 AF
:1; // Auxiliary Carry Flag
3504 UINT32 Reserved_2
:1; // Reserved
3505 UINT32 ZF
:1; // Zero Flag
3506 UINT32 SF
:1; // Sign Flag
3507 UINT32 TF
:1; // Trap Flag
3508 UINT32 IF
:1; // Interrupt Enable Flag
3509 UINT32 DF
:1; // Direction Flag
3510 UINT32 OF
:1; // Overflow Flag
3511 UINT32 IOPL
:2; // I/O Privilege Level
3512 UINT32 NT
:1; // Nested Task
3513 UINT32 Reserved_3
:1; // Reserved
3519 // Byte packed structure for EFLAGS/RFLAGS
3521 // 64-bits on X64. The upper 32-bits on X64 are reserved
3525 UINT32 CF
:1; // Carry Flag
3526 UINT32 Reserved_0
:1; // Reserved
3527 UINT32 PF
:1; // Parity Flag
3528 UINT32 Reserved_1
:1; // Reserved
3529 UINT32 AF
:1; // Auxiliary Carry Flag
3530 UINT32 Reserved_2
:1; // Reserved
3531 UINT32 ZF
:1; // Zero Flag
3532 UINT32 SF
:1; // Sign Flag
3533 UINT32 TF
:1; // Trap Flag
3534 UINT32 IF
:1; // Interrupt Enable Flag
3535 UINT32 DF
:1; // Direction Flag
3536 UINT32 OF
:1; // Overflow Flag
3537 UINT32 IOPL
:2; // I/O Privilege Level
3538 UINT32 NT
:1; // Nested Task
3539 UINT32 Reserved_3
:1; // Reserved
3540 UINT32 RF
:1; // Resume Flag
3541 UINT32 VM
:1; // Virtual 8086 Mode
3542 UINT32 AC
:1; // Alignment Check
3543 UINT32 VIF
:1; // Virtual Interrupt Flag
3544 UINT32 VIP
:1; // Virtual Interrupt Pending
3545 UINT32 ID
:1; // ID Flag
3546 UINT32 Reserved_4
:10; // Reserved
3552 // Byte packed structure for Control Register 0 (CR0)
3554 // 64-bits on X64. The upper 32-bits on X64 are reserved
3558 UINT32 PE
:1; // Protection Enable
3559 UINT32 MP
:1; // Monitor Coprocessor
3560 UINT32 EM
:1; // Emulation
3561 UINT32 TS
:1; // Task Switched
3562 UINT32 ET
:1; // Extension Type
3563 UINT32 NE
:1; // Numeric Error
3564 UINT32 Reserved_0
:10; // Reserved
3565 UINT32 WP
:1; // Write Protect
3566 UINT32 Reserved_1
:1; // Reserved
3567 UINT32 AM
:1; // Alignment Mask
3568 UINT32 Reserved_2
:10; // Reserved
3569 UINT32 NW
:1; // Mot Write-through
3570 UINT32 CD
:1; // Cache Disable
3571 UINT32 PG
:1; // Paging
3577 // Byte packed structure for Control Register 4 (CR4)
3579 // 64-bits on X64. The upper 32-bits on X64 are reserved
3583 UINT32 VME
:1; // Virtual-8086 Mode Extensions
3584 UINT32 PVI
:1; // Protected-Mode Virtual Interrupts
3585 UINT32 TSD
:1; // Time Stamp Disable
3586 UINT32 DE
:1; // Debugging Extensions
3587 UINT32 PSE
:1; // Page Size Extensions
3588 UINT32 PAE
:1; // Physical Address Extension
3589 UINT32 MCE
:1; // Machine Check Enable
3590 UINT32 PGE
:1; // Page Global Enable
3591 UINT32 PCE
:1; // Performance Monitoring Counter
3593 UINT32 OSFXSR
:1; // Operating System Support for
3594 // FXSAVE and FXRSTOR instructions
3595 UINT32 OSXMMEXCPT
:1; // Operating System Support for
3596 // Unmasked SIMD Floating Point
3598 UINT32 Reserved_0
:2; // Reserved
3599 UINT32 VMXE
:1; // VMX Enable
3600 UINT32 Reserved_1
:18; // Reseved
3606 // Byte packed structure for an IDTR, GDTR, LDTR descriptor
3607 /// @bug How to make this structure byte-packed in a compiler independent way?
3616 #define IA32_IDT_GATE_TYPE_TASK 0x85
3617 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
3618 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
3619 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
3620 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
3623 // Byte packed structure for an Interrupt Gate Descriptor
3627 UINT32 OffsetLow
:16; // Offset bits 15..0
3628 UINT32 Selector
:16; // Selector
3629 UINT32 Reserved_0
:8; // Reserved
3630 UINT32 GateType
:8; // Gate Type. See #defines above
3631 UINT32 OffsetHigh
:16; // Offset bits 31..16
3634 } IA32_IDT_GATE_DESCRIPTOR
;
3637 // Byte packed structure for an FP/SSE/SSE2 context
3644 // Structures for the 16-bit real mode thunks
3697 IA32_EFLAGS32 EFLAGS
;
3707 } IA32_REGISTER_SET
;
3710 // Byte packed structure for an 16-bit real mode thunks
3713 IA32_REGISTER_SET
*RealModeState
;
3714 VOID
*RealModeBuffer
;
3715 UINT32 RealModeBufferSize
;
3716 UINT32 ThunkAttributes
;
3719 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
3720 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
3721 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
3724 Retrieves CPUID information.
3726 Executes the CPUID instruction with EAX set to the value specified by Index.
3727 This function always returns Index.
3728 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
3729 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
3730 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
3731 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
3732 This function is only available on IA-32 and X64.
3734 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
3736 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
3737 instruction. This is an optional parameter that may be NULL.
3738 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
3739 instruction. This is an optional parameter that may be NULL.
3740 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
3741 instruction. This is an optional parameter that may be NULL.
3742 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
3743 instruction. This is an optional parameter that may be NULL.
3752 OUT UINT32
*Eax
, OPTIONAL
3753 OUT UINT32
*Ebx
, OPTIONAL
3754 OUT UINT32
*Ecx
, OPTIONAL
3755 OUT UINT32
*Edx OPTIONAL
3759 Retrieves CPUID information using an extended leaf identifier.
3761 Executes the CPUID instruction with EAX set to the value specified by Index
3762 and ECX set to the value specified by SubIndex. This function always returns
3763 Index. This function is only available on IA-32 and x64.
3765 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
3766 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
3767 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
3768 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
3770 @param Index The 32-bit value to load into EAX prior to invoking the
3772 @param SubIndex The 32-bit value to load into ECX prior to invoking the
3774 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
3775 instruction. This is an optional parameter that may be
3777 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
3778 instruction. This is an optional parameter that may be
3780 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
3781 instruction. This is an optional parameter that may be
3783 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
3784 instruction. This is an optional parameter that may be
3795 OUT UINT32
*Eax
, OPTIONAL
3796 OUT UINT32
*Ebx
, OPTIONAL
3797 OUT UINT32
*Ecx
, OPTIONAL
3798 OUT UINT32
*Edx OPTIONAL
3802 Returns the lower 32-bits of a Machine Specific Register(MSR).
3804 Reads and returns the lower 32-bits of the MSR specified by Index.
3805 No parameter checking is performed on Index, and some Index values may cause
3806 CPU exceptions. The caller must either guarantee that Index is valid, or the
3807 caller must set up exception handlers to catch the exceptions. This function
3808 is only available on IA-32 and X64.
3810 @param Index The 32-bit MSR index to read.
3812 @return The lower 32 bits of the MSR identified by Index.
3822 Zero-extend a 32-bit value and writes it to a Machine Specific Register(MSR).
3824 Writes the 32-bit value specified by Value to the MSR specified by Index. The
3825 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
3826 the MSR is returned. No parameter checking is performed on Index or Value,
3827 and some of these may cause CPU exceptions. The caller must either guarantee
3828 that Index and Value are valid, or the caller must establish proper exception
3829 handlers. This function is only available on IA-32 and X64.
3831 @param Index The 32-bit MSR index to write.
3832 @param Value The 32-bit value to write to the MSR.
3845 Reads a 64-bit MSR, performs a bitwise inclusive OR on the lower 32-bits, and
3846 writes the result back to the 64-bit MSR.
3848 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
3849 between the lower 32-bits of the read result and the value specified by
3850 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
3851 32-bits of the value written to the MSR is returned. No parameter checking is
3852 performed on Index or OrData, and some of these may cause CPU exceptions. The
3853 caller must either guarantee that Index and OrData are valid, or the caller
3854 must establish proper exception handlers. This function is only available on
3857 @param Index The 32-bit MSR index to write.
3858 @param OrData The value to OR with the read value from the MSR.
3860 @return The lower 32-bit value written to the MSR.
3871 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
3872 the result back to the 64-bit MSR.
3874 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
3875 lower 32-bits of the read result and the value specified by AndData, and
3876 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
3877 the value written to the MSR is returned. No parameter checking is performed
3878 on Index or AndData, and some of these may cause CPU exceptions. The caller
3879 must either guarantee that Index and AndData are valid, or the caller must
3880 establish proper exception handlers. This function is only available on IA-32
3883 @param Index The 32-bit MSR index to write.
3884 @param AndData The value to AND with the read value from the MSR.
3886 @return The lower 32-bit value written to the MSR.
3897 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive OR
3898 on the lower 32-bits, and writes the result back to the 64-bit MSR.
3900 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
3901 lower 32-bits of the read result and the value specified by AndData
3902 preserving the upper 32-bits, performs a bitwise inclusive OR between the
3903 result of the AND operation and the value specified by OrData, and writes the
3904 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
3905 written to the MSR is returned. No parameter checking is performed on Index,
3906 AndData, or OrData, and some of these may cause CPU exceptions. The caller
3907 must either guarantee that Index, AndData, and OrData are valid, or the
3908 caller must establish proper exception handlers. This function is only
3909 available on IA-32 and X64.
3911 @param Index The 32-bit MSR index to write.
3912 @param AndData The value to AND with the read value from the MSR.
3913 @param OrData The value to OR with the result of the AND operation.
3915 @return The lower 32-bit value written to the MSR.
3927 Reads a bit field of an MSR.
3929 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
3930 specified by the StartBit and the EndBit. The value of the bit field is
3931 returned. The caller must either guarantee that Index is valid, or the caller
3932 must set up exception handlers to catch the exceptions. This function is only
3933 available on IA-32 and X64.
3935 If StartBit is greater than 31, then ASSERT().
3936 If EndBit is greater than 31, then ASSERT().
3937 If EndBit is less than StartBit, then ASSERT().
3939 @param Index The 32-bit MSR index to read.
3940 @param StartBit The ordinal of the least significant bit in the bit field.
3942 @param EndBit The ordinal of the most significant bit in the bit field.
3945 @return The bit field read from the MSR.
3950 AsmMsrBitFieldRead32 (
3957 Writes a bit field to an MSR.
3959 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
3960 field is specified by the StartBit and the EndBit. All other bits in the
3961 destination MSR are preserved. The lower 32-bits of the MSR written is
3962 returned. Extra left bits in Value are stripped. The caller must either
3963 guarantee that Index and the data written is valid, or the caller must set up
3964 exception handlers to catch the exceptions. This function is only available
3967 If StartBit is greater than 31, then ASSERT().
3968 If EndBit is greater than 31, then ASSERT().
3969 If EndBit is less than StartBit, then ASSERT().
3971 @param Index The 32-bit MSR index to write.
3972 @param StartBit The ordinal of the least significant bit in the bit field.
3974 @param EndBit The ordinal of the most significant bit in the bit field.
3976 @param Value New value of the bit field.
3978 @return The lower 32-bit of the value written to the MSR.
3983 AsmMsrBitFieldWrite32 (
3991 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
3992 result back to the bit field in the 64-bit MSR.
3994 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
3995 between the read result and the value specified by OrData, and writes the
3996 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
3997 written to the MSR are returned. Extra left bits in OrData are stripped. The
3998 caller must either guarantee that Index and the data written is valid, or
3999 the caller must set up exception handlers to catch the exceptions. This
4000 function is only available on IA-32 and X64.
4002 If StartBit is greater than 31, then ASSERT().
4003 If EndBit is greater than 31, then ASSERT().
4004 If EndBit is less than StartBit, then ASSERT().
4006 @param Index The 32-bit MSR index to write.
4007 @param StartBit The ordinal of the least significant bit in the bit field.
4009 @param EndBit The ordinal of the most significant bit in the bit field.
4011 @param OrData The value to OR with the read value from the MSR.
4013 @return The lower 32-bit of the value written to the MSR.
4018 AsmMsrBitFieldOr32 (
4026 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
4027 result back to the bit field in the 64-bit MSR.
4029 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
4030 read result and the value specified by AndData, and writes the result to the
4031 64-bit MSR specified by Index. The lower 32-bits of the value written to the
4032 MSR are returned. Extra left bits in AndData are stripped. The caller must
4033 either guarantee that Index and the data written is valid, or the caller must
4034 set up exception handlers to catch the exceptions. This function is only
4035 available on IA-32 and X64.
4037 If StartBit is greater than 31, then ASSERT().
4038 If EndBit is greater than 31, then ASSERT().
4039 If EndBit is less than StartBit, then ASSERT().
4041 @param Index The 32-bit MSR index to write.
4042 @param StartBit The ordinal of the least significant bit in the bit field.
4044 @param EndBit The ordinal of the most significant bit in the bit field.
4046 @param AndData The value to AND with the read value from the MSR.
4048 @return The lower 32-bit of the value written to the MSR.
4053 AsmMsrBitFieldAnd32 (
4061 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
4062 bitwise inclusive OR, and writes the result back to the bit field in the
4065 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
4066 bitwise inclusive OR between the read result and the value specified by
4067 AndData, and writes the result to the 64-bit MSR specified by Index. The
4068 lower 32-bits of the value written to the MSR are returned. Extra left bits
4069 in both AndData and OrData are stripped. The caller must either guarantee
4070 that Index and the data written is valid, or the caller must set up exception
4071 handlers to catch the exceptions. This function is only available on IA-32
4074 If StartBit is greater than 31, then ASSERT().
4075 If EndBit is greater than 31, then ASSERT().
4076 If EndBit is less than StartBit, then ASSERT().
4078 @param Index The 32-bit MSR index to write.
4079 @param StartBit The ordinal of the least significant bit in the bit field.
4081 @param EndBit The ordinal of the most significant bit in the bit field.
4083 @param AndData The value to AND with the read value from the MSR.
4084 @param OrData The value to OR with the result of the AND operation.
4086 @return The lower 32-bit of the value written to the MSR.
4091 AsmMsrBitFieldAndThenOr32 (
4100 Returns a 64-bit Machine Specific Register(MSR).
4102 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
4103 performed on Index, and some Index values may cause CPU exceptions. The
4104 caller must either guarantee that Index is valid, or the caller must set up
4105 exception handlers to catch the exceptions. This function is only available
4108 @param Index The 32-bit MSR index to read.
4110 @return The value of the MSR identified by Index.
4120 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
4123 Writes the 64-bit value specified by Value to the MSR specified by Index. The
4124 64-bit value written to the MSR is returned. No parameter checking is
4125 performed on Index or Value, and some of these may cause CPU exceptions. The
4126 caller must either guarantee that Index and Value are valid, or the caller
4127 must establish proper exception handlers. This function is only available on
4130 @param Index The 32-bit MSR index to write.
4131 @param Value The 64-bit value to write to the MSR.
4144 Reads a 64-bit MSR, performs a bitwise inclusive OR, and writes the result
4145 back to the 64-bit MSR.
4147 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
4148 between the read result and the value specified by OrData, and writes the
4149 result to the 64-bit MSR specified by Index. The value written to the MSR is
4150 returned. No parameter checking is performed on Index or OrData, and some of
4151 these may cause CPU exceptions. The caller must either guarantee that Index
4152 and OrData are valid, or the caller must establish proper exception handlers.
4153 This function is only available on IA-32 and X64.
4155 @param Index The 32-bit MSR index to write.
4156 @param OrData The value to OR with the read value from the MSR.
4158 @return The value written back to the MSR.
4169 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
4172 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
4173 read result and the value specified by OrData, and writes the result to the
4174 64-bit MSR specified by Index. The value written to the MSR is returned. No
4175 parameter checking is performed on Index or OrData, and some of these may
4176 cause CPU exceptions. The caller must either guarantee that Index and OrData
4177 are valid, or the caller must establish proper exception handlers. This
4178 function is only available on IA-32 and X64.
4180 @param Index The 32-bit MSR index to write.
4181 @param AndData The value to AND with the read value from the MSR.
4183 @return The value written back to the MSR.
4194 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive
4195 OR, and writes the result back to the 64-bit MSR.
4197 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
4198 result and the value specified by AndData, performs a bitwise inclusive OR
4199 between the result of the AND operation and the value specified by OrData,
4200 and writes the result to the 64-bit MSR specified by Index. The value written
4201 to the MSR is returned. No parameter checking is performed on Index, AndData,
4202 or OrData, and some of these may cause CPU exceptions. The caller must either
4203 guarantee that Index, AndData, and OrData are valid, or the caller must
4204 establish proper exception handlers. This function is only available on IA-32
4207 @param Index The 32-bit MSR index to write.
4208 @param AndData The value to AND with the read value from the MSR.
4209 @param OrData The value to OR with the result of the AND operation.
4211 @return The value written back to the MSR.
4223 Reads a bit field of an MSR.
4225 Reads the bit field in the 64-bit MSR. The bit field is specified by the
4226 StartBit and the EndBit. The value of the bit field is returned. The caller
4227 must either guarantee that Index is valid, or the caller must set up
4228 exception handlers to catch the exceptions. This function is only available
4231 If StartBit is greater than 63, then ASSERT().
4232 If EndBit is greater than 63, then ASSERT().
4233 If EndBit is less than StartBit, then ASSERT().
4235 @param Index The 32-bit MSR index to read.
4236 @param StartBit The ordinal of the least significant bit in the bit field.
4238 @param EndBit The ordinal of the most significant bit in the bit field.
4241 @return The value read from the MSR.
4246 AsmMsrBitFieldRead64 (
4253 Writes a bit field to an MSR.
4255 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
4256 the StartBit and the EndBit. All other bits in the destination MSR are
4257 preserved. The MSR written is returned. Extra left bits in Value are
4258 stripped. The caller must either guarantee that Index and the data written is
4259 valid, or the caller must set up exception handlers to catch the exceptions.
4260 This function is only available on IA-32 and X64.
4262 If StartBit is greater than 63, then ASSERT().
4263 If EndBit is greater than 63, then ASSERT().
4264 If EndBit is less than StartBit, then ASSERT().
4266 @param Index The 32-bit MSR index to write.
4267 @param StartBit The ordinal of the least significant bit in the bit field.
4269 @param EndBit The ordinal of the most significant bit in the bit field.
4271 @param Value New value of the bit field.
4273 @return The value written back to the MSR.
4278 AsmMsrBitFieldWrite64 (
4286 Reads a bit field in a 64-bit MSR, performs a bitwise inclusive OR, and
4287 writes the result back to the bit field in the 64-bit MSR.
4289 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
4290 between the read result and the value specified by OrData, and writes the
4291 result to the 64-bit MSR specified by Index. The value written to the MSR is
4292 returned. Extra left bits in OrData are stripped. The caller must either
4293 guarantee that Index and the data written is valid, or the caller must set up
4294 exception handlers to catch the exceptions. This function is only available
4297 If StartBit is greater than 63, then ASSERT().
4298 If EndBit is greater than 63, then ASSERT().
4299 If EndBit is less than StartBit, then ASSERT().
4301 @param Index The 32-bit MSR index to write.
4302 @param StartBit The ordinal of the least significant bit in the bit field.
4304 @param EndBit The ordinal of the most significant bit in the bit field.
4306 @param OrData The value to OR with the read value from the bit field.
4308 @return The value written back to the MSR.
4313 AsmMsrBitFieldOr64 (
4321 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
4322 result back to the bit field in the 64-bit MSR.
4324 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
4325 read result and the value specified by AndData, and writes the result to the
4326 64-bit MSR specified by Index. The value written to the MSR is returned.
4327 Extra left bits in AndData are stripped. The caller must either guarantee
4328 that Index and the data written is valid, or the caller must set up exception
4329 handlers to catch the exceptions. This function is only available on IA-32
4332 If StartBit is greater than 63, then ASSERT().
4333 If EndBit is greater than 63, then ASSERT().
4334 If EndBit is less than StartBit, then ASSERT().
4336 @param Index The 32-bit MSR index to write.
4337 @param StartBit The ordinal of the least significant bit in the bit field.
4339 @param EndBit The ordinal of the most significant bit in the bit field.
4341 @param AndData The value to AND with the read value from the bit field.
4343 @return The value written back to the MSR.
4348 AsmMsrBitFieldAnd64 (
4356 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
4357 bitwise inclusive OR, and writes the result back to the bit field in the
4360 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
4361 a bitwise inclusive OR between the read result and the value specified by
4362 AndData, and writes the result to the 64-bit MSR specified by Index. The
4363 value written to the MSR is returned. Extra left bits in both AndData and
4364 OrData are stripped. The caller must either guarantee that Index and the data
4365 written is valid, or the caller must set up exception handlers to catch the
4366 exceptions. This function is only available on IA-32 and X64.
4368 If StartBit is greater than 63, then ASSERT().
4369 If EndBit is greater than 63, then ASSERT().
4370 If EndBit is less than StartBit, then ASSERT().
4372 @param Index The 32-bit MSR index to write.
4373 @param StartBit The ordinal of the least significant bit in the bit field.
4375 @param EndBit The ordinal of the most significant bit in the bit field.
4377 @param AndData The value to AND with the read value from the bit field.
4378 @param OrData The value to OR with the result of the AND operation.
4380 @return The value written back to the MSR.
4385 AsmMsrBitFieldAndThenOr64 (
4394 Reads the current value of the EFLAGS register.
4396 Reads and returns the current value of the EFLAGS register. This function is
4397 only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a
4398 64-bit value on X64.
4400 @return EFLAGS on IA-32 or RFLAGS on X64.
4410 Reads the current value of the Control Register 0 (CR0).
4412 Reads and returns the current value of CR0. This function is only available
4413 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4416 @return The value of the Control Register 0 (CR0).
4426 Reads the current value of the Control Register 2 (CR2).
4428 Reads and returns the current value of CR2. This function is only available
4429 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4432 @return The value of the Control Register 2 (CR2).
4442 Reads the current value of the Control Register 3 (CR3).
4444 Reads and returns the current value of CR3. This function is only available
4445 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4448 @return The value of the Control Register 3 (CR3).
4458 Reads the current value of the Control Register 4 (CR4).
4460 Reads and returns the current value of CR4. This function is only available
4461 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4464 @return The value of the Control Register 4 (CR4).
4474 Writes a value to Control Register 0 (CR0).
4476 Writes and returns a new value to CR0. This function is only available on
4477 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4479 @param Cr0 The value to write to CR0.
4481 @return The value written to CR0.
4491 Writes a value to Control Register 2 (CR2).
4493 Writes and returns a new value to CR2. This function is only available on
4494 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4496 @param Cr2 The value to write to CR2.
4498 @return The value written to CR2.
4508 Writes a value to Control Register 3 (CR3).
4510 Writes and returns a new value to CR3. This function is only available on
4511 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4513 @param Cr3 The value to write to CR3.
4515 @return The value written to CR3.
4525 Writes a value to Control Register 4 (CR4).
4527 Writes and returns a new value to CR4. This function is only available on
4528 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4530 @param Cr4 The value to write to CR4.
4532 @return The value written to CR4.
4542 Reads the current value of Debug Register 0 (DR0).
4544 Reads and returns the current value of DR0. This function is only available
4545 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4548 @return The value of Debug Register 0 (DR0).
4558 Reads the current value of Debug Register 1 (DR1).
4560 Reads and returns the current value of DR1. This function is only available
4561 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4564 @return The value of Debug Register 1 (DR1).
4574 Reads the current value of Debug Register 2 (DR2).
4576 Reads and returns the current value of DR2. This function is only available
4577 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4580 @return The value of Debug Register 2 (DR2).
4590 Reads the current value of Debug Register 3 (DR3).
4592 Reads and returns the current value of DR3. This function is only available
4593 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4596 @return The value of Debug Register 3 (DR3).
4606 Reads the current value of Debug Register 4 (DR4).
4608 Reads and returns the current value of DR4. This function is only available
4609 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4612 @return The value of Debug Register 4 (DR4).
4622 Reads the current value of Debug Register 5 (DR5).
4624 Reads and returns the current value of DR5. This function is only available
4625 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4628 @return The value of Debug Register 5 (DR5).
4638 Reads the current value of Debug Register 6 (DR6).
4640 Reads and returns the current value of DR6. This function is only available
4641 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4644 @return The value of Debug Register 6 (DR6).
4654 Reads the current value of Debug Register 7 (DR7).
4656 Reads and returns the current value of DR7. This function is only available
4657 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4660 @return The value of Debug Register 7 (DR7).
4670 Writes a value to Debug Register 0 (DR0).
4672 Writes and returns a new value to DR0. This function is only available on
4673 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4675 @param Dr0 The value to write to Dr0.
4677 @return The value written to Debug Register 0 (DR0).
4687 Writes a value to Debug Register 1 (DR1).
4689 Writes and returns a new value to DR1. This function is only available on
4690 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4692 @param Dr1 The value to write to Dr1.
4694 @return The value written to Debug Register 1 (DR1).
4704 Writes a value to Debug Register 2 (DR2).
4706 Writes and returns a new value to DR2. This function is only available on
4707 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4709 @param Dr2 The value to write to Dr2.
4711 @return The value written to Debug Register 2 (DR2).
4721 Writes a value to Debug Register 3 (DR3).
4723 Writes and returns a new value to DR3. This function is only available on
4724 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4726 @param Dr3 The value to write to Dr3.
4728 @return The value written to Debug Register 3 (DR3).
4738 Writes a value to Debug Register 4 (DR4).
4740 Writes and returns a new value to DR4. This function is only available on
4741 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4743 @param Dr4 The value to write to Dr4.
4745 @return The value written to Debug Register 4 (DR4).
4755 Writes a value to Debug Register 5 (DR5).
4757 Writes and returns a new value to DR5. This function is only available on
4758 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4760 @param Dr5 The value to write to Dr5.
4762 @return The value written to Debug Register 5 (DR5).
4772 Writes a value to Debug Register 6 (DR6).
4774 Writes and returns a new value to DR6. This function is only available on
4775 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4777 @param Dr6 The value to write to Dr6.
4779 @return The value written to Debug Register 6 (DR6).
4789 Writes a value to Debug Register 7 (DR7).
4791 Writes and returns a new value to DR7. This function is only available on
4792 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4794 @param Dr7 The value to write to Dr7.
4796 @return The value written to Debug Register 7 (DR7).
4806 Reads the current value of Code Segment Register (CS).
4808 Reads and returns the current value of CS. This function is only available on
4811 @return The current value of CS.
4821 Reads the current value of Data Segment Register (DS).
4823 Reads and returns the current value of DS. This function is only available on
4826 @return The current value of DS.
4836 Reads the current value of Extra Segment Register (ES).
4838 Reads and returns the current value of ES. This function is only available on
4841 @return The current value of ES.
4851 Reads the current value of FS Data Segment Register (FS).
4853 Reads and returns the current value of FS. This function is only available on
4856 @return The current value of FS.
4866 Reads the current value of GS Data Segment Register (GS).
4868 Reads and returns the current value of GS. This function is only available on
4871 @return The current value of GS.
4881 Reads the current value of Stack Segment Register (SS).
4883 Reads and returns the current value of SS. This function is only available on
4886 @return The current value of SS.
4896 Reads the current value of Task Register (TR).
4898 Reads and returns the current value of TR. This function is only available on
4901 @return The current value of TR.
4911 Reads the current Global Descriptor Table Register(GDTR) descriptor.
4913 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
4914 function is only available on IA-32 and X64.
4916 If Gdtr is NULL, then ASSERT().
4918 @param Gdtr Pointer to a GDTR descriptor.
4924 OUT IA32_DESCRIPTOR
*Gdtr
4928 Writes the current Global Descriptor Table Register (GDTR) descriptor.
4930 Writes and the current GDTR descriptor specified by Gdtr. This function is
4931 only available on IA-32 and X64.
4933 If Gdtr is NULL, then ASSERT().
4935 @param Gdtr Pointer to a GDTR descriptor.
4941 IN CONST IA32_DESCRIPTOR
*Gdtr
4945 Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.
4947 Reads and returns the current IDTR descriptor and returns it in Idtr. This
4948 function is only available on IA-32 and X64.
4950 If Idtr is NULL, then ASSERT().
4952 @param Idtr Pointer to a IDTR descriptor.
4958 OUT IA32_DESCRIPTOR
*Idtr
4962 Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.
4964 Writes the current IDTR descriptor and returns it in Idtr. This function is
4965 only available on IA-32 and X64.
4967 If Idtr is NULL, then ASSERT().
4969 @param Idtr Pointer to a IDTR descriptor.
4975 IN CONST IA32_DESCRIPTOR
*Idtr
4979 Reads the current Local Descriptor Table Register(LDTR) selector.
4981 Reads and returns the current 16-bit LDTR descriptor value. This function is
4982 only available on IA-32 and X64.
4984 @return The current selector of LDT.
4994 Writes the current Local Descriptor Table Register (GDTR) selector.
4996 Writes and the current LDTR descriptor specified by Ldtr. This function is
4997 only available on IA-32 and X64.
4999 @param Ldtr 16-bit LDTR selector value.
5009 Save the current floating point/SSE/SSE2 context to a buffer.
5011 Saves the current floating point/SSE/SSE2 state to the buffer specified by
5012 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
5013 available on IA-32 and X64.
5015 If Buffer is NULL, then ASSERT().
5016 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
5018 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
5024 OUT IA32_FX_BUFFER
*Buffer
5028 Restores the current floating point/SSE/SSE2 context from a buffer.
5030 Restores the current floating point/SSE/SSE2 state from the buffer specified
5031 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
5032 only available on IA-32 and X64.
5034 If Buffer is NULL, then ASSERT().
5035 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
5036 If Buffer was not saved with AsmFxSave(), then ASSERT().
5038 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
5044 IN CONST IA32_FX_BUFFER
*Buffer
5048 Reads the current value of 64-bit MMX Register #0 (MM0).
5050 Reads and returns the current value of MM0. This function is only available
5053 @return The current value of MM0.
5063 Reads the current value of 64-bit MMX Register #1 (MM1).
5065 Reads and returns the current value of MM1. This function is only available
5068 @return The current value of MM1.
5078 Reads the current value of 64-bit MMX Register #2 (MM2).
5080 Reads and returns the current value of MM2. This function is only available
5083 @return The current value of MM2.
5093 Reads the current value of 64-bit MMX Register #3 (MM3).
5095 Reads and returns the current value of MM3. This function is only available
5098 @return The current value of MM3.
5108 Reads the current value of 64-bit MMX Register #4 (MM4).
5110 Reads and returns the current value of MM4. This function is only available
5113 @return The current value of MM4.
5123 Reads the current value of 64-bit MMX Register #5 (MM5).
5125 Reads and returns the current value of MM5. This function is only available
5128 @return The current value of MM5.
5138 Reads the current value of 64-bit MMX Register #6 (MM6).
5140 Reads and returns the current value of MM6. This function is only available
5143 @return The current value of MM6.
5153 Reads the current value of 64-bit MMX Register #7 (MM7).
5155 Reads and returns the current value of MM7. This function is only available
5158 @return The current value of MM7.
5168 Writes the current value of 64-bit MMX Register #0 (MM0).
5170 Writes the current value of MM0. This function is only available on IA32 and
5173 @param Value The 64-bit value to write to MM0.
5183 Writes the current value of 64-bit MMX Register #1 (MM1).
5185 Writes the current value of MM1. This function is only available on IA32 and
5188 @param Value The 64-bit value to write to MM1.
5198 Writes the current value of 64-bit MMX Register #2 (MM2).
5200 Writes the current value of MM2. This function is only available on IA32 and
5203 @param Value The 64-bit value to write to MM2.
5213 Writes the current value of 64-bit MMX Register #3 (MM3).
5215 Writes the current value of MM3. This function is only available on IA32 and
5218 @param Value The 64-bit value to write to MM3.
5228 Writes the current value of 64-bit MMX Register #4 (MM4).
5230 Writes the current value of MM4. This function is only available on IA32 and
5233 @param Value The 64-bit value to write to MM4.
5243 Writes the current value of 64-bit MMX Register #5 (MM5).
5245 Writes the current value of MM5. This function is only available on IA32 and
5248 @param Value The 64-bit value to write to MM5.
5258 Writes the current value of 64-bit MMX Register #6 (MM6).
5260 Writes the current value of MM6. This function is only available on IA32 and
5263 @param Value The 64-bit value to write to MM6.
5273 Writes the current value of 64-bit MMX Register #7 (MM7).
5275 Writes the current value of MM7. This function is only available on IA32 and
5278 @param Value The 64-bit value to write to MM7.
5288 Reads the current value of Time Stamp Counter (TSC).
5290 Reads and returns the current value of TSC. This function is only available
5293 @return The current value of TSC
5303 Reads the current value of a Performance Counter (PMC).
5305 Reads and returns the current value of performance counter specified by
5306 Index. This function is only available on IA-32 and X64.
5308 @param Index The 32-bit Performance Counter index to read.
5310 @return The value of the PMC specified by Index.
5320 Sets up a monitor buffer that is used by AsmMwait().
5322 Executes a MONITOR instruction with the register state specified by Eax, Ecx
5323 and Edx. Returns Eax. This function is only available on IA-32 and X64.
5325 @param Eax The value to load into EAX or RAX before executing the MONITOR
5327 @param Ecx The value to load into ECX or RCX before executing the MONITOR
5329 @param Edx The value to load into EDX or RDX before executing the MONITOR
5344 Executes an MWAIT instruction.
5346 Executes an MWAIT instruction with the register state specified by Eax and
5347 Ecx. Returns Eax. This function is only available on IA-32 and X64.
5349 @param Eax The value to load into EAX or RAX before executing the MONITOR
5351 @param Ecx The value to load into ECX or RCX before executing the MONITOR
5365 Executes a WBINVD instruction.
5367 Executes a WBINVD instruction. This function is only available on IA-32 and
5378 Executes a INVD instruction.
5380 Executes a INVD instruction. This function is only available on IA-32 and
5391 Flushes a cache line from all the instruction and data caches within the
5392 coherency domain of the CPU.
5394 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
5395 This function is only available on IA-32 and X64.
5397 @param LinearAddress The address of the cache line to flush. If the CPU is
5398 in a physical addressing mode, then LinearAddress is a
5399 physical address. If the CPU is in a virtual
5400 addressing mode, then LinearAddress is a virtual
5403 @return LinearAddress
5408 IN VOID
*LinearAddress
5412 Enables the 32-bit paging mode on the CPU.
5414 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
5415 must be properly initialized prior to calling this service. This function
5416 assumes the current execution mode is 32-bit protected mode. This function is
5417 only available on IA-32. After the 32-bit paging mode is enabled, control is
5418 transferred to the function specified by EntryPoint using the new stack
5419 specified by NewStack and passing in the parameters specified by Context1 and
5420 Context2. Context1 and Context2 are optional and may be NULL. The function
5421 EntryPoint must never return.
5423 If the current execution mode is not 32-bit protected mode, then ASSERT().
5424 If EntryPoint is NULL, then ASSERT().
5425 If NewStack is NULL, then ASSERT().
5427 There are a number of constraints that must be followed before calling this
5429 1) Interrupts must be disabled.
5430 2) The caller must be in 32-bit protected mode with flat descriptors. This
5431 means all descriptors must have a base of 0 and a limit of 4GB.
5432 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
5434 4) CR3 must point to valid page tables that will be used once the transition
5435 is complete, and those page tables must guarantee that the pages for this
5436 function and the stack are identity mapped.
5438 @param EntryPoint A pointer to function to call with the new stack after
5440 @param Context1 A pointer to the context to pass into the EntryPoint
5441 function as the first parameter after paging is enabled.
5442 @param Context2 A pointer to the context to pass into the EntryPoint
5443 function as the second parameter after paging is enabled.
5444 @param NewStack A pointer to the new stack to use for the EntryPoint
5445 function after paging is enabled.
5451 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
5452 IN VOID
*Context1
, OPTIONAL
5453 IN VOID
*Context2
, OPTIONAL
5458 Disables the 32-bit paging mode on the CPU.
5460 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
5461 mode. This function assumes the current execution mode is 32-paged protected
5462 mode. This function is only available on IA-32. After the 32-bit paging mode
5463 is disabled, control is transferred to the function specified by EntryPoint
5464 using the new stack specified by NewStack and passing in the parameters
5465 specified by Context1 and Context2. Context1 and Context2 are optional and
5466 may be NULL. The function EntryPoint must never return.
5468 If the current execution mode is not 32-bit paged mode, then ASSERT().
5469 If EntryPoint is NULL, then ASSERT().
5470 If NewStack is NULL, then ASSERT().
5472 There are a number of constraints that must be followed before calling this
5474 1) Interrupts must be disabled.
5475 2) The caller must be in 32-bit paged mode.
5476 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
5477 4) CR3 must point to valid page tables that guarantee that the pages for
5478 this function and the stack are identity mapped.
5480 @param EntryPoint A pointer to function to call with the new stack after
5482 @param Context1 A pointer to the context to pass into the EntryPoint
5483 function as the first parameter after paging is disabled.
5484 @param Context2 A pointer to the context to pass into the EntryPoint
5485 function as the second parameter after paging is
5487 @param NewStack A pointer to the new stack to use for the EntryPoint
5488 function after paging is disabled.
5493 AsmDisablePaging32 (
5494 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
5495 IN VOID
*Context1
, OPTIONAL
5496 IN VOID
*Context2
, OPTIONAL
5501 Enables the 64-bit paging mode on the CPU.
5503 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
5504 must be properly initialized prior to calling this service. This function
5505 assumes the current execution mode is 32-bit protected mode with flat
5506 descriptors. This function is only available on IA-32. After the 64-bit
5507 paging mode is enabled, control is transferred to the function specified by
5508 EntryPoint using the new stack specified by NewStack and passing in the
5509 parameters specified by Context1 and Context2. Context1 and Context2 are
5510 optional and may be 0. The function EntryPoint must never return.
5512 If the current execution mode is not 32-bit protected mode with flat
5513 descriptors, then ASSERT().
5514 If EntryPoint is 0, then ASSERT().
5515 If NewStack is 0, then ASSERT().
5517 @param Cs The 16-bit selector to load in the CS before EntryPoint
5518 is called. The descriptor in the GDT that this selector
5519 references must be setup for long mode.
5520 @param EntryPoint The 64-bit virtual address of the function to call with
5521 the new stack after paging is enabled.
5522 @param Context1 The 64-bit virtual address of the context to pass into
5523 the EntryPoint function as the first parameter after
5525 @param Context2 The 64-bit virtual address of the context to pass into
5526 the EntryPoint function as the second parameter after
5528 @param NewStack The 64-bit virtual address of the new stack to use for
5529 the EntryPoint function after paging is enabled.
5535 IN UINT16 CodeSelector
,
5536 IN UINT64 EntryPoint
,
5537 IN UINT64 Context1
, OPTIONAL
5538 IN UINT64 Context2
, OPTIONAL
5543 Disables the 64-bit paging mode on the CPU.
5545 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
5546 mode. This function assumes the current execution mode is 64-paging mode.
5547 This function is only available on X64. After the 64-bit paging mode is
5548 disabled, control is transferred to the function specified by EntryPoint
5549 using the new stack specified by NewStack and passing in the parameters
5550 specified by Context1 and Context2. Context1 and Context2 are optional and
5551 may be 0. The function EntryPoint must never return.
5553 If the current execution mode is not 64-bit paged mode, then ASSERT().
5554 If EntryPoint is 0, then ASSERT().
5555 If NewStack is 0, then ASSERT().
5557 @param Cs The 16-bit selector to load in the CS before EntryPoint
5558 is called. The descriptor in the GDT that this selector
5559 references must be setup for 32-bit protected mode.
5560 @param EntryPoint The 64-bit virtual address of the function to call with
5561 the new stack after paging is disabled.
5562 @param Context1 The 64-bit virtual address of the context to pass into
5563 the EntryPoint function as the first parameter after
5565 @param Context2 The 64-bit virtual address of the context to pass into
5566 the EntryPoint function as the second parameter after
5568 @param NewStack The 64-bit virtual address of the new stack to use for
5569 the EntryPoint function after paging is disabled.
5574 AsmDisablePaging64 (
5575 IN UINT16 CodeSelector
,
5576 IN UINT32 EntryPoint
,
5577 IN UINT32 Context1
, OPTIONAL
5578 IN UINT32 Context2
, OPTIONAL
5583 // 16-bit thunking services
5587 Retrieves the properties for 16-bit thunk functions.
5589 Computes the size of the buffer and stack below 1MB required to use the
5590 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
5591 buffer size is returned in RealModeBufferSize, and the stack size is returned
5592 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
5593 then the actual minimum stack size is ExtraStackSize plus the maximum number
5594 of bytes that need to be passed to the 16-bit real mode code.
5596 If RealModeBufferSize is NULL, then ASSERT().
5597 If ExtraStackSize is NULL, then ASSERT().
5599 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
5600 required to use the 16-bit thunk functions.
5601 @param ExtraStackSize A pointer to the extra size of stack below 1MB
5602 that the 16-bit thunk functions require for
5603 temporary storage in the transition to and from
5609 AsmGetThunk16Properties (
5610 OUT UINT32
*RealModeBufferSize
,
5611 OUT UINT32
*ExtraStackSize
5615 Prepares all structures a code required to use AsmThunk16().
5617 Prepares all structures and code required to use AsmThunk16().
5619 If ThunkContext is NULL, then ASSERT().
5621 @param ThunkContext A pointer to the context structure that describes the
5622 16-bit real mode code to call.
5628 OUT THUNK_CONTEXT
*ThunkContext
5632 Transfers control to a 16-bit real mode entry point and returns the results.
5634 Transfers control to a 16-bit real mode entry point and returns the results.
5635 AsmPrepareThunk16() must be called with ThunkContext before this function is
5638 If ThunkContext is NULL, then ASSERT().
5639 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
5641 @param ThunkContext A pointer to the context structure that describes the
5642 16-bit real mode code to call.
5648 IN OUT THUNK_CONTEXT
*ThunkContext
5652 Prepares all structures and code for a 16-bit real mode thunk, transfers
5653 control to a 16-bit real mode entry point, and returns the results.
5655 Prepares all structures and code for a 16-bit real mode thunk, transfers
5656 control to a 16-bit real mode entry point, and returns the results. If the
5657 caller only need to perform a single 16-bit real mode thunk, then this
5658 service should be used. If the caller intends to make more than one 16-bit
5659 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
5660 once and AsmThunk16() can be called for each 16-bit real mode thunk.
5662 If ThunkContext is NULL, then ASSERT().
5664 @param ThunkContext A pointer to the context structure that describes the
5665 16-bit real mode code to call.
5670 AsmPrepareAndThunk16 (
5671 IN OUT THUNK_CONTEXT
*ThunkContext
5682 // IPF Specific functions
5687 Performs a PAL call using static calling convention.
5689 An internal function to perform a PAL call using static calling convention.
5691 @param PalEntryPoint The entry point address of PAL. The address in ar.kr5
5692 would be used if this parameter were NULL on input.
5693 @param Arg1 The first argument of a PAL call.
5694 @param Arg1 The second argument of a PAL call.
5695 @param Arg1 The third argument of a PAL call.
5696 @param Arg1 The fourth argument of a PAL call.
5698 @return The values returned in r8, r9, r10 and r11.
5703 IN CONST VOID
*PalEntryPoint
,
5712 Returns the current value of ar.itc.
5714 An internal function to return the current value of ar.itc, which is the
5717 @return The currect value of ar.itc
5727 Flush a range of cache lines in the cache coherency domain of the calling
5730 Invalidates the cache lines specified by Address and Length. If Address is
5731 not aligned on a cache line boundary, then entire cache line containing
5732 Address is invalidated. If Address + Length is not aligned on a cache line
5733 boundary, then the entire instruction cache line containing Address + Length
5734 -1 is invalidated. This function may choose to invalidate the entire
5735 instruction cache if that is more efficient than invalidating the specified
5736 range. If Length is 0, the no instruction cache lines are invalidated.
5737 Address is returned.
5739 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
5741 @param Address The base address of the instruction lines to invalidate. If
5742 the CPU is in a physical addressing mode, then Address is a
5743 physical address. If the CPU is in a virtual addressing mode,
5744 then Address is a virtual address.
5746 @param Length The number of bytes to invalidate from the instruction cache.
5753 IpfFlushCacheRange (