3 Copyright (c) 2004 - 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 Memory-only library functions with no library constructor/destructor
23 #ifndef __EDKII_GLUE_BASE_LIB_H__
24 #define __EDKII_GLUE_BASE_LIB_H__
30 #define StrCpy(_Dest, _Source) GlueStrCpy(_Dest, _Source)
31 #define StrnCpy(_Dest, _Source, _Length) GlueStrnCpy(_Dest, _Source, _Length)
32 #define StrLen(_String) GlueStrLen(_String)
33 #define StrSize(_String) GlueStrSize(_String)
34 #define StrCmp(_FristString, _SecondString) GlueStrCmp(_FristString, _SecondString)
35 #define StrnCmp(_FirstString, _SecondString, _Length) GlueStrnCmp(_FirstString, _SecondString, _Length)
36 #define StrCat(_Dest, _Source) GlueStrCat(_Dest, _Source)
37 #define StrnCat(_Dest, _Source, _Length) GlueStrnCat(_Dest, _Source, _Length)
42 #define InitializeListHead(_ListHead) GlueInitializeListHead(_ListHead)
43 #define InsertHeadList(_ListHead, _Entry ) GlueInsertHeadList(_ListHead, _Entry)
44 #define InsertTailList(_ListHead, _Entry) GlueInsertTailList(_ListHead, _Entry)
45 #define GetFirstNode(_List) GlueGetFirstNode(_List)
46 #define GetNextNode(_List, _Node) GlueGetNextNode(_List, _Node)
47 #define IsListEmpty(_ListHead) GlueIsListEmpty(_ListHead)
48 #define IsNull(_List, _Node) GlueIsNull(_List, _Node)
49 #define IsNodeAtEnd(_List, _Node) GlueIsNodeAtEnd(_List, _Node)
50 #define SwapListEntries(_FirstEntry, _SecondEntry) GlueSwapListEntries(_FirstEntry, _SecondEntry)
51 #define RemoveEntryList(_Entry) GlueRemoveEntryList(_Entry)
56 #define LShiftU64(_Op, _Count) GlueLShiftU64(_Op, _Count)
57 #define RShiftU64(_Op, _Count) GlueRShiftU64(_Op, _Count)
58 #define MultU64x32(_Multiplicand, _Multiplier) GlueMultU64x32(_Multiplicand, _Multiplier)
59 #define DivU64x32(_Dividend, _Divisor) GlueDivU64x32(_Dividend, _Divisor)
64 #define GetInterruptState() GlueGetInterruptState()
68 // Definitions for architecture specific types
69 // These include SPIN_LOCK and BASE_LIBRARY_JUMP_BUFFER
75 typedef UINTN SPIN_LOCK
;
77 #if defined (MDE_CPU_IA32)
79 // IA32 context buffer used by SetJump() and LongJump()
88 } BASE_LIBRARY_JUMP_BUFFER
;
90 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
92 #elif defined (MDE_CPU_IPF)
94 // IPF context buffer used by SetJump() and LongJump()
129 UINT64 AfterSpillUNAT
;
135 } BASE_LIBRARY_JUMP_BUFFER
;
137 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 0x10
139 #elif defined (MDE_CPU_X64)
141 // X64 context buffer used by SetJump() and LongJump()
154 } BASE_LIBRARY_JUMP_BUFFER
;
156 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
158 #elif defined (MDE_CPU_EBC)
160 // EBC context buffer used by SetJump() and LongJump()
168 } BASE_LIBRARY_JUMP_BUFFER
;
170 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
173 #error Unknown Processor Type
181 Copies one Null-terminated Unicode string to another Null-terminated Unicode
182 string and returns the new Unicode string.
184 This function copies the contents of the Unicode string Source to the Unicode
185 string Destination, and returns Destination. If Source and Destination
186 overlap, then the results are undefined.
188 If Destination is NULL, then ASSERT().
189 If Destination is not aligned on a 16-bit boundary, then ASSERT().
190 If Source is NULL, then ASSERT().
191 If Source is not aligned on a 16-bit boundary, then ASSERT().
192 If Source and Destination overlap, then ASSERT().
193 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
194 PcdMaximumUnicodeStringLength Unicode characters not including the
195 Null-terminator, then ASSERT().
197 @param Destination Pointer to a Null-terminated Unicode string.
198 @param Source Pointer to a Null-terminated Unicode string.
206 OUT CHAR16
*Destination
,
207 IN CONST CHAR16
*Source
210 Copies one Null-terminated Unicode string with a maximum length to another
211 Null-terminated Unicode string with a maximum length and returns the new
214 This function copies the contents of the Unicode string Source to the Unicode
215 string Destination, and returns Destination. At most, Length Unicode
216 characters are copied from Source to Destination. If Length is 0, then
217 Destination is returned unmodified. If Length is greater that the number of
218 Unicode characters in Source, then Destination is padded with Null Unicode
219 characters. If Source and Destination overlap, then the results are
222 If Length > 0 and Destination is NULL, then ASSERT().
223 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
224 If Length > 0 and Source is NULL, then ASSERT().
225 If Length > 0 and Source is not aligned on a 16-bit bounadry, then ASSERT().
226 If Source and Destination overlap, then ASSERT().
227 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
228 PcdMaximumUnicodeStringLength Unicode characters not including the
229 Null-terminator, then ASSERT().
231 @param Destination Pointer to a Null-terminated Unicode string.
232 @param Source Pointer to a Null-terminated Unicode string.
233 @param Length Maximum number of Unicode characters to copy.
241 OUT CHAR16
*Destination
,
242 IN CONST CHAR16
*Source
,
246 Returns the length of a Null-terminated Unicode string.
248 This function returns the number of Unicode characters in the Null-terminated
249 Unicode string specified by String.
251 If String is NULL, then ASSERT().
252 If String is not aligned on a 16-bit boundary, then ASSERT().
253 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
254 PcdMaximumUnicodeStringLength Unicode characters not including the
255 Null-terminator, then ASSERT().
257 @param String Pointer to a Null-terminated Unicode string.
259 @return The length of String.
265 IN CONST CHAR16
*String
268 Returns the size of a Null-terminated Unicode string in bytes, including the
271 This function returns the size, in bytes, of the Null-terminated Unicode
272 string specified by String.
274 If String is NULL, then ASSERT().
275 If String is not aligned on a 16-bit boundary, then ASSERT().
276 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
277 PcdMaximumUnicodeStringLength Unicode characters not including the
278 Null-terminator, then ASSERT().
280 @param String Pointer to a Null-terminated Unicode string.
282 @return The size of String.
288 IN CONST CHAR16
*String
291 Compares two Null-terminated Unicode strings, and returns the difference
292 between the first mismatched Unicode characters.
294 This function compares the Null-terminated Unicode string FirstString to the
295 Null-terminated Unicode string SecondString. If FirstString is identical to
296 SecondString, then 0 is returned. Otherwise, the value returned is the first
297 mismatched Unicode character in SecondString subtracted from the first
298 mismatched Unicode character in FirstString.
300 If FirstString is NULL, then ASSERT().
301 If FirstString is not aligned on a 16-bit boundary, then ASSERT().
302 If SecondString is NULL, then ASSERT().
303 If SecondString is not aligned on a 16-bit boundary, then ASSERT().
304 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
305 than PcdMaximumUnicodeStringLength Unicode characters not including the
306 Null-terminator, then ASSERT().
307 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
308 than PcdMaximumUnicodeStringLength Unicode characters not including the
309 Null-terminator, then ASSERT().
311 @param FirstString Pointer to a Null-terminated Unicode string.
312 @param SecondString Pointer to a Null-terminated Unicode string.
314 @retval 0 FirstString is identical to SecondString.
315 @retval !=0 FirstString is not identical to SecondString.
321 IN CONST CHAR16
*FirstString
,
322 IN CONST CHAR16
*SecondString
325 Compares two Null-terminated Unicode strings with maximum lengths, and
326 returns the difference between the first mismatched Unicode characters.
328 This function compares the Null-terminated Unicode string FirstString to the
329 Null-terminated Unicode string SecondString. At most, Length Unicode
330 characters will be compared. If Length is 0, then 0 is returned. If
331 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
332 value returned is the first mismatched Unicode character in SecondString
333 subtracted from the first mismatched Unicode character in FirstString.
335 If Length > 0 and FirstString is NULL, then ASSERT().
336 If Length > 0 and FirstString is not aligned on a 16-bit bounadary, then ASSERT().
337 If Length > 0 and SecondString is NULL, then ASSERT().
338 If Length > 0 and SecondString is not aligned on a 16-bit bounadary, then ASSERT().
339 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
340 than PcdMaximumUnicodeStringLength Unicode characters not including the
341 Null-terminator, then ASSERT().
342 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
343 than PcdMaximumUnicodeStringLength Unicode characters not including the
344 Null-terminator, then ASSERT().
346 @param FirstString Pointer to a Null-terminated Unicode string.
347 @param SecondString Pointer to a Null-terminated Unicode string.
348 @param Length Maximum number of Unicode characters to compare.
350 @retval 0 FirstString is identical to SecondString.
351 @retval !=0 FirstString is not identical to SecondString.
357 IN CONST CHAR16
*FirstString
,
358 IN CONST CHAR16
*SecondString
,
362 Concatenates one Null-terminated Unicode string to another Null-terminated
363 Unicode string, and returns the concatenated Unicode string.
365 This function concatenates two Null-terminated Unicode strings. The contents
366 of Null-terminated Unicode string Source are concatenated to the end of
367 Null-terminated Unicode string Destination. The Null-terminated concatenated
368 Unicode String is returned. If Source and Destination overlap, then the
369 results are undefined.
371 If Destination is NULL, then ASSERT().
372 If Destination is not aligned on a 16-bit bounadary, then ASSERT().
373 If Source is NULL, then ASSERT().
374 If Source is not aligned on a 16-bit bounadary, then ASSERT().
375 If Source and Destination overlap, then ASSERT().
376 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
377 than PcdMaximumUnicodeStringLength Unicode characters not including the
378 Null-terminator, then ASSERT().
379 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
380 PcdMaximumUnicodeStringLength Unicode characters not including the
381 Null-terminator, then ASSERT().
382 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
383 and Source results in a Unicode string with more than
384 PcdMaximumUnicodeStringLength Unicode characters not including the
385 Null-terminator, then ASSERT().
387 @param Destination Pointer to a Null-terminated Unicode string.
388 @param Source Pointer to a Null-terminated Unicode string.
396 IN OUT CHAR16
*Destination
,
397 IN CONST CHAR16
*Source
400 Concatenates one Null-terminated Unicode string with a maximum length to the
401 end of another Null-terminated Unicode string, and returns the concatenated
404 This function concatenates two Null-terminated Unicode strings. The contents
405 of Null-terminated Unicode string Source are concatenated to the end of
406 Null-terminated Unicode string Destination, and Destination is returned. At
407 most, Length Unicode characters are concatenated from Source to the end of
408 Destination, and Destination is always Null-terminated. If Length is 0, then
409 Destination is returned unmodified. If Source and Destination overlap, then
410 the results are undefined.
412 If Destination is NULL, then ASSERT().
413 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
414 If Length > 0 and Source is NULL, then ASSERT().
415 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
416 If Source and Destination overlap, then ASSERT().
417 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
418 than PcdMaximumUnicodeStringLength Unicode characters not including the
419 Null-terminator, then ASSERT().
420 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
421 PcdMaximumUnicodeStringLength Unicode characters not including the
422 Null-terminator, then ASSERT().
423 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
424 and Source results in a Unicode string with more than
425 PcdMaximumUnicodeStringLength Unicode characters not including the
426 Null-terminator, then ASSERT().
428 @param Destination Pointer to a Null-terminated Unicode string.
429 @param Source Pointer to a Null-terminated Unicode string.
430 @param Length Maximum number of Unicode characters to concatenate from
439 IN OUT CHAR16
*Destination
,
440 IN CONST CHAR16
*Source
,
445 Returns the first occurance of a Null-terminated Unicode sub-string
446 in a Null-terminated Unicode string.
448 This function scans the contents of the Null-terminated Unicode string
449 specified by String and returns the first occurrence of SearchString.
450 If SearchString is not found in String, then NULL is returned. If
451 the length of SearchString is zero, then String is
454 If String is NULL, then ASSERT().
455 If String is not aligned on a 16-bit boundary, then ASSERT().
456 If SearchString is NULL, then ASSERT().
457 If SearchString is not aligned on a 16-bit boundary, then ASSERT().
459 If PcdMaximumUnicodeStringLength is not zero, and SearchString
460 or String contains more than PcdMaximumUnicodeStringLength Unicode
461 characters not including the Null-terminator, then ASSERT().
463 @param String Pointer to a Null-terminated Unicode string.
464 @param SearchString Pointer to a Null-terminated Unicode string to search for.
466 @retval NULL If the SearchString does not appear in String.
467 @retval !NULL If there is a match.
473 IN CONST CHAR16
*String
,
474 IN CONST CHAR16
*SearchString
478 Convert a Null-terminated Unicode decimal string to a value of
481 This function returns a value of type UINTN by interpreting the contents
482 of the Unicode string specified by String as a decimal number. The format
483 of the input Unicode string String is:
485 [spaces] [decimal digits].
487 The valid decimal digit character is in the range [0-9]. The
488 function will ignore the pad space, which includes spaces or
489 tab characters, before [decimal digits]. The running zero in the
490 beginning of [decimal digits] will be ignored. Then, the function
491 stops at the first character that is a not a valid decimal character
492 or a Null-terminator, whichever one comes first.
494 If String is NULL, then ASSERT().
495 If String is not aligned in a 16-bit boundary, then ASSERT().
496 If String has only pad spaces, then 0 is returned.
497 If String has no pad spaces or valid decimal digits,
499 If the number represented by String overflows according
500 to the range defined by UINTN, then ASSERT().
502 If PcdMaximumUnicodeStringLength is not zero, and String contains
503 more than PcdMaximumUnicodeStringLength Unicode characters not including
504 the Null-terminator, then ASSERT().
506 @param String Pointer to a Null-terminated Unicode string.
514 IN CONST CHAR16
*String
518 Convert a Null-terminated Unicode decimal string to a value of
521 This function returns a value of type UINT64 by interpreting the contents
522 of the Unicode string specified by String as a decimal number. The format
523 of the input Unicode string String is:
525 [spaces] [decimal digits].
527 The valid decimal digit character is in the range [0-9]. The
528 function will ignore the pad space, which includes spaces or
529 tab characters, before [decimal digits]. The running zero in the
530 beginning of [decimal digits] will be ignored. Then, the function
531 stops at the first character that is a not a valid decimal character
532 or a Null-terminator, whichever one comes first.
534 If String is NULL, then ASSERT().
535 If String is not aligned in a 16-bit boundary, then ASSERT().
536 If String has only pad spaces, then 0 is returned.
537 If String has no pad spaces or valid decimal digits,
539 If the number represented by String overflows according
540 to the range defined by UINT64, then ASSERT().
542 If PcdMaximumUnicodeStringLength is not zero, and String contains
543 more than PcdMaximumUnicodeStringLength Unicode characters not including
544 the Null-terminator, then ASSERT().
546 @param String Pointer to a Null-terminated Unicode string.
554 IN CONST CHAR16
*String
558 Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.
560 This function returns a value of type UINTN by interpreting the contents
561 of the Unicode string specified by String as a hexadecimal number.
562 The format of the input Unicode string String is:
564 [spaces][zeros][x][hexadecimal digits].
566 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
567 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
568 If "x" appears in the input string, it must be prefixed with at least one 0.
569 The function will ignore the pad space, which includes spaces or tab characters,
570 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
571 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
572 first valid hexadecimal digit. Then, the function stops at the first character that is
573 a not a valid hexadecimal character or NULL, whichever one comes first.
575 If String is NULL, then ASSERT().
576 If String is not aligned in a 16-bit boundary, then ASSERT().
577 If String has only pad spaces, then zero is returned.
578 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
579 then zero is returned.
580 If the number represented by String overflows according to the range defined by
581 UINTN, then ASSERT().
583 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
584 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
587 @param String Pointer to a Null-terminated Unicode string.
595 IN CONST CHAR16
*String
599 Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.
601 This function returns a value of type UINT64 by interpreting the contents
602 of the Unicode string specified by String as a hexadecimal number.
603 The format of the input Unicode string String is
605 [spaces][zeros][x][hexadecimal digits].
607 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
608 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
609 If "x" appears in the input string, it must be prefixed with at least one 0.
610 The function will ignore the pad space, which includes spaces or tab characters,
611 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
612 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
613 first valid hexadecimal digit. Then, the function stops at the first character that is
614 a not a valid hexadecimal character or NULL, whichever one comes first.
616 If String is NULL, then ASSERT().
617 If String is not aligned in a 16-bit boundary, then ASSERT().
618 If String has only pad spaces, then zero is returned.
619 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
620 then zero is returned.
621 If the number represented by String overflows according to the range defined by
622 UINT64, then ASSERT().
624 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
625 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
628 @param String Pointer to a Null-terminated Unicode string.
636 IN CONST CHAR16
*String
640 Convert one Null-terminated Unicode string to a Null-terminated
641 ASCII string and returns the ASCII string.
643 This function converts the content of the Unicode string Source
644 to the ASCII string Destination by copying the lower 8 bits of
645 each Unicode character. It returns Destination.
647 If any Unicode characters in Source contain non-zero value in
648 the upper 8 bits, then ASSERT().
650 If Destination is NULL, then ASSERT().
651 If Source is NULL, then ASSERT().
652 If Source is not aligned on a 16-bit boundary, then ASSERT().
653 If Source and Destination overlap, then ASSERT().
655 If PcdMaximumUnicodeStringLength is not zero, and Source contains
656 more than PcdMaximumUnicodeStringLength Unicode characters not including
657 the Null-terminator, then ASSERT().
659 If PcdMaximumAsciiStringLength is not zero, and Source contains more
660 than PcdMaximumAsciiStringLength Unicode characters not including the
661 Null-terminator, then ASSERT().
663 @param Source Pointer to a Null-terminated Unicode string.
664 @param Destination Pointer to a Null-terminated ASCII string.
671 UnicodeStrToAsciiStr (
672 IN CONST CHAR16
*Source
,
673 OUT CHAR8
*Destination
677 Copies one Null-terminated ASCII string to another Null-terminated ASCII
678 string and returns the new ASCII string.
680 This function copies the contents of the ASCII string Source to the ASCII
681 string Destination, and returns Destination. If Source and Destination
682 overlap, then the results are undefined.
684 If Destination is NULL, then ASSERT().
685 If Source is NULL, then ASSERT().
686 If Source and Destination overlap, then ASSERT().
687 If PcdMaximumAsciiStringLength is not zero and Source contains more than
688 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
691 @param Destination Pointer to a Null-terminated ASCII string.
692 @param Source Pointer to a Null-terminated ASCII string.
700 OUT CHAR8
*Destination
,
701 IN CONST CHAR8
*Source
704 Copies one Null-terminated ASCII string with a maximum length to another
705 Null-terminated ASCII string with a maximum length and returns the new ASCII
708 This function copies the contents of the ASCII string Source to the ASCII
709 string Destination, and returns Destination. At most, Length ASCII characters
710 are copied from Source to Destination. If Length is 0, then Destination is
711 returned unmodified. If Length is greater that the number of ASCII characters
712 in Source, then Destination is padded with Null ASCII characters. If Source
713 and Destination overlap, then the results are undefined.
715 If Destination is NULL, then ASSERT().
716 If Source is NULL, then ASSERT().
717 If Source and Destination overlap, then ASSERT().
718 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
719 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
722 @param Destination Pointer to a Null-terminated ASCII string.
723 @param Source Pointer to a Null-terminated ASCII string.
724 @param Length Maximum number of ASCII characters to copy.
732 OUT CHAR8
*Destination
,
733 IN CONST CHAR8
*Source
,
737 Returns the length of a Null-terminated ASCII string.
739 This function returns the number of ASCII characters in the Null-terminated
740 ASCII string specified by String.
742 If Length > 0 and Destination is NULL, then ASSERT().
743 If Length > 0 and Source is NULL, then ASSERT().
744 If PcdMaximumAsciiStringLength is not zero and String contains more than
745 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
748 @param String Pointer to a Null-terminated ASCII string.
750 @return The length of String.
756 IN CONST CHAR8
*String
759 Returns the size of a Null-terminated ASCII string in bytes, including the
762 This function returns the size, in bytes, of the Null-terminated ASCII string
765 If String is NULL, then ASSERT().
766 If PcdMaximumAsciiStringLength is not zero and String contains more than
767 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
770 @param String Pointer to a Null-terminated ASCII string.
772 @return The size of String.
778 IN CONST CHAR8
*String
781 Compares two Null-terminated ASCII strings, and returns the difference
782 between the first mismatched ASCII characters.
784 This function compares the Null-terminated ASCII string FirstString to the
785 Null-terminated ASCII string SecondString. If FirstString is identical to
786 SecondString, then 0 is returned. Otherwise, the value returned is the first
787 mismatched ASCII character in SecondString subtracted from the first
788 mismatched ASCII character in FirstString.
790 If FirstString is NULL, then ASSERT().
791 If SecondString is NULL, then ASSERT().
792 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
793 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
795 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
796 than PcdMaximumAsciiStringLength ASCII characters not including the
797 Null-terminator, then ASSERT().
799 @param FirstString Pointer to a Null-terminated ASCII string.
800 @param SecondString Pointer to a Null-terminated ASCII string.
802 @retval 0 FirstString is identical to SecondString.
803 @retval !=0 FirstString is not identical to SecondString.
809 IN CONST CHAR8
*FirstString
,
810 IN CONST CHAR8
*SecondString
813 Performs a case insensitive comparison of two Null-terminated ASCII strings,
814 and returns the difference between the first mismatched ASCII characters.
816 This function performs a case insensitive comparison of the Null-terminated
817 ASCII string FirstString to the Null-terminated ASCII string SecondString. If
818 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
819 value returned is the first mismatched lower case ASCII character in
820 SecondString subtracted from the first mismatched lower case ASCII character
823 If FirstString is NULL, then ASSERT().
824 If SecondString is NULL, then ASSERT().
825 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
826 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
828 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
829 than PcdMaximumAsciiStringLength ASCII characters not including the
830 Null-terminator, then ASSERT().
832 @param FirstString Pointer to a Null-terminated ASCII string.
833 @param SecondString Pointer to a Null-terminated ASCII string.
835 @retval 0 FirstString is identical to SecondString using case insensitive
837 @retval !=0 FirstString is not identical to SecondString using case
838 insensitive comparisons.
844 IN CONST CHAR8
*FirstString
,
845 IN CONST CHAR8
*SecondString
848 Compares two Null-terminated ASCII strings with maximum lengths, and returns
849 the difference between the first mismatched ASCII characters.
851 This function compares the Null-terminated ASCII string FirstString to the
852 Null-terminated ASCII string SecondString. At most, Length ASCII characters
853 will be compared. If Length is 0, then 0 is returned. If FirstString is
854 identical to SecondString, then 0 is returned. Otherwise, the value returned
855 is the first mismatched ASCII character in SecondString subtracted from the
856 first mismatched ASCII character in FirstString.
858 If Length > 0 and FirstString is NULL, then ASSERT().
859 If Length > 0 and SecondString is NULL, then ASSERT().
860 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
861 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
863 If PcdMaximumAsciiStringLength is not zero and SecondString contains more than
864 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
867 @param FirstString Pointer to a Null-terminated ASCII string.
868 @param SecondString Pointer to a Null-terminated ASCII string.
870 @retval 0 FirstString is identical to SecondString.
871 @retval !=0 FirstString is not identical to SecondString.
877 IN CONST CHAR8
*FirstString
,
878 IN CONST CHAR8
*SecondString
,
882 Concatenates one Null-terminated ASCII string to another Null-terminated
883 ASCII string, and returns the concatenated ASCII string.
885 This function concatenates two Null-terminated ASCII strings. The contents of
886 Null-terminated ASCII string Source are concatenated to the end of Null-
887 terminated ASCII string Destination. The Null-terminated concatenated ASCII
890 If Destination is NULL, then ASSERT().
891 If Source is NULL, then ASSERT().
892 If PcdMaximumAsciiStringLength is not zero and Destination contains more than
893 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
895 If PcdMaximumAsciiStringLength is not zero and Source contains more than
896 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
898 If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
899 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
900 ASCII characters, then ASSERT().
902 @param Destination Pointer to a Null-terminated ASCII string.
903 @param Source Pointer to a Null-terminated ASCII string.
911 IN OUT CHAR8
*Destination
,
912 IN CONST CHAR8
*Source
915 Concatenates one Null-terminated ASCII string with a maximum length to the
916 end of another Null-terminated ASCII string, and returns the concatenated
919 This function concatenates two Null-terminated ASCII strings. The contents
920 of Null-terminated ASCII string Source are concatenated to the end of Null-
921 terminated ASCII string Destination, and Destination is returned. At most,
922 Length ASCII characters are concatenated from Source to the end of
923 Destination, and Destination is always Null-terminated. If Length is 0, then
924 Destination is returned unmodified. If Source and Destination overlap, then
925 the results are undefined.
927 If Length > 0 and Destination is NULL, then ASSERT().
928 If Length > 0 and Source is NULL, then ASSERT().
929 If Source and Destination overlap, then ASSERT().
930 If PcdMaximumAsciiStringLength is not zero, and Destination contains more than
931 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
933 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
934 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
936 If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
937 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
938 ASCII characters not including the Null-terminator, then ASSERT().
940 @param Destination Pointer to a Null-terminated ASCII string.
941 @param Source Pointer to a Null-terminated ASCII string.
942 @param Length Maximum number of ASCII characters to concatenate from
951 IN OUT CHAR8
*Destination
,
952 IN CONST CHAR8
*Source
,
957 Returns the first occurance of a Null-terminated ASCII sub-string
958 in a Null-terminated ASCII string.
960 This function scans the contents of the ASCII string specified by String
961 and returns the first occurrence of SearchString. If SearchString is not
962 found in String, then NULL is returned. If the length of SearchString is zero,
963 then String is returned.
965 If String is NULL, then ASSERT().
966 If SearchString is NULL, then ASSERT().
968 If PcdMaximumAsciiStringLength is not zero, and SearchString or
969 String contains more than PcdMaximumAsciiStringLength Unicode characters
970 not including the Null-terminator, then ASSERT().
972 @param String Pointer to a Null-terminated ASCII string.
973 @param SearchString Pointer to a Null-terminated ASCII string to search for.
975 @retval NULL If the SearchString does not appear in String.
976 @retval !NULL If there is a match.
982 IN CONST CHAR8
*String
,
983 IN CONST CHAR8
*SearchString
987 Convert a Null-terminated ASCII decimal string to a value of type
990 This function returns a value of type UINTN by interpreting the contents
991 of the ASCII string String as a decimal number. The format of the input
992 ASCII string String is:
994 [spaces] [decimal digits].
996 The valid decimal digit character is in the range [0-9]. The function will
997 ignore the pad space, which includes spaces or tab characters, before the digits.
998 The running zero in the beginning of [decimal digits] will be ignored. Then, the
999 function stops at the first character that is a not a valid decimal character or
1000 Null-terminator, whichever on comes first.
1002 If String has only pad spaces, then 0 is returned.
1003 If String has no pad spaces or valid decimal digits, then 0 is returned.
1004 If the number represented by String overflows according to the range defined by
1005 UINTN, then ASSERT().
1006 If String is NULL, then ASSERT().
1007 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1008 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1011 @param String Pointer to a Null-terminated ASCII string.
1018 AsciiStrDecimalToUintn (
1019 IN CONST CHAR8
*String
1023 Convert a Null-terminated ASCII decimal string to a value of type
1026 This function returns a value of type UINT64 by interpreting the contents
1027 of the ASCII string String as a decimal number. The format of the input
1028 ASCII string String is:
1030 [spaces] [decimal digits].
1032 The valid decimal digit character is in the range [0-9]. The function will
1033 ignore the pad space, which includes spaces or tab characters, before the digits.
1034 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1035 function stops at the first character that is a not a valid decimal character or
1036 Null-terminator, whichever on comes first.
1038 If String has only pad spaces, then 0 is returned.
1039 If String has no pad spaces or valid decimal digits, then 0 is returned.
1040 If the number represented by String overflows according to the range defined by
1041 UINT64, then ASSERT().
1042 If String is NULL, then ASSERT().
1043 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1044 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1047 @param String Pointer to a Null-terminated ASCII string.
1054 AsciiStrDecimalToUint64 (
1055 IN CONST CHAR8
*String
1059 Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.
1061 This function returns a value of type UINTN by interpreting the contents of
1062 the ASCII string String as a hexadecimal number. The format of the input ASCII
1065 [spaces][zeros][x][hexadecimal digits].
1067 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1068 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1069 appears in the input string, it must be prefixed with at least one 0. The function
1070 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1071 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1072 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1073 digit. Then, the function stops at the first character that is a not a valid
1074 hexadecimal character or Null-terminator, whichever on comes first.
1076 If String has only pad spaces, then 0 is returned.
1077 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1080 If the number represented by String overflows according to the range defined by UINTN,
1082 If String is NULL, then ASSERT().
1083 If PcdMaximumAsciiStringLength is not zero,
1084 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1085 the Null-terminator, then ASSERT().
1087 @param String Pointer to a Null-terminated ASCII string.
1094 AsciiStrHexToUintn (
1095 IN CONST CHAR8
*String
1099 Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.
1101 This function returns a value of type UINT64 by interpreting the contents of
1102 the ASCII string String as a hexadecimal number. The format of the input ASCII
1105 [spaces][zeros][x][hexadecimal digits].
1107 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1108 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1109 appears in the input string, it must be prefixed with at least one 0. The function
1110 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1111 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1112 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1113 digit. Then, the function stops at the first character that is a not a valid
1114 hexadecimal character or Null-terminator, whichever on comes first.
1116 If String has only pad spaces, then 0 is returned.
1117 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1120 If the number represented by String overflows according to the range defined by UINT64,
1122 If String is NULL, then ASSERT().
1123 If PcdMaximumAsciiStringLength is not zero,
1124 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1125 the Null-terminator, then ASSERT().
1127 @param String Pointer to a Null-terminated ASCII string.
1134 AsciiStrHexToUint64 (
1135 IN CONST CHAR8
*String
1139 Convert one Null-terminated ASCII string to a Null-terminated
1140 Unicode string and returns the Unicode string.
1142 This function converts the contents of the ASCII string Source to the Unicode
1143 string Destination, and returns Destination. The function terminates the
1144 Unicode string Destination by appending a Null-terminator character at the end.
1145 The caller is responsible to make sure Destination points to a buffer with size
1146 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
1148 If Destination is NULL, then ASSERT().
1149 If Destination is not aligned on a 16-bit boundary, then ASSERT().
1150 If Source is NULL, then ASSERT().
1151 If Source and Destination overlap, then ASSERT().
1152 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1153 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1155 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1156 PcdMaximumUnicodeStringLength ASCII characters not including the
1157 Null-terminator, then ASSERT().
1159 @param Source Pointer to a Null-terminated ASCII string.
1160 @param Destination Pointer to a Null-terminated Unicode string.
1167 AsciiStrToUnicodeStr (
1168 IN CONST CHAR8
*Source
,
1169 OUT CHAR16
*Destination
1173 Converts an 8-bit value to an 8-bit BCD value.
1175 Converts the 8-bit value specified by Value to BCD. The BCD value is
1178 If Value >= 100, then ASSERT().
1180 @param Value The 8-bit value to convert to BCD. Range 0..99.
1182 @return The BCD value
1192 Converts an 8-bit BCD value to an 8-bit value.
1194 Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit
1197 If Value >= 0xA0, then ASSERT().
1198 If (Value & 0x0F) >= 0x0A, then ASSERT().
1200 @param Value The 8-bit BCD value to convert to an 8-bit value.
1202 @return The 8-bit value is returned.
1212 // LIST_ENTRY definition
1214 typedef struct _LIST_ENTRY LIST_ENTRY
;
1216 struct _LIST_ENTRY
{
1217 LIST_ENTRY
*ForwardLink
;
1218 LIST_ENTRY
*BackLink
;
1222 // Linked List Functions and Macros
1226 Initializes the head node of a doubly linked list that is declared as a
1227 global variable in a module.
1229 Initializes the forward and backward links of a new linked list. After
1230 initializing a linked list with this macro, the other linked list functions
1231 may be used to add and remove nodes from the linked list. This macro results
1232 in smaller executables by initializing the linked list in the data section,
1233 instead if calling the InitializeListHead() function to perform the
1234 equivalent operation.
1236 @param ListHead The head note of a list to initiailize.
1239 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&ListHead, &ListHead}
1242 Initializes the head node of a doubly linked list, and returns the pointer to
1243 the head node of the doubly linked list.
1245 Initializes the forward and backward links of a new linked list. After
1246 initializing a linked list with this function, the other linked list
1247 functions may be used to add and remove nodes from the linked list. It is up
1248 to the caller of this function to allocate the memory for ListHead.
1250 If ListHead is NULL, then ASSERT().
1252 @param ListHead A pointer to the head node of a new doubly linked list.
1259 GlueInitializeListHead (
1260 IN LIST_ENTRY
*ListHead
1264 Adds a node to the beginning of a doubly linked list, and returns the pointer
1265 to the head node of the doubly linked list.
1267 Adds the node Entry at the beginning of the doubly linked list denoted by
1268 ListHead, and returns ListHead.
1270 If ListHead is NULL, then ASSERT().
1271 If Entry is NULL, then ASSERT().
1272 If ListHead was not initialized with InitializeListHead(), then ASSERT().
1273 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
1274 of nodes in ListHead, including the ListHead node, is greater than or
1275 equal to PcdMaximumLinkedListLength, then ASSERT().
1277 @param ListHead A pointer to the head node of a doubly linked list.
1278 @param Entry A pointer to a node that is to be inserted at the beginning
1279 of a doubly linked list.
1286 GlueInsertHeadList (
1287 IN LIST_ENTRY
*ListHead
,
1288 IN LIST_ENTRY
*Entry
1292 Adds a node to the end of a doubly linked list, and returns the pointer to
1293 the head node of the doubly linked list.
1295 Adds the node Entry to the end of the doubly linked list denoted by ListHead,
1296 and returns ListHead.
1298 If ListHead is NULL, then ASSERT().
1299 If Entry is NULL, then ASSERT().
1300 If ListHead was not initialized with InitializeListHead(), then ASSERT().
1301 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
1302 of nodes in ListHead, including the ListHead node, is greater than or
1303 equal to PcdMaximumLinkedListLength, then ASSERT().
1305 @param ListHead A pointer to the head node of a doubly linked list.
1306 @param Entry A pointer to a node that is to be added at the end of the
1314 GlueInsertTailList (
1315 IN LIST_ENTRY
*ListHead
,
1316 IN LIST_ENTRY
*Entry
1320 Retrieves the first node of a doubly linked list.
1322 Returns the first node of a doubly linked list. List must have been
1323 initialized with InitializeListHead(). If List is empty, then NULL is
1326 If List is NULL, then ASSERT().
1327 If List was not initialized with InitializeListHead(), then ASSERT().
1328 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1329 in List, including the List node, is greater than or equal to
1330 PcdMaximumLinkedListLength, then ASSERT().
1332 @param List A pointer to the head node of a doubly linked list.
1334 @return The first node of a doubly linked list.
1335 @retval NULL The list is empty.
1341 IN CONST LIST_ENTRY
*List
1345 Retrieves the next node of a doubly linked list.
1347 Returns the node of a doubly linked list that follows Node. List must have
1348 been initialized with InitializeListHead(). If List is empty, then List is
1351 If List is NULL, then ASSERT().
1352 If Node is NULL, then ASSERT().
1353 If List was not initialized with InitializeListHead(), then ASSERT().
1354 If PcdMaximumLinkedListLenth is not zero, and List contains more than
1355 PcdMaximumLinkedListLenth nodes, then ASSERT().
1356 If Node is not a node in List, then ASSERT().
1358 @param List A pointer to the head node of a doubly linked list.
1359 @param Node A pointer to a node in the doubly linked list.
1361 @return Pointer to the next node if one exists. Otherwise a null value which
1362 is actually List is returned.
1368 IN CONST LIST_ENTRY
*List
,
1369 IN CONST LIST_ENTRY
*Node
1373 Checks to see if a doubly linked list is empty or not.
1375 Checks to see if the doubly linked list is empty. If the linked list contains
1376 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
1378 If ListHead is NULL, then ASSERT().
1379 If ListHead was not initialized with InitializeListHead(), then ASSERT().
1380 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1381 in List, including the List node, is greater than or equal to
1382 PcdMaximumLinkedListLength, then ASSERT().
1384 @param ListHead A pointer to the head node of a doubly linked list.
1386 @retval TRUE The linked list is empty.
1387 @retval FALSE The linked list is not empty.
1393 IN CONST LIST_ENTRY
*ListHead
1397 Determines if a node in a doubly linked list is null.
1399 Returns FALSE if Node is one of the nodes in the doubly linked list specified
1400 by List. Otherwise, TRUE is returned. List must have been initialized with
1401 InitializeListHead().
1403 If List is NULL, then ASSERT().
1404 If Node is NULL, then ASSERT().
1405 If List was not initialized with InitializeListHead(), then ASSERT().
1406 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1407 in List, including the List node, is greater than or equal to
1408 PcdMaximumLinkedListLength, then ASSERT().
1409 If Node is not a node in List and Node is not equal to List, then ASSERT().
1411 @param List A pointer to the head node of a doubly linked list.
1412 @param Node A pointer to a node in the doubly linked list.
1414 @retval TRUE Node is one of the nodes in the doubly linked list.
1415 @retval FALSE Node is not one of the nodes in the doubly linked list.
1421 IN CONST LIST_ENTRY
*List
,
1422 IN CONST LIST_ENTRY
*Node
1426 Determines if a node the last node in a doubly linked list.
1428 Returns TRUE if Node is the last node in the doubly linked list specified by
1429 List. Otherwise, FALSE is returned. List must have been initialized with
1430 InitializeListHead().
1432 If List is NULL, then ASSERT().
1433 If Node is NULL, then ASSERT().
1434 If List was not initialized with InitializeListHead(), then ASSERT().
1435 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1436 in List, including the List node, is greater than or equal to
1437 PcdMaximumLinkedListLength, then ASSERT().
1438 If Node is not a node in List, then ASSERT().
1440 @param List A pointer to the head node of a doubly linked list.
1441 @param Node A pointer to a node in the doubly linked list.
1443 @retval TRUE Node is the last node in the linked list.
1444 @retval FALSE Node is not the last node in the linked list.
1450 IN CONST LIST_ENTRY
*List
,
1451 IN CONST LIST_ENTRY
*Node
1455 Swaps the location of two nodes in a doubly linked list, and returns the
1456 first node after the swap.
1458 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
1459 Otherwise, the location of the FirstEntry node is swapped with the location
1460 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
1461 same double linked list as FirstEntry and that double linked list must have
1462 been initialized with InitializeListHead(). SecondEntry is returned after the
1465 If FirstEntry is NULL, then ASSERT().
1466 If SecondEntry is NULL, then ASSERT().
1467 If SecondEntry and FirstEntry are not in the same linked list, then ASSERT().
1468 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1469 linked list containing the FirstEntry and SecondEntry nodes, including
1470 the FirstEntry and SecondEntry nodes, is greater than or equal to
1471 PcdMaximumLinkedListLength, then ASSERT().
1473 @param FirstEntry A pointer to a node in a linked list.
1474 @param SecondEntry A pointer to another node in the same linked list.
1479 GlueSwapListEntries (
1480 IN LIST_ENTRY
*FirstEntry
,
1481 IN LIST_ENTRY
*SecondEntry
1485 Removes a node from a doubly linked list, and returns the node that follows
1488 Removes the node Entry from a doubly linked list. It is up to the caller of
1489 this function to release the memory used by this node if that is required. On
1490 exit, the node following Entry in the doubly linked list is returned. If
1491 Entry is the only node in the linked list, then the head node of the linked
1494 If Entry is NULL, then ASSERT().
1495 If Entry is the head node of an empty list, then ASSERT().
1496 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1497 linked list containing Entry, including the Entry node, is greater than
1498 or equal to PcdMaximumLinkedListLength, then ASSERT().
1500 @param Entry A pointer to a node in a linked list
1507 GlueRemoveEntryList (
1508 IN CONST LIST_ENTRY
*Entry
1516 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
1517 with zeros. The shifted value is returned.
1519 This function shifts the 64-bit value Operand to the left by Count bits. The
1520 low Count bits are set to zero. The shifted value is returned.
1522 If Count is greater than 63, then ASSERT().
1524 @param Operand The 64-bit operand to shift left.
1525 @param Count The number of bits to shift left.
1527 @return Operand << Count
1538 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
1539 filled with zeros. The shifted value is returned.
1541 This function shifts the 64-bit value Operand to the right by Count bits. The
1542 high Count bits are set to zero. The shifted value is returned.
1544 If Count is greater than 63, then ASSERT().
1546 @param Operand The 64-bit operand to shift right.
1547 @param Count The number of bits to shift right.
1549 @return Operand >> Count
1560 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
1561 with original integer's bit 63. The shifted value is returned.
1563 This function shifts the 64-bit value Operand to the right by Count bits. The
1564 high Count bits are set to bit 63 of Operand. The shifted value is returned.
1566 If Count is greater than 63, then ASSERT().
1568 @param Operand The 64-bit operand to shift right.
1569 @param Count The number of bits to shift right.
1571 @return Operand >> Count
1582 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
1583 with the high bits that were rotated.
1585 This function rotates the 32-bit value Operand to the left by Count bits. The
1586 low Count bits are fill with the high Count bits of Operand. The rotated
1589 If Count is greater than 31, then ASSERT().
1591 @param Operand The 32-bit operand to rotate left.
1592 @param Count The number of bits to rotate left.
1594 @return Operand <<< Count
1605 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
1606 with the low bits that were rotated.
1608 This function rotates the 32-bit value Operand to the right by Count bits.
1609 The high Count bits are fill with the low Count bits of Operand. The rotated
1612 If Count is greater than 31, then ASSERT().
1614 @param Operand The 32-bit operand to rotate right.
1615 @param Count The number of bits to rotate right.
1617 @return Operand >>> Count
1628 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
1629 with the high bits that were rotated.
1631 This function rotates the 64-bit value Operand to the left by Count bits. The
1632 low Count bits are fill with the high Count bits of Operand. The rotated
1635 If Count is greater than 63, then ASSERT().
1637 @param Operand The 64-bit operand to rotate left.
1638 @param Count The number of bits to rotate left.
1640 @return Operand <<< Count
1651 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
1652 with the high low bits that were rotated.
1654 This function rotates the 64-bit value Operand to the right by Count bits.
1655 The high Count bits are fill with the low Count bits of Operand. The rotated
1658 If Count is greater than 63, then ASSERT().
1660 @param Operand The 64-bit operand to rotate right.
1661 @param Count The number of bits to rotate right.
1663 @return Operand >>> Count
1674 Returns the bit position of the lowest bit set in a 32-bit value.
1676 This function computes the bit position of the lowest bit set in the 32-bit
1677 value specified by Operand. If Operand is zero, then -1 is returned.
1678 Otherwise, a value between 0 and 31 is returned.
1680 @param Operand The 32-bit operand to evaluate.
1682 @return Position of the lowest bit set in Operand if found.
1683 @retval -1 Operand is zero.
1693 Returns the bit position of the lowest bit set in a 64-bit value.
1695 This function computes the bit position of the lowest bit set in the 64-bit
1696 value specified by Operand. If Operand is zero, then -1 is returned.
1697 Otherwise, a value between 0 and 63 is returned.
1699 @param Operand The 64-bit operand to evaluate.
1701 @return Position of the lowest bit set in Operand if found.
1702 @retval -1 Operand is zero.
1712 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
1715 This function computes the bit position of the highest bit set in the 32-bit
1716 value specified by Operand. If Operand is zero, then -1 is returned.
1717 Otherwise, a value between 0 and 31 is returned.
1719 @param Operand The 32-bit operand to evaluate.
1721 @return Position of the highest bit set in Operand if found.
1722 @retval -1 Operand is zero.
1732 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
1735 This function computes the bit position of the highest bit set in the 64-bit
1736 value specified by Operand. If Operand is zero, then -1 is returned.
1737 Otherwise, a value between 0 and 63 is returned.
1739 @param Operand The 64-bit operand to evaluate.
1741 @return Position of the highest bit set in Operand if found.
1742 @retval -1 Operand is zero.
1752 Returns the value of the highest bit set in a 32-bit value. Equivalent to
1753 1 << HighBitSet32(x).
1755 This function computes the value of the highest bit set in the 32-bit value
1756 specified by Operand. If Operand is zero, then zero is returned.
1758 @param Operand The 32-bit operand to evaluate.
1760 @return 1 << HighBitSet32(Operand)
1761 @retval 0 Operand is zero.
1771 Returns the value of the highest bit set in a 64-bit value. Equivalent to
1772 1 << HighBitSet64(x).
1774 This function computes the value of the highest bit set in the 64-bit value
1775 specified by Operand. If Operand is zero, then zero is returned.
1777 @param Operand The 64-bit operand to evaluate.
1779 @return 1 << HighBitSet64(Operand)
1780 @retval 0 Operand is zero.
1790 Switches the endianess of a 16-bit integer.
1792 This function swaps the bytes in a 16-bit unsigned value to switch the value
1793 from little endian to big endian or vice versa. The byte swapped value is
1796 @param Operand A 16-bit unsigned value.
1798 @return The byte swaped Operand.
1808 Switches the endianess of a 32-bit integer.
1810 This function swaps the bytes in a 32-bit unsigned value to switch the value
1811 from little endian to big endian or vice versa. The byte swapped value is
1814 @param Operand A 32-bit unsigned value.
1816 @return The byte swaped Operand.
1826 Switches the endianess of a 64-bit integer.
1828 This function swaps the bytes in a 64-bit unsigned value to switch the value
1829 from little endian to big endian or vice versa. The byte swapped value is
1832 @param Operand A 64-bit unsigned value.
1834 @return The byte swaped Operand.
1844 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
1845 generates a 64-bit unsigned result.
1847 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
1848 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1849 bit unsigned result is returned.
1851 If the result overflows, then ASSERT().
1853 @param Multiplicand A 64-bit unsigned value.
1854 @param Multiplier A 32-bit unsigned value.
1856 @return Multiplicand * Multiplier
1862 IN UINT64 Multiplicand
,
1863 IN UINT32 Multiplier
1867 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
1868 generates a 64-bit unsigned result.
1870 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
1871 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1872 bit unsigned result is returned.
1874 If the result overflows, then ASSERT().
1876 @param Multiplicand A 64-bit unsigned value.
1877 @param Multiplier A 64-bit unsigned value.
1879 @return Multiplicand * Multiplier
1885 IN UINT64 Multiplicand
,
1886 IN UINT64 Multiplier
1890 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
1891 64-bit signed result.
1893 This function multiples the 64-bit signed value Multiplicand by the 64-bit
1894 signed value Multiplier and generates a 64-bit signed result. This 64-bit
1895 signed result is returned.
1897 If the result overflows, then ASSERT().
1899 @param Multiplicand A 64-bit signed value.
1900 @param Multiplier A 64-bit signed value.
1902 @return Multiplicand * Multiplier
1908 IN INT64 Multiplicand
,
1913 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1914 a 64-bit unsigned result.
1916 This function divides the 64-bit unsigned value Dividend by the 32-bit
1917 unsigned value Divisor and generates a 64-bit unsigned quotient. This
1918 function returns the 64-bit unsigned quotient.
1920 If Divisor is 0, then ASSERT().
1922 @param Dividend A 64-bit unsigned value.
1923 @param Divisor A 32-bit unsigned value.
1925 @return Dividend / Divisor
1936 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1937 a 32-bit unsigned remainder.
1939 This function divides the 64-bit unsigned value Dividend by the 32-bit
1940 unsigned value Divisor and generates a 32-bit remainder. This function
1941 returns the 32-bit unsigned remainder.
1943 If Divisor is 0, then ASSERT().
1945 @param Dividend A 64-bit unsigned value.
1946 @param Divisor A 32-bit unsigned value.
1948 @return Dividend % Divisor
1959 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1960 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
1962 This function divides the 64-bit unsigned value Dividend by the 32-bit
1963 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
1964 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
1965 This function returns the 64-bit unsigned quotient.
1967 If Divisor is 0, then ASSERT().
1969 @param Dividend A 64-bit unsigned value.
1970 @param Divisor A 32-bit unsigned value.
1971 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
1972 optional and may be NULL.
1974 @return Dividend / Divisor
1979 DivU64x32Remainder (
1982 OUT UINT32
*Remainder OPTIONAL
1986 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
1987 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
1989 This function divides the 64-bit unsigned value Dividend by the 64-bit
1990 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
1991 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
1992 This function returns the 64-bit unsigned quotient.
1994 If Divisor is 0, then ASSERT().
1996 @param Dividend A 64-bit unsigned value.
1997 @param Divisor A 64-bit unsigned value.
1998 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
1999 optional and may be NULL.
2001 @return Dividend / Divisor
2006 DivU64x64Remainder (
2009 OUT UINT64
*Remainder OPTIONAL
2013 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
2014 64-bit signed result and a optional 64-bit signed remainder.
2016 This function divides the 64-bit signed value Dividend by the 64-bit signed
2017 value Divisor and generates a 64-bit signed quotient. If Remainder is not
2018 NULL, then the 64-bit signed remainder is returned in Remainder. This
2019 function returns the 64-bit signed quotient.
2021 If Divisor is 0, then ASSERT().
2023 @param Dividend A 64-bit signed value.
2024 @param Divisor A 64-bit signed value.
2025 @param Remainder A pointer to a 64-bit signed value. This parameter is
2026 optional and may be NULL.
2028 @return Dividend / Divisor
2033 DivS64x64Remainder (
2036 OUT INT64
*Remainder OPTIONAL
2040 Reads a 16-bit value from memory that may be unaligned.
2042 This function returns the 16-bit value pointed to by Buffer. The function
2043 guarantees that the read operation does not produce an alignment fault.
2045 If the Buffer is NULL, then ASSERT().
2047 @param Buffer Pointer to a 16-bit value that may be unaligned.
2055 IN CONST UINT16
*Uint16
2059 Writes a 16-bit value to memory that may be unaligned.
2061 This function writes the 16-bit value specified by Value to Buffer. Value is
2062 returned. The function guarantees that the write operation does not produce
2065 If the Buffer is NULL, then ASSERT().
2067 @param Buffer Pointer to a 16-bit value that may be unaligned.
2068 @param Value 16-bit value to write to Buffer.
2081 Reads a 24-bit value from memory that may be unaligned.
2083 This function returns the 24-bit value pointed to by Buffer. The function
2084 guarantees that the read operation does not produce an alignment fault.
2086 If the Buffer is NULL, then ASSERT().
2088 @param Buffer Pointer to a 24-bit value that may be unaligned.
2090 @return The value read.
2096 IN CONST UINT32
*Buffer
2100 Writes a 24-bit value to memory that may be unaligned.
2102 This function writes the 24-bit value specified by Value to Buffer. Value is
2103 returned. The function guarantees that the write operation does not produce
2106 If the Buffer is NULL, then ASSERT().
2108 @param Buffer Pointer to a 24-bit value that may be unaligned.
2109 @param Value 24-bit value to write to Buffer.
2111 @return The value written.
2122 Reads a 32-bit value from memory that may be unaligned.
2124 This function returns the 32-bit value pointed to by Buffer. The function
2125 guarantees that the read operation does not produce an alignment fault.
2127 If the Buffer is NULL, then ASSERT().
2129 @param Buffer Pointer to a 32-bit value that may be unaligned.
2137 IN CONST UINT32
*Uint32
2141 Writes a 32-bit value to memory that may be unaligned.
2143 This function writes the 32-bit value specified by Value to Buffer. Value is
2144 returned. The function guarantees that the write operation does not produce
2147 If the Buffer is NULL, then ASSERT().
2149 @param Buffer Pointer to a 32-bit value that may be unaligned.
2150 @param Value 32-bit value to write to Buffer.
2163 Reads a 64-bit value from memory that may be unaligned.
2165 This function returns the 64-bit value pointed to by Buffer. The function
2166 guarantees that the read operation does not produce an alignment fault.
2168 If the Buffer is NULL, then ASSERT().
2170 @param Buffer Pointer to a 64-bit value that may be unaligned.
2178 IN CONST UINT64
*Uint64
2182 Writes a 64-bit value to memory that may be unaligned.
2184 This function writes the 64-bit value specified by Value to Buffer. Value is
2185 returned. The function guarantees that the write operation does not produce
2188 If the Buffer is NULL, then ASSERT().
2190 @param Buffer Pointer to a 64-bit value that may be unaligned.
2191 @param Value 64-bit value to write to Buffer.
2204 // Bit Field Functions
2208 Returns a bit field from an 8-bit value.
2210 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2212 If 8-bit operations are not supported, then ASSERT().
2213 If StartBit is greater than 7, then ASSERT().
2214 If EndBit is greater than 7, then ASSERT().
2215 If EndBit is less than StartBit, then ASSERT().
2217 @param Operand Operand on which to perform the bitfield operation.
2218 @param StartBit The ordinal of the least significant bit in the bit field.
2220 @param EndBit The ordinal of the most significant bit in the bit field.
2223 @return The bit field read.
2235 Writes a bit field to an 8-bit value, and returns the result.
2237 Writes Value to the bit field specified by the StartBit and the EndBit in
2238 Operand. All other bits in Operand are preserved. The new 8-bit value is
2241 If 8-bit operations are not supported, then ASSERT().
2242 If StartBit is greater than 7, then ASSERT().
2243 If EndBit is greater than 7, then ASSERT().
2244 If EndBit is less than StartBit, then ASSERT().
2246 @param Operand Operand on which to perform the bitfield operation.
2247 @param StartBit The ordinal of the least significant bit in the bit field.
2249 @param EndBit The ordinal of the most significant bit in the bit field.
2251 @param Value New value of the bit field.
2253 @return The new 8-bit value.
2266 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
2269 Performs a bitwise inclusive OR between the bit field specified by StartBit
2270 and EndBit in Operand and the value specified by OrData. All other bits in
2271 Operand are preserved. The new 8-bit value is returned.
2273 If 8-bit operations are not supported, then ASSERT().
2274 If StartBit is greater than 7, then ASSERT().
2275 If EndBit is greater than 7, then ASSERT().
2276 If EndBit is less than StartBit, then ASSERT().
2278 @param Operand Operand on which to perform the bitfield operation.
2279 @param StartBit The ordinal of the least significant bit in the bit field.
2281 @param EndBit The ordinal of the most significant bit in the bit field.
2283 @param OrData The value to OR with the read value from the value
2285 @return The new 8-bit value.
2298 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
2301 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2302 in Operand and the value specified by AndData. All other bits in Operand are
2303 preserved. The new 8-bit value is returned.
2305 If 8-bit operations are not supported, then ASSERT().
2306 If StartBit is greater than 7, then ASSERT().
2307 If EndBit is greater than 7, then ASSERT().
2308 If EndBit is less than StartBit, then ASSERT().
2310 @param Operand Operand on which to perform the bitfield operation.
2311 @param StartBit The ordinal of the least significant bit in the bit field.
2313 @param EndBit The ordinal of the most significant bit in the bit field.
2315 @param AndData The value to AND with the read value from the value.
2317 @return The new 8-bit value.
2330 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
2331 bitwise OR, and returns the result.
2333 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2334 in Operand and the value specified by AndData, followed by a bitwise
2335 inclusive OR with value specified by OrData. All other bits in Operand are
2336 preserved. The new 8-bit value is returned.
2338 If 8-bit operations are not supported, then ASSERT().
2339 If StartBit is greater than 7, then ASSERT().
2340 If EndBit is greater than 7, then ASSERT().
2341 If EndBit is less than StartBit, then ASSERT().
2343 @param Operand Operand on which to perform the bitfield operation.
2344 @param StartBit The ordinal of the least significant bit in the bit field.
2346 @param EndBit The ordinal of the most significant bit in the bit field.
2348 @param AndData The value to AND with the read value from the value.
2349 @param OrData The value to OR with the result of the AND operation.
2351 @return The new 8-bit value.
2356 BitFieldAndThenOr8 (
2365 Returns a bit field from a 16-bit value.
2367 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2369 If 16-bit operations are not supported, then ASSERT().
2370 If StartBit is greater than 15, then ASSERT().
2371 If EndBit is greater than 15, then ASSERT().
2372 If EndBit is less than StartBit, then ASSERT().
2374 @param Operand Operand on which to perform the bitfield operation.
2375 @param StartBit The ordinal of the least significant bit in the bit field.
2377 @param EndBit The ordinal of the most significant bit in the bit field.
2380 @return The bit field read.
2392 Writes a bit field to a 16-bit value, and returns the result.
2394 Writes Value to the bit field specified by the StartBit and the EndBit in
2395 Operand. All other bits in Operand are preserved. The new 16-bit value is
2398 If 16-bit operations are not supported, then ASSERT().
2399 If StartBit is greater than 15, then ASSERT().
2400 If EndBit is greater than 15, then ASSERT().
2401 If EndBit is less than StartBit, then ASSERT().
2403 @param Operand Operand on which to perform the bitfield operation.
2404 @param StartBit The ordinal of the least significant bit in the bit field.
2406 @param EndBit The ordinal of the most significant bit in the bit field.
2408 @param Value New value of the bit field.
2410 @return The new 16-bit value.
2423 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
2426 Performs a bitwise inclusive OR between the bit field specified by StartBit
2427 and EndBit in Operand and the value specified by OrData. All other bits in
2428 Operand are preserved. The new 16-bit value is returned.
2430 If 16-bit operations are not supported, then ASSERT().
2431 If StartBit is greater than 15, then ASSERT().
2432 If EndBit is greater than 15, then ASSERT().
2433 If EndBit is less than StartBit, then ASSERT().
2435 @param Operand Operand on which to perform the bitfield operation.
2436 @param StartBit The ordinal of the least significant bit in the bit field.
2438 @param EndBit The ordinal of the most significant bit in the bit field.
2440 @param OrData The value to OR with the read value from the value
2442 @return The new 16-bit value.
2455 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
2458 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2459 in Operand and the value specified by AndData. All other bits in Operand are
2460 preserved. The new 16-bit value is returned.
2462 If 16-bit operations are not supported, then ASSERT().
2463 If StartBit is greater than 15, then ASSERT().
2464 If EndBit is greater than 15, then ASSERT().
2465 If EndBit is less than StartBit, then ASSERT().
2467 @param Operand Operand on which to perform the bitfield operation.
2468 @param StartBit The ordinal of the least significant bit in the bit field.
2470 @param EndBit The ordinal of the most significant bit in the bit field.
2472 @param AndData The value to AND with the read value from the value
2474 @return The new 16-bit value.
2487 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
2488 bitwise OR, and returns the result.
2490 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2491 in Operand and the value specified by AndData, followed by a bitwise
2492 inclusive OR with value specified by OrData. All other bits in Operand are
2493 preserved. The new 16-bit value is returned.
2495 If 16-bit operations are not supported, then ASSERT().
2496 If StartBit is greater than 15, then ASSERT().
2497 If EndBit is greater than 15, then ASSERT().
2498 If EndBit is less than StartBit, then ASSERT().
2500 @param Operand Operand on which to perform the bitfield operation.
2501 @param StartBit The ordinal of the least significant bit in the bit field.
2503 @param EndBit The ordinal of the most significant bit in the bit field.
2505 @param AndData The value to AND with the read value from the value.
2506 @param OrData The value to OR with the result of the AND operation.
2508 @return The new 16-bit value.
2513 BitFieldAndThenOr16 (
2522 Returns a bit field from a 32-bit value.
2524 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2526 If 32-bit operations are not supported, then ASSERT().
2527 If StartBit is greater than 31, then ASSERT().
2528 If EndBit is greater than 31, then ASSERT().
2529 If EndBit is less than StartBit, then ASSERT().
2531 @param Operand Operand on which to perform the bitfield operation.
2532 @param StartBit The ordinal of the least significant bit in the bit field.
2534 @param EndBit The ordinal of the most significant bit in the bit field.
2537 @return The bit field read.
2549 Writes a bit field to a 32-bit value, and returns the result.
2551 Writes Value to the bit field specified by the StartBit and the EndBit in
2552 Operand. All other bits in Operand are preserved. The new 32-bit value is
2555 If 32-bit operations are not supported, then ASSERT().
2556 If StartBit is greater than 31, then ASSERT().
2557 If EndBit is greater than 31, then ASSERT().
2558 If EndBit is less than StartBit, then ASSERT().
2560 @param Operand Operand on which to perform the bitfield operation.
2561 @param StartBit The ordinal of the least significant bit in the bit field.
2563 @param EndBit The ordinal of the most significant bit in the bit field.
2565 @param Value New value of the bit field.
2567 @return The new 32-bit value.
2580 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
2583 Performs a bitwise inclusive OR between the bit field specified by StartBit
2584 and EndBit in Operand and the value specified by OrData. All other bits in
2585 Operand are preserved. The new 32-bit value is returned.
2587 If 32-bit operations are not supported, then ASSERT().
2588 If StartBit is greater than 31, then ASSERT().
2589 If EndBit is greater than 31, then ASSERT().
2590 If EndBit is less than StartBit, then ASSERT().
2592 @param Operand Operand on which to perform the bitfield operation.
2593 @param StartBit The ordinal of the least significant bit in the bit field.
2595 @param EndBit The ordinal of the most significant bit in the bit field.
2597 @param OrData The value to OR with the read value from the value
2599 @return The new 32-bit value.
2612 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
2615 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2616 in Operand and the value specified by AndData. All other bits in Operand are
2617 preserved. The new 32-bit value is returned.
2619 If 32-bit operations are not supported, then ASSERT().
2620 If StartBit is greater than 31, then ASSERT().
2621 If EndBit is greater than 31, then ASSERT().
2622 If EndBit is less than StartBit, then ASSERT().
2624 @param Operand Operand on which to perform the bitfield operation.
2625 @param StartBit The ordinal of the least significant bit in the bit field.
2627 @param EndBit The ordinal of the most significant bit in the bit field.
2629 @param AndData The value to AND with the read value from the value
2631 @return The new 32-bit value.
2644 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
2645 bitwise OR, and returns the result.
2647 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2648 in Operand and the value specified by AndData, followed by a bitwise
2649 inclusive OR with value specified by OrData. All other bits in Operand are
2650 preserved. The new 32-bit value is returned.
2652 If 32-bit operations are not supported, then ASSERT().
2653 If StartBit is greater than 31, then ASSERT().
2654 If EndBit is greater than 31, then ASSERT().
2655 If EndBit is less than StartBit, then ASSERT().
2657 @param Operand Operand on which to perform the bitfield operation.
2658 @param StartBit The ordinal of the least significant bit in the bit field.
2660 @param EndBit The ordinal of the most significant bit in the bit field.
2662 @param AndData The value to AND with the read value from the value.
2663 @param OrData The value to OR with the result of the AND operation.
2665 @return The new 32-bit value.
2670 BitFieldAndThenOr32 (
2679 Returns a bit field from a 64-bit value.
2681 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2683 If 64-bit operations are not supported, then ASSERT().
2684 If StartBit is greater than 63, then ASSERT().
2685 If EndBit is greater than 63, then ASSERT().
2686 If EndBit is less than StartBit, then ASSERT().
2688 @param Operand Operand on which to perform the bitfield operation.
2689 @param StartBit The ordinal of the least significant bit in the bit field.
2691 @param EndBit The ordinal of the most significant bit in the bit field.
2694 @return The bit field read.
2706 Writes a bit field to a 64-bit value, and returns the result.
2708 Writes Value to the bit field specified by the StartBit and the EndBit in
2709 Operand. All other bits in Operand are preserved. The new 64-bit value is
2712 If 64-bit operations are not supported, then ASSERT().
2713 If StartBit is greater than 63, then ASSERT().
2714 If EndBit is greater than 63, then ASSERT().
2715 If EndBit is less than StartBit, then ASSERT().
2717 @param Operand Operand on which to perform the bitfield operation.
2718 @param StartBit The ordinal of the least significant bit in the bit field.
2720 @param EndBit The ordinal of the most significant bit in the bit field.
2722 @param Value New value of the bit field.
2724 @return The new 64-bit value.
2737 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
2740 Performs a bitwise inclusive OR between the bit field specified by StartBit
2741 and EndBit in Operand and the value specified by OrData. All other bits in
2742 Operand are preserved. The new 64-bit value is returned.
2744 If 64-bit operations are not supported, then ASSERT().
2745 If StartBit is greater than 63, then ASSERT().
2746 If EndBit is greater than 63, then ASSERT().
2747 If EndBit is less than StartBit, then ASSERT().
2749 @param Operand Operand on which to perform the bitfield operation.
2750 @param StartBit The ordinal of the least significant bit in the bit field.
2752 @param EndBit The ordinal of the most significant bit in the bit field.
2754 @param OrData The value to OR with the read value from the value
2756 @return The new 64-bit value.
2769 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
2772 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2773 in Operand and the value specified by AndData. All other bits in Operand are
2774 preserved. The new 64-bit value is returned.
2776 If 64-bit operations are not supported, then ASSERT().
2777 If StartBit is greater than 63, then ASSERT().
2778 If EndBit is greater than 63, then ASSERT().
2779 If EndBit is less than StartBit, then ASSERT().
2781 @param Operand Operand on which to perform the bitfield operation.
2782 @param StartBit The ordinal of the least significant bit in the bit field.
2784 @param EndBit The ordinal of the most significant bit in the bit field.
2786 @param AndData The value to AND with the read value from the value
2788 @return The new 64-bit value.
2801 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
2802 bitwise OR, and returns the result.
2804 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2805 in Operand and the value specified by AndData, followed by a bitwise
2806 inclusive OR with value specified by OrData. All other bits in Operand are
2807 preserved. The new 64-bit value is returned.
2809 If 64-bit operations are not supported, then ASSERT().
2810 If StartBit is greater than 63, then ASSERT().
2811 If EndBit is greater than 63, then ASSERT().
2812 If EndBit is less than StartBit, then ASSERT().
2814 @param Operand Operand on which to perform the bitfield operation.
2815 @param StartBit The ordinal of the least significant bit in the bit field.
2817 @param EndBit The ordinal of the most significant bit in the bit field.
2819 @param AndData The value to AND with the read value from the value.
2820 @param OrData The value to OR with the result of the AND operation.
2822 @return The new 64-bit value.
2827 BitFieldAndThenOr64 (
2836 // Base Library Synchronization Functions
2840 Retrieves the architecture specific spin lock alignment requirements for
2841 optimal spin lock performance.
2843 This function retrieves the spin lock alignment requirements for optimal
2844 performance on a given CPU architecture. The spin lock alignment must be a
2845 power of two and is returned by this function. If there are no alignment
2846 requirements, then 1 must be returned. The spin lock synchronization
2847 functions must function correctly if the spin lock size and alignment values
2848 returned by this function are not used at all. These values are hints to the
2849 consumers of the spin lock synchronization functions to obtain optimal spin
2852 @return The architecture specific spin lock alignment.
2857 GetSpinLockProperties (
2862 Initializes a spin lock to the released state and returns the spin lock.
2864 This function initializes the spin lock specified by SpinLock to the released
2865 state, and returns SpinLock. Optimal performance can be achieved by calling
2866 GetSpinLockProperties() to determine the size and alignment requirements for
2869 If SpinLock is NULL, then ASSERT().
2871 @param SpinLock A pointer to the spin lock to initialize to the released
2879 InitializeSpinLock (
2880 IN SPIN_LOCK
*SpinLock
2884 Waits until a spin lock can be placed in the acquired state.
2886 This function checks the state of the spin lock specified by SpinLock. If
2887 SpinLock is in the released state, then this function places SpinLock in the
2888 acquired state and returns SpinLock. Otherwise, this function waits
2889 indefinitely for the spin lock to be released, and then places it in the
2890 acquired state and returns SpinLock. All state transitions of SpinLock must
2891 be performed using MP safe mechanisms.
2893 If SpinLock is NULL, then ASSERT().
2894 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
2895 If PcdSpinLockTimeout is not zero, and SpinLock is can not be acquired in
2896 PcdSpinLockTimeout microseconds, then ASSERT().
2898 @param SpinLock A pointer to the spin lock to place in the acquired state.
2906 IN SPIN_LOCK
*SpinLock
2910 Attempts to place a spin lock in the acquired state.
2912 This function checks the state of the spin lock specified by SpinLock. If
2913 SpinLock is in the released state, then this function places SpinLock in the
2914 acquired state and returns TRUE. Otherwise, FALSE is returned. All state
2915 transitions of SpinLock must be performed using MP safe mechanisms.
2917 If SpinLock is NULL, then ASSERT().
2918 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
2920 @param SpinLock A pointer to the spin lock to place in the acquired state.
2922 @retval TRUE SpinLock was placed in the acquired state.
2923 @retval FALSE SpinLock could not be acquired.
2928 AcquireSpinLockOrFail (
2929 IN SPIN_LOCK
*SpinLock
2933 Releases a spin lock.
2935 This function places the spin lock specified by SpinLock in the release state
2936 and returns SpinLock.
2938 If SpinLock is NULL, then ASSERT().
2939 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
2941 @param SpinLock A pointer to the spin lock to release.
2949 IN SPIN_LOCK
*SpinLock
2953 Performs an atomic increment of an 32-bit unsigned integer.
2955 Performs an atomic increment of the 32-bit unsigned integer specified by
2956 Value and returns the incremented value. The increment operation must be
2957 performed using MP safe mechanisms. The state of the return value is not
2958 guaranteed to be MP safe.
2960 If Value is NULL, then ASSERT().
2962 @param Value A pointer to the 32-bit value to increment.
2964 @return The incremented value.
2969 InterlockedIncrement (
2974 Performs an atomic decrement of an 32-bit unsigned integer.
2976 Performs an atomic decrement of the 32-bit unsigned integer specified by
2977 Value and returns the decremented value. The decrement operation must be
2978 performed using MP safe mechanisms. The state of the return value is not
2979 guaranteed to be MP safe.
2981 If Value is NULL, then ASSERT().
2983 @param Value A pointer to the 32-bit value to decrement.
2985 @return The decremented value.
2990 InterlockedDecrement (
2995 Performs an atomic compare exchange operation on a 32-bit unsigned integer.
2997 Performs an atomic compare exchange operation on the 32-bit unsigned integer
2998 specified by Value. If Value is equal to CompareValue, then Value is set to
2999 ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,
3000 then Value is returned. The compare exchange operation must be performed using
3003 If Value is NULL, then ASSERT().
3005 @param Value A pointer to the 32-bit value for the compare exchange
3007 @param CompareValue 32-bit value used in compare operation.
3008 @param ExchangeValue 32-bit value used in exchange operation.
3010 @return The original *Value before exchange.
3015 InterlockedCompareExchange32 (
3016 IN OUT UINT32
*Value
,
3017 IN UINT32 CompareValue
,
3018 IN UINT32 ExchangeValue
3022 Performs an atomic compare exchange operation on a 64-bit unsigned integer.
3024 Performs an atomic compare exchange operation on the 64-bit unsigned integer specified
3025 by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and
3026 CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.
3027 The compare exchange operation must be performed using MP safe mechanisms.
3029 If Value is NULL, then ASSERT().
3031 @param Value A pointer to the 64-bit value for the compare exchange
3033 @param CompareValue 64-bit value used in compare operation.
3034 @param ExchangeValue 64-bit value used in exchange operation.
3036 @return The original *Value before exchange.
3041 InterlockedCompareExchange64 (
3042 IN OUT UINT64
*Value
,
3043 IN UINT64 CompareValue
,
3044 IN UINT64 ExchangeValue
3048 Performs an atomic compare exchange operation on a pointer value.
3050 Performs an atomic compare exchange operation on the pointer value specified
3051 by Value. If Value is equal to CompareValue, then Value is set to
3052 ExchangeValue and CompareValue is returned. If Value is not equal to
3053 CompareValue, then Value is returned. The compare exchange operation must be
3054 performed using MP safe mechanisms.
3056 If Value is NULL, then ASSERT().
3058 @param Value A pointer to the pointer value for the compare exchange
3060 @param CompareValue Pointer value used in compare operation.
3061 @param ExchangeValue Pointer value used in exchange operation.
3066 InterlockedCompareExchangePointer (
3067 IN OUT VOID
**Value
,
3068 IN VOID
*CompareValue
,
3069 IN VOID
*ExchangeValue
3073 // Base Library Checksum Functions
3077 Calculate the sum of all elements in a buffer in unit of UINT8.
3078 During calculation, the carry bits are dropped.
3080 This function calculates the sum of all elements in a buffer
3081 in unit of UINT8. The carry bits in result of addition are dropped.
3082 The result is returned as UINT8. If Length is Zero, then Zero is
3085 If Buffer is NULL, then ASSERT().
3086 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3088 @param Buffer Pointer to the buffer to carry out the sum operation.
3089 @param Length The size, in bytes, of Buffer .
3091 @return Sum The sum of Buffer with carry bits dropped during additions.
3097 IN CONST UINT8
*Buffer
,
3103 Returns the two's complement checksum of all elements in a buffer
3106 This function first calculates the sum of the 8-bit values in the
3107 buffer specified by Buffer and Length. The carry bits in the result
3108 of addition are dropped. Then, the two's complement of the sum is
3109 returned. If Length is 0, then 0 is returned.
3111 If Buffer is NULL, then ASSERT().
3112 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3115 @param Buffer Pointer to the buffer to carry out the checksum operation.
3116 @param Length The size, in bytes, of Buffer.
3118 @return Checksum The 2's complement checksum of Buffer.
3123 CalculateCheckSum8 (
3124 IN CONST UINT8
*Buffer
,
3129 Returns the sum of all elements in a buffer of 16-bit values. During
3130 calculation, the carry bits are dropped.
3132 This function calculates the sum of the 16-bit values in the buffer
3133 specified by Buffer and Length. The carry bits in result of addition are dropped.
3134 The 16-bit result is returned. If Length is 0, then 0 is returned.
3136 If Buffer is NULL, then ASSERT().
3137 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3138 If Length is not aligned on a 16-bit boundary, then ASSERT().
3139 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3141 @param Buffer Pointer to the buffer to carry out the sum operation.
3142 @param Length The size, in bytes, of Buffer.
3144 @return Sum The sum of Buffer with carry bits dropped during additions.
3150 IN CONST UINT16
*Buffer
,
3155 Returns the two's complement checksum of all elements in a buffer of
3158 This function first calculates the sum of the 16-bit values in the buffer
3159 specified by Buffer and Length. The carry bits in the result of addition
3160 are dropped. Then, the two's complement of the sum is returned. If Length
3161 is 0, then 0 is returned.
3163 If Buffer is NULL, then ASSERT().
3164 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3165 If Length is not aligned on a 16-bit boundary, then ASSERT().
3166 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3168 @param Buffer Pointer to the buffer to carry out the checksum operation.
3169 @param Length The size, in bytes, of Buffer.
3171 @return Checksum The 2's complement checksum of Buffer.
3176 CalculateCheckSum16 (
3177 IN CONST UINT16
*Buffer
,
3182 Returns the sum of all elements in a buffer of 32-bit values. During
3183 calculation, the carry bits are dropped.
3185 This function calculates the sum of the 32-bit values in the buffer
3186 specified by Buffer and Length. The carry bits in result of addition are dropped.
3187 The 32-bit result is returned. If Length is 0, then 0 is returned.
3189 If Buffer is NULL, then ASSERT().
3190 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3191 If Length is not aligned on a 32-bit boundary, then ASSERT().
3192 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3194 @param Buffer Pointer to the buffer to carry out the sum operation.
3195 @param Length The size, in bytes, of Buffer.
3197 @return Sum The sum of Buffer with carry bits dropped during additions.
3203 IN CONST UINT32
*Buffer
,
3208 Returns the two's complement checksum of all elements in a buffer of
3211 This function first calculates the sum of the 32-bit values in the buffer
3212 specified by Buffer and Length. The carry bits in the result of addition
3213 are dropped. Then, the two's complement of the sum is returned. If Length
3214 is 0, then 0 is returned.
3216 If Buffer is NULL, then ASSERT().
3217 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3218 If Length is not aligned on a 32-bit boundary, then ASSERT().
3219 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3221 @param Buffer Pointer to the buffer to carry out the checksum operation.
3222 @param Length The size, in bytes, of Buffer.
3224 @return Checksum The 2's complement checksum of Buffer.
3229 CalculateCheckSum32 (
3230 IN CONST UINT32
*Buffer
,
3235 Returns the sum of all elements in a buffer of 64-bit values. During
3236 calculation, the carry bits are dropped.
3238 This function calculates the sum of the 64-bit values in the buffer
3239 specified by Buffer and Length. The carry bits in result of addition are dropped.
3240 The 64-bit result is returned. If Length is 0, then 0 is returned.
3242 If Buffer is NULL, then ASSERT().
3243 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3244 If Length is not aligned on a 64-bit boundary, then ASSERT().
3245 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3247 @param Buffer Pointer to the buffer to carry out the sum operation.
3248 @param Length The size, in bytes, of Buffer.
3250 @return Sum The sum of Buffer with carry bits dropped during additions.
3256 IN CONST UINT64
*Buffer
,
3261 Returns the two's complement checksum of all elements in a buffer of
3264 This function first calculates the sum of the 64-bit values in the buffer
3265 specified by Buffer and Length. The carry bits in the result of addition
3266 are dropped. Then, the two's complement of the sum is returned. If Length
3267 is 0, then 0 is returned.
3269 If Buffer is NULL, then ASSERT().
3270 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3271 If Length is not aligned on a 64-bit boundary, then ASSERT().
3272 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3274 @param Buffer Pointer to the buffer to carry out the checksum operation.
3275 @param Length The size, in bytes, of Buffer.
3277 @return Checksum The 2's complement checksum of Buffer.
3282 CalculateCheckSum64 (
3283 IN CONST UINT64
*Buffer
,
3288 // Base Library CPU Functions
3292 (EFIAPI
*SWITCH_STACK_ENTRY_POINT
) (
3293 IN VOID
*Context1
, OPTIONAL
3294 IN VOID
*Context2 OPTIONAL
3298 Used to serialize load and store operations.
3300 All loads and stores that proceed calls to this function are guaranteed to be
3301 globally visible when this function returns.
3311 Saves the current CPU context that can be restored with a call to LongJump()
3314 Saves the current CPU context in the buffer specified by JumpBuffer and
3315 returns 0. The initial call to SetJump() must always return 0. Subsequent
3316 calls to LongJump() cause a non-zero value to be returned by SetJump().
3318 If JumpBuffer is NULL, then ASSERT().
3319 For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3321 @param JumpBuffer A pointer to CPU context buffer.
3323 @retval 0 Indicates a return from SetJump().
3329 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
3333 Restores the CPU context that was saved with SetJump().
3335 Restores the CPU context from the buffer specified by JumpBuffer. This
3336 function never returns to the caller. Instead is resumes execution based on
3337 the state of JumpBuffer.
3339 If JumpBuffer is NULL, then ASSERT().
3340 For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3341 If Value is 0, then ASSERT().
3343 @param JumpBuffer A pointer to CPU context buffer.
3344 @param Value The value to return when the SetJump() context is
3345 restored and must be non-zero.
3351 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
3356 Enables CPU interrupts.
3358 Enables CPU interrupts.
3368 Disables CPU interrupts.
3370 Disables CPU interrupts.
3380 Disables CPU interrupts and returns the interrupt state prior to the disable
3383 Disables CPU interrupts and returns the interrupt state prior to the disable
3386 @retval TRUE CPU interrupts were enabled on entry to this call.
3387 @retval FALSE CPU interrupts were disabled on entry to this call.
3392 SaveAndDisableInterrupts (
3397 Enables CPU interrupts for the smallest window required to capture any
3400 Enables CPU interrupts for the smallest window required to capture any
3406 EnableDisableInterrupts (
3411 Retrieves the current CPU interrupt state.
3413 Retrieves the current CPU interrupt state. Returns TRUE is interrupts are
3414 currently enabled. Otherwise returns FALSE.
3416 @retval TRUE CPU interrupts are enabled.
3417 @retval FALSE CPU interrupts are disabled.
3422 GlueGetInterruptState (
3427 Set the current CPU interrupt state.
3429 Sets the current CPU interrupt state to the state specified by
3430 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
3431 InterruptState is FALSE, then interrupts are disabled. InterruptState is
3434 @param InterruptState TRUE if interrupts should enabled. FALSE if
3435 interrupts should be disabled.
3437 @return InterruptState
3443 IN BOOLEAN InterruptState
3447 Places the CPU in a sleep state until an interrupt is received.
3449 Places the CPU in a sleep state until an interrupt is received. If interrupts
3450 are disabled prior to calling this function, then the CPU will be placed in a
3451 sleep state indefinitely.
3461 Requests CPU to pause for a short period of time.
3463 Requests CPU to pause for a short period of time. Typically used in MP
3464 systems to prevent memory starvation while waiting for a spin lock.
3474 Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU.
3476 Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU.
3486 Transfers control to a function starting with a new stack.
3488 Transfers control to the function specified by EntryPoint using the new stack
3489 specified by NewStack and passing in the parameters specified by Context1 and
3490 Context2. Context1 and Context2 are optional and may be NULL. The function
3491 EntryPoint must never return.
3493 If EntryPoint is NULL, then ASSERT().
3494 If NewStack is NULL, then ASSERT().
3496 @param EntryPoint A pointer to function to call with the new stack.
3497 @param Context1 A pointer to the context to pass into the EntryPoint
3499 @param Context2 A pointer to the context to pass into the EntryPoint
3501 @param NewStack A pointer to the new stack to use for the EntryPoint
3508 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
3509 IN VOID
*Context1
, OPTIONAL
3510 IN VOID
*Context2
, OPTIONAL
3515 Generates a breakpoint on the CPU.
3517 Generates a breakpoint on the CPU. The breakpoint must be implemented such
3518 that code can resume normal execution after the breakpoint.
3528 Executes an infinite loop.
3530 Forces the CPU to execute an infinite loop. A debugger may be used to skip
3531 past the loop and the code that follows the loop must execute properly. This
3532 implies that the infinite loop must not cause the code that follow it to be
3543 // IA32 and X64 Specific Functions
3546 // Byte packed structure for 16-bit Real Mode EFLAGS
3550 UINT32 CF
:1; // Carry Flag
3551 UINT32 Reserved_0
:1; // Reserved
3552 UINT32 PF
:1; // Parity Flag
3553 UINT32 Reserved_1
:1; // Reserved
3554 UINT32 AF
:1; // Auxiliary Carry Flag
3555 UINT32 Reserved_2
:1; // Reserved
3556 UINT32 ZF
:1; // Zero Flag
3557 UINT32 SF
:1; // Sign Flag
3558 UINT32 TF
:1; // Trap Flag
3559 UINT32 IF
:1; // Interrupt Enable Flag
3560 UINT32 DF
:1; // Direction Flag
3561 UINT32 OF
:1; // Overflow Flag
3562 UINT32 IOPL
:2; // I/O Privilege Level
3563 UINT32 NT
:1; // Nested Task
3564 UINT32 Reserved_3
:1; // Reserved
3570 // Byte packed structure for EFLAGS/RFLAGS
3572 // 64-bits on X64. The upper 32-bits on X64 are reserved
3576 UINT32 CF
:1; // Carry Flag
3577 UINT32 Reserved_0
:1; // Reserved
3578 UINT32 PF
:1; // Parity Flag
3579 UINT32 Reserved_1
:1; // Reserved
3580 UINT32 AF
:1; // Auxiliary Carry Flag
3581 UINT32 Reserved_2
:1; // Reserved
3582 UINT32 ZF
:1; // Zero Flag
3583 UINT32 SF
:1; // Sign Flag
3584 UINT32 TF
:1; // Trap Flag
3585 UINT32 IF
:1; // Interrupt Enable Flag
3586 UINT32 DF
:1; // Direction Flag
3587 UINT32 OF
:1; // Overflow Flag
3588 UINT32 IOPL
:2; // I/O Privilege Level
3589 UINT32 NT
:1; // Nested Task
3590 UINT32 Reserved_3
:1; // Reserved
3591 UINT32 RF
:1; // Resume Flag
3592 UINT32 VM
:1; // Virtual 8086 Mode
3593 UINT32 AC
:1; // Alignment Check
3594 UINT32 VIF
:1; // Virtual Interrupt Flag
3595 UINT32 VIP
:1; // Virtual Interrupt Pending
3596 UINT32 ID
:1; // ID Flag
3597 UINT32 Reserved_4
:10; // Reserved
3603 // Byte packed structure for Control Register 0 (CR0)
3605 // 64-bits on X64. The upper 32-bits on X64 are reserved
3609 UINT32 PE
:1; // Protection Enable
3610 UINT32 MP
:1; // Monitor Coprocessor
3611 UINT32 EM
:1; // Emulation
3612 UINT32 TS
:1; // Task Switched
3613 UINT32 ET
:1; // Extension Type
3614 UINT32 NE
:1; // Numeric Error
3615 UINT32 Reserved_0
:10; // Reserved
3616 UINT32 WP
:1; // Write Protect
3617 UINT32 Reserved_1
:1; // Reserved
3618 UINT32 AM
:1; // Alignment Mask
3619 UINT32 Reserved_2
:10; // Reserved
3620 UINT32 NW
:1; // Mot Write-through
3621 UINT32 CD
:1; // Cache Disable
3622 UINT32 PG
:1; // Paging
3628 // Byte packed structure for Control Register 4 (CR4)
3630 // 64-bits on X64. The upper 32-bits on X64 are reserved
3634 UINT32 VME
:1; // Virtual-8086 Mode Extensions
3635 UINT32 PVI
:1; // Protected-Mode Virtual Interrupts
3636 UINT32 TSD
:1; // Time Stamp Disable
3637 UINT32 DE
:1; // Debugging Extensions
3638 UINT32 PSE
:1; // Page Size Extensions
3639 UINT32 PAE
:1; // Physical Address Extension
3640 UINT32 MCE
:1; // Machine Check Enable
3641 UINT32 PGE
:1; // Page Global Enable
3642 UINT32 PCE
:1; // Performance Monitoring Counter
3644 UINT32 OSFXSR
:1; // Operating System Support for
3645 // FXSAVE and FXRSTOR instructions
3646 UINT32 OSXMMEXCPT
:1; // Operating System Support for
3647 // Unmasked SIMD Floating Point
3649 UINT32 Reserved_0
:2; // Reserved
3650 UINT32 VMXE
:1; // VMX Enable
3651 UINT32 Reserved_1
:18; // Reseved
3657 // Byte packed structure for an IDTR, GDTR, LDTR descriptor
3658 /// @bug How to make this structure byte-packed in a compiler independent way?
3667 #define IA32_IDT_GATE_TYPE_TASK 0x85
3668 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
3669 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
3670 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
3671 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
3674 // Byte packed structure for an Interrupt Gate Descriptor
3678 UINT32 OffsetLow
:16; // Offset bits 15..0
3679 UINT32 Selector
:16; // Selector
3680 UINT32 Reserved_0
:8; // Reserved
3681 UINT32 GateType
:8; // Gate Type. See #defines above
3682 UINT32 OffsetHigh
:16; // Offset bits 31..16
3685 } IA32_IDT_GATE_DESCRIPTOR
;
3688 // Byte packed structure for an FP/SSE/SSE2 context
3695 // Structures for the 16-bit real mode thunks
3748 IA32_EFLAGS32 EFLAGS
;
3758 } IA32_REGISTER_SET
;
3761 // Byte packed structure for an 16-bit real mode thunks
3764 IA32_REGISTER_SET
*RealModeState
;
3765 VOID
*RealModeBuffer
;
3766 UINT32 RealModeBufferSize
;
3767 UINT32 ThunkAttributes
;
3770 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
3771 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
3772 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
3775 Retrieves CPUID information.
3777 Executes the CPUID instruction with EAX set to the value specified by Index.
3778 This function always returns Index.
3779 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
3780 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
3781 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
3782 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
3783 This function is only available on IA-32 and X64.
3785 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
3787 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
3788 instruction. This is an optional parameter that may be NULL.
3789 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
3790 instruction. This is an optional parameter that may be NULL.
3791 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
3792 instruction. This is an optional parameter that may be NULL.
3793 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
3794 instruction. This is an optional parameter that may be NULL.
3803 OUT UINT32
*Eax
, OPTIONAL
3804 OUT UINT32
*Ebx
, OPTIONAL
3805 OUT UINT32
*Ecx
, OPTIONAL
3806 OUT UINT32
*Edx OPTIONAL
3810 Retrieves CPUID information using an extended leaf identifier.
3812 Executes the CPUID instruction with EAX set to the value specified by Index
3813 and ECX set to the value specified by SubIndex. This function always returns
3814 Index. This function is only available on IA-32 and x64.
3816 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
3817 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
3818 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
3819 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
3821 @param Index The 32-bit value to load into EAX prior to invoking the
3823 @param SubIndex The 32-bit value to load into ECX prior to invoking the
3825 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
3826 instruction. This is an optional parameter that may be
3828 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
3829 instruction. This is an optional parameter that may be
3831 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
3832 instruction. This is an optional parameter that may be
3834 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
3835 instruction. This is an optional parameter that may be
3846 OUT UINT32
*Eax
, OPTIONAL
3847 OUT UINT32
*Ebx
, OPTIONAL
3848 OUT UINT32
*Ecx
, OPTIONAL
3849 OUT UINT32
*Edx OPTIONAL
3853 Returns the lower 32-bits of a Machine Specific Register(MSR).
3855 Reads and returns the lower 32-bits of the MSR specified by Index.
3856 No parameter checking is performed on Index, and some Index values may cause
3857 CPU exceptions. The caller must either guarantee that Index is valid, or the
3858 caller must set up exception handlers to catch the exceptions. This function
3859 is only available on IA-32 and X64.
3861 @param Index The 32-bit MSR index to read.
3863 @return The lower 32 bits of the MSR identified by Index.
3873 Zero-extend a 32-bit value and writes it to a Machine Specific Register(MSR).
3875 Writes the 32-bit value specified by Value to the MSR specified by Index. The
3876 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
3877 the MSR is returned. No parameter checking is performed on Index or Value,
3878 and some of these may cause CPU exceptions. The caller must either guarantee
3879 that Index and Value are valid, or the caller must establish proper exception
3880 handlers. This function is only available on IA-32 and X64.
3882 @param Index The 32-bit MSR index to write.
3883 @param Value The 32-bit value to write to the MSR.
3896 Reads a 64-bit MSR, performs a bitwise inclusive OR on the lower 32-bits, and
3897 writes the result back to the 64-bit MSR.
3899 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
3900 between the lower 32-bits of the read result and the value specified by
3901 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
3902 32-bits of the value written to the MSR is returned. No parameter checking is
3903 performed on Index or OrData, and some of these may cause CPU exceptions. The
3904 caller must either guarantee that Index and OrData are valid, or the caller
3905 must establish proper exception handlers. This function is only available on
3908 @param Index The 32-bit MSR index to write.
3909 @param OrData The value to OR with the read value from the MSR.
3911 @return The lower 32-bit value written to the MSR.
3922 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
3923 the result back to the 64-bit MSR.
3925 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
3926 lower 32-bits of the read result and the value specified by AndData, and
3927 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
3928 the value written to the MSR is returned. No parameter checking is performed
3929 on Index or AndData, and some of these may cause CPU exceptions. The caller
3930 must either guarantee that Index and AndData are valid, or the caller must
3931 establish proper exception handlers. This function is only available on IA-32
3934 @param Index The 32-bit MSR index to write.
3935 @param AndData The value to AND with the read value from the MSR.
3937 @return The lower 32-bit value written to the MSR.
3948 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive OR
3949 on the lower 32-bits, and writes the result back to the 64-bit MSR.
3951 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
3952 lower 32-bits of the read result and the value specified by AndData
3953 preserving the upper 32-bits, performs a bitwise inclusive OR between the
3954 result of the AND operation and the value specified by OrData, and writes the
3955 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
3956 written to the MSR is returned. No parameter checking is performed on Index,
3957 AndData, or OrData, and some of these may cause CPU exceptions. The caller
3958 must either guarantee that Index, AndData, and OrData are valid, or the
3959 caller must establish proper exception handlers. This function is only
3960 available on IA-32 and X64.
3962 @param Index The 32-bit MSR index to write.
3963 @param AndData The value to AND with the read value from the MSR.
3964 @param OrData The value to OR with the result of the AND operation.
3966 @return The lower 32-bit value written to the MSR.
3978 Reads a bit field of an MSR.
3980 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
3981 specified by the StartBit and the EndBit. The value of the bit field is
3982 returned. The caller must either guarantee that Index is valid, or the caller
3983 must set up exception handlers to catch the exceptions. This function is only
3984 available on IA-32 and X64.
3986 If StartBit is greater than 31, then ASSERT().
3987 If EndBit is greater than 31, then ASSERT().
3988 If EndBit is less than StartBit, then ASSERT().
3990 @param Index The 32-bit MSR index to read.
3991 @param StartBit The ordinal of the least significant bit in the bit field.
3993 @param EndBit The ordinal of the most significant bit in the bit field.
3996 @return The bit field read from the MSR.
4001 AsmMsrBitFieldRead32 (
4008 Writes a bit field to an MSR.
4010 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
4011 field is specified by the StartBit and the EndBit. All other bits in the
4012 destination MSR are preserved. The lower 32-bits of the MSR written is
4013 returned. Extra left bits in Value are stripped. The caller must either
4014 guarantee that Index and the data written is valid, or the caller must set up
4015 exception handlers to catch the exceptions. This function is only available
4018 If StartBit is greater than 31, then ASSERT().
4019 If EndBit is greater than 31, then ASSERT().
4020 If EndBit is less than StartBit, then ASSERT().
4022 @param Index The 32-bit MSR index to write.
4023 @param StartBit The ordinal of the least significant bit in the bit field.
4025 @param EndBit The ordinal of the most significant bit in the bit field.
4027 @param Value New value of the bit field.
4029 @return The lower 32-bit of the value written to the MSR.
4034 AsmMsrBitFieldWrite32 (
4042 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
4043 result back to the bit field in the 64-bit MSR.
4045 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
4046 between the read result and the value specified by OrData, and writes the
4047 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
4048 written to the MSR are returned. Extra left bits in OrData are stripped. The
4049 caller must either guarantee that Index and the data written is valid, or
4050 the caller must set up exception handlers to catch the exceptions. This
4051 function is only available on IA-32 and X64.
4053 If StartBit is greater than 31, then ASSERT().
4054 If EndBit is greater than 31, then ASSERT().
4055 If EndBit is less than StartBit, then ASSERT().
4057 @param Index The 32-bit MSR index to write.
4058 @param StartBit The ordinal of the least significant bit in the bit field.
4060 @param EndBit The ordinal of the most significant bit in the bit field.
4062 @param OrData The value to OR with the read value from the MSR.
4064 @return The lower 32-bit of the value written to the MSR.
4069 AsmMsrBitFieldOr32 (
4077 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
4078 result back to the bit field in the 64-bit MSR.
4080 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
4081 read result and the value specified by AndData, and writes the result to the
4082 64-bit MSR specified by Index. The lower 32-bits of the value written to the
4083 MSR are returned. Extra left bits in AndData are stripped. The caller must
4084 either guarantee that Index and the data written is valid, or the caller must
4085 set up exception handlers to catch the exceptions. This function is only
4086 available on IA-32 and X64.
4088 If StartBit is greater than 31, then ASSERT().
4089 If EndBit is greater than 31, then ASSERT().
4090 If EndBit is less than StartBit, then ASSERT().
4092 @param Index The 32-bit MSR index to write.
4093 @param StartBit The ordinal of the least significant bit in the bit field.
4095 @param EndBit The ordinal of the most significant bit in the bit field.
4097 @param AndData The value to AND with the read value from the MSR.
4099 @return The lower 32-bit of the value written to the MSR.
4104 AsmMsrBitFieldAnd32 (
4112 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
4113 bitwise inclusive OR, and writes the result back to the bit field in the
4116 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
4117 bitwise inclusive OR between the read result and the value specified by
4118 AndData, and writes the result to the 64-bit MSR specified by Index. The
4119 lower 32-bits of the value written to the MSR are returned. Extra left bits
4120 in both AndData and OrData are stripped. The caller must either guarantee
4121 that Index and the data written is valid, or the caller must set up exception
4122 handlers to catch the exceptions. This function is only available on IA-32
4125 If StartBit is greater than 31, then ASSERT().
4126 If EndBit is greater than 31, then ASSERT().
4127 If EndBit is less than StartBit, then ASSERT().
4129 @param Index The 32-bit MSR index to write.
4130 @param StartBit The ordinal of the least significant bit in the bit field.
4132 @param EndBit The ordinal of the most significant bit in the bit field.
4134 @param AndData The value to AND with the read value from the MSR.
4135 @param OrData The value to OR with the result of the AND operation.
4137 @return The lower 32-bit of the value written to the MSR.
4142 AsmMsrBitFieldAndThenOr32 (
4151 Returns a 64-bit Machine Specific Register(MSR).
4153 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
4154 performed on Index, and some Index values may cause CPU exceptions. The
4155 caller must either guarantee that Index is valid, or the caller must set up
4156 exception handlers to catch the exceptions. This function is only available
4159 @param Index The 32-bit MSR index to read.
4161 @return The value of the MSR identified by Index.
4171 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
4174 Writes the 64-bit value specified by Value to the MSR specified by Index. The
4175 64-bit value written to the MSR is returned. No parameter checking is
4176 performed on Index or Value, and some of these may cause CPU exceptions. The
4177 caller must either guarantee that Index and Value are valid, or the caller
4178 must establish proper exception handlers. This function is only available on
4181 @param Index The 32-bit MSR index to write.
4182 @param Value The 64-bit value to write to the MSR.
4195 Reads a 64-bit MSR, performs a bitwise inclusive OR, and writes the result
4196 back to the 64-bit MSR.
4198 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
4199 between the read result and the value specified by OrData, and writes the
4200 result to the 64-bit MSR specified by Index. The value written to the MSR is
4201 returned. No parameter checking is performed on Index or OrData, and some of
4202 these may cause CPU exceptions. The caller must either guarantee that Index
4203 and OrData are valid, or the caller must establish proper exception handlers.
4204 This function is only available on IA-32 and X64.
4206 @param Index The 32-bit MSR index to write.
4207 @param OrData The value to OR with the read value from the MSR.
4209 @return The value written back to the MSR.
4220 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
4223 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
4224 read result and the value specified by OrData, and writes the result to the
4225 64-bit MSR specified by Index. The value written to the MSR is returned. No
4226 parameter checking is performed on Index or OrData, and some of these may
4227 cause CPU exceptions. The caller must either guarantee that Index and OrData
4228 are valid, or the caller must establish proper exception handlers. This
4229 function is only available on IA-32 and X64.
4231 @param Index The 32-bit MSR index to write.
4232 @param AndData The value to AND with the read value from the MSR.
4234 @return The value written back to the MSR.
4245 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive
4246 OR, and writes the result back to the 64-bit MSR.
4248 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
4249 result and the value specified by AndData, performs a bitwise inclusive OR
4250 between the result of the AND operation and the value specified by OrData,
4251 and writes the result to the 64-bit MSR specified by Index. The value written
4252 to the MSR is returned. No parameter checking is performed on Index, AndData,
4253 or OrData, and some of these may cause CPU exceptions. The caller must either
4254 guarantee that Index, AndData, and OrData are valid, or the caller must
4255 establish proper exception handlers. This function is only available on IA-32
4258 @param Index The 32-bit MSR index to write.
4259 @param AndData The value to AND with the read value from the MSR.
4260 @param OrData The value to OR with the result of the AND operation.
4262 @return The value written back to the MSR.
4274 Reads a bit field of an MSR.
4276 Reads the bit field in the 64-bit MSR. The bit field is specified by the
4277 StartBit and the EndBit. The value of the bit field is returned. The caller
4278 must either guarantee that Index is valid, or the caller must set up
4279 exception handlers to catch the exceptions. This function is only available
4282 If StartBit is greater than 63, then ASSERT().
4283 If EndBit is greater than 63, then ASSERT().
4284 If EndBit is less than StartBit, then ASSERT().
4286 @param Index The 32-bit MSR index to read.
4287 @param StartBit The ordinal of the least significant bit in the bit field.
4289 @param EndBit The ordinal of the most significant bit in the bit field.
4292 @return The value read from the MSR.
4297 AsmMsrBitFieldRead64 (
4304 Writes a bit field to an MSR.
4306 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
4307 the StartBit and the EndBit. All other bits in the destination MSR are
4308 preserved. The MSR written is returned. Extra left bits in Value are
4309 stripped. The caller must either guarantee that Index and the data written is
4310 valid, or the caller must set up exception handlers to catch the exceptions.
4311 This function is only available on IA-32 and X64.
4313 If StartBit is greater than 63, then ASSERT().
4314 If EndBit is greater than 63, then ASSERT().
4315 If EndBit is less than StartBit, then ASSERT().
4317 @param Index The 32-bit MSR index to write.
4318 @param StartBit The ordinal of the least significant bit in the bit field.
4320 @param EndBit The ordinal of the most significant bit in the bit field.
4322 @param Value New value of the bit field.
4324 @return The value written back to the MSR.
4329 AsmMsrBitFieldWrite64 (
4337 Reads a bit field in a 64-bit MSR, performs a bitwise inclusive OR, and
4338 writes the result back to the bit field in the 64-bit MSR.
4340 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
4341 between the read result and the value specified by OrData, and writes the
4342 result to the 64-bit MSR specified by Index. The value written to the MSR is
4343 returned. Extra left bits in OrData are stripped. The caller must either
4344 guarantee that Index and the data written is valid, or the caller must set up
4345 exception handlers to catch the exceptions. This function is only available
4348 If StartBit is greater than 63, then ASSERT().
4349 If EndBit is greater than 63, then ASSERT().
4350 If EndBit is less than StartBit, then ASSERT().
4352 @param Index The 32-bit MSR index to write.
4353 @param StartBit The ordinal of the least significant bit in the bit field.
4355 @param EndBit The ordinal of the most significant bit in the bit field.
4357 @param OrData The value to OR with the read value from the bit field.
4359 @return The value written back to the MSR.
4364 AsmMsrBitFieldOr64 (
4372 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
4373 result back to the bit field in the 64-bit MSR.
4375 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
4376 read result and the value specified by AndData, and writes the result to the
4377 64-bit MSR specified by Index. The value written to the MSR is returned.
4378 Extra left bits in AndData are stripped. The caller must either guarantee
4379 that Index and the data written is valid, or the caller must set up exception
4380 handlers to catch the exceptions. This function is only available on IA-32
4383 If StartBit is greater than 63, then ASSERT().
4384 If EndBit is greater than 63, then ASSERT().
4385 If EndBit is less than StartBit, then ASSERT().
4387 @param Index The 32-bit MSR index to write.
4388 @param StartBit The ordinal of the least significant bit in the bit field.
4390 @param EndBit The ordinal of the most significant bit in the bit field.
4392 @param AndData The value to AND with the read value from the bit field.
4394 @return The value written back to the MSR.
4399 AsmMsrBitFieldAnd64 (
4407 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
4408 bitwise inclusive OR, and writes the result back to the bit field in the
4411 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
4412 a bitwise inclusive OR between the read result and the value specified by
4413 AndData, and writes the result to the 64-bit MSR specified by Index. The
4414 value written to the MSR is returned. Extra left bits in both AndData and
4415 OrData are stripped. The caller must either guarantee that Index and the data
4416 written is valid, or the caller must set up exception handlers to catch the
4417 exceptions. This function is only available on IA-32 and X64.
4419 If StartBit is greater than 63, then ASSERT().
4420 If EndBit is greater than 63, then ASSERT().
4421 If EndBit is less than StartBit, then ASSERT().
4423 @param Index The 32-bit MSR index to write.
4424 @param StartBit The ordinal of the least significant bit in the bit field.
4426 @param EndBit The ordinal of the most significant bit in the bit field.
4428 @param AndData The value to AND with the read value from the bit field.
4429 @param OrData The value to OR with the result of the AND operation.
4431 @return The value written back to the MSR.
4436 AsmMsrBitFieldAndThenOr64 (
4445 Reads the current value of the EFLAGS register.
4447 Reads and returns the current value of the EFLAGS register. This function is
4448 only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a
4449 64-bit value on X64.
4451 @return EFLAGS on IA-32 or RFLAGS on X64.
4461 Reads the current value of the Control Register 0 (CR0).
4463 Reads and returns the current value of CR0. This function is only available
4464 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4467 @return The value of the Control Register 0 (CR0).
4477 Reads the current value of the Control Register 2 (CR2).
4479 Reads and returns the current value of CR2. This function is only available
4480 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4483 @return The value of the Control Register 2 (CR2).
4493 Reads the current value of the Control Register 3 (CR3).
4495 Reads and returns the current value of CR3. This function is only available
4496 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4499 @return The value of the Control Register 3 (CR3).
4509 Reads the current value of the Control Register 4 (CR4).
4511 Reads and returns the current value of CR4. This function is only available
4512 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4515 @return The value of the Control Register 4 (CR4).
4525 Writes a value to Control Register 0 (CR0).
4527 Writes and returns a new value to CR0. This function is only available on
4528 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4530 @param Cr0 The value to write to CR0.
4532 @return The value written to CR0.
4542 Writes a value to Control Register 2 (CR2).
4544 Writes and returns a new value to CR2. This function is only available on
4545 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4547 @param Cr2 The value to write to CR2.
4549 @return The value written to CR2.
4559 Writes a value to Control Register 3 (CR3).
4561 Writes and returns a new value to CR3. This function is only available on
4562 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4564 @param Cr3 The value to write to CR3.
4566 @return The value written to CR3.
4576 Writes a value to Control Register 4 (CR4).
4578 Writes and returns a new value to CR4. This function is only available on
4579 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4581 @param Cr4 The value to write to CR4.
4583 @return The value written to CR4.
4593 Reads the current value of Debug Register 0 (DR0).
4595 Reads and returns the current value of DR0. This function is only available
4596 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4599 @return The value of Debug Register 0 (DR0).
4609 Reads the current value of Debug Register 1 (DR1).
4611 Reads and returns the current value of DR1. This function is only available
4612 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4615 @return The value of Debug Register 1 (DR1).
4625 Reads the current value of Debug Register 2 (DR2).
4627 Reads and returns the current value of DR2. This function is only available
4628 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4631 @return The value of Debug Register 2 (DR2).
4641 Reads the current value of Debug Register 3 (DR3).
4643 Reads and returns the current value of DR3. This function is only available
4644 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4647 @return The value of Debug Register 3 (DR3).
4657 Reads the current value of Debug Register 4 (DR4).
4659 Reads and returns the current value of DR4. This function is only available
4660 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4663 @return The value of Debug Register 4 (DR4).
4673 Reads the current value of Debug Register 5 (DR5).
4675 Reads and returns the current value of DR5. This function is only available
4676 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4679 @return The value of Debug Register 5 (DR5).
4689 Reads the current value of Debug Register 6 (DR6).
4691 Reads and returns the current value of DR6. This function is only available
4692 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4695 @return The value of Debug Register 6 (DR6).
4705 Reads the current value of Debug Register 7 (DR7).
4707 Reads and returns the current value of DR7. This function is only available
4708 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4711 @return The value of Debug Register 7 (DR7).
4721 Writes a value to Debug Register 0 (DR0).
4723 Writes and returns a new value to DR0. This function is only available on
4724 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4726 @param Dr0 The value to write to Dr0.
4728 @return The value written to Debug Register 0 (DR0).
4738 Writes a value to Debug Register 1 (DR1).
4740 Writes and returns a new value to DR1. This function is only available on
4741 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4743 @param Dr1 The value to write to Dr1.
4745 @return The value written to Debug Register 1 (DR1).
4755 Writes a value to Debug Register 2 (DR2).
4757 Writes and returns a new value to DR2. This function is only available on
4758 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4760 @param Dr2 The value to write to Dr2.
4762 @return The value written to Debug Register 2 (DR2).
4772 Writes a value to Debug Register 3 (DR3).
4774 Writes and returns a new value to DR3. This function is only available on
4775 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4777 @param Dr3 The value to write to Dr3.
4779 @return The value written to Debug Register 3 (DR3).
4789 Writes a value to Debug Register 4 (DR4).
4791 Writes and returns a new value to DR4. This function is only available on
4792 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4794 @param Dr4 The value to write to Dr4.
4796 @return The value written to Debug Register 4 (DR4).
4806 Writes a value to Debug Register 5 (DR5).
4808 Writes and returns a new value to DR5. This function is only available on
4809 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4811 @param Dr5 The value to write to Dr5.
4813 @return The value written to Debug Register 5 (DR5).
4823 Writes a value to Debug Register 6 (DR6).
4825 Writes and returns a new value to DR6. This function is only available on
4826 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4828 @param Dr6 The value to write to Dr6.
4830 @return The value written to Debug Register 6 (DR6).
4840 Writes a value to Debug Register 7 (DR7).
4842 Writes and returns a new value to DR7. This function is only available on
4843 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4845 @param Dr7 The value to write to Dr7.
4847 @return The value written to Debug Register 7 (DR7).
4857 Reads the current value of Code Segment Register (CS).
4859 Reads and returns the current value of CS. This function is only available on
4862 @return The current value of CS.
4872 Reads the current value of Data Segment Register (DS).
4874 Reads and returns the current value of DS. This function is only available on
4877 @return The current value of DS.
4887 Reads the current value of Extra Segment Register (ES).
4889 Reads and returns the current value of ES. This function is only available on
4892 @return The current value of ES.
4902 Reads the current value of FS Data Segment Register (FS).
4904 Reads and returns the current value of FS. This function is only available on
4907 @return The current value of FS.
4917 Reads the current value of GS Data Segment Register (GS).
4919 Reads and returns the current value of GS. This function is only available on
4922 @return The current value of GS.
4932 Reads the current value of Stack Segment Register (SS).
4934 Reads and returns the current value of SS. This function is only available on
4937 @return The current value of SS.
4947 Reads the current value of Task Register (TR).
4949 Reads and returns the current value of TR. This function is only available on
4952 @return The current value of TR.
4962 Reads the current Global Descriptor Table Register(GDTR) descriptor.
4964 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
4965 function is only available on IA-32 and X64.
4967 If Gdtr is NULL, then ASSERT().
4969 @param Gdtr Pointer to a GDTR descriptor.
4975 OUT IA32_DESCRIPTOR
*Gdtr
4979 Writes the current Global Descriptor Table Register (GDTR) descriptor.
4981 Writes and the current GDTR descriptor specified by Gdtr. This function is
4982 only available on IA-32 and X64.
4984 If Gdtr is NULL, then ASSERT().
4986 @param Gdtr Pointer to a GDTR descriptor.
4992 IN CONST IA32_DESCRIPTOR
*Gdtr
4996 Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.
4998 Reads and returns the current IDTR descriptor and returns it in Idtr. This
4999 function is only available on IA-32 and X64.
5001 If Idtr is NULL, then ASSERT().
5003 @param Idtr Pointer to a IDTR descriptor.
5009 OUT IA32_DESCRIPTOR
*Idtr
5013 Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.
5015 Writes the current IDTR descriptor and returns it in Idtr. This function is
5016 only available on IA-32 and X64.
5018 If Idtr is NULL, then ASSERT().
5020 @param Idtr Pointer to a IDTR descriptor.
5026 IN CONST IA32_DESCRIPTOR
*Idtr
5030 Reads the current Local Descriptor Table Register(LDTR) selector.
5032 Reads and returns the current 16-bit LDTR descriptor value. This function is
5033 only available on IA-32 and X64.
5035 @return The current selector of LDT.
5045 Writes the current Local Descriptor Table Register (GDTR) selector.
5047 Writes and the current LDTR descriptor specified by Ldtr. This function is
5048 only available on IA-32 and X64.
5050 @param Ldtr 16-bit LDTR selector value.
5060 Save the current floating point/SSE/SSE2 context to a buffer.
5062 Saves the current floating point/SSE/SSE2 state to the buffer specified by
5063 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
5064 available on IA-32 and X64.
5066 If Buffer is NULL, then ASSERT().
5067 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
5069 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
5075 OUT IA32_FX_BUFFER
*Buffer
5079 Restores the current floating point/SSE/SSE2 context from a buffer.
5081 Restores the current floating point/SSE/SSE2 state from the buffer specified
5082 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
5083 only available on IA-32 and X64.
5085 If Buffer is NULL, then ASSERT().
5086 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
5087 If Buffer was not saved with AsmFxSave(), then ASSERT().
5089 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
5095 IN CONST IA32_FX_BUFFER
*Buffer
5099 Reads the current value of 64-bit MMX Register #0 (MM0).
5101 Reads and returns the current value of MM0. This function is only available
5104 @return The current value of MM0.
5114 Reads the current value of 64-bit MMX Register #1 (MM1).
5116 Reads and returns the current value of MM1. This function is only available
5119 @return The current value of MM1.
5129 Reads the current value of 64-bit MMX Register #2 (MM2).
5131 Reads and returns the current value of MM2. This function is only available
5134 @return The current value of MM2.
5144 Reads the current value of 64-bit MMX Register #3 (MM3).
5146 Reads and returns the current value of MM3. This function is only available
5149 @return The current value of MM3.
5159 Reads the current value of 64-bit MMX Register #4 (MM4).
5161 Reads and returns the current value of MM4. This function is only available
5164 @return The current value of MM4.
5174 Reads the current value of 64-bit MMX Register #5 (MM5).
5176 Reads and returns the current value of MM5. This function is only available
5179 @return The current value of MM5.
5189 Reads the current value of 64-bit MMX Register #6 (MM6).
5191 Reads and returns the current value of MM6. This function is only available
5194 @return The current value of MM6.
5204 Reads the current value of 64-bit MMX Register #7 (MM7).
5206 Reads and returns the current value of MM7. This function is only available
5209 @return The current value of MM7.
5219 Writes the current value of 64-bit MMX Register #0 (MM0).
5221 Writes the current value of MM0. This function is only available on IA32 and
5224 @param Value The 64-bit value to write to MM0.
5234 Writes the current value of 64-bit MMX Register #1 (MM1).
5236 Writes the current value of MM1. This function is only available on IA32 and
5239 @param Value The 64-bit value to write to MM1.
5249 Writes the current value of 64-bit MMX Register #2 (MM2).
5251 Writes the current value of MM2. This function is only available on IA32 and
5254 @param Value The 64-bit value to write to MM2.
5264 Writes the current value of 64-bit MMX Register #3 (MM3).
5266 Writes the current value of MM3. This function is only available on IA32 and
5269 @param Value The 64-bit value to write to MM3.
5279 Writes the current value of 64-bit MMX Register #4 (MM4).
5281 Writes the current value of MM4. This function is only available on IA32 and
5284 @param Value The 64-bit value to write to MM4.
5294 Writes the current value of 64-bit MMX Register #5 (MM5).
5296 Writes the current value of MM5. This function is only available on IA32 and
5299 @param Value The 64-bit value to write to MM5.
5309 Writes the current value of 64-bit MMX Register #6 (MM6).
5311 Writes the current value of MM6. This function is only available on IA32 and
5314 @param Value The 64-bit value to write to MM6.
5324 Writes the current value of 64-bit MMX Register #7 (MM7).
5326 Writes the current value of MM7. This function is only available on IA32 and
5329 @param Value The 64-bit value to write to MM7.
5339 Reads the current value of Time Stamp Counter (TSC).
5341 Reads and returns the current value of TSC. This function is only available
5344 @return The current value of TSC
5354 Reads the current value of a Performance Counter (PMC).
5356 Reads and returns the current value of performance counter specified by
5357 Index. This function is only available on IA-32 and X64.
5359 @param Index The 32-bit Performance Counter index to read.
5361 @return The value of the PMC specified by Index.
5371 Sets up a monitor buffer that is used by AsmMwait().
5373 Executes a MONITOR instruction with the register state specified by Eax, Ecx
5374 and Edx. Returns Eax. This function is only available on IA-32 and X64.
5376 @param Eax The value to load into EAX or RAX before executing the MONITOR
5378 @param Ecx The value to load into ECX or RCX before executing the MONITOR
5380 @param Edx The value to load into EDX or RDX before executing the MONITOR
5395 Executes an MWAIT instruction.
5397 Executes an MWAIT instruction with the register state specified by Eax and
5398 Ecx. Returns Eax. This function is only available on IA-32 and X64.
5400 @param Eax The value to load into EAX or RAX before executing the MONITOR
5402 @param Ecx The value to load into ECX or RCX before executing the MONITOR
5416 Executes a WBINVD instruction.
5418 Executes a WBINVD instruction. This function is only available on IA-32 and
5429 Executes a INVD instruction.
5431 Executes a INVD instruction. This function is only available on IA-32 and
5442 Flushes a cache line from all the instruction and data caches within the
5443 coherency domain of the CPU.
5445 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
5446 This function is only available on IA-32 and X64.
5448 @param LinearAddress The address of the cache line to flush. If the CPU is
5449 in a physical addressing mode, then LinearAddress is a
5450 physical address. If the CPU is in a virtual
5451 addressing mode, then LinearAddress is a virtual
5454 @return LinearAddress
5459 IN VOID
*LinearAddress
5463 Enables the 32-bit paging mode on the CPU.
5465 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
5466 must be properly initialized prior to calling this service. This function
5467 assumes the current execution mode is 32-bit protected mode. This function is
5468 only available on IA-32. After the 32-bit paging mode is enabled, control is
5469 transferred to the function specified by EntryPoint using the new stack
5470 specified by NewStack and passing in the parameters specified by Context1 and
5471 Context2. Context1 and Context2 are optional and may be NULL. The function
5472 EntryPoint must never return.
5474 If the current execution mode is not 32-bit protected mode, then ASSERT().
5475 If EntryPoint is NULL, then ASSERT().
5476 If NewStack is NULL, then ASSERT().
5478 There are a number of constraints that must be followed before calling this
5480 1) Interrupts must be disabled.
5481 2) The caller must be in 32-bit protected mode with flat descriptors. This
5482 means all descriptors must have a base of 0 and a limit of 4GB.
5483 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
5485 4) CR3 must point to valid page tables that will be used once the transition
5486 is complete, and those page tables must guarantee that the pages for this
5487 function and the stack are identity mapped.
5489 @param EntryPoint A pointer to function to call with the new stack after
5491 @param Context1 A pointer to the context to pass into the EntryPoint
5492 function as the first parameter after paging is enabled.
5493 @param Context2 A pointer to the context to pass into the EntryPoint
5494 function as the second parameter after paging is enabled.
5495 @param NewStack A pointer to the new stack to use for the EntryPoint
5496 function after paging is enabled.
5502 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
5503 IN VOID
*Context1
, OPTIONAL
5504 IN VOID
*Context2
, OPTIONAL
5509 Disables the 32-bit paging mode on the CPU.
5511 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
5512 mode. This function assumes the current execution mode is 32-paged protected
5513 mode. This function is only available on IA-32. After the 32-bit paging mode
5514 is disabled, control is transferred to the function specified by EntryPoint
5515 using the new stack specified by NewStack and passing in the parameters
5516 specified by Context1 and Context2. Context1 and Context2 are optional and
5517 may be NULL. The function EntryPoint must never return.
5519 If the current execution mode is not 32-bit paged mode, then ASSERT().
5520 If EntryPoint is NULL, then ASSERT().
5521 If NewStack is NULL, then ASSERT().
5523 There are a number of constraints that must be followed before calling this
5525 1) Interrupts must be disabled.
5526 2) The caller must be in 32-bit paged mode.
5527 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
5528 4) CR3 must point to valid page tables that guarantee that the pages for
5529 this function and the stack are identity mapped.
5531 @param EntryPoint A pointer to function to call with the new stack after
5533 @param Context1 A pointer to the context to pass into the EntryPoint
5534 function as the first parameter after paging is disabled.
5535 @param Context2 A pointer to the context to pass into the EntryPoint
5536 function as the second parameter after paging is
5538 @param NewStack A pointer to the new stack to use for the EntryPoint
5539 function after paging is disabled.
5544 AsmDisablePaging32 (
5545 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
5546 IN VOID
*Context1
, OPTIONAL
5547 IN VOID
*Context2
, OPTIONAL
5552 Enables the 64-bit paging mode on the CPU.
5554 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
5555 must be properly initialized prior to calling this service. This function
5556 assumes the current execution mode is 32-bit protected mode with flat
5557 descriptors. This function is only available on IA-32. After the 64-bit
5558 paging mode is enabled, control is transferred to the function specified by
5559 EntryPoint using the new stack specified by NewStack and passing in the
5560 parameters specified by Context1 and Context2. Context1 and Context2 are
5561 optional and may be 0. The function EntryPoint must never return.
5563 If the current execution mode is not 32-bit protected mode with flat
5564 descriptors, then ASSERT().
5565 If EntryPoint is 0, then ASSERT().
5566 If NewStack is 0, then ASSERT().
5568 @param Cs The 16-bit selector to load in the CS before EntryPoint
5569 is called. The descriptor in the GDT that this selector
5570 references must be setup for long mode.
5571 @param EntryPoint The 64-bit virtual address of the function to call with
5572 the new stack after paging is enabled.
5573 @param Context1 The 64-bit virtual address of the context to pass into
5574 the EntryPoint function as the first parameter after
5576 @param Context2 The 64-bit virtual address of the context to pass into
5577 the EntryPoint function as the second parameter after
5579 @param NewStack The 64-bit virtual address of the new stack to use for
5580 the EntryPoint function after paging is enabled.
5586 IN UINT16 CodeSelector
,
5587 IN UINT64 EntryPoint
,
5588 IN UINT64 Context1
, OPTIONAL
5589 IN UINT64 Context2
, OPTIONAL
5594 Disables the 64-bit paging mode on the CPU.
5596 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
5597 mode. This function assumes the current execution mode is 64-paging mode.
5598 This function is only available on X64. After the 64-bit paging mode is
5599 disabled, control is transferred to the function specified by EntryPoint
5600 using the new stack specified by NewStack and passing in the parameters
5601 specified by Context1 and Context2. Context1 and Context2 are optional and
5602 may be 0. The function EntryPoint must never return.
5604 If the current execution mode is not 64-bit paged mode, then ASSERT().
5605 If EntryPoint is 0, then ASSERT().
5606 If NewStack is 0, then ASSERT().
5608 @param Cs The 16-bit selector to load in the CS before EntryPoint
5609 is called. The descriptor in the GDT that this selector
5610 references must be setup for 32-bit protected mode.
5611 @param EntryPoint The 64-bit virtual address of the function to call with
5612 the new stack after paging is disabled.
5613 @param Context1 The 64-bit virtual address of the context to pass into
5614 the EntryPoint function as the first parameter after
5616 @param Context2 The 64-bit virtual address of the context to pass into
5617 the EntryPoint function as the second parameter after
5619 @param NewStack The 64-bit virtual address of the new stack to use for
5620 the EntryPoint function after paging is disabled.
5625 AsmDisablePaging64 (
5626 IN UINT16 CodeSelector
,
5627 IN UINT32 EntryPoint
,
5628 IN UINT32 Context1
, OPTIONAL
5629 IN UINT32 Context2
, OPTIONAL
5634 // 16-bit thunking services
5638 Retrieves the properties for 16-bit thunk functions.
5640 Computes the size of the buffer and stack below 1MB required to use the
5641 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
5642 buffer size is returned in RealModeBufferSize, and the stack size is returned
5643 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
5644 then the actual minimum stack size is ExtraStackSize plus the maximum number
5645 of bytes that need to be passed to the 16-bit real mode code.
5647 If RealModeBufferSize is NULL, then ASSERT().
5648 If ExtraStackSize is NULL, then ASSERT().
5650 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
5651 required to use the 16-bit thunk functions.
5652 @param ExtraStackSize A pointer to the extra size of stack below 1MB
5653 that the 16-bit thunk functions require for
5654 temporary storage in the transition to and from
5660 AsmGetThunk16Properties (
5661 OUT UINT32
*RealModeBufferSize
,
5662 OUT UINT32
*ExtraStackSize
5666 Prepares all structures a code required to use AsmThunk16().
5668 Prepares all structures and code required to use AsmThunk16().
5670 If ThunkContext is NULL, then ASSERT().
5672 @param ThunkContext A pointer to the context structure that describes the
5673 16-bit real mode code to call.
5679 OUT THUNK_CONTEXT
*ThunkContext
5683 Transfers control to a 16-bit real mode entry point and returns the results.
5685 Transfers control to a 16-bit real mode entry point and returns the results.
5686 AsmPrepareThunk16() must be called with ThunkContext before this function is
5689 If ThunkContext is NULL, then ASSERT().
5690 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
5692 @param ThunkContext A pointer to the context structure that describes the
5693 16-bit real mode code to call.
5699 IN OUT THUNK_CONTEXT
*ThunkContext
5703 Prepares all structures and code for a 16-bit real mode thunk, transfers
5704 control to a 16-bit real mode entry point, and returns the results.
5706 Prepares all structures and code for a 16-bit real mode thunk, transfers
5707 control to a 16-bit real mode entry point, and returns the results. If the
5708 caller only need to perform a single 16-bit real mode thunk, then this
5709 service should be used. If the caller intends to make more than one 16-bit
5710 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
5711 once and AsmThunk16() can be called for each 16-bit real mode thunk.
5713 If ThunkContext is NULL, then ASSERT().
5715 @param ThunkContext A pointer to the context structure that describes the
5716 16-bit real mode code to call.
5721 AsmPrepareAndThunk16 (
5722 IN OUT THUNK_CONTEXT
*ThunkContext
5726 Transfers control to a function starting with a new stack.
5728 Transfers control to the function specified by EntryPoint using the new stack
5729 specified by NewStack and passing in the parameters specified by Context1 and
5730 Context2. Context1 and Context2 are optional and may be NULL. The function
5731 EntryPoint must never return.
5733 If EntryPoint is NULL, then ASSERT().
5734 If NewStack is NULL, then ASSERT().
5736 @param EntryPoint A pointer to function to call with the new stack.
5737 @param Context1 A pointer to the context to pass into the EntryPoint
5739 @param Context2 A pointer to the context to pass into the EntryPoint
5741 @param NewStack A pointer to the new stack to use for the EntryPoint
5743 @param NewBsp A pointer to the new memory location for RSE backing
5749 AsmSwitchStackAndBackingStore (
5750 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
5751 IN VOID
*Context1
, OPTIONAL
5752 IN VOID
*Context2
, OPTIONAL
5765 // IPF Specific functions
5770 Performs a PAL call using static calling convention.
5772 An internal function to perform a PAL call using static calling convention.
5774 @param PalEntryPoint The entry point address of PAL. The address in ar.kr5
5775 would be used if this parameter were NULL on input.
5776 @param Arg1 The first argument of a PAL call.
5777 @param Arg1 The second argument of a PAL call.
5778 @param Arg1 The third argument of a PAL call.
5779 @param Arg1 The fourth argument of a PAL call.
5781 @return The values returned in r8, r9, r10 and r11.
5786 IN CONST VOID
*PalEntryPoint
,
5795 Returns the current value of ar.itc.
5797 An internal function to return the current value of ar.itc, which is the
5800 @return The currect value of ar.itc
5810 Flush a range of cache lines in the cache coherency domain of the calling
5813 Invalidates the cache lines specified by Address and Length. If Address is
5814 not aligned on a cache line boundary, then entire cache line containing
5815 Address is invalidated. If Address + Length is not aligned on a cache line
5816 boundary, then the entire instruction cache line containing Address + Length
5817 -1 is invalidated. This function may choose to invalidate the entire
5818 instruction cache if that is more efficient than invalidating the specified
5819 range. If Length is 0, the no instruction cache lines are invalidated.
5820 Address is returned.
5822 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
5824 @param Address The base address of the instruction lines to invalidate. If
5825 the CPU is in a physical addressing mode, then Address is a
5826 physical address. If the CPU is in a virtual addressing mode,
5827 then Address is a virtual address.
5829 @param Length The number of bytes to invalidate from the instruction cache.
5836 IpfFlushCacheRange (