]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Include/Library/BaseLib.h
Synchronization of MDE Library Spec., Mde.dec, and corresponding head files in MdePkg...
[mirror_edk2.git] / MdePkg / Include / Library / BaseLib.h
index 6961c0a229a70f8cf70a27d52082d2bd9b7c608e..2249c2a79d4322b545b008759edb10a4874d9da8 100644 (file)
@@ -1,34 +1,33 @@
 /** @file\r
-  Memory-only library functions with no library constructor/destructor\r
+  Provides string functions, linked list functions, math functions, synchronization\r
+  functions, and CPU architecture specific functions.\r
 \r
-  Copyright (c) 2006 - 2007, 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 - 2008, 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
 **/\r
 \r
 #ifndef __BASE_LIB__\r
 #define __BASE_LIB__\r
 \r
-//\r
-// Definitions for architecture specific types\r
-// These include SPIN_LOCK and BASE_LIBRARY_JUMP_BUFFER\r
-//\r
-\r
-//\r
-// SPIN_LOCK\r
-//\r
+///\r
+/// Definitions for SPIN_LOCK\r
+///\r
 typedef volatile UINTN              SPIN_LOCK;\r
 \r
-#if   defined (MDE_CPU_IA32)\r
 //\r
-// IA32 context buffer used by SetJump() and LongJump()\r
+// Definitions for architecture specific types\r
 //\r
+#if   defined (MDE_CPU_IA32)\r
+///\r
+/// IA32 context buffer used by SetJump() and LongJump()\r
+///\r
 typedef struct {\r
   UINT32                            Ebx;\r
   UINT32                            Esi;\r
@@ -42,9 +41,9 @@ typedef struct {
 \r
 #elif defined (MDE_CPU_IPF)\r
 \r
-//\r
-// IPF context buffer used by SetJump() and LongJump()\r
-//\r
+///\r
+/// IPF context buffer used by SetJump() and LongJump()\r
+///\r
 typedef struct {\r
   UINT64                            F2[2];\r
   UINT64                            F3[2];\r
@@ -89,9 +88,9 @@ typedef struct {
 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 0x10\r
 \r
 #elif defined (MDE_CPU_X64)\r
-//\r
-// X64 context buffer used by SetJump() and LongJump()\r
-//\r
+///\r
+/// X64 context buffer used by SetJump() and LongJump()\r
+///\r
 typedef struct {\r
   UINT64                            Rbx;\r
   UINT64                            Rsp;\r
@@ -108,9 +107,9 @@ typedef struct {
 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8\r
 \r
 #elif defined (MDE_CPU_EBC)\r
-//\r
-// EBC context buffer used by SetJump() and LongJump()\r
-//\r
+///\r
+/// EBC context buffer used by SetJump() and LongJump()\r
+///\r
 typedef struct {\r
   UINT64                            R0;\r
   UINT64                            R1;\r
@@ -271,8 +270,8 @@ StrSize (
   @param  FirstString   Pointer to a Null-terminated Unicode string.\r
   @param  SecondString  Pointer to a Null-terminated Unicode string.\r
 \r
-  @retval 0   FirstString is identical to SecondString.\r
-  @retval !=0 FirstString is not identical to SecondString.\r
+  @retval 0      FirstString is identical to SecondString.\r
+  @return others FirstString is not identical to SecondString.\r
 \r
 **/\r
 INTN\r
@@ -309,8 +308,8 @@ StrCmp (
   @param  SecondString  Pointer to a Null-terminated Unicode string.\r
   @param  Length        Maximum number of Unicode characters to compare.\r
 \r
-  @retval 0   FirstString is identical to SecondString.\r
-  @retval !=0 FirstString is not identical to SecondString.\r
+  @retval 0      FirstString is identical to SecondString.\r
+  @return others FirstString is not identical to SecondString.\r
 \r
 **/\r
 INTN\r
@@ -430,7 +429,7 @@ StrnCat (
   @param  SearchString Pointer to a Null-terminated Unicode string to search for.\r
 \r
   @retval NULL            If the SearchString does not appear in String.\r
-  @retval !NULL           If there is a match.\r
+  @return others          If there is a match.\r
 \r
 **/\r
 CHAR16 *\r
@@ -471,7 +470,7 @@ StrStr (
 \r
   @param  String                           Pointer to a Null-terminated Unicode string.\r
 \r
-  @retval UINTN\r
+  @retval Value translated from String.\r
 \r
 **/\r
 UINTN\r
@@ -511,7 +510,7 @@ StrDecimalToUintn (
 \r
   @param  String                           Pointer to a Null-terminated Unicode string.\r
 \r
-  @retval UINT64\r
+  @retval Value translated from String.\r
 \r
 **/\r
 UINT64\r
@@ -553,7 +552,7 @@ StrDecimalToUint64 (
 \r
   @param  String                           Pointer to a Null-terminated Unicode string.\r
 \r
-  @retval UINTN\r
+  @retval Value translated from String.\r
 \r
 **/\r
 UINTN\r
@@ -595,7 +594,7 @@ StrHexToUintn (
 \r
   @param  String                           Pointer to a Null-terminated Unicode string.\r
 \r
-  @retval UINT64\r
+  @retval Value translated from String.\r
 \r
 **/\r
 UINT64\r
@@ -622,13 +621,12 @@ CHAR16
 EFIAPI\r
 NibbleToHexChar (\r
   IN UINT8      Nibble\r
-  )\r
-;\r
+  );\r
 \r
 /** \r
   Convert binary buffer to a Unicode String in a specified sequence. \r
 \r
-  This function converts bytes in the binary Buffer Buf to a Unicode String Str. \r
+  This function converts bytes in the memory block pointed by Buffer to a Unicode String Str. \r
   Each byte will be represented by two Unicode characters. For example, byte 0xA1 will \r
   be converted into two Unicode character L'A' and L'1'. In the output String, the Unicode Character \r
   for the Most Significant Nibble will be put before the Unicode Character for the Least Significant\r
@@ -660,8 +658,7 @@ BufToHexString (
   IN OUT       UINTN                *StringLen,\r
   IN     CONST UINT8                *Buffer,\r
   IN           UINTN                BufferSizeInBytes\r
-  )\r
-;\r
+  );\r
 \r
 \r
 /**\r
@@ -705,8 +702,7 @@ HexStringToBuf (
   IN OUT       UINTN                    *BufferSizeInBytes,\r
   IN     CONST CHAR16                   *String,\r
   OUT          UINTN                    *ConvertedStrLen  OPTIONAL\r
-  )\r
-;\r
+  );\r
 \r
 \r
 /**\r
@@ -719,6 +715,10 @@ HexStringToBuf (
 \r
   If Digit is NULL, then ASSERT.\r
 \r
+  @param  Digit       The output hexadecimal digit.\r
+\r
+  @param  Char        The input Unicode character.\r
+\r
   @retval TRUE        Char is in the range of Hexadecimal number. Digit is updated\r
                       to the byte value of the number.\r
   @retval FALSE       Char is not in the range of Hexadecimal number. Digit is keep\r
@@ -730,8 +730,7 @@ EFIAPI
 IsHexDigit (\r
   OUT UINT8      *Digit,\r
   IN  CHAR16      Char\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Convert one Null-terminated Unicode string to a Null-terminated\r
@@ -905,8 +904,8 @@ AsciiStrSize (
   @param  FirstString   Pointer to a Null-terminated ASCII string.\r
   @param  SecondString  Pointer to a Null-terminated ASCII string.\r
 \r
-  @retval 0   FirstString is identical to SecondString.\r
-  @retval !=0 FirstString is not identical to SecondString.\r
+  @retval 0      FirstString is identical to SecondString.\r
+  @return others FirstString is not identical to SecondString.\r
 \r
 **/\r
 INTN\r
@@ -940,10 +939,10 @@ AsciiStrCmp (
   @param  FirstString   Pointer to a Null-terminated ASCII string.\r
   @param  SecondString  Pointer to a Null-terminated ASCII string.\r
 \r
-  @retval 0   FirstString is identical to SecondString using case insensitive\r
-              comparisons.\r
-  @retval !=0 FirstString is not identical to SecondString using case\r
-              insensitive comparisons.\r
+  @retval 0      FirstString is identical to SecondString using case insensitive\r
+                 comparisons.\r
+  @return others FirstString is not identical to SecondString using case\r
+                 insensitive comparisons.\r
 \r
 **/\r
 INTN\r
@@ -978,8 +977,8 @@ AsciiStriCmp (
   @param  SecondString  Pointer to a Null-terminated ASCII string.\r
   @param  Length        Maximum number of ASCII characters for compare.\r
   \r
-  @retval 0   FirstString is identical to SecondString.\r
-  @retval !=0 FirstString is not identical to SecondString.\r
+  @retval 0      FirstString is identical to SecondString.\r
+  @return others FirstString is not identical to SecondString.\r
 \r
 **/\r
 INTN\r
@@ -1085,11 +1084,11 @@ AsciiStrnCat (
   String contains more than PcdMaximumAsciiStringLength Unicode characters\r
   not including the Null-terminator, then ASSERT().\r
 \r
-  @param  String                                 Pointer to a Null-terminated ASCII string.\r
-  @param  SearchString   Pointer to a Null-terminated ASCII string to search for.\r
+  @param  String          Pointer to a Null-terminated ASCII string.\r
+  @param  SearchString    Pointer to a Null-terminated ASCII string to search for.\r
 \r
   @retval NULL            If the SearchString does not appear in String.\r
-  @retval !NULL           If there is a match.\r
+  @return others          If there is a match.\r
 \r
 **/\r
 CHAR8 *\r
@@ -1127,7 +1126,7 @@ AsciiStrStr (
 \r
   @param  String                           Pointer to a Null-terminated ASCII string.\r
 \r
-  @retval UINTN\r
+  @retval Value translated from String.\r
 \r
 **/\r
 UINTN\r
@@ -1164,7 +1163,7 @@ AsciiStrDecimalToUintn (
 \r
   @param  String                           Pointer to a Null-terminated ASCII string.\r
 \r
-  @retval UINT64\r
+  @retval Value translated from String.\r
 \r
 **/\r
 UINT64\r
@@ -1205,7 +1204,7 @@ AsciiStrDecimalToUint64 (
 \r
   @param  String                           Pointer to a Null-terminated ASCII string.\r
 \r
-  @retval UINTN\r
+  @retval Value translated from String.\r
 \r
 **/\r
 UINTN\r
@@ -1246,7 +1245,7 @@ AsciiStrHexToUintn (
 \r
   @param  String                           Pointer to a Null-terminated ASCII string.\r
 \r
-  @retval UINT64\r
+  @retval Value translated from String.\r
 \r
 **/\r
 UINT64\r
@@ -1372,7 +1371,7 @@ BcdToDecimal8 (
 LIST_ENTRY *\r
 EFIAPI\r
 InitializeListHead (\r
-  IN      LIST_ENTRY                *ListHead\r
+  IN OUT  LIST_ENTRY                *ListHead\r
   );\r
 \r
 \r
@@ -1400,8 +1399,8 @@ InitializeListHead (
 LIST_ENTRY *\r
 EFIAPI\r
 InsertHeadList (\r
-  IN      LIST_ENTRY                *ListHead,\r
-  IN      LIST_ENTRY                *Entry\r
+  IN OUT  LIST_ENTRY                *ListHead,\r
+  IN OUT  LIST_ENTRY                *Entry\r
   );\r
 \r
 \r
@@ -1429,8 +1428,8 @@ InsertHeadList (
 LIST_ENTRY *\r
 EFIAPI\r
 InsertTailList (\r
-  IN      LIST_ENTRY                *ListHead,\r
-  IN      LIST_ENTRY                *Entry\r
+  IN OUT  LIST_ENTRY                *ListHead,\r
+  IN OUT  LIST_ENTRY                *Entry\r
   );\r
 \r
 \r
@@ -1515,11 +1514,13 @@ IsListEmpty (
 \r
 \r
 /**\r
-  Determines if a node in a doubly linked list is null.\r
+  Determines if a node in a doubly linked list is the head node of a the same\r
+  doubly linked list.  This function is typically used to terminate a loop that\r
+  traverses all the nodes in a doubly linked list starting with the head node.\r
 \r
-  Returns FALSE if Node is one of the nodes in the doubly linked list specified\r
-  by List. Otherwise, TRUE is returned. List must have been initialized with\r
-  InitializeListHead().\r
+  Returns TRUE if Node is equal to List.  Returns FALSE if Node is one of the\r
+  nodes in the doubly linked list specified by List.  List must have been\r
+  initialized with InitializeListHead().\r
 \r
   If List is NULL, then ASSERT().\r
   If Node is NULL, then ASSERT().\r
@@ -1595,13 +1596,15 @@ IsNodeAtEnd (
 \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
+  \r
+  @return SecondEntry\r
 \r
 **/\r
 LIST_ENTRY *\r
 EFIAPI\r
 SwapListEntries (\r
-  IN      LIST_ENTRY                *FirstEntry,\r
-  IN      LIST_ENTRY                *SecondEntry\r
+  IN OUT  LIST_ENTRY                *FirstEntry,\r
+  IN OUT  LIST_ENTRY                *SecondEntry\r
   );\r
 \r
 \r
@@ -2192,15 +2195,15 @@ DivS64x64Remainder (
 \r
   If the Buffer is NULL, then ASSERT().\r
 \r
-  @param  Uint16  Pointer to a 16-bit value that may be unaligned.\r
+  @param  Buffer  Pointer to a 16-bit value that may be unaligned.\r
 \r
-  @return *Uint16\r
+  @return The 16-bit value read from Buffer.\r
 \r
 **/\r
 UINT16\r
 EFIAPI\r
 ReadUnaligned16 (\r
-  IN      CONST UINT16              *Uint16\r
+  IN CONST UINT16              *Buffer\r
   );\r
 \r
 \r
@@ -2213,17 +2216,17 @@ ReadUnaligned16 (
 \r
   If the Buffer is NULL, then ASSERT().\r
 \r
-  @param  Uint16  Pointer to a 16-bit value that may be unaligned.\r
+  @param  Buffer  Pointer to a 16-bit value that may be unaligned.\r
   @param  Value   16-bit value to write to Buffer.\r
 \r
-  @return Value\r
+  @return The 16-bit value to write to Buffer.\r
 \r
 **/\r
 UINT16\r
 EFIAPI\r
 WriteUnaligned16 (\r
-  OUT     UINT16                    *Uint16,\r
-  IN      UINT16                    Value\r
+  OUT UINT16                    *Buffer,\r
+  IN  UINT16                    Value\r
   );\r
 \r
 \r
@@ -2237,13 +2240,13 @@ WriteUnaligned16 (
 \r
   @param  Buffer  Pointer to a 24-bit value that may be unaligned.\r
 \r
-  @return The value read.\r
+  @return The 24-bit value read from Buffer.\r
 \r
 **/\r
 UINT32\r
 EFIAPI\r
 ReadUnaligned24 (\r
-  IN      CONST UINT32              *Buffer\r
+  IN CONST UINT32              *Buffer\r
   );\r
 \r
 \r
@@ -2259,14 +2262,14 @@ ReadUnaligned24 (
   @param  Buffer  Pointer to a 24-bit value that may be unaligned.\r
   @param  Value   24-bit value to write to Buffer.\r
 \r
-  @return The value written.\r
+  @return The 24-bit value to write to Buffer.\r
 \r
 **/\r
 UINT32\r
 EFIAPI\r
 WriteUnaligned24 (\r
-  OUT     UINT32                    *Buffer,\r
-  IN      UINT32                    Value\r
+  OUT UINT32                    *Buffer,\r
+  IN  UINT32                    Value\r
   );\r
 \r
 \r
@@ -2278,15 +2281,15 @@ WriteUnaligned24 (
 \r
   If the Buffer is NULL, then ASSERT().\r
 \r
-  @param  Uint32  Pointer to a 32-bit value that may be unaligned.\r
+  @param  Buffer  Pointer to a 32-bit value that may be unaligned.\r
 \r
-  @return *Uint32\r
+  @return The 32-bit value read from Buffer.\r
 \r
 **/\r
 UINT32\r
 EFIAPI\r
 ReadUnaligned32 (\r
-  IN      CONST UINT32              *Uint32\r
+  IN CONST UINT32              *Buffer\r
   );\r
 \r
 \r
@@ -2299,17 +2302,17 @@ ReadUnaligned32 (
 \r
   If the Buffer is NULL, then ASSERT().\r
 \r
-  @param  Uint32  Pointer to a 32-bit value that may be unaligned.\r
+  @param  Buffer  Pointer to a 32-bit value that may be unaligned.\r
   @param  Value   32-bit value to write to Buffer.\r
 \r
-  @return Value\r
+  @return The 32-bit value to write to Buffer.\r
 \r
 **/\r
 UINT32\r
 EFIAPI\r
 WriteUnaligned32 (\r
-  OUT     UINT32                    *Uint32,\r
-  IN      UINT32                    Value\r
+  OUT UINT32                    *Buffer,\r
+  IN  UINT32                    Value\r
   );\r
 \r
 \r
@@ -2321,15 +2324,15 @@ WriteUnaligned32 (
 \r
   If the Buffer is NULL, then ASSERT().\r
 \r
-  @param  Uint64  Pointer to a 64-bit value that may be unaligned.\r
+  @param  Buffer  Pointer to a 64-bit value that may be unaligned.\r
 \r
-  @return *Uint64\r
+  @return The 64-bit value read from Buffer.\r
 \r
 **/\r
 UINT64\r
 EFIAPI\r
 ReadUnaligned64 (\r
-  IN      CONST UINT64              *Uint64\r
+  IN CONST UINT64              *Buffer\r
   );\r
 \r
 \r
@@ -2342,17 +2345,17 @@ ReadUnaligned64 (
 \r
   If the Buffer is NULL, then ASSERT().\r
 \r
-  @param  Uint64  Pointer to a 64-bit value that may be unaligned.\r
+  @param  Buffer  Pointer to a 64-bit value that may be unaligned.\r
   @param  Value   64-bit value to write to Buffer.\r
 \r
-  @return Value\r
+  @return The 64-bit value to write to Buffer.\r
 \r
 **/\r
 UINT64\r
 EFIAPI\r
 WriteUnaligned64 (\r
-  OUT     UINT64                    *Uint64,\r
-  IN      UINT64                    Value\r
+  OUT UINT64                    *Buffer,\r
+  IN  UINT64                    Value\r
   );\r
 \r
 \r
@@ -3048,13 +3051,13 @@ GetSpinLockProperties (
   @param  SpinLock  A pointer to the spin lock to initialize to the released\r
                     state.\r
 \r
-  @return SpinLock\r
+  @return SpinLock in release state.\r
 \r
 **/\r
 SPIN_LOCK *\r
 EFIAPI\r
 InitializeSpinLock (\r
-  IN      SPIN_LOCK                 *SpinLock\r
+  OUT      SPIN_LOCK                 *SpinLock\r
   );\r
 \r
 \r
@@ -3075,13 +3078,13 @@ InitializeSpinLock (
 \r
   @param  SpinLock  A pointer to the spin lock to place in the acquired state.\r
 \r
-  @return SpinLock\r
+  @return SpinLock accquired lock.\r
 \r
 **/\r
 SPIN_LOCK *\r
 EFIAPI\r
 AcquireSpinLock (\r
-  IN      SPIN_LOCK                 *SpinLock\r
+  IN OUT  SPIN_LOCK                 *SpinLock\r
   );\r
 \r
 \r
@@ -3105,7 +3108,7 @@ AcquireSpinLock (
 BOOLEAN\r
 EFIAPI\r
 AcquireSpinLockOrFail (\r
-  IN      SPIN_LOCK                 *SpinLock\r
+  IN OUT  SPIN_LOCK                 *SpinLock\r
   );\r
 \r
 \r
@@ -3120,13 +3123,13 @@ AcquireSpinLockOrFail (
 \r
   @param  SpinLock  A pointer to the spin lock to release.\r
 \r
-  @return SpinLock\r
+  @return SpinLock released lock.\r
 \r
 **/\r
 SPIN_LOCK *\r
 EFIAPI\r
 ReleaseSpinLock (\r
-  IN      SPIN_LOCK                 *SpinLock\r
+  IN OUT  SPIN_LOCK                 *SpinLock\r
   );\r
 \r
 \r
@@ -3245,6 +3248,7 @@ InterlockedCompareExchange64 (
   @param  CompareValue  Pointer value used in compare operation.\r
   @param  ExchangeValue Pointer value used in exchange operation.\r
 \r
+  @return The original *Value before exchange.\r
 **/\r
 VOID *\r
 EFIAPI\r
@@ -3271,8 +3275,8 @@ InterlockedCompareExchangePointer (
   If Buffer is NULL, then ASSERT().\r
   If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
 \r
-  @param  Buffer                       Pointer to the buffer to carry out the sum operation.\r
-  @param  Length           The size, in bytes, of Buffer .\r
+  @param  Buffer      Pointer to the buffer to carry out the sum operation.\r
+  @param  Length      The size, in bytes, of Buffer .\r
 \r
   @return Sum         The sum of Buffer with carry bits dropped during additions.\r
 \r
@@ -3297,9 +3301,8 @@ CalculateSum8 (
   If Buffer is NULL, then ASSERT().\r
   If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
 \r
-\r
-  @param  Buffer                       Pointer to the buffer to carry out the checksum operation.\r
-  @param  Length           The size, in bytes, of Buffer.\r
+  @param  Buffer      Pointer to the buffer to carry out the checksum operation.\r
+  @param  Length      The size, in bytes, of Buffer.\r
 \r
   @return Checksum       The 2's complement checksum of Buffer.\r
 \r
@@ -3325,8 +3328,8 @@ CalculateCheckSum8 (
   If Length is not aligned on a 16-bit boundary, then ASSERT().\r
   If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
 \r
-  @param  Buffer                       Pointer to the buffer to carry out the sum operation.\r
-  @param  Length           The size, in bytes, of Buffer.\r
+  @param  Buffer      Pointer to the buffer to carry out the sum operation.\r
+  @param  Length      The size, in bytes, of Buffer.\r
 \r
   @return Sum         The sum of Buffer with carry bits dropped during additions.\r
 \r
@@ -3353,8 +3356,8 @@ CalculateSum16 (
   If Length is not aligned on a 16-bit boundary, then ASSERT().\r
   If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
 \r
-  @param  Buffer                       Pointer to the buffer to carry out the checksum operation.\r
-  @param  Length           The size, in bytes, of Buffer.\r
+  @param  Buffer      Pointer to the buffer to carry out the checksum operation.\r
+  @param  Length      The size, in bytes, of Buffer.\r
 \r
   @return Checksum       The 2's complement checksum of Buffer.\r
 \r
@@ -3380,8 +3383,8 @@ CalculateCheckSum16 (
   If Length is not aligned on a 32-bit boundary, then ASSERT().\r
   If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
 \r
-  @param  Buffer                       Pointer to the buffer to carry out the sum operation.\r
-  @param  Length           The size, in bytes, of Buffer.\r
+  @param  Buffer      Pointer to the buffer to carry out the sum operation.\r
+  @param  Length      The size, in bytes, of Buffer.\r
 \r
   @return Sum         The sum of Buffer with carry bits dropped during additions.\r
 \r
@@ -3408,8 +3411,8 @@ CalculateSum32 (
   If Length is not aligned on a 32-bit boundary, then ASSERT().\r
   If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
 \r
-  @param  Buffer                       Pointer to the buffer to carry out the checksum operation.\r
-  @param  Length           The size, in bytes, of Buffer.\r
+  @param  Buffer      Pointer to the buffer to carry out the checksum operation.\r
+  @param  Length      The size, in bytes, of Buffer.\r
 \r
   @return Checksum       The 2's complement checksum of Buffer.\r
 \r
@@ -3435,8 +3438,8 @@ CalculateCheckSum32 (
   If Length is not aligned on a 64-bit boundary, then ASSERT().\r
   If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
 \r
-  @param  Buffer                       Pointer to the buffer to carry out the sum operation.\r
-  @param  Length           The size, in bytes, of Buffer.\r
+  @param  Buffer      Pointer to the buffer to carry out the sum operation.\r
+  @param  Length      The size, in bytes, of Buffer.\r
 \r
   @return Sum         The sum of Buffer with carry bits dropped during additions.\r
 \r
@@ -3463,8 +3466,8 @@ CalculateSum64 (
   If Length is not aligned on a 64-bit boundary, then ASSERT().\r
   If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
 \r
-  @param  Buffer                       Pointer to the buffer to carry out the checksum operation.\r
-  @param  Length           The size, in bytes, of Buffer.\r
+  @param  Buffer      Pointer to the buffer to carry out the checksum operation.\r
+  @param  Length      The size, in bytes, of Buffer.\r
 \r
   @return Checksum       The 2's complement checksum of Buffer.\r
 \r
@@ -3477,12 +3480,12 @@ CalculateCheckSum64 (
   );\r
 \r
 \r
-//\r
-// Base Library CPU Functions\r
-//\r
+///\r
+/// Base Library CPU Functions\r
+///\r
 typedef\r
 VOID\r
-(EFIAPI *SWITCH_STACK_ENTRY_POINT) (\r
+(EFIAPI *SWITCH_STACK_ENTRY_POINT)(\r
   IN      VOID                      *Context1,  OPTIONAL\r
   IN      VOID                      *Context2   OPTIONAL\r
   );\r
@@ -3552,8 +3555,6 @@ LongJump (
 /**\r
   Enables CPU interrupts.\r
 \r
-  Enables CPU interrupts.\r
-\r
 **/\r
 VOID\r
 EFIAPI\r
@@ -3565,8 +3566,6 @@ EnableInterrupts (
 /**\r
   Disables CPU interrupts.\r
 \r
-  Disables CPU interrupts.\r
-\r
 **/\r
 VOID\r
 EFIAPI\r
@@ -3579,9 +3578,6 @@ DisableInterrupts (
   Disables CPU interrupts and returns the interrupt state prior to the disable\r
   operation.\r
 \r
-  Disables CPU interrupts and returns the interrupt state prior to the disable\r
-  operation.\r
-\r
   @retval TRUE  CPU interrupts were enabled on entry to this call.\r
   @retval FALSE CPU interrupts were disabled on entry to this call.\r
 \r
@@ -3597,9 +3593,6 @@ SaveAndDisableInterrupts (
   Enables CPU interrupts for the smallest window required to capture any\r
   pending interrupts.\r
 \r
-  Enables CPU interrupts for the smallest window required to capture any\r
-  pending interrupts.\r
-\r
 **/\r
 VOID\r
 EFIAPI\r
@@ -3611,8 +3604,8 @@ EnableDisableInterrupts (
 /**\r
   Retrieves the current CPU interrupt state.\r
 \r
-  Retrieves the current CPU interrupt state. Returns TRUE is interrupts are\r
-  currently enabled. Otherwise returns FALSE.\r
+  Returns TRUE is interrupts are currently enabled. Otherwise\r
+  returns FALSE.\r
 \r
   @retval TRUE  CPU interrupts are enabled.\r
   @retval FALSE CPU interrupts are disabled.\r
@@ -3682,6 +3675,8 @@ CpuPause (
                       function.\r
   @param  NewStack    A pointer to the new stack to use for the EntryPoint\r
                       function.\r
+  @param  ...         Extended parameters.\r
+\r
 \r
 **/\r
 VOID\r
@@ -4924,12 +4919,10 @@ AsmSwitchStackAndBackingStore (
   IN      VOID                      *NewBsp\r
   );\r
 \r
-\r
-//\r
-// Bugbug: This call should be removed after\r
-//         the PalCall Instance issue has been fixed.\r
-//\r
 /**\r
+  @todo   This call should be removed after the PalCall\r
+          Instance issue has been fixed.\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
@@ -4937,9 +4930,9 @@ AsmSwitchStackAndBackingStore (
   @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
+  @param  Arg2          The second argument of a PAL call.\r
+  @param  Arg3          The third argument of a PAL call.\r
+  @param  Arg4          The fourth argument of a PAL call.\r
 \r
   @return The values returned in r8, r9, r10 and r11.\r
 \r
@@ -4955,124 +4948,122 @@ PalCallStatic (
 \r
 \r
 #elif defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)\r
-//\r
-// IA32 and X64 Specific Functions\r
-//\r
-//\r
-// Byte packed structure for 16-bit Real Mode EFLAGS\r
-//\r
+///\r
+/// IA32 and X64 Specific Functions\r
+/// Byte packed structure for 16-bit Real Mode EFLAGS\r
+///\r
 typedef union {\r
   struct {\r
-    UINT32  CF:1;           // Carry Flag\r
-    UINT32  Reserved_0:1;   // Reserved\r
-    UINT32  PF:1;           // Parity Flag\r
-    UINT32  Reserved_1:1;   // Reserved\r
-    UINT32  AF:1;           // Auxiliary Carry Flag\r
-    UINT32  Reserved_2:1;   // Reserved\r
-    UINT32  ZF:1;           // Zero Flag\r
-    UINT32  SF:1;           // Sign Flag\r
-    UINT32  TF:1;           // Trap Flag\r
-    UINT32  IF:1;           // Interrupt Enable Flag\r
-    UINT32  DF:1;           // Direction Flag\r
-    UINT32  OF:1;           // Overflow Flag\r
-    UINT32  IOPL:2;         // I/O Privilege Level\r
-    UINT32  NT:1;           // Nested Task\r
-    UINT32  Reserved_3:1;   // Reserved\r
+    UINT32  CF:1;           /// Carry Flag\r
+    UINT32  Reserved_0:1;   /// Reserved\r
+    UINT32  PF:1;           /// Parity Flag\r
+    UINT32  Reserved_1:1;   /// Reserved\r
+    UINT32  AF:1;           /// Auxiliary Carry Flag\r
+    UINT32  Reserved_2:1;   /// Reserved\r
+    UINT32  ZF:1;           /// Zero Flag\r
+    UINT32  SF:1;           /// Sign Flag\r
+    UINT32  TF:1;           /// Trap Flag\r
+    UINT32  IF:1;           /// Interrupt Enable Flag\r
+    UINT32  DF:1;           /// Direction Flag\r
+    UINT32  OF:1;           /// Overflow Flag\r
+    UINT32  IOPL:2;         /// I/O Privilege Level\r
+    UINT32  NT:1;           /// Nested Task\r
+    UINT32  Reserved_3:1;   /// Reserved\r
   } Bits;\r
   UINT16    Uint16;\r
 } IA32_FLAGS16;\r
 \r
-//\r
-// Byte packed structure for EFLAGS/RFLAGS\r
-// 32-bits on IA-32\r
-// 64-bits on X64.  The upper 32-bits on X64 are reserved\r
-//\r
+///\r
+/// Byte packed structure for EFLAGS/RFLAGS\r
+/// 32-bits on IA-32\r
+/// 64-bits on X64.  The upper 32-bits on X64 are reserved\r
+///\r
 typedef union {\r
   struct {\r
-    UINT32  CF:1;           // Carry Flag\r
-    UINT32  Reserved_0:1;   // Reserved\r
-    UINT32  PF:1;           // Parity Flag\r
-    UINT32  Reserved_1:1;   // Reserved\r
-    UINT32  AF:1;           // Auxiliary Carry Flag\r
-    UINT32  Reserved_2:1;   // Reserved\r
-    UINT32  ZF:1;           // Zero Flag\r
-    UINT32  SF:1;           // Sign Flag\r
-    UINT32  TF:1;           // Trap Flag\r
-    UINT32  IF:1;           // Interrupt Enable Flag\r
-    UINT32  DF:1;           // Direction Flag\r
-    UINT32  OF:1;           // Overflow Flag\r
-    UINT32  IOPL:2;         // I/O Privilege Level\r
-    UINT32  NT:1;           // Nested Task\r
-    UINT32  Reserved_3:1;   // Reserved\r
-    UINT32  RF:1;           // Resume Flag\r
-    UINT32  VM:1;           // Virtual 8086 Mode\r
-    UINT32  AC:1;           // Alignment Check\r
-    UINT32  VIF:1;          // Virtual Interrupt Flag\r
-    UINT32  VIP:1;          // Virtual Interrupt Pending\r
-    UINT32  ID:1;           // ID Flag\r
-    UINT32  Reserved_4:10;  // Reserved\r
+    UINT32  CF:1;           /// Carry Flag\r
+    UINT32  Reserved_0:1;   /// Reserved\r
+    UINT32  PF:1;           /// Parity Flag\r
+    UINT32  Reserved_1:1;   /// Reserved\r
+    UINT32  AF:1;           /// Auxiliary Carry Flag\r
+    UINT32  Reserved_2:1;   /// Reserved\r
+    UINT32  ZF:1;           /// Zero Flag\r
+    UINT32  SF:1;           /// Sign Flag\r
+    UINT32  TF:1;           /// Trap Flag\r
+    UINT32  IF:1;           /// Interrupt Enable Flag\r
+    UINT32  DF:1;           /// Direction Flag\r
+    UINT32  OF:1;           /// Overflow Flag\r
+    UINT32  IOPL:2;         /// I/O Privilege Level\r
+    UINT32  NT:1;           /// Nested Task\r
+    UINT32  Reserved_3:1;   /// Reserved\r
+    UINT32  RF:1;           /// Resume Flag\r
+    UINT32  VM:1;           /// Virtual 8086 Mode\r
+    UINT32  AC:1;           /// Alignment Check\r
+    UINT32  VIF:1;          /// Virtual Interrupt Flag\r
+    UINT32  VIP:1;          /// Virtual Interrupt Pending\r
+    UINT32  ID:1;           /// ID Flag\r
+    UINT32  Reserved_4:10;  /// Reserved\r
   } Bits;\r
   UINTN     UintN;\r
 } IA32_EFLAGS32;\r
 \r
-//\r
-// Byte packed structure for Control Register 0 (CR0)\r
-// 32-bits on IA-32\r
-// 64-bits on X64.  The upper 32-bits on X64 are reserved\r
-//\r
+///\r
+/// Byte packed structure for Control Register 0 (CR0)\r
+/// 32-bits on IA-32\r
+/// 64-bits on X64.  The upper 32-bits on X64 are reserved\r
+///\r
 typedef union {\r
   struct {\r
-    UINT32  PE:1;           // Protection Enable\r
-    UINT32  MP:1;           // Monitor Coprocessor\r
-    UINT32  EM:1;           // Emulation\r
-    UINT32  TS:1;           // Task Switched\r
-    UINT32  ET:1;           // Extension Type\r
-    UINT32  NE:1;           // Numeric Error\r
-    UINT32  Reserved_0:10;  // Reserved\r
-    UINT32  WP:1;           // Write Protect\r
-    UINT32  Reserved_1:1;   // Reserved\r
-    UINT32  AM:1;           // Alignment Mask\r
-    UINT32  Reserved_2:10;  // Reserved\r
-    UINT32  NW:1;           // Mot Write-through\r
-    UINT32  CD:1;           // Cache Disable\r
-    UINT32  PG:1;           // Paging\r
+    UINT32  PE:1;           /// Protection Enable\r
+    UINT32  MP:1;           /// Monitor Coprocessor\r
+    UINT32  EM:1;           /// Emulation\r
+    UINT32  TS:1;           /// Task Switched\r
+    UINT32  ET:1;           /// Extension Type\r
+    UINT32  NE:1;           /// Numeric Error\r
+    UINT32  Reserved_0:10;  /// Reserved\r
+    UINT32  WP:1;           /// Write Protect\r
+    UINT32  Reserved_1:1;   /// Reserved\r
+    UINT32  AM:1;           /// Alignment Mask\r
+    UINT32  Reserved_2:10;  /// Reserved\r
+    UINT32  NW:1;           /// Mot Write-through\r
+    UINT32  CD:1;           /// Cache Disable\r
+    UINT32  PG:1;           /// Paging\r
   } Bits;\r
   UINTN     UintN;\r
 } IA32_CR0;\r
 \r
-//\r
-// Byte packed structure for Control Register 4 (CR4)\r
-// 32-bits on IA-32\r
-// 64-bits on X64.  The upper 32-bits on X64 are reserved\r
-//\r
+///\r
+/// Byte packed structure for Control Register 4 (CR4)\r
+/// 32-bits on IA-32\r
+/// 64-bits on X64.  The upper 32-bits on X64 are reserved\r
+///\r
 typedef union {\r
   struct {\r
-    UINT32  VME:1;          // Virtual-8086 Mode Extensions\r
-    UINT32  PVI:1;          // Protected-Mode Virtual Interrupts\r
-    UINT32  TSD:1;          // Time Stamp Disable\r
-    UINT32  DE:1;           // Debugging Extensions\r
-    UINT32  PSE:1;          // Page Size Extensions\r
-    UINT32  PAE:1;          // Physical Address Extension\r
-    UINT32  MCE:1;          // Machine Check Enable\r
-    UINT32  PGE:1;          // Page Global Enable\r
-    UINT32  PCE:1;          // Performance Monitoring Counter\r
-                            // Enable\r
-    UINT32  OSFXSR:1;       // Operating System Support for\r
-                            // FXSAVE and FXRSTOR instructions\r
-    UINT32  OSXMMEXCPT:1;   // Operating System Support for\r
-                            // Unmasked SIMD Floating Point\r
-                            // Exceptions\r
-    UINT32  Reserved_0:2;   // Reserved\r
-    UINT32  VMXE:1;         // VMX Enable\r
-    UINT32  Reserved_1:18;  // Reseved\r
+    UINT32  VME:1;          /// Virtual-8086 Mode Extensions\r
+    UINT32  PVI:1;          /// Protected-Mode Virtual Interrupts\r
+    UINT32  TSD:1;          /// Time Stamp Disable\r
+    UINT32  DE:1;           /// Debugging Extensions\r
+    UINT32  PSE:1;          /// Page Size Extensions\r
+    UINT32  PAE:1;          /// Physical Address Extension\r
+    UINT32  MCE:1;          /// Machine Check Enable\r
+    UINT32  PGE:1;          /// Page Global Enable\r
+    UINT32  PCE:1;          /// Performance Monitoring Counter\r
+                            /// Enable\r
+    UINT32  OSFXSR:1;       /// Operating System Support for\r
+                            /// FXSAVE and FXRSTOR instructions\r
+    UINT32  OSXMMEXCPT:1;   /// Operating System Support for\r
+                            /// Unmasked SIMD Floating Point\r
+                            /// Exceptions\r
+    UINT32  Reserved_0:2;   /// Reserved\r
+    UINT32  VMXE:1;         /// VMX Enable\r
+    UINT32  Reserved_1:18;  /// Reseved\r
   } Bits;\r
   UINTN     UintN;\r
 } IA32_CR4;\r
 \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
+///\r
+/// Byte packed structure for an IDTR, GDTR, LDTR descriptor\r
+/// @todo  How to make this structure byte-packed in a compiler independent way?\r
+///\r
 #pragma pack (1)\r
 typedef struct {\r
   UINT16  Limit;\r
@@ -5086,9 +5077,11 @@ typedef struct {
 #define IA32_IDT_GATE_TYPE_INTERRUPT_32  0x8E\r
 #define IA32_IDT_GATE_TYPE_TRAP_32       0x8F\r
 \r
-//\r
-// Byte packed structure for an Interrupt Gate Descriptor\r
-//\r
+///\r
+/// Byte packed structure for an Interrupt Gate Descriptor\r
+///\r
+#if defined (MDE_CPU_IA32)\r
+\r
 typedef union {\r
   struct {\r
     UINT32  OffsetLow:16;   // Offset bits 15..0\r
@@ -5100,16 +5093,36 @@ typedef union {
   UINT64  Uint64;\r
 } IA32_IDT_GATE_DESCRIPTOR;\r
 \r
-//\r
-// Byte packed structure for an FP/SSE/SSE2 context\r
-//\r
+#endif\r
+\r
+#if defined (MDE_CPU_X64)\r
+\r
+typedef union {\r
+  struct {\r
+    UINT32  OffsetLow:16;   // Offset bits 15..0\r
+    UINT32  Selector:16;    // Selector\r
+    UINT32  Reserved_0:8;   // Reserved\r
+    UINT32  GateType:8;     // Gate Type.  See #defines above\r
+    UINT32  OffsetHigh:16;  // Offset bits 31..16\r
+    UINT32  OffsetUpper:32; // Offset bits 63..32\r
+    UINT32  Reserved_1:32;  // Reserved\r
+  } Bits;\r
+  UINT64  Uint64;\r
+  UINT64  Uint64_1;\r
+} IA32_IDT_GATE_DESCRIPTOR;\r
+\r
+#endif\r
+\r
+///\r
+/// Byte packed structure for an FP/SSE/SSE2 context\r
+///\r
 typedef struct {\r
   UINT8  Buffer[512];\r
 } IA32_FX_BUFFER;\r
 \r
-//\r
-// Structures for the 16-bit real mode thunks\r
-//\r
+///\r
+/// Structures for the 16-bit real mode thunks\r
+///\r
 typedef struct {\r
   UINT32                            Reserved1;\r
   UINT32                            Reserved2;\r
@@ -5173,9 +5186,9 @@ typedef union {
   IA32_BYTE_REGS                    H;\r
 } IA32_REGISTER_SET;\r
 \r
-//\r
-// Byte packed structure for an 16-bit real mode thunks\r
-//\r
+///\r
+/// Byte packed structure for an 16-bit real mode thunks\r
+///\r
 typedef struct {\r
   IA32_REGISTER_SET                 *RealModeState;\r
   VOID                              *RealModeBuffer;\r
@@ -7068,7 +7081,7 @@ AsmDisablePaging32 (
   If EntryPoint is 0, then ASSERT().\r
   If NewStack is 0, then ASSERT().\r
 \r
-  @param  Cs          The 16-bit selector to load in the CS before EntryPoint\r
+  @param  CodeSelector The 16-bit selector to load in the CS before EntryPoint\r
                       is called. The descriptor in the GDT that this selector\r
                       references must be setup for long mode.\r
   @param  EntryPoint  The 64-bit virtual address of the function to call with\r
@@ -7109,7 +7122,7 @@ AsmEnablePaging64 (
   If EntryPoint is 0, then ASSERT().\r
   If NewStack is 0, then ASSERT().\r
 \r
-  @param  Cs          The 16-bit selector to load in the CS before EntryPoint\r
+  @param  CodeSelector The 16-bit selector to load in the CS before EntryPoint\r
                       is called. The descriptor in the GDT that this selector\r
                       references must be setup for 32-bit protected mode.\r
   @param  EntryPoint  The 64-bit virtual address of the function to call with\r
@@ -7230,10 +7243,7 @@ AsmPrepareAndThunk16 (
   IN OUT  THUNK_CONTEXT             *ThunkContext\r
   );\r
 \r
-#else\r
-\r
 #endif\r
-\r
 #endif\r
 \r
 \r