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 new stack
3433 specified by NewStack and passing in the parameters specified by Context1 and
3434 Context2. Context1 and Context2 are optional and may be NULL. The function
3435 EntryPoint must never return.
3437 If EntryPoint is NULL, then ASSERT().
3438 If NewStack is NULL, then ASSERT().
3440 @param EntryPoint A pointer to function to call with the new stack.
3441 @param Context1 A pointer to the context to pass into the EntryPoint
3443 @param Context2 A pointer to the context to pass into the EntryPoint
3445 @param NewStack A pointer to the new stack to use for the EntryPoint
3452 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
3453 IN VOID
*Context1
, OPTIONAL
3454 IN VOID
*Context2
, OPTIONAL
3459 Generates a breakpoint on the CPU.
3461 Generates a breakpoint on the CPU. The breakpoint must be implemented such
3462 that code can resume normal execution after the breakpoint.
3472 Executes an infinite loop.
3474 Forces the CPU to execute an infinite loop. A debugger may be used to skip
3475 past the loop and the code that follows the loop must execute properly. This
3476 implies that the infinite loop must not cause the code that follow it to be
3487 // IA32 and X64 Specific Functions
3490 // Byte packed structure for 16-bit Real Mode EFLAGS
3494 UINT32 CF
:1; // Carry Flag
3495 UINT32 Reserved_0
:1; // Reserved
3496 UINT32 PF
:1; // Parity Flag
3497 UINT32 Reserved_1
:1; // Reserved
3498 UINT32 AF
:1; // Auxiliary Carry Flag
3499 UINT32 Reserved_2
:1; // Reserved
3500 UINT32 ZF
:1; // Zero Flag
3501 UINT32 SF
:1; // Sign Flag
3502 UINT32 TF
:1; // Trap Flag
3503 UINT32 IF
:1; // Interrupt Enable Flag
3504 UINT32 DF
:1; // Direction Flag
3505 UINT32 OF
:1; // Overflow Flag
3506 UINT32 IOPL
:2; // I/O Privilege Level
3507 UINT32 NT
:1; // Nested Task
3508 UINT32 Reserved_3
:1; // Reserved
3514 // Byte packed structure for EFLAGS/RFLAGS
3516 // 64-bits on X64. The upper 32-bits on X64 are reserved
3520 UINT32 CF
:1; // Carry Flag
3521 UINT32 Reserved_0
:1; // Reserved
3522 UINT32 PF
:1; // Parity Flag
3523 UINT32 Reserved_1
:1; // Reserved
3524 UINT32 AF
:1; // Auxiliary Carry Flag
3525 UINT32 Reserved_2
:1; // Reserved
3526 UINT32 ZF
:1; // Zero Flag
3527 UINT32 SF
:1; // Sign Flag
3528 UINT32 TF
:1; // Trap Flag
3529 UINT32 IF
:1; // Interrupt Enable Flag
3530 UINT32 DF
:1; // Direction Flag
3531 UINT32 OF
:1; // Overflow Flag
3532 UINT32 IOPL
:2; // I/O Privilege Level
3533 UINT32 NT
:1; // Nested Task
3534 UINT32 Reserved_3
:1; // Reserved
3535 UINT32 RF
:1; // Resume Flag
3536 UINT32 VM
:1; // Virtual 8086 Mode
3537 UINT32 AC
:1; // Alignment Check
3538 UINT32 VIF
:1; // Virtual Interrupt Flag
3539 UINT32 VIP
:1; // Virtual Interrupt Pending
3540 UINT32 ID
:1; // ID Flag
3541 UINT32 Reserved_4
:10; // Reserved
3547 // Byte packed structure for Control Register 0 (CR0)
3549 // 64-bits on X64. The upper 32-bits on X64 are reserved
3553 UINT32 PE
:1; // Protection Enable
3554 UINT32 MP
:1; // Monitor Coprocessor
3555 UINT32 EM
:1; // Emulation
3556 UINT32 TS
:1; // Task Switched
3557 UINT32 ET
:1; // Extension Type
3558 UINT32 NE
:1; // Numeric Error
3559 UINT32 Reserved_0
:10; // Reserved
3560 UINT32 WP
:1; // Write Protect
3561 UINT32 Reserved_1
:1; // Reserved
3562 UINT32 AM
:1; // Alignment Mask
3563 UINT32 Reserved_2
:10; // Reserved
3564 UINT32 NW
:1; // Mot Write-through
3565 UINT32 CD
:1; // Cache Disable
3566 UINT32 PG
:1; // Paging
3572 // Byte packed structure for Control Register 4 (CR4)
3574 // 64-bits on X64. The upper 32-bits on X64 are reserved
3578 UINT32 VME
:1; // Virtual-8086 Mode Extensions
3579 UINT32 PVI
:1; // Protected-Mode Virtual Interrupts
3580 UINT32 TSD
:1; // Time Stamp Disable
3581 UINT32 DE
:1; // Debugging Extensions
3582 UINT32 PSE
:1; // Page Size Extensions
3583 UINT32 PAE
:1; // Physical Address Extension
3584 UINT32 MCE
:1; // Machine Check Enable
3585 UINT32 PGE
:1; // Page Global Enable
3586 UINT32 PCE
:1; // Performance Monitoring Counter
3588 UINT32 OSFXSR
:1; // Operating System Support for
3589 // FXSAVE and FXRSTOR instructions
3590 UINT32 OSXMMEXCPT
:1; // Operating System Support for
3591 // Unmasked SIMD Floating Point
3593 UINT32 Reserved_0
:2; // Reserved
3594 UINT32 VMXE
:1; // VMX Enable
3595 UINT32 Reserved_1
:18; // Reseved
3601 // Byte packed structure for an IDTR, GDTR, LDTR descriptor
3602 /// @bug How to make this structure byte-packed in a compiler independent way?
3611 #define IA32_IDT_GATE_TYPE_TASK 0x85
3612 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
3613 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
3614 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
3615 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
3618 // Byte packed structure for an Interrupt Gate Descriptor
3622 UINT32 OffsetLow
:16; // Offset bits 15..0
3623 UINT32 Selector
:16; // Selector
3624 UINT32 Reserved_0
:8; // Reserved
3625 UINT32 GateType
:8; // Gate Type. See #defines above
3626 UINT32 OffsetHigh
:16; // Offset bits 31..16
3629 } IA32_IDT_GATE_DESCRIPTOR
;
3632 // Byte packed structure for an FP/SSE/SSE2 context
3639 // Structures for the 16-bit real mode thunks
3692 IA32_EFLAGS32 EFLAGS
;
3702 } IA32_REGISTER_SET
;
3705 // Byte packed structure for an 16-bit real mode thunks
3708 IA32_REGISTER_SET
*RealModeState
;
3709 VOID
*RealModeBuffer
;
3710 UINT32 RealModeBufferSize
;
3711 UINT32 ThunkAttributes
;
3714 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
3715 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
3716 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
3719 Retrieves CPUID information.
3721 Executes the CPUID instruction with EAX set to the value specified by Index.
3722 This function always returns Index.
3723 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
3724 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
3725 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
3726 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
3727 This function is only available on IA-32 and X64.
3729 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
3731 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
3732 instruction. This is an optional parameter that may be NULL.
3733 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
3734 instruction. This is an optional parameter that may be NULL.
3735 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
3736 instruction. This is an optional parameter that may be NULL.
3737 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
3738 instruction. This is an optional parameter that may be NULL.
3747 OUT UINT32
*Eax
, OPTIONAL
3748 OUT UINT32
*Ebx
, OPTIONAL
3749 OUT UINT32
*Ecx
, OPTIONAL
3750 OUT UINT32
*Edx OPTIONAL
3754 Retrieves CPUID information using an extended leaf identifier.
3756 Executes the CPUID instruction with EAX set to the value specified by Index
3757 and ECX set to the value specified by SubIndex. This function always returns
3758 Index. This function is only available on IA-32 and x64.
3760 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
3761 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
3762 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
3763 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
3765 @param Index The 32-bit value to load into EAX prior to invoking the
3767 @param SubIndex The 32-bit value to load into ECX prior to invoking the
3769 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
3770 instruction. This is an optional parameter that may be
3772 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
3773 instruction. This is an optional parameter that may be
3775 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
3776 instruction. This is an optional parameter that may be
3778 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
3779 instruction. This is an optional parameter that may be
3790 OUT UINT32
*Eax
, OPTIONAL
3791 OUT UINT32
*Ebx
, OPTIONAL
3792 OUT UINT32
*Ecx
, OPTIONAL
3793 OUT UINT32
*Edx OPTIONAL
3797 Returns the lower 32-bits of a Machine Specific Register(MSR).
3799 Reads and returns the lower 32-bits of the MSR specified by Index.
3800 No parameter checking is performed on Index, and some Index values may cause
3801 CPU exceptions. The caller must either guarantee that Index is valid, or the
3802 caller must set up exception handlers to catch the exceptions. This function
3803 is only available on IA-32 and X64.
3805 @param Index The 32-bit MSR index to read.
3807 @return The lower 32 bits of the MSR identified by Index.
3817 Zero-extend a 32-bit value and writes it to a Machine Specific Register(MSR).
3819 Writes the 32-bit value specified by Value to the MSR specified by Index. The
3820 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
3821 the MSR is returned. No parameter checking is performed on Index or Value,
3822 and some of these may cause CPU exceptions. The caller must either guarantee
3823 that Index and Value are valid, or the caller must establish proper exception
3824 handlers. This function is only available on IA-32 and X64.
3826 @param Index The 32-bit MSR index to write.
3827 @param Value The 32-bit value to write to the MSR.
3840 Reads a 64-bit MSR, performs a bitwise inclusive OR on the lower 32-bits, and
3841 writes the result back to the 64-bit MSR.
3843 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
3844 between the lower 32-bits of the read result and the value specified by
3845 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
3846 32-bits of the value written to the MSR is returned. No parameter checking is
3847 performed on Index or OrData, and some of these may cause CPU exceptions. The
3848 caller must either guarantee that Index and OrData are valid, or the caller
3849 must establish proper exception handlers. This function is only available on
3852 @param Index The 32-bit MSR index to write.
3853 @param OrData The value to OR with the read value from the MSR.
3855 @return The lower 32-bit value written to the MSR.
3866 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
3867 the result back to the 64-bit MSR.
3869 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
3870 lower 32-bits of the read result and the value specified by AndData, and
3871 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
3872 the value written to the MSR is returned. No parameter checking is performed
3873 on Index or AndData, and some of these may cause CPU exceptions. The caller
3874 must either guarantee that Index and AndData are valid, or the caller must
3875 establish proper exception handlers. This function is only available on IA-32
3878 @param Index The 32-bit MSR index to write.
3879 @param AndData The value to AND with the read value from the MSR.
3881 @return The lower 32-bit value written to the MSR.
3892 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive OR
3893 on the lower 32-bits, and writes the result back to the 64-bit MSR.
3895 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
3896 lower 32-bits of the read result and the value specified by AndData
3897 preserving the upper 32-bits, performs a bitwise inclusive OR between the
3898 result of the AND operation and the value specified by OrData, and writes the
3899 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
3900 written to the MSR is returned. No parameter checking is performed on Index,
3901 AndData, or OrData, and some of these may cause CPU exceptions. The caller
3902 must either guarantee that Index, AndData, and OrData are valid, or the
3903 caller must establish proper exception handlers. This function is only
3904 available on IA-32 and X64.
3906 @param Index The 32-bit MSR index to write.
3907 @param AndData The value to AND with the read value from the MSR.
3908 @param OrData The value to OR with the result of the AND operation.
3910 @return The lower 32-bit value written to the MSR.
3922 Reads a bit field of an MSR.
3924 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
3925 specified by the StartBit and the EndBit. The value of the bit field is
3926 returned. The caller must either guarantee that Index is valid, or the caller
3927 must set up exception handlers to catch the exceptions. This function is only
3928 available on IA-32 and X64.
3930 If StartBit is greater than 31, then ASSERT().
3931 If EndBit is greater than 31, then ASSERT().
3932 If EndBit is less than StartBit, then ASSERT().
3934 @param Index The 32-bit MSR index to read.
3935 @param StartBit The ordinal of the least significant bit in the bit field.
3937 @param EndBit The ordinal of the most significant bit in the bit field.
3940 @return The bit field read from the MSR.
3945 AsmMsrBitFieldRead32 (
3952 Writes a bit field to an MSR.
3954 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
3955 field is specified by the StartBit and the EndBit. All other bits in the
3956 destination MSR are preserved. The lower 32-bits of the MSR written is
3957 returned. Extra left bits in Value are stripped. The caller must either
3958 guarantee that Index and the data written is valid, or the caller must set up
3959 exception handlers to catch the exceptions. This function is only available
3962 If StartBit is greater than 31, then ASSERT().
3963 If EndBit is greater than 31, then ASSERT().
3964 If EndBit is less than StartBit, then ASSERT().
3966 @param Index The 32-bit MSR index to write.
3967 @param StartBit The ordinal of the least significant bit in the bit field.
3969 @param EndBit The ordinal of the most significant bit in the bit field.
3971 @param Value New value of the bit field.
3973 @return The lower 32-bit of the value written to the MSR.
3978 AsmMsrBitFieldWrite32 (
3986 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
3987 result back to the bit field in the 64-bit MSR.
3989 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
3990 between the read result and the value specified by OrData, and writes the
3991 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
3992 written to the MSR are returned. Extra left bits in OrData are stripped. The
3993 caller must either guarantee that Index and the data written is valid, or
3994 the caller must set up exception handlers to catch the exceptions. This
3995 function is only available on IA-32 and X64.
3997 If StartBit is greater than 31, then ASSERT().
3998 If EndBit is greater than 31, then ASSERT().
3999 If EndBit is less than StartBit, then ASSERT().
4001 @param Index The 32-bit MSR index to write.
4002 @param StartBit The ordinal of the least significant bit in the bit field.
4004 @param EndBit The ordinal of the most significant bit in the bit field.
4006 @param OrData The value to OR with the read value from the MSR.
4008 @return The lower 32-bit of the value written to the MSR.
4013 AsmMsrBitFieldOr32 (
4021 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
4022 result back to the bit field in the 64-bit MSR.
4024 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
4025 read result and the value specified by AndData, and writes the result to the
4026 64-bit MSR specified by Index. The lower 32-bits of the value written to the
4027 MSR are returned. Extra left bits in AndData are stripped. The caller must
4028 either guarantee that Index and the data written is valid, or the caller must
4029 set up exception handlers to catch the exceptions. This function is only
4030 available on IA-32 and X64.
4032 If StartBit is greater than 31, then ASSERT().
4033 If EndBit is greater than 31, then ASSERT().
4034 If EndBit is less than StartBit, then ASSERT().
4036 @param Index The 32-bit MSR index to write.
4037 @param StartBit The ordinal of the least significant bit in the bit field.
4039 @param EndBit The ordinal of the most significant bit in the bit field.
4041 @param AndData The value to AND with the read value from the MSR.
4043 @return The lower 32-bit of the value written to the MSR.
4048 AsmMsrBitFieldAnd32 (
4056 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
4057 bitwise inclusive OR, and writes the result back to the bit field in the
4060 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
4061 bitwise inclusive OR between the read result and the value specified by
4062 AndData, and writes the result to the 64-bit MSR specified by Index. The
4063 lower 32-bits of the value written to the MSR are returned. Extra left bits
4064 in both AndData and OrData are stripped. The caller must either guarantee
4065 that Index and the data written is valid, or the caller must set up exception
4066 handlers to catch the exceptions. This function is only available on IA-32
4069 If StartBit is greater than 31, then ASSERT().
4070 If EndBit is greater than 31, then ASSERT().
4071 If EndBit is less than StartBit, then ASSERT().
4073 @param Index The 32-bit MSR index to write.
4074 @param StartBit The ordinal of the least significant bit in the bit field.
4076 @param EndBit The ordinal of the most significant bit in the bit field.
4078 @param AndData The value to AND with the read value from the MSR.
4079 @param OrData The value to OR with the result of the AND operation.
4081 @return The lower 32-bit of the value written to the MSR.
4086 AsmMsrBitFieldAndThenOr32 (
4095 Returns a 64-bit Machine Specific Register(MSR).
4097 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
4098 performed on Index, and some Index values may cause CPU exceptions. The
4099 caller must either guarantee that Index is valid, or the caller must set up
4100 exception handlers to catch the exceptions. This function is only available
4103 @param Index The 32-bit MSR index to read.
4105 @return The value of the MSR identified by Index.
4115 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
4118 Writes the 64-bit value specified by Value to the MSR specified by Index. The
4119 64-bit value written to the MSR is returned. No parameter checking is
4120 performed on Index or Value, and some of these may cause CPU exceptions. The
4121 caller must either guarantee that Index and Value are valid, or the caller
4122 must establish proper exception handlers. This function is only available on
4125 @param Index The 32-bit MSR index to write.
4126 @param Value The 64-bit value to write to the MSR.
4139 Reads a 64-bit MSR, performs a bitwise inclusive OR, and writes the result
4140 back to the 64-bit MSR.
4142 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
4143 between the read result and the value specified by OrData, and writes the
4144 result to the 64-bit MSR specified by Index. The value written to the MSR is
4145 returned. No parameter checking is performed on Index or OrData, and some of
4146 these may cause CPU exceptions. The caller must either guarantee that Index
4147 and OrData are valid, or the caller must establish proper exception handlers.
4148 This function is only available on IA-32 and X64.
4150 @param Index The 32-bit MSR index to write.
4151 @param OrData The value to OR with the read value from the MSR.
4153 @return The value written back to the MSR.
4164 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
4167 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
4168 read result and the value specified by OrData, and writes the result to the
4169 64-bit MSR specified by Index. The value written to the MSR is returned. No
4170 parameter checking is performed on Index or OrData, and some of these may
4171 cause CPU exceptions. The caller must either guarantee that Index and OrData
4172 are valid, or the caller must establish proper exception handlers. This
4173 function is only available on IA-32 and X64.
4175 @param Index The 32-bit MSR index to write.
4176 @param AndData The value to AND with the read value from the MSR.
4178 @return The value written back to the MSR.
4189 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive
4190 OR, and writes the result back to the 64-bit MSR.
4192 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
4193 result and the value specified by AndData, performs a bitwise inclusive OR
4194 between the result of the AND operation and the value specified by OrData,
4195 and writes the result to the 64-bit MSR specified by Index. The value written
4196 to the MSR is returned. No parameter checking is performed on Index, AndData,
4197 or OrData, and some of these may cause CPU exceptions. The caller must either
4198 guarantee that Index, AndData, and OrData are valid, or the caller must
4199 establish proper exception handlers. This function is only available on IA-32
4202 @param Index The 32-bit MSR index to write.
4203 @param AndData The value to AND with the read value from the MSR.
4204 @param OrData The value to OR with the result of the AND operation.
4206 @return The value written back to the MSR.
4218 Reads a bit field of an MSR.
4220 Reads the bit field in the 64-bit MSR. The bit field is specified by the
4221 StartBit and the EndBit. The value of the bit field is returned. The caller
4222 must either guarantee that Index is valid, or the caller must set up
4223 exception handlers to catch the exceptions. This function is only available
4226 If StartBit is greater than 63, then ASSERT().
4227 If EndBit is greater than 63, then ASSERT().
4228 If EndBit is less than StartBit, then ASSERT().
4230 @param Index The 32-bit MSR index to read.
4231 @param StartBit The ordinal of the least significant bit in the bit field.
4233 @param EndBit The ordinal of the most significant bit in the bit field.
4236 @return The value read from the MSR.
4241 AsmMsrBitFieldRead64 (
4248 Writes a bit field to an MSR.
4250 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
4251 the StartBit and the EndBit. All other bits in the destination MSR are
4252 preserved. The MSR written is returned. Extra left bits in Value are
4253 stripped. The caller must either guarantee that Index and the data written is
4254 valid, or the caller must set up exception handlers to catch the exceptions.
4255 This function is only available on IA-32 and X64.
4257 If StartBit is greater than 63, then ASSERT().
4258 If EndBit is greater than 63, then ASSERT().
4259 If EndBit is less than StartBit, then ASSERT().
4261 @param Index The 32-bit MSR index to write.
4262 @param StartBit The ordinal of the least significant bit in the bit field.
4264 @param EndBit The ordinal of the most significant bit in the bit field.
4266 @param Value New value of the bit field.
4268 @return The value written back to the MSR.
4273 AsmMsrBitFieldWrite64 (
4281 Reads a bit field in a 64-bit MSR, performs a bitwise inclusive OR, and
4282 writes the result back to the bit field in the 64-bit MSR.
4284 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
4285 between the read result and the value specified by OrData, and writes the
4286 result to the 64-bit MSR specified by Index. The value written to the MSR is
4287 returned. Extra left bits in OrData are stripped. The caller must either
4288 guarantee that Index and the data written is valid, or the caller must set up
4289 exception handlers to catch the exceptions. This function is only available
4292 If StartBit is greater than 63, then ASSERT().
4293 If EndBit is greater than 63, then ASSERT().
4294 If EndBit is less than StartBit, then ASSERT().
4296 @param Index The 32-bit MSR index to write.
4297 @param StartBit The ordinal of the least significant bit in the bit field.
4299 @param EndBit The ordinal of the most significant bit in the bit field.
4301 @param OrData The value to OR with the read value from the bit field.
4303 @return The value written back to the MSR.
4308 AsmMsrBitFieldOr64 (
4316 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
4317 result back to the bit field in the 64-bit MSR.
4319 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
4320 read result and the value specified by AndData, and writes the result to the
4321 64-bit MSR specified by Index. The value written to the MSR is returned.
4322 Extra left bits in AndData are stripped. The caller must either guarantee
4323 that Index and the data written is valid, or the caller must set up exception
4324 handlers to catch the exceptions. This function is only available on IA-32
4327 If StartBit is greater than 63, then ASSERT().
4328 If EndBit is greater than 63, then ASSERT().
4329 If EndBit is less than StartBit, then ASSERT().
4331 @param Index The 32-bit MSR index to write.
4332 @param StartBit The ordinal of the least significant bit in the bit field.
4334 @param EndBit The ordinal of the most significant bit in the bit field.
4336 @param AndData The value to AND with the read value from the bit field.
4338 @return The value written back to the MSR.
4343 AsmMsrBitFieldAnd64 (
4351 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
4352 bitwise inclusive OR, and writes the result back to the bit field in the
4355 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
4356 a bitwise inclusive OR between the read result and the value specified by
4357 AndData, and writes the result to the 64-bit MSR specified by Index. The
4358 value written to the MSR is returned. Extra left bits in both AndData and
4359 OrData are stripped. The caller must either guarantee that Index and the data
4360 written is valid, or the caller must set up exception handlers to catch the
4361 exceptions. This function is only available on IA-32 and X64.
4363 If StartBit is greater than 63, then ASSERT().
4364 If EndBit is greater than 63, then ASSERT().
4365 If EndBit is less than StartBit, then ASSERT().
4367 @param Index The 32-bit MSR index to write.
4368 @param StartBit The ordinal of the least significant bit in the bit field.
4370 @param EndBit The ordinal of the most significant bit in the bit field.
4372 @param AndData The value to AND with the read value from the bit field.
4373 @param OrData The value to OR with the result of the AND operation.
4375 @return The value written back to the MSR.
4380 AsmMsrBitFieldAndThenOr64 (
4389 Reads the current value of the EFLAGS register.
4391 Reads and returns the current value of the EFLAGS register. This function is
4392 only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a
4393 64-bit value on X64.
4395 @return EFLAGS on IA-32 or RFLAGS on X64.
4405 Reads the current value of the Control Register 0 (CR0).
4407 Reads and returns the current value of CR0. This function is only available
4408 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4411 @return The value of the Control Register 0 (CR0).
4421 Reads the current value of the Control Register 2 (CR2).
4423 Reads and returns the current value of CR2. This function is only available
4424 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4427 @return The value of the Control Register 2 (CR2).
4437 Reads the current value of the Control Register 3 (CR3).
4439 Reads and returns the current value of CR3. This function is only available
4440 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4443 @return The value of the Control Register 3 (CR3).
4453 Reads the current value of the Control Register 4 (CR4).
4455 Reads and returns the current value of CR4. This function is only available
4456 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4459 @return The value of the Control Register 4 (CR4).
4469 Writes a value to Control Register 0 (CR0).
4471 Writes and returns a new value to CR0. This function is only available on
4472 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4474 @param Cr0 The value to write to CR0.
4476 @return The value written to CR0.
4486 Writes a value to Control Register 2 (CR2).
4488 Writes and returns a new value to CR2. This function is only available on
4489 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4491 @param Cr2 The value to write to CR2.
4493 @return The value written to CR2.
4503 Writes a value to Control Register 3 (CR3).
4505 Writes and returns a new value to CR3. This function is only available on
4506 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4508 @param Cr3 The value to write to CR3.
4510 @return The value written to CR3.
4520 Writes a value to Control Register 4 (CR4).
4522 Writes and returns a new value to CR4. This function is only available on
4523 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4525 @param Cr4 The value to write to CR4.
4527 @return The value written to CR4.
4537 Reads the current value of Debug Register 0 (DR0).
4539 Reads and returns the current value of DR0. This function is only available
4540 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4543 @return The value of Debug Register 0 (DR0).
4553 Reads the current value of Debug Register 1 (DR1).
4555 Reads and returns the current value of DR1. This function is only available
4556 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4559 @return The value of Debug Register 1 (DR1).
4569 Reads the current value of Debug Register 2 (DR2).
4571 Reads and returns the current value of DR2. This function is only available
4572 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4575 @return The value of Debug Register 2 (DR2).
4585 Reads the current value of Debug Register 3 (DR3).
4587 Reads and returns the current value of DR3. This function is only available
4588 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4591 @return The value of Debug Register 3 (DR3).
4601 Reads the current value of Debug Register 4 (DR4).
4603 Reads and returns the current value of DR4. This function is only available
4604 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4607 @return The value of Debug Register 4 (DR4).
4617 Reads the current value of Debug Register 5 (DR5).
4619 Reads and returns the current value of DR5. This function is only available
4620 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4623 @return The value of Debug Register 5 (DR5).
4633 Reads the current value of Debug Register 6 (DR6).
4635 Reads and returns the current value of DR6. This function is only available
4636 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4639 @return The value of Debug Register 6 (DR6).
4649 Reads the current value of Debug Register 7 (DR7).
4651 Reads and returns the current value of DR7. This function is only available
4652 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4655 @return The value of Debug Register 7 (DR7).
4665 Writes a value to Debug Register 0 (DR0).
4667 Writes and returns a new value to DR0. This function is only available on
4668 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4670 @param Dr0 The value to write to Dr0.
4672 @return The value written to Debug Register 0 (DR0).
4682 Writes a value to Debug Register 1 (DR1).
4684 Writes and returns a new value to DR1. This function is only available on
4685 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4687 @param Dr1 The value to write to Dr1.
4689 @return The value written to Debug Register 1 (DR1).
4699 Writes a value to Debug Register 2 (DR2).
4701 Writes and returns a new value to DR2. This function is only available on
4702 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4704 @param Dr2 The value to write to Dr2.
4706 @return The value written to Debug Register 2 (DR2).
4716 Writes a value to Debug Register 3 (DR3).
4718 Writes and returns a new value to DR3. This function is only available on
4719 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4721 @param Dr3 The value to write to Dr3.
4723 @return The value written to Debug Register 3 (DR3).
4733 Writes a value to Debug Register 4 (DR4).
4735 Writes and returns a new value to DR4. This function is only available on
4736 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4738 @param Dr4 The value to write to Dr4.
4740 @return The value written to Debug Register 4 (DR4).
4750 Writes a value to Debug Register 5 (DR5).
4752 Writes and returns a new value to DR5. This function is only available on
4753 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4755 @param Dr5 The value to write to Dr5.
4757 @return The value written to Debug Register 5 (DR5).
4767 Writes a value to Debug Register 6 (DR6).
4769 Writes and returns a new value to DR6. This function is only available on
4770 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4772 @param Dr6 The value to write to Dr6.
4774 @return The value written to Debug Register 6 (DR6).
4784 Writes a value to Debug Register 7 (DR7).
4786 Writes and returns a new value to DR7. This function is only available on
4787 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4789 @param Dr7 The value to write to Dr7.
4791 @return The value written to Debug Register 7 (DR7).
4801 Reads the current value of Code Segment Register (CS).
4803 Reads and returns the current value of CS. This function is only available on
4806 @return The current value of CS.
4816 Reads the current value of Data Segment Register (DS).
4818 Reads and returns the current value of DS. This function is only available on
4821 @return The current value of DS.
4831 Reads the current value of Extra Segment Register (ES).
4833 Reads and returns the current value of ES. This function is only available on
4836 @return The current value of ES.
4846 Reads the current value of FS Data Segment Register (FS).
4848 Reads and returns the current value of FS. This function is only available on
4851 @return The current value of FS.
4861 Reads the current value of GS Data Segment Register (GS).
4863 Reads and returns the current value of GS. This function is only available on
4866 @return The current value of GS.
4876 Reads the current value of Stack Segment Register (SS).
4878 Reads and returns the current value of SS. This function is only available on
4881 @return The current value of SS.
4891 Reads the current value of Task Register (TR).
4893 Reads and returns the current value of TR. This function is only available on
4896 @return The current value of TR.
4906 Reads the current Global Descriptor Table Register(GDTR) descriptor.
4908 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
4909 function is only available on IA-32 and X64.
4911 If Gdtr is NULL, then ASSERT().
4913 @param Gdtr Pointer to a GDTR descriptor.
4919 OUT IA32_DESCRIPTOR
*Gdtr
4923 Writes the current Global Descriptor Table Register (GDTR) descriptor.
4925 Writes and the current GDTR descriptor specified by Gdtr. This function is
4926 only available on IA-32 and X64.
4928 If Gdtr is NULL, then ASSERT().
4930 @param Gdtr Pointer to a GDTR descriptor.
4936 IN CONST IA32_DESCRIPTOR
*Gdtr
4940 Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.
4942 Reads and returns the current IDTR descriptor and returns it in Idtr. This
4943 function is only available on IA-32 and X64.
4945 If Idtr is NULL, then ASSERT().
4947 @param Idtr Pointer to a IDTR descriptor.
4953 OUT IA32_DESCRIPTOR
*Idtr
4957 Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.
4959 Writes the current IDTR descriptor and returns it in Idtr. This function is
4960 only available on IA-32 and X64.
4962 If Idtr is NULL, then ASSERT().
4964 @param Idtr Pointer to a IDTR descriptor.
4970 IN CONST IA32_DESCRIPTOR
*Idtr
4974 Reads the current Local Descriptor Table Register(LDTR) selector.
4976 Reads and returns the current 16-bit LDTR descriptor value. This function is
4977 only available on IA-32 and X64.
4979 @return The current selector of LDT.
4989 Writes the current Local Descriptor Table Register (GDTR) selector.
4991 Writes and the current LDTR descriptor specified by Ldtr. This function is
4992 only available on IA-32 and X64.
4994 @param Ldtr 16-bit LDTR selector value.
5004 Save the current floating point/SSE/SSE2 context to a buffer.
5006 Saves the current floating point/SSE/SSE2 state to the buffer specified by
5007 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
5008 available on IA-32 and X64.
5010 If Buffer is NULL, then ASSERT().
5011 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
5013 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
5019 OUT IA32_FX_BUFFER
*Buffer
5023 Restores the current floating point/SSE/SSE2 context from a buffer.
5025 Restores the current floating point/SSE/SSE2 state from the buffer specified
5026 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
5027 only available on IA-32 and X64.
5029 If Buffer is NULL, then ASSERT().
5030 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
5031 If Buffer was not saved with AsmFxSave(), then ASSERT().
5033 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
5039 IN CONST IA32_FX_BUFFER
*Buffer
5043 Reads the current value of 64-bit MMX Register #0 (MM0).
5045 Reads and returns the current value of MM0. This function is only available
5048 @return The current value of MM0.
5058 Reads the current value of 64-bit MMX Register #1 (MM1).
5060 Reads and returns the current value of MM1. This function is only available
5063 @return The current value of MM1.
5073 Reads the current value of 64-bit MMX Register #2 (MM2).
5075 Reads and returns the current value of MM2. This function is only available
5078 @return The current value of MM2.
5088 Reads the current value of 64-bit MMX Register #3 (MM3).
5090 Reads and returns the current value of MM3. This function is only available
5093 @return The current value of MM3.
5103 Reads the current value of 64-bit MMX Register #4 (MM4).
5105 Reads and returns the current value of MM4. This function is only available
5108 @return The current value of MM4.
5118 Reads the current value of 64-bit MMX Register #5 (MM5).
5120 Reads and returns the current value of MM5. This function is only available
5123 @return The current value of MM5.
5133 Reads the current value of 64-bit MMX Register #6 (MM6).
5135 Reads and returns the current value of MM6. This function is only available
5138 @return The current value of MM6.
5148 Reads the current value of 64-bit MMX Register #7 (MM7).
5150 Reads and returns the current value of MM7. This function is only available
5153 @return The current value of MM7.
5163 Writes the current value of 64-bit MMX Register #0 (MM0).
5165 Writes the current value of MM0. This function is only available on IA32 and
5168 @param Value The 64-bit value to write to MM0.
5178 Writes the current value of 64-bit MMX Register #1 (MM1).
5180 Writes the current value of MM1. This function is only available on IA32 and
5183 @param Value The 64-bit value to write to MM1.
5193 Writes the current value of 64-bit MMX Register #2 (MM2).
5195 Writes the current value of MM2. This function is only available on IA32 and
5198 @param Value The 64-bit value to write to MM2.
5208 Writes the current value of 64-bit MMX Register #3 (MM3).
5210 Writes the current value of MM3. This function is only available on IA32 and
5213 @param Value The 64-bit value to write to MM3.
5223 Writes the current value of 64-bit MMX Register #4 (MM4).
5225 Writes the current value of MM4. This function is only available on IA32 and
5228 @param Value The 64-bit value to write to MM4.
5238 Writes the current value of 64-bit MMX Register #5 (MM5).
5240 Writes the current value of MM5. This function is only available on IA32 and
5243 @param Value The 64-bit value to write to MM5.
5253 Writes the current value of 64-bit MMX Register #6 (MM6).
5255 Writes the current value of MM6. This function is only available on IA32 and
5258 @param Value The 64-bit value to write to MM6.
5268 Writes the current value of 64-bit MMX Register #7 (MM7).
5270 Writes the current value of MM7. This function is only available on IA32 and
5273 @param Value The 64-bit value to write to MM7.
5283 Reads the current value of Time Stamp Counter (TSC).
5285 Reads and returns the current value of TSC. This function is only available
5288 @return The current value of TSC
5298 Reads the current value of a Performance Counter (PMC).
5300 Reads and returns the current value of performance counter specified by
5301 Index. This function is only available on IA-32 and X64.
5303 @param Index The 32-bit Performance Counter index to read.
5305 @return The value of the PMC specified by Index.
5315 Sets up a monitor buffer that is used by AsmMwait().
5317 Executes a MONITOR instruction with the register state specified by Eax, Ecx
5318 and Edx. Returns Eax. This function is only available on IA-32 and X64.
5320 @param Eax The value to load into EAX or RAX before executing the MONITOR
5322 @param Ecx The value to load into ECX or RCX before executing the MONITOR
5324 @param Edx The value to load into EDX or RDX before executing the MONITOR
5339 Executes an MWAIT instruction.
5341 Executes an MWAIT instruction with the register state specified by Eax and
5342 Ecx. Returns Eax. This function is only available on IA-32 and X64.
5344 @param Eax The value to load into EAX or RAX before executing the MONITOR
5346 @param Ecx The value to load into ECX or RCX before executing the MONITOR
5360 Executes a WBINVD instruction.
5362 Executes a WBINVD instruction. This function is only available on IA-32 and
5373 Executes a INVD instruction.
5375 Executes a INVD instruction. This function is only available on IA-32 and
5386 Flushes a cache line from all the instruction and data caches within the
5387 coherency domain of the CPU.
5389 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
5390 This function is only available on IA-32 and X64.
5392 @param LinearAddress The address of the cache line to flush. If the CPU is
5393 in a physical addressing mode, then LinearAddress is a
5394 physical address. If the CPU is in a virtual
5395 addressing mode, then LinearAddress is a virtual
5398 @return LinearAddress
5403 IN VOID
*LinearAddress
5407 Enables the 32-bit paging mode on the CPU.
5409 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
5410 must be properly initialized prior to calling this service. This function
5411 assumes the current execution mode is 32-bit protected mode. This function is
5412 only available on IA-32. After the 32-bit paging mode is enabled, control is
5413 transferred to the function specified by EntryPoint using the new stack
5414 specified by NewStack and passing in the parameters specified by Context1 and
5415 Context2. Context1 and Context2 are optional and may be NULL. The function
5416 EntryPoint must never return.
5418 If the current execution mode is not 32-bit protected mode, then ASSERT().
5419 If EntryPoint is NULL, then ASSERT().
5420 If NewStack is NULL, then ASSERT().
5422 There are a number of constraints that must be followed before calling this
5424 1) Interrupts must be disabled.
5425 2) The caller must be in 32-bit protected mode with flat descriptors. This
5426 means all descriptors must have a base of 0 and a limit of 4GB.
5427 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
5429 4) CR3 must point to valid page tables that will be used once the transition
5430 is complete, and those page tables must guarantee that the pages for this
5431 function and the stack are identity mapped.
5433 @param EntryPoint A pointer to function to call with the new stack after
5435 @param Context1 A pointer to the context to pass into the EntryPoint
5436 function as the first parameter after paging is enabled.
5437 @param Context2 A pointer to the context to pass into the EntryPoint
5438 function as the second parameter after paging is enabled.
5439 @param NewStack A pointer to the new stack to use for the EntryPoint
5440 function after paging is enabled.
5446 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
5447 IN VOID
*Context1
, OPTIONAL
5448 IN VOID
*Context2
, OPTIONAL
5453 Disables the 32-bit paging mode on the CPU.
5455 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
5456 mode. This function assumes the current execution mode is 32-paged protected
5457 mode. This function is only available on IA-32. After the 32-bit paging mode
5458 is disabled, control is transferred to the function specified by EntryPoint
5459 using the new stack specified by NewStack and passing in the parameters
5460 specified by Context1 and Context2. Context1 and Context2 are optional and
5461 may be NULL. The function EntryPoint must never return.
5463 If the current execution mode is not 32-bit paged mode, then ASSERT().
5464 If EntryPoint is NULL, then ASSERT().
5465 If NewStack is NULL, then ASSERT().
5467 There are a number of constraints that must be followed before calling this
5469 1) Interrupts must be disabled.
5470 2) The caller must be in 32-bit paged mode.
5471 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
5472 4) CR3 must point to valid page tables that guarantee that the pages for
5473 this function and the stack are identity mapped.
5475 @param EntryPoint A pointer to function to call with the new stack after
5477 @param Context1 A pointer to the context to pass into the EntryPoint
5478 function as the first parameter after paging is disabled.
5479 @param Context2 A pointer to the context to pass into the EntryPoint
5480 function as the second parameter after paging is
5482 @param NewStack A pointer to the new stack to use for the EntryPoint
5483 function after paging is disabled.
5488 AsmDisablePaging32 (
5489 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
5490 IN VOID
*Context1
, OPTIONAL
5491 IN VOID
*Context2
, OPTIONAL
5496 Enables the 64-bit paging mode on the CPU.
5498 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
5499 must be properly initialized prior to calling this service. This function
5500 assumes the current execution mode is 32-bit protected mode with flat
5501 descriptors. This function is only available on IA-32. After the 64-bit
5502 paging mode is enabled, control is transferred to the function specified by
5503 EntryPoint using the new stack specified by NewStack and passing in the
5504 parameters specified by Context1 and Context2. Context1 and Context2 are
5505 optional and may be 0. The function EntryPoint must never return.
5507 If the current execution mode is not 32-bit protected mode with flat
5508 descriptors, then ASSERT().
5509 If EntryPoint is 0, then ASSERT().
5510 If NewStack is 0, then ASSERT().
5512 @param Cs The 16-bit selector to load in the CS before EntryPoint
5513 is called. The descriptor in the GDT that this selector
5514 references must be setup for long mode.
5515 @param EntryPoint The 64-bit virtual address of the function to call with
5516 the new stack after paging is enabled.
5517 @param Context1 The 64-bit virtual address of the context to pass into
5518 the EntryPoint function as the first parameter after
5520 @param Context2 The 64-bit virtual address of the context to pass into
5521 the EntryPoint function as the second parameter after
5523 @param NewStack The 64-bit virtual address of the new stack to use for
5524 the EntryPoint function after paging is enabled.
5530 IN UINT16 CodeSelector
,
5531 IN UINT64 EntryPoint
,
5532 IN UINT64 Context1
, OPTIONAL
5533 IN UINT64 Context2
, OPTIONAL
5538 Disables the 64-bit paging mode on the CPU.
5540 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
5541 mode. This function assumes the current execution mode is 64-paging mode.
5542 This function is only available on X64. After the 64-bit paging mode is
5543 disabled, control is transferred to the function specified by EntryPoint
5544 using the new stack specified by NewStack and passing in the parameters
5545 specified by Context1 and Context2. Context1 and Context2 are optional and
5546 may be 0. The function EntryPoint must never return.
5548 If the current execution mode is not 64-bit paged mode, then ASSERT().
5549 If EntryPoint is 0, then ASSERT().
5550 If NewStack is 0, then ASSERT().
5552 @param Cs The 16-bit selector to load in the CS before EntryPoint
5553 is called. The descriptor in the GDT that this selector
5554 references must be setup for 32-bit protected mode.
5555 @param EntryPoint The 64-bit virtual address of the function to call with
5556 the new stack after paging is disabled.
5557 @param Context1 The 64-bit virtual address of the context to pass into
5558 the EntryPoint function as the first parameter after
5560 @param Context2 The 64-bit virtual address of the context to pass into
5561 the EntryPoint function as the second parameter after
5563 @param NewStack The 64-bit virtual address of the new stack to use for
5564 the EntryPoint function after paging is disabled.
5569 AsmDisablePaging64 (
5570 IN UINT16 CodeSelector
,
5571 IN UINT32 EntryPoint
,
5572 IN UINT32 Context1
, OPTIONAL
5573 IN UINT32 Context2
, OPTIONAL
5578 // 16-bit thunking services
5582 Retrieves the properties for 16-bit thunk functions.
5584 Computes the size of the buffer and stack below 1MB required to use the
5585 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
5586 buffer size is returned in RealModeBufferSize, and the stack size is returned
5587 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
5588 then the actual minimum stack size is ExtraStackSize plus the maximum number
5589 of bytes that need to be passed to the 16-bit real mode code.
5591 If RealModeBufferSize is NULL, then ASSERT().
5592 If ExtraStackSize is NULL, then ASSERT().
5594 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
5595 required to use the 16-bit thunk functions.
5596 @param ExtraStackSize A pointer to the extra size of stack below 1MB
5597 that the 16-bit thunk functions require for
5598 temporary storage in the transition to and from
5604 AsmGetThunk16Properties (
5605 OUT UINT32
*RealModeBufferSize
,
5606 OUT UINT32
*ExtraStackSize
5610 Prepares all structures a code required to use AsmThunk16().
5612 Prepares all structures and code required to use AsmThunk16().
5614 If ThunkContext is NULL, then ASSERT().
5616 @param ThunkContext A pointer to the context structure that describes the
5617 16-bit real mode code to call.
5623 OUT THUNK_CONTEXT
*ThunkContext
5627 Transfers control to a 16-bit real mode entry point and returns the results.
5629 Transfers control to a 16-bit real mode entry point and returns the results.
5630 AsmPrepareThunk16() must be called with ThunkContext before this function is
5633 If ThunkContext is NULL, then ASSERT().
5634 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
5636 @param ThunkContext A pointer to the context structure that describes the
5637 16-bit real mode code to call.
5643 IN OUT THUNK_CONTEXT
*ThunkContext
5647 Prepares all structures and code for a 16-bit real mode thunk, transfers
5648 control to a 16-bit real mode entry point, and returns the results.
5650 Prepares all structures and code for a 16-bit real mode thunk, transfers
5651 control to a 16-bit real mode entry point, and returns the results. If the
5652 caller only need to perform a single 16-bit real mode thunk, then this
5653 service should be used. If the caller intends to make more than one 16-bit
5654 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
5655 once and AsmThunk16() can be called for each 16-bit real mode thunk.
5657 If ThunkContext is NULL, then ASSERT().
5659 @param ThunkContext A pointer to the context structure that describes the
5660 16-bit real mode code to call.
5665 AsmPrepareAndThunk16 (
5666 IN OUT THUNK_CONTEXT
*ThunkContext
5670 Transfers control to a function starting with a new stack.
5672 Transfers control to the function specified by EntryPoint using the new stack
5673 specified by NewStack and passing in the parameters specified by Context1 and
5674 Context2. Context1 and Context2 are optional and may be NULL. The function
5675 EntryPoint must never return.
5677 If EntryPoint is NULL, then ASSERT().
5678 If NewStack is NULL, then ASSERT().
5680 @param EntryPoint A pointer to function to call with the new stack.
5681 @param Context1 A pointer to the context to pass into the EntryPoint
5683 @param Context2 A pointer to the context to pass into the EntryPoint
5685 @param NewStack A pointer to the new stack to use for the EntryPoint
5687 @param NewBsp A pointer to the new memory location for RSE backing
5693 AsmSwitchStackAndBackingStore (
5694 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
5695 IN VOID
*Context1
, OPTIONAL
5696 IN VOID
*Context2
, OPTIONAL
5709 // IPF Specific functions
5714 Performs a PAL call using static calling convention.
5716 An internal function to perform a PAL call using static calling convention.
5718 @param PalEntryPoint The entry point address of PAL. The address in ar.kr5
5719 would be used if this parameter were NULL on input.
5720 @param Arg1 The first argument of a PAL call.
5721 @param Arg1 The second argument of a PAL call.
5722 @param Arg1 The third argument of a PAL call.
5723 @param Arg1 The fourth argument of a PAL call.
5725 @return The values returned in r8, r9, r10 and r11.
5730 IN CONST VOID
*PalEntryPoint
,
5739 Returns the current value of ar.itc.
5741 An internal function to return the current value of ar.itc, which is the
5744 @return The currect value of ar.itc
5754 Flush a range of cache lines in the cache coherency domain of the calling
5757 Invalidates the cache lines specified by Address and Length. If Address is
5758 not aligned on a cache line boundary, then entire cache line containing
5759 Address is invalidated. If Address + Length is not aligned on a cache line
5760 boundary, then the entire instruction cache line containing Address + Length
5761 -1 is invalidated. This function may choose to invalidate the entire
5762 instruction cache if that is more efficient than invalidating the specified
5763 range. If Length is 0, the no instruction cache lines are invalidated.
5764 Address is returned.
5766 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
5768 @param Address The base address of the instruction lines to invalidate. If
5769 the CPU is in a physical addressing mode, then Address is a
5770 physical address. If the CPU is in a virtual addressing mode,
5771 then Address is a virtual address.
5773 @param Length The number of bytes to invalidate from the instruction cache.
5780 IpfFlushCacheRange (