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()
80 UINT64 AfterSpillUNAT
;
86 } BASE_LIBRARY_JUMP_BUFFER
;
88 #elif defined (MDE_CPU_X64)
90 // X64 context buffer used by SetJump() and LongJump()
103 } BASE_LIBRARY_JUMP_BUFFER
;
105 #elif defined (MDE_CPU_EBC)
107 // EBC context buffer used by SetJump() and LongJump()
115 } BASE_LIBRARY_JUMP_BUFFER
;
118 #error Unknown Processor Type
126 Copies one Null-terminated Unicode string to another Null-terminated Unicode
127 string and returns the new Unicode string.
129 This function copies the contents of the Unicode string Source to the Unicode
130 string Destination, and returns Destination. If Source and Destination
131 overlap, then the results are undefined.
133 If Destination is NULL, then ASSERT().
134 If Source is NULL, then ASSERT().
135 If Source and Destination overlap, then ASSERT().
136 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
137 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
139 @param Destination Pointer to a Null-terminated Unicode string.
140 @param Source Pointer to a Null-terminated Unicode string.
148 OUT CHAR16
*Destination
,
149 IN CONST CHAR16
*Source
153 Copies one Null-terminated Unicode string with a maximum length to another
154 Null-terminated Unicode string with a maximum length and returns the new
157 This function copies the contents of the Unicode string Source to the Unicode
158 string Destination, and returns Destination. At most, Length Unicode
159 characters are copied from Source to Destination. If Length is 0, then
160 Destination is returned unmodified. If Length is greater that the number of
161 Unicode characters in Source, then Destination is padded with Null Unicode
162 characters. If Source and Destination overlap, then the results are
165 If Destination is NULL, then ASSERT().
166 If Source is NULL, then ASSERT().
167 If Source and Destination overlap, then ASSERT().
168 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
169 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
171 @param Destination Pointer to a Null-terminated Unicode string.
172 @param Source Pointer to a Null-terminated Unicode string.
173 @param Length Maximum number of Unicode characters to copy.
181 OUT CHAR16
*Destination
,
182 IN CONST CHAR16
*Source
,
187 Returns the length of a Null-terminated Unicode string.
189 This function returns the number of Unicode characters in the Null-terminated
190 Unicode string specified by String.
192 If String is NULL, then ASSERT().
193 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
194 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
196 @param String Pointer to a Null-terminated Unicode string.
198 @return The length of String.
204 IN CONST CHAR16
*String
208 Returns the size of a Null-terminated Unicode string in bytes, including the
211 This function returns the size, in bytes, of the Null-terminated Unicode
212 string specified by String.
214 If String is NULL, then ASSERT().
215 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
216 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
218 @param String Pointer to a Null-terminated Unicode string.
220 @return The size of String.
226 IN CONST CHAR16
*String
230 Compares two Null-terminated Unicode strings, and returns the difference
231 between the first mismatched Unicode characters.
233 This function compares the Null-terminated Unicode string FirstString to the
234 Null-terminated Unicode string SecondString. If FirstString is identical to
235 SecondString, then 0 is returned. Otherwise, the value returned is the first
236 mismatched Unicode character in SecondString subtracted from the first
237 mismatched Unicode character in FirstString.
239 If FirstString is NULL, then ASSERT().
240 If SecondString is NULL, then ASSERT().
241 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
242 than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
243 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
244 than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
246 @param FirstString Pointer to a Null-terminated Unicode string.
247 @param SecondString Pointer to a Null-terminated Unicode string.
249 @retval 0 FirstString is identical to SecondString.
250 @retval !=0 FirstString is not identical to SecondString.
256 IN CONST CHAR16
*FirstString
,
257 IN CONST CHAR16
*SecondString
261 Compares two Null-terminated Unicode strings with maximum lengths, and
262 returns the difference between the first mismatched Unicode characters.
264 This function compares the Null-terminated Unicode string FirstString to the
265 Null-terminated Unicode string SecondString. At most, Length Unicode
266 characters will be compared. If Length is 0, then 0 is returned. If
267 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
268 value returned is the first mismatched Unicode character in SecondString
269 subtracted from the first mismatched Unicode character in FirstString.
271 If FirstString is NULL, then ASSERT().
272 If SecondString is NULL, then ASSERT().
273 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
274 than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
275 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
276 than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
278 @param FirstString Pointer to a Null-terminated Unicode string.
279 @param SecondString Pointer to a Null-terminated Unicode string.
280 @param Length Maximum number of Unicode characters to compare.
282 @retval 0 FirstString is identical to SecondString.
283 @retval !=0 FirstString is not identical to SecondString.
289 IN CONST CHAR16
*FirstString
,
290 IN CONST CHAR16
*SecondString
,
295 Concatenates one Null-terminated Unicode string to another Null-terminated
296 Unicode string, and returns the concatenated Unicode string.
298 This function concatenates two Null-terminated Unicode strings. The contents
299 of Null-terminated Unicode string Source are concatenated to the end of
300 Null-terminated Unicode string Destination. The Null-terminated concatenated
301 Unicode String is returned. If Source and Destination overlap, then the
302 results are undefined.
304 If Destination is NULL, then ASSERT().
305 If Source is NULL, then ASSERT().
306 If Source and Destination overlap, then ASSERT().
307 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
308 than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
309 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
310 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
311 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
312 and Source results in a Unicode string with more than
313 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
315 @param Destination Pointer to a Null-terminated Unicode string.
316 @param Source Pointer to a Null-terminated Unicode string.
324 IN OUT CHAR16
*Destination
,
325 IN CONST CHAR16
*Source
329 Concatenates one Null-terminated Unicode string with a maximum length to the
330 end of another Null-terminated Unicode string, and returns the concatenated
333 This function concatenates two Null-terminated Unicode strings. The contents
334 of Null-terminated Unicode string Source are concatenated to the end of
335 Null-terminated Unicode string Destination, and Destination is returned. At
336 most, Length Unicode characters are concatenated from Source to the end of
337 Destination, and Destination is always Null-terminated. If Length is 0, then
338 Destination is returned unmodified. If Source and Destination overlap, then
339 the results are undefined.
341 If Destination is NULL, then ASSERT().
342 If Source is NULL, then ASSERT().
343 If Source and Destination overlap, then ASSERT().
344 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
345 than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
346 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
347 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
348 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
349 and Source results in a Unicode string with more than
350 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
352 @param Destination Pointer to a Null-terminated Unicode string.
353 @param Source Pointer to a Null-terminated Unicode string.
354 @param Length Maximum number of Unicode characters to concatenate from
363 IN OUT CHAR16
*Destination
,
364 IN CONST CHAR16
*Source
,
369 Copies one Null-terminated ASCII string to another Null-terminated ASCII
370 string and returns the new ASCII string.
372 This function copies the contents of the ASCII string Source to the ASCII
373 string Destination, and returns Destination. If Source and Destination
374 overlap, then the results are undefined.
376 If Destination is NULL, then ASSERT().
377 If Source is NULL, then ASSERT().
378 If Source and Destination overlap, then ASSERT().
379 If PcdMaximumAsciiStringLength is not zero and Source contains more than
380 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
382 @param Destination Pointer to a Null-terminated ASCII string.
383 @param Source Pointer to a Null-terminated ASCII string.
391 OUT CHAR8
*Destination
,
392 IN CONST CHAR8
*Source
396 Copies one Null-terminated ASCII string with a maximum length to another
397 Null-terminated ASCII string with a maximum length and returns the new ASCII
400 This function copies the contents of the ASCII string Source to the ASCII
401 string Destination, and returns Destination. At most, Length ASCII characters
402 are copied from Source to Destination. If Length is 0, then Destination is
403 returned unmodified. If Length is greater that the number of ASCII characters
404 in Source, then Destination is padded with Null ASCII characters. If Source
405 and Destination overlap, then the results are undefined.
407 If Destination is NULL, then ASSERT().
408 If Source is NULL, then ASSERT().
409 If Source and Destination overlap, then ASSERT().
410 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
411 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
413 @param Destination Pointer to a Null-terminated ASCII string.
414 @param Source Pointer to a Null-terminated ASCII string.
415 @param Length Maximum number of ASCII characters to copy.
423 OUT CHAR8
*Destination
,
424 IN CONST CHAR8
*Source
,
429 Returns the length of a Null-terminated ASCII string.
431 This function returns the number of ASCII characters in the Null-terminated
432 ASCII string specified by String.
434 If String is NULL, then ASSERT().
435 If PcdMaximumAsciiStringLength is not zero and String contains more than
436 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
438 @param String Pointer to a Null-terminated ASCII string.
440 @return The length of String.
446 IN CONST CHAR8
*String
450 Returns the size of a Null-terminated ASCII string in bytes, including the
453 This function returns the size, in bytes, of the Null-terminated ASCII string
456 If String is NULL, then ASSERT().
457 If PcdMaximumAsciiStringLength is not zero and String contains more than
458 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
460 @param String Pointer to a Null-terminated ASCII string.
462 @return The size of String.
468 IN CONST CHAR8
*String
472 Compares two Null-terminated ASCII strings, and returns the difference
473 between the first mismatched ASCII characters.
475 This function compares the Null-terminated ASCII string FirstString to the
476 Null-terminated ASCII string SecondString. If FirstString is identical to
477 SecondString, then 0 is returned. Otherwise, the value returned is the first
478 mismatched ASCII character in SecondString subtracted from the first
479 mismatched ASCII character in FirstString.
481 If FirstString is NULL, then ASSERT().
482 If SecondString is NULL, then ASSERT().
483 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
484 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
485 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
486 than PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
488 @param FirstString Pointer to a Null-terminated ASCII string.
489 @param SecondString Pointer to a Null-terminated ASCII string.
491 @retval 0 FirstString is identical to SecondString.
492 @retval !=0 FirstString is not identical to SecondString.
498 IN CONST CHAR8
*FirstString
,
499 IN CONST CHAR8
*SecondString
503 Performs a case insensitive comparison of two Null-terminated ASCII strings,
504 and returns the difference between the first mismatched ASCII characters.
506 This function performs a case insensitive comparison of the Null-terminated
507 ASCII string FirstString to the Null-terminated ASCII string SecondString. If
508 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
509 value returned is the first mismatched lower case ASCII character in
510 SecondString subtracted from the first mismatched lower case ASCII character
513 If FirstString is NULL, then ASSERT().
514 If SecondString is NULL, then ASSERT().
515 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
516 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
517 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
518 than PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
520 @param FirstString Pointer to a Null-terminated ASCII string.
521 @param SecondString Pointer to a Null-terminated ASCII string.
523 @retval 0 FirstString is identical to SecondString using case insensitive
525 @retval !=0 FirstString is not identical to SecondString using case
526 insensitive comparisons.
532 IN CONST CHAR8
*FirstString
,
533 IN CONST CHAR8
*SecondString
537 Compares two Null-terminated ASCII strings with maximum lengths, and returns
538 the difference between the first mismatched ASCII characters.
540 This function compares the Null-terminated ASCII string FirstString to the
541 Null-terminated ASCII string SecondString. At most, Length ASCII characters
542 will be compared. If Length is 0, then 0 is returned. If FirstString is
543 identical to SecondString, then 0 is returned. Otherwise, the value returned
544 is the first mismatched ASCII character in SecondString subtracted from the
545 first mismatched ASCII character in FirstString.
547 If FirstString is NULL, then ASSERT().
548 If SecondString is NULL, then ASSERT().
549 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
550 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
551 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
552 than PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
554 @param FirstString Pointer to a Null-terminated ASCII string.
555 @param SecondString Pointer to a Null-terminated ASCII string.
557 @retval 0 FirstString is identical to SecondString.
558 @retval !=0 FirstString is not identical to SecondString.
564 IN CONST CHAR8
*FirstString
,
565 IN CONST CHAR8
*SecondString
,
570 Concatenates one Null-terminated ASCII string to another Null-terminated
571 ASCII string, and returns the concatenated ASCII string.
573 This function concatenates two Null-terminated ASCII strings. The contents of
574 Null-terminated ASCII string Source are concatenated to the end of Null-
575 terminated ASCII string Destination. The Null-terminated concatenated ASCII
578 If Destination is NULL, then ASSERT().
579 If Source is NULL, then ASSERT().
580 If PcdMaximumAsciiStringLength is not zero and Destination contains more than
581 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
582 If PcdMaximumAsciiStringLength is not zero and Source contains more than
583 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
584 If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
585 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
586 ASCII characters, then ASSERT().
588 @param Destination Pointer to a Null-terminated ASCII string.
589 @param Source Pointer to a Null-terminated ASCII string.
597 IN OUT CHAR8
*Destination
,
598 IN CONST CHAR8
*Source
602 Concatenates one Null-terminated ASCII string with a maximum length to the
603 end of another Null-terminated ASCII string, and returns the concatenated
606 This function concatenates two Null-terminated ASCII strings. The contents
607 of Null-terminated ASCII string Source are concatenated to the end of Null-
608 terminated ASCII string Destination, and Destination is returned. At most,
609 Length ASCII characters are concatenated from Source to the end of
610 Destination, and Destination is always Null-terminated. If Length is 0, then
611 Destination is returned unmodified. If Source and Destination overlap, then
612 the results are undefined.
614 If Destination is NULL, then ASSERT().
615 If Source is NULL, then ASSERT().
616 If Source and Destination overlap, then ASSERT().
617 If PcdMaximumAsciiStringLength is not zero, and Destination contains more
618 than PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
619 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
620 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
621 If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
622 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
623 ASCII characters, then ASSERT().
625 @param Destination Pointer to a Null-terminated ASCII string.
626 @param Source Pointer to a Null-terminated ASCII string.
627 @param Length Maximum number of ASCII characters to concatenate from
636 IN OUT CHAR8
*Destination
,
637 IN CONST CHAR8
*Source
,
642 Converts an 8-bit value to an 8-bit BCD value.
644 Converts the 8-bit value specified by Value to BCD. The BCD value is
647 If Value >= 100, then ASSERT().
649 @param Value The 8-bit value to convert to BCD. Range 0..99.
651 @return The BCD value
661 Converts an 8-bit BCD value to an 8-bit value.
663 Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit
666 If Value >= 0xA0, then ASSERT().
667 If (Value & 0x0F) >= 0x0A, then ASSERT().
669 @param Value The 8-bit BCD value to convert to an 8-bit value.
671 @return The 8-bit value is returned.
681 // LIST_ENTRY definition
683 typedef struct _LIST_ENTRY LIST_ENTRY
;
686 LIST_ENTRY
*ForwardLink
;
687 LIST_ENTRY
*BackLink
;
691 // Linked List Functions and Macros
695 Initializes the head node of a doubly linked list that is declared as a
696 global variable in a module.
698 Initializes the forward and backward links of a new linked list. After
699 initializing a linked list with this macro, the other linked list functions
700 may be used to add and remove nodes from the linked list. This macro results
701 in smaller executables by initializing the linked list in the data section,
702 instead if calling the InitializeListHead() function to perform the
703 equivalent operation.
705 @param ListHead The head note of a list to initiailize.
708 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&ListHead, &ListHead}
711 Initializes the head node of a doubly linked list, and returns the pointer to
712 the head node of the doubly linked list.
714 Initializes the forward and backward links of a new linked list. After
715 initializing a linked list with this function, the other linked list
716 functions may be used to add and remove nodes from the linked list. It is up
717 to the caller of this function to allocate the memory for ListHead.
719 If ListHead is NULL, then ASSERT().
721 @param ListHead A pointer to the head node of a new doubly linked list.
729 IN LIST_ENTRY
*ListHead
733 Adds a node to the beginning of a doubly linked list, and returns the pointer
734 to the head node of the doubly linked list.
736 Adds the node Entry at the beginning of the doubly linked list denoted by
737 ListHead, and returns ListHead.
739 If ListHead is NULL, then ASSERT().
740 If Entry is NULL, then ASSERT().
741 If ListHead was not initialized with InitializeListHead(), then ASSERT().
742 If PcdMaximumLinkedListLenth is not zero, and ListHead contains more than
743 PcdMaximumLinkedListLenth nodes, then ASSERT().
745 @param ListHead A pointer to the head node of a doubly linked list.
746 @param Entry A pointer to a node that is to be inserted at the beginning
747 of a doubly linked list.
755 IN LIST_ENTRY
*ListHead
,
760 Adds a node to the end of a doubly linked list, and returns the pointer to
761 the head node of the doubly linked list.
763 Adds the node Entry to the end of the doubly linked list denoted by ListHead,
764 and returns ListHead.
766 If ListHead is NULL, then ASSERT().
767 If Entry is NULL, then ASSERT().
768 If ListHead was not initialized with InitializeListHead(), then ASSERT().
769 If PcdMaximumLinkedListLenth is not zero, and ListHead contains more than
770 PcdMaximumLinkedListLenth nodes, then ASSERT().
772 @param ListHead A pointer to the head node of a doubly linked list.
773 @param Entry A pointer to a node that is to be added at the end of the
782 IN LIST_ENTRY
*ListHead
,
787 Retrieves the first node of a doubly linked list.
789 Returns the first node of a doubly linked list. List must have been
790 initialized with InitializeListHead(). If List is empty, then NULL is
793 If List is NULL, then ASSERT().
794 If List was not initialized with InitializeListHead(), then ASSERT().
795 If PcdMaximumLinkedListLenth is not zero, and List contains more than
796 PcdMaximumLinkedListLenth nodes, then ASSERT().
798 @param List A pointer to the head node of a doubly linked list.
800 @return The first node of a doubly linked list.
801 @retval NULL The list is empty.
807 IN CONST LIST_ENTRY
*List
811 Retrieves the next node of a doubly linked list.
813 Returns the node of a doubly linked list that follows Node. List must have
814 been initialized with InitializeListHead(). If List is empty, then List is
817 If List is NULL, then ASSERT().
818 If Node is NULL, then ASSERT().
819 If List was not initialized with InitializeListHead(), then ASSERT().
820 If PcdMaximumLinkedListLenth is not zero, and List contains more than
821 PcdMaximumLinkedListLenth nodes, then ASSERT().
822 If Node is not a node in List, then ASSERT().
824 @param List A pointer to the head node of a doubly linked list.
825 @param Node A pointer to a node in the doubly linked list.
827 @return Pointer to the next node if one exists. Otherwise a null value which
828 is actually List is returned.
834 IN CONST LIST_ENTRY
*List
,
835 IN CONST LIST_ENTRY
*Node
839 Checks to see if a doubly linked list is empty or not.
841 Checks to see if the doubly linked list is empty. If the linked list contains
842 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
844 If ListHead is NULL, then ASSERT().
845 If ListHead was not initialized with InitializeListHead(), then ASSERT().
846 If PcdMaximumLinkedListLenth is not zero, and List contains more than
847 PcdMaximumLinkedListLenth nodes, then ASSERT().
849 @param ListHead A pointer to the head node of a doubly linked list.
851 @retval TRUE The linked list is empty.
852 @retval FALSE The linked list is not empty.
858 IN CONST LIST_ENTRY
*ListHead
862 Determines if a node in a doubly linked list is null.
864 Returns FALSE if Node is one of the nodes in the doubly linked list specified
865 by List. Otherwise, TRUE is returned. List must have been initialized with
866 InitializeListHead().
868 If List is NULL, then ASSERT().
869 If Node is NULL, then ASSERT().
870 If List was not initialized with InitializeListHead(), then ASSERT().
871 If PcdMaximumLinkedListLenth is not zero, and List contains more than
872 PcdMaximumLinkedListLenth nodes, then ASSERT().
873 If Node is not a node in List and Node is not equal to List, then ASSERT().
875 @param List A pointer to the head node of a doubly linked list.
876 @param Node A pointer to a node in the doubly linked list.
878 @retval TRUE Node is one of the nodes in the doubly linked list.
879 @retval FALSE Node is not one of the nodes in the doubly linked list.
885 IN CONST LIST_ENTRY
*List
,
886 IN CONST LIST_ENTRY
*Node
890 Determines if a node the last node in a doubly linked list.
892 Returns TRUE if Node is the last node in the doubly linked list specified by
893 List. Otherwise, FALSE is returned. List must have been initialized with
894 InitializeListHead().
896 If List is NULL, then ASSERT().
897 If Node is NULL, then ASSERT().
898 If List was not initialized with InitializeListHead(), then ASSERT().
899 If PcdMaximumLinkedListLenth is not zero, and List contains more than
900 PcdMaximumLinkedListLenth nodes, then ASSERT().
901 If Node is not a node in List, then ASSERT().
903 @param List A pointer to the head node of a doubly linked list.
904 @param Node A pointer to a node in the doubly linked list.
906 @retval TRUE Node is the last node in the linked list.
907 @retval FALSE Node is not the last node in the linked list.
913 IN CONST LIST_ENTRY
*List
,
914 IN CONST LIST_ENTRY
*Node
918 Swaps the location of two nodes in a doubly linked list, and returns the
919 first node after the swap.
921 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
922 Otherwise, the location of the FirstEntry node is swapped with the location
923 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
924 same double linked list as FirstEntry and that double linked list must have
925 been initialized with InitializeListHead(). SecondEntry is returned after the
928 If FirstEntry is NULL, then ASSERT().
929 If SecondEntry is NULL, then ASSERT().
930 If SecondEntry and FirstEntry are not in the same linked list, then ASSERT().
931 If PcdMaximumLinkedListLenth is not zero, and the linked list containing
932 FirstEntry and SecondEntry contains more than PcdMaximumLinkedListLenth
933 nodes, then ASSERT().
935 @param FirstEntry A pointer to a node in a linked list.
936 @param SecondEntry A pointer to another node in the same linked list.
942 IN LIST_ENTRY
*FirstEntry
,
943 IN LIST_ENTRY
*SecondEntry
947 Removes a node from a doubly linked list, and returns the node that follows
950 Removes the node Entry from a doubly linked list. It is up to the caller of
951 this function to release the memory used by this node if that is required. On
952 exit, the node following Entry in the doubly linked list is returned. If
953 Entry is the only node in the linked list, then the head node of the linked
956 If Entry is NULL, then ASSERT().
957 If Entry is the head node of an empty list, then ASSERT().
958 If PcdMaximumLinkedListLenth is not zero, and the linked list containing
959 Entry contains more than PcdMaximumLinkedListLenth nodes, then ASSERT().
961 @param Entry A pointer to a node in a linked list
969 IN CONST LIST_ENTRY
*Entry
977 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
978 with zeros. The shifted value is returned.
980 This function shifts the 64-bit value Operand to the left by Count bits. The
981 low Count bits are set to zero. The shifted value is returned.
983 If Count is greater than 63, then ASSERT().
985 @param Operand The 64-bit operand to shift left.
986 @param Count The number of bits to shift left.
988 @return Operand << Count
999 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
1000 filled with zeros. The shifted value is returned.
1002 This function shifts the 64-bit value Operand to the right by Count bits. The
1003 high Count bits are set to zero. The shifted value is returned.
1005 If Count is greater than 63, then ASSERT().
1007 @param Operand The 64-bit operand to shift right.
1008 @param Count The number of bits to shift right.
1010 @return Operand >> Count
1021 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
1022 with original integer's bit 63. The shifted value is returned.
1024 This function shifts the 64-bit value Operand to the right by Count bits. The
1025 high Count bits are set to bit 63 of Operand. The shifted value is returned.
1027 If Count is greater than 63, then ASSERT().
1029 @param Operand The 64-bit operand to shift right.
1030 @param Count The number of bits to shift right.
1032 @return Operand >> Count
1043 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
1044 with the high bits that were rotated.
1046 This function rotates the 32-bit value Operand to the left by Count bits. The
1047 low Count bits are fill with the high Count bits of Operand. The rotated
1050 If Count is greater than 31, then ASSERT().
1052 @param Operand The 32-bit operand to rotate left.
1053 @param Count The number of bits to rotate left.
1055 @return Operand <<< Count
1066 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
1067 with the low bits that were rotated.
1069 This function rotates the 32-bit value Operand to the right by Count bits.
1070 The high Count bits are fill with the low Count bits of Operand. The rotated
1073 If Count is greater than 31, then ASSERT().
1075 @param Operand The 32-bit operand to rotate right.
1076 @param Count The number of bits to rotate right.
1078 @return Operand >>> Count
1089 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
1090 with the high bits that were rotated.
1092 This function rotates the 64-bit value Operand to the left by Count bits. The
1093 low Count bits are fill with the high Count bits of Operand. The rotated
1096 If Count is greater than 63, then ASSERT().
1098 @param Operand The 64-bit operand to rotate left.
1099 @param Count The number of bits to rotate left.
1101 @return Operand <<< Count
1112 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
1113 with the high low bits that were rotated.
1115 This function rotates the 64-bit value Operand to the right by Count bits.
1116 The high Count bits are fill with the low Count bits of Operand. The rotated
1119 If Count is greater than 63, then ASSERT().
1121 @param Operand The 64-bit operand to rotate right.
1122 @param Count The number of bits to rotate right.
1124 @return Operand >>> Count
1135 Returns the bit position of the lowest bit set in a 32-bit value.
1137 This function computes the bit position of the lowest bit set in the 32-bit
1138 value specified by Operand. If Operand is zero, then -1 is returned.
1139 Otherwise, a value between 0 and 31 is returned.
1141 @param Operand The 32-bit operand to evaluate.
1143 @return Position of the lowest bit set in Operand if found.
1144 @retval -1 Operand is zero.
1154 Returns the bit position of the lowest bit set in a 64-bit value.
1156 This function computes the bit position of the lowest bit set in the 64-bit
1157 value specified by Operand. If Operand is zero, then -1 is returned.
1158 Otherwise, a value between 0 and 63 is returned.
1160 @param Operand The 64-bit operand to evaluate.
1162 @return Position of the lowest bit set in Operand if found.
1163 @retval -1 Operand is zero.
1173 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
1176 This function computes the bit position of the highest bit set in the 32-bit
1177 value specified by Operand. If Operand is zero, then -1 is returned.
1178 Otherwise, a value between 0 and 31 is returned.
1180 @param Operand The 32-bit operand to evaluate.
1182 @return Position of the highest bit set in Operand if found.
1183 @retval -1 Operand is zero.
1193 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
1196 This function computes the bit position of the highest bit set in the 64-bit
1197 value specified by Operand. If Operand is zero, then -1 is returned.
1198 Otherwise, a value between 0 and 63 is returned.
1200 @param Operand The 64-bit operand to evaluate.
1202 @return Position of the highest bit set in Operand if found.
1203 @retval -1 Operand is zero.
1213 Returns the value of the highest bit set in a 32-bit value. Equivalent to
1214 1 << HighBitSet32(x).
1216 This function computes the value of the highest bit set in the 32-bit value
1217 specified by Operand. If Operand is zero, then zero is returned.
1219 @param Operand The 32-bit operand to evaluate.
1221 @return 1 << HighBitSet32(Operand)
1222 @retval 0 Operand is zero.
1232 Returns the value of the highest bit set in a 64-bit value. Equivalent to
1233 1 << HighBitSet64(x).
1235 This function computes the value of the highest bit set in the 64-bit value
1236 specified by Operand. If Operand is zero, then zero is returned.
1238 @param Operand The 64-bit operand to evaluate.
1240 @return 1 << HighBitSet64(Operand)
1241 @retval 0 Operand is zero.
1251 Switches the endianess of a 16-bit integer.
1253 This function swaps the bytes in a 16-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 16-bit unsigned value.
1259 @return The byte swaped Operand.
1269 Switches the endianess of a 32-bit integer.
1271 This function swaps the bytes in a 32-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 32-bit unsigned value.
1277 @return The byte swaped Operand.
1287 Switches the endianess of a 64-bit integer.
1289 This function swaps the bytes in a 64-bit unsigned value to switch the value
1290 from little endian to big endian or vice versa. The byte swapped value is
1293 @param Operand A 64-bit unsigned value.
1295 @return The byte swaped Operand.
1305 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
1306 generates a 64-bit unsigned result.
1308 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
1309 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1310 bit unsigned result is returned.
1312 If the result overflows, then ASSERT().
1314 @param Multiplicand A 64-bit unsigned value.
1315 @param Multiplier A 32-bit unsigned value.
1317 @return Multiplicand * Multiplier
1323 IN UINT64 Multiplicand
,
1324 IN UINT32 Multiplier
1328 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
1329 generates a 64-bit unsigned result.
1331 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
1332 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1333 bit unsigned result is returned.
1335 If the result overflows, then ASSERT().
1337 @param Multiplicand A 64-bit unsigned value.
1338 @param Multiplier A 64-bit unsigned value.
1340 @return Multiplicand * Multiplier
1346 IN UINT64 Multiplicand
,
1347 IN UINT64 Multiplier
1351 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
1352 64-bit signed result.
1354 This function multiples the 64-bit signed value Multiplicand by the 64-bit
1355 signed value Multiplier and generates a 64-bit signed result. This 64-bit
1356 signed result is returned.
1358 If the result overflows, then ASSERT().
1360 @param Multiplicand A 64-bit signed value.
1361 @param Multiplier A 64-bit signed value.
1363 @return Multiplicand * Multiplier
1369 IN INT64 Multiplicand
,
1374 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1375 a 64-bit unsigned result.
1377 This function divides the 64-bit unsigned value Dividend by the 32-bit
1378 unsigned value Divisor and generates a 64-bit unsigned quotient. This
1379 function returns the 64-bit unsigned quotient.
1381 If Divisor is 0, then ASSERT().
1383 @param Dividend A 64-bit unsigned value.
1384 @param Divisor A 32-bit unsigned value.
1386 @return Dividend / Divisor
1397 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1398 a 32-bit unsigned remainder.
1400 This function divides the 64-bit unsigned value Dividend by the 32-bit
1401 unsigned value Divisor and generates a 32-bit remainder. This function
1402 returns the 32-bit unsigned remainder.
1404 If Divisor is 0, then ASSERT().
1406 @param Dividend A 64-bit unsigned value.
1407 @param Divisor A 32-bit unsigned value.
1409 @return Dividend % Divisor
1420 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1421 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
1423 This function divides the 64-bit unsigned value Dividend by the 32-bit
1424 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
1425 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
1426 This function returns the 64-bit unsigned quotient.
1428 If Divisor is 0, then ASSERT().
1430 @param Dividend A 64-bit unsigned value.
1431 @param Divisor A 32-bit unsigned value.
1432 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
1433 optional and may be NULL.
1435 @return Dividend / Divisor
1440 DivU64x32Remainder (
1443 OUT UINT32
*Remainder OPTIONAL
1447 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
1448 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
1450 This function divides the 64-bit unsigned value Dividend by the 64-bit
1451 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
1452 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
1453 This function returns the 64-bit unsigned quotient.
1455 If Divisor is 0, then ASSERT().
1457 @param Dividend A 64-bit unsigned value.
1458 @param Divisor A 64-bit unsigned value.
1459 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
1460 optional and may be NULL.
1462 @return Dividend / Divisor
1467 DivU64x64Remainder (
1470 OUT UINT64
*Remainder OPTIONAL
1474 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
1475 64-bit signed result and a optional 64-bit signed remainder.
1477 This function divides the 64-bit signed value Dividend by the 64-bit signed
1478 value Divisor and generates a 64-bit signed quotient. If Remainder is not
1479 NULL, then the 64-bit signed remainder is returned in Remainder. This
1480 function returns the 64-bit signed quotient.
1482 If Divisor is 0, then ASSERT().
1484 @param Dividend A 64-bit signed value.
1485 @param Divisor A 64-bit signed value.
1486 @param Remainder A pointer to a 64-bit signed value. This parameter is
1487 optional and may be NULL.
1489 @return Dividend / Divisor
1494 DivS64x64Remainder (
1497 OUT INT64
*Remainder OPTIONAL
1501 Reads a 16-bit value from memory that may be unaligned.
1503 This function returns the 16-bit value pointed to by Buffer. The function
1504 guarantees that the read operation does not produce an alignment fault.
1506 If the Buffer is NULL, then ASSERT().
1508 @param Buffer Pointer to a 16-bit value that may be unaligned.
1516 IN CONST UINT16
*Uint16
1520 Writes a 16-bit value to memory that may be unaligned.
1522 This function writes the 16-bit value specified by Value to Buffer. Value is
1523 returned. The function guarantees that the write operation does not produce
1526 If the Buffer is NULL, then ASSERT().
1528 @param Buffer Pointer to a 16-bit value that may be unaligned.
1529 @param Value 16-bit value to write to Buffer.
1542 Reads a 24-bit value from memory that may be unaligned.
1544 This function returns the 24-bit value pointed to by Buffer. The function
1545 guarantees that the read operation does not produce an alignment fault.
1547 If the Buffer is NULL, then ASSERT().
1549 @param Buffer Pointer to a 24-bit value that may be unaligned.
1551 @return The value read.
1557 IN CONST UINT32
*Buffer
1561 Writes a 24-bit value to memory that may be unaligned.
1563 This function writes the 24-bit value specified by Value to Buffer. Value is
1564 returned. The function guarantees that the write operation does not produce
1567 If the Buffer is NULL, then ASSERT().
1569 @param Buffer Pointer to a 24-bit value that may be unaligned.
1570 @param Value 24-bit value to write to Buffer.
1572 @return The value written.
1583 Reads a 32-bit value from memory that may be unaligned.
1585 This function returns the 32-bit value pointed to by Buffer. The function
1586 guarantees that the read operation does not produce an alignment fault.
1588 If the Buffer is NULL, then ASSERT().
1590 @param Buffer Pointer to a 32-bit value that may be unaligned.
1598 IN CONST UINT32
*Uint32
1602 Writes a 32-bit value to memory that may be unaligned.
1604 This function writes the 32-bit value specified by Value to Buffer. Value is
1605 returned. The function guarantees that the write operation does not produce
1608 If the Buffer is NULL, then ASSERT().
1610 @param Buffer Pointer to a 32-bit value that may be unaligned.
1611 @param Value 32-bit value to write to Buffer.
1624 Reads a 64-bit value from memory that may be unaligned.
1626 This function returns the 64-bit value pointed to by Buffer. The function
1627 guarantees that the read operation does not produce an alignment fault.
1629 If the Buffer is NULL, then ASSERT().
1631 @param Buffer Pointer to a 64-bit value that may be unaligned.
1639 IN CONST UINT64
*Uint64
1643 Writes a 64-bit value to memory that may be unaligned.
1645 This function writes the 64-bit value specified by Value to Buffer. Value is
1646 returned. The function guarantees that the write operation does not produce
1649 If the Buffer is NULL, then ASSERT().
1651 @param Buffer Pointer to a 64-bit value that may be unaligned.
1652 @param Value 64-bit value to write to Buffer.
1665 // Bit Field Functions
1669 Returns a bit field from an 8-bit value.
1671 Returns the bitfield specified by the StartBit and the EndBit from Operand.
1673 If 8-bit operations are not supported, then ASSERT().
1674 If StartBit is greater than 7, then ASSERT().
1675 If EndBit is greater than 7, then ASSERT().
1676 If EndBit is less than or equal to StartBit, then ASSERT().
1678 @param Operand Operand on which to perform the bitfield operation.
1679 @param StartBit The ordinal of the least significant bit in the bit field.
1681 @param EndBit The ordinal of the most significant bit in the bit field.
1684 @return The bit field read.
1696 Writes a bit field to an 8-bit value, and returns the result.
1698 Writes Value to the bit field specified by the StartBit and the EndBit in
1699 Operand. All other bits in Operand are preserved. The new 8-bit value is
1702 If 8-bit operations are not supported, then ASSERT().
1703 If StartBit is greater than 7, then ASSERT().
1704 If EndBit is greater than 7, then ASSERT().
1705 If EndBit is less than or equal to StartBit, then ASSERT().
1707 @param Operand Operand on which to perform the bitfield operation.
1708 @param StartBit The ordinal of the least significant bit in the bit field.
1710 @param EndBit The ordinal of the most significant bit in the bit field.
1712 @param Value New value of the bit field.
1714 @return The new 8-bit value.
1727 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
1730 Performs a bitwise inclusive OR between the bit field specified by StartBit
1731 and EndBit in Operand and the value specified by OrData. All other bits in
1732 Operand are preserved. The new 8-bit value is returned.
1734 If 8-bit operations are not supported, then ASSERT().
1735 If StartBit is greater than 7, then ASSERT().
1736 If EndBit is greater than 7, then ASSERT().
1737 If EndBit is less than or equal to StartBit, then ASSERT().
1739 @param Operand Operand on which to perform the bitfield operation.
1740 @param StartBit The ordinal of the least significant bit in the bit field.
1742 @param EndBit The ordinal of the most significant bit in the bit field.
1744 @param OrData The value to OR with the read value from the value
1746 @return The new 8-bit value.
1759 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
1762 Performs a bitwise AND between the bit field specified by StartBit and EndBit
1763 in Operand and the value specified by AndData. All other bits in Operand are
1764 preserved. The new 8-bit value is returned.
1766 If 8-bit operations are not supported, then ASSERT().
1767 If StartBit is greater than 7, then ASSERT().
1768 If EndBit is greater than 7, then ASSERT().
1769 If EndBit is less than or equal to StartBit, then ASSERT().
1771 @param Operand Operand on which to perform the bitfield operation.
1772 @param StartBit The ordinal of the least significant bit in the bit field.
1774 @param EndBit The ordinal of the most significant bit in the bit field.
1776 @param AndData The value to AND with the read value from the value.
1778 @return The new 8-bit value.
1791 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
1792 bitwise OR, and returns the result.
1794 Performs a bitwise AND between the bit field specified by StartBit and EndBit
1795 in Operand and the value specified by AndData, followed by a bitwise
1796 inclusive OR with value specified by OrData. All other bits in Operand are
1797 preserved. The new 8-bit value is returned.
1799 If 8-bit operations are not supported, then ASSERT().
1800 If StartBit is greater than 7, then ASSERT().
1801 If EndBit is greater than 7, then ASSERT().
1802 If EndBit is less than or equal to StartBit, then ASSERT().
1804 @param Operand Operand on which to perform the bitfield operation.
1805 @param StartBit The ordinal of the least significant bit in the bit field.
1807 @param EndBit The ordinal of the most significant bit in the bit field.
1809 @param AndData The value to AND with the read value from the value.
1810 @param OrData The value to OR with the result of the AND operation.
1812 @return The new 8-bit value.
1817 BitFieldAndThenOr8 (
1826 Returns a bit field from a 16-bit value.
1828 Returns the bitfield specified by the StartBit and the EndBit from Operand.
1830 If 16-bit operations are not supported, then ASSERT().
1831 If StartBit is greater than 15, then ASSERT().
1832 If EndBit is greater than 15, then ASSERT().
1833 If EndBit is less than or equal to StartBit, then ASSERT().
1835 @param Operand Operand on which to perform the bitfield operation.
1836 @param StartBit The ordinal of the least significant bit in the bit field.
1838 @param EndBit The ordinal of the most significant bit in the bit field.
1841 @return The bit field read.
1853 Writes a bit field to a 16-bit value, and returns the result.
1855 Writes Value to the bit field specified by the StartBit and the EndBit in
1856 Operand. All other bits in Operand are preserved. The new 16-bit value is
1859 If 16-bit operations are not supported, then ASSERT().
1860 If StartBit is greater than 15, then ASSERT().
1861 If EndBit is greater than 15, then ASSERT().
1862 If EndBit is less than or equal to StartBit, then ASSERT().
1864 @param Operand Operand on which to perform the bitfield operation.
1865 @param StartBit The ordinal of the least significant bit in the bit field.
1867 @param EndBit The ordinal of the most significant bit in the bit field.
1869 @param Value New value of the bit field.
1871 @return The new 16-bit value.
1884 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
1887 Performs a bitwise inclusive OR between the bit field specified by StartBit
1888 and EndBit in Operand and the value specified by OrData. All other bits in
1889 Operand are preserved. The new 16-bit value is returned.
1891 If 16-bit operations are not supported, then ASSERT().
1892 If StartBit is greater than 15, then ASSERT().
1893 If EndBit is greater than 15, then ASSERT().
1894 If EndBit is less than or equal to StartBit, then ASSERT().
1896 @param Operand Operand on which to perform the bitfield operation.
1897 @param StartBit The ordinal of the least significant bit in the bit field.
1899 @param EndBit The ordinal of the most significant bit in the bit field.
1901 @param OrData The value to OR with the read value from the value
1903 @return The new 16-bit value.
1916 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
1919 Performs a bitwise AND between the bit field specified by StartBit and EndBit
1920 in Operand and the value specified by AndData. All other bits in Operand are
1921 preserved. The new 16-bit value is returned.
1923 If 16-bit operations are not supported, then ASSERT().
1924 If StartBit is greater than 15, then ASSERT().
1925 If EndBit is greater than 15, then ASSERT().
1926 If EndBit is less than or equal to StartBit, then ASSERT().
1928 @param Operand Operand on which to perform the bitfield operation.
1929 @param StartBit The ordinal of the least significant bit in the bit field.
1931 @param EndBit The ordinal of the most significant bit in the bit field.
1933 @param AndData The value to AND with the read value from the value
1935 @return The new 16-bit value.
1948 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
1949 bitwise OR, and returns the result.
1951 Performs a bitwise AND between the bit field specified by StartBit and EndBit
1952 in Operand and the value specified by AndData, followed by a bitwise
1953 inclusive OR with value specified by OrData. All other bits in Operand are
1954 preserved. The new 16-bit value is returned.
1956 If 16-bit operations are not supported, then ASSERT().
1957 If StartBit is greater than 15, then ASSERT().
1958 If EndBit is greater than 15, then ASSERT().
1959 If EndBit is less than or equal to StartBit, then ASSERT().
1961 @param Operand Operand on which to perform the bitfield operation.
1962 @param StartBit The ordinal of the least significant bit in the bit field.
1964 @param EndBit The ordinal of the most significant bit in the bit field.
1966 @param AndData The value to AND with the read value from the value.
1967 @param OrData The value to OR with the result of the AND operation.
1969 @return The new 16-bit value.
1974 BitFieldAndThenOr16 (
1983 Returns a bit field from a 32-bit value.
1985 Returns the bitfield specified by the StartBit and the EndBit from Operand.
1987 If 32-bit operations are not supported, then ASSERT().
1988 If StartBit is greater than 31, then ASSERT().
1989 If EndBit is greater than 31, then ASSERT().
1990 If EndBit is less than or equal to StartBit, then ASSERT().
1992 @param Operand Operand on which to perform the bitfield operation.
1993 @param StartBit The ordinal of the least significant bit in the bit field.
1995 @param EndBit The ordinal of the most significant bit in the bit field.
1998 @return The bit field read.
2010 Writes a bit field to a 32-bit value, and returns the result.
2012 Writes Value to the bit field specified by the StartBit and the EndBit in
2013 Operand. All other bits in Operand are preserved. The new 32-bit value is
2016 If 32-bit operations are not supported, then ASSERT().
2017 If StartBit is greater than 31, then ASSERT().
2018 If EndBit is greater than 31, then ASSERT().
2019 If EndBit is less than or equal to StartBit, then ASSERT().
2021 @param Operand Operand on which to perform the bitfield operation.
2022 @param StartBit The ordinal of the least significant bit in the bit field.
2024 @param EndBit The ordinal of the most significant bit in the bit field.
2026 @param Value New value of the bit field.
2028 @return The new 32-bit value.
2041 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
2044 Performs a bitwise inclusive OR between the bit field specified by StartBit
2045 and EndBit in Operand and the value specified by OrData. All other bits in
2046 Operand are preserved. The new 32-bit value is returned.
2048 If 32-bit operations are not supported, then ASSERT().
2049 If StartBit is greater than 31, then ASSERT().
2050 If EndBit is greater than 31, then ASSERT().
2051 If EndBit is less than or equal to StartBit, then ASSERT().
2053 @param Operand Operand on which to perform the bitfield operation.
2054 @param StartBit The ordinal of the least significant bit in the bit field.
2056 @param EndBit The ordinal of the most significant bit in the bit field.
2058 @param OrData The value to OR with the read value from the value
2060 @return The new 32-bit value.
2073 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
2076 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2077 in Operand and the value specified by AndData. All other bits in Operand are
2078 preserved. The new 32-bit value is returned.
2080 If 32-bit operations are not supported, then ASSERT().
2081 If StartBit is greater than 31, then ASSERT().
2082 If EndBit is greater than 31, then ASSERT().
2083 If EndBit is less than or equal to StartBit, then ASSERT().
2085 @param Operand Operand on which to perform the bitfield operation.
2086 @param StartBit The ordinal of the least significant bit in the bit field.
2088 @param EndBit The ordinal of the most significant bit in the bit field.
2090 @param AndData The value to AND with the read value from the value
2092 @return The new 32-bit value.
2105 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
2106 bitwise OR, and returns the result.
2108 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2109 in Operand and the value specified by AndData, followed by a bitwise
2110 inclusive OR with value specified by OrData. All other bits in Operand are
2111 preserved. The new 32-bit value is returned.
2113 If 32-bit operations are not supported, then ASSERT().
2114 If StartBit is greater than 31, then ASSERT().
2115 If EndBit is greater than 31, then ASSERT().
2116 If EndBit is less than or equal to StartBit, then ASSERT().
2118 @param Operand Operand on which to perform the bitfield operation.
2119 @param StartBit The ordinal of the least significant bit in the bit field.
2121 @param EndBit The ordinal of the most significant bit in the bit field.
2123 @param AndData The value to AND with the read value from the value.
2124 @param OrData The value to OR with the result of the AND operation.
2126 @return The new 32-bit value.
2131 BitFieldAndThenOr32 (
2140 Returns a bit field from a 64-bit value.
2142 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2144 If 64-bit operations are not supported, then ASSERT().
2145 If StartBit is greater than 63, then ASSERT().
2146 If EndBit is greater than 63, then ASSERT().
2147 If EndBit is less than or equal to StartBit, then ASSERT().
2149 @param Operand Operand on which to perform the bitfield operation.
2150 @param StartBit The ordinal of the least significant bit in the bit field.
2152 @param EndBit The ordinal of the most significant bit in the bit field.
2155 @return The bit field read.
2167 Writes a bit field to a 64-bit value, and returns the result.
2169 Writes Value to the bit field specified by the StartBit and the EndBit in
2170 Operand. All other bits in Operand are preserved. The new 64-bit value is
2173 If 64-bit operations are not supported, then ASSERT().
2174 If StartBit is greater than 63, then ASSERT().
2175 If EndBit is greater than 63, then ASSERT().
2176 If EndBit is less than or equal to StartBit, then ASSERT().
2178 @param Operand Operand on which to perform the bitfield operation.
2179 @param StartBit The ordinal of the least significant bit in the bit field.
2181 @param EndBit The ordinal of the most significant bit in the bit field.
2183 @param Value New value of the bit field.
2185 @return The new 64-bit value.
2198 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
2201 Performs a bitwise inclusive OR between the bit field specified by StartBit
2202 and EndBit in Operand and the value specified by OrData. All other bits in
2203 Operand are preserved. The new 64-bit value is returned.
2205 If 64-bit operations are not supported, then ASSERT().
2206 If StartBit is greater than 63, then ASSERT().
2207 If EndBit is greater than 63, then ASSERT().
2208 If EndBit is less than or equal to StartBit, then ASSERT().
2210 @param Operand Operand on which to perform the bitfield operation.
2211 @param StartBit The ordinal of the least significant bit in the bit field.
2213 @param EndBit The ordinal of the most significant bit in the bit field.
2215 @param OrData The value to OR with the read value from the value
2217 @return The new 64-bit value.
2230 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
2233 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2234 in Operand and the value specified by AndData. All other bits in Operand are
2235 preserved. The new 64-bit value is returned.
2237 If 64-bit operations are not supported, then ASSERT().
2238 If StartBit is greater than 63, then ASSERT().
2239 If EndBit is greater than 63, then ASSERT().
2240 If EndBit is less than or equal to StartBit, then ASSERT().
2242 @param Operand Operand on which to perform the bitfield operation.
2243 @param StartBit The ordinal of the least significant bit in the bit field.
2245 @param EndBit The ordinal of the most significant bit in the bit field.
2247 @param AndData The value to AND with the read value from the value
2249 @return The new 64-bit value.
2262 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
2263 bitwise OR, and returns the result.
2265 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2266 in Operand and the value specified by AndData, followed by a bitwise
2267 inclusive OR with value specified by OrData. All other bits in Operand are
2268 preserved. The new 64-bit value is returned.
2270 If 64-bit operations are not supported, then ASSERT().
2271 If StartBit is greater than 63, then ASSERT().
2272 If EndBit is greater than 63, then ASSERT().
2273 If EndBit is less than or equal to StartBit, then ASSERT().
2275 @param Operand Operand on which to perform the bitfield operation.
2276 @param StartBit The ordinal of the least significant bit in the bit field.
2278 @param EndBit The ordinal of the most significant bit in the bit field.
2280 @param AndData The value to AND with the read value from the value.
2281 @param OrData The value to OR with the result of the AND operation.
2283 @return The new 64-bit value.
2288 BitFieldAndThenOr64 (
2297 // Base Library Synchronization Functions
2301 Retrieves the architecture specific spin lock alignment requirements for
2302 optimal spin lock performance.
2304 This function retrieves the spin lock alignment requirements for optimal
2305 performance on a given CPU architecture. The spin lock alignment must be a
2306 power of two and is returned by this function. If there are no alignment
2307 requirements, then 1 must be returned. The spin lock synchronization
2308 functions must function correctly if the spin lock size and alignment values
2309 returned by this function are not used at all. These values are hints to the
2310 consumers of the spin lock synchronization functions to obtain optimal spin
2313 @return The architecture specific spin lock alignment.
2318 GetSpinLockProperties (
2323 Initializes a spin lock to the released state and returns the spin lock.
2325 This function initializes the spin lock specified by SpinLock to the released
2326 state, and returns SpinLock. Optimal performance can be achieved by calling
2327 GetSpinLockProperties() to determine the size and alignment requirements for
2330 If SpinLock is NULL, then ASSERT().
2332 @param SpinLock A pointer to the spin lock to initialize to the released
2340 InitializeSpinLock (
2341 IN SPIN_LOCK
*SpinLock
2345 Waits until a spin lock can be placed in the acquired state.
2347 This function checks the state of the spin lock specified by SpinLock. If
2348 SpinLock is in the released state, then this function places SpinLock in the
2349 acquired state and returns SpinLock. Otherwise, this function waits
2350 indefinitely for the spin lock to be released, and then places it in the
2351 acquired state and returns SpinLock. All state transitions of SpinLock must
2352 be performed using MP safe mechanisms.
2354 If SpinLock is NULL, then ASSERT().
2355 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
2356 If PcdSpinLockTimeout is not zero, and SpinLock is can not be acquired in
2357 PcdSpinLockTimeout microseconds, then ASSERT().
2359 @param SpinLock A pointer to the spin lock to place in the acquired state.
2367 IN SPIN_LOCK
*SpinLock
2371 Attempts to place a spin lock in the acquired state.
2373 This function checks the state of the spin lock specified by SpinLock. If
2374 SpinLock is in the released state, then this function places SpinLock in the
2375 acquired state and returns TRUE. Otherwise, FALSE is returned. All state
2376 transitions of SpinLock must be performed using MP safe mechanisms.
2378 If SpinLock is NULL, then ASSERT().
2379 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
2381 @param SpinLock A pointer to the spin lock to place in the acquired state.
2383 @retval TRUE SpinLock was placed in the acquired state.
2384 @retval FALSE SpinLock could not be acquired.
2389 AcquireSpinLockOrFail (
2390 IN SPIN_LOCK
*SpinLock
2394 Releases a spin lock.
2396 This function places the spin lock specified by SpinLock in the release state
2397 and returns SpinLock.
2399 If SpinLock is NULL, then ASSERT().
2400 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
2402 @param SpinLock A pointer to the spin lock to release.
2410 IN SPIN_LOCK
*SpinLock
2414 Performs an atomic increment of an 32-bit unsigned integer.
2416 Performs an atomic increment of the 32-bit unsigned integer specified by
2417 Value and returns the incremented value. The increment operation must be
2418 performed using MP safe mechanisms. The state of the return value is not
2419 guaranteed to be MP safe.
2421 If Value is NULL, then ASSERT().
2423 @param Value A pointer to the 32-bit value to increment.
2425 @return The incremented value.
2430 InterlockedIncrement (
2435 Performs an atomic decrement of an 32-bit unsigned integer.
2437 Performs an atomic decrement of the 32-bit unsigned integer specified by
2438 Value and returns the decremented value. The decrement operation must be
2439 performed using MP safe mechanisms. The state of the return value is not
2440 guaranteed to be MP safe.
2442 If Value is NULL, then ASSERT().
2444 @param Value A pointer to the 32-bit value to decrement.
2446 @return The decremented value.
2451 InterlockedDecrement (
2456 Performs an atomic compare exchange operation on a 32-bit unsigned integer.
2458 @param Value A pointer to the 32-bit value for the compare exchange
2460 @param CompareValue 32-bit value used in compare operation.
2461 @param ExchangeValue 32-bit value used in exchange operation.
2463 @return The original *Value before exchange.
2468 InterlockedCompareExchange32 (
2470 IN UINT32 CompareValue
,
2471 IN UINT32 ExchangeValue
2475 Performs an atomic compare exchange operation on a 64-bit unsigned integer.
2477 @param Value A pointer to the 64-bit value for the compare exchange
2479 @param CompareValue 64-bit value used in compare operation.
2480 @param ExchangeValue 64-bit value used in exchange operation.
2482 @return The original *Value before exchange.
2487 InterlockedCompareExchange64 (
2489 IN UINT64 CompareValue
,
2490 IN UINT64 ExchangeValue
2494 Performs an atomic compare exchange operation on a pointer value.
2496 Performs an atomic compare exchange operation on the pointer value specified
2497 by Value. If Value is equal to CompareValue, then Value is set to
2498 ExchangeValue and CompareValue is returned. If Value is not equal to
2499 CompareValue, then Value is returned. The compare exchange operation must be
2500 performed using MP safe mechanisms.
2502 If Value is NULL, then ASSERT().
2504 @param Value A pointer to the pointer value for the compare exchange
2506 @param CompareValue Pointer value used in compare operation.
2507 @param ExchangeValue Pointer value used in exchange operation.
2512 InterlockedCompareExchangePointer (
2514 IN VOID
*CompareValue
,
2515 IN VOID
*ExchangeValue
2519 // Base Library CPU Functions
2523 (EFIAPI
*SWITCH_STACK_ENTRY_POINT
) (
2524 IN VOID
*Context1
, OPTIONAL
2525 IN VOID
*Context2 OPTIONAL
2529 Used to serialize load and store operations.
2531 All loads and stores that proceed calls to this function are guaranteed to be
2532 globally visible when this function returns.
2542 Saves the current CPU context that can be restored with a call to LongJump()
2545 Saves the current CPU context in the buffer specified by JumpBuffer and
2546 returns 0. The initial call to SetJump() must always return 0. Subsequent
2547 calls to LongJump() cause a non-zero value to be returned by SetJump().
2549 If JumpBuffer is NULL, then ASSERT().
2551 @param JumpBuffer A pointer to CPU context buffer.
2553 @retval 0 Indicates a return from SetJump().
2559 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
2563 Restores the CPU context that was saved with SetJump().
2565 Restores the CPU context from the buffer specified by JumpBuffer. This
2566 function never returns to the caller. Instead is resumes execution based on
2567 the state of JumpBuffer.
2569 If JumpBuffer is NULL, then ASSERT().
2570 If Value is 0, then ASSERT().
2572 @param JumpBuffer A pointer to CPU context buffer.
2573 @param Value The value to return when the SetJump() context is
2574 restored and must be non-zero.
2580 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
2585 Enables CPU interrupts.
2587 Enables CPU interrupts.
2597 Disables CPU interrupts.
2599 Disables CPU interrupts.
2609 Disables CPU interrupts and returns the interrupt state prior to the disable
2612 Disables CPU interrupts and returns the interrupt state prior to the disable
2615 @retval TRUE CPU interrupts were enabled on entry to this call.
2616 @retval FALSE CPU interrupts were disabled on entry to this call.
2621 SaveAndDisableInterrupts (
2626 Enables CPU interrupts for the smallest window required to capture any
2629 Enables CPU interrupts for the smallest window required to capture any
2635 EnableDisableInterrupts (
2640 Retrieves the current CPU interrupt state.
2642 Retrieves the current CPU interrupt state. Returns TRUE is interrupts are
2643 currently enabled. Otherwise returns FALSE.
2645 @retval TRUE CPU interrupts are enabled.
2646 @retval FALSE CPU interrupts are disabled.
2656 Set the current CPU interrupt state.
2658 Sets the current CPU interrupt state to the state specified by
2659 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
2660 InterruptState is FALSE, then interrupts are disabled. InterruptState is
2663 @param InterruptState TRUE if interrupts should enabled. FALSE if
2664 interrupts should be disabled.
2666 @return InterruptState
2672 IN BOOLEAN InterruptState
2676 Places the CPU in a sleep state until an interrupt is received.
2678 Places the CPU in a sleep state until an interrupt is received. If interrupts
2679 are disabled prior to calling this function, then the CPU will be placed in a
2680 sleep state indefinitely.
2690 Requests CPU to pause for a short period of time.
2692 Requests CPU to pause for a short period of time. Typically used in MP
2693 systems to prevent memory starvation while waiting for a spin lock.
2703 Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU.
2705 Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU.
2715 Transfers control to a function starting with a new stack.
2717 Transfers control to the function specified by EntryPoint using the new stack
2718 specified by NewStack and passing in the parameters specified by Context1 and
2719 Context2. Context1 and Context2 are optional and may be NULL. The function
2720 EntryPoint must never return.
2722 If EntryPoint is NULL, then ASSERT().
2723 If NewStack is NULL, then ASSERT().
2725 @param EntryPoint A pointer to function to call with the new stack.
2726 @param Context1 A pointer to the context to pass into the EntryPoint
2728 @param Context2 A pointer to the context to pass into the EntryPoint
2730 @param NewStack A pointer to the new stack to use for the EntryPoint
2737 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
2738 IN VOID
*Context1
, OPTIONAL
2739 IN VOID
*Context2
, OPTIONAL
2744 Generates a breakpoint on the CPU.
2746 Generates a breakpoint on the CPU. The breakpoint must be implemented such
2747 that code can resume normal execution after the breakpoint.
2757 Executes an infinite loop.
2759 Forces the CPU to execute an infinite loop. A debugger may be used to skip
2760 past the loop and the code that follows the loop must execute properly. This
2761 implies that the infinite loop must not cause the code that follow it to be
2772 // IA32 and X64 Specific Functions
2775 // Byte packed structure for 16-bit Real Mode EFLAGS
2779 UINT32 CF
:1; // Carry Flag
2780 UINT32 Reserved_0
:1; // Reserved
2781 UINT32 PF
:1; // Parity Flag
2782 UINT32 Reserved_1
:1; // Reserved
2783 UINT32 AF
:1; // Auxiliary Carry Flag
2784 UINT32 Reserved_2
:1; // Reserved
2785 UINT32 ZF
:1; // Zero Flag
2786 UINT32 SF
:1; // Sign Flag
2787 UINT32 TF
:1; // Trap Flag
2788 UINT32 IF
:1; // Interrupt Enable Flag
2789 UINT32 DF
:1; // Direction Flag
2790 UINT32 OF
:1; // Overflow Flag
2791 UINT32 IOPL
:2; // I/O Privilege Level
2792 UINT32 NT
:1; // Nested Task
2793 UINT32 Reserved_3
:1; // Reserved
2799 // Byte packed structure for EFLAGS/RFLAGS
2801 // 64-bits on X64. The upper 32-bits on X64 are reserved
2805 UINT32 CF
:1; // Carry Flag
2806 UINT32 Reserved_0
:1; // Reserved
2807 UINT32 PF
:1; // Parity Flag
2808 UINT32 Reserved_1
:1; // Reserved
2809 UINT32 AF
:1; // Auxiliary Carry Flag
2810 UINT32 Reserved_2
:1; // Reserved
2811 UINT32 ZF
:1; // Zero Flag
2812 UINT32 SF
:1; // Sign Flag
2813 UINT32 TF
:1; // Trap Flag
2814 UINT32 IF
:1; // Interrupt Enable Flag
2815 UINT32 DF
:1; // Direction Flag
2816 UINT32 OF
:1; // Overflow Flag
2817 UINT32 IOPL
:2; // I/O Privilege Level
2818 UINT32 NT
:1; // Nested Task
2819 UINT32 Reserved_3
:1; // Reserved
2820 UINT32 RF
:1; // Resume Flag
2821 UINT32 VM
:1; // Virtual 8086 Mode
2822 UINT32 AC
:1; // Alignment Check
2823 UINT32 VIF
:1; // Virtual Interrupt Flag
2824 UINT32 VIP
:1; // Virtual Interrupt Pending
2825 UINT32 ID
:1; // ID Flag
2826 UINT32 Reserved_4
:10; // Reserved
2832 // Byte packed structure for Control Register 0 (CR0)
2834 // 64-bits on X64. The upper 32-bits on X64 are reserved
2838 UINT32 PE
:1; // Protection Enable
2839 UINT32 MP
:1; // Monitor Coprocessor
2840 UINT32 EM
:1; // Emulation
2841 UINT32 TS
:1; // Task Switched
2842 UINT32 ET
:1; // Extension Type
2843 UINT32 NE
:1; // Numeric Error
2844 UINT32 Reserved_0
:10; // Reserved
2845 UINT32 WP
:1; // Write Protect
2846 UINT32 Reserved_1
:1; // Reserved
2847 UINT32 AM
:1; // Alignment Mask
2848 UINT32 Reserved_2
:10; // Reserved
2849 UINT32 NW
:1; // Mot Write-through
2850 UINT32 CD
:1; // Cache Disable
2851 UINT32 PG
:1; // Paging
2857 // Byte packed structure for Control Register 4 (CR4)
2859 // 64-bits on X64. The upper 32-bits on X64 are reserved
2863 UINT32 VME
:1; // Virtual-8086 Mode Extensions
2864 UINT32 PVI
:1; // Protected-Mode Virtual Interrupts
2865 UINT32 TSD
:1; // Time Stamp Disable
2866 UINT32 DE
:1; // Debugging Extensions
2867 UINT32 PSE
:1; // Page Size Extensions
2868 UINT32 PAE
:1; // Physical Address Extension
2869 UINT32 MCE
:1; // Machine Check Enable
2870 UINT32 PGE
:1; // Page Global Enable
2871 UINT32 PCE
:1; // Performance Monitoring Counter
2873 UINT32 OSFXSR
:1; // Operating System Support for
2874 // FXSAVE and FXRSTOR instructions
2875 UINT32 OSXMMEXCPT
:1; // Operating System Support for
2876 // Unmasked SIMD Floating Point
2878 UINT32 Reserved_0
:2; // Reserved
2879 UINT32 VMXE
:1; // VMX Enable
2880 UINT32 Reserved_1
:18; // Reseved
2886 // Byte packed structure for an IDTR, GDTR, LDTR descriptor
2887 /// @bug How to make this structure byte-packed in a compiler independent way?
2894 #define IA32_IDT_GATE_TYPE_TASK 0x85
2895 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
2896 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
2897 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
2898 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
2901 // Byte packed structure for an Interrupt Gate Descriptor
2905 UINT32 OffsetLow
:16; // Offset bits 15..0
2906 UINT32 Selector
:16; // Selector
2907 UINT32 Reserved_0
:8; // Reserved
2908 UINT32 GateType
:8; // Gate Type. See #defines above
2909 UINT32 OffsetHigh
:16; // Offset bits 31..16
2912 } IA32_IDT_GATE_DESCRIPTOR
;
2915 // Byte packed structure for an FP/SSE/SSE2 context
2922 // Structures for the 16-bit real mode thunks
2975 IA32_EFLAGS32 EFLAGS
;
2985 } IA32_REGISTER_SET
;
2988 // Byte packed structure for an 16-bit real mode thunks
2991 IA32_REGISTER_SET
*RealModeState
;
2992 VOID
*RealModeBuffer
;
2993 UINT32 RealModeBufferSize
;
2994 UINT32 ThunkAttributes
;
2997 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
2998 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
2999 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
3002 Retrieves CPUID information.
3004 Executes the CPUID instruction with EAX set to the value specified by Index.
3005 This function always returns Index.
3006 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
3007 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
3008 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
3009 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
3010 This function is only available on IA-32 and X64.
3012 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
3014 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
3015 instruction. This is an optional parameter that may be NULL.
3016 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
3017 instruction. This is an optional parameter that may be NULL.
3018 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
3019 instruction. This is an optional parameter that may be NULL.
3020 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
3021 instruction. This is an optional parameter that may be NULL.
3030 OUT UINT32
*Eax
, OPTIONAL
3031 OUT UINT32
*Ebx
, OPTIONAL
3032 OUT UINT32
*Ecx
, OPTIONAL
3033 OUT UINT32
*Edx OPTIONAL
3037 Retrieves CPUID information using an extended leaf identifier.
3039 Executes the CPUID instruction with EAX set to the value specified by Index
3040 and ECX set to the value specified by SubIndex. This function always returns
3041 Index. This function is only available on IA-32 and x64.
3043 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
3044 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
3045 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
3046 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
3048 @param Index The 32-bit value to load into EAX prior to invoking the
3050 @param SubIndex The 32-bit value to load into ECX prior to invoking the
3052 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
3053 instruction. This is an optional parameter that may be
3055 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
3056 instruction. This is an optional parameter that may be
3058 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
3059 instruction. This is an optional parameter that may be
3061 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
3062 instruction. This is an optional parameter that may be
3073 OUT UINT32
*Eax
, OPTIONAL
3074 OUT UINT32
*Ebx
, OPTIONAL
3075 OUT UINT32
*Ecx
, OPTIONAL
3076 OUT UINT32
*Edx OPTIONAL
3080 Returns the lower 32-bits of a Machine Specific Register(MSR).
3082 Reads and returns the lower 32-bits of the MSR specified by Index.
3083 No parameter checking is performed on Index, and some Index values may cause
3084 CPU exceptions. The caller must either guarantee that Index is valid, or the
3085 caller must set up exception handlers to catch the exceptions. This function
3086 is only available on IA-32 and X64.
3088 @param Index The 32-bit MSR index to read.
3090 @return The lower 32 bits of the MSR identified by Index.
3100 Zero-extend a 32-bit value and writes it to a Machine Specific Register(MSR).
3102 Writes the 32-bit value specified by Value to the MSR specified by Index. The
3103 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
3104 the MSR is returned. No parameter checking is performed on Index or Value,
3105 and some of these may cause CPU exceptions. The caller must either guarantee
3106 that Index and Value are valid, or the caller must establish proper exception
3107 handlers. This function is only available on IA-32 and X64.
3109 @param Index The 32-bit MSR index to write.
3110 @param Value The 32-bit value to write to the MSR.
3123 Reads a 64-bit MSR, performs a bitwise inclusive OR on the lower 32-bits, and
3124 writes the result back to the 64-bit MSR.
3126 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
3127 between the lower 32-bits of the read result and the value specified by
3128 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
3129 32-bits of the value written to the MSR is returned. No parameter checking is
3130 performed on Index or OrData, and some of these may cause CPU exceptions. The
3131 caller must either guarantee that Index and OrData are valid, or the caller
3132 must establish proper exception handlers. This function is only available on
3135 @param Index The 32-bit MSR index to write.
3136 @param OrData The value to OR with the read value from the MSR.
3138 @return The lower 32-bit value written to the MSR.
3149 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
3150 the result back to the 64-bit MSR.
3152 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
3153 lower 32-bits of the read result and the value specified by AndData, and
3154 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
3155 the value written to the MSR is returned. No parameter checking is performed
3156 on Index or AndData, and some of these may cause CPU exceptions. The caller
3157 must either guarantee that Index and AndData are valid, or the caller must
3158 establish proper exception handlers. This function is only available on IA-32
3161 @param Index The 32-bit MSR index to write.
3162 @param AndData The value to AND with the read value from the MSR.
3164 @return The lower 32-bit value written to the MSR.
3175 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive OR
3176 on the lower 32-bits, and writes the result back to the 64-bit MSR.
3178 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
3179 lower 32-bits of the read result and the value specified by AndData
3180 preserving the upper 32-bits, performs a bitwise inclusive OR between the
3181 result of the AND operation and the value specified by OrData, and writes the
3182 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
3183 written to the MSR is returned. No parameter checking is performed on Index,
3184 AndData, or OrData, and some of these may cause CPU exceptions. The caller
3185 must either guarantee that Index, AndData, and OrData are valid, or the
3186 caller must establish proper exception handlers. This function is only
3187 available on IA-32 and X64.
3189 @param Index The 32-bit MSR index to write.
3190 @param AndData The value to AND with the read value from the MSR.
3191 @param OrData The value to OR with the result of the AND operation.
3193 @return The lower 32-bit value written to the MSR.
3205 Reads a bit field of an MSR.
3207 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
3208 specified by the StartBit and the EndBit. The value of the bit field is
3209 returned. The caller must either guarantee that Index is valid, or the caller
3210 must set up exception handlers to catch the exceptions. This function is only
3211 available on IA-32 and X64.
3213 If StartBit is greater than 31, then ASSERT().
3214 If EndBit is greater than 31, then ASSERT().
3215 If EndBit is less than or equal to StartBit, then ASSERT().
3217 @param Index The 32-bit MSR index to read.
3218 @param StartBit The ordinal of the least significant bit in the bit field.
3220 @param EndBit The ordinal of the most significant bit in the bit field.
3223 @return The bit field read from the MSR.
3228 AsmMsrBitFieldRead32 (
3235 Writes a bit field to an MSR.
3237 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
3238 field is specified by the StartBit and the EndBit. All other bits in the
3239 destination MSR are preserved. The lower 32-bits of the MSR written is
3240 returned. Extra left bits in Value are stripped. The caller must either
3241 guarantee that Index and the data written is valid, or the caller must set up
3242 exception handlers to catch the exceptions. This function is only available
3245 If StartBit is greater than 31, then ASSERT().
3246 If EndBit is greater than 31, then ASSERT().
3247 If EndBit is less than or equal to StartBit, then ASSERT().
3249 @param Index The 32-bit MSR index to write.
3250 @param StartBit The ordinal of the least significant bit in the bit field.
3252 @param EndBit The ordinal of the most significant bit in the bit field.
3254 @param Value New value of the bit field.
3256 @return The lower 32-bit of the value written to the MSR.
3261 AsmMsrBitFieldWrite32 (
3269 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
3270 result back to the bit field in the 64-bit MSR.
3272 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
3273 between the read result and the value specified by OrData, and writes the
3274 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
3275 written to the MSR are returned. Extra left bits in OrData are stripped. The
3276 caller must either guarantee that Index and the data written is valid, or
3277 the caller must set up exception handlers to catch the exceptions. This
3278 function is only available on IA-32 and X64.
3280 If StartBit is greater than 31, then ASSERT().
3281 If EndBit is greater than 31, then ASSERT().
3282 If EndBit is less than or equal to StartBit, then ASSERT().
3284 @param Index The 32-bit MSR index to write.
3285 @param StartBit The ordinal of the least significant bit in the bit field.
3287 @param EndBit The ordinal of the most significant bit in the bit field.
3289 @param OrData The value to OR with the read value from the MSR.
3291 @return The lower 32-bit of the value written to the MSR.
3296 AsmMsrBitFieldOr32 (
3304 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
3305 result back to the bit field in the 64-bit MSR.
3307 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
3308 read result and the value specified by AndData, and writes the result to the
3309 64-bit MSR specified by Index. The lower 32-bits of the value written to the
3310 MSR are returned. Extra left bits in AndData are stripped. The caller must
3311 either guarantee that Index and the data written is valid, or the caller must
3312 set up exception handlers to catch the exceptions. This function is only
3313 available on IA-32 and X64.
3315 If StartBit is greater than 31, then ASSERT().
3316 If EndBit is greater than 31, then ASSERT().
3317 If EndBit is less than or equal to StartBit, then ASSERT().
3319 @param Index The 32-bit MSR index to write.
3320 @param StartBit The ordinal of the least significant bit in the bit field.
3322 @param EndBit The ordinal of the most significant bit in the bit field.
3324 @param AndData The value to AND with the read value from the MSR.
3326 @return The lower 32-bit of the value written to the MSR.
3331 AsmMsrBitFieldAnd32 (
3339 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
3340 bitwise inclusive OR, and writes the result back to the bit field in the
3343 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
3344 bitwise inclusive OR between the read result and the value specified by
3345 AndData, and writes the result to the 64-bit MSR specified by Index. The
3346 lower 32-bits of the value written to the MSR are returned. Extra left bits
3347 in both AndData and OrData are stripped. The caller must either guarantee
3348 that Index and the data written is valid, or the caller must set up exception
3349 handlers to catch the exceptions. This function is only available on IA-32
3352 If StartBit is greater than 31, then ASSERT().
3353 If EndBit is greater than 31, then ASSERT().
3354 If EndBit is less than or equal to StartBit, then ASSERT().
3356 @param Index The 32-bit MSR index to write.
3357 @param StartBit The ordinal of the least significant bit in the bit field.
3359 @param EndBit The ordinal of the most significant bit in the bit field.
3361 @param AndData The value to AND with the read value from the MSR.
3362 @param OrData The value to OR with the result of the AND operation.
3364 @return The lower 32-bit of the value written to the MSR.
3369 AsmMsrBitFieldAndThenOr32 (
3378 Returns a 64-bit Machine Specific Register(MSR).
3380 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
3381 performed on Index, and some Index values may cause CPU exceptions. The
3382 caller must either guarantee that Index is valid, or the caller must set up
3383 exception handlers to catch the exceptions. This function is only available
3386 @param Index The 32-bit MSR index to read.
3388 @return The value of the MSR identified by Index.
3398 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
3401 Writes the 64-bit value specified by Value to the MSR specified by Index. The
3402 64-bit value written to the MSR is returned. No parameter checking is
3403 performed on Index or Value, and some of these may cause CPU exceptions. The
3404 caller must either guarantee that Index and Value are valid, or the caller
3405 must establish proper exception handlers. This function is only available on
3408 @param Index The 32-bit MSR index to write.
3409 @param Value The 64-bit value to write to the MSR.
3422 Reads a 64-bit MSR, performs a bitwise inclusive OR, and writes the result
3423 back to the 64-bit MSR.
3425 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
3426 between the read result and the value specified by OrData, and writes the
3427 result to the 64-bit MSR specified by Index. The value written to the MSR is
3428 returned. No parameter checking is performed on Index or OrData, and some of
3429 these may cause CPU exceptions. The caller must either guarantee that Index
3430 and OrData are valid, or the caller must establish proper exception handlers.
3431 This function is only available on IA-32 and X64.
3433 @param Index The 32-bit MSR index to write.
3434 @param OrData The value to OR with the read value from the MSR.
3436 @return The value written back to the MSR.
3447 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
3450 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
3451 read result and the value specified by OrData, and writes the result to the
3452 64-bit MSR specified by Index. The value written to the MSR is returned. No
3453 parameter checking is performed on Index or OrData, and some of these may
3454 cause CPU exceptions. The caller must either guarantee that Index and OrData
3455 are valid, or the caller must establish proper exception handlers. This
3456 function is only available on IA-32 and X64.
3458 @param Index The 32-bit MSR index to write.
3459 @param AndData The value to AND with the read value from the MSR.
3461 @return The value written back to the MSR.
3472 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive
3473 OR, and writes the result back to the 64-bit MSR.
3475 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
3476 result and the value specified by AndData, performs a bitwise inclusive OR
3477 between the result of the AND operation and the value specified by OrData,
3478 and writes the result to the 64-bit MSR specified by Index. The value written
3479 to the MSR is returned. No parameter checking is performed on Index, AndData,
3480 or OrData, and some of these may cause CPU exceptions. The caller must either
3481 guarantee that Index, AndData, and OrData are valid, or the caller must
3482 establish proper exception handlers. This function is only available on IA-32
3485 @param Index The 32-bit MSR index to write.
3486 @param AndData The value to AND with the read value from the MSR.
3487 @param OrData The value to OR with the result of the AND operation.
3489 @return The value written back to the MSR.
3501 Reads a bit field of an MSR.
3503 Reads the bit field in the 64-bit MSR. The bit field is specified by the
3504 StartBit and the EndBit. The value of the bit field is returned. The caller
3505 must either guarantee that Index is valid, or the caller must set up
3506 exception handlers to catch the exceptions. This function is only available
3509 If StartBit is greater than 63, then ASSERT().
3510 If EndBit is greater than 63, then ASSERT().
3511 If EndBit is less than or equal to StartBit, then ASSERT().
3513 @param Index The 32-bit MSR index to read.
3514 @param StartBit The ordinal of the least significant bit in the bit field.
3516 @param EndBit The ordinal of the most significant bit in the bit field.
3519 @return The value read from the MSR.
3524 AsmMsrBitFieldRead64 (
3531 Writes a bit field to an MSR.
3533 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
3534 the StartBit and the EndBit. All other bits in the destination MSR are
3535 preserved. The MSR written is returned. Extra left bits in Value are
3536 stripped. The caller must either guarantee that Index and the data written is
3537 valid, or the caller must set up exception handlers to catch the exceptions.
3538 This function is only available on IA-32 and X64.
3540 If StartBit is greater than 63, then ASSERT().
3541 If EndBit is greater than 63, then ASSERT().
3542 If EndBit is less than or equal to StartBit, then ASSERT().
3544 @param Index The 32-bit MSR index to write.
3545 @param StartBit The ordinal of the least significant bit in the bit field.
3547 @param EndBit The ordinal of the most significant bit in the bit field.
3549 @param Value New value of the bit field.
3551 @return The value written back to the MSR.
3556 AsmMsrBitFieldWrite64 (
3564 Reads a bit field in a 64-bit MSR, performs a bitwise inclusive OR, and
3565 writes the result back to the bit field in the 64-bit MSR.
3567 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
3568 between the read result and the value specified by OrData, and writes the
3569 result to the 64-bit MSR specified by Index. The value written to the MSR is
3570 returned. Extra left bits in OrData are stripped. The caller must either
3571 guarantee that Index and the data written is valid, or the caller must set up
3572 exception handlers to catch the exceptions. This function is only available
3575 If StartBit is greater than 63, then ASSERT().
3576 If EndBit is greater than 63, then ASSERT().
3577 If EndBit is less than or equal to StartBit, then ASSERT().
3579 @param Index The 32-bit MSR index to write.
3580 @param StartBit The ordinal of the least significant bit in the bit field.
3582 @param EndBit The ordinal of the most significant bit in the bit field.
3584 @param OrData The value to OR with the read value from the bit field.
3586 @return The value written back to the MSR.
3591 AsmMsrBitFieldOr64 (
3599 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
3600 result back to the bit field in the 64-bit MSR.
3602 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
3603 read result and the value specified by AndData, and writes the result to the
3604 64-bit MSR specified by Index. The value written to the MSR is returned.
3605 Extra left bits in AndData are stripped. The caller must either guarantee
3606 that Index and the data written is valid, or the caller must set up exception
3607 handlers to catch the exceptions. This function is only available on IA-32
3610 If StartBit is greater than 63, then ASSERT().
3611 If EndBit is greater than 63, then ASSERT().
3612 If EndBit is less than or equal to StartBit, then ASSERT().
3614 @param Index The 32-bit MSR index to write.
3615 @param StartBit The ordinal of the least significant bit in the bit field.
3617 @param EndBit The ordinal of the most significant bit in the bit field.
3619 @param AndData The value to AND with the read value from the bit field.
3621 @return The value written back to the MSR.
3626 AsmMsrBitFieldAnd64 (
3634 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
3635 bitwise inclusive OR, and writes the result back to the bit field in the
3638 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
3639 a bitwise inclusive OR between the read result and the value specified by
3640 AndData, and writes the result to the 64-bit MSR specified by Index. The
3641 value written to the MSR is returned. Extra left bits in both AndData and
3642 OrData are stripped. The caller must either guarantee that Index and the data
3643 written is valid, or the caller must set up exception handlers to catch the
3644 exceptions. This function is only available on IA-32 and X64.
3646 If StartBit is greater than 63, then ASSERT().
3647 If EndBit is greater than 63, then ASSERT().
3648 If EndBit is less than or equal to StartBit, then ASSERT().
3650 @param Index The 32-bit MSR index to write.
3651 @param StartBit The ordinal of the least significant bit in the bit field.
3653 @param EndBit The ordinal of the most significant bit in the bit field.
3655 @param AndData The value to AND with the read value from the bit field.
3656 @param OrData The value to OR with the result of the AND operation.
3658 @return The value written back to the MSR.
3663 AsmMsrBitFieldAndThenOr64 (
3672 Reads the current value of the EFLAGS register.
3674 Reads and returns the current value of the EFLAGS register. This function is
3675 only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a
3676 64-bit value on X64.
3678 @return EFLAGS on IA-32 or RFLAGS on X64.
3688 Reads the current value of the Control Register 0 (CR0).
3690 Reads and returns the current value of CR0. This function is only available
3691 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3694 @return The value of the Control Register 0 (CR0).
3704 Reads the current value of the Control Register 2 (CR2).
3706 Reads and returns the current value of CR2. This function is only available
3707 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3710 @return The value of the Control Register 2 (CR2).
3720 Reads the current value of the Control Register 3 (CR3).
3722 Reads and returns the current value of CR3. This function is only available
3723 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3726 @return The value of the Control Register 3 (CR3).
3736 Reads the current value of the Control Register 4 (CR4).
3738 Reads and returns the current value of CR4. This function is only available
3739 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3742 @return The value of the Control Register 4 (CR4).
3752 Writes a value to Control Register 0 (CR0).
3754 Writes and returns a new value to CR0. This function is only available on
3755 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3757 @param Cr0 The value to write to CR0.
3759 @return The value written to CR0.
3769 Writes a value to Control Register 2 (CR2).
3771 Writes and returns a new value to CR2. This function is only available on
3772 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3774 @param Cr2 The value to write to CR2.
3776 @return The value written to CR2.
3786 Writes a value to Control Register 3 (CR3).
3788 Writes and returns a new value to CR3. This function is only available on
3789 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3791 @param Cr3 The value to write to CR3.
3793 @return The value written to CR3.
3803 Writes a value to Control Register 4 (CR4).
3805 Writes and returns a new value to CR4. This function is only available on
3806 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3808 @param Cr4 The value to write to CR4.
3810 @return The value written to CR4.
3820 Reads the current value of Debug Register 0 (DR0).
3822 Reads and returns the current value of DR0. This function is only available
3823 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3826 @return The value of Debug Register 0 (DR0).
3836 Reads the current value of Debug Register 1 (DR1).
3838 Reads and returns the current value of DR1. This function is only available
3839 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3842 @return The value of Debug Register 1 (DR1).
3852 Reads the current value of Debug Register 2 (DR2).
3854 Reads and returns the current value of DR2. This function is only available
3855 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3858 @return The value of Debug Register 2 (DR2).
3868 Reads the current value of Debug Register 3 (DR3).
3870 Reads and returns the current value of DR3. This function is only available
3871 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3874 @return The value of Debug Register 3 (DR3).
3884 Reads the current value of Debug Register 4 (DR4).
3886 Reads and returns the current value of DR4. This function is only available
3887 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3890 @return The value of Debug Register 4 (DR4).
3900 Reads the current value of Debug Register 5 (DR5).
3902 Reads and returns the current value of DR5. This function is only available
3903 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3906 @return The value of Debug Register 5 (DR5).
3916 Reads the current value of Debug Register 6 (DR6).
3918 Reads and returns the current value of DR6. This function is only available
3919 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3922 @return The value of Debug Register 6 (DR6).
3932 Reads the current value of Debug Register 7 (DR7).
3934 Reads and returns the current value of DR7. This function is only available
3935 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3938 @return The value of Debug Register 7 (DR7).
3948 Writes a value to Debug Register 0 (DR0).
3950 Writes and returns a new value to DR0. This function is only available on
3951 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3953 @param Dr0 The value to write to Dr0.
3955 @return The value written to Debug Register 0 (DR0).
3965 Writes a value to Debug Register 1 (DR1).
3967 Writes and returns a new value to DR1. This function is only available on
3968 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3970 @param Dr1 The value to write to Dr1.
3972 @return The value written to Debug Register 1 (DR1).
3982 Writes a value to Debug Register 2 (DR2).
3984 Writes and returns a new value to DR2. This function is only available on
3985 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3987 @param Dr2 The value to write to Dr2.
3989 @return The value written to Debug Register 2 (DR2).
3999 Writes a value to Debug Register 3 (DR3).
4001 Writes and returns a new value to DR3. This function is only available on
4002 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4004 @param Dr3 The value to write to Dr3.
4006 @return The value written to Debug Register 3 (DR3).
4016 Writes a value to Debug Register 4 (DR4).
4018 Writes and returns a new value to DR4. This function is only available on
4019 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4021 @param Dr4 The value to write to Dr4.
4023 @return The value written to Debug Register 4 (DR4).
4033 Writes a value to Debug Register 5 (DR5).
4035 Writes and returns a new value to DR5. This function is only available on
4036 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4038 @param Dr5 The value to write to Dr5.
4040 @return The value written to Debug Register 5 (DR5).
4050 Writes a value to Debug Register 6 (DR6).
4052 Writes and returns a new value to DR6. This function is only available on
4053 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4055 @param Dr6 The value to write to Dr6.
4057 @return The value written to Debug Register 6 (DR6).
4067 Writes a value to Debug Register 7 (DR7).
4069 Writes and returns a new value to DR7. This function is only available on
4070 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4072 @param Dr7 The value to write to Dr7.
4074 @return The value written to Debug Register 7 (DR7).
4084 Reads the current value of Code Segment Register (CS).
4086 Reads and returns the current value of CS. This function is only available on
4089 @return The current value of CS.
4099 Reads the current value of Data Segment Register (DS).
4101 Reads and returns the current value of DS. This function is only available on
4104 @return The current value of DS.
4114 Reads the current value of Extra Segment Register (ES).
4116 Reads and returns the current value of ES. This function is only available on
4119 @return The current value of ES.
4129 Reads the current value of FS Data Segment Register (FS).
4131 Reads and returns the current value of FS. This function is only available on
4134 @return The current value of FS.
4144 Reads the current value of GS Data Segment Register (GS).
4146 Reads and returns the current value of GS. This function is only available on
4149 @return The current value of GS.
4159 Reads the current value of Stack Segment Register (SS).
4161 Reads and returns the current value of SS. This function is only available on
4164 @return The current value of SS.
4174 Reads the current value of Task Register (TR).
4176 Reads and returns the current value of TR. This function is only available on
4179 @return The current value of TR.
4189 Reads the current Global Descriptor Table Register(GDTR) descriptor.
4191 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
4192 function is only available on IA-32 and X64.
4194 If Gdtr is NULL, then ASSERT().
4196 @param Gdtr Pointer to a GDTR descriptor.
4202 OUT IA32_DESCRIPTOR
*Gdtr
4206 Writes the current Global Descriptor Table Register (GDTR) descriptor.
4208 Writes and the current GDTR descriptor specified by Gdtr. This function is
4209 only available on IA-32 and X64.
4211 If Gdtr is NULL, then ASSERT().
4213 @param Gdtr Pointer to a GDTR descriptor.
4219 IN CONST IA32_DESCRIPTOR
*Gdtr
4223 Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.
4225 Reads and returns the current IDTR descriptor and returns it in Idtr. This
4226 function is only available on IA-32 and X64.
4228 If Idtr is NULL, then ASSERT().
4230 @param Idtr Pointer to a IDTR descriptor.
4236 OUT IA32_DESCRIPTOR
*Idtr
4240 Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.
4242 Writes the current IDTR descriptor and returns it in Idtr. This function is
4243 only available on IA-32 and X64.
4245 If Idtr is NULL, then ASSERT().
4247 @param Idtr Pointer to a IDTR descriptor.
4253 IN CONST IA32_DESCRIPTOR
*Idtr
4257 Reads the current Local Descriptor Table Register(LDTR) selector.
4259 Reads and returns the current 16-bit LDTR descriptor value. This function is
4260 only available on IA-32 and X64.
4262 @return The current selector of LDT.
4272 Writes the current Local Descriptor Table Register (GDTR) selector.
4274 Writes and the current LDTR descriptor specified by Ldtr. This function is
4275 only available on IA-32 and X64.
4277 @param Ldtr 16-bit LDTR selector value.
4287 Save the current floating point/SSE/SSE2 context to a buffer.
4289 Saves the current floating point/SSE/SSE2 state to the buffer specified by
4290 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
4291 available on IA-32 and X64.
4293 If Buffer is NULL, then ASSERT().
4294 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
4296 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
4302 OUT IA32_FX_BUFFER
*Buffer
4306 Restores the current floating point/SSE/SSE2 context from a buffer.
4308 Restores the current floating point/SSE/SSE2 state from the buffer specified
4309 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
4310 only available on IA-32 and X64.
4312 If Buffer is NULL, then ASSERT().
4313 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
4314 If Buffer was not saved with AsmFxSave(), then ASSERT().
4316 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
4322 IN CONST IA32_FX_BUFFER
*Buffer
4326 Reads the current value of 64-bit MMX Register #0 (MM0).
4328 Reads and returns the current value of MM0. This function is only available
4331 @return The current value of MM0.
4341 Reads the current value of 64-bit MMX Register #1 (MM1).
4343 Reads and returns the current value of MM1. This function is only available
4346 @return The current value of MM1.
4356 Reads the current value of 64-bit MMX Register #2 (MM2).
4358 Reads and returns the current value of MM2. This function is only available
4361 @return The current value of MM2.
4371 Reads the current value of 64-bit MMX Register #3 (MM3).
4373 Reads and returns the current value of MM3. This function is only available
4376 @return The current value of MM3.
4386 Reads the current value of 64-bit MMX Register #4 (MM4).
4388 Reads and returns the current value of MM4. This function is only available
4391 @return The current value of MM4.
4401 Reads the current value of 64-bit MMX Register #5 (MM5).
4403 Reads and returns the current value of MM5. This function is only available
4406 @return The current value of MM5.
4416 Reads the current value of 64-bit MMX Register #6 (MM6).
4418 Reads and returns the current value of MM6. This function is only available
4421 @return The current value of MM6.
4431 Reads the current value of 64-bit MMX Register #7 (MM7).
4433 Reads and returns the current value of MM7. This function is only available
4436 @return The current value of MM7.
4446 Writes the current value of 64-bit MMX Register #0 (MM0).
4448 Writes the current value of MM0. This function is only available on IA32 and
4451 @param Value The 64-bit value to write to MM0.
4461 Writes the current value of 64-bit MMX Register #1 (MM1).
4463 Writes the current value of MM1. This function is only available on IA32 and
4466 @param Value The 64-bit value to write to MM1.
4476 Writes the current value of 64-bit MMX Register #2 (MM2).
4478 Writes the current value of MM2. This function is only available on IA32 and
4481 @param Value The 64-bit value to write to MM2.
4491 Writes the current value of 64-bit MMX Register #3 (MM3).
4493 Writes the current value of MM3. This function is only available on IA32 and
4496 @param Value The 64-bit value to write to MM3.
4506 Writes the current value of 64-bit MMX Register #4 (MM4).
4508 Writes the current value of MM4. This function is only available on IA32 and
4511 @param Value The 64-bit value to write to MM4.
4521 Writes the current value of 64-bit MMX Register #5 (MM5).
4523 Writes the current value of MM5. This function is only available on IA32 and
4526 @param Value The 64-bit value to write to MM5.
4536 Writes the current value of 64-bit MMX Register #6 (MM6).
4538 Writes the current value of MM6. This function is only available on IA32 and
4541 @param Value The 64-bit value to write to MM6.
4551 Writes the current value of 64-bit MMX Register #7 (MM7).
4553 Writes the current value of MM7. This function is only available on IA32 and
4556 @param Value The 64-bit value to write to MM7.
4566 Reads the current value of Time Stamp Counter (TSC).
4568 Reads and returns the current value of TSC. This function is only available
4571 @return The current value of TSC
4581 Reads the current value of a Performance Counter (PMC).
4583 Reads and returns the current value of performance counter specified by
4584 Index. This function is only available on IA-32 and X64.
4586 @param Index The 32-bit Performance Counter index to read.
4588 @return The value of the PMC specified by Index.
4598 Sets up a monitor buffer that is used by AsmMwait().
4600 Executes a MONITOR instruction with the register state specified by Eax, Ecx
4601 and Edx. Returns Eax. This function is only available on IA-32 and X64.
4603 @param Eax The value to load into EAX or RAX before executing the MONITOR
4605 @param Ecx The value to load into ECX or RCX before executing the MONITOR
4607 @param Edx The value to load into EDX or RDX before executing the MONITOR
4622 Executes an MWAIT instruction.
4624 Executes an MWAIT instruction with the register state specified by Eax and
4625 Ecx. Returns Eax. This function is only available on IA-32 and X64.
4627 @param Eax The value to load into EAX or RAX before executing the MONITOR
4629 @param Ecx The value to load into ECX or RCX before executing the MONITOR
4643 Executes a WBINVD instruction.
4645 Executes a WBINVD instruction. This function is only available on IA-32 and
4656 Executes a INVD instruction.
4658 Executes a INVD instruction. This function is only available on IA-32 and
4669 Flushes a cache line from all the instruction and data caches within the
4670 coherency domain of the CPU.
4672 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
4673 This function is only available on IA-32 and X64.
4675 @param LinearAddress The address of the cache line to flush. If the CPU is
4676 in a physical addressing mode, then LinearAddress is a
4677 physical address. If the CPU is in a virtual
4678 addressing mode, then LinearAddress is a virtual
4681 @return LinearAddress
4686 IN VOID
*LinearAddress
4690 Enables the 32-bit paging mode on the CPU.
4692 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
4693 must be properly initialized prior to calling this service. This function
4694 assumes the current execution mode is 32-bit protected mode. This function is
4695 only available on IA-32. After the 32-bit paging mode is enabled, control is
4696 transferred to the function specified by EntryPoint using the new stack
4697 specified by NewStack and passing in the parameters specified by Context1 and
4698 Context2. Context1 and Context2 are optional and may be NULL. The function
4699 EntryPoint must never return.
4701 If the current execution mode is not 32-bit protected mode, then ASSERT().
4702 If EntryPoint is NULL, then ASSERT().
4703 If NewStack is NULL, then ASSERT().
4705 There are a number of constraints that must be followed before calling this
4707 1) Interrupts must be disabled.
4708 2) The caller must be in 32-bit protected mode with flat descriptors. This
4709 means all descriptors must have a base of 0 and a limit of 4GB.
4710 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
4712 4) CR3 must point to valid page tables that will be used once the transition
4713 is complete, and those page tables must guarantee that the pages for this
4714 function and the stack are identity mapped.
4716 @param EntryPoint A pointer to function to call with the new stack after
4718 @param Context1 A pointer to the context to pass into the EntryPoint
4719 function as the first parameter after paging is enabled.
4720 @param Context2 A pointer to the context to pass into the EntryPoint
4721 function as the second parameter after paging is enabled.
4722 @param NewStack A pointer to the new stack to use for the EntryPoint
4723 function after paging is enabled.
4729 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
4730 IN VOID
*Context1
, OPTIONAL
4731 IN VOID
*Context2
, OPTIONAL
4736 Disables the 32-bit paging mode on the CPU.
4738 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
4739 mode. This function assumes the current execution mode is 32-paged protected
4740 mode. This function is only available on IA-32. After the 32-bit paging mode
4741 is disabled, control is transferred to the function specified by EntryPoint
4742 using the new stack specified by NewStack and passing in the parameters
4743 specified by Context1 and Context2. Context1 and Context2 are optional and
4744 may be NULL. The function EntryPoint must never return.
4746 If the current execution mode is not 32-bit paged mode, then ASSERT().
4747 If EntryPoint is NULL, then ASSERT().
4748 If NewStack is NULL, then ASSERT().
4750 There are a number of constraints that must be followed before calling this
4752 1) Interrupts must be disabled.
4753 2) The caller must be in 32-bit paged mode.
4754 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
4755 4) CR3 must point to valid page tables that guarantee that the pages for
4756 this function and the stack are identity mapped.
4758 @param EntryPoint A pointer to function to call with the new stack after
4760 @param Context1 A pointer to the context to pass into the EntryPoint
4761 function as the first parameter after paging is disabled.
4762 @param Context2 A pointer to the context to pass into the EntryPoint
4763 function as the second parameter after paging is
4765 @param NewStack A pointer to the new stack to use for the EntryPoint
4766 function after paging is disabled.
4771 AsmDisablePaging32 (
4772 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
4773 IN VOID
*Context1
, OPTIONAL
4774 IN VOID
*Context2
, OPTIONAL
4779 Enables the 64-bit paging mode on the CPU.
4781 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
4782 must be properly initialized prior to calling this service. This function
4783 assumes the current execution mode is 32-bit protected mode with flat
4784 descriptors. This function is only available on IA-32. After the 64-bit
4785 paging mode is enabled, control is transferred to the function specified by
4786 EntryPoint using the new stack specified by NewStack and passing in the
4787 parameters specified by Context1 and Context2. Context1 and Context2 are
4788 optional and may be 0. The function EntryPoint must never return.
4790 If the current execution mode is not 32-bit protected mode with flat
4791 descriptors, then ASSERT().
4792 If EntryPoint is 0, then ASSERT().
4793 If NewStack is 0, then ASSERT().
4795 @param Cs The 16-bit selector to load in the CS before EntryPoint
4796 is called. The descriptor in the GDT that this selector
4797 references must be setup for long mode.
4798 @param EntryPoint The 64-bit virtual address of the function to call with
4799 the new stack after paging is enabled.
4800 @param Context1 The 64-bit virtual address of the context to pass into
4801 the EntryPoint function as the first parameter after
4803 @param Context2 The 64-bit virtual address of the context to pass into
4804 the EntryPoint function as the second parameter after
4806 @param NewStack The 64-bit virtual address of the new stack to use for
4807 the EntryPoint function after paging is enabled.
4813 IN UINT16 CodeSelector
,
4814 IN UINT64 EntryPoint
,
4815 IN UINT64 Context1
, OPTIONAL
4816 IN UINT64 Context2
, OPTIONAL
4821 Disables the 64-bit paging mode on the CPU.
4823 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
4824 mode. This function assumes the current execution mode is 64-paging mode.
4825 This function is only available on X64. After the 64-bit paging mode is
4826 disabled, control is transferred to the function specified by EntryPoint
4827 using the new stack specified by NewStack and passing in the parameters
4828 specified by Context1 and Context2. Context1 and Context2 are optional and
4829 may be 0. The function EntryPoint must never return.
4831 If the current execution mode is not 64-bit paged mode, then ASSERT().
4832 If EntryPoint is 0, then ASSERT().
4833 If NewStack is 0, then ASSERT().
4835 @param Cs The 16-bit selector to load in the CS before EntryPoint
4836 is called. The descriptor in the GDT that this selector
4837 references must be setup for 32-bit protected mode.
4838 @param EntryPoint The 64-bit virtual address of the function to call with
4839 the new stack after paging is disabled.
4840 @param Context1 The 64-bit virtual address of the context to pass into
4841 the EntryPoint function as the first parameter after
4843 @param Context2 The 64-bit virtual address of the context to pass into
4844 the EntryPoint function as the second parameter after
4846 @param NewStack The 64-bit virtual address of the new stack to use for
4847 the EntryPoint function after paging is disabled.
4852 AsmDisablePaging64 (
4853 IN UINT16 CodeSelector
,
4854 IN UINT32 EntryPoint
,
4855 IN UINT32 Context1
, OPTIONAL
4856 IN UINT32 Context2
, OPTIONAL
4861 // 16-bit thunking services
4865 Retrieves the properties for 16-bit thunk functions.
4867 Computes the size of the buffer and stack below 1MB required to use the
4868 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
4869 buffer size is returned in RealModeBufferSize, and the stack size is returned
4870 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
4871 then the actual minimum stack size is ExtraStackSize plus the maximum number
4872 of bytes that need to be passed to the 16-bit real mode code.
4874 If RealModeBufferSize is NULL, then ASSERT().
4875 If ExtraStackSize is NULL, then ASSERT().
4877 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
4878 required to use the 16-bit thunk functions.
4879 @param ExtraStackSize A pointer to the extra size of stack below 1MB
4880 that the 16-bit thunk functions require for
4881 temporary storage in the transition to and from
4887 AsmGetThunk16Properties (
4888 OUT UINT32
*RealModeBufferSize
,
4889 OUT UINT32
*ExtraStackSize
4893 Prepares all structures a code required to use AsmThunk16().
4895 Prepares all structures and code required to use AsmThunk16().
4897 If ThunkContext is NULL, then ASSERT().
4899 @param ThunkContext A pointer to the context structure that describes the
4900 16-bit real mode code to call.
4906 OUT THUNK_CONTEXT
*ThunkContext
4910 Transfers control to a 16-bit real mode entry point and returns the results.
4912 Transfers control to a 16-bit real mode entry point and returns the results.
4913 AsmPrepareThunk16() must be called with ThunkContext before this function is
4916 If ThunkContext is NULL, then ASSERT().
4917 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
4919 @param ThunkContext A pointer to the context structure that describes the
4920 16-bit real mode code to call.
4926 IN OUT THUNK_CONTEXT
*ThunkContext
4930 Prepares all structures and code for a 16-bit real mode thunk, transfers
4931 control to a 16-bit real mode entry point, and returns the results.
4933 Prepares all structures and code for a 16-bit real mode thunk, transfers
4934 control to a 16-bit real mode entry point, and returns the results. If the
4935 caller only need to perform a single 16-bit real mode thunk, then this
4936 service should be used. If the caller intends to make more than one 16-bit
4937 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
4938 once and AsmThunk16() can be called for each 16-bit real mode thunk.
4940 If ThunkContext is NULL, then ASSERT().
4942 @param ThunkContext A pointer to the context structure that describes the
4943 16-bit real mode code to call.
4948 AsmPrepareAndThunk16 (
4949 IN OUT THUNK_CONTEXT
*ThunkContext