]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Include/Library/BaseLib.h
Removed duplicate PalCallStatic functions in different libraries. Moved ReadItc and...
[mirror_edk2.git] / MdePkg / Include / Library / BaseLib.h
index 7fb2e64dfbbc427bc23e3e85b7565dc402a18b86..e414e27399b1336ddf9c7ce2e18fcd13576ef9ca 100644 (file)
@@ -1,16 +1,16 @@
 /** @file\r
-       Memory-only library functions with no library constructor/destructor\r
+  Memory-only library functions with no library constructor/destructor\r
 \r
-       Copyright (c) 2006, Intel Corporation\r
-       All rights reserved. This program and the accompanying materials\r
-       are licensed and made available under the terms and conditions of the BSD License\r
-       which accompanies this distribution.  The full text of the license may be found at\r
-       http://opensource.org/licenses/bsd-license.php\r
+  Copyright (c) 2006, Intel Corporation\r
+  All rights reserved. This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
 \r
-       THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-       WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-       Module Name:    BaseLib.h\r
+  Module Name:  BaseLib.h\r
 \r
 **/\r
 \r
@@ -45,65 +45,44 @@ typedef struct {
 // IPF context buffer used by SetJump() and LongJump()\r
 //\r
 typedef struct {\r
-  UINT64                            InitialUNAT;\r
-  UINT64                            AfterSpillUNAT;\r
-  UINT64                            PFS;\r
-  UINT64                            BSP;\r
-  UINT64                            RNAT;\r
-  UINT64                            Predicates;\r
-  UINT64                            LoopCount;\r
+  UINT64                            F2[2];\r
+  UINT64                            F3[2];\r
+  UINT64                            F4[2];\r
+  UINT64                            F5[2];\r
+  UINT64                            F16[2];\r
+  UINT64                            F17[2];\r
+  UINT64                            F18[2];\r
+  UINT64                            F19[2];\r
+  UINT64                            F20[2];\r
+  UINT64                            F21[2];\r
+  UINT64                            F22[2];\r
+  UINT64                            F23[2];\r
+  UINT64                            F24[2];\r
+  UINT64                            F25[2];\r
+  UINT64                            F26[2];\r
+  UINT64                            F27[2];\r
+  UINT64                            F28[2];\r
+  UINT64                            F29[2];\r
+  UINT64                            F30[2];\r
+  UINT64                            F31[2];\r
   UINT64                            R4;\r
   UINT64                            R5;\r
   UINT64                            R6;\r
   UINT64                            R7;\r
   UINT64                            SP;\r
-  UINT64                            F2Low;\r
-  UINT64                            F2High;\r
-  UINT64                            F3Low;\r
-  UINT64                            F3High;\r
-  UINT64                            F4Low;\r
-  UINT64                            F4High;\r
-  UINT64                            F5Low;\r
-  UINT64                            F5High;\r
-  UINT64                            F16Low;\r
-  UINT64                            F16High;\r
-  UINT64                            F17Low;\r
-  UINT64                            F17High;\r
-  UINT64                            F18Low;\r
-  UINT64                            F18High;\r
-  UINT64                            F19Low;\r
-  UINT64                            F19High;\r
-  UINT64                            F20Low;\r
-  UINT64                            F20High;\r
-  UINT64                            F21Low;\r
-  UINT64                            F21High;\r
-  UINT64                            F22Low;\r
-  UINT64                            F22High;\r
-  UINT64                            F23Low;\r
-  UINT64                            F23High;\r
-  UINT64                            F24Low;\r
-  UINT64                            F24High;\r
-  UINT64                            F25Low;\r
-  UINT64                            F25High;\r
-  UINT64                            F26Low;\r
-  UINT64                            F26High;\r
-  UINT64                            F27Low;\r
-  UINT64                            F27High;\r
-  UINT64                            F28Low;\r
-  UINT64                            F28High;\r
-  UINT64                            F29Low;\r
-  UINT64                            F29High;\r
-  UINT64                            F30Low;\r
-  UINT64                            F30High;\r
-  UINT64                            F31Low;\r
-  UINT64                            F31High;\r
-  UINT64                            FPSR;\r
   UINT64                            BR0;\r
   UINT64                            BR1;\r
   UINT64                            BR2;\r
   UINT64                            BR3;\r
   UINT64                            BR4;\r
   UINT64                            BR5;\r
+  UINT64                            InitialUNAT;\r
+  UINT64                            AfterSpillUNAT;\r
+  UINT64                            PFS;\r
+  UINT64                            BSP;\r
+  UINT64                            Predicates;\r
+  UINT64                            LoopCount;\r
+  UINT64                            FPSR;\r
 } BASE_LIBRARY_JUMP_BUFFER;\r
 \r
 #elif defined (MDE_CPU_X64)\r
@@ -155,7 +134,8 @@ typedef struct {
   If Source is NULL, then ASSERT().\r
   If Source and Destination overlap, then ASSERT().\r
   If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r
-  PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
+  PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
 \r
   @param  Destination Pointer to a Null-terminated Unicode string.\r
   @param  Source      Pointer to a Null-terminated Unicode string.\r
@@ -169,7 +149,6 @@ StrCpy (
   OUT     CHAR16                    *Destination,\r
   IN      CONST CHAR16              *Source\r
   );\r
-\r
 /**\r
   Copies one Null-terminated Unicode string with a maximum length to another\r
   Null-terminated Unicode string with a maximum length and returns the new\r
@@ -187,7 +166,8 @@ StrCpy (
   If Source is NULL, then ASSERT().\r
   If Source and Destination overlap, then ASSERT().\r
   If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r
-  PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
+  PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
 \r
   @param  Destination Pointer to a Null-terminated Unicode string.\r
   @param  Source      Pointer to a Null-terminated Unicode string.\r
@@ -203,7 +183,6 @@ StrnCpy (
   IN      CONST CHAR16              *Source,\r
   IN      UINTN                     Length\r
   );\r
-\r
 /**\r
   Returns the length of a Null-terminated Unicode string.\r
 \r
@@ -212,7 +191,8 @@ StrnCpy (
 \r
   If String is NULL, then ASSERT().\r
   If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r
-  PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
+  PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
 \r
   @param  String  Pointer to a Null-terminated Unicode string.\r
 \r
@@ -224,7 +204,6 @@ EFIAPI
 StrLen (\r
   IN      CONST CHAR16              *String\r
   );\r
-\r
 /**\r
   Returns the size of a Null-terminated Unicode string in bytes, including the\r
   Null terminator.\r
@@ -234,7 +213,8 @@ StrLen (
 \r
   If String is NULL, then ASSERT().\r
   If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r
-  PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
+  PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
 \r
   @param  String  Pointer to a Null-terminated Unicode string.\r
 \r
@@ -246,7 +226,6 @@ EFIAPI
 StrSize (\r
   IN      CONST CHAR16              *String\r
   );\r
-\r
 /**\r
   Compares two Null-terminated Unicode strings, and returns the difference\r
   between the first mismatched Unicode characters.\r
@@ -260,9 +239,11 @@ StrSize (
   If FirstString is NULL, then ASSERT().\r
   If SecondString is NULL, then ASSERT().\r
   If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more\r
-  than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
+  than PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
   If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more\r
-  than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
+  than PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
 \r
   @param  FirstString   Pointer to a Null-terminated Unicode string.\r
   @param  SecondString  Pointer to a Null-terminated Unicode string.\r
@@ -277,7 +258,6 @@ StrCmp (
   IN      CONST CHAR16              *FirstString,\r
   IN      CONST CHAR16              *SecondString\r
   );\r
-\r
 /**\r
   Compares two Null-terminated Unicode strings with maximum lengths, and\r
   returns the difference between the first mismatched Unicode characters.\r
@@ -292,9 +272,11 @@ StrCmp (
   If FirstString is NULL, then ASSERT().\r
   If SecondString is NULL, then ASSERT().\r
   If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more\r
-  than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
+  than PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
   If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more\r
-  than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
+  than PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
 \r
   @param  FirstString   Pointer to a Null-terminated Unicode string.\r
   @param  SecondString  Pointer to a Null-terminated Unicode string.\r
@@ -311,7 +293,6 @@ StrnCmp (
   IN      CONST CHAR16              *SecondString,\r
   IN      UINTN                     Length\r
   );\r
-\r
 /**\r
   Concatenates one Null-terminated Unicode string to another Null-terminated\r
   Unicode string, and returns the concatenated Unicode string.\r
@@ -326,12 +307,15 @@ StrnCmp (
   If Source is NULL, then ASSERT().\r
   If Source and Destination overlap, then ASSERT().\r
   If PcdMaximumUnicodeStringLength is not zero, and Destination contains more\r
-  than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
+  than PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
   If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r
-  PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
+  PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
   If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination\r
   and Source results in a Unicode string with more than\r
-  PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
+  PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
 \r
   @param  Destination Pointer to a Null-terminated Unicode string.\r
   @param  Source      Pointer to a Null-terminated Unicode string.\r
@@ -345,7 +329,6 @@ StrCat (
   IN OUT  CHAR16                    *Destination,\r
   IN      CONST CHAR16              *Source\r
   );\r
-\r
 /**\r
   Concatenates one Null-terminated Unicode string with a maximum length to the\r
   end of another Null-terminated Unicode string, and returns the concatenated\r
@@ -363,12 +346,15 @@ StrCat (
   If Source is NULL, then ASSERT().\r
   If Source and Destination overlap, then ASSERT().\r
   If PcdMaximumUnicodeStringLength is not zero, and Destination contains more\r
-  than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
+  than PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
   If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r
-  PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
+  PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
   If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination\r
   and Source results in a Unicode string with more than\r
-  PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
+  PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
 \r
   @param  Destination Pointer to a Null-terminated Unicode string.\r
   @param  Source      Pointer to a Null-terminated Unicode string.\r
@@ -385,7 +371,6 @@ StrnCat (
   IN      CONST CHAR16              *Source,\r
   IN      UINTN                     Length\r
   );\r
-\r
 /**\r
   Copies one Null-terminated ASCII string to another Null-terminated ASCII\r
   string and returns the new ASCII string.\r
@@ -398,7 +383,8 @@ StrnCat (
   If Source is NULL, then ASSERT().\r
   If Source and Destination overlap, then ASSERT().\r
   If PcdMaximumAsciiStringLength is not zero and Source contains more than\r
-  PcdMaximumAsciiStringLength ASCII characters, then ASSERT().\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
 \r
   @param  Destination Pointer to a Null-terminated ASCII string.\r
   @param  Source      Pointer to a Null-terminated ASCII string.\r
@@ -412,7 +398,6 @@ AsciiStrCpy (
   OUT     CHAR8                     *Destination,\r
   IN      CONST CHAR8               *Source\r
   );\r
-\r
 /**\r
   Copies one Null-terminated ASCII string with a maximum length to another\r
   Null-terminated ASCII string with a maximum length and returns the new ASCII\r
@@ -429,7 +414,8 @@ AsciiStrCpy (
   If Source is NULL, then ASSERT().\r
   If Source and Destination overlap, then ASSERT().\r
   If PcdMaximumAsciiStringLength is not zero, and Source contains more than\r
-  PcdMaximumAsciiStringLength ASCII characters, then ASSERT().\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
 \r
   @param  Destination Pointer to a Null-terminated ASCII string.\r
   @param  Source      Pointer to a Null-terminated ASCII string.\r
@@ -445,7 +431,6 @@ AsciiStrnCpy (
   IN      CONST CHAR8               *Source,\r
   IN      UINTN                     Length\r
   );\r
-\r
 /**\r
   Returns the length of a Null-terminated ASCII string.\r
 \r
@@ -454,7 +439,8 @@ AsciiStrnCpy (
 \r
   If String is NULL, then ASSERT().\r
   If PcdMaximumAsciiStringLength is not zero and String contains more than\r
-  PcdMaximumAsciiStringLength ASCII characters, then ASSERT().\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
 \r
   @param  String  Pointer to a Null-terminated ASCII string.\r
 \r
@@ -466,7 +452,6 @@ EFIAPI
 AsciiStrLen (\r
   IN      CONST CHAR8               *String\r
   );\r
-\r
 /**\r
   Returns the size of a Null-terminated ASCII string in bytes, including the\r
   Null terminator.\r
@@ -476,7 +461,8 @@ AsciiStrLen (
 \r
   If String is NULL, then ASSERT().\r
   If PcdMaximumAsciiStringLength is not zero and String contains more than\r
-  PcdMaximumAsciiStringLength ASCII characters, then ASSERT().\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
 \r
   @param  String  Pointer to a Null-terminated ASCII string.\r
 \r
@@ -488,7 +474,6 @@ EFIAPI
 AsciiStrSize (\r
   IN      CONST CHAR8               *String\r
   );\r
-\r
 /**\r
   Compares two Null-terminated ASCII strings, and returns the difference\r
   between the first mismatched ASCII characters.\r
@@ -502,9 +487,11 @@ AsciiStrSize (
   If FirstString is NULL, then ASSERT().\r
   If SecondString is NULL, then ASSERT().\r
   If PcdMaximumAsciiStringLength is not zero and FirstString contains more than\r
-  PcdMaximumAsciiStringLength ASCII characters, then ASSERT().\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
   If PcdMaximumAsciiStringLength is not zero and SecondString contains more\r
-  than PcdMaximumAsciiStringLength ASCII characters, then ASSERT().\r
+  than PcdMaximumAsciiStringLength ASCII characters not including the\r
+  Null-terminator, then ASSERT().\r
 \r
   @param  FirstString   Pointer to a Null-terminated ASCII string.\r
   @param  SecondString  Pointer to a Null-terminated ASCII string.\r
@@ -519,7 +506,6 @@ AsciiStrCmp (
   IN      CONST CHAR8               *FirstString,\r
   IN      CONST CHAR8               *SecondString\r
   );\r
-\r
 /**\r
   Performs a case insensitive comparison of two Null-terminated ASCII strings,\r
   and returns the difference between the first mismatched ASCII characters.\r
@@ -534,9 +520,11 @@ AsciiStrCmp (
   If FirstString is NULL, then ASSERT().\r
   If SecondString is NULL, then ASSERT().\r
   If PcdMaximumAsciiStringLength is not zero and FirstString contains more than\r
-  PcdMaximumAsciiStringLength ASCII characters, then ASSERT().\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
   If PcdMaximumAsciiStringLength is not zero and SecondString contains more\r
-  than PcdMaximumAsciiStringLength ASCII characters, then ASSERT().\r
+  than PcdMaximumAsciiStringLength ASCII characters not including the\r
+  Null-terminator, then ASSERT().\r
 \r
   @param  FirstString   Pointer to a Null-terminated ASCII string.\r
   @param  SecondString  Pointer to a Null-terminated ASCII string.\r
@@ -553,7 +541,6 @@ AsciiStriCmp (
   IN      CONST CHAR8               *FirstString,\r
   IN      CONST CHAR8               *SecondString\r
   );\r
-\r
 /**\r
   Compares two Null-terminated ASCII strings with maximum lengths, and returns\r
   the difference between the first mismatched ASCII characters.\r
@@ -568,9 +555,11 @@ AsciiStriCmp (
   If FirstString is NULL, then ASSERT().\r
   If SecondString is NULL, then ASSERT().\r
   If PcdMaximumAsciiStringLength is not zero and FirstString contains more than\r
-  PcdMaximumAsciiStringLength ASCII characters, then ASSERT().\r
-  If PcdMaximumAsciiStringLength is not zero and SecondString contains more\r
-  than PcdMaximumAsciiStringLength ASCII characters, then ASSERT().\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero and SecondString contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
 \r
   @param  FirstString   Pointer to a Null-terminated ASCII string.\r
   @param  SecondString  Pointer to a Null-terminated ASCII string.\r
@@ -586,7 +575,6 @@ AsciiStrnCmp (
   IN      CONST CHAR8               *SecondString,\r
   IN      UINTN                     Length\r
   );\r
-\r
 /**\r
   Concatenates one Null-terminated ASCII string to another Null-terminated\r
   ASCII string, and returns the concatenated ASCII string.\r
@@ -599,9 +587,11 @@ AsciiStrnCmp (
   If Destination is NULL, then ASSERT().\r
   If Source is NULL, then ASSERT().\r
   If PcdMaximumAsciiStringLength is not zero and Destination contains more than\r
-  PcdMaximumAsciiStringLength ASCII characters, then ASSERT().\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
   If PcdMaximumAsciiStringLength is not zero and Source contains more than\r
-  PcdMaximumAsciiStringLength ASCII characters, then ASSERT().\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
   If PcdMaximumAsciiStringLength is not zero and concatenating Destination and\r
   Source results in a ASCII string with more than PcdMaximumAsciiStringLength\r
   ASCII characters, then ASSERT().\r
@@ -615,10 +605,9 @@ AsciiStrnCmp (
 CHAR8 *\r
 EFIAPI\r
 AsciiStrCat (\r
-  IN OUT  CHAR8                     *Destination,\r
-  IN      CONST CHAR8               *Source\r
+  IN OUT CHAR8    *Destination,\r
+  IN CONST CHAR8  *Source\r
   );\r
-\r
 /**\r
   Concatenates one Null-terminated ASCII string with a maximum length to the\r
   end of another Null-terminated ASCII string, and returns the concatenated\r
@@ -635,13 +624,15 @@ AsciiStrCat (
   If Destination is NULL, then ASSERT().\r
   If Source is NULL, then ASSERT().\r
   If Source and Destination overlap, then ASSERT().\r
-  If PcdMaximumAsciiStringLength is not zero, and Destination contains more\r
-  than PcdMaximumAsciiStringLength ASCII characters, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and Destination contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
   If PcdMaximumAsciiStringLength is not zero, and Source contains more than\r
-  PcdMaximumAsciiStringLength ASCII characters, then ASSERT().\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
   If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and\r
   Source results in a ASCII string with more than PcdMaximumAsciiStringLength\r
-  ASCII characters, then ASSERT().\r
+  ASCII characters not including the Null-terminator, then ASSERT().\r
 \r
   @param  Destination Pointer to a Null-terminated ASCII string.\r
   @param  Source      Pointer to a Null-terminated ASCII string.\r
@@ -658,6 +649,44 @@ AsciiStrnCat (
   IN      CONST CHAR8               *Source,\r
   IN      UINTN                     Length\r
   );\r
+/**\r
+  Converts an 8-bit value to an 8-bit BCD value.\r
+\r
+  Converts the 8-bit value specified by Value to BCD. The BCD value is\r
+  returned.\r
+\r
+  If Value >= 100, then ASSERT().\r
+\r
+  @param  Value The 8-bit value to convert to BCD. Range 0..99.\r
+\r
+  @return The BCD value\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+DecimalToBcd8 (\r
+  IN      UINT8                     Value\r
+  );\r
+\r
+/**\r
+  Converts an 8-bit BCD value to an 8-bit value.\r
+\r
+  Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit\r
+  value is returned.\r
+\r
+  If Value >= 0xA0, then ASSERT().\r
+  If (Value & 0x0F) >= 0x0A, then ASSERT().\r
+\r
+  @param  Value The 8-bit BCD value to convert to an 8-bit value.\r
+\r
+  @return The 8-bit value is returned.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+BcdToDecimal8 (\r
+  IN      UINT8                     Value\r
+  );\r
 \r
 //\r
 // LIST_ENTRY definition\r
@@ -721,8 +750,9 @@ InitializeListHead (
   If ListHead is NULL, then ASSERT().\r
   If Entry is NULL, then ASSERT().\r
   If ListHead was not initialized with InitializeListHead(), then ASSERT().\r
-  If PcdMaximumLinkedListLenth is not zero, and ListHead contains more than\r
-  PcdMaximumLinkedListLenth nodes, then ASSERT().\r
+  If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number\r
+  of nodes in ListHead, including the ListHead node, is greater than or\r
+  equal to PcdMaximumLinkedListLength, then ASSERT().\r
 \r
   @param  ListHead  A pointer to the head node of a doubly linked list.\r
   @param  Entry     A pointer to a node that is to be inserted at the beginning\r
@@ -748,8 +778,9 @@ InsertHeadList (
   If ListHead is NULL, then ASSERT().\r
   If Entry is NULL, then ASSERT().\r
   If ListHead was not initialized with InitializeListHead(), then ASSERT().\r
-  If PcdMaximumLinkedListLenth is not zero, and ListHead contains more than\r
-  PcdMaximumLinkedListLenth nodes, then ASSERT().\r
+  If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number\r
+  of nodes in ListHead, including the ListHead node, is greater than or\r
+  equal to PcdMaximumLinkedListLength, then ASSERT().\r
 \r
   @param  ListHead  A pointer to the head node of a doubly linked list.\r
   @param  Entry     A pointer to a node that is to be added at the end of the\r
@@ -774,8 +805,9 @@ InsertTailList (
 \r
   If List is NULL, then ASSERT().\r
   If List was not initialized with InitializeListHead(), then ASSERT().\r
-  If PcdMaximumLinkedListLenth is not zero, and List contains more than\r
-  PcdMaximumLinkedListLenth nodes, then ASSERT().\r
+  If PcdMaximumLinkedListLenth is not zero, and the number of nodes\r
+  in List, including the List node, is greater than or equal to\r
+  PcdMaximumLinkedListLength, then ASSERT().\r
 \r
   @param  List  A pointer to the head node of a doubly linked list.\r
 \r
@@ -825,8 +857,9 @@ GetNextNode (
 \r
   If ListHead is NULL, then ASSERT().\r
   If ListHead was not initialized with InitializeListHead(), then ASSERT().\r
-  If PcdMaximumLinkedListLenth is not zero, and List contains more than\r
-  PcdMaximumLinkedListLenth nodes, then ASSERT().\r
+  If PcdMaximumLinkedListLenth is not zero, and the number of nodes\r
+  in List, including the List node, is greater than or equal to\r
+  PcdMaximumLinkedListLength, then ASSERT().\r
 \r
   @param  ListHead  A pointer to the head node of a doubly linked list.\r
 \r
@@ -850,12 +883,13 @@ IsListEmpty (
   If List is NULL, then ASSERT().\r
   If Node is NULL, then ASSERT().\r
   If List was not initialized with InitializeListHead(), then ASSERT().\r
-  If PcdMaximumLinkedListLenth is not zero, and List contains more than\r
-  PcdMaximumLinkedListLenth nodes, then ASSERT().\r
+  If PcdMaximumLinkedListLenth is not zero, and the number of nodes\r
+  in List, including the List node, is greater than or equal to\r
+  PcdMaximumLinkedListLength, then ASSERT().\r
   If Node is not a node in List and Node is not equal to List, then ASSERT().\r
 \r
   @param  List  A pointer to the head node of a doubly linked list.\r
-  @param  Node A pointer to a node in the doubly linked list.\r
+  @param  Node  A pointer to a node in the doubly linked list.\r
 \r
   @retval TRUE  Node is one of the nodes in the doubly linked list.\r
   @retval FALSE Node is not one of the nodes in the doubly linked list.\r
@@ -878,12 +912,13 @@ IsNull (
   If List is NULL, then ASSERT().\r
   If Node is NULL, then ASSERT().\r
   If List was not initialized with InitializeListHead(), then ASSERT().\r
-  If PcdMaximumLinkedListLenth is not zero, and List contains more than\r
-  PcdMaximumLinkedListLenth nodes, then ASSERT().\r
+  If PcdMaximumLinkedListLenth is not zero, and the number of nodes\r
+  in List, including the List node, is greater than or equal to\r
+  PcdMaximumLinkedListLength, then ASSERT().\r
   If Node is not a node in List, then ASSERT().\r
 \r
   @param  List  A pointer to the head node of a doubly linked list.\r
-  @param  Node A pointer to a node in the doubly linked list.\r
+  @param  Node  A pointer to a node in the doubly linked list.\r
 \r
   @retval TRUE  Node is the last node in the linked list.\r
   @retval FALSE Node is not the last node in the linked list.\r
@@ -910,9 +945,10 @@ IsNodeAtEnd (
   If FirstEntry is NULL, then ASSERT().\r
   If SecondEntry is NULL, then ASSERT().\r
   If SecondEntry and FirstEntry are not in the same linked list, then ASSERT().\r
-  If PcdMaximumLinkedListLenth is not zero, and the linked list containing\r
-  FirstEntry and SecondEntry contains more than PcdMaximumLinkedListLenth\r
-  nodes, then ASSERT().\r
+  If PcdMaximumLinkedListLength is not zero, and the number of nodes in the\r
+  linked list containing the FirstEntry and SecondEntry nodes, including\r
+  the FirstEntry and SecondEntry nodes, is greater than or equal to\r
+  PcdMaximumLinkedListLength, then ASSERT().\r
 \r
   @param  FirstEntry  A pointer to a node in a linked list.\r
   @param  SecondEntry A pointer to another node in the same linked list.\r
@@ -937,8 +973,9 @@ SwapListEntries (
 \r
   If Entry is NULL, then ASSERT().\r
   If Entry is the head node of an empty list, then ASSERT().\r
-  If PcdMaximumLinkedListLenth is not zero, and the linked list containing\r
-  Entry contains more than PcdMaximumLinkedListLenth nodes, then ASSERT().\r
+  If PcdMaximumLinkedListLength is not zero, and the number of nodes in the\r
+  linked list containing Entry, including the Entry node, is greater than\r
+  or equal to PcdMaximumLinkedListLength, then ASSERT().\r
 \r
   @param  Entry A pointer to a node in a linked list\r
 \r
@@ -1655,7 +1692,7 @@ WriteUnaligned64 (
   If 8-bit operations are not supported, then ASSERT().\r
   If StartBit is greater than 7, then ASSERT().\r
   If EndBit is greater than 7, then ASSERT().\r
-  If EndBit is less than or equal to StartBit, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
 \r
   @param  Operand   Operand on which to perform the bitfield operation.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -1684,7 +1721,7 @@ BitFieldRead8 (
   If 8-bit operations are not supported, then ASSERT().\r
   If StartBit is greater than 7, then ASSERT().\r
   If EndBit is greater than 7, then ASSERT().\r
-  If EndBit is less than or equal to StartBit, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
 \r
   @param  Operand   Operand on which to perform the bitfield operation.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -1716,7 +1753,7 @@ BitFieldWrite8 (
   If 8-bit operations are not supported, then ASSERT().\r
   If StartBit is greater than 7, then ASSERT().\r
   If EndBit is greater than 7, then ASSERT().\r
-  If EndBit is less than or equal to StartBit, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
 \r
   @param  Operand   Operand on which to perform the bitfield operation.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -1748,7 +1785,7 @@ BitFieldOr8 (
   If 8-bit operations are not supported, then ASSERT().\r
   If StartBit is greater than 7, then ASSERT().\r
   If EndBit is greater than 7, then ASSERT().\r
-  If EndBit is less than or equal to StartBit, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
 \r
   @param  Operand   Operand on which to perform the bitfield operation.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -1781,7 +1818,7 @@ BitFieldAnd8 (
   If 8-bit operations are not supported, then ASSERT().\r
   If StartBit is greater than 7, then ASSERT().\r
   If EndBit is greater than 7, then ASSERT().\r
-  If EndBit is less than or equal to StartBit, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
 \r
   @param  Operand   Operand on which to perform the bitfield operation.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -1812,7 +1849,7 @@ BitFieldAndThenOr8 (
   If 16-bit operations are not supported, then ASSERT().\r
   If StartBit is greater than 15, then ASSERT().\r
   If EndBit is greater than 15, then ASSERT().\r
-  If EndBit is less than or equal to StartBit, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
 \r
   @param  Operand   Operand on which to perform the bitfield operation.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -1841,7 +1878,7 @@ BitFieldRead16 (
   If 16-bit operations are not supported, then ASSERT().\r
   If StartBit is greater than 15, then ASSERT().\r
   If EndBit is greater than 15, then ASSERT().\r
-  If EndBit is less than or equal to StartBit, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
 \r
   @param  Operand   Operand on which to perform the bitfield operation.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -1873,7 +1910,7 @@ BitFieldWrite16 (
   If 16-bit operations are not supported, then ASSERT().\r
   If StartBit is greater than 15, then ASSERT().\r
   If EndBit is greater than 15, then ASSERT().\r
-  If EndBit is less than or equal to StartBit, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
 \r
   @param  Operand   Operand on which to perform the bitfield operation.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -1905,7 +1942,7 @@ BitFieldOr16 (
   If 16-bit operations are not supported, then ASSERT().\r
   If StartBit is greater than 15, then ASSERT().\r
   If EndBit is greater than 15, then ASSERT().\r
-  If EndBit is less than or equal to StartBit, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
 \r
   @param  Operand   Operand on which to perform the bitfield operation.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -1938,7 +1975,7 @@ BitFieldAnd16 (
   If 16-bit operations are not supported, then ASSERT().\r
   If StartBit is greater than 15, then ASSERT().\r
   If EndBit is greater than 15, then ASSERT().\r
-  If EndBit is less than or equal to StartBit, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
 \r
   @param  Operand   Operand on which to perform the bitfield operation.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -1969,7 +2006,7 @@ BitFieldAndThenOr16 (
   If 32-bit operations are not supported, then ASSERT().\r
   If StartBit is greater than 31, then ASSERT().\r
   If EndBit is greater than 31, then ASSERT().\r
-  If EndBit is less than or equal to StartBit, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
 \r
   @param  Operand   Operand on which to perform the bitfield operation.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -1998,7 +2035,7 @@ BitFieldRead32 (
   If 32-bit operations are not supported, then ASSERT().\r
   If StartBit is greater than 31, then ASSERT().\r
   If EndBit is greater than 31, then ASSERT().\r
-  If EndBit is less than or equal to StartBit, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
 \r
   @param  Operand   Operand on which to perform the bitfield operation.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -2030,7 +2067,7 @@ BitFieldWrite32 (
   If 32-bit operations are not supported, then ASSERT().\r
   If StartBit is greater than 31, then ASSERT().\r
   If EndBit is greater than 31, then ASSERT().\r
-  If EndBit is less than or equal to StartBit, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
 \r
   @param  Operand   Operand on which to perform the bitfield operation.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -2062,7 +2099,7 @@ BitFieldOr32 (
   If 32-bit operations are not supported, then ASSERT().\r
   If StartBit is greater than 31, then ASSERT().\r
   If EndBit is greater than 31, then ASSERT().\r
-  If EndBit is less than or equal to StartBit, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
 \r
   @param  Operand   Operand on which to perform the bitfield operation.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -2095,7 +2132,7 @@ BitFieldAnd32 (
   If 32-bit operations are not supported, then ASSERT().\r
   If StartBit is greater than 31, then ASSERT().\r
   If EndBit is greater than 31, then ASSERT().\r
-  If EndBit is less than or equal to StartBit, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
 \r
   @param  Operand   Operand on which to perform the bitfield operation.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -2126,7 +2163,7 @@ BitFieldAndThenOr32 (
   If 64-bit operations are not supported, then ASSERT().\r
   If StartBit is greater than 63, then ASSERT().\r
   If EndBit is greater than 63, then ASSERT().\r
-  If EndBit is less than or equal to StartBit, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
 \r
   @param  Operand   Operand on which to perform the bitfield operation.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -2155,7 +2192,7 @@ BitFieldRead64 (
   If 64-bit operations are not supported, then ASSERT().\r
   If StartBit is greater than 63, then ASSERT().\r
   If EndBit is greater than 63, then ASSERT().\r
-  If EndBit is less than or equal to StartBit, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
 \r
   @param  Operand   Operand on which to perform the bitfield operation.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -2187,7 +2224,7 @@ BitFieldWrite64 (
   If 64-bit operations are not supported, then ASSERT().\r
   If StartBit is greater than 63, then ASSERT().\r
   If EndBit is greater than 63, then ASSERT().\r
-  If EndBit is less than or equal to StartBit, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
 \r
   @param  Operand   Operand on which to perform the bitfield operation.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -2219,7 +2256,7 @@ BitFieldOr64 (
   If 64-bit operations are not supported, then ASSERT().\r
   If StartBit is greater than 63, then ASSERT().\r
   If EndBit is greater than 63, then ASSERT().\r
-  If EndBit is less than or equal to StartBit, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
 \r
   @param  Operand   Operand on which to perform the bitfield operation.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -2252,7 +2289,7 @@ BitFieldAnd64 (
   If 64-bit operations are not supported, then ASSERT().\r
   If StartBit is greater than 63, then ASSERT().\r
   If EndBit is greater than 63, then ASSERT().\r
-  If EndBit is less than or equal to StartBit, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
 \r
   @param  Operand   Operand on which to perform the bitfield operation.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -2437,6 +2474,14 @@ InterlockedDecrement (
 /**\r
   Performs an atomic compare exchange operation on a 32-bit unsigned integer.\r
 \r
+  Performs an atomic compare exchange operation on the 32-bit unsigned integer\r
+  specified by Value.  If Value is equal to CompareValue, then Value is set to\r
+  ExchangeValue and CompareValue is returned.  If Value is not equal to CompareValue,\r
+  then Value is returned.  The compare exchange operation must be performed using\r
+  MP safe mechanisms.\r
+\r
+  If Value is NULL, then ASSERT().\r
+\r
   @param  Value         A pointer to the 32-bit value for the compare exchange\r
                         operation.\r
   @param  CompareValue  32-bit value used in compare operation.\r
@@ -2448,7 +2493,7 @@ InterlockedDecrement (
 UINT32\r
 EFIAPI\r
 InterlockedCompareExchange32 (\r
-  IN      UINT32                    *Value,\r
+  IN OUT  UINT32                    *Value,\r
   IN      UINT32                    CompareValue,\r
   IN      UINT32                    ExchangeValue\r
   );\r
@@ -2456,6 +2501,13 @@ InterlockedCompareExchange32 (
 /**\r
   Performs an atomic compare exchange operation on a 64-bit unsigned integer.\r
 \r
+  Performs an atomic compare exchange operation on the 64-bit unsigned integer specified\r
+  by Value.  If Value is equal to CompareValue, then Value is set to ExchangeValue and\r
+  CompareValue is returned.  If Value is not equal to CompareValue, then Value is returned.\r
+  The compare exchange operation must be performed using MP safe mechanisms.\r
+\r
+  If Value is NULL, then ASSERT().\r
+\r
   @param  Value         A pointer to the 64-bit value for the compare exchange\r
                         operation.\r
   @param  CompareValue  64-bit value used in compare operation.\r
@@ -2467,7 +2519,7 @@ InterlockedCompareExchange32 (
 UINT64\r
 EFIAPI\r
 InterlockedCompareExchange64 (\r
-  IN      UINT64                    *Value,\r
+  IN OUT  UINT64                    *Value,\r
   IN      UINT64                    CompareValue,\r
   IN      UINT64                    ExchangeValue\r
   );\r
@@ -2492,7 +2544,7 @@ InterlockedCompareExchange64 (
 VOID *\r
 EFIAPI\r
 InterlockedCompareExchangePointer (\r
-  IN      VOID                      **Value,\r
+  IN OUT  VOID                      **Value,\r
   IN      VOID                      *CompareValue,\r
   IN      VOID                      *ExchangeValue\r
   );\r
@@ -2529,6 +2581,7 @@ MemoryFence (
   calls to LongJump() cause a non-zero value to be returned by SetJump().\r
 \r
   If JumpBuffer is NULL, then ASSERT().\r
+  For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().\r
 \r
   @param  JumpBuffer  A pointer to CPU context buffer.\r
 \r
@@ -2549,6 +2602,7 @@ SetJump (
   the state of JumpBuffer.\r
 \r
   If JumpBuffer is NULL, then ASSERT().\r
+  For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().\r
   If Value is 0, then ASSERT().\r
 \r
   @param  JumpBuffer  A pointer to CPU context buffer.\r
@@ -2866,11 +2920,14 @@ typedef union {
 \r
 //\r
 // Byte packed structure for an IDTR, GDTR, LDTR descriptor\r
+/// @bug  How to make this structure byte-packed in a compiler independent way?\r
 //\r
+#pragma pack (1)\r
 typedef struct {\r
   UINT16  Limit;\r
   UINTN   Base;\r
 } IA32_DESCRIPTOR;\r
+#pragma pack ()\r
 \r
 #define IA32_IDT_GATE_TYPE_TASK          0x85\r
 #define IA32_IDT_GATE_TYPE_INTERRUPT_16  0x86\r
@@ -3014,6 +3071,49 @@ AsmCpuid (
   OUT     UINT32                    *Edx   OPTIONAL\r
   );\r
 \r
+/**\r
+  Retrieves CPUID information using an extended leaf identifier.\r
+\r
+  Executes the CPUID instruction with EAX set to the value specified by Index\r
+  and ECX set to the value specified by SubIndex. This function always returns\r
+  Index. This function is only available on IA-32 and x64.\r
+\r
+  If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.\r
+  If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.\r
+  If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.\r
+  If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.\r
+\r
+  @param  Index     The 32-bit value to load into EAX prior to invoking the\r
+                    CPUID instruction.\r
+  @param  SubIndex  The 32-bit value to load into ECX prior to invoking the\r
+                    CPUID instruction.\r
+  @param  Eax       Pointer to the 32-bit EAX value returned by the CPUID\r
+                    instruction. This is an optional parameter that may be\r
+                    NULL.\r
+  @param  Ebx       Pointer to the 32-bit EBX value returned by the CPUID\r
+                    instruction. This is an optional parameter that may be\r
+                    NULL.\r
+  @param  Ecx       Pointer to the 32-bit ECX value returned by the CPUID\r
+                    instruction. This is an optional parameter that may be\r
+                    NULL.\r
+  @param  Edx       Pointer to the 32-bit EDX value returned by the CPUID\r
+                    instruction. This is an optional parameter that may be\r
+                    NULL.\r
+\r
+  @return Index\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+AsmCpuidEx (\r
+  IN      UINT32                    Index,\r
+  IN      UINT32                    SubIndex,\r
+  OUT     UINT32                    *Eax,  OPTIONAL\r
+  OUT     UINT32                    *Ebx,  OPTIONAL\r
+  OUT     UINT32                    *Ecx,  OPTIONAL\r
+  OUT     UINT32                    *Edx   OPTIONAL\r
+  );\r
+\r
 /**\r
   Returns the lower 32-bits of a Machine Specific Register(MSR).\r
 \r
@@ -3150,7 +3250,7 @@ AsmMsrAndThenOr32 (
 \r
   If StartBit is greater than 31, then ASSERT().\r
   If EndBit is greater than 31, then ASSERT().\r
-  If EndBit is less than or equal to StartBit, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
 \r
   @param  Index     The 32-bit MSR index to read.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -3182,7 +3282,7 @@ AsmMsrBitFieldRead32 (
 \r
   If StartBit is greater than 31, then ASSERT().\r
   If EndBit is greater than 31, then ASSERT().\r
-  If EndBit is less than or equal to StartBit, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
 \r
   @param  Index     The 32-bit MSR index to write.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -3217,7 +3317,7 @@ AsmMsrBitFieldWrite32 (
 \r
   If StartBit is greater than 31, then ASSERT().\r
   If EndBit is greater than 31, then ASSERT().\r
-  If EndBit is less than or equal to StartBit, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
 \r
   @param  Index     The 32-bit MSR index to write.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -3252,7 +3352,7 @@ AsmMsrBitFieldOr32 (
 \r
   If StartBit is greater than 31, then ASSERT().\r
   If EndBit is greater than 31, then ASSERT().\r
-  If EndBit is less than or equal to StartBit, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
 \r
   @param  Index     The 32-bit MSR index to write.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -3289,7 +3389,7 @@ AsmMsrBitFieldAnd32 (
 \r
   If StartBit is greater than 31, then ASSERT().\r
   If EndBit is greater than 31, then ASSERT().\r
-  If EndBit is less than or equal to StartBit, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
 \r
   @param  Index     The 32-bit MSR index to write.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -3446,7 +3546,7 @@ AsmMsrAndThenOr64 (
 \r
   If StartBit is greater than 63, then ASSERT().\r
   If EndBit is greater than 63, then ASSERT().\r
-  If EndBit is less than or equal to StartBit, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
 \r
   @param  Index     The 32-bit MSR index to read.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -3477,7 +3577,7 @@ AsmMsrBitFieldRead64 (
 \r
   If StartBit is greater than 63, then ASSERT().\r
   If EndBit is greater than 63, then ASSERT().\r
-  If EndBit is less than or equal to StartBit, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
 \r
   @param  Index     The 32-bit MSR index to write.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -3512,7 +3612,7 @@ AsmMsrBitFieldWrite64 (
 \r
   If StartBit is greater than 63, then ASSERT().\r
   If EndBit is greater than 63, then ASSERT().\r
-  If EndBit is less than or equal to StartBit, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
 \r
   @param  Index     The 32-bit MSR index to write.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -3547,7 +3647,7 @@ AsmMsrBitFieldOr64 (
 \r
   If StartBit is greater than 63, then ASSERT().\r
   If EndBit is greater than 63, then ASSERT().\r
-  If EndBit is less than or equal to StartBit, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
 \r
   @param  Index     The 32-bit MSR index to write.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -3583,7 +3683,7 @@ AsmMsrBitFieldAnd64 (
 \r
   If StartBit is greater than 63, then ASSERT().\r
   If EndBit is greater than 63, then ASSERT().\r
-  If EndBit is less than or equal to StartBit, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
 \r
   @param  Index     The 32-bit MSR index to write.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -4887,4 +4987,120 @@ AsmPrepareAndThunk16 (
   IN OUT  THUNK_CONTEXT             *ThunkContext\r
   );\r
 \r
+/**\r
+  Transfers control to a function starting with a new stack.\r
+\r
+  Transfers control to the function specified by EntryPoint using the new stack\r
+  specified by NewStack and passing in the parameters specified by Context1 and\r
+  Context2. Context1 and Context2 are optional and may be NULL. The function\r
+  EntryPoint must never return.\r
+\r
+  If EntryPoint is NULL, then ASSERT().\r
+  If NewStack is NULL, then ASSERT().\r
+\r
+  @param  EntryPoint  A pointer to function to call with the new stack.\r
+  @param  Context1    A pointer to the context to pass into the EntryPoint\r
+                      function.\r
+  @param  Context2    A pointer to the context to pass into the EntryPoint\r
+                      function.\r
+  @param  NewStack    A pointer to the new stack to use for the EntryPoint\r
+                      function.\r
+  @param  NewBsp      A pointer to the new memory location for RSE backing\r
+                      store.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmSwitchStackAndBackingStore (\r
+  IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,\r
+  IN      VOID                      *Context1,  OPTIONAL\r
+  IN      VOID                      *Context2,  OPTIONAL\r
+  IN      VOID                      *NewStack,\r
+  IN      VOID                      *NewBsp\r
+  );\r
+\r
+typedef struct {\r
+  UINT64                            Status;\r
+  UINT64                            r9;\r
+  UINT64                            r10;\r
+  UINT64                            r11;\r
+} PAL_PROC_RETURN;\r
+\r
+//\r
+// IPF Specific functions\r
+//\r
+\r
+\r
+/**\r
+  Performs a PAL call using static calling convention.\r
+\r
+  An internal function to perform a PAL call using static calling convention.\r
+\r
+  @param  PalEntryPoint The entry point address of PAL. The address in ar.kr5\r
+                        would be used if this parameter were NULL on input.\r
+  @param  Arg1          The first argument of a PAL call.\r
+  @param  Arg1          The second argument of a PAL call.\r
+  @param  Arg1          The third argument of a PAL call.\r
+  @param  Arg1          The fourth argument of a PAL call.\r
+\r
+  @return The values returned in r8, r9, r10 and r11.\r
+\r
+**/\r
+PAL_PROC_RETURN\r
+PalCallStatic (\r
+  IN      CONST VOID                *PalEntryPoint,\r
+  IN      UINT64                    Arg1,\r
+  IN      UINT64                    Arg2,\r
+  IN      UINT64                    Arg3,\r
+  IN      UINT64                    Arg4\r
+  );\r
+\r
+\r
+/**\r
+  Returns the current value of ar.itc.\r
+\r
+  An internal function to return the current value of ar.itc, which is the\r
+  timer tick on IPF.\r
+\r
+  @return The currect value of ar.itc\r
+\r
+**/\r
+INT64\r
+IpfReadItc (\r
+  VOID\r
+  );\r
+\r
+\r
+/**\r
+  Invalidates a range of instruction cache lines in the cache coherency domain\r
+  of the calling CPU.\r
+\r
+  Invalidates the instruction cache lines specified by Address and Length. If\r
+  Address is not aligned on a cache line boundary, then entire instruction\r
+  cache line containing Address is invalidated. If Address + Length is not\r
+  aligned on a cache line boundary, then the entire instruction cache line\r
+  containing Address + Length -1 is invalidated. This function may choose to\r
+  invalidate the entire instruction cache if that is more efficient than\r
+  invalidating the specified range. If Length is 0, the no instruction cache\r
+  lines are invalidated. Address is returned.\r
+\r
+  If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r
+\r
+  @param  Address The base address of the instruction cache lines to\r
+                  invalidate. If the CPU is in a physical addressing mode, then\r
+                  Address is a physical address. If the CPU is in a virtual\r
+                  addressing mode, then Address is a virtual address.\r
+\r
+  @param  Length  The number of bytes to invalidate from the instruction cache.\r
+\r
+  @return Address\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+IpfInvalidateInstructionCacheRange (\r
+  IN      VOID                      *Address,\r
+  IN      UINTN                     Length\r
+  );\r
+\r
 #endif\r