2 Memory-only library functions with no library constructor/destructor
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 Module Name: BaseLib.h
21 // Definitions for architecture specific types
22 // These include SPIN_LOCK and BASE_LIBRARY_JUMP_BUFFER
28 typedef UINTN SPIN_LOCK
;
30 #if defined (MDE_CPU_IA32)
32 // IA32 context buffer used by SetJump() and LongJump()
41 } BASE_LIBRARY_JUMP_BUFFER
;
43 #elif defined (MDE_CPU_IPF)
45 // IPF context buffer used by SetJump() and LongJump()
49 UINT64 AfterSpillUNAT
;
107 } BASE_LIBRARY_JUMP_BUFFER
;
109 #elif defined (MDE_CPU_X64)
111 // X64 context buffer used by SetJump() and LongJump()
124 } BASE_LIBRARY_JUMP_BUFFER
;
126 #elif defined (MDE_CPU_EBC)
128 // EBC context buffer used by SetJump() and LongJump()
136 } BASE_LIBRARY_JUMP_BUFFER
;
139 #error Unknown Processor Type
147 Copies one Null-terminated Unicode string to another Null-terminated Unicode
148 string and returns the new Unicode string.
150 This function copies the contents of the Unicode string Source to the Unicode
151 string Destination, and returns Destination. If Source and Destination
152 overlap, then the results are undefined.
154 If Destination is NULL, then ASSERT().
155 If Source is NULL, then ASSERT().
156 If Source and Destination overlap, then ASSERT().
157 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
158 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
160 @param Destination Pointer to a Null-terminated Unicode string.
161 @param Source Pointer to a Null-terminated Unicode string.
169 OUT CHAR16
*Destination
,
170 IN CONST CHAR16
*Source
174 Copies one Null-terminated Unicode string with a maximum length to another
175 Null-terminated Unicode string with a maximum length and returns the new
178 This function copies the contents of the Unicode string Source to the Unicode
179 string Destination, and returns Destination. At most, Length Unicode
180 characters are copied from Source to Destination. If Length is 0, then
181 Destination is returned unmodified. If Length is greater that the number of
182 Unicode characters in Source, then Destination is padded with Null Unicode
183 characters. If Source and Destination overlap, then the results are
186 If Destination is NULL, then ASSERT().
187 If Source is NULL, then ASSERT().
188 If Source and Destination overlap, then ASSERT().
189 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
190 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
192 @param Destination Pointer to a Null-terminated Unicode string.
193 @param Source Pointer to a Null-terminated Unicode string.
194 @param Length Maximum number of Unicode characters to copy.
202 OUT CHAR16
*Destination
,
203 IN CONST CHAR16
*Source
,
208 Returns the length of a Null-terminated Unicode string.
210 This function returns the number of Unicode characters in the Null-terminated
211 Unicode string specified by String.
213 If String is NULL, then ASSERT().
214 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
215 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
217 @param String Pointer to a Null-terminated Unicode string.
219 @return The length of String.
225 IN CONST CHAR16
*String
229 Returns the size of a Null-terminated Unicode string in bytes, including the
232 This function returns the size, in bytes, of the Null-terminated Unicode
233 string specified by String.
235 If String is NULL, then ASSERT().
236 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
237 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
239 @param String Pointer to a Null-terminated Unicode string.
241 @return The size of String.
247 IN CONST CHAR16
*String
251 Compares two Null-terminated Unicode strings, and returns the difference
252 between the first mismatched Unicode characters.
254 This function compares the Null-terminated Unicode string FirstString to the
255 Null-terminated Unicode string SecondString. If FirstString is identical to
256 SecondString, then 0 is returned. Otherwise, the value returned is the first
257 mismatched Unicode character in SecondString subtracted from the first
258 mismatched Unicode character in FirstString.
260 If FirstString is NULL, then ASSERT().
261 If SecondString is NULL, then ASSERT().
262 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
263 than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
264 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
265 than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
267 @param FirstString Pointer to a Null-terminated Unicode string.
268 @param SecondString Pointer to a Null-terminated Unicode string.
270 @retval 0 FirstString is identical to SecondString.
271 @retval !=0 FirstString is not identical to SecondString.
277 IN CONST CHAR16
*FirstString
,
278 IN CONST CHAR16
*SecondString
282 Compares two Null-terminated Unicode strings with maximum lengths, and
283 returns the difference between the first mismatched Unicode characters.
285 This function compares the Null-terminated Unicode string FirstString to the
286 Null-terminated Unicode string SecondString. At most, Length Unicode
287 characters will be compared. If Length is 0, then 0 is returned. If
288 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
289 value returned is the first mismatched Unicode character in SecondString
290 subtracted from the first mismatched Unicode character in FirstString.
292 If FirstString is NULL, then ASSERT().
293 If SecondString is NULL, then ASSERT().
294 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
295 than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
296 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
297 than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
299 @param FirstString Pointer to a Null-terminated Unicode string.
300 @param SecondString Pointer to a Null-terminated Unicode string.
301 @param Length Maximum number of Unicode characters to compare.
303 @retval 0 FirstString is identical to SecondString.
304 @retval !=0 FirstString is not identical to SecondString.
310 IN CONST CHAR16
*FirstString
,
311 IN CONST CHAR16
*SecondString
,
316 Concatenates one Null-terminated Unicode string to another Null-terminated
317 Unicode string, and returns the concatenated Unicode string.
319 This function concatenates two Null-terminated Unicode strings. The contents
320 of Null-terminated Unicode string Source are concatenated to the end of
321 Null-terminated Unicode string Destination. The Null-terminated concatenated
322 Unicode String is returned. If Source and Destination overlap, then the
323 results are undefined.
325 If Destination is NULL, then ASSERT().
326 If Source is NULL, then ASSERT().
327 If Source and Destination overlap, then ASSERT().
328 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
329 than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
330 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
331 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
332 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
333 and Source results in a Unicode string with more than
334 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
336 @param Destination Pointer to a Null-terminated Unicode string.
337 @param Source Pointer to a Null-terminated Unicode string.
345 IN OUT CHAR16
*Destination
,
346 IN CONST CHAR16
*Source
350 Concatenates one Null-terminated Unicode string with a maximum length to the
351 end of another Null-terminated Unicode string, and returns the concatenated
354 This function concatenates two Null-terminated Unicode strings. The contents
355 of Null-terminated Unicode string Source are concatenated to the end of
356 Null-terminated Unicode string Destination, and Destination is returned. At
357 most, Length Unicode characters are concatenated from Source to the end of
358 Destination, and Destination is always Null-terminated. If Length is 0, then
359 Destination is returned unmodified. If Source and Destination overlap, then
360 the results are undefined.
362 If Destination is NULL, then ASSERT().
363 If Source is NULL, then ASSERT().
364 If Source and Destination overlap, then ASSERT().
365 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
366 than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
367 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
368 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
369 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
370 and Source results in a Unicode string with more than
371 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
373 @param Destination Pointer to a Null-terminated Unicode string.
374 @param Source Pointer to a Null-terminated Unicode string.
375 @param Length Maximum number of Unicode characters to concatenate from
384 IN OUT CHAR16
*Destination
,
385 IN CONST CHAR16
*Source
,
390 Copies one Null-terminated ASCII string to another Null-terminated ASCII
391 string and returns the new ASCII string.
393 This function copies the contents of the ASCII string Source to the ASCII
394 string Destination, and returns Destination. If Source and Destination
395 overlap, then the results are undefined.
397 If Destination is NULL, then ASSERT().
398 If Source is NULL, then ASSERT().
399 If Source and Destination overlap, then ASSERT().
400 If PcdMaximumAsciiStringLength is not zero and Source contains more than
401 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
403 @param Destination Pointer to a Null-terminated ASCII string.
404 @param Source Pointer to a Null-terminated ASCII string.
412 OUT CHAR8
*Destination
,
413 IN CONST CHAR8
*Source
417 Copies one Null-terminated ASCII string with a maximum length to another
418 Null-terminated ASCII string with a maximum length and returns the new ASCII
421 This function copies the contents of the ASCII string Source to the ASCII
422 string Destination, and returns Destination. At most, Length ASCII characters
423 are copied from Source to Destination. If Length is 0, then Destination is
424 returned unmodified. If Length is greater that the number of ASCII characters
425 in Source, then Destination is padded with Null ASCII characters. If Source
426 and Destination overlap, then the results are undefined.
428 If Destination is NULL, then ASSERT().
429 If Source is NULL, then ASSERT().
430 If Source and Destination overlap, then ASSERT().
431 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
432 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
434 @param Destination Pointer to a Null-terminated ASCII string.
435 @param Source Pointer to a Null-terminated ASCII string.
436 @param Length Maximum number of ASCII characters to copy.
444 OUT CHAR8
*Destination
,
445 IN CONST CHAR8
*Source
,
450 Returns the length of a Null-terminated ASCII string.
452 This function returns the number of ASCII characters in the Null-terminated
453 ASCII string specified by String.
455 If String is NULL, then ASSERT().
456 If PcdMaximumAsciiStringLength is not zero and String contains more than
457 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
459 @param String Pointer to a Null-terminated ASCII string.
461 @return The length of String.
467 IN CONST CHAR8
*String
471 Returns the size of a Null-terminated ASCII string in bytes, including the
474 This function returns the size, in bytes, of the Null-terminated ASCII string
477 If String is NULL, then ASSERT().
478 If PcdMaximumAsciiStringLength is not zero and String contains more than
479 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
481 @param String Pointer to a Null-terminated ASCII string.
483 @return The size of String.
489 IN CONST CHAR8
*String
493 Compares two Null-terminated ASCII strings, and returns the difference
494 between the first mismatched ASCII characters.
496 This function compares the Null-terminated ASCII string FirstString to the
497 Null-terminated ASCII string SecondString. If FirstString is identical to
498 SecondString, then 0 is returned. Otherwise, the value returned is the first
499 mismatched ASCII character in SecondString subtracted from the first
500 mismatched ASCII character in FirstString.
502 If FirstString is NULL, then ASSERT().
503 If SecondString is NULL, then ASSERT().
504 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
505 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
506 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
507 than PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
509 @param FirstString Pointer to a Null-terminated ASCII string.
510 @param SecondString Pointer to a Null-terminated ASCII string.
512 @retval 0 FirstString is identical to SecondString.
513 @retval !=0 FirstString is not identical to SecondString.
519 IN CONST CHAR8
*FirstString
,
520 IN CONST CHAR8
*SecondString
524 Performs a case insensitive comparison of two Null-terminated ASCII strings,
525 and returns the difference between the first mismatched ASCII characters.
527 This function performs a case insensitive comparison of the Null-terminated
528 ASCII string FirstString to the Null-terminated ASCII string SecondString. If
529 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
530 value returned is the first mismatched lower case ASCII character in
531 SecondString subtracted from the first mismatched lower case ASCII character
534 If FirstString is NULL, then ASSERT().
535 If SecondString is NULL, then ASSERT().
536 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
537 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
538 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
539 than PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
541 @param FirstString Pointer to a Null-terminated ASCII string.
542 @param SecondString Pointer to a Null-terminated ASCII string.
544 @retval 0 FirstString is identical to SecondString using case insensitive
546 @retval !=0 FirstString is not identical to SecondString using case
547 insensitive comparisons.
553 IN CONST CHAR8
*FirstString
,
554 IN CONST CHAR8
*SecondString
558 Compares two Null-terminated ASCII strings with maximum lengths, and returns
559 the difference between the first mismatched ASCII characters.
561 This function compares the Null-terminated ASCII string FirstString to the
562 Null-terminated ASCII string SecondString. At most, Length ASCII characters
563 will be compared. If Length is 0, then 0 is returned. If FirstString is
564 identical to SecondString, then 0 is returned. Otherwise, the value returned
565 is the first mismatched ASCII character in SecondString subtracted from the
566 first mismatched ASCII character in FirstString.
568 If FirstString is NULL, then ASSERT().
569 If SecondString is NULL, then ASSERT().
570 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
571 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
572 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
573 than PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
575 @param FirstString Pointer to a Null-terminated ASCII string.
576 @param SecondString Pointer to a Null-terminated ASCII string.
578 @retval 0 FirstString is identical to SecondString.
579 @retval !=0 FirstString is not identical to SecondString.
585 IN CONST CHAR8
*FirstString
,
586 IN CONST CHAR8
*SecondString
,
591 Concatenates one Null-terminated ASCII string to another Null-terminated
592 ASCII string, and returns the concatenated ASCII string.
594 This function concatenates two Null-terminated ASCII strings. The contents of
595 Null-terminated ASCII string Source are concatenated to the end of Null-
596 terminated ASCII string Destination. The Null-terminated concatenated ASCII
599 If Destination is NULL, then ASSERT().
600 If Source is NULL, then ASSERT().
601 If PcdMaximumAsciiStringLength is not zero and Destination contains more than
602 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
603 If PcdMaximumAsciiStringLength is not zero and Source contains more than
604 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
605 If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
606 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
607 ASCII characters, then ASSERT().
609 @param Destination Pointer to a Null-terminated ASCII string.
610 @param Source Pointer to a Null-terminated ASCII string.
618 IN OUT CHAR8
*Destination
,
619 IN CONST CHAR8
*Source
623 Concatenates one Null-terminated ASCII string with a maximum length to the
624 end of another Null-terminated ASCII string, and returns the concatenated
627 This function concatenates two Null-terminated ASCII strings. The contents
628 of Null-terminated ASCII string Source are concatenated to the end of Null-
629 terminated ASCII string Destination, and Destination is returned. At most,
630 Length ASCII characters are concatenated from Source to the end of
631 Destination, and Destination is always Null-terminated. If Length is 0, then
632 Destination is returned unmodified. If Source and Destination overlap, then
633 the results are undefined.
635 If Destination is NULL, then ASSERT().
636 If Source is NULL, then ASSERT().
637 If Source and Destination overlap, then ASSERT().
638 If PcdMaximumAsciiStringLength is not zero, and Destination contains more
639 than PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
640 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
641 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
642 If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
643 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
644 ASCII characters, then ASSERT().
646 @param Destination Pointer to a Null-terminated ASCII string.
647 @param Source Pointer to a Null-terminated ASCII string.
648 @param Length Maximum number of ASCII characters to concatenate from
657 IN OUT CHAR8
*Destination
,
658 IN CONST CHAR8
*Source
,
663 // LIST_ENTRY definition
665 typedef struct _LIST_ENTRY LIST_ENTRY
;
668 LIST_ENTRY
*ForwardLink
;
669 LIST_ENTRY
*BackLink
;
673 // Linked List Functions and Macros
677 Initializes the head node of a doubly linked list that is declared as a
678 global variable in a module.
680 Initializes the forward and backward links of a new linked list. After
681 initializing a linked list with this macro, the other linked list functions
682 may be used to add and remove nodes from the linked list. This macro results
683 in smaller executables by initializing the linked list in the data section,
684 instead if calling the InitializeListHead() function to perform the
685 equivalent operation.
687 @param ListHead The head note of a list to initiailize.
690 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&ListHead, &ListHead}
693 Initializes the head node of a doubly linked list, and returns the pointer to
694 the head node of the doubly linked list.
696 Initializes the forward and backward links of a new linked list. After
697 initializing a linked list with this function, the other linked list
698 functions may be used to add and remove nodes from the linked list. It is up
699 to the caller of this function to allocate the memory for ListHead.
701 If ListHead is NULL, then ASSERT().
703 @param ListHead A pointer to the head node of a new doubly linked list.
711 IN LIST_ENTRY
*ListHead
715 Adds a node to the beginning of a doubly linked list, and returns the pointer
716 to the head node of the doubly linked list.
718 Adds the node Entry at the beginning of the doubly linked list denoted by
719 ListHead, and returns ListHead.
721 If ListHead is NULL, then ASSERT().
722 If Entry is NULL, then ASSERT().
723 If ListHead was not initialized with InitializeListHead(), then ASSERT().
724 If PcdMaximumLinkedListLenth is not zero, and ListHead contains more than
725 PcdMaximumLinkedListLenth nodes, then ASSERT().
727 @param ListHead A pointer to the head node of a doubly linked list.
728 @param Entry A pointer to a node that is to be inserted at the beginning
729 of a doubly linked list.
737 IN LIST_ENTRY
*ListHead
,
742 Adds a node to the end of a doubly linked list, and returns the pointer to
743 the head node of the doubly linked list.
745 Adds the node Entry to the end of the doubly linked list denoted by ListHead,
746 and returns ListHead.
748 If ListHead is NULL, then ASSERT().
749 If Entry is NULL, then ASSERT().
750 If ListHead was not initialized with InitializeListHead(), then ASSERT().
751 If PcdMaximumLinkedListLenth is not zero, and ListHead contains more than
752 PcdMaximumLinkedListLenth nodes, then ASSERT().
754 @param ListHead A pointer to the head node of a doubly linked list.
755 @param Entry A pointer to a node that is to be added at the end of the
764 IN LIST_ENTRY
*ListHead
,
769 Retrieves the first node of a doubly linked list.
771 Returns the first node of a doubly linked list. List must have been
772 initialized with InitializeListHead(). If List is empty, then NULL is
775 If List is NULL, then ASSERT().
776 If List was not initialized with InitializeListHead(), then ASSERT().
777 If PcdMaximumLinkedListLenth is not zero, and List contains more than
778 PcdMaximumLinkedListLenth nodes, then ASSERT().
780 @param List A pointer to the head node of a doubly linked list.
782 @return The first node of a doubly linked list.
783 @retval NULL The list is empty.
789 IN CONST LIST_ENTRY
*List
793 Retrieves the next node of a doubly linked list.
795 Returns the node of a doubly linked list that follows Node. List must have
796 been initialized with InitializeListHead(). If List is empty, then List is
799 If List is NULL, then ASSERT().
800 If Node is NULL, then ASSERT().
801 If List was not initialized with InitializeListHead(), then ASSERT().
802 If PcdMaximumLinkedListLenth is not zero, and List contains more than
803 PcdMaximumLinkedListLenth nodes, then ASSERT().
804 If Node is not a node in List, then ASSERT().
806 @param List A pointer to the head node of a doubly linked list.
807 @param Node A pointer to a node in the doubly linked list.
809 @return Pointer to the next node if one exists. Otherwise a null value which
810 is actually List is returned.
816 IN CONST LIST_ENTRY
*List
,
817 IN CONST LIST_ENTRY
*Node
821 Checks to see if a doubly linked list is empty or not.
823 Checks to see if the doubly linked list is empty. If the linked list contains
824 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
826 If ListHead is NULL, then ASSERT().
827 If ListHead was not initialized with InitializeListHead(), then ASSERT().
828 If PcdMaximumLinkedListLenth is not zero, and List contains more than
829 PcdMaximumLinkedListLenth nodes, then ASSERT().
831 @param ListHead A pointer to the head node of a doubly linked list.
833 @retval TRUE The linked list is empty.
834 @retval FALSE The linked list is not empty.
840 IN CONST LIST_ENTRY
*ListHead
844 Determines if a node in a doubly linked list is null.
846 Returns FALSE if Node is one of the nodes in the doubly linked list specified
847 by List. Otherwise, TRUE is returned. List must have been initialized with
848 InitializeListHead().
850 If List is NULL, then ASSERT().
851 If Node is NULL, then ASSERT().
852 If List was not initialized with InitializeListHead(), then ASSERT().
853 If PcdMaximumLinkedListLenth is not zero, and List contains more than
854 PcdMaximumLinkedListLenth nodes, then ASSERT().
855 If Node is not a node in List and Node is not equal to List, then ASSERT().
857 @param List A pointer to the head node of a doubly linked list.
858 @param Node A pointer to a node in the doubly linked list.
860 @retval TRUE Node is one of the nodes in the doubly linked list.
861 @retval FALSE Node is not one of the nodes in the doubly linked list.
867 IN CONST LIST_ENTRY
*List
,
868 IN CONST LIST_ENTRY
*Node
872 Determines if a node the last node in a doubly linked list.
874 Returns TRUE if Node is the last node in the doubly linked list specified by
875 List. Otherwise, FALSE is returned. List must have been initialized with
876 InitializeListHead().
878 If List is NULL, then ASSERT().
879 If Node is NULL, then ASSERT().
880 If List was not initialized with InitializeListHead(), then ASSERT().
881 If PcdMaximumLinkedListLenth is not zero, and List contains more than
882 PcdMaximumLinkedListLenth nodes, then ASSERT().
883 If Node is not a node in List, then ASSERT().
885 @param List A pointer to the head node of a doubly linked list.
886 @param Node A pointer to a node in the doubly linked list.
888 @retval TRUE Node is the last node in the linked list.
889 @retval FALSE Node is not the last node in the linked list.
895 IN CONST LIST_ENTRY
*List
,
896 IN CONST LIST_ENTRY
*Node
900 Swaps the location of two nodes in a doubly linked list, and returns the
901 first node after the swap.
903 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
904 Otherwise, the location of the FirstEntry node is swapped with the location
905 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
906 same double linked list as FirstEntry and that double linked list must have
907 been initialized with InitializeListHead(). SecondEntry is returned after the
910 If FirstEntry is NULL, then ASSERT().
911 If SecondEntry is NULL, then ASSERT().
912 If SecondEntry and FirstEntry are not in the same linked list, then ASSERT().
913 If PcdMaximumLinkedListLenth is not zero, and the linked list containing
914 FirstEntry and SecondEntry contains more than PcdMaximumLinkedListLenth
915 nodes, then ASSERT().
917 @param FirstEntry A pointer to a node in a linked list.
918 @param SecondEntry A pointer to another node in the same linked list.
924 IN LIST_ENTRY
*FirstEntry
,
925 IN LIST_ENTRY
*SecondEntry
929 Removes a node from a doubly linked list, and returns the node that follows
932 Removes the node Entry from a doubly linked list. It is up to the caller of
933 this function to release the memory used by this node if that is required. On
934 exit, the node following Entry in the doubly linked list is returned. If
935 Entry is the only node in the linked list, then the head node of the linked
938 If Entry is NULL, then ASSERT().
939 If Entry is the head node of an empty list, then ASSERT().
940 If PcdMaximumLinkedListLenth is not zero, and the linked list containing
941 Entry contains more than PcdMaximumLinkedListLenth nodes, then ASSERT().
943 @param Entry A pointer to a node in a linked list
951 IN CONST LIST_ENTRY
*Entry
959 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
960 with zeros. The shifted value is returned.
962 This function shifts the 64-bit value Operand to the left by Count bits. The
963 low Count bits are set to zero. The shifted value is returned.
965 If Count is greater than 63, then ASSERT().
967 @param Operand The 64-bit operand to shift left.
968 @param Count The number of bits to shift left.
970 @return Operand << Count
981 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
982 filled with zeros. The shifted value is returned.
984 This function shifts the 64-bit value Operand to the right by Count bits. The
985 high Count bits are set to zero. The shifted value is returned.
987 If Count is greater than 63, then ASSERT().
989 @param Operand The 64-bit operand to shift right.
990 @param Count The number of bits to shift right.
992 @return Operand >> Count
1003 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
1004 with original integer's bit 63. The shifted value is returned.
1006 This function shifts the 64-bit value Operand to the right by Count bits. The
1007 high Count bits are set to bit 63 of Operand. The shifted value is returned.
1009 If Count is greater than 63, then ASSERT().
1011 @param Operand The 64-bit operand to shift right.
1012 @param Count The number of bits to shift right.
1014 @return Operand >> Count
1025 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
1026 with the high bits that were rotated.
1028 This function rotates the 32-bit value Operand to the left by Count bits. The
1029 low Count bits are fill with the high Count bits of Operand. The rotated
1032 If Count is greater than 31, then ASSERT().
1034 @param Operand The 32-bit operand to rotate left.
1035 @param Count The number of bits to rotate left.
1037 @return Operand <<< Count
1048 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
1049 with the low bits that were rotated.
1051 This function rotates the 32-bit value Operand to the right by Count bits.
1052 The high Count bits are fill with the low Count bits of Operand. The rotated
1055 If Count is greater than 31, then ASSERT().
1057 @param Operand The 32-bit operand to rotate right.
1058 @param Count The number of bits to rotate right.
1060 @return Operand >>> Count
1071 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
1072 with the high bits that were rotated.
1074 This function rotates the 64-bit value Operand to the left by Count bits. The
1075 low Count bits are fill with the high Count bits of Operand. The rotated
1078 If Count is greater than 63, then ASSERT().
1080 @param Operand The 64-bit operand to rotate left.
1081 @param Count The number of bits to rotate left.
1083 @return Operand <<< Count
1094 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
1095 with the high low bits that were rotated.
1097 This function rotates the 64-bit value Operand to the right by Count bits.
1098 The high Count bits are fill with the low Count bits of Operand. The rotated
1101 If Count is greater than 63, then ASSERT().
1103 @param Operand The 64-bit operand to rotate right.
1104 @param Count The number of bits to rotate right.
1106 @return Operand >>> Count
1117 Returns the bit position of the lowest bit set in a 32-bit value.
1119 This function computes the bit position of the lowest bit set in the 32-bit
1120 value specified by Operand. If Operand is zero, then -1 is returned.
1121 Otherwise, a value between 0 and 31 is returned.
1123 @param Operand The 32-bit operand to evaluate.
1125 @return Position of the lowest bit set in Operand if found.
1126 @retval -1 Operand is zero.
1136 Returns the bit position of the lowest bit set in a 64-bit value.
1138 This function computes the bit position of the lowest bit set in the 64-bit
1139 value specified by Operand. If Operand is zero, then -1 is returned.
1140 Otherwise, a value between 0 and 63 is returned.
1142 @param Operand The 64-bit operand to evaluate.
1144 @return Position of the lowest bit set in Operand if found.
1145 @retval -1 Operand is zero.
1155 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
1158 This function computes the bit position of the highest bit set in the 32-bit
1159 value specified by Operand. If Operand is zero, then -1 is returned.
1160 Otherwise, a value between 0 and 31 is returned.
1162 @param Operand The 32-bit operand to evaluate.
1164 @return Position of the highest bit set in Operand if found.
1165 @retval -1 Operand is zero.
1175 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
1178 This function computes the bit position of the highest bit set in the 64-bit
1179 value specified by Operand. If Operand is zero, then -1 is returned.
1180 Otherwise, a value between 0 and 63 is returned.
1182 @param Operand The 64-bit operand to evaluate.
1184 @return Position of the highest bit set in Operand if found.
1185 @retval -1 Operand is zero.
1195 Returns the value of the highest bit set in a 32-bit value. Equivalent to
1196 1 << HighBitSet32(x).
1198 This function computes the value of the highest bit set in the 32-bit value
1199 specified by Operand. If Operand is zero, then zero is returned.
1201 @param Operand The 32-bit operand to evaluate.
1203 @return 1 << HighBitSet32(Operand)
1204 @retval 0 Operand is zero.
1214 Returns the value of the highest bit set in a 64-bit value. Equivalent to
1215 1 << HighBitSet64(x).
1217 This function computes the value of the highest bit set in the 64-bit value
1218 specified by Operand. If Operand is zero, then zero is returned.
1220 @param Operand The 64-bit operand to evaluate.
1222 @return 1 << HighBitSet64(Operand)
1223 @retval 0 Operand is zero.
1233 Switches the endianess of a 16-bit integer.
1235 This function swaps the bytes in a 16-bit unsigned value to switch the value
1236 from little endian to big endian or vice versa. The byte swapped value is
1239 @param Operand A 16-bit unsigned value.
1241 @return The byte swaped Operand.
1251 Switches the endianess of a 32-bit integer.
1253 This function swaps the bytes in a 32-bit unsigned value to switch the value
1254 from little endian to big endian or vice versa. The byte swapped value is
1257 @param Operand A 32-bit unsigned value.
1259 @return The byte swaped Operand.
1269 Switches the endianess of a 64-bit integer.
1271 This function swaps the bytes in a 64-bit unsigned value to switch the value
1272 from little endian to big endian or vice versa. The byte swapped value is
1275 @param Operand A 64-bit unsigned value.
1277 @return The byte swaped Operand.
1287 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
1288 generates a 64-bit unsigned result.
1290 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
1291 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1292 bit unsigned result is returned.
1294 If the result overflows, then ASSERT().
1296 @param Multiplicand A 64-bit unsigned value.
1297 @param Multiplier A 32-bit unsigned value.
1299 @return Multiplicand * Multiplier
1305 IN UINT64 Multiplicand
,
1306 IN UINT32 Multiplier
1310 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
1311 generates a 64-bit unsigned result.
1313 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
1314 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1315 bit unsigned result is returned.
1317 If the result overflows, then ASSERT().
1319 @param Multiplicand A 64-bit unsigned value.
1320 @param Multiplier A 64-bit unsigned value.
1322 @return Multiplicand * Multiplier
1328 IN UINT64 Multiplicand
,
1329 IN UINT64 Multiplier
1333 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
1334 64-bit signed result.
1336 This function multiples the 64-bit signed value Multiplicand by the 64-bit
1337 signed value Multiplier and generates a 64-bit signed result. This 64-bit
1338 signed result is returned.
1340 If the result overflows, then ASSERT().
1342 @param Multiplicand A 64-bit signed value.
1343 @param Multiplier A 64-bit signed value.
1345 @return Multiplicand * Multiplier
1351 IN INT64 Multiplicand
,
1356 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1357 a 64-bit unsigned result.
1359 This function divides the 64-bit unsigned value Dividend by the 32-bit
1360 unsigned value Divisor and generates a 64-bit unsigned quotient. This
1361 function returns the 64-bit unsigned quotient.
1363 If Divisor is 0, then ASSERT().
1365 @param Dividend A 64-bit unsigned value.
1366 @param Divisor A 32-bit unsigned value.
1368 @return Dividend / Divisor
1379 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1380 a 32-bit unsigned remainder.
1382 This function divides the 64-bit unsigned value Dividend by the 32-bit
1383 unsigned value Divisor and generates a 32-bit remainder. This function
1384 returns the 32-bit unsigned remainder.
1386 If Divisor is 0, then ASSERT().
1388 @param Dividend A 64-bit unsigned value.
1389 @param Divisor A 32-bit unsigned value.
1391 @return Dividend % Divisor
1402 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1403 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
1405 This function divides the 64-bit unsigned value Dividend by the 32-bit
1406 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
1407 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
1408 This function returns the 64-bit unsigned quotient.
1410 If Divisor is 0, then ASSERT().
1412 @param Dividend A 64-bit unsigned value.
1413 @param Divisor A 32-bit unsigned value.
1414 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
1415 optional and may be NULL.
1417 @return Dividend / Divisor
1422 DivU64x32Remainder (
1425 OUT UINT32
*Remainder OPTIONAL
1429 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
1430 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
1432 This function divides the 64-bit unsigned value Dividend by the 64-bit
1433 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
1434 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
1435 This function returns the 64-bit unsigned quotient.
1437 If Divisor is 0, then ASSERT().
1439 @param Dividend A 64-bit unsigned value.
1440 @param Divisor A 64-bit unsigned value.
1441 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
1442 optional and may be NULL.
1444 @return Dividend / Divisor
1449 DivU64x64Remainder (
1452 OUT UINT64
*Remainder OPTIONAL
1456 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
1457 64-bit signed result and a optional 64-bit signed remainder.
1459 This function divides the 64-bit signed value Dividend by the 64-bit signed
1460 value Divisor and generates a 64-bit signed quotient. If Remainder is not
1461 NULL, then the 64-bit signed remainder is returned in Remainder. This
1462 function returns the 64-bit signed quotient.
1464 If Divisor is 0, then ASSERT().
1466 @param Dividend A 64-bit signed value.
1467 @param Divisor A 64-bit signed value.
1468 @param Remainder A pointer to a 64-bit signed value. This parameter is
1469 optional and may be NULL.
1471 @return Dividend / Divisor
1476 DivS64x64Remainder (
1479 OUT INT64
*Remainder OPTIONAL
1483 Reads a 16-bit value from memory that may be unaligned.
1485 This function returns the 16-bit value pointed to by Buffer. The function
1486 guarantees that the read operation does not produce an alignment fault.
1488 If the Buffer is NULL, then ASSERT().
1490 @param Buffer Pointer to a 16-bit value that may be unaligned.
1498 IN CONST UINT16
*Uint16
1502 Writes a 16-bit value to memory that may be unaligned.
1504 This function writes the 16-bit value specified by Value to Buffer. Value is
1505 returned. The function guarantees that the write operation does not produce
1508 If the Buffer is NULL, then ASSERT().
1510 @param Buffer Pointer to a 16-bit value that may be unaligned.
1511 @param Value 16-bit value to write to Buffer.
1524 Reads a 24-bit value from memory that may be unaligned.
1526 This function returns the 24-bit value pointed to by Buffer. The function
1527 guarantees that the read operation does not produce an alignment fault.
1529 If the Buffer is NULL, then ASSERT().
1531 @param Buffer Pointer to a 24-bit value that may be unaligned.
1533 @return The value read.
1539 IN CONST UINT32
*Buffer
1543 Writes a 24-bit value to memory that may be unaligned.
1545 This function writes the 24-bit value specified by Value to Buffer. Value is
1546 returned. The function guarantees that the write operation does not produce
1549 If the Buffer is NULL, then ASSERT().
1551 @param Buffer Pointer to a 24-bit value that may be unaligned.
1552 @param Value 24-bit value to write to Buffer.
1554 @return The value written.
1565 Reads a 32-bit value from memory that may be unaligned.
1567 This function returns the 32-bit value pointed to by Buffer. The function
1568 guarantees that the read operation does not produce an alignment fault.
1570 If the Buffer is NULL, then ASSERT().
1572 @param Buffer Pointer to a 32-bit value that may be unaligned.
1580 IN CONST UINT32
*Uint32
1584 Writes a 32-bit value to memory that may be unaligned.
1586 This function writes the 32-bit value specified by Value to Buffer. Value is
1587 returned. The function guarantees that the write operation does not produce
1590 If the Buffer is NULL, then ASSERT().
1592 @param Buffer Pointer to a 32-bit value that may be unaligned.
1593 @param Value 32-bit value to write to Buffer.
1606 Reads a 64-bit value from memory that may be unaligned.
1608 This function returns the 64-bit value pointed to by Buffer. The function
1609 guarantees that the read operation does not produce an alignment fault.
1611 If the Buffer is NULL, then ASSERT().
1613 @param Buffer Pointer to a 64-bit value that may be unaligned.
1621 IN CONST UINT64
*Uint64
1625 Writes a 64-bit value to memory that may be unaligned.
1627 This function writes the 64-bit value specified by Value to Buffer. Value is
1628 returned. The function guarantees that the write operation does not produce
1631 If the Buffer is NULL, then ASSERT().
1633 @param Buffer Pointer to a 64-bit value that may be unaligned.
1634 @param Value 64-bit value to write to Buffer.
1647 // Bit Field Functions
1651 Returns a bit field from an 8-bit value.
1653 Returns the bitfield specified by the StartBit and the EndBit from Operand.
1655 If 8-bit operations are not supported, then ASSERT().
1656 If StartBit is greater than 7, then ASSERT().
1657 If EndBit is greater than 7, then ASSERT().
1658 If EndBit is less than or equal to StartBit, then ASSERT().
1660 @param Operand Operand on which to perform the bitfield operation.
1661 @param StartBit The ordinal of the least significant bit in the bit field.
1663 @param EndBit The ordinal of the most significant bit in the bit field.
1666 @return The bit field read.
1678 Writes a bit field to an 8-bit value, and returns the result.
1680 Writes Value to the bit field specified by the StartBit and the EndBit in
1681 Operand. All other bits in Operand are preserved. The new 8-bit value is
1684 If 8-bit operations are not supported, then ASSERT().
1685 If StartBit is greater than 7, then ASSERT().
1686 If EndBit is greater than 7, then ASSERT().
1687 If EndBit is less than or equal to StartBit, then ASSERT().
1689 @param Operand Operand on which to perform the bitfield operation.
1690 @param StartBit The ordinal of the least significant bit in the bit field.
1692 @param EndBit The ordinal of the most significant bit in the bit field.
1694 @param Value New value of the bit field.
1696 @return The new 8-bit value.
1709 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
1712 Performs a bitwise inclusive OR between the bit field specified by StartBit
1713 and EndBit in Operand and the value specified by OrData. All other bits in
1714 Operand are preserved. The new 8-bit value is returned.
1716 If 8-bit operations are not supported, then ASSERT().
1717 If StartBit is greater than 7, then ASSERT().
1718 If EndBit is greater than 7, then ASSERT().
1719 If EndBit is less than or equal to StartBit, then ASSERT().
1721 @param Operand Operand on which to perform the bitfield operation.
1722 @param StartBit The ordinal of the least significant bit in the bit field.
1724 @param EndBit The ordinal of the most significant bit in the bit field.
1726 @param OrData The value to OR with the read value from the value
1728 @return The new 8-bit value.
1741 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
1744 Performs a bitwise AND between the bit field specified by StartBit and EndBit
1745 in Operand and the value specified by AndData. All other bits in Operand are
1746 preserved. The new 8-bit value is returned.
1748 If 8-bit operations are not supported, then ASSERT().
1749 If StartBit is greater than 7, then ASSERT().
1750 If EndBit is greater than 7, then ASSERT().
1751 If EndBit is less than or equal to StartBit, then ASSERT().
1753 @param Operand Operand on which to perform the bitfield operation.
1754 @param StartBit The ordinal of the least significant bit in the bit field.
1756 @param EndBit The ordinal of the most significant bit in the bit field.
1758 @param AndData The value to AND with the read value from the value.
1760 @return The new 8-bit value.
1773 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
1774 bitwise OR, and returns the result.
1776 Performs a bitwise AND between the bit field specified by StartBit and EndBit
1777 in Operand and the value specified by AndData, followed by a bitwise
1778 inclusive OR with value specified by OrData. All other bits in Operand are
1779 preserved. The new 8-bit value is returned.
1781 If 8-bit operations are not supported, then ASSERT().
1782 If StartBit is greater than 7, then ASSERT().
1783 If EndBit is greater than 7, then ASSERT().
1784 If EndBit is less than or equal to StartBit, then ASSERT().
1786 @param Operand Operand on which to perform the bitfield operation.
1787 @param StartBit The ordinal of the least significant bit in the bit field.
1789 @param EndBit The ordinal of the most significant bit in the bit field.
1791 @param AndData The value to AND with the read value from the value.
1792 @param OrData The value to OR with the result of the AND operation.
1794 @return The new 8-bit value.
1799 BitFieldAndThenOr8 (
1808 Returns a bit field from a 16-bit value.
1810 Returns the bitfield specified by the StartBit and the EndBit from Operand.
1812 If 16-bit operations are not supported, then ASSERT().
1813 If StartBit is greater than 15, then ASSERT().
1814 If EndBit is greater than 15, then ASSERT().
1815 If EndBit is less than or equal to StartBit, then ASSERT().
1817 @param Operand Operand on which to perform the bitfield operation.
1818 @param StartBit The ordinal of the least significant bit in the bit field.
1820 @param EndBit The ordinal of the most significant bit in the bit field.
1823 @return The bit field read.
1835 Writes a bit field to a 16-bit value, and returns the result.
1837 Writes Value to the bit field specified by the StartBit and the EndBit in
1838 Operand. All other bits in Operand are preserved. The new 16-bit value is
1841 If 16-bit operations are not supported, then ASSERT().
1842 If StartBit is greater than 15, then ASSERT().
1843 If EndBit is greater than 15, then ASSERT().
1844 If EndBit is less than or equal to StartBit, then ASSERT().
1846 @param Operand Operand on which to perform the bitfield operation.
1847 @param StartBit The ordinal of the least significant bit in the bit field.
1849 @param EndBit The ordinal of the most significant bit in the bit field.
1851 @param Value New value of the bit field.
1853 @return The new 16-bit value.
1866 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
1869 Performs a bitwise inclusive OR between the bit field specified by StartBit
1870 and EndBit in Operand and the value specified by OrData. All other bits in
1871 Operand are preserved. The new 16-bit value is returned.
1873 If 16-bit operations are not supported, then ASSERT().
1874 If StartBit is greater than 15, then ASSERT().
1875 If EndBit is greater than 15, then ASSERT().
1876 If EndBit is less than or equal to StartBit, then ASSERT().
1878 @param Operand Operand on which to perform the bitfield operation.
1879 @param StartBit The ordinal of the least significant bit in the bit field.
1881 @param EndBit The ordinal of the most significant bit in the bit field.
1883 @param OrData The value to OR with the read value from the value
1885 @return The new 16-bit value.
1898 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
1901 Performs a bitwise AND between the bit field specified by StartBit and EndBit
1902 in Operand and the value specified by AndData. All other bits in Operand are
1903 preserved. The new 16-bit value is returned.
1905 If 16-bit operations are not supported, then ASSERT().
1906 If StartBit is greater than 15, then ASSERT().
1907 If EndBit is greater than 15, then ASSERT().
1908 If EndBit is less than or equal to StartBit, then ASSERT().
1910 @param Operand Operand on which to perform the bitfield operation.
1911 @param StartBit The ordinal of the least significant bit in the bit field.
1913 @param EndBit The ordinal of the most significant bit in the bit field.
1915 @param AndData The value to AND with the read value from the value
1917 @return The new 16-bit value.
1930 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
1931 bitwise OR, and returns the result.
1933 Performs a bitwise AND between the bit field specified by StartBit and EndBit
1934 in Operand and the value specified by AndData, followed by a bitwise
1935 inclusive OR with value specified by OrData. All other bits in Operand are
1936 preserved. The new 16-bit value is returned.
1938 If 16-bit operations are not supported, then ASSERT().
1939 If StartBit is greater than 15, then ASSERT().
1940 If EndBit is greater than 15, then ASSERT().
1941 If EndBit is less than or equal to StartBit, then ASSERT().
1943 @param Operand Operand on which to perform the bitfield operation.
1944 @param StartBit The ordinal of the least significant bit in the bit field.
1946 @param EndBit The ordinal of the most significant bit in the bit field.
1948 @param AndData The value to AND with the read value from the value.
1949 @param OrData The value to OR with the result of the AND operation.
1951 @return The new 16-bit value.
1956 BitFieldAndThenOr16 (
1965 Returns a bit field from a 32-bit value.
1967 Returns the bitfield specified by the StartBit and the EndBit from Operand.
1969 If 32-bit operations are not supported, then ASSERT().
1970 If StartBit is greater than 31, then ASSERT().
1971 If EndBit is greater than 31, then ASSERT().
1972 If EndBit is less than or equal to StartBit, then ASSERT().
1974 @param Operand Operand on which to perform the bitfield operation.
1975 @param StartBit The ordinal of the least significant bit in the bit field.
1977 @param EndBit The ordinal of the most significant bit in the bit field.
1980 @return The bit field read.
1992 Writes a bit field to a 32-bit value, and returns the result.
1994 Writes Value to the bit field specified by the StartBit and the EndBit in
1995 Operand. All other bits in Operand are preserved. The new 32-bit value is
1998 If 32-bit operations are not supported, then ASSERT().
1999 If StartBit is greater than 31, then ASSERT().
2000 If EndBit is greater than 31, then ASSERT().
2001 If EndBit is less than or equal to StartBit, then ASSERT().
2003 @param Operand Operand on which to perform the bitfield operation.
2004 @param StartBit The ordinal of the least significant bit in the bit field.
2006 @param EndBit The ordinal of the most significant bit in the bit field.
2008 @param Value New value of the bit field.
2010 @return The new 32-bit value.
2023 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
2026 Performs a bitwise inclusive OR between the bit field specified by StartBit
2027 and EndBit in Operand and the value specified by OrData. All other bits in
2028 Operand are preserved. The new 32-bit value is returned.
2030 If 32-bit operations are not supported, then ASSERT().
2031 If StartBit is greater than 31, then ASSERT().
2032 If EndBit is greater than 31, then ASSERT().
2033 If EndBit is less than or equal to StartBit, then ASSERT().
2035 @param Operand Operand on which to perform the bitfield operation.
2036 @param StartBit The ordinal of the least significant bit in the bit field.
2038 @param EndBit The ordinal of the most significant bit in the bit field.
2040 @param OrData The value to OR with the read value from the value
2042 @return The new 32-bit value.
2055 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
2058 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2059 in Operand and the value specified by AndData. All other bits in Operand are
2060 preserved. The new 32-bit value is returned.
2062 If 32-bit operations are not supported, then ASSERT().
2063 If StartBit is greater than 31, then ASSERT().
2064 If EndBit is greater than 31, then ASSERT().
2065 If EndBit is less than or equal to StartBit, then ASSERT().
2067 @param Operand Operand on which to perform the bitfield operation.
2068 @param StartBit The ordinal of the least significant bit in the bit field.
2070 @param EndBit The ordinal of the most significant bit in the bit field.
2072 @param AndData The value to AND with the read value from the value
2074 @return The new 32-bit value.
2087 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
2088 bitwise OR, and returns the result.
2090 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2091 in Operand and the value specified by AndData, followed by a bitwise
2092 inclusive OR with value specified by OrData. All other bits in Operand are
2093 preserved. The new 32-bit value is returned.
2095 If 32-bit operations are not supported, then ASSERT().
2096 If StartBit is greater than 31, then ASSERT().
2097 If EndBit is greater than 31, then ASSERT().
2098 If EndBit is less than or equal to StartBit, then ASSERT().
2100 @param Operand Operand on which to perform the bitfield operation.
2101 @param StartBit The ordinal of the least significant bit in the bit field.
2103 @param EndBit The ordinal of the most significant bit in the bit field.
2105 @param AndData The value to AND with the read value from the value.
2106 @param OrData The value to OR with the result of the AND operation.
2108 @return The new 32-bit value.
2113 BitFieldAndThenOr32 (
2122 Returns a bit field from a 64-bit value.
2124 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2126 If 64-bit operations are not supported, then ASSERT().
2127 If StartBit is greater than 63, then ASSERT().
2128 If EndBit is greater than 63, then ASSERT().
2129 If EndBit is less than or equal to StartBit, then ASSERT().
2131 @param Operand Operand on which to perform the bitfield operation.
2132 @param StartBit The ordinal of the least significant bit in the bit field.
2134 @param EndBit The ordinal of the most significant bit in the bit field.
2137 @return The bit field read.
2149 Writes a bit field to a 64-bit value, and returns the result.
2151 Writes Value to the bit field specified by the StartBit and the EndBit in
2152 Operand. All other bits in Operand are preserved. The new 64-bit value is
2155 If 64-bit operations are not supported, then ASSERT().
2156 If StartBit is greater than 63, then ASSERT().
2157 If EndBit is greater than 63, then ASSERT().
2158 If EndBit is less than or equal to StartBit, then ASSERT().
2160 @param Operand Operand on which to perform the bitfield operation.
2161 @param StartBit The ordinal of the least significant bit in the bit field.
2163 @param EndBit The ordinal of the most significant bit in the bit field.
2165 @param Value New value of the bit field.
2167 @return The new 64-bit value.
2180 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
2183 Performs a bitwise inclusive OR between the bit field specified by StartBit
2184 and EndBit in Operand and the value specified by OrData. All other bits in
2185 Operand are preserved. The new 64-bit value is returned.
2187 If 64-bit operations are not supported, then ASSERT().
2188 If StartBit is greater than 63, then ASSERT().
2189 If EndBit is greater than 63, then ASSERT().
2190 If EndBit is less than or equal to StartBit, then ASSERT().
2192 @param Operand Operand on which to perform the bitfield operation.
2193 @param StartBit The ordinal of the least significant bit in the bit field.
2195 @param EndBit The ordinal of the most significant bit in the bit field.
2197 @param OrData The value to OR with the read value from the value
2199 @return The new 64-bit value.
2212 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
2215 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2216 in Operand and the value specified by AndData. All other bits in Operand are
2217 preserved. The new 64-bit value is returned.
2219 If 64-bit operations are not supported, then ASSERT().
2220 If StartBit is greater than 63, then ASSERT().
2221 If EndBit is greater than 63, then ASSERT().
2222 If EndBit is less than or equal to StartBit, then ASSERT().
2224 @param Operand Operand on which to perform the bitfield operation.
2225 @param StartBit The ordinal of the least significant bit in the bit field.
2227 @param EndBit The ordinal of the most significant bit in the bit field.
2229 @param AndData The value to AND with the read value from the value
2231 @return The new 64-bit value.
2244 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
2245 bitwise OR, and returns the result.
2247 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2248 in Operand and the value specified by AndData, followed by a bitwise
2249 inclusive OR with value specified by OrData. All other bits in Operand are
2250 preserved. The new 64-bit value is returned.
2252 If 64-bit operations are not supported, then ASSERT().
2253 If StartBit is greater than 63, then ASSERT().
2254 If EndBit is greater than 63, then ASSERT().
2255 If EndBit is less than or equal to StartBit, then ASSERT().
2257 @param Operand Operand on which to perform the bitfield operation.
2258 @param StartBit The ordinal of the least significant bit in the bit field.
2260 @param EndBit The ordinal of the most significant bit in the bit field.
2262 @param AndData The value to AND with the read value from the value.
2263 @param OrData The value to OR with the result of the AND operation.
2265 @return The new 64-bit value.
2270 BitFieldAndThenOr64 (
2279 // Base Library Synchronization Functions
2283 Retrieves the architecture specific spin lock alignment requirements for
2284 optimal spin lock performance.
2286 This function retrieves the spin lock alignment requirements for optimal
2287 performance on a given CPU architecture. The spin lock alignment must be a
2288 power of two and is returned by this function. If there are no alignment
2289 requirements, then 1 must be returned. The spin lock synchronization
2290 functions must function correctly if the spin lock size and alignment values
2291 returned by this function are not used at all. These values are hints to the
2292 consumers of the spin lock synchronization functions to obtain optimal spin
2295 @return The architecture specific spin lock alignment.
2300 GetSpinLockProperties (
2305 Initializes a spin lock to the released state and returns the spin lock.
2307 This function initializes the spin lock specified by SpinLock to the released
2308 state, and returns SpinLock. Optimal performance can be achieved by calling
2309 GetSpinLockProperties() to determine the size and alignment requirements for
2312 If SpinLock is NULL, then ASSERT().
2314 @param SpinLock A pointer to the spin lock to initialize to the released
2322 InitializeSpinLock (
2323 IN SPIN_LOCK
*SpinLock
2327 Waits until a spin lock can be placed in the acquired state.
2329 This function checks the state of the spin lock specified by SpinLock. If
2330 SpinLock is in the released state, then this function places SpinLock in the
2331 acquired state and returns SpinLock. Otherwise, this function waits
2332 indefinitely for the spin lock to be released, and then places it in the
2333 acquired state and returns SpinLock. All state transitions of SpinLock must
2334 be performed using MP safe mechanisms.
2336 If SpinLock is NULL, then ASSERT().
2337 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
2338 If PcdSpinLockTimeout is not zero, and SpinLock is can not be acquired in
2339 PcdSpinLockTimeout microseconds, then ASSERT().
2341 @param SpinLock A pointer to the spin lock to place in the acquired state.
2349 IN SPIN_LOCK
*SpinLock
2353 Attempts to place a spin lock in the acquired state.
2355 This function checks the state of the spin lock specified by SpinLock. If
2356 SpinLock is in the released state, then this function places SpinLock in the
2357 acquired state and returns TRUE. Otherwise, FALSE is returned. All state
2358 transitions of SpinLock must be performed using MP safe mechanisms.
2360 If SpinLock is NULL, then ASSERT().
2361 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
2363 @param SpinLock A pointer to the spin lock to place in the acquired state.
2365 @retval TRUE SpinLock was placed in the acquired state.
2366 @retval FALSE SpinLock could not be acquired.
2371 AcquireSpinLockOrFail (
2372 IN SPIN_LOCK
*SpinLock
2376 Releases a spin lock.
2378 This function places the spin lock specified by SpinLock in the release state
2379 and returns SpinLock.
2381 If SpinLock is NULL, then ASSERT().
2382 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
2384 @param SpinLock A pointer to the spin lock to release.
2392 IN SPIN_LOCK
*SpinLock
2396 Performs an atomic increment of an 32-bit unsigned integer.
2398 Performs an atomic increment of the 32-bit unsigned integer specified by
2399 Value and returns the incremented value. The increment operation must be
2400 performed using MP safe mechanisms. The state of the return value is not
2401 guaranteed to be MP safe.
2403 If Value is NULL, then ASSERT().
2405 @param Value A pointer to the 32-bit value to increment.
2407 @return The incremented value.
2412 InterlockedIncrement (
2417 Performs an atomic decrement of an 32-bit unsigned integer.
2419 Performs an atomic decrement of the 32-bit unsigned integer specified by
2420 Value and returns the decremented value. The decrement operation must be
2421 performed using MP safe mechanisms. The state of the return value is not
2422 guaranteed to be MP safe.
2424 If Value is NULL, then ASSERT().
2426 @param Value A pointer to the 32-bit value to decrement.
2428 @return The decremented value.
2433 InterlockedDecrement (
2438 Performs an atomic compare exchange operation on a 32-bit unsigned integer.
2440 @param Value A pointer to the 32-bit value for the compare exchange
2442 @param CompareValue 32-bit value used in compare operation.
2443 @param ExchangeValue 32-bit value used in exchange operation.
2445 @return The original *Value before exchange.
2450 InterlockedCompareExchange32 (
2452 IN UINT32 CompareValue
,
2453 IN UINT32 ExchangeValue
2457 Performs an atomic compare exchange operation on a 64-bit unsigned integer.
2459 @param Value A pointer to the 64-bit value for the compare exchange
2461 @param CompareValue 64-bit value used in compare operation.
2462 @param ExchangeValue 64-bit value used in exchange operation.
2464 @return The original *Value before exchange.
2469 InterlockedCompareExchange64 (
2471 IN UINT64 CompareValue
,
2472 IN UINT64 ExchangeValue
2476 Performs an atomic compare exchange operation on a pointer value.
2478 Performs an atomic compare exchange operation on the pointer value specified
2479 by Value. If Value is equal to CompareValue, then Value is set to
2480 ExchangeValue and CompareValue is returned. If Value is not equal to
2481 CompareValue, then Value is returned. The compare exchange operation must be
2482 performed using MP safe mechanisms.
2484 If Value is NULL, then ASSERT().
2486 @param Value A pointer to the pointer value for the compare exchange
2488 @param CompareValue Pointer value used in compare operation.
2489 @param ExchangeValue Pointer value used in exchange operation.
2494 InterlockedCompareExchangePointer (
2496 IN VOID
*CompareValue
,
2497 IN VOID
*ExchangeValue
2501 // Base Library CPU Functions
2505 (EFIAPI
*SWITCH_STACK_ENTRY_POINT
) (
2506 IN VOID
*Context1
, OPTIONAL
2507 IN VOID
*Context2 OPTIONAL
2511 Used to serialize load and store operations.
2513 All loads and stores that proceed calls to this function are guaranteed to be
2514 globally visible when this function returns.
2524 Saves the current CPU context that can be restored with a call to LongJump()
2527 Saves the current CPU context in the buffer specified by JumpBuffer and
2528 returns 0. The initial call to SetJump() must always return 0. Subsequent
2529 calls to LongJump() cause a non-zero value to be returned by SetJump().
2531 If JumpBuffer is NULL, then ASSERT().
2533 @param JumpBuffer A pointer to CPU context buffer.
2535 @retval 0 Indicates a return from SetJump().
2541 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
2545 Restores the CPU context that was saved with SetJump().
2547 Restores the CPU context from the buffer specified by JumpBuffer. This
2548 function never returns to the caller. Instead is resumes execution based on
2549 the state of JumpBuffer.
2551 If JumpBuffer is NULL, then ASSERT().
2552 If Value is 0, then ASSERT().
2554 @param JumpBuffer A pointer to CPU context buffer.
2555 @param Value The value to return when the SetJump() context is
2556 restored and must be non-zero.
2562 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
2567 Enables CPU interrupts.
2569 Enables CPU interrupts.
2579 Disables CPU interrupts.
2581 Disables CPU interrupts.
2591 Disables CPU interrupts and returns the interrupt state prior to the disable
2594 Disables CPU interrupts and returns the interrupt state prior to the disable
2597 @retval TRUE CPU interrupts were enabled on entry to this call.
2598 @retval FALSE CPU interrupts were disabled on entry to this call.
2603 SaveAndDisableInterrupts (
2608 Enables CPU interrupts for the smallest window required to capture any
2611 Enables CPU interrupts for the smallest window required to capture any
2617 EnableDisableInterrupts (
2622 Retrieves the current CPU interrupt state.
2624 Retrieves the current CPU interrupt state. Returns TRUE is interrupts are
2625 currently enabled. Otherwise returns FALSE.
2627 @retval TRUE CPU interrupts are enabled.
2628 @retval FALSE CPU interrupts are disabled.
2638 Set the current CPU interrupt state.
2640 Sets the current CPU interrupt state to the state specified by
2641 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
2642 InterruptState is FALSE, then interrupts are disabled. InterruptState is
2645 @param InterruptState TRUE if interrupts should enabled. FALSE if
2646 interrupts should be disabled.
2648 @return InterruptState
2654 IN BOOLEAN InterruptState
2658 Places the CPU in a sleep state until an interrupt is received.
2660 Places the CPU in a sleep state until an interrupt is received. If interrupts
2661 are disabled prior to calling this function, then the CPU will be placed in a
2662 sleep state indefinitely.
2672 Requests CPU to pause for a short period of time.
2674 Requests CPU to pause for a short period of time. Typically used in MP
2675 systems to prevent memory starvation while waiting for a spin lock.
2685 Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU.
2687 Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU.
2697 Transfers control to a function starting with a new stack.
2699 Transfers control to the function specified by EntryPoint using the new stack
2700 specified by NewStack and passing in the parameters specified by Context1 and
2701 Context2. Context1 and Context2 are optional and may be NULL. The function
2702 EntryPoint must never return.
2704 If EntryPoint is NULL, then ASSERT().
2705 If NewStack is NULL, then ASSERT().
2707 @param EntryPoint A pointer to function to call with the new stack.
2708 @param Context1 A pointer to the context to pass into the EntryPoint
2710 @param Context2 A pointer to the context to pass into the EntryPoint
2712 @param NewStack A pointer to the new stack to use for the EntryPoint
2719 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
2720 IN VOID
*Context1
, OPTIONAL
2721 IN VOID
*Context2
, OPTIONAL
2726 Generates a breakpoint on the CPU.
2728 Generates a breakpoint on the CPU. The breakpoint must be implemented such
2729 that code can resume normal execution after the breakpoint.
2739 Executes an infinite loop.
2741 Forces the CPU to execute an infinite loop. A debugger may be used to skip
2742 past the loop and the code that follows the loop must execute properly. This
2743 implies that the infinite loop must not cause the code that follow it to be
2754 // IA32 and X64 Specific Functions
2757 // Byte packed structure for 16-bit Real Mode EFLAGS
2761 UINT32 CF
:1; // Carry Flag
2762 UINT32 Reserved_0
:1; // Reserved
2763 UINT32 PF
:1; // Parity Flag
2764 UINT32 Reserved_1
:1; // Reserved
2765 UINT32 AF
:1; // Auxiliary Carry Flag
2766 UINT32 Reserved_2
:1; // Reserved
2767 UINT32 ZF
:1; // Zero Flag
2768 UINT32 SF
:1; // Sign Flag
2769 UINT32 TF
:1; // Trap Flag
2770 UINT32 IF
:1; // Interrupt Enable Flag
2771 UINT32 DF
:1; // Direction Flag
2772 UINT32 OF
:1; // Overflow Flag
2773 UINT32 IOPL
:2; // I/O Privilege Level
2774 UINT32 NT
:1; // Nested Task
2775 UINT32 Reserved_3
:1; // Reserved
2781 // Byte packed structure for EFLAGS/RFLAGS
2783 // 64-bits on X64. The upper 32-bits on X64 are reserved
2787 UINT32 CF
:1; // Carry Flag
2788 UINT32 Reserved_0
:1; // Reserved
2789 UINT32 PF
:1; // Parity Flag
2790 UINT32 Reserved_1
:1; // Reserved
2791 UINT32 AF
:1; // Auxiliary Carry Flag
2792 UINT32 Reserved_2
:1; // Reserved
2793 UINT32 ZF
:1; // Zero Flag
2794 UINT32 SF
:1; // Sign Flag
2795 UINT32 TF
:1; // Trap Flag
2796 UINT32 IF
:1; // Interrupt Enable Flag
2797 UINT32 DF
:1; // Direction Flag
2798 UINT32 OF
:1; // Overflow Flag
2799 UINT32 IOPL
:2; // I/O Privilege Level
2800 UINT32 NT
:1; // Nested Task
2801 UINT32 Reserved_3
:1; // Reserved
2802 UINT32 RF
:1; // Resume Flag
2803 UINT32 VM
:1; // Virtual 8086 Mode
2804 UINT32 AC
:1; // Alignment Check
2805 UINT32 VIF
:1; // Virtual Interrupt Flag
2806 UINT32 VIP
:1; // Virtual Interrupt Pending
2807 UINT32 ID
:1; // ID Flag
2808 UINT32 Reserved_4
:10; // Reserved
2814 // Byte packed structure for Control Register 0 (CR0)
2816 // 64-bits on X64. The upper 32-bits on X64 are reserved
2820 UINT32 PE
:1; // Protection Enable
2821 UINT32 MP
:1; // Monitor Coprocessor
2822 UINT32 EM
:1; // Emulation
2823 UINT32 TS
:1; // Task Switched
2824 UINT32 ET
:1; // Extension Type
2825 UINT32 NE
:1; // Numeric Error
2826 UINT32 Reserved_0
:10; // Reserved
2827 UINT32 WP
:1; // Write Protect
2828 UINT32 Reserved_1
:1; // Reserved
2829 UINT32 AM
:1; // Alignment Mask
2830 UINT32 Reserved_2
:10; // Reserved
2831 UINT32 NW
:1; // Mot Write-through
2832 UINT32 CD
:1; // Cache Disable
2833 UINT32 PG
:1; // Paging
2839 // Byte packed structure for Control Register 4 (CR4)
2841 // 64-bits on X64. The upper 32-bits on X64 are reserved
2845 UINT32 VME
:1; // Virtual-8086 Mode Extensions
2846 UINT32 PVI
:1; // Protected-Mode Virtual Interrupts
2847 UINT32 TSD
:1; // Time Stamp Disable
2848 UINT32 DE
:1; // Debugging Extensions
2849 UINT32 PSE
:1; // Page Size Extensions
2850 UINT32 PAE
:1; // Physical Address Extension
2851 UINT32 MCE
:1; // Machine Check Enable
2852 UINT32 PGE
:1; // Page Global Enable
2853 UINT32 PCE
:1; // Performance Monitoring Counter
2855 UINT32 OSFXSR
:1; // Operating System Support for
2856 // FXSAVE and FXRSTOR instructions
2857 UINT32 OSXMMEXCPT
:1; // Operating System Support for
2858 // Unmasked SIMD Floating Point
2860 UINT32 Reserved_0
:2; // Reserved
2861 UINT32 VMXE
:1; // VMX Enable
2862 UINT32 Reserved_1
:18; // Reseved
2868 // Byte packed structure for an IDTR, GDTR, LDTR descriptor
2875 #define IA32_IDT_GATE_TYPE_TASK 0x85
2876 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
2877 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
2878 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
2879 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
2882 // Byte packed structure for an Interrupt Gate Descriptor
2886 UINT32 OffsetLow
:16; // Offset bits 15..0
2887 UINT32 Selector
:16; // Selector
2888 UINT32 Reserved_0
:8; // Reserved
2889 UINT32 GateType
:8; // Gate Type. See #defines above
2890 UINT32 OffsetHigh
:16; // Offset bits 31..16
2893 } IA32_IDT_GATE_DESCRIPTOR
;
2896 // Byte packed structure for an FP/SSE/SSE2 context
2903 // Structures for the 16-bit real mode thunks
2956 IA32_EFLAGS32 EFLAGS
;
2966 } IA32_REGISTER_SET
;
2969 // Byte packed structure for an 16-bit real mode thunks
2972 IA32_REGISTER_SET RealModeState
;
2973 VOID
*RealModeBuffer
;
2974 UINTN RealModeBufferSize
;
2976 UINTN CallStackSize
;
2978 UINTN RealModeCodeSize
;
2982 Retrieves CPUID information.
2984 Executes the CPUID instruction with EAX set to the value specified by Index.
2985 This function always returns Index.
2986 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
2987 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
2988 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
2989 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
2990 This function is only available on IA-32 and X64.
2992 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
2994 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
2995 instruction. This is an optional parameter that may be NULL.
2996 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
2997 instruction. This is an optional parameter that may be NULL.
2998 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
2999 instruction. This is an optional parameter that may be NULL.
3000 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
3001 instruction. This is an optional parameter that may be NULL.
3010 OUT UINT32
*Eax
, OPTIONAL
3011 OUT UINT32
*Ebx
, OPTIONAL
3012 OUT UINT32
*Ecx
, OPTIONAL
3013 OUT UINT32
*Edx OPTIONAL
3017 Returns the lower 32-bits of a Machine Specific Register(MSR).
3019 Reads and returns the lower 32-bits of the MSR specified by Index.
3020 No parameter checking is performed on Index, and some Index values may cause
3021 CPU exceptions. The caller must either guarantee that Index is valid, or the
3022 caller must set up exception handlers to catch the exceptions. This function
3023 is only available on IA-32 and X64.
3025 @param Index The 32-bit MSR index to read.
3027 @return The lower 32 bits of the MSR identified by Index.
3037 Zero-extend a 32-bit value and writes it to a Machine Specific Register(MSR).
3039 Writes the 32-bit value specified by Value to the MSR specified by Index. The
3040 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
3041 the MSR is returned. No parameter checking is performed on Index or Value,
3042 and some of these may cause CPU exceptions. The caller must either guarantee
3043 that Index and Value are valid, or the caller must establish proper exception
3044 handlers. This function is only available on IA-32 and X64.
3046 @param Index The 32-bit MSR index to write.
3047 @param Value The 32-bit value to write to the MSR.
3060 Reads a 64-bit MSR, performs a bitwise inclusive OR on the lower 32-bits, and
3061 writes the result back to the 64-bit MSR.
3063 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
3064 between the lower 32-bits of the read result and the value specified by
3065 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
3066 32-bits of the value written to the MSR is returned. No parameter checking is
3067 performed on Index or OrData, and some of these may cause CPU exceptions. The
3068 caller must either guarantee that Index and OrData are valid, or the caller
3069 must establish proper exception handlers. This function is only available on
3072 @param Index The 32-bit MSR index to write.
3073 @param OrData The value to OR with the read value from the MSR.
3075 @return The lower 32-bit value written to the MSR.
3086 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
3087 the result back to the 64-bit MSR.
3089 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
3090 lower 32-bits of the read result and the value specified by AndData, and
3091 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
3092 the value written to the MSR is returned. No parameter checking is performed
3093 on Index or AndData, and some of these may cause CPU exceptions. The caller
3094 must either guarantee that Index and AndData are valid, or the caller must
3095 establish proper exception handlers. This function is only available on IA-32
3098 @param Index The 32-bit MSR index to write.
3099 @param AndData The value to AND with the read value from the MSR.
3101 @return The lower 32-bit value written to the MSR.
3112 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive OR
3113 on the lower 32-bits, and writes the result back to the 64-bit MSR.
3115 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
3116 lower 32-bits of the read result and the value specified by AndData
3117 preserving the upper 32-bits, performs a bitwise inclusive OR between the
3118 result of the AND operation and the value specified by OrData, and writes the
3119 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
3120 written to the MSR is returned. No parameter checking is performed on Index,
3121 AndData, or OrData, and some of these may cause CPU exceptions. The caller
3122 must either guarantee that Index, AndData, and OrData are valid, or the
3123 caller must establish proper exception handlers. This function is only
3124 available on IA-32 and X64.
3126 @param Index The 32-bit MSR index to write.
3127 @param AndData The value to AND with the read value from the MSR.
3128 @param OrData The value to OR with the result of the AND operation.
3130 @return The lower 32-bit value written to the MSR.
3142 Reads a bit field of an MSR.
3144 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
3145 specified by the StartBit and the EndBit. The value of the bit field is
3146 returned. The caller must either guarantee that Index is valid, or the caller
3147 must set up exception handlers to catch the exceptions. This function is only
3148 available on IA-32 and X64.
3150 If StartBit is greater than 31, then ASSERT().
3151 If EndBit is greater than 31, then ASSERT().
3152 If EndBit is less than or equal to StartBit, then ASSERT().
3154 @param Index The 32-bit MSR index to read.
3155 @param StartBit The ordinal of the least significant bit in the bit field.
3157 @param EndBit The ordinal of the most significant bit in the bit field.
3160 @return The bit field read from the MSR.
3165 AsmMsrBitFieldRead32 (
3172 Writes a bit field to an MSR.
3174 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
3175 field is specified by the StartBit and the EndBit. All other bits in the
3176 destination MSR are preserved. The lower 32-bits of the MSR written is
3177 returned. Extra left bits in Value are stripped. The caller must either
3178 guarantee that Index and the data written is valid, or the caller must set up
3179 exception handlers to catch the exceptions. This function is only available
3182 If StartBit is greater than 31, then ASSERT().
3183 If EndBit is greater than 31, then ASSERT().
3184 If EndBit is less than or equal to StartBit, then ASSERT().
3186 @param Index The 32-bit MSR index to write.
3187 @param StartBit The ordinal of the least significant bit in the bit field.
3189 @param EndBit The ordinal of the most significant bit in the bit field.
3191 @param Value New value of the bit field.
3193 @return The lower 32-bit of the value written to the MSR.
3198 AsmMsrBitFieldWrite32 (
3206 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
3207 result back to the bit field in the 64-bit MSR.
3209 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
3210 between the read result and the value specified by OrData, and writes the
3211 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
3212 written to the MSR are returned. Extra left bits in OrData are stripped. The
3213 caller must either guarantee that Index and the data written is valid, or
3214 the caller must set up exception handlers to catch the exceptions. This
3215 function is only available on IA-32 and X64.
3217 If StartBit is greater than 31, then ASSERT().
3218 If EndBit is greater than 31, then ASSERT().
3219 If EndBit is less than or equal to StartBit, then ASSERT().
3221 @param Index The 32-bit MSR index to write.
3222 @param StartBit The ordinal of the least significant bit in the bit field.
3224 @param EndBit The ordinal of the most significant bit in the bit field.
3226 @param OrData The value to OR with the read value from the MSR.
3228 @return The lower 32-bit of the value written to the MSR.
3233 AsmMsrBitFieldOr32 (
3241 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
3242 result back to the bit field in the 64-bit MSR.
3244 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
3245 read result and the value specified by AndData, and writes the result to the
3246 64-bit MSR specified by Index. The lower 32-bits of the value written to the
3247 MSR are returned. Extra left bits in AndData are stripped. The caller must
3248 either guarantee that Index and the data written is valid, or the caller must
3249 set up exception handlers to catch the exceptions. This function is only
3250 available on IA-32 and X64.
3252 If StartBit is greater than 31, then ASSERT().
3253 If EndBit is greater than 31, then ASSERT().
3254 If EndBit is less than or equal to StartBit, then ASSERT().
3256 @param Index The 32-bit MSR index to write.
3257 @param StartBit The ordinal of the least significant bit in the bit field.
3259 @param EndBit The ordinal of the most significant bit in the bit field.
3261 @param AndData The value to AND with the read value from the MSR.
3263 @return The lower 32-bit of the value written to the MSR.
3268 AsmMsrBitFieldAnd32 (
3276 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
3277 bitwise inclusive OR, and writes the result back to the bit field in the
3280 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
3281 bitwise inclusive OR between the read result and the value specified by
3282 AndData, and writes the result to the 64-bit MSR specified by Index. The
3283 lower 32-bits of the value written to the MSR are returned. Extra left bits
3284 in both AndData and OrData are stripped. The caller must either guarantee
3285 that Index and the data written is valid, or the caller must set up exception
3286 handlers to catch the exceptions. This function is only available on IA-32
3289 If StartBit is greater than 31, then ASSERT().
3290 If EndBit is greater than 31, then ASSERT().
3291 If EndBit is less than or equal to StartBit, then ASSERT().
3293 @param Index The 32-bit MSR index to write.
3294 @param StartBit The ordinal of the least significant bit in the bit field.
3296 @param EndBit The ordinal of the most significant bit in the bit field.
3298 @param AndData The value to AND with the read value from the MSR.
3299 @param OrData The value to OR with the result of the AND operation.
3301 @return The lower 32-bit of the value written to the MSR.
3306 AsmMsrBitFieldAndThenOr32 (
3315 Returns a 64-bit Machine Specific Register(MSR).
3317 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
3318 performed on Index, and some Index values may cause CPU exceptions. The
3319 caller must either guarantee that Index is valid, or the caller must set up
3320 exception handlers to catch the exceptions. This function is only available
3323 @param Index The 32-bit MSR index to read.
3325 @return The value of the MSR identified by Index.
3335 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
3338 Writes the 64-bit value specified by Value to the MSR specified by Index. The
3339 64-bit value written to the MSR is returned. No parameter checking is
3340 performed on Index or Value, and some of these may cause CPU exceptions. The
3341 caller must either guarantee that Index and Value are valid, or the caller
3342 must establish proper exception handlers. This function is only available on
3345 @param Index The 32-bit MSR index to write.
3346 @param Value The 64-bit value to write to the MSR.
3359 Reads a 64-bit MSR, performs a bitwise inclusive OR, and writes the result
3360 back to the 64-bit MSR.
3362 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
3363 between the read result and the value specified by OrData, and writes the
3364 result to the 64-bit MSR specified by Index. The value written to the MSR is
3365 returned. No parameter checking is performed on Index or OrData, and some of
3366 these may cause CPU exceptions. The caller must either guarantee that Index
3367 and OrData are valid, or the caller must establish proper exception handlers.
3368 This function is only available on IA-32 and X64.
3370 @param Index The 32-bit MSR index to write.
3371 @param OrData The value to OR with the read value from the MSR.
3373 @return The value written back to the MSR.
3384 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
3387 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
3388 read result and the value specified by OrData, and writes the result to the
3389 64-bit MSR specified by Index. The value written to the MSR is returned. No
3390 parameter checking is performed on Index or OrData, and some of these may
3391 cause CPU exceptions. The caller must either guarantee that Index and OrData
3392 are valid, or the caller must establish proper exception handlers. This
3393 function is only available on IA-32 and X64.
3395 @param Index The 32-bit MSR index to write.
3396 @param AndData The value to AND with the read value from the MSR.
3398 @return The value written back to the MSR.
3409 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive
3410 OR, and writes the result back to the 64-bit MSR.
3412 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
3413 result and the value specified by AndData, performs a bitwise inclusive OR
3414 between the result of the AND operation and the value specified by OrData,
3415 and writes the result to the 64-bit MSR specified by Index. The value written
3416 to the MSR is returned. No parameter checking is performed on Index, AndData,
3417 or OrData, and some of these may cause CPU exceptions. The caller must either
3418 guarantee that Index, AndData, and OrData are valid, or the caller must
3419 establish proper exception handlers. This function is only available on IA-32
3422 @param Index The 32-bit MSR index to write.
3423 @param AndData The value to AND with the read value from the MSR.
3424 @param OrData The value to OR with the result of the AND operation.
3426 @return The value written back to the MSR.
3438 Reads a bit field of an MSR.
3440 Reads the bit field in the 64-bit MSR. The bit field is specified by the
3441 StartBit and the EndBit. The value of the bit field is returned. The caller
3442 must either guarantee that Index is valid, or the caller must set up
3443 exception handlers to catch the exceptions. This function is only available
3446 If StartBit is greater than 63, then ASSERT().
3447 If EndBit is greater than 63, then ASSERT().
3448 If EndBit is less than or equal to StartBit, then ASSERT().
3450 @param Index The 32-bit MSR index to read.
3451 @param StartBit The ordinal of the least significant bit in the bit field.
3453 @param EndBit The ordinal of the most significant bit in the bit field.
3456 @return The value read from the MSR.
3461 AsmMsrBitFieldRead64 (
3468 Writes a bit field to an MSR.
3470 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
3471 the StartBit and the EndBit. All other bits in the destination MSR are
3472 preserved. The MSR written is returned. Extra left bits in Value are
3473 stripped. The caller must either guarantee that Index and the data written is
3474 valid, or the caller must set up exception handlers to catch the exceptions.
3475 This function is only available on IA-32 and X64.
3477 If StartBit is greater than 63, then ASSERT().
3478 If EndBit is greater than 63, then ASSERT().
3479 If EndBit is less than or equal to StartBit, then ASSERT().
3481 @param Index The 32-bit MSR index to write.
3482 @param StartBit The ordinal of the least significant bit in the bit field.
3484 @param EndBit The ordinal of the most significant bit in the bit field.
3486 @param Value New value of the bit field.
3488 @return The value written back to the MSR.
3493 AsmMsrBitFieldWrite64 (
3501 Reads a bit field in a 64-bit MSR, performs a bitwise inclusive OR, and
3502 writes the result back to the bit field in the 64-bit MSR.
3504 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
3505 between the read result and the value specified by OrData, and writes the
3506 result to the 64-bit MSR specified by Index. The value written to the MSR is
3507 returned. Extra left bits in OrData are stripped. The caller must either
3508 guarantee that Index and the data written is valid, or the caller must set up
3509 exception handlers to catch the exceptions. This function is only available
3512 If StartBit is greater than 63, then ASSERT().
3513 If EndBit is greater than 63, then ASSERT().
3514 If EndBit is less than or equal to StartBit, then ASSERT().
3516 @param Index The 32-bit MSR index to write.
3517 @param StartBit The ordinal of the least significant bit in the bit field.
3519 @param EndBit The ordinal of the most significant bit in the bit field.
3521 @param OrData The value to OR with the read value from the bit field.
3523 @return The value written back to the MSR.
3528 AsmMsrBitFieldOr64 (
3536 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
3537 result back to the bit field in the 64-bit MSR.
3539 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
3540 read result and the value specified by AndData, and writes the result to the
3541 64-bit MSR specified by Index. The value written to the MSR is returned.
3542 Extra left bits in AndData are stripped. The caller must either guarantee
3543 that Index and the data written is valid, or the caller must set up exception
3544 handlers to catch the exceptions. This function is only available on IA-32
3547 If StartBit is greater than 63, then ASSERT().
3548 If EndBit is greater than 63, then ASSERT().
3549 If EndBit is less than or equal to StartBit, then ASSERT().
3551 @param Index The 32-bit MSR index to write.
3552 @param StartBit The ordinal of the least significant bit in the bit field.
3554 @param EndBit The ordinal of the most significant bit in the bit field.
3556 @param AndData The value to AND with the read value from the bit field.
3558 @return The value written back to the MSR.
3563 AsmMsrBitFieldAnd64 (
3571 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
3572 bitwise inclusive OR, and writes the result back to the bit field in the
3575 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
3576 a bitwise inclusive OR between the read result and the value specified by
3577 AndData, and writes the result to the 64-bit MSR specified by Index. The
3578 value written to the MSR is returned. Extra left bits in both AndData and
3579 OrData are stripped. The caller must either guarantee that Index and the data
3580 written is valid, or the caller must set up exception handlers to catch the
3581 exceptions. This function is only available on IA-32 and X64.
3583 If StartBit is greater than 63, then ASSERT().
3584 If EndBit is greater than 63, then ASSERT().
3585 If EndBit is less than or equal to StartBit, then ASSERT().
3587 @param Index The 32-bit MSR index to write.
3588 @param StartBit The ordinal of the least significant bit in the bit field.
3590 @param EndBit The ordinal of the most significant bit in the bit field.
3592 @param AndData The value to AND with the read value from the bit field.
3593 @param OrData The value to OR with the result of the AND operation.
3595 @return The value written back to the MSR.
3600 AsmMsrBitFieldAndThenOr64 (
3609 Reads the current value of the EFLAGS register.
3611 Reads and returns the current value of the EFLAGS register. This function is
3612 only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a
3613 64-bit value on X64.
3615 @return EFLAGS on IA-32 or RFLAGS on X64.
3625 Reads the current value of the Control Register 0 (CR0).
3627 Reads and returns the current value of CR0. This function is only available
3628 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3631 @return The value of the Control Register 0 (CR0).
3641 Reads the current value of the Control Register 2 (CR2).
3643 Reads and returns the current value of CR2. This function is only available
3644 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3647 @return The value of the Control Register 2 (CR2).
3657 Reads the current value of the Control Register 3 (CR3).
3659 Reads and returns the current value of CR3. This function is only available
3660 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3663 @return The value of the Control Register 3 (CR3).
3673 Reads the current value of the Control Register 4 (CR4).
3675 Reads and returns the current value of CR4. This function is only available
3676 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3679 @return The value of the Control Register 4 (CR4).
3689 Writes a value to Control Register 0 (CR0).
3691 Writes and returns a new value to CR0. This function is only available on
3692 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3694 @param Cr0 The value to write to CR0.
3696 @return The value written to CR0.
3706 Writes a value to Control Register 2 (CR2).
3708 Writes and returns a new value to CR2. This function is only available on
3709 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3711 @param Cr2 The value to write to CR2.
3713 @return The value written to CR2.
3723 Writes a value to Control Register 3 (CR3).
3725 Writes and returns a new value to CR3. This function is only available on
3726 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3728 @param Cr3 The value to write to CR3.
3730 @return The value written to CR3.
3740 Writes a value to Control Register 4 (CR4).
3742 Writes and returns a new value to CR4. This function is only available on
3743 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3745 @param Cr4 The value to write to CR4.
3747 @return The value written to CR4.
3757 Reads the current value of Debug Register 0 (DR0).
3759 Reads and returns the current value of DR0. This function is only available
3760 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3763 @return The value of Debug Register 0 (DR0).
3773 Reads the current value of Debug Register 1 (DR1).
3775 Reads and returns the current value of DR1. This function is only available
3776 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3779 @return The value of Debug Register 1 (DR1).
3789 Reads the current value of Debug Register 2 (DR2).
3791 Reads and returns the current value of DR2. This function is only available
3792 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3795 @return The value of Debug Register 2 (DR2).
3805 Reads the current value of Debug Register 3 (DR3).
3807 Reads and returns the current value of DR3. This function is only available
3808 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3811 @return The value of Debug Register 3 (DR3).
3821 Reads the current value of Debug Register 4 (DR4).
3823 Reads and returns the current value of DR4. This function is only available
3824 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3827 @return The value of Debug Register 4 (DR4).
3837 Reads the current value of Debug Register 5 (DR5).
3839 Reads and returns the current value of DR5. This function is only available
3840 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3843 @return The value of Debug Register 5 (DR5).
3853 Reads the current value of Debug Register 6 (DR6).
3855 Reads and returns the current value of DR6. This function is only available
3856 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3859 @return The value of Debug Register 6 (DR6).
3869 Reads the current value of Debug Register 7 (DR7).
3871 Reads and returns the current value of DR7. This function is only available
3872 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3875 @return The value of Debug Register 7 (DR7).
3885 Writes a value to Debug Register 0 (DR0).
3887 Writes and returns a new value to DR0. This function is only available on
3888 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3890 @param Dr0 The value to write to Dr0.
3892 @return The value written to Debug Register 0 (DR0).
3902 Writes a value to Debug Register 1 (DR1).
3904 Writes and returns a new value to DR1. This function is only available on
3905 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3907 @param Dr1 The value to write to Dr1.
3909 @return The value written to Debug Register 1 (DR1).
3919 Writes a value to Debug Register 2 (DR2).
3921 Writes and returns a new value to DR2. This function is only available on
3922 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3924 @param Dr2 The value to write to Dr2.
3926 @return The value written to Debug Register 2 (DR2).
3936 Writes a value to Debug Register 3 (DR3).
3938 Writes and returns a new value to DR3. This function is only available on
3939 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3941 @param Dr3 The value to write to Dr3.
3943 @return The value written to Debug Register 3 (DR3).
3953 Writes a value to Debug Register 4 (DR4).
3955 Writes and returns a new value to DR4. This function is only available on
3956 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3958 @param Dr4 The value to write to Dr4.
3960 @return The value written to Debug Register 4 (DR4).
3970 Writes a value to Debug Register 5 (DR5).
3972 Writes and returns a new value to DR5. This function is only available on
3973 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3975 @param Dr5 The value to write to Dr5.
3977 @return The value written to Debug Register 5 (DR5).
3987 Writes a value to Debug Register 6 (DR6).
3989 Writes and returns a new value to DR6. This function is only available on
3990 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3992 @param Dr6 The value to write to Dr6.
3994 @return The value written to Debug Register 6 (DR6).
4004 Writes a value to Debug Register 7 (DR7).
4006 Writes and returns a new value to DR7. This function is only available on
4007 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4009 @param Dr7 The value to write to Dr7.
4011 @return The value written to Debug Register 7 (DR7).
4021 Reads the current value of Code Segment Register (CS).
4023 Reads and returns the current value of CS. This function is only available on
4026 @return The current value of CS.
4036 Reads the current value of Data Segment Register (DS).
4038 Reads and returns the current value of DS. This function is only available on
4041 @return The current value of DS.
4051 Reads the current value of Extra Segment Register (ES).
4053 Reads and returns the current value of ES. This function is only available on
4056 @return The current value of ES.
4066 Reads the current value of FS Data Segment Register (FS).
4068 Reads and returns the current value of FS. This function is only available on
4071 @return The current value of FS.
4081 Reads the current value of GS Data Segment Register (GS).
4083 Reads and returns the current value of GS. This function is only available on
4086 @return The current value of GS.
4096 Reads the current value of Stack Segment Register (SS).
4098 Reads and returns the current value of SS. This function is only available on
4101 @return The current value of SS.
4111 Reads the current value of Task Register (TR).
4113 Reads and returns the current value of TR. This function is only available on
4116 @return The current value of TR.
4126 Reads the current Global Descriptor Table Register(GDTR) descriptor.
4128 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
4129 function is only available on IA-32 and X64.
4131 If Gdtr is NULL, then ASSERT().
4133 @param Gdtr Pointer to a GDTR descriptor.
4139 OUT IA32_DESCRIPTOR
*Gdtr
4143 Writes the current Global Descriptor Table Register (GDTR) descriptor.
4145 Writes and the current GDTR descriptor specified by Gdtr. This function is
4146 only available on IA-32 and X64.
4148 If Gdtr is NULL, then ASSERT().
4150 @param Gdtr Pointer to a GDTR descriptor.
4156 IN CONST IA32_DESCRIPTOR
*Gdtr
4160 Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.
4162 Reads and returns the current IDTR descriptor and returns it in Idtr. This
4163 function is only available on IA-32 and X64.
4165 If Idtr is NULL, then ASSERT().
4167 @param Idtr Pointer to a IDTR descriptor.
4173 OUT IA32_DESCRIPTOR
*Idtr
4177 Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.
4179 Writes the current IDTR descriptor and returns it in Idtr. This function is
4180 only available on IA-32 and X64.
4182 If Idtr is NULL, then ASSERT().
4184 @param Idtr Pointer to a IDTR descriptor.
4190 IN CONST IA32_DESCRIPTOR
*Idtr
4194 Reads the current Local Descriptor Table Register(LDTR) selector.
4196 Reads and returns the current 16-bit LDTR descriptor value. This function is
4197 only available on IA-32 and X64.
4199 @return The current selector of LDT.
4209 Writes the current Local Descriptor Table Register (GDTR) selector.
4211 Writes and the current LDTR descriptor specified by Ldtr. This function is
4212 only available on IA-32 and X64.
4214 @param Ldtr 16-bit LDTR selector value.
4224 Save the current floating point/SSE/SSE2 context to a buffer.
4226 Saves the current floating point/SSE/SSE2 state to the buffer specified by
4227 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
4228 available on IA-32 and X64.
4230 If Buffer is NULL, then ASSERT().
4231 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
4233 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
4239 OUT IA32_FX_BUFFER
*Buffer
4243 Restores the current floating point/SSE/SSE2 context from a buffer.
4245 Restores the current floating point/SSE/SSE2 state from the buffer specified
4246 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
4247 only available on IA-32 and X64.
4249 If Buffer is NULL, then ASSERT().
4250 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
4251 If Buffer was not saved with AsmFxSave(), then ASSERT().
4253 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
4259 IN CONST IA32_FX_BUFFER
*Buffer
4263 Reads the current value of 64-bit MMX Register #0 (MM0).
4265 Reads and returns the current value of MM0. This function is only available
4268 @return The current value of MM0.
4278 Reads the current value of 64-bit MMX Register #1 (MM1).
4280 Reads and returns the current value of MM1. This function is only available
4283 @return The current value of MM1.
4293 Reads the current value of 64-bit MMX Register #2 (MM2).
4295 Reads and returns the current value of MM2. This function is only available
4298 @return The current value of MM2.
4308 Reads the current value of 64-bit MMX Register #3 (MM3).
4310 Reads and returns the current value of MM3. This function is only available
4313 @return The current value of MM3.
4323 Reads the current value of 64-bit MMX Register #4 (MM4).
4325 Reads and returns the current value of MM4. This function is only available
4328 @return The current value of MM4.
4338 Reads the current value of 64-bit MMX Register #5 (MM5).
4340 Reads and returns the current value of MM5. This function is only available
4343 @return The current value of MM5.
4353 Reads the current value of 64-bit MMX Register #6 (MM6).
4355 Reads and returns the current value of MM6. This function is only available
4358 @return The current value of MM6.
4368 Reads the current value of 64-bit MMX Register #7 (MM7).
4370 Reads and returns the current value of MM7. This function is only available
4373 @return The current value of MM7.
4383 Writes the current value of 64-bit MMX Register #0 (MM0).
4385 Writes the current value of MM0. This function is only available on IA32 and
4388 @param Value The 64-bit value to write to MM0.
4398 Writes the current value of 64-bit MMX Register #1 (MM1).
4400 Writes the current value of MM1. This function is only available on IA32 and
4403 @param Value The 64-bit value to write to MM1.
4413 Writes the current value of 64-bit MMX Register #2 (MM2).
4415 Writes the current value of MM2. This function is only available on IA32 and
4418 @param Value The 64-bit value to write to MM2.
4428 Writes the current value of 64-bit MMX Register #3 (MM3).
4430 Writes the current value of MM3. This function is only available on IA32 and
4433 @param Value The 64-bit value to write to MM3.
4443 Writes the current value of 64-bit MMX Register #4 (MM4).
4445 Writes the current value of MM4. This function is only available on IA32 and
4448 @param Value The 64-bit value to write to MM4.
4458 Writes the current value of 64-bit MMX Register #5 (MM5).
4460 Writes the current value of MM5. This function is only available on IA32 and
4463 @param Value The 64-bit value to write to MM5.
4473 Writes the current value of 64-bit MMX Register #6 (MM6).
4475 Writes the current value of MM6. This function is only available on IA32 and
4478 @param Value The 64-bit value to write to MM6.
4488 Writes the current value of 64-bit MMX Register #7 (MM7).
4490 Writes the current value of MM7. This function is only available on IA32 and
4493 @param Value The 64-bit value to write to MM7.
4503 Reads the current value of Time Stamp Counter (TSC).
4505 Reads and returns the current value of TSC. This function is only available
4508 @return The current value of TSC
4518 Reads the current value of a Performance Counter (PMC).
4520 Reads and returns the current value of performance counter specified by
4521 Index. This function is only available on IA-32 and X64.
4523 @param Index The 32-bit Performance Counter index to read.
4525 @return The value of the PMC specified by Index.
4535 Sets up a monitor buffer that is used by AsmMwait().
4537 Executes a MONITOR instruction with the register state specified by Eax, Ecx
4538 and Edx. Returns Eax. This function is only available on IA-32 and X64.
4540 @param Eax The value to load into EAX or RAX before executing the MONITOR
4542 @param Ecx The value to load into ECX or RCX before executing the MONITOR
4544 @param Edx The value to load into EDX or RDX before executing the MONITOR
4559 Executes an MWAIT instruction.
4561 Executes an MWAIT instruction with the register state specified by Eax and
4562 Ecx. Returns Eax. This function is only available on IA-32 and X64.
4564 @param Eax The value to load into EAX or RAX before executing the MONITOR
4566 @param Ecx The value to load into ECX or RCX before executing the MONITOR
4580 Executes a WBINVD instruction.
4582 Executes a WBINVD instruction. This function is only available on IA-32 and
4593 Executes a INVD instruction.
4595 Executes a INVD instruction. This function is only available on IA-32 and
4606 Flushes a cache line from all the instruction and data caches within the
4607 coherency domain of the CPU.
4609 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
4610 This function is only available on IA-32 and X64.
4612 @param LinearAddress The address of the cache line to flush. If the CPU is
4613 in a physical addressing mode, then LinearAddress is a
4614 physical address. If the CPU is in a virtual
4615 addressing mode, then LinearAddress is a virtual
4618 @return LinearAddress
4623 IN VOID
*LinearAddress
4627 Enables the 32-bit paging mode on the CPU.
4629 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
4630 must be properly initialized prior to calling this service. This function
4631 assumes the current execution mode is 32-bit protected mode. This function is
4632 only available on IA-32. After the 32-bit paging mode is enabled, control is
4633 transferred to the function specified by EntryPoint using the new stack
4634 specified by NewStack and passing in the parameters specified by Context1 and
4635 Context2. Context1 and Context2 are optional and may be NULL. The function
4636 EntryPoint must never return.
4638 If the current execution mode is not 32-bit protected mode, then ASSERT().
4639 If EntryPoint is NULL, then ASSERT().
4640 If NewStack is NULL, then ASSERT().
4642 There are a number of constraints that must be followed before calling this
4644 1) Interrupts must be disabled.
4645 2) The caller must be in 32-bit protected mode with flat descriptors. This
4646 means all descriptors must have a base of 0 and a limit of 4GB.
4647 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
4649 4) CR3 must point to valid page tables that will be used once the transition
4650 is complete, and those page tables must guarantee that the pages for this
4651 function and the stack are identity mapped.
4653 @param EntryPoint A pointer to function to call with the new stack after
4655 @param Context1 A pointer to the context to pass into the EntryPoint
4656 function as the first parameter after paging is enabled.
4657 @param Context2 A pointer to the context to pass into the EntryPoint
4658 function as the second parameter after paging is enabled.
4659 @param NewStack A pointer to the new stack to use for the EntryPoint
4660 function after paging is enabled.
4666 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
4667 IN VOID
*Context1
, OPTIONAL
4668 IN VOID
*Context2
, OPTIONAL
4673 Disables the 32-bit paging mode on the CPU.
4675 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
4676 mode. This function assumes the current execution mode is 32-paged protected
4677 mode. This function is only available on IA-32. After the 32-bit paging mode
4678 is disabled, control is transferred to the function specified by EntryPoint
4679 using the new stack specified by NewStack and passing in the parameters
4680 specified by Context1 and Context2. Context1 and Context2 are optional and
4681 may be NULL. The function EntryPoint must never return.
4683 If the current execution mode is not 32-bit paged mode, then ASSERT().
4684 If EntryPoint is NULL, then ASSERT().
4685 If NewStack is NULL, then ASSERT().
4687 There are a number of constraints that must be followed before calling this
4689 1) Interrupts must be disabled.
4690 2) The caller must be in 32-bit paged mode.
4691 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
4692 4) CR3 must point to valid page tables that guarantee that the pages for
4693 this function and the stack are identity mapped.
4695 @param EntryPoint A pointer to function to call with the new stack after
4697 @param Context1 A pointer to the context to pass into the EntryPoint
4698 function as the first parameter after paging is disabled.
4699 @param Context2 A pointer to the context to pass into the EntryPoint
4700 function as the second parameter after paging is
4702 @param NewStack A pointer to the new stack to use for the EntryPoint
4703 function after paging is disabled.
4708 AsmDisablePaging32 (
4709 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
4710 IN VOID
*Context1
, OPTIONAL
4711 IN VOID
*Context2
, OPTIONAL
4716 Enables the 64-bit paging mode on the CPU.
4718 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
4719 must be properly initialized prior to calling this service. This function
4720 assumes the current execution mode is 32-bit protected mode with flat
4721 descriptors. This function is only available on IA-32. After the 64-bit
4722 paging mode is enabled, control is transferred to the function specified by
4723 EntryPoint using the new stack specified by NewStack and passing in the
4724 parameters specified by Context1 and Context2. Context1 and Context2 are
4725 optional and may be 0. The function EntryPoint must never return.
4727 If the current execution mode is not 32-bit protected mode with flat
4728 descriptors, then ASSERT().
4729 If EntryPoint is 0, then ASSERT().
4730 If NewStack is 0, then ASSERT().
4732 @param Cs The 16-bit selector to load in the CS before EntryPoint
4733 is called. The descriptor in the GDT that this selector
4734 references must be setup for long mode.
4735 @param EntryPoint The 64-bit virtual address of the function to call with
4736 the new stack after paging is enabled.
4737 @param Context1 The 64-bit virtual address of the context to pass into
4738 the EntryPoint function as the first parameter after
4740 @param Context2 The 64-bit virtual address of the context to pass into
4741 the EntryPoint function as the second parameter after
4743 @param NewStack The 64-bit virtual address of the new stack to use for
4744 the EntryPoint function after paging is enabled.
4750 IN UINT16 CodeSelector
,
4751 IN UINT64 EntryPoint
,
4752 IN UINT64 Context1
, OPTIONAL
4753 IN UINT64 Context2
, OPTIONAL
4758 Disables the 64-bit paging mode on the CPU.
4760 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
4761 mode. This function assumes the current execution mode is 64-paging mode.
4762 This function is only available on X64. After the 64-bit paging mode is
4763 disabled, control is transferred to the function specified by EntryPoint
4764 using the new stack specified by NewStack and passing in the parameters
4765 specified by Context1 and Context2. Context1 and Context2 are optional and
4766 may be 0. The function EntryPoint must never return.
4768 If the current execution mode is not 64-bit paged mode, then ASSERT().
4769 If EntryPoint is 0, then ASSERT().
4770 If NewStack is 0, then ASSERT().
4772 @param Cs The 16-bit selector to load in the CS before EntryPoint
4773 is called. The descriptor in the GDT that this selector
4774 references must be setup for 32-bit protected mode.
4775 @param EntryPoint The 64-bit virtual address of the function to call with
4776 the new stack after paging is disabled.
4777 @param Context1 The 64-bit virtual address of the context to pass into
4778 the EntryPoint function as the first parameter after
4780 @param Context2 The 64-bit virtual address of the context to pass into
4781 the EntryPoint function as the second parameter after
4783 @param NewStack The 64-bit virtual address of the new stack to use for
4784 the EntryPoint function after paging is disabled.
4789 AsmDisablePaging64 (
4790 IN UINT16 CodeSelector
,
4791 IN UINT32 EntryPoint
,
4792 IN UINT32 Context1
, OPTIONAL
4793 IN UINT32 Context2
, OPTIONAL
4798 // 16-bit thunking services
4802 Prepares all structures a code required to use AsmThunk16().
4804 Prepares all structures and code required to use AsmThunk16().
4806 If ThunkContext is NULL, then ASSERT().
4808 @param ThunkContext A pointer to the context structure that describes the
4809 16-bit real mode code to call.
4815 OUT THUNK_CONTEXT
*ThunkContext
4819 Transfers control to a 16-bit real mode entry point and returns the results.
4821 Transfers control to a 16-bit real mode entry point and returns the results.
4822 AsmPrepareThunk16() must be called with ThunkContext before this function is
4825 If ThunkContext is NULL, then ASSERT().
4826 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
4828 @param ThunkContext A pointer to the context structure that describes the
4829 16-bit real mode code to call.
4835 IN OUT THUNK_CONTEXT
*ThunkContext
4839 Prepares all structures and code for a 16-bit real mode thunk, transfers
4840 control to a 16-bit real mode entry point, and returns the results.
4842 Prepares all structures and code for a 16-bit real mode thunk, transfers
4843 control to a 16-bit real mode entry point, and returns the results. If the
4844 caller only need to perform a single 16-bit real mode thunk, then this
4845 service should be used. If the caller intends to make more than one 16-bit
4846 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
4847 once and AsmThunk16() can be called for each 16-bit real mode thunk.
4849 If ThunkContext is NULL, then ASSERT().
4851 @param ThunkContext A pointer to the context structure that describes the
4852 16-bit real mode code to call.
4857 AsmPrepareAndThunk16 (
4858 IN OUT THUNK_CONTEXT
*ThunkContext