2 Memory-only library functions with no library constructor/destructor
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 Module Name: BaseLib.h
21 // Definitions for architecture specific types
22 // These include SPIN_LOCK and BASE_LIBRARY_JUMP_BUFFER
28 typedef UINTN SPIN_LOCK
;
30 #if defined (MDE_CPU_IA32)
32 // IA32 context buffer used by SetJump() and LongJump()
41 } BASE_LIBRARY_JUMP_BUFFER
;
43 #elif defined (MDE_CPU_IPF)
45 // IPF context buffer used by SetJump() and LongJump()
49 UINT64 AfterSpillUNAT
;
107 } BASE_LIBRARY_JUMP_BUFFER
;
109 #elif defined (MDE_CPU_X64)
111 // X64 context buffer used by SetJump() and LongJump()
124 } BASE_LIBRARY_JUMP_BUFFER
;
126 #elif defined (MDE_CPU_EBC)
128 // EBC context buffer used by SetJump() and LongJump()
136 } BASE_LIBRARY_JUMP_BUFFER
;
139 #error Unknown Processor Type
147 Copies one Null-terminated Unicode string to another Null-terminated Unicode
148 string and returns the new Unicode string.
150 This function copies the contents of the Unicode string Source to the Unicode
151 string Destination, and returns Destination. If Source and Destination
152 overlap, then the results are undefined.
154 If Destination is NULL, then ASSERT().
155 If Source is NULL, then ASSERT().
156 If Source and Destination overlap, then ASSERT().
157 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
158 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
160 @param Destination Pointer to a Null-terminated Unicode string.
161 @param Source Pointer to a Null-terminated Unicode string.
169 OUT CHAR16
*Destination
,
170 IN CONST CHAR16
*Source
174 Copies one Null-terminated Unicode string with a maximum length to another
175 Null-terminated Unicode string with a maximum length and returns the new
178 This function copies the contents of the Unicode string Source to the Unicode
179 string Destination, and returns Destination. At most, Length Unicode
180 characters are copied from Source to Destination. If Length is 0, then
181 Destination is returned unmodified. If Length is greater that the number of
182 Unicode characters in Source, then Destination is padded with Null Unicode
183 characters. If Source and Destination overlap, then the results are
186 If Destination is NULL, then ASSERT().
187 If Source is NULL, then ASSERT().
188 If Source and Destination overlap, then ASSERT().
189 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
190 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
192 @param Destination Pointer to a Null-terminated Unicode string.
193 @param Source Pointer to a Null-terminated Unicode string.
194 @param Length Maximum number of Unicode characters to copy.
202 OUT CHAR16
*Destination
,
203 IN CONST CHAR16
*Source
,
208 Returns the length of a Null-terminated Unicode string.
210 This function returns the number of Unicode characters in the Null-terminated
211 Unicode string specified by String.
213 If String is NULL, then ASSERT().
214 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
215 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
217 @param String Pointer to a Null-terminated Unicode string.
219 @return The length of String.
225 IN CONST CHAR16
*String
229 Returns the size of a Null-terminated Unicode string in bytes, including the
232 This function returns the size, in bytes, of the Null-terminated Unicode
233 string specified by String.
235 If String is NULL, then ASSERT().
236 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
237 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
239 @param String Pointer to a Null-terminated Unicode string.
241 @return The size of String.
247 IN CONST CHAR16
*String
251 Compares two Null-terminated Unicode strings, and returns the difference
252 between the first mismatched Unicode characters.
254 This function compares the Null-terminated Unicode string FirstString to the
255 Null-terminated Unicode string SecondString. If FirstString is identical to
256 SecondString, then 0 is returned. Otherwise, the value returned is the first
257 mismatched Unicode character in SecondString subtracted from the first
258 mismatched Unicode character in FirstString.
260 If FirstString is NULL, then ASSERT().
261 If SecondString is NULL, then ASSERT().
262 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
263 than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
264 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
265 than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
267 @param FirstString Pointer to a Null-terminated Unicode string.
268 @param SecondString Pointer to a Null-terminated Unicode string.
270 @retval 0 FirstString is identical to SecondString.
271 @retval !=0 FirstString is not identical to SecondString.
277 IN CONST CHAR16
*FirstString
,
278 IN CONST CHAR16
*SecondString
282 Compares two Null-terminated Unicode strings with maximum lengths, and
283 returns the difference between the first mismatched Unicode characters.
285 This function compares the Null-terminated Unicode string FirstString to the
286 Null-terminated Unicode string SecondString. At most, Length Unicode
287 characters will be compared. If Length is 0, then 0 is returned. If
288 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
289 value returned is the first mismatched Unicode character in SecondString
290 subtracted from the first mismatched Unicode character in FirstString.
292 If FirstString is NULL, then ASSERT().
293 If SecondString is NULL, then ASSERT().
294 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
295 than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
296 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
297 than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
299 @param FirstString Pointer to a Null-terminated Unicode string.
300 @param SecondString Pointer to a Null-terminated Unicode string.
301 @param Length Maximum number of Unicode characters to compare.
303 @retval 0 FirstString is identical to SecondString.
304 @retval !=0 FirstString is not identical to SecondString.
310 IN CONST CHAR16
*FirstString
,
311 IN CONST CHAR16
*SecondString
,
316 Concatenates one Null-terminated Unicode string to another Null-terminated
317 Unicode string, and returns the concatenated Unicode string.
319 This function concatenates two Null-terminated Unicode strings. The contents
320 of Null-terminated Unicode string Source are concatenated to the end of
321 Null-terminated Unicode string Destination. The Null-terminated concatenated
322 Unicode String is returned. If Source and Destination overlap, then the
323 results are undefined.
325 If Destination is NULL, then ASSERT().
326 If Source is NULL, then ASSERT().
327 If Source and Destination overlap, then ASSERT().
328 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
329 than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
330 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
331 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
332 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
333 and Source results in a Unicode string with more than
334 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
336 @param Destination Pointer to a Null-terminated Unicode string.
337 @param Source Pointer to a Null-terminated Unicode string.
345 IN OUT CHAR16
*Destination
,
346 IN CONST CHAR16
*Source
350 Concatenates one Null-terminated Unicode string with a maximum length to the
351 end of another Null-terminated Unicode string, and returns the concatenated
354 This function concatenates two Null-terminated Unicode strings. The contents
355 of Null-terminated Unicode string Source are concatenated to the end of
356 Null-terminated Unicode string Destination, and Destination is returned. At
357 most, Length Unicode characters are concatenated from Source to the end of
358 Destination, and Destination is always Null-terminated. If Length is 0, then
359 Destination is returned unmodified. If Source and Destination overlap, then
360 the results are undefined.
362 If Destination is NULL, then ASSERT().
363 If Source is NULL, then ASSERT().
364 If Source and Destination overlap, then ASSERT().
365 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
366 than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
367 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
368 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
369 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
370 and Source results in a Unicode string with more than
371 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
373 @param Destination Pointer to a Null-terminated Unicode string.
374 @param Source Pointer to a Null-terminated Unicode string.
375 @param Length Maximum number of Unicode characters to concatenate from
384 IN OUT CHAR16
*Destination
,
385 IN CONST CHAR16
*Source
,
390 Copies one Null-terminated ASCII string to another Null-terminated ASCII
391 string and returns the new ASCII string.
393 This function copies the contents of the ASCII string Source to the ASCII
394 string Destination, and returns Destination. If Source and Destination
395 overlap, then the results are undefined.
397 If Destination is NULL, then ASSERT().
398 If Source is NULL, then ASSERT().
399 If Source and Destination overlap, then ASSERT().
400 If PcdMaximumAsciiStringLength is not zero and Source contains more than
401 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
403 @param Destination Pointer to a Null-terminated ASCII string.
404 @param Source Pointer to a Null-terminated ASCII string.
412 OUT CHAR8
*Destination
,
413 IN CONST CHAR8
*Source
417 Copies one Null-terminated ASCII string with a maximum length to another
418 Null-terminated ASCII string with a maximum length and returns the new ASCII
421 This function copies the contents of the ASCII string Source to the ASCII
422 string Destination, and returns Destination. At most, Length ASCII characters
423 are copied from Source to Destination. If Length is 0, then Destination is
424 returned unmodified. If Length is greater that the number of ASCII characters
425 in Source, then Destination is padded with Null ASCII characters. If Source
426 and Destination overlap, then the results are undefined.
428 If Destination is NULL, then ASSERT().
429 If Source is NULL, then ASSERT().
430 If Source and Destination overlap, then ASSERT().
431 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
432 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
434 @param Destination Pointer to a Null-terminated ASCII string.
435 @param Source Pointer to a Null-terminated ASCII string.
436 @param Length Maximum number of ASCII characters to copy.
444 OUT CHAR8
*Destination
,
445 IN CONST CHAR8
*Source
,
450 Returns the length of a Null-terminated ASCII string.
452 This function returns the number of ASCII characters in the Null-terminated
453 ASCII string specified by String.
455 If String is NULL, then ASSERT().
456 If PcdMaximumAsciiStringLength is not zero and String contains more than
457 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
459 @param String Pointer to a Null-terminated ASCII string.
461 @return The length of String.
467 IN CONST CHAR8
*String
471 Returns the size of a Null-terminated ASCII string in bytes, including the
474 This function returns the size, in bytes, of the Null-terminated ASCII string
477 If String is NULL, then ASSERT().
478 If PcdMaximumAsciiStringLength is not zero and String contains more than
479 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
481 @param String Pointer to a Null-terminated ASCII string.
483 @return The size of String.
489 IN CONST CHAR8
*String
493 Compares two Null-terminated ASCII strings, and returns the difference
494 between the first mismatched ASCII characters.
496 This function compares the Null-terminated ASCII string FirstString to the
497 Null-terminated ASCII string SecondString. If FirstString is identical to
498 SecondString, then 0 is returned. Otherwise, the value returned is the first
499 mismatched ASCII character in SecondString subtracted from the first
500 mismatched ASCII character in FirstString.
502 If FirstString is NULL, then ASSERT().
503 If SecondString is NULL, then ASSERT().
504 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
505 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
506 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
507 than PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
509 @param FirstString Pointer to a Null-terminated ASCII string.
510 @param SecondString Pointer to a Null-terminated ASCII string.
512 @retval 0 FirstString is identical to SecondString.
513 @retval !=0 FirstString is not identical to SecondString.
519 IN CONST CHAR8
*FirstString
,
520 IN CONST CHAR8
*SecondString
524 Performs a case insensitive comparison of two Null-terminated ASCII strings,
525 and returns the difference between the first mismatched ASCII characters.
527 This function performs a case insensitive comparison of the Null-terminated
528 ASCII string FirstString to the Null-terminated ASCII string SecondString. If
529 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
530 value returned is the first mismatched lower case ASCII character in
531 SecondString subtracted from the first mismatched lower case ASCII character
534 If FirstString is NULL, then ASSERT().
535 If SecondString is NULL, then ASSERT().
536 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
537 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
538 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
539 than PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
541 @param FirstString Pointer to a Null-terminated ASCII string.
542 @param SecondString Pointer to a Null-terminated ASCII string.
544 @retval 0 FirstString is identical to SecondString using case insensitive
546 @retval !=0 FirstString is not identical to SecondString using case
547 insensitive comparisons.
553 IN CONST CHAR8
*FirstString
,
554 IN CONST CHAR8
*SecondString
558 Compares two Null-terminated ASCII strings with maximum lengths, and returns
559 the difference between the first mismatched ASCII characters.
561 This function compares the Null-terminated ASCII string FirstString to the
562 Null-terminated ASCII string SecondString. At most, Length ASCII characters
563 will be compared. If Length is 0, then 0 is returned. If FirstString is
564 identical to SecondString, then 0 is returned. Otherwise, the value returned
565 is the first mismatched ASCII character in SecondString subtracted from the
566 first mismatched ASCII character in FirstString.
568 If FirstString is NULL, then ASSERT().
569 If SecondString is NULL, then ASSERT().
570 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
571 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
572 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
573 than PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
575 @param FirstString Pointer to a Null-terminated ASCII string.
576 @param SecondString Pointer to a Null-terminated ASCII string.
578 @retval 0 FirstString is identical to SecondString.
579 @retval !=0 FirstString is not identical to SecondString.
585 IN CONST CHAR8
*FirstString
,
586 IN CONST CHAR8
*SecondString
,
591 Concatenates one Null-terminated ASCII string to another Null-terminated
592 ASCII string, and returns the concatenated ASCII string.
594 This function concatenates two Null-terminated ASCII strings. The contents of
595 Null-terminated ASCII string Source are concatenated to the end of Null-
596 terminated ASCII string Destination. The Null-terminated concatenated ASCII
599 If Destination is NULL, then ASSERT().
600 If Source is NULL, then ASSERT().
601 If PcdMaximumAsciiStringLength is not zero and Destination contains more than
602 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
603 If PcdMaximumAsciiStringLength is not zero and Source contains more than
604 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
605 If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
606 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
607 ASCII characters, then ASSERT().
609 @param Destination Pointer to a Null-terminated ASCII string.
610 @param Source Pointer to a Null-terminated ASCII string.
618 IN OUT CHAR8
*Destination
,
619 IN CONST CHAR8
*Source
623 Concatenates one Null-terminated ASCII string with a maximum length to the
624 end of another Null-terminated ASCII string, and returns the concatenated
627 This function concatenates two Null-terminated ASCII strings. The contents
628 of Null-terminated ASCII string Source are concatenated to the end of Null-
629 terminated ASCII string Destination, and Destination is returned. At most,
630 Length ASCII characters are concatenated from Source to the end of
631 Destination, and Destination is always Null-terminated. If Length is 0, then
632 Destination is returned unmodified. If Source and Destination overlap, then
633 the results are undefined.
635 If Destination is NULL, then ASSERT().
636 If Source is NULL, then ASSERT().
637 If Source and Destination overlap, then ASSERT().
638 If PcdMaximumAsciiStringLength is not zero, and Destination contains more
639 than PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
640 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
641 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
642 If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
643 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
644 ASCII characters, then ASSERT().
646 @param Destination Pointer to a Null-terminated ASCII string.
647 @param Source Pointer to a Null-terminated ASCII string.
648 @param Length Maximum number of ASCII characters to concatenate from
657 IN OUT CHAR8
*Destination
,
658 IN CONST CHAR8
*Source
,
663 // LIST_ENTRY definition
665 typedef struct _LIST_ENTRY LIST_ENTRY
;
668 LIST_ENTRY
*ForwardLink
;
669 LIST_ENTRY
*BackLink
;
673 // Linked List Functions and Macros
677 Initializes the head node of a doubly linked list that is declared as a
678 global variable in a module.
680 Initializes the forward and backward links of a new linked list. After
681 initializing a linked list with this macro, the other linked list functions
682 may be used to add and remove nodes from the linked list. This macro results
683 in smaller executables by initializing the linked list in the data section,
684 instead if calling the InitializeListHead() function to perform the
685 equivalent operation.
687 @param ListHead The head note of a list to initiailize.
690 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&ListHead, &ListHead}
693 Initializes the head node of a doubly linked list, and returns the pointer to
694 the head node of the doubly linked list.
696 Initializes the forward and backward links of a new linked list. After
697 initializing a linked list with this function, the other linked list
698 functions may be used to add and remove nodes from the linked list. It is up
699 to the caller of this function to allocate the memory for ListHead.
701 If ListHead is NULL, then ASSERT().
703 @param ListHead A pointer to the head node of a new doubly linked list.
711 IN LIST_ENTRY
*ListHead
715 Adds a node to the beginning of a doubly linked list, and returns the pointer
716 to the head node of the doubly linked list.
718 Adds the node Entry at the beginning of the doubly linked list denoted by
719 ListHead, and returns ListHead.
721 If ListHead is NULL, then ASSERT().
722 If Entry is NULL, then ASSERT().
723 If ListHead was not initialized with InitializeListHead(), then ASSERT().
724 If PcdMaximumLinkedListLenth is not zero, and ListHead contains more than
725 PcdMaximumLinkedListLenth nodes, then ASSERT().
727 @param ListHead A pointer to the head node of a doubly linked list.
728 @param Entry A pointer to a node that is to be inserted at the beginning
729 of a doubly linked list.
737 IN LIST_ENTRY
*ListHead
,
742 Adds a node to the end of a doubly linked list, and returns the pointer to
743 the head node of the doubly linked list.
745 Adds the node Entry to the end of the doubly linked list denoted by ListHead,
746 and returns ListHead.
748 If ListHead is NULL, then ASSERT().
749 If Entry is NULL, then ASSERT().
750 If ListHead was not initialized with InitializeListHead(), then ASSERT().
751 If PcdMaximumLinkedListLenth is not zero, and ListHead contains more than
752 PcdMaximumLinkedListLenth nodes, then ASSERT().
754 @param ListHead A pointer to the head node of a doubly linked list.
755 @param Entry A pointer to a node that is to be added at the end of the
764 IN LIST_ENTRY
*ListHead
,
769 Retrieves the first node of a doubly linked list.
771 Returns the first node of a doubly linked list. List must have been
772 initialized with InitializeListHead(). If List is empty, then NULL is
775 If List is NULL, then ASSERT().
776 If List was not initialized with InitializeListHead(), then ASSERT().
777 If PcdMaximumLinkedListLenth is not zero, and List contains more than
778 PcdMaximumLinkedListLenth nodes, then ASSERT().
780 @param List A pointer to the head node of a doubly linked list.
782 @return The first node of a doubly linked list.
783 @retval NULL The list is empty.
789 IN CONST LIST_ENTRY
*List
793 Retrieves the next node of a doubly linked list.
795 Returns the node of a doubly linked list that follows Node. List must have
796 been initialized with InitializeListHead(). If List is empty, then List is
799 If List is NULL, then ASSERT().
800 If Node is NULL, then ASSERT().
801 If List was not initialized with InitializeListHead(), then ASSERT().
802 If PcdMaximumLinkedListLenth is not zero, and List contains more than
803 PcdMaximumLinkedListLenth nodes, then ASSERT().
804 If Node is not a node in List, then ASSERT().
806 @param List A pointer to the head node of a doubly linked list.
807 @param Node A pointer to a node in the doubly linked list.
809 @return Pointer to the next node if one exists. Otherwise a null value which
810 is actually List is returned.
816 IN CONST LIST_ENTRY
*List
,
817 IN CONST LIST_ENTRY
*Node
821 Checks to see if a doubly linked list is empty or not.
823 Checks to see if the doubly linked list is empty. If the linked list contains
824 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
826 If ListHead is NULL, then ASSERT().
827 If ListHead was not initialized with InitializeListHead(), then ASSERT().
828 If PcdMaximumLinkedListLenth is not zero, and List contains more than
829 PcdMaximumLinkedListLenth nodes, then ASSERT().
831 @param ListHead A pointer to the head node of a doubly linked list.
833 @retval TRUE The linked list is empty.
834 @retval FALSE The linked list is not empty.
840 IN CONST LIST_ENTRY
*ListHead
844 Determines if a node in a doubly linked list is null.
846 Returns FALSE if Node is one of the nodes in the doubly linked list specified
847 by List. Otherwise, TRUE is returned. List must have been initialized with
848 InitializeListHead().
850 If List is NULL, then ASSERT().
851 If Node is NULL, then ASSERT().
852 If List was not initialized with InitializeListHead(), then ASSERT().
853 If PcdMaximumLinkedListLenth is not zero, and List contains more than
854 PcdMaximumLinkedListLenth nodes, then ASSERT().
855 If Node is not a node in List and Node is not equal to List, then ASSERT().
857 @param List A pointer to the head node of a doubly linked list.
858 @param Node A pointer to a node in the doubly linked list.
860 @retval TRUE Node is one of the nodes in the doubly linked list.
861 @retval FALSE Node is not one of the nodes in the doubly linked list.
867 IN CONST LIST_ENTRY
*List
,
868 IN CONST LIST_ENTRY
*Node
872 Determines if a node the last node in a doubly linked list.
874 Returns TRUE if Node is the last node in the doubly linked list specified by
875 List. Otherwise, FALSE is returned. List must have been initialized with
876 InitializeListHead().
878 If List is NULL, then ASSERT().
879 If Node is NULL, then ASSERT().
880 If List was not initialized with InitializeListHead(), then ASSERT().
881 If PcdMaximumLinkedListLenth is not zero, and List contains more than
882 PcdMaximumLinkedListLenth nodes, then ASSERT().
883 If Node is not a node in List, then ASSERT().
885 @param List A pointer to the head node of a doubly linked list.
886 @param Node A pointer to a node in the doubly linked list.
888 @retval TRUE Node is the last node in the linked list.
889 @retval FALSE Node is not the last node in the linked list.
895 IN CONST LIST_ENTRY
*List
,
896 IN CONST LIST_ENTRY
*Node
900 Swaps the location of two nodes in a doubly linked list, and returns the
901 first node after the swap.
903 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
904 Otherwise, the location of the FirstEntry node is swapped with the location
905 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
906 same double linked list as FirstEntry and that double linked list must have
907 been initialized with InitializeListHead(). SecondEntry is returned after the
910 If FirstEntry is NULL, then ASSERT().
911 If SecondEntry is NULL, then ASSERT().
912 If SecondEntry and FirstEntry are not in the same linked list, then ASSERT().
913 If PcdMaximumLinkedListLenth is not zero, and the linked list containing
914 FirstEntry and SecondEntry contains more than PcdMaximumLinkedListLenth
915 nodes, then ASSERT().
917 @param FirstEntry A pointer to a node in a linked list.
918 @param SecondEntry A pointer to another node in the same linked list.
924 IN LIST_ENTRY
*FirstEntry
,
925 IN LIST_ENTRY
*SecondEntry
929 Removes a node from a doubly linked list, and returns the node that follows
932 Removes the node Entry from a doubly linked list. It is up to the caller of
933 this function to release the memory used by this node if that is required. On
934 exit, the node following Entry in the doubly linked list is returned. If
935 Entry is the only node in the linked list, then the head node of the linked
938 If Entry is NULL, then ASSERT().
939 If Entry is the head node of an empty list, then ASSERT().
940 If PcdMaximumLinkedListLenth is not zero, and the linked list containing
941 Entry contains more than PcdMaximumLinkedListLenth nodes, then ASSERT().
943 @param Entry A pointer to a node in a linked list
951 IN CONST LIST_ENTRY
*Entry
959 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
960 with zeros. The shifted value is returned.
962 This function shifts the 64-bit value Operand to the left by Count bits. The
963 low Count bits are set to zero. The shifted value is returned.
965 If Count is greater than 63, then ASSERT().
967 @param Operand The 64-bit operand to shift left.
968 @param Count The number of bits to shift left.
970 @return Operand << Count
981 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
982 filled with zeros. The shifted value is returned.
984 This function shifts the 64-bit value Operand to the right by Count bits. The
985 high Count bits are set to zero. The shifted value is returned.
987 If Count is greater than 63, then ASSERT().
989 @param Operand The 64-bit operand to shift right.
990 @param Count The number of bits to shift right.
992 @return Operand >> Count
1003 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
1004 with original integer's bit 63. The shifted value is returned.
1006 This function shifts the 64-bit value Operand to the right by Count bits. The
1007 high Count bits are set to bit 63 of Operand. The shifted value is returned.
1009 If Count is greater than 63, then ASSERT().
1011 @param Operand The 64-bit operand to shift right.
1012 @param Count The number of bits to shift right.
1014 @return Operand >> Count
1025 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
1026 with the high bits that were rotated.
1028 This function rotates the 32-bit value Operand to the left by Count bits. The
1029 low Count bits are fill with the high Count bits of Operand. The rotated
1032 If Count is greater than 31, then ASSERT().
1034 @param Operand The 32-bit operand to rotate left.
1035 @param Count The number of bits to rotate left.
1037 @return Operand <<< Count
1048 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
1049 with the low bits that were rotated.
1051 This function rotates the 32-bit value Operand to the right by Count bits.
1052 The high Count bits are fill with the low Count bits of Operand. The rotated
1055 If Count is greater than 31, then ASSERT().
1057 @param Operand The 32-bit operand to rotate right.
1058 @param Count The number of bits to rotate right.
1060 @return Operand >>> Count
1071 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
1072 with the high bits that were rotated.
1074 This function rotates the 64-bit value Operand to the left by Count bits. The
1075 low Count bits are fill with the high Count bits of Operand. The rotated
1078 If Count is greater than 63, then ASSERT().
1080 @param Operand The 64-bit operand to rotate left.
1081 @param Count The number of bits to rotate left.
1083 @return Operand <<< Count
1094 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
1095 with the high low bits that were rotated.
1097 This function rotates the 64-bit value Operand to the right by Count bits.
1098 The high Count bits are fill with the low Count bits of Operand. The rotated
1101 If Count is greater than 63, then ASSERT().
1103 @param Operand The 64-bit operand to rotate right.
1104 @param Count The number of bits to rotate right.
1106 @return Operand >>> Count
1117 Returns the bit position of the lowest bit set in a 32-bit value.
1119 This function computes the bit position of the lowest bit set in the 32-bit
1120 value specified by Operand. If Operand is zero, then -1 is returned.
1121 Otherwise, a value between 0 and 31 is returned.
1123 @param Operand The 32-bit operand to evaluate.
1125 @return Position of the lowest bit set in Operand if found.
1126 @retval -1 Operand is zero.
1136 Returns the bit position of the lowest bit set in a 64-bit value.
1138 This function computes the bit position of the lowest bit set in the 64-bit
1139 value specified by Operand. If Operand is zero, then -1 is returned.
1140 Otherwise, a value between 0 and 63 is returned.
1142 @param Operand The 64-bit operand to evaluate.
1144 @return Position of the lowest bit set in Operand if found.
1145 @retval -1 Operand is zero.
1155 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
1158 This function computes the bit position of the highest bit set in the 32-bit
1159 value specified by Operand. If Operand is zero, then -1 is returned.
1160 Otherwise, a value between 0 and 31 is returned.
1162 @param Operand The 32-bit operand to evaluate.
1164 @return Position of the highest bit set in Operand if found.
1165 @retval -1 Operand is zero.
1175 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
1178 This function computes the bit position of the highest bit set in the 64-bit
1179 value specified by Operand. If Operand is zero, then -1 is returned.
1180 Otherwise, a value between 0 and 63 is returned.
1182 @param Operand The 64-bit operand to evaluate.
1184 @return Position of the highest bit set in Operand if found.
1185 @retval -1 Operand is zero.
1195 Returns the value of the highest bit set in a 32-bit value. Equivalent to
1196 1 << HighBitSet32(x).
1198 This function computes the value of the highest bit set in the 32-bit value
1199 specified by Operand. If Operand is zero, then zero is returned.
1201 @param Operand The 32-bit operand to evaluate.
1203 @return 1 << HighBitSet32(Operand)
1204 @retval 0 Operand is zero.
1214 Returns the value of the highest bit set in a 64-bit value. Equivalent to
1215 1 << HighBitSet64(x).
1217 This function computes the value of the highest bit set in the 64-bit value
1218 specified by Operand. If Operand is zero, then zero is returned.
1220 @param Operand The 64-bit operand to evaluate.
1222 @return 1 << HighBitSet64(Operand)
1223 @retval 0 Operand is zero.
1233 Switches the endianess of a 16-bit integer.
1235 This function swaps the bytes in a 16-bit unsigned value to switch the value
1236 from little endian to big endian or vice versa. The byte swapped value is
1239 @param Operand A 16-bit unsigned value.
1241 @return The byte swaped Operand.
1251 Switches the endianess of a 32-bit integer.
1253 This function swaps the bytes in a 32-bit unsigned value to switch the value
1254 from little endian to big endian or vice versa. The byte swapped value is
1257 @param Operand A 32-bit unsigned value.
1259 @return The byte swaped Operand.
1269 Switches the endianess of a 64-bit integer.
1271 This function swaps the bytes in a 64-bit unsigned value to switch the value
1272 from little endian to big endian or vice versa. The byte swapped value is
1275 @param Operand A 64-bit unsigned value.
1277 @return The byte swaped Operand.
1287 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
1288 generates a 64-bit unsigned result.
1290 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
1291 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1292 bit unsigned result is returned.
1294 If the result overflows, then ASSERT().
1296 @param Multiplicand A 64-bit unsigned value.
1297 @param Multiplier A 32-bit unsigned value.
1299 @return Multiplicand * Multiplier
1305 IN UINT64 Multiplicand
,
1306 IN UINT32 Multiplier
1310 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
1311 generates a 64-bit unsigned result.
1313 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
1314 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1315 bit unsigned result is returned.
1317 If the result overflows, then ASSERT().
1319 @param Multiplicand A 64-bit unsigned value.
1320 @param Multiplier A 64-bit unsigned value.
1322 @return Multiplicand * Multiplier
1328 IN UINT64 Multiplicand
,
1329 IN UINT64 Multiplier
1333 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
1334 64-bit signed result.
1336 This function multiples the 64-bit signed value Multiplicand by the 64-bit
1337 signed value Multiplier and generates a 64-bit signed result. This 64-bit
1338 signed result is returned.
1340 If the result overflows, then ASSERT().
1342 @param Multiplicand A 64-bit signed value.
1343 @param Multiplier A 64-bit signed value.
1345 @return Multiplicand * Multiplier
1351 IN INT64 Multiplicand
,
1356 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1357 a 64-bit unsigned result.
1359 This function divides the 64-bit unsigned value Dividend by the 32-bit
1360 unsigned value Divisor and generates a 64-bit unsigned quotient. This
1361 function returns the 64-bit unsigned quotient.
1363 If Divisor is 0, then ASSERT().
1365 @param Dividend A 64-bit unsigned value.
1366 @param Divisor A 32-bit unsigned value.
1368 @return Dividend / Divisor
1379 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1380 a 32-bit unsigned remainder.
1382 This function divides the 64-bit unsigned value Dividend by the 32-bit
1383 unsigned value Divisor and generates a 32-bit remainder. This function
1384 returns the 32-bit unsigned remainder.
1386 If Divisor is 0, then ASSERT().
1388 @param Dividend A 64-bit unsigned value.
1389 @param Divisor A 32-bit unsigned value.
1391 @return Dividend % Divisor
1402 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1403 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
1405 This function divides the 64-bit unsigned value Dividend by the 32-bit
1406 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
1407 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
1408 This function returns the 64-bit unsigned quotient.
1410 If Divisor is 0, then ASSERT().
1412 @param Dividend A 64-bit unsigned value.
1413 @param Divisor A 32-bit unsigned value.
1414 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
1415 optional and may be NULL.
1417 @return Dividend / Divisor
1422 DivU64x32Remainder (
1425 OUT UINT32
*Remainder OPTIONAL
1429 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
1430 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
1432 This function divides the 64-bit unsigned value Dividend by the 64-bit
1433 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
1434 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
1435 This function returns the 64-bit unsigned quotient.
1437 If Divisor is 0, then ASSERT().
1439 @param Dividend A 64-bit unsigned value.
1440 @param Divisor A 64-bit unsigned value.
1441 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
1442 optional and may be NULL.
1444 @return Dividend / Divisor
1449 DivU64x64Remainder (
1452 OUT UINT64
*Remainder OPTIONAL
1456 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
1457 64-bit signed result and a optional 64-bit signed remainder.
1459 This function divides the 64-bit signed value Dividend by the 64-bit signed
1460 value Divisor and generates a 64-bit signed quotient. If Remainder is not
1461 NULL, then the 64-bit signed remainder is returned in Remainder. This
1462 function returns the 64-bit signed quotient.
1464 If Divisor is 0, then ASSERT().
1466 @param Dividend A 64-bit signed value.
1467 @param Divisor A 64-bit signed value.
1468 @param Remainder A pointer to a 64-bit signed value. This parameter is
1469 optional and may be NULL.
1471 @return Dividend / Divisor
1476 DivS64x64Remainder (
1479 OUT INT64
*Remainder OPTIONAL
1483 Reads a 16-bit value from memory that may be unaligned.
1485 This function returns the 16-bit value pointed to by Buffer. The function
1486 guarantees that the read operation does not produce an alignment fault.
1488 If the Buffer is NULL, then ASSERT().
1490 @param Buffer Pointer to a 16-bit value that may be unaligned.
1498 IN CONST UINT16
*Uint16
1502 Writes a 16-bit value to memory that may be unaligned.
1504 This function writes the 16-bit value specified by Value to Buffer. Value is
1505 returned. The function guarantees that the write operation does not produce
1508 If the Buffer is NULL, then ASSERT().
1510 @param Buffer Pointer to a 16-bit value that may be unaligned.
1511 @param Value 16-bit value to write to Buffer.
1524 Reads a 24-bit value from memory that may be unaligned.
1526 This function returns the 24-bit value pointed to by Buffer. The function
1527 guarantees that the read operation does not produce an alignment fault.
1529 If the Buffer is NULL, then ASSERT().
1531 @param Buffer Pointer to a 24-bit value that may be unaligned.
1533 @return The value read.
1539 IN CONST UINT32
*Buffer
1543 Writes a 24-bit value to memory that may be unaligned.
1545 This function writes the 24-bit value specified by Value to Buffer. Value is
1546 returned. The function guarantees that the write operation does not produce
1549 If the Buffer is NULL, then ASSERT().
1551 @param Buffer Pointer to a 24-bit value that may be unaligned.
1552 @param Value 24-bit value to write to Buffer.
1554 @return The value written.
1565 Reads a 32-bit value from memory that may be unaligned.
1567 This function returns the 32-bit value pointed to by Buffer. The function
1568 guarantees that the read operation does not produce an alignment fault.
1570 If the Buffer is NULL, then ASSERT().
1572 @param Buffer Pointer to a 32-bit value that may be unaligned.
1580 IN CONST UINT32
*Uint32
1584 Writes a 32-bit value to memory that may be unaligned.
1586 This function writes the 32-bit value specified by Value to Buffer. Value is
1587 returned. The function guarantees that the write operation does not produce
1590 If the Buffer is NULL, then ASSERT().
1592 @param Buffer Pointer to a 32-bit value that may be unaligned.
1593 @param Value 32-bit value to write to Buffer.
1606 Reads a 64-bit value from memory that may be unaligned.
1608 This function returns the 64-bit value pointed to by Buffer. The function
1609 guarantees that the read operation does not produce an alignment fault.
1611 If the Buffer is NULL, then ASSERT().
1613 @param Buffer Pointer to a 64-bit value that may be unaligned.
1621 IN CONST UINT64
*Uint64
1625 Writes a 64-bit value to memory that may be unaligned.
1627 This function writes the 64-bit value specified by Value to Buffer. Value is
1628 returned. The function guarantees that the write operation does not produce
1631 If the Buffer is NULL, then ASSERT().
1633 @param Buffer Pointer to a 64-bit value that may be unaligned.
1634 @param Value 64-bit value to write to Buffer.
1647 // Bit Field Functions
1651 Returns a bit field from an 8-bit value.
1653 Returns the bitfield specified by the StartBit and the EndBit from Operand.
1655 If 8-bit operations are not supported, then ASSERT().
1656 If StartBit is greater than 7, then ASSERT().
1657 If EndBit is greater than 7, then ASSERT().
1658 If EndBit is less than or equal to StartBit, then ASSERT().
1660 @param Operand Operand on which to perform the bitfield operation.
1661 @param StartBit The ordinal of the least significant bit in the bit field.
1663 @param EndBit The ordinal of the most significant bit in the bit field.
1666 @return The bit field read.
1678 Writes a bit field to an 8-bit value, and returns the result.
1680 Writes Value to the bit field specified by the StartBit and the EndBit in
1681 Operand. All other bits in Operand are preserved. The new 8-bit value is
1684 If 8-bit operations are not supported, then ASSERT().
1685 If StartBit is greater than 7, then ASSERT().
1686 If EndBit is greater than 7, then ASSERT().
1687 If EndBit is less than or equal to StartBit, then ASSERT().
1689 @param Operand Operand on which to perform the bitfield operation.
1690 @param StartBit The ordinal of the least significant bit in the bit field.
1692 @param EndBit The ordinal of the most significant bit in the bit field.
1694 @param Value New value of the bit field.
1696 @return The new 8-bit value.
1709 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
1712 Performs a bitwise inclusive OR between the bit field specified by StartBit
1713 and EndBit in Operand and the value specified by OrData. All other bits in
1714 Operand are preserved. The new 8-bit value is returned.
1716 If 8-bit operations are not supported, then ASSERT().
1717 If StartBit is greater than 7, then ASSERT().
1718 If EndBit is greater than 7, then ASSERT().
1719 If EndBit is less than or equal to StartBit, then ASSERT().
1721 @param Operand Operand on which to perform the bitfield operation.
1722 @param StartBit The ordinal of the least significant bit in the bit field.
1724 @param EndBit The ordinal of the most significant bit in the bit field.
1726 @param OrData The value to OR with the read value from the value
1728 @return The new 8-bit value.
1741 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
1744 Performs a bitwise AND between the bit field specified by StartBit and EndBit
1745 in Operand and the value specified by AndData. All other bits in Operand are
1746 preserved. The new 8-bit value is returned.
1748 If 8-bit operations are not supported, then ASSERT().
1749 If StartBit is greater than 7, then ASSERT().
1750 If EndBit is greater than 7, then ASSERT().
1751 If EndBit is less than or equal to StartBit, then ASSERT().
1753 @param Operand Operand on which to perform the bitfield operation.
1754 @param StartBit The ordinal of the least significant bit in the bit field.
1756 @param EndBit The ordinal of the most significant bit in the bit field.
1758 @param AndData The value to AND with the read value from the value.
1760 @return The new 8-bit value.
1773 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
1774 bitwise OR, and returns the result.
1776 Performs a bitwise AND between the bit field specified by StartBit and EndBit
1777 in Operand and the value specified by AndData, followed by a bitwise
1778 inclusive OR with value specified by OrData. All other bits in Operand are
1779 preserved. The new 8-bit value is returned.
1781 If 8-bit operations are not supported, then ASSERT().
1782 If StartBit is greater than 7, then ASSERT().
1783 If EndBit is greater than 7, then ASSERT().
1784 If EndBit is less than or equal to StartBit, then ASSERT().
1786 @param Operand Operand on which to perform the bitfield operation.
1787 @param StartBit The ordinal of the least significant bit in the bit field.
1789 @param EndBit The ordinal of the most significant bit in the bit field.
1791 @param AndData The value to AND with the read value from the value.
1792 @param OrData The value to OR with the result of the AND operation.
1794 @return The new 8-bit value.
1799 BitFieldAndThenOr8 (
1808 Returns a bit field from a 16-bit value.
1810 Returns the bitfield specified by the StartBit and the EndBit from Operand.
1812 If 16-bit operations are not supported, then ASSERT().
1813 If StartBit is greater than 15, then ASSERT().
1814 If EndBit is greater than 15, then ASSERT().
1815 If EndBit is less than or equal to StartBit, then ASSERT().
1817 @param Operand Operand on which to perform the bitfield operation.
1818 @param StartBit The ordinal of the least significant bit in the bit field.
1820 @param EndBit The ordinal of the most significant bit in the bit field.
1823 @return The bit field read.
1835 Writes a bit field to a 16-bit value, and returns the result.
1837 Writes Value to the bit field specified by the StartBit and the EndBit in
1838 Operand. All other bits in Operand are preserved. The new 16-bit value is
1841 If 16-bit operations are not supported, then ASSERT().
1842 If StartBit is greater than 15, then ASSERT().
1843 If EndBit is greater than 15, then ASSERT().
1844 If EndBit is less than or equal to StartBit, then ASSERT().
1846 @param Operand Operand on which to perform the bitfield operation.
1847 @param StartBit The ordinal of the least significant bit in the bit field.
1849 @param EndBit The ordinal of the most significant bit in the bit field.
1851 @param Value New value of the bit field.
1853 @return The new 16-bit value.
1866 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
1869 Performs a bitwise inclusive OR between the bit field specified by StartBit
1870 and EndBit in Operand and the value specified by OrData. All other bits in
1871 Operand are preserved. The new 16-bit value is returned.
1873 If 16-bit operations are not supported, then ASSERT().
1874 If StartBit is greater than 15, then ASSERT().
1875 If EndBit is greater than 15, then ASSERT().
1876 If EndBit is less than or equal to StartBit, then ASSERT().
1878 @param Operand Operand on which to perform the bitfield operation.
1879 @param StartBit The ordinal of the least significant bit in the bit field.
1881 @param EndBit The ordinal of the most significant bit in the bit field.
1883 @param OrData The value to OR with the read value from the value
1885 @return The new 16-bit value.
1898 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
1901 Performs a bitwise AND between the bit field specified by StartBit and EndBit
1902 in Operand and the value specified by AndData. All other bits in Operand are
1903 preserved. The new 16-bit value is returned.
1905 If 16-bit operations are not supported, then ASSERT().
1906 If StartBit is greater than 15, then ASSERT().
1907 If EndBit is greater than 15, then ASSERT().
1908 If EndBit is less than or equal to StartBit, then ASSERT().
1910 @param Operand Operand on which to perform the bitfield operation.
1911 @param StartBit The ordinal of the least significant bit in the bit field.
1913 @param EndBit The ordinal of the most significant bit in the bit field.
1915 @param AndData The value to AND with the read value from the value
1917 @return The new 16-bit value.
1930 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
1931 bitwise OR, and returns the result.
1933 Performs a bitwise AND between the bit field specified by StartBit and EndBit
1934 in Operand and the value specified by AndData, followed by a bitwise
1935 inclusive OR with value specified by OrData. All other bits in Operand are
1936 preserved. The new 16-bit value is returned.
1938 If 16-bit operations are not supported, then ASSERT().
1939 If StartBit is greater than 15, then ASSERT().
1940 If EndBit is greater than 15, then ASSERT().
1941 If EndBit is less than or equal to StartBit, then ASSERT().
1943 @param Operand Operand on which to perform the bitfield operation.
1944 @param StartBit The ordinal of the least significant bit in the bit field.
1946 @param EndBit The ordinal of the most significant bit in the bit field.
1948 @param AndData The value to AND with the read value from the value.
1949 @param OrData The value to OR with the result of the AND operation.
1951 @return The new 16-bit value.
1956 BitFieldAndThenOr16 (
1965 Returns a bit field from a 32-bit value.
1967 Returns the bitfield specified by the StartBit and the EndBit from Operand.
1969 If 32-bit operations are not supported, then ASSERT().
1970 If StartBit is greater than 31, then ASSERT().
1971 If EndBit is greater than 31, then ASSERT().
1972 If EndBit is less than or equal to StartBit, then ASSERT().
1974 @param Operand Operand on which to perform the bitfield operation.
1975 @param StartBit The ordinal of the least significant bit in the bit field.
1977 @param EndBit The ordinal of the most significant bit in the bit field.
1980 @return The bit field read.
1992 Writes a bit field to a 32-bit value, and returns the result.
1994 Writes Value to the bit field specified by the StartBit and the EndBit in
1995 Operand. All other bits in Operand are preserved. The new 32-bit value is
1998 If 32-bit operations are not supported, then ASSERT().
1999 If StartBit is greater than 31, then ASSERT().
2000 If EndBit is greater than 31, then ASSERT().
2001 If EndBit is less than or equal to StartBit, then ASSERT().
2003 @param Operand Operand on which to perform the bitfield operation.
2004 @param StartBit The ordinal of the least significant bit in the bit field.
2006 @param EndBit The ordinal of the most significant bit in the bit field.
2008 @param Value New value of the bit field.
2010 @return The new 32-bit value.
2023 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
2026 Performs a bitwise inclusive OR between the bit field specified by StartBit
2027 and EndBit in Operand and the value specified by OrData. All other bits in
2028 Operand are preserved. The new 32-bit value is returned.
2030 If 32-bit operations are not supported, then ASSERT().
2031 If StartBit is greater than 31, then ASSERT().
2032 If EndBit is greater than 31, then ASSERT().
2033 If EndBit is less than or equal to StartBit, then ASSERT().
2035 @param Operand Operand on which to perform the bitfield operation.
2036 @param StartBit The ordinal of the least significant bit in the bit field.
2038 @param EndBit The ordinal of the most significant bit in the bit field.
2040 @param OrData The value to OR with the read value from the value
2042 @return The new 32-bit value.
2055 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
2058 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2059 in Operand and the value specified by AndData. All other bits in Operand are
2060 preserved. The new 32-bit value is returned.
2062 If 32-bit operations are not supported, then ASSERT().
2063 If StartBit is greater than 31, then ASSERT().
2064 If EndBit is greater than 31, then ASSERT().
2065 If EndBit is less than or equal to StartBit, then ASSERT().
2067 @param Operand Operand on which to perform the bitfield operation.
2068 @param StartBit The ordinal of the least significant bit in the bit field.
2070 @param EndBit The ordinal of the most significant bit in the bit field.
2072 @param AndData The value to AND with the read value from the value
2074 @return The new 32-bit value.
2087 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
2088 bitwise OR, and returns the result.
2090 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2091 in Operand and the value specified by AndData, followed by a bitwise
2092 inclusive OR with value specified by OrData. All other bits in Operand are
2093 preserved. The new 32-bit value is returned.
2095 If 32-bit operations are not supported, then ASSERT().
2096 If StartBit is greater than 31, then ASSERT().
2097 If EndBit is greater than 31, then ASSERT().
2098 If EndBit is less than or equal to StartBit, then ASSERT().
2100 @param Operand Operand on which to perform the bitfield operation.
2101 @param StartBit The ordinal of the least significant bit in the bit field.
2103 @param EndBit The ordinal of the most significant bit in the bit field.
2105 @param AndData The value to AND with the read value from the value.
2106 @param OrData The value to OR with the result of the AND operation.
2108 @return The new 32-bit value.
2113 BitFieldAndThenOr32 (
2122 Returns a bit field from a 64-bit value.
2124 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2126 If 64-bit operations are not supported, then ASSERT().
2127 If StartBit is greater than 63, then ASSERT().
2128 If EndBit is greater than 63, then ASSERT().
2129 If EndBit is less than or equal to StartBit, then ASSERT().
2131 @param Operand Operand on which to perform the bitfield operation.
2132 @param StartBit The ordinal of the least significant bit in the bit field.
2134 @param EndBit The ordinal of the most significant bit in the bit field.
2137 @return The bit field read.
2149 Writes a bit field to a 64-bit value, and returns the result.
2151 Writes Value to the bit field specified by the StartBit and the EndBit in
2152 Operand. All other bits in Operand are preserved. The new 64-bit value is
2155 If 64-bit operations are not supported, then ASSERT().
2156 If StartBit is greater than 63, then ASSERT().
2157 If EndBit is greater than 63, then ASSERT().
2158 If EndBit is less than or equal to StartBit, then ASSERT().
2160 @param Operand Operand on which to perform the bitfield operation.
2161 @param StartBit The ordinal of the least significant bit in the bit field.
2163 @param EndBit The ordinal of the most significant bit in the bit field.
2165 @param Value New value of the bit field.
2167 @return The new 64-bit value.
2180 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
2183 Performs a bitwise inclusive OR between the bit field specified by StartBit
2184 and EndBit in Operand and the value specified by OrData. All other bits in
2185 Operand are preserved. The new 64-bit value is returned.
2187 If 64-bit operations are not supported, then ASSERT().
2188 If StartBit is greater than 63, then ASSERT().
2189 If EndBit is greater than 63, then ASSERT().
2190 If EndBit is less than or equal to StartBit, then ASSERT().
2192 @param Operand Operand on which to perform the bitfield operation.
2193 @param StartBit The ordinal of the least significant bit in the bit field.
2195 @param EndBit The ordinal of the most significant bit in the bit field.
2197 @param OrData The value to OR with the read value from the value
2199 @return The new 64-bit value.
2212 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
2215 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2216 in Operand and the value specified by AndData. All other bits in Operand are
2217 preserved. The new 64-bit value is returned.
2219 If 64-bit operations are not supported, then ASSERT().
2220 If StartBit is greater than 63, then ASSERT().
2221 If EndBit is greater than 63, then ASSERT().
2222 If EndBit is less than or equal to StartBit, then ASSERT().
2224 @param Operand Operand on which to perform the bitfield operation.
2225 @param StartBit The ordinal of the least significant bit in the bit field.
2227 @param EndBit The ordinal of the most significant bit in the bit field.
2229 @param AndData The value to AND with the read value from the value
2231 @return The new 64-bit value.
2244 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
2245 bitwise OR, and returns the result.
2247 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2248 in Operand and the value specified by AndData, followed by a bitwise
2249 inclusive OR with value specified by OrData. All other bits in Operand are
2250 preserved. The new 64-bit value is returned.
2252 If 64-bit operations are not supported, then ASSERT().
2253 If StartBit is greater than 63, then ASSERT().
2254 If EndBit is greater than 63, then ASSERT().
2255 If EndBit is less than or equal to StartBit, then ASSERT().
2257 @param Operand Operand on which to perform the bitfield operation.
2258 @param StartBit The ordinal of the least significant bit in the bit field.
2260 @param EndBit The ordinal of the most significant bit in the bit field.
2262 @param AndData The value to AND with the read value from the value.
2263 @param OrData The value to OR with the result of the AND operation.
2265 @return The new 64-bit value.
2270 BitFieldAndThenOr64 (
2279 // Base Library Synchronization Functions
2283 Retrieves the architecture specific spin lock alignment requirements for
2284 optimal spin lock performance.
2286 This function retrieves the spin lock alignment requirements for optimal
2287 performance on a given CPU architecture. The spin lock alignment must be a
2288 power of two and is returned by this function. If there are no alignment
2289 requirements, then 1 must be returned. The spin lock synchronization
2290 functions must function correctly if the spin lock size and alignment values
2291 returned by this function are not used at all. These values are hints to the
2292 consumers of the spin lock synchronization functions to obtain optimal spin
2295 @return The architecture specific spin lock alignment.
2300 GetSpinLockProperties (
2305 Initializes a spin lock to the released state and returns the spin lock.
2307 This function initializes the spin lock specified by SpinLock to the released
2308 state, and returns SpinLock. Optimal performance can be achieved by calling
2309 GetSpinLockProperties() to determine the size and alignment requirements for
2312 If SpinLock is NULL, then ASSERT().
2314 @param SpinLock A pointer to the spin lock to initialize to the released
2322 InitializeSpinLock (
2323 IN SPIN_LOCK
*SpinLock
2327 Waits until a spin lock can be placed in the acquired state.
2329 This function checks the state of the spin lock specified by SpinLock. If
2330 SpinLock is in the released state, then this function places SpinLock in the
2331 acquired state and returns SpinLock. Otherwise, this function waits
2332 indefinitely for the spin lock to be released, and then places it in the
2333 acquired state and returns SpinLock. All state transitions of SpinLock must
2334 be performed using MP safe mechanisms.
2336 If SpinLock is NULL, then ASSERT().
2337 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
2338 If PcdSpinLockTimeout is not zero, and SpinLock is can not be acquired in
2339 PcdSpinLockTimeout microseconds, then ASSERT().
2341 @param SpinLock A pointer to the spin lock to place in the acquired state.
2349 IN SPIN_LOCK
*SpinLock
2353 Attempts to place a spin lock in the acquired state.
2355 This function checks the state of the spin lock specified by SpinLock. If
2356 SpinLock is in the released state, then this function places SpinLock in the
2357 acquired state and returns TRUE. Otherwise, FALSE is returned. All state
2358 transitions of SpinLock must be performed using MP safe mechanisms.
2360 If SpinLock is NULL, then ASSERT().
2361 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
2363 @param SpinLock A pointer to the spin lock to place in the acquired state.
2365 @retval TRUE SpinLock was placed in the acquired state.
2366 @retval FALSE SpinLock could not be acquired.
2371 AcquireSpinLockOrFail (
2372 IN SPIN_LOCK
*SpinLock
2376 Releases a spin lock.
2378 This function places the spin lock specified by SpinLock in the release state
2379 and returns SpinLock.
2381 If SpinLock is NULL, then ASSERT().
2382 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
2384 @param SpinLock A pointer to the spin lock to release.
2392 IN SPIN_LOCK
*SpinLock
2396 Performs an atomic increment of an 32-bit unsigned integer.
2398 Performs an atomic increment of the 32-bit unsigned integer specified by
2399 Value and returns the incremented value. The increment operation must be
2400 performed using MP safe mechanisms. The state of the return value is not
2401 guaranteed to be MP safe.
2403 If Value is NULL, then ASSERT().
2405 @param Value A pointer to the 32-bit value to increment.
2407 @return The incremented value.
2412 InterlockedIncrement (
2417 Performs an atomic decrement of an 32-bit unsigned integer.
2419 Performs an atomic decrement of the 32-bit unsigned integer specified by
2420 Value and returns the decremented value. The decrement operation must be
2421 performed using MP safe mechanisms. The state of the return value is not
2422 guaranteed to be MP safe.
2424 If Value is NULL, then ASSERT().
2426 @param Value A pointer to the 32-bit value to decrement.
2428 @return The decremented value.
2433 InterlockedDecrement (
2438 Performs an atomic compare exchange operation on a 32-bit unsigned integer.
2440 @param Value A pointer to the 32-bit value for the compare exchange
2442 @param CompareValue 32-bit value used in compare operation.
2443 @param ExchangeValue 32-bit value used in exchange operation.
2445 @return The original *Value before exchange.
2450 InterlockedCompareExchange32 (
2452 IN UINT32 CompareValue
,
2453 IN UINT32 ExchangeValue
2457 Performs an atomic compare exchange operation on a 64-bit unsigned integer.
2459 @param Value A pointer to the 64-bit value for the compare exchange
2461 @param CompareValue 64-bit value used in compare operation.
2462 @param ExchangeValue 64-bit value used in exchange operation.
2464 @return The original *Value before exchange.
2469 InterlockedCompareExchange64 (
2471 IN UINT64 CompareValue
,
2472 IN UINT64 ExchangeValue
2476 Performs an atomic compare exchange operation on a pointer value.
2478 Performs an atomic compare exchange operation on the pointer value specified
2479 by Value. If Value is equal to CompareValue, then Value is set to
2480 ExchangeValue and CompareValue is returned. If Value is not equal to
2481 CompareValue, then Value is returned. The compare exchange operation must be
2482 performed using MP safe mechanisms.
2484 If Value is NULL, then ASSERT().
2486 @param Value A pointer to the pointer value for the compare exchange
2488 @param CompareValue Pointer value used in compare operation.
2489 @param ExchangeValue Pointer value used in exchange operation.
2494 InterlockedCompareExchangePointer (
2496 IN VOID
*CompareValue
,
2497 IN VOID
*ExchangeValue
2501 // Base Library CPU Functions
2505 (EFIAPI
*SWITCH_STACK_ENTRY_POINT
) (
2506 IN VOID
*Context1
, OPTIONAL
2507 IN VOID
*Context2 OPTIONAL
2511 Used to serialize load and store operations.
2513 All loads and stores that proceed calls to this function are guaranteed to be
2514 globally visible when this function returns.
2524 Saves the current CPU context that can be restored with a call to LongJump()
2527 Saves the current CPU context in the buffer specified by JumpBuffer and
2528 returns 0. The initial call to SetJump() must always return 0. Subsequent
2529 calls to LongJump() cause a non-zero value to be returned by SetJump().
2531 If JumpBuffer is NULL, then ASSERT().
2533 @param JumpBuffer A pointer to CPU context buffer.
2535 @retval 0 Indicates a return from SetJump().
2541 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
2545 Restores the CPU context that was saved with SetJump().
2547 Restores the CPU context from the buffer specified by JumpBuffer. This
2548 function never returns to the caller. Instead is resumes execution based on
2549 the state of JumpBuffer.
2551 If JumpBuffer is NULL, then ASSERT().
2552 If Value is 0, then ASSERT().
2554 @param JumpBuffer A pointer to CPU context buffer.
2555 @param Value The value to return when the SetJump() context is
2556 restored and must be non-zero.
2562 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
2567 Enables CPU interrupts.
2569 Enables CPU interrupts.
2579 Disables CPU interrupts.
2581 Disables CPU interrupts.
2591 Disables CPU interrupts and returns the interrupt state prior to the disable
2594 Disables CPU interrupts and returns the interrupt state prior to the disable
2597 @retval TRUE CPU interrupts were enabled on entry to this call.
2598 @retval FALSE CPU interrupts were disabled on entry to this call.
2603 SaveAndDisableInterrupts (
2608 Enables CPU interrupts for the smallest window required to capture any
2611 Enables CPU interrupts for the smallest window required to capture any
2617 EnableDisableInterrupts (
2622 Retrieves the current CPU interrupt state.
2624 Retrieves the current CPU interrupt state. Returns TRUE is interrupts are
2625 currently enabled. Otherwise returns FALSE.
2627 @retval TRUE CPU interrupts are enabled.
2628 @retval FALSE CPU interrupts are disabled.
2638 Set the current CPU interrupt state.
2640 Sets the current CPU interrupt state to the state specified by
2641 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
2642 InterruptState is FALSE, then interrupts are disabled. InterruptState is
2645 @param InterruptState TRUE if interrupts should enabled. FALSE if
2646 interrupts should be disabled.
2648 @return InterruptState
2654 IN BOOLEAN InterruptState
2658 Places the CPU in a sleep state until an interrupt is received.
2660 Places the CPU in a sleep state until an interrupt is received. If interrupts
2661 are disabled prior to calling this function, then the CPU will be placed in a
2662 sleep state indefinitely.
2672 Requests CPU to pause for a short period of time.
2674 Requests CPU to pause for a short period of time. Typically used in MP
2675 systems to prevent memory starvation while waiting for a spin lock.
2685 Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU.
2687 Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU.
2697 Transfers control to a function starting with a new stack.
2699 Transfers control to the function specified by EntryPoint using the new stack
2700 specified by NewStack and passing in the parameters specified by Context1 and
2701 Context2. Context1 and Context2 are optional and may be NULL. The function
2702 EntryPoint must never return.
2704 If EntryPoint is NULL, then ASSERT().
2705 If NewStack is NULL, then ASSERT().
2707 @param EntryPoint A pointer to function to call with the new stack.
2708 @param Context1 A pointer to the context to pass into the EntryPoint
2710 @param Context2 A pointer to the context to pass into the EntryPoint
2712 @param NewStack A pointer to the new stack to use for the EntryPoint
2719 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
2720 IN VOID
*Context1
, OPTIONAL
2721 IN VOID
*Context2
, OPTIONAL
2726 Generates a breakpoint on the CPU.
2728 Generates a breakpoint on the CPU. The breakpoint must be implemented such
2729 that code can resume normal execution after the breakpoint.
2739 Executes an infinite loop.
2741 Forces the CPU to execute an infinite loop. A debugger may be used to skip
2742 past the loop and the code that follows the loop must execute properly. This
2743 implies that the infinite loop must not cause the code that follow it to be
2754 // IA32 and X64 Specific Functions
2757 // Byte packed structure for 16-bit Real Mode EFLAGS
2761 UINT32 CF
:1; // Carry Flag
2762 UINT32 Reserved_0
:1; // Reserved
2763 UINT32 PF
:1; // Parity Flag
2764 UINT32 Reserved_1
:1; // Reserved
2765 UINT32 AF
:1; // Auxiliary Carry Flag
2766 UINT32 Reserved_2
:1; // Reserved
2767 UINT32 ZF
:1; // Zero Flag
2768 UINT32 SF
:1; // Sign Flag
2769 UINT32 TF
:1; // Trap Flag
2770 UINT32 IF
:1; // Interrupt Enable Flag
2771 UINT32 DF
:1; // Direction Flag
2772 UINT32 OF
:1; // Overflow Flag
2773 UINT32 IOPL
:2; // I/O Privilege Level
2774 UINT32 NT
:1; // Nested Task
2775 UINT32 Reserved_3
:1; // Reserved
2781 // Byte packed structure for EFLAGS/RFLAGS
2783 // 64-bits on X64. The upper 32-bits on X64 are reserved
2787 UINT32 CF
:1; // Carry Flag
2788 UINT32 Reserved_0
:1; // Reserved
2789 UINT32 PF
:1; // Parity Flag
2790 UINT32 Reserved_1
:1; // Reserved
2791 UINT32 AF
:1; // Auxiliary Carry Flag
2792 UINT32 Reserved_2
:1; // Reserved
2793 UINT32 ZF
:1; // Zero Flag
2794 UINT32 SF
:1; // Sign Flag
2795 UINT32 TF
:1; // Trap Flag
2796 UINT32 IF
:1; // Interrupt Enable Flag
2797 UINT32 DF
:1; // Direction Flag
2798 UINT32 OF
:1; // Overflow Flag
2799 UINT32 IOPL
:2; // I/O Privilege Level
2800 UINT32 NT
:1; // Nested Task
2801 UINT32 Reserved_3
:1; // Reserved
2802 UINT32 RF
:1; // Resume Flag
2803 UINT32 VM
:1; // Virtual 8086 Mode
2804 UINT32 AC
:1; // Alignment Check
2805 UINT32 VIF
:1; // Virtual Interrupt Flag
2806 UINT32 VIP
:1; // Virtual Interrupt Pending
2807 UINT32 ID
:1; // ID Flag
2808 UINT32 Reserved_4
:10; // Reserved
2814 // Byte packed structure for Control Register 0 (CR0)
2816 // 64-bits on X64. The upper 32-bits on X64 are reserved
2820 UINT32 PE
:1; // Protection Enable
2821 UINT32 MP
:1; // Monitor Coprocessor
2822 UINT32 EM
:1; // Emulation
2823 UINT32 TS
:1; // Task Switched
2824 UINT32 ET
:1; // Extension Type
2825 UINT32 NE
:1; // Numeric Error
2826 UINT32 Reserved_0
:10; // Reserved
2827 UINT32 WP
:1; // Write Protect
2828 UINT32 Reserved_1
:1; // Reserved
2829 UINT32 AM
:1; // Alignment Mask
2830 UINT32 Reserved_2
:10; // Reserved
2831 UINT32 NW
:1; // Mot Write-through
2832 UINT32 CD
:1; // Cache Disable
2833 UINT32 PG
:1; // Paging
2839 // Byte packed structure for Control Register 4 (CR4)
2841 // 64-bits on X64. The upper 32-bits on X64 are reserved
2845 UINT32 VME
:1; // Virtual-8086 Mode Extensions
2846 UINT32 PVI
:1; // Protected-Mode Virtual Interrupts
2847 UINT32 TSD
:1; // Time Stamp Disable
2848 UINT32 DE
:1; // Debugging Extensions
2849 UINT32 PSE
:1; // Page Size Extensions
2850 UINT32 PAE
:1; // Physical Address Extension
2851 UINT32 MCE
:1; // Machine Check Enable
2852 UINT32 PGE
:1; // Page Global Enable
2853 UINT32 PCE
:1; // Performance Monitoring Counter
2855 UINT32 OSFXSR
:1; // Operating System Support for
2856 // FXSAVE and FXRSTOR instructions
2857 UINT32 OSXMMEXCPT
:1; // Operating System Support for
2858 // Unmasked SIMD Floating Point
2860 UINT32 Reserved_0
:2; // Reserved
2861 UINT32 VMXE
:1; // VMX Enable
2862 UINT32 Reserved_1
:18; // Reseved
2868 // Byte packed structure for an IDTR, GDTR, LDTR descriptor
2875 #define IA32_IDT_GATE_TYPE_TASK 0x85
2876 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
2877 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
2878 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
2879 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
2882 // Byte packed structure for an Interrupt Gate Descriptor
2886 UINT32 OffsetLow
:16; // Offset bits 15..0
2887 UINT32 Selector
:16; // Selector
2888 UINT32 Reserved_0
:8; // Reserved
2889 UINT32 GateType
:8; // Gate Type. See #defines above
2890 UINT32 OffsetHigh
:16; // Offset bits 31..16
2893 } IA32_IDT_GATE_DESCRIPTOR
;
2896 // Byte packed structure for an FP/SSE/SSE2 context
2903 // Structures for the 16-bit real mode thunks
2956 IA32_EFLAGS32 EFLAGS
;
2966 } IA32_REGISTER_SET
;
2969 // Byte packed structure for an 16-bit real mode thunks
2972 IA32_REGISTER_SET
*RealModeState
;
2973 VOID
*RealModeBuffer
;
2974 UINT32 RealModeBufferSize
;
2975 UINT32 ThunkAttributes
;
2978 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
2979 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
2980 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
2983 Retrieves CPUID information.
2985 Executes the CPUID instruction with EAX set to the value specified by Index.
2986 This function always returns Index.
2987 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
2988 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
2989 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
2990 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
2991 This function is only available on IA-32 and X64.
2993 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
2995 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
2996 instruction. This is an optional parameter that may be NULL.
2997 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
2998 instruction. This is an optional parameter that may be NULL.
2999 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
3000 instruction. This is an optional parameter that may be NULL.
3001 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
3002 instruction. This is an optional parameter that may be NULL.
3011 OUT UINT32
*Eax
, OPTIONAL
3012 OUT UINT32
*Ebx
, OPTIONAL
3013 OUT UINT32
*Ecx
, OPTIONAL
3014 OUT UINT32
*Edx OPTIONAL
3018 Returns the lower 32-bits of a Machine Specific Register(MSR).
3020 Reads and returns the lower 32-bits of the MSR specified by Index.
3021 No parameter checking is performed on Index, and some Index values may cause
3022 CPU exceptions. The caller must either guarantee that Index is valid, or the
3023 caller must set up exception handlers to catch the exceptions. This function
3024 is only available on IA-32 and X64.
3026 @param Index The 32-bit MSR index to read.
3028 @return The lower 32 bits of the MSR identified by Index.
3038 Zero-extend a 32-bit value and writes it to a Machine Specific Register(MSR).
3040 Writes the 32-bit value specified by Value to the MSR specified by Index. The
3041 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
3042 the MSR is returned. No parameter checking is performed on Index or Value,
3043 and some of these may cause CPU exceptions. The caller must either guarantee
3044 that Index and Value are valid, or the caller must establish proper exception
3045 handlers. This function is only available on IA-32 and X64.
3047 @param Index The 32-bit MSR index to write.
3048 @param Value The 32-bit value to write to the MSR.
3061 Reads a 64-bit MSR, performs a bitwise inclusive OR on the lower 32-bits, and
3062 writes the result back to the 64-bit MSR.
3064 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
3065 between the lower 32-bits of the read result and the value specified by
3066 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
3067 32-bits of the value written to the MSR is returned. No parameter checking is
3068 performed on Index or OrData, and some of these may cause CPU exceptions. The
3069 caller must either guarantee that Index and OrData are valid, or the caller
3070 must establish proper exception handlers. This function is only available on
3073 @param Index The 32-bit MSR index to write.
3074 @param OrData The value to OR with the read value from the MSR.
3076 @return The lower 32-bit value written to the MSR.
3087 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
3088 the result back to the 64-bit MSR.
3090 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
3091 lower 32-bits of the read result and the value specified by AndData, and
3092 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
3093 the value written to the MSR is returned. No parameter checking is performed
3094 on Index or AndData, and some of these may cause CPU exceptions. The caller
3095 must either guarantee that Index and AndData are valid, or the caller must
3096 establish proper exception handlers. This function is only available on IA-32
3099 @param Index The 32-bit MSR index to write.
3100 @param AndData The value to AND with the read value from the MSR.
3102 @return The lower 32-bit value written to the MSR.
3113 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive OR
3114 on the lower 32-bits, and writes the result back to the 64-bit MSR.
3116 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
3117 lower 32-bits of the read result and the value specified by AndData
3118 preserving the upper 32-bits, performs a bitwise inclusive OR between the
3119 result of the AND operation and the value specified by OrData, and writes the
3120 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
3121 written to the MSR is returned. No parameter checking is performed on Index,
3122 AndData, or OrData, and some of these may cause CPU exceptions. The caller
3123 must either guarantee that Index, AndData, and OrData are valid, or the
3124 caller must establish proper exception handlers. This function is only
3125 available on IA-32 and X64.
3127 @param Index The 32-bit MSR index to write.
3128 @param AndData The value to AND with the read value from the MSR.
3129 @param OrData The value to OR with the result of the AND operation.
3131 @return The lower 32-bit value written to the MSR.
3143 Reads a bit field of an MSR.
3145 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
3146 specified by the StartBit and the EndBit. The value of the bit field is
3147 returned. The caller must either guarantee that Index is valid, or the caller
3148 must set up exception handlers to catch the exceptions. This function is only
3149 available on IA-32 and X64.
3151 If StartBit is greater than 31, then ASSERT().
3152 If EndBit is greater than 31, then ASSERT().
3153 If EndBit is less than or equal to StartBit, then ASSERT().
3155 @param Index The 32-bit MSR index to read.
3156 @param StartBit The ordinal of the least significant bit in the bit field.
3158 @param EndBit The ordinal of the most significant bit in the bit field.
3161 @return The bit field read from the MSR.
3166 AsmMsrBitFieldRead32 (
3173 Writes a bit field to an MSR.
3175 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
3176 field is specified by the StartBit and the EndBit. All other bits in the
3177 destination MSR are preserved. The lower 32-bits of the MSR written is
3178 returned. Extra left bits in Value are stripped. The caller must either
3179 guarantee that Index and the data written is valid, or the caller must set up
3180 exception handlers to catch the exceptions. This function is only available
3183 If StartBit is greater than 31, then ASSERT().
3184 If EndBit is greater than 31, then ASSERT().
3185 If EndBit is less than or equal to StartBit, then ASSERT().
3187 @param Index The 32-bit MSR index to write.
3188 @param StartBit The ordinal of the least significant bit in the bit field.
3190 @param EndBit The ordinal of the most significant bit in the bit field.
3192 @param Value New value of the bit field.
3194 @return The lower 32-bit of the value written to the MSR.
3199 AsmMsrBitFieldWrite32 (
3207 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
3208 result back to the bit field in the 64-bit MSR.
3210 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
3211 between the read result and the value specified by OrData, and writes the
3212 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
3213 written to the MSR are returned. Extra left bits in OrData are stripped. The
3214 caller must either guarantee that Index and the data written is valid, or
3215 the caller must set up exception handlers to catch the exceptions. This
3216 function is only available on IA-32 and X64.
3218 If StartBit is greater than 31, then ASSERT().
3219 If EndBit is greater than 31, then ASSERT().
3220 If EndBit is less than or equal to StartBit, then ASSERT().
3222 @param Index The 32-bit MSR index to write.
3223 @param StartBit The ordinal of the least significant bit in the bit field.
3225 @param EndBit The ordinal of the most significant bit in the bit field.
3227 @param OrData The value to OR with the read value from the MSR.
3229 @return The lower 32-bit of the value written to the MSR.
3234 AsmMsrBitFieldOr32 (
3242 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
3243 result back to the bit field in the 64-bit MSR.
3245 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
3246 read result and the value specified by AndData, and writes the result to the
3247 64-bit MSR specified by Index. The lower 32-bits of the value written to the
3248 MSR are returned. Extra left bits in AndData are stripped. The caller must
3249 either guarantee that Index and the data written is valid, or the caller must
3250 set up exception handlers to catch the exceptions. This function is only
3251 available on IA-32 and X64.
3253 If StartBit is greater than 31, then ASSERT().
3254 If EndBit is greater than 31, then ASSERT().
3255 If EndBit is less than or equal to StartBit, then ASSERT().
3257 @param Index The 32-bit MSR index to write.
3258 @param StartBit The ordinal of the least significant bit in the bit field.
3260 @param EndBit The ordinal of the most significant bit in the bit field.
3262 @param AndData The value to AND with the read value from the MSR.
3264 @return The lower 32-bit of the value written to the MSR.
3269 AsmMsrBitFieldAnd32 (
3277 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
3278 bitwise inclusive OR, and writes the result back to the bit field in the
3281 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
3282 bitwise inclusive OR between the read result and the value specified by
3283 AndData, and writes the result to the 64-bit MSR specified by Index. The
3284 lower 32-bits of the value written to the MSR are returned. Extra left bits
3285 in both AndData and OrData are stripped. The caller must either guarantee
3286 that Index and the data written is valid, or the caller must set up exception
3287 handlers to catch the exceptions. This function is only available on IA-32
3290 If StartBit is greater than 31, then ASSERT().
3291 If EndBit is greater than 31, then ASSERT().
3292 If EndBit is less than or equal to StartBit, then ASSERT().
3294 @param Index The 32-bit MSR index to write.
3295 @param StartBit The ordinal of the least significant bit in the bit field.
3297 @param EndBit The ordinal of the most significant bit in the bit field.
3299 @param AndData The value to AND with the read value from the MSR.
3300 @param OrData The value to OR with the result of the AND operation.
3302 @return The lower 32-bit of the value written to the MSR.
3307 AsmMsrBitFieldAndThenOr32 (
3316 Returns a 64-bit Machine Specific Register(MSR).
3318 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
3319 performed on Index, and some Index values may cause CPU exceptions. The
3320 caller must either guarantee that Index is valid, or the caller must set up
3321 exception handlers to catch the exceptions. This function is only available
3324 @param Index The 32-bit MSR index to read.
3326 @return The value of the MSR identified by Index.
3336 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
3339 Writes the 64-bit value specified by Value to the MSR specified by Index. The
3340 64-bit value written to the MSR is returned. No parameter checking is
3341 performed on Index or Value, and some of these may cause CPU exceptions. The
3342 caller must either guarantee that Index and Value are valid, or the caller
3343 must establish proper exception handlers. This function is only available on
3346 @param Index The 32-bit MSR index to write.
3347 @param Value The 64-bit value to write to the MSR.
3360 Reads a 64-bit MSR, performs a bitwise inclusive OR, and writes the result
3361 back to the 64-bit MSR.
3363 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
3364 between the read result and the value specified by OrData, and writes the
3365 result to the 64-bit MSR specified by Index. The value written to the MSR is
3366 returned. No parameter checking is performed on Index or OrData, and some of
3367 these may cause CPU exceptions. The caller must either guarantee that Index
3368 and OrData are valid, or the caller must establish proper exception handlers.
3369 This function is only available on IA-32 and X64.
3371 @param Index The 32-bit MSR index to write.
3372 @param OrData The value to OR with the read value from the MSR.
3374 @return The value written back to the MSR.
3385 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
3388 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
3389 read result and the value specified by OrData, and writes the result to the
3390 64-bit MSR specified by Index. The value written to the MSR is returned. No
3391 parameter checking is performed on Index or OrData, and some of these may
3392 cause CPU exceptions. The caller must either guarantee that Index and OrData
3393 are valid, or the caller must establish proper exception handlers. This
3394 function is only available on IA-32 and X64.
3396 @param Index The 32-bit MSR index to write.
3397 @param AndData The value to AND with the read value from the MSR.
3399 @return The value written back to the MSR.
3410 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive
3411 OR, and writes the result back to the 64-bit MSR.
3413 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
3414 result and the value specified by AndData, performs a bitwise inclusive OR
3415 between the result of the AND operation and the value specified by OrData,
3416 and writes the result to the 64-bit MSR specified by Index. The value written
3417 to the MSR is returned. No parameter checking is performed on Index, AndData,
3418 or OrData, and some of these may cause CPU exceptions. The caller must either
3419 guarantee that Index, AndData, and OrData are valid, or the caller must
3420 establish proper exception handlers. This function is only available on IA-32
3423 @param Index The 32-bit MSR index to write.
3424 @param AndData The value to AND with the read value from the MSR.
3425 @param OrData The value to OR with the result of the AND operation.
3427 @return The value written back to the MSR.
3439 Reads a bit field of an MSR.
3441 Reads the bit field in the 64-bit MSR. The bit field is specified by the
3442 StartBit and the EndBit. The value of the bit field is returned. The caller
3443 must either guarantee that Index is valid, or the caller must set up
3444 exception handlers to catch the exceptions. This function is only available
3447 If StartBit is greater than 63, then ASSERT().
3448 If EndBit is greater than 63, then ASSERT().
3449 If EndBit is less than or equal to StartBit, then ASSERT().
3451 @param Index The 32-bit MSR index to read.
3452 @param StartBit The ordinal of the least significant bit in the bit field.
3454 @param EndBit The ordinal of the most significant bit in the bit field.
3457 @return The value read from the MSR.
3462 AsmMsrBitFieldRead64 (
3469 Writes a bit field to an MSR.
3471 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
3472 the StartBit and the EndBit. All other bits in the destination MSR are
3473 preserved. The MSR written is returned. Extra left bits in Value are
3474 stripped. The caller must either guarantee that Index and the data written is
3475 valid, or the caller must set up exception handlers to catch the exceptions.
3476 This function is only available on IA-32 and X64.
3478 If StartBit is greater than 63, then ASSERT().
3479 If EndBit is greater than 63, then ASSERT().
3480 If EndBit is less than or equal to StartBit, then ASSERT().
3482 @param Index The 32-bit MSR index to write.
3483 @param StartBit The ordinal of the least significant bit in the bit field.
3485 @param EndBit The ordinal of the most significant bit in the bit field.
3487 @param Value New value of the bit field.
3489 @return The value written back to the MSR.
3494 AsmMsrBitFieldWrite64 (
3502 Reads a bit field in a 64-bit MSR, performs a bitwise inclusive OR, and
3503 writes the result back to the bit field in the 64-bit MSR.
3505 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
3506 between the read result and the value specified by OrData, and writes the
3507 result to the 64-bit MSR specified by Index. The value written to the MSR is
3508 returned. Extra left bits in OrData are stripped. The caller must either
3509 guarantee that Index and the data written is valid, or the caller must set up
3510 exception handlers to catch the exceptions. This function is only available
3513 If StartBit is greater than 63, then ASSERT().
3514 If EndBit is greater than 63, then ASSERT().
3515 If EndBit is less than or equal to StartBit, then ASSERT().
3517 @param Index The 32-bit MSR index to write.
3518 @param StartBit The ordinal of the least significant bit in the bit field.
3520 @param EndBit The ordinal of the most significant bit in the bit field.
3522 @param OrData The value to OR with the read value from the bit field.
3524 @return The value written back to the MSR.
3529 AsmMsrBitFieldOr64 (
3537 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
3538 result back to the bit field in the 64-bit MSR.
3540 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
3541 read result and the value specified by AndData, and writes the result to the
3542 64-bit MSR specified by Index. The value written to the MSR is returned.
3543 Extra left bits in AndData are stripped. The caller must either guarantee
3544 that Index and the data written is valid, or the caller must set up exception
3545 handlers to catch the exceptions. This function is only available on IA-32
3548 If StartBit is greater than 63, then ASSERT().
3549 If EndBit is greater than 63, then ASSERT().
3550 If EndBit is less than or equal to StartBit, then ASSERT().
3552 @param Index The 32-bit MSR index to write.
3553 @param StartBit The ordinal of the least significant bit in the bit field.
3555 @param EndBit The ordinal of the most significant bit in the bit field.
3557 @param AndData The value to AND with the read value from the bit field.
3559 @return The value written back to the MSR.
3564 AsmMsrBitFieldAnd64 (
3572 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
3573 bitwise inclusive OR, and writes the result back to the bit field in the
3576 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
3577 a bitwise inclusive OR between the read result and the value specified by
3578 AndData, and writes the result to the 64-bit MSR specified by Index. The
3579 value written to the MSR is returned. Extra left bits in both AndData and
3580 OrData are stripped. The caller must either guarantee that Index and the data
3581 written is valid, or the caller must set up exception handlers to catch the
3582 exceptions. This function is only available on IA-32 and X64.
3584 If StartBit is greater than 63, then ASSERT().
3585 If EndBit is greater than 63, then ASSERT().
3586 If EndBit is less than or equal to StartBit, then ASSERT().
3588 @param Index The 32-bit MSR index to write.
3589 @param StartBit The ordinal of the least significant bit in the bit field.
3591 @param EndBit The ordinal of the most significant bit in the bit field.
3593 @param AndData The value to AND with the read value from the bit field.
3594 @param OrData The value to OR with the result of the AND operation.
3596 @return The value written back to the MSR.
3601 AsmMsrBitFieldAndThenOr64 (
3610 Reads the current value of the EFLAGS register.
3612 Reads and returns the current value of the EFLAGS register. This function is
3613 only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a
3614 64-bit value on X64.
3616 @return EFLAGS on IA-32 or RFLAGS on X64.
3626 Reads the current value of the Control Register 0 (CR0).
3628 Reads and returns the current value of CR0. This function is only available
3629 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3632 @return The value of the Control Register 0 (CR0).
3642 Reads the current value of the Control Register 2 (CR2).
3644 Reads and returns the current value of CR2. This function is only available
3645 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3648 @return The value of the Control Register 2 (CR2).
3658 Reads the current value of the Control Register 3 (CR3).
3660 Reads and returns the current value of CR3. This function is only available
3661 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3664 @return The value of the Control Register 3 (CR3).
3674 Reads the current value of the Control Register 4 (CR4).
3676 Reads and returns the current value of CR4. This function is only available
3677 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3680 @return The value of the Control Register 4 (CR4).
3690 Writes a value to Control Register 0 (CR0).
3692 Writes and returns a new value to CR0. This function is only available on
3693 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3695 @param Cr0 The value to write to CR0.
3697 @return The value written to CR0.
3707 Writes a value to Control Register 2 (CR2).
3709 Writes and returns a new value to CR2. This function is only available on
3710 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3712 @param Cr2 The value to write to CR2.
3714 @return The value written to CR2.
3724 Writes a value to Control Register 3 (CR3).
3726 Writes and returns a new value to CR3. This function is only available on
3727 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3729 @param Cr3 The value to write to CR3.
3731 @return The value written to CR3.
3741 Writes a value to Control Register 4 (CR4).
3743 Writes and returns a new value to CR4. This function is only available on
3744 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3746 @param Cr4 The value to write to CR4.
3748 @return The value written to CR4.
3758 Reads the current value of Debug Register 0 (DR0).
3760 Reads and returns the current value of DR0. This function is only available
3761 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3764 @return The value of Debug Register 0 (DR0).
3774 Reads the current value of Debug Register 1 (DR1).
3776 Reads and returns the current value of DR1. This function is only available
3777 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3780 @return The value of Debug Register 1 (DR1).
3790 Reads the current value of Debug Register 2 (DR2).
3792 Reads and returns the current value of DR2. This function is only available
3793 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3796 @return The value of Debug Register 2 (DR2).
3806 Reads the current value of Debug Register 3 (DR3).
3808 Reads and returns the current value of DR3. This function is only available
3809 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3812 @return The value of Debug Register 3 (DR3).
3822 Reads the current value of Debug Register 4 (DR4).
3824 Reads and returns the current value of DR4. This function is only available
3825 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3828 @return The value of Debug Register 4 (DR4).
3838 Reads the current value of Debug Register 5 (DR5).
3840 Reads and returns the current value of DR5. This function is only available
3841 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3844 @return The value of Debug Register 5 (DR5).
3854 Reads the current value of Debug Register 6 (DR6).
3856 Reads and returns the current value of DR6. This function is only available
3857 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3860 @return The value of Debug Register 6 (DR6).
3870 Reads the current value of Debug Register 7 (DR7).
3872 Reads and returns the current value of DR7. This function is only available
3873 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3876 @return The value of Debug Register 7 (DR7).
3886 Writes a value to Debug Register 0 (DR0).
3888 Writes and returns a new value to DR0. This function is only available on
3889 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3891 @param Dr0 The value to write to Dr0.
3893 @return The value written to Debug Register 0 (DR0).
3903 Writes a value to Debug Register 1 (DR1).
3905 Writes and returns a new value to DR1. This function is only available on
3906 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3908 @param Dr1 The value to write to Dr1.
3910 @return The value written to Debug Register 1 (DR1).
3920 Writes a value to Debug Register 2 (DR2).
3922 Writes and returns a new value to DR2. This function is only available on
3923 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3925 @param Dr2 The value to write to Dr2.
3927 @return The value written to Debug Register 2 (DR2).
3937 Writes a value to Debug Register 3 (DR3).
3939 Writes and returns a new value to DR3. This function is only available on
3940 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3942 @param Dr3 The value to write to Dr3.
3944 @return The value written to Debug Register 3 (DR3).
3954 Writes a value to Debug Register 4 (DR4).
3956 Writes and returns a new value to DR4. This function is only available on
3957 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3959 @param Dr4 The value to write to Dr4.
3961 @return The value written to Debug Register 4 (DR4).
3971 Writes a value to Debug Register 5 (DR5).
3973 Writes and returns a new value to DR5. This function is only available on
3974 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3976 @param Dr5 The value to write to Dr5.
3978 @return The value written to Debug Register 5 (DR5).
3988 Writes a value to Debug Register 6 (DR6).
3990 Writes and returns a new value to DR6. This function is only available on
3991 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3993 @param Dr6 The value to write to Dr6.
3995 @return The value written to Debug Register 6 (DR6).
4005 Writes a value to Debug Register 7 (DR7).
4007 Writes and returns a new value to DR7. This function is only available on
4008 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4010 @param Dr7 The value to write to Dr7.
4012 @return The value written to Debug Register 7 (DR7).
4022 Reads the current value of Code Segment Register (CS).
4024 Reads and returns the current value of CS. This function is only available on
4027 @return The current value of CS.
4037 Reads the current value of Data Segment Register (DS).
4039 Reads and returns the current value of DS. This function is only available on
4042 @return The current value of DS.
4052 Reads the current value of Extra Segment Register (ES).
4054 Reads and returns the current value of ES. This function is only available on
4057 @return The current value of ES.
4067 Reads the current value of FS Data Segment Register (FS).
4069 Reads and returns the current value of FS. This function is only available on
4072 @return The current value of FS.
4082 Reads the current value of GS Data Segment Register (GS).
4084 Reads and returns the current value of GS. This function is only available on
4087 @return The current value of GS.
4097 Reads the current value of Stack Segment Register (SS).
4099 Reads and returns the current value of SS. This function is only available on
4102 @return The current value of SS.
4112 Reads the current value of Task Register (TR).
4114 Reads and returns the current value of TR. This function is only available on
4117 @return The current value of TR.
4127 Reads the current Global Descriptor Table Register(GDTR) descriptor.
4129 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
4130 function is only available on IA-32 and X64.
4132 If Gdtr is NULL, then ASSERT().
4134 @param Gdtr Pointer to a GDTR descriptor.
4140 OUT IA32_DESCRIPTOR
*Gdtr
4144 Writes the current Global Descriptor Table Register (GDTR) descriptor.
4146 Writes and the current GDTR descriptor specified by Gdtr. This function is
4147 only available on IA-32 and X64.
4149 If Gdtr is NULL, then ASSERT().
4151 @param Gdtr Pointer to a GDTR descriptor.
4157 IN CONST IA32_DESCRIPTOR
*Gdtr
4161 Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.
4163 Reads and returns the current IDTR descriptor and returns it in Idtr. This
4164 function is only available on IA-32 and X64.
4166 If Idtr is NULL, then ASSERT().
4168 @param Idtr Pointer to a IDTR descriptor.
4174 OUT IA32_DESCRIPTOR
*Idtr
4178 Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.
4180 Writes the current IDTR descriptor and returns it in Idtr. This function is
4181 only available on IA-32 and X64.
4183 If Idtr is NULL, then ASSERT().
4185 @param Idtr Pointer to a IDTR descriptor.
4191 IN CONST IA32_DESCRIPTOR
*Idtr
4195 Reads the current Local Descriptor Table Register(LDTR) selector.
4197 Reads and returns the current 16-bit LDTR descriptor value. This function is
4198 only available on IA-32 and X64.
4200 @return The current selector of LDT.
4210 Writes the current Local Descriptor Table Register (GDTR) selector.
4212 Writes and the current LDTR descriptor specified by Ldtr. This function is
4213 only available on IA-32 and X64.
4215 @param Ldtr 16-bit LDTR selector value.
4225 Save the current floating point/SSE/SSE2 context to a buffer.
4227 Saves the current floating point/SSE/SSE2 state to the buffer specified by
4228 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
4229 available on IA-32 and X64.
4231 If Buffer is NULL, then ASSERT().
4232 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
4234 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
4240 OUT IA32_FX_BUFFER
*Buffer
4244 Restores the current floating point/SSE/SSE2 context from a buffer.
4246 Restores the current floating point/SSE/SSE2 state from the buffer specified
4247 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
4248 only available on IA-32 and X64.
4250 If Buffer is NULL, then ASSERT().
4251 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
4252 If Buffer was not saved with AsmFxSave(), then ASSERT().
4254 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
4260 IN CONST IA32_FX_BUFFER
*Buffer
4264 Reads the current value of 64-bit MMX Register #0 (MM0).
4266 Reads and returns the current value of MM0. This function is only available
4269 @return The current value of MM0.
4279 Reads the current value of 64-bit MMX Register #1 (MM1).
4281 Reads and returns the current value of MM1. This function is only available
4284 @return The current value of MM1.
4294 Reads the current value of 64-bit MMX Register #2 (MM2).
4296 Reads and returns the current value of MM2. This function is only available
4299 @return The current value of MM2.
4309 Reads the current value of 64-bit MMX Register #3 (MM3).
4311 Reads and returns the current value of MM3. This function is only available
4314 @return The current value of MM3.
4324 Reads the current value of 64-bit MMX Register #4 (MM4).
4326 Reads and returns the current value of MM4. This function is only available
4329 @return The current value of MM4.
4339 Reads the current value of 64-bit MMX Register #5 (MM5).
4341 Reads and returns the current value of MM5. This function is only available
4344 @return The current value of MM5.
4354 Reads the current value of 64-bit MMX Register #6 (MM6).
4356 Reads and returns the current value of MM6. This function is only available
4359 @return The current value of MM6.
4369 Reads the current value of 64-bit MMX Register #7 (MM7).
4371 Reads and returns the current value of MM7. This function is only available
4374 @return The current value of MM7.
4384 Writes the current value of 64-bit MMX Register #0 (MM0).
4386 Writes the current value of MM0. This function is only available on IA32 and
4389 @param Value The 64-bit value to write to MM0.
4399 Writes the current value of 64-bit MMX Register #1 (MM1).
4401 Writes the current value of MM1. This function is only available on IA32 and
4404 @param Value The 64-bit value to write to MM1.
4414 Writes the current value of 64-bit MMX Register #2 (MM2).
4416 Writes the current value of MM2. This function is only available on IA32 and
4419 @param Value The 64-bit value to write to MM2.
4429 Writes the current value of 64-bit MMX Register #3 (MM3).
4431 Writes the current value of MM3. This function is only available on IA32 and
4434 @param Value The 64-bit value to write to MM3.
4444 Writes the current value of 64-bit MMX Register #4 (MM4).
4446 Writes the current value of MM4. This function is only available on IA32 and
4449 @param Value The 64-bit value to write to MM4.
4459 Writes the current value of 64-bit MMX Register #5 (MM5).
4461 Writes the current value of MM5. This function is only available on IA32 and
4464 @param Value The 64-bit value to write to MM5.
4474 Writes the current value of 64-bit MMX Register #6 (MM6).
4476 Writes the current value of MM6. This function is only available on IA32 and
4479 @param Value The 64-bit value to write to MM6.
4489 Writes the current value of 64-bit MMX Register #7 (MM7).
4491 Writes the current value of MM7. This function is only available on IA32 and
4494 @param Value The 64-bit value to write to MM7.
4504 Reads the current value of Time Stamp Counter (TSC).
4506 Reads and returns the current value of TSC. This function is only available
4509 @return The current value of TSC
4519 Reads the current value of a Performance Counter (PMC).
4521 Reads and returns the current value of performance counter specified by
4522 Index. This function is only available on IA-32 and X64.
4524 @param Index The 32-bit Performance Counter index to read.
4526 @return The value of the PMC specified by Index.
4536 Sets up a monitor buffer that is used by AsmMwait().
4538 Executes a MONITOR instruction with the register state specified by Eax, Ecx
4539 and Edx. Returns Eax. This function is only available on IA-32 and X64.
4541 @param Eax The value to load into EAX or RAX before executing the MONITOR
4543 @param Ecx The value to load into ECX or RCX before executing the MONITOR
4545 @param Edx The value to load into EDX or RDX before executing the MONITOR
4560 Executes an MWAIT instruction.
4562 Executes an MWAIT instruction with the register state specified by Eax and
4563 Ecx. Returns Eax. This function is only available on IA-32 and X64.
4565 @param Eax The value to load into EAX or RAX before executing the MONITOR
4567 @param Ecx The value to load into ECX or RCX before executing the MONITOR
4581 Executes a WBINVD instruction.
4583 Executes a WBINVD instruction. This function is only available on IA-32 and
4594 Executes a INVD instruction.
4596 Executes a INVD instruction. This function is only available on IA-32 and
4607 Flushes a cache line from all the instruction and data caches within the
4608 coherency domain of the CPU.
4610 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
4611 This function is only available on IA-32 and X64.
4613 @param LinearAddress The address of the cache line to flush. If the CPU is
4614 in a physical addressing mode, then LinearAddress is a
4615 physical address. If the CPU is in a virtual
4616 addressing mode, then LinearAddress is a virtual
4619 @return LinearAddress
4624 IN VOID
*LinearAddress
4628 Enables the 32-bit paging mode on the CPU.
4630 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
4631 must be properly initialized prior to calling this service. This function
4632 assumes the current execution mode is 32-bit protected mode. This function is
4633 only available on IA-32. After the 32-bit paging mode is enabled, control is
4634 transferred to the function specified by EntryPoint using the new stack
4635 specified by NewStack and passing in the parameters specified by Context1 and
4636 Context2. Context1 and Context2 are optional and may be NULL. The function
4637 EntryPoint must never return.
4639 If the current execution mode is not 32-bit protected mode, then ASSERT().
4640 If EntryPoint is NULL, then ASSERT().
4641 If NewStack is NULL, then ASSERT().
4643 There are a number of constraints that must be followed before calling this
4645 1) Interrupts must be disabled.
4646 2) The caller must be in 32-bit protected mode with flat descriptors. This
4647 means all descriptors must have a base of 0 and a limit of 4GB.
4648 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
4650 4) CR3 must point to valid page tables that will be used once the transition
4651 is complete, and those page tables must guarantee that the pages for this
4652 function and the stack are identity mapped.
4654 @param EntryPoint A pointer to function to call with the new stack after
4656 @param Context1 A pointer to the context to pass into the EntryPoint
4657 function as the first parameter after paging is enabled.
4658 @param Context2 A pointer to the context to pass into the EntryPoint
4659 function as the second parameter after paging is enabled.
4660 @param NewStack A pointer to the new stack to use for the EntryPoint
4661 function after paging is enabled.
4667 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
4668 IN VOID
*Context1
, OPTIONAL
4669 IN VOID
*Context2
, OPTIONAL
4674 Disables the 32-bit paging mode on the CPU.
4676 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
4677 mode. This function assumes the current execution mode is 32-paged protected
4678 mode. This function is only available on IA-32. After the 32-bit paging mode
4679 is disabled, control is transferred to the function specified by EntryPoint
4680 using the new stack specified by NewStack and passing in the parameters
4681 specified by Context1 and Context2. Context1 and Context2 are optional and
4682 may be NULL. The function EntryPoint must never return.
4684 If the current execution mode is not 32-bit paged mode, then ASSERT().
4685 If EntryPoint is NULL, then ASSERT().
4686 If NewStack is NULL, then ASSERT().
4688 There are a number of constraints that must be followed before calling this
4690 1) Interrupts must be disabled.
4691 2) The caller must be in 32-bit paged mode.
4692 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
4693 4) CR3 must point to valid page tables that guarantee that the pages for
4694 this function and the stack are identity mapped.
4696 @param EntryPoint A pointer to function to call with the new stack after
4698 @param Context1 A pointer to the context to pass into the EntryPoint
4699 function as the first parameter after paging is disabled.
4700 @param Context2 A pointer to the context to pass into the EntryPoint
4701 function as the second parameter after paging is
4703 @param NewStack A pointer to the new stack to use for the EntryPoint
4704 function after paging is disabled.
4709 AsmDisablePaging32 (
4710 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
4711 IN VOID
*Context1
, OPTIONAL
4712 IN VOID
*Context2
, OPTIONAL
4717 Enables the 64-bit paging mode on the CPU.
4719 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
4720 must be properly initialized prior to calling this service. This function
4721 assumes the current execution mode is 32-bit protected mode with flat
4722 descriptors. This function is only available on IA-32. After the 64-bit
4723 paging mode is enabled, control is transferred to the function specified by
4724 EntryPoint using the new stack specified by NewStack and passing in the
4725 parameters specified by Context1 and Context2. Context1 and Context2 are
4726 optional and may be 0. The function EntryPoint must never return.
4728 If the current execution mode is not 32-bit protected mode with flat
4729 descriptors, then ASSERT().
4730 If EntryPoint is 0, then ASSERT().
4731 If NewStack is 0, then ASSERT().
4733 @param Cs The 16-bit selector to load in the CS before EntryPoint
4734 is called. The descriptor in the GDT that this selector
4735 references must be setup for long mode.
4736 @param EntryPoint The 64-bit virtual address of the function to call with
4737 the new stack after paging is enabled.
4738 @param Context1 The 64-bit virtual address of the context to pass into
4739 the EntryPoint function as the first parameter after
4741 @param Context2 The 64-bit virtual address of the context to pass into
4742 the EntryPoint function as the second parameter after
4744 @param NewStack The 64-bit virtual address of the new stack to use for
4745 the EntryPoint function after paging is enabled.
4751 IN UINT16 CodeSelector
,
4752 IN UINT64 EntryPoint
,
4753 IN UINT64 Context1
, OPTIONAL
4754 IN UINT64 Context2
, OPTIONAL
4759 Disables the 64-bit paging mode on the CPU.
4761 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
4762 mode. This function assumes the current execution mode is 64-paging mode.
4763 This function is only available on X64. After the 64-bit paging mode is
4764 disabled, control is transferred to the function specified by EntryPoint
4765 using the new stack specified by NewStack and passing in the parameters
4766 specified by Context1 and Context2. Context1 and Context2 are optional and
4767 may be 0. The function EntryPoint must never return.
4769 If the current execution mode is not 64-bit paged mode, then ASSERT().
4770 If EntryPoint is 0, then ASSERT().
4771 If NewStack is 0, then ASSERT().
4773 @param Cs The 16-bit selector to load in the CS before EntryPoint
4774 is called. The descriptor in the GDT that this selector
4775 references must be setup for 32-bit protected mode.
4776 @param EntryPoint The 64-bit virtual address of the function to call with
4777 the new stack after paging is disabled.
4778 @param Context1 The 64-bit virtual address of the context to pass into
4779 the EntryPoint function as the first parameter after
4781 @param Context2 The 64-bit virtual address of the context to pass into
4782 the EntryPoint function as the second parameter after
4784 @param NewStack The 64-bit virtual address of the new stack to use for
4785 the EntryPoint function after paging is disabled.
4790 AsmDisablePaging64 (
4791 IN UINT16 CodeSelector
,
4792 IN UINT32 EntryPoint
,
4793 IN UINT32 Context1
, OPTIONAL
4794 IN UINT32 Context2
, OPTIONAL
4799 // 16-bit thunking services
4803 Retrieves the properties for 16-bit thunk functions.
4805 Computes the size of the buffer and stack below 1MB required to use the
4806 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
4807 buffer size is returned in RealModeBufferSize, and the stack size is returned
4808 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
4809 then the actual minimum stack size is ExtraStackSize plus the maximum number
4810 of bytes that need to be passed to the 16-bit real mode code.
4812 If RealModeBufferSize is NULL, then ASSERT().
4813 If ExtraStackSize is NULL, then ASSERT().
4815 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
4816 required to use the 16-bit thunk functions.
4817 @param ExtraStackSize A pointer to the extra size of stack below 1MB
4818 that the 16-bit thunk functions require for
4819 temporary storage in the transition to and from
4825 AsmGetThunk16Properties (
4826 OUT UINT32
*RealModeBufferSize
,
4827 OUT UINT32
*ExtraStackSize
4831 Prepares all structures a code required to use AsmThunk16().
4833 Prepares all structures and code required to use AsmThunk16().
4835 If ThunkContext is NULL, then ASSERT().
4837 @param ThunkContext A pointer to the context structure that describes the
4838 16-bit real mode code to call.
4844 OUT THUNK_CONTEXT
*ThunkContext
4848 Transfers control to a 16-bit real mode entry point and returns the results.
4850 Transfers control to a 16-bit real mode entry point and returns the results.
4851 AsmPrepareThunk16() must be called with ThunkContext before this function is
4854 If ThunkContext is NULL, then ASSERT().
4855 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
4857 @param ThunkContext A pointer to the context structure that describes the
4858 16-bit real mode code to call.
4864 IN OUT THUNK_CONTEXT
*ThunkContext
4868 Prepares all structures and code for a 16-bit real mode thunk, transfers
4869 control to a 16-bit real mode entry point, and returns the results.
4871 Prepares all structures and code for a 16-bit real mode thunk, transfers
4872 control to a 16-bit real mode entry point, and returns the results. If the
4873 caller only need to perform a single 16-bit real mode thunk, then this
4874 service should be used. If the caller intends to make more than one 16-bit
4875 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
4876 once and AsmThunk16() can be called for each 16-bit real mode thunk.
4878 If ThunkContext is NULL, then ASSERT().
4880 @param ThunkContext A pointer to the context structure that describes the
4881 16-bit real mode code to call.
4886 AsmPrepareAndThunk16 (
4887 IN OUT THUNK_CONTEXT
*ThunkContext