From 2fc60b703842994beb1d78f9221deca7d81d9159 Mon Sep 17 00:00:00 2001
From: gikidy <gikidy@6f19259b-4bc3-4df7-8a09-765794883524>
Date: Thu, 11 Dec 2008 02:59:41 +0000
Subject: [PATCH] Synchronize BaseLib h files to c files.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6983 6f19259b-4bc3-4df7-8a09-765794883524
---
 MdePkg/Library/BaseLib/BitField.c           |  6 +-
 MdePkg/Library/BaseLib/CheckSum.c           | 32 +++++-----
 MdePkg/Library/BaseLib/LinkedList.c         | 70 ++++++++++-----------
 MdePkg/Library/BaseLib/Math64.c             | 16 +++--
 MdePkg/Library/BaseLib/SetJump.c            |  3 +-
 MdePkg/Library/BaseLib/String.c             | 32 +++++-----
 MdePkg/Library/BaseLib/SwapBytes16.c        |  8 +--
 MdePkg/Library/BaseLib/SwapBytes32.c        | 10 +--
 MdePkg/Library/BaseLib/SwapBytes64.c        |  8 +--
 MdePkg/Library/BaseLib/SwitchStack.c        |  1 +
 MdePkg/Library/BaseLib/Synchronization.c    |  5 +-
 MdePkg/Library/BaseLib/SynchronizationGcc.c |  2 +-
 MdePkg/Library/BaseLib/SynchronizationMsc.c |  5 +-
 MdePkg/Library/BaseLib/X86FxRestore.c       |  2 +-
 MdePkg/Library/BaseLib/X86Msr.c             |  7 ++-
 MdePkg/Library/BaseLib/X86ReadIdtr.c        |  2 +-
 MdePkg/Library/BaseLib/X86Thunk.c           | 45 +++++++++++--
 MdePkg/Library/BaseLib/X86WriteIdtr.c       |  2 +-
 18 files changed, 144 insertions(+), 112 deletions(-)

diff --git a/MdePkg/Library/BaseLib/BitField.c b/MdePkg/Library/BaseLib/BitField.c
index e4104f5a70..658dd97cda 100644
--- a/MdePkg/Library/BaseLib/BitField.c
+++ b/MdePkg/Library/BaseLib/BitField.c
@@ -15,7 +15,7 @@
 #include "BaseLibInternals.h"
 
 /**
-  Worker function that returns a bit field from Operand
+  Worker function that returns a bit field from Operand.
 
   Returns the bitfield specified by the StartBit and the EndBit from Operand.
 
@@ -42,7 +42,7 @@ BitFieldReadUint (
 }
 
 /**
-  Worker function that reads a bit field from Operand, performs a bitwise OR, 
+  Worker function that reads a bit field from Operand, performs a bitwise OR,
   and returns the result.
 
   Performs a bitwise OR between the bit field specified by StartBit and EndBit
@@ -74,7 +74,7 @@ BitFieldOrUint (
 }
 
 /**
-  Worker function that reads a bit field from Operand, performs a bitwise AND, 
+  Worker function that reads a bit field from Operand, performs a bitwise AND,
   and returns the result.
 
   Performs a bitwise AND between the bit field specified by StartBit and EndBit
diff --git a/MdePkg/Library/BaseLib/CheckSum.c b/MdePkg/Library/BaseLib/CheckSum.c
index 7fad548aa9..4acaf42a6f 100644
--- a/MdePkg/Library/BaseLib/CheckSum.c
+++ b/MdePkg/Library/BaseLib/CheckSum.c
@@ -36,8 +36,8 @@
 UINT8
 EFIAPI
 CalculateSum8 (
-  IN      CONST UINT8        *Buffer,
-  IN      UINTN              Length
+  IN      CONST UINT8              *Buffer,
+  IN      UINTN                     Length
   )
 {
   UINT8     Sum;
@@ -75,8 +75,8 @@ CalculateSum8 (
 UINT8
 EFIAPI
 CalculateCheckSum8 (
-  IN      CONST UINT8        *Buffer,
-  IN      UINTN              Length
+  IN      CONST UINT8              *Buffer,
+  IN      UINTN                     Length
   )
 {
   UINT8     CheckSum;
@@ -111,8 +111,8 @@ CalculateCheckSum8 (
 UINT16
 EFIAPI
 CalculateSum16 (
-  IN      CONST UINT16       *Buffer,
-  IN      UINTN              Length
+  IN      CONST UINT16             *Buffer,
+  IN      UINTN                     Length
   )
 {
   UINT16    Sum;
@@ -156,8 +156,8 @@ CalculateSum16 (
 UINT16
 EFIAPI
 CalculateCheckSum16 (
-  IN      CONST UINT16         *Buffer,
-  IN      UINTN                Length
+  IN      CONST UINT16             *Buffer,
+  IN      UINTN                     Length
   )
 {
   UINT16     CheckSum;
@@ -193,8 +193,8 @@ CalculateCheckSum16 (
 UINT32
 EFIAPI
 CalculateSum32 (
-  IN      CONST UINT32         *Buffer,
-  IN      UINTN                Length
+  IN      CONST UINT32             *Buffer,
+  IN      UINTN                     Length
   )
 {
   UINT32    Sum;
@@ -238,8 +238,8 @@ CalculateSum32 (
 UINT32
 EFIAPI
 CalculateCheckSum32 (
-  IN      CONST UINT32         *Buffer,
-  IN      UINTN                Length
+  IN      CONST UINT32             *Buffer,
+  IN      UINTN                     Length
   )
 {
   UINT32     CheckSum;
@@ -275,8 +275,8 @@ CalculateCheckSum32 (
 UINT64
 EFIAPI
 CalculateSum64 (
-  IN      CONST UINT64         *Buffer,
-  IN      UINTN                Length
+  IN      CONST UINT64             *Buffer,
+  IN      UINTN                     Length
   )
 {
   UINT64    Sum;
@@ -320,8 +320,8 @@ CalculateSum64 (
 UINT64
 EFIAPI
 CalculateCheckSum64 (
-  IN      CONST UINT64         *Buffer,
-  IN      UINTN                Length
+  IN      CONST UINT64             *Buffer,
+  IN      UINTN                     Length
   )
 {
   UINT64     CheckSum;
diff --git a/MdePkg/Library/BaseLib/LinkedList.c b/MdePkg/Library/BaseLib/LinkedList.c
index ef69d1827a..8069bd3550 100644
--- a/MdePkg/Library/BaseLib/LinkedList.c
+++ b/MdePkg/Library/BaseLib/LinkedList.c
@@ -15,14 +15,14 @@
 #include "BaseLibInternals.h"
 
 /**
-  Worker function that locates the Node in the List
+  Worker function that locates the Node in the List.
 
   By searching the List, finds the location of the Node in List. At the same time,
   verifies the validity of this list.
 
   If List is NULL, then ASSERT().
   If List->ForwardLink is NULL, then ASSERT().
-  If List->BackLink is NULL, then ASSERT().
+  If List->backLink is NULL, then ASSERT().
   If Node is NULL, then ASSERT();
   If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
   of nodes in ListHead, including the ListHead node, is greater than or
@@ -93,15 +93,15 @@ IsNodeInList (
 LIST_ENTRY *
 EFIAPI
 InitializeListHead (
-  IN OUT  LIST_ENTRY            *List
+  IN OUT  LIST_ENTRY                *ListHead
   )
 
 {
-  ASSERT (List != NULL);
+  ASSERT (ListHead != NULL);
 
-  List->ForwardLink = List;
-  List->BackLink = List;
-  return List;
+  ListHead->ForwardLink = ListHead;
+  ListHead->BackLink = ListHead;
+  return ListHead;
 }
 
 /**
@@ -129,20 +129,20 @@ InitializeListHead (
 LIST_ENTRY *
 EFIAPI
 InsertHeadList (
-  IN OUT  LIST_ENTRY            *List,
-  IN OUT  LIST_ENTRY            *Entry
+  IN OUT  LIST_ENTRY                *ListHead,
+  IN OUT  LIST_ENTRY                *Entry
   )
 {
   //
   // ASSERT List not too long and Entry is not one of the nodes of List
   //
-  ASSERT (!IsNodeInList (List, Entry));
+  ASSERT (!IsNodeInList (ListHead, Entry));
 
-  Entry->ForwardLink = List->ForwardLink;
-  Entry->BackLink = List;
+  Entry->ForwardLink = ListHead->ForwardLink;
+  Entry->BackLink = ListHead;
   Entry->ForwardLink->BackLink = Entry;
-  List->ForwardLink = Entry;
-  return List;
+  ListHead->ForwardLink = Entry;
+  return ListHead;
 }
 
 /**
@@ -170,20 +170,20 @@ InsertHeadList (
 LIST_ENTRY *
 EFIAPI
 InsertTailList (
-  IN OUT  LIST_ENTRY            *List,
-  IN OUT  LIST_ENTRY            *Entry
+  IN OUT  LIST_ENTRY                *ListHead,
+  IN OUT  LIST_ENTRY                *Entry
   )
 {
   //
   // ASSERT List not too long and Entry is not one of the nodes of List
   //
-  ASSERT (!IsNodeInList (List, Entry));
+  ASSERT (!IsNodeInList (ListHead, Entry));
 
-  Entry->ForwardLink = List;
-  Entry->BackLink = List->BackLink;
+  Entry->ForwardLink = ListHead;
+  Entry->BackLink = ListHead->BackLink;
   Entry->BackLink->ForwardLink = Entry;
-  List->BackLink = Entry;
-  return List;
+  ListHead->BackLink = Entry;
+  return ListHead;
 }
 
 /**
@@ -209,7 +209,7 @@ InsertTailList (
 LIST_ENTRY *
 EFIAPI
 GetFirstNode (
-  IN CONST LIST_ENTRY  *List
+  IN      CONST LIST_ENTRY          *List
   )
 {
   //
@@ -245,8 +245,8 @@ GetFirstNode (
 LIST_ENTRY *
 EFIAPI
 GetNextNode (
-  IN CONST LIST_ENTRY  *List,
-  IN CONST LIST_ENTRY  *Node
+  IN      CONST LIST_ENTRY          *List,
+  IN      CONST LIST_ENTRY          *Node
   )
 {
   //
@@ -279,15 +279,15 @@ GetNextNode (
 BOOLEAN
 EFIAPI
 IsListEmpty (
-  IN      CONST LIST_ENTRY      *List
+  IN      CONST LIST_ENTRY          *ListHead
   )
 {
   //
   // ASSERT List not too long
   //
-  ASSERT (IsNodeInList (List, List));
+  ASSERT (IsNodeInList (ListHead, ListHead));
 
-  return (BOOLEAN)(List->ForwardLink == List);
+  return (BOOLEAN)(ListHead->ForwardLink == ListHead);
 }
 
 /**
@@ -318,8 +318,8 @@ IsListEmpty (
 BOOLEAN
 EFIAPI
 IsNull (
-  IN      CONST LIST_ENTRY      *List,
-  IN      CONST LIST_ENTRY      *Node
+  IN      CONST LIST_ENTRY          *List,
+  IN      CONST LIST_ENTRY          *Node
   )
 {
   //
@@ -356,8 +356,8 @@ IsNull (
 BOOLEAN
 EFIAPI
 IsNodeAtEnd (
-  IN      CONST LIST_ENTRY      *List,
-  IN      CONST LIST_ENTRY      *Node
+  IN      CONST LIST_ENTRY          *List,
+  IN      CONST LIST_ENTRY          *Node
   )
 {
   //
@@ -389,15 +389,15 @@ IsNodeAtEnd (
 
   @param  FirstEntry  A pointer to a node in a linked list.
   @param  SecondEntry A pointer to another node in the same linked list.
-
+  
   @return SecondEntry.
 
 **/
 LIST_ENTRY *
 EFIAPI
 SwapListEntries (
-  IN OUT  LIST_ENTRY            *FirstEntry,
-  IN OUT  LIST_ENTRY            *SecondEntry
+  IN OUT  LIST_ENTRY                *FirstEntry,
+  IN OUT  LIST_ENTRY                *SecondEntry
   )
 {
   LIST_ENTRY                    *Ptr;
@@ -464,7 +464,7 @@ SwapListEntries (
 LIST_ENTRY *
 EFIAPI
 RemoveEntryList (
-  IN      CONST LIST_ENTRY      *Entry
+  IN      CONST LIST_ENTRY          *Entry
   )
 {
   ASSERT (!IsListEmpty (Entry));
diff --git a/MdePkg/Library/BaseLib/Math64.c b/MdePkg/Library/BaseLib/Math64.c
index 0b127c70b1..0001124f06 100644
--- a/MdePkg/Library/BaseLib/Math64.c
+++ b/MdePkg/Library/BaseLib/Math64.c
@@ -68,8 +68,6 @@ InternalMathRShiftU64 (
   This function shifts the 64-bit value Operand to the right by Count bits. The
   high Count bits are set to bit 63 of Operand.  The shifted value is returned.
 
-  If Count is greater than 63, then ASSERT().
-
   @param  Operand The 64-bit operand to shift right.
   @param  Count   The number of bits to shift right.
 
@@ -161,7 +159,7 @@ InternalMathRRotU64 (
 
   @param  Operand A 64-bit unsigned value.
 
-  @return The byte swaped Operand.
+  @return The byte swapped Operand.
 
 **/
 UINT64
@@ -236,7 +234,7 @@ InternalMathMultU64x64 (
   unsigned value Divisor and generates a 64-bit unsigned quotient. This
   function returns the 64-bit unsigned quotient.
 
-   @param  Dividend  A 64-bit unsigned value.
+  @param  Dividend  A 64-bit unsigned value.
   @param  Divisor   A 32-bit unsigned value.
 
   @return Dividend / Divisor
@@ -253,8 +251,8 @@ InternalMathDivU64x32 (
 }
 
 /**
-  Divides a 64-bit unsigned integer by a 32-bit unsigned integer
-  and generates a 32-bit unsigned remainder.
+  Divides a 64-bit unsigned integer by a 32-bit unsigned integer and
+  generates a 32-bit unsigned remainder.
 
   This function divides the 64-bit unsigned value Dividend by the 32-bit
   unsigned value Divisor and generates a 32-bit remainder. This function
@@ -298,7 +296,7 @@ EFIAPI
 InternalMathDivRemU64x32 (
   IN      UINT64                    Dividend,
   IN      UINT32                    Divisor,
-  OUT     UINT32                    *Remainder  OPTIONAL
+  OUT     UINT32                    *Remainder OPTIONAL
   )
 {
   if (Remainder != NULL) {
@@ -329,7 +327,7 @@ EFIAPI
 InternalMathDivRemU64x64 (
   IN      UINT64                    Dividend,
   IN      UINT64                    Divisor,
-  OUT     UINT64                    *Remainder  OPTIONAL
+  OUT     UINT64                    *Remainder OPTIONAL
   )
 {
   if (Remainder != NULL) {
@@ -340,7 +338,7 @@ InternalMathDivRemU64x64 (
 
 /**
   Divides a 64-bit signed integer by a 64-bit signed integer and
-  generates a 64-bit signed result and a optional 64-bit signed remainder.
+  generates a 64-bit signed result and an optional 64-bit signed remainder.
 
   This function divides the 64-bit signed value Dividend by the 64-bit
   signed value Divisor and generates a 64-bit signed quotient. If Remainder
diff --git a/MdePkg/Library/BaseLib/SetJump.c b/MdePkg/Library/BaseLib/SetJump.c
index d4c8895755..6cf197d535 100644
--- a/MdePkg/Library/BaseLib/SetJump.c
+++ b/MdePkg/Library/BaseLib/SetJump.c
@@ -23,8 +23,7 @@
   Checks ASSERT condition for JumpBuffer.
 
   If JumpBuffer is NULL, then ASSERT().
-  If JumpBuffer is not aligned on a BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT
-  boundary, then ASSERT().
+  For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
 
   @param  JumpBuffer    A pointer to CPU context buffer.
 
diff --git a/MdePkg/Library/BaseLib/String.c b/MdePkg/Library/BaseLib/String.c
index 9f1ad6c482..b9c5c8c960 100644
--- a/MdePkg/Library/BaseLib/String.c
+++ b/MdePkg/Library/BaseLib/String.c
@@ -261,7 +261,7 @@ StrCmp (
 /**
   Compares up to a specified length the contents of two Null-terminated Unicode strings,
   and returns the difference between the first mismatched Unicode characters.
-
+  
   This function compares the Null-terminated Unicode string FirstString to the
   Null-terminated Unicode string SecondString. At most, Length Unicode
   characters will be compared. If Length is 0, then 0 is returned. If
@@ -451,8 +451,8 @@ StrnCat (
 CHAR16 *
 EFIAPI
 StrStr (
-  IN      CONST CHAR16                *String,
-  IN      CONST CHAR16                *SearchString
+  IN      CONST CHAR16              *String,
+  IN      CONST CHAR16              *SearchString
   )
 {
   CONST CHAR16 *FirstMatch;
@@ -632,7 +632,7 @@ InternalIsHexaDecimalDigitCharacter (
 UINTN
 EFIAPI
 StrDecimalToUintn (
-  IN      CONST CHAR16                *String
+  IN      CONST CHAR16              *String
   )
 {
   UINTN     Result;
@@ -714,7 +714,7 @@ StrDecimalToUintn (
 UINT64
 EFIAPI
 StrDecimalToUint64 (
-  IN      CONST CHAR16                *String
+  IN      CONST CHAR16              *String
   )
 {
   UINT64     Result;
@@ -796,7 +796,7 @@ StrDecimalToUint64 (
 UINTN
 EFIAPI
 StrHexToUintn (
-  IN      CONST CHAR16                *String
+  IN      CONST CHAR16              *String
   )
 {
   UINTN     Result;
@@ -886,11 +886,11 @@ StrHexToUintn (
 
   @retval Value translated from String.
 
-  **/
+**/
 UINT64
 EFIAPI
 StrHexToUint64 (
-  IN      CONST CHAR16                *String
+  IN      CONST CHAR16             *String
   )
 {
   UINT64    Result;
@@ -1027,8 +1027,8 @@ InternalAsciiIsHexaDecimalDigitCharacter (
 CHAR8 *
 EFIAPI
 UnicodeStrToAsciiStr (
-  IN      CONST CHAR16                *Source,
-  OUT     CHAR8                       *Destination
+  IN      CONST CHAR16              *Source,
+  OUT     CHAR8                     *Destination
   )
 {
   CHAR8                               *ReturnValue;
@@ -1421,7 +1421,7 @@ AsciiStriCmp (
   @param  FirstString   Pointer to a Null-terminated ASCII string.
   @param  SecondString  Pointer to a Null-terminated ASCII string.
   @param  Length        Maximum number of ASCII characters for compare.
-
+  
   @retval ==0       FirstString is identical to SecondString.
   @retval !=0       FirstString is not identical to SecondString.
 
@@ -1577,8 +1577,8 @@ AsciiStrnCat (
 CHAR8 *
 EFIAPI
 AsciiStrStr (
-  IN      CONST CHAR8             *String,
-  IN      CONST CHAR8             *SearchString
+  IN      CONST CHAR8               *String,
+  IN      CONST CHAR8               *SearchString
   )
 {
   CONST CHAR8 *FirstMatch;
@@ -1729,7 +1729,7 @@ AsciiStrDecimalToUintn (
 UINT64
 EFIAPI
 AsciiStrDecimalToUint64 (
-  IN      CONST CHAR8             *String
+  IN      CONST CHAR8               *String
   )
 {
   UINT64     Result;
@@ -1809,7 +1809,7 @@ AsciiStrDecimalToUint64 (
 UINTN
 EFIAPI
 AsciiStrHexToUintn (
-  IN      CONST CHAR8             *String
+  IN      CONST CHAR8               *String
   )
 {
   UINTN     Result;
@@ -1901,7 +1901,7 @@ AsciiStrHexToUintn (
 UINT64
 EFIAPI
 AsciiStrHexToUint64 (
-  IN      CONST CHAR8             *String
+  IN      CONST CHAR8                *String
   )
 {
   UINT64    Result;
diff --git a/MdePkg/Library/BaseLib/SwapBytes16.c b/MdePkg/Library/BaseLib/SwapBytes16.c
index 872250bac1..a656a8cea2 100644
--- a/MdePkg/Library/BaseLib/SwapBytes16.c
+++ b/MdePkg/Library/BaseLib/SwapBytes16.c
@@ -24,16 +24,16 @@
   from little endian to big endian or vice versa. The byte swapped value is
   returned.
 
-  @param  Value Operand A 16-bit unsigned value.
+  @param  Value A 16-bit unsigned value.
 
-  @return The byte swapped Operand.
+  @return The byte swapped value.
 
 **/
 UINT16
 EFIAPI
 SwapBytes16 (
-  IN      UINT16                    Operand
+  IN      UINT16                    Value
   )
 {
-  return (UINT16) ((Operand << 8) | (Operand >> 8));
+  return (UINT16) ((Value<< 8) | (Value>> 8));
 }
diff --git a/MdePkg/Library/BaseLib/SwapBytes32.c b/MdePkg/Library/BaseLib/SwapBytes32.c
index f1a1b8925e..9833111447 100644
--- a/MdePkg/Library/BaseLib/SwapBytes32.c
+++ b/MdePkg/Library/BaseLib/SwapBytes32.c
@@ -24,22 +24,22 @@
   from little endian to big endian or vice versa. The byte swapped value is
   returned.
 
-  @param  Value Operand A 32-bit unsigned value.
+  @param  Value A 32-bit unsigned value.
 
-  @return The byte swapped Operand.
+  @return The byte swapped Value.
 
 **/
 UINT32
 EFIAPI
 SwapBytes32 (
-  IN      UINT32                    Operand
+  IN      UINT32                    Value
   )
 {
   UINT32  LowerBytes;
   UINT32  HigherBytes;
 
-  LowerBytes  = (UINT32) SwapBytes16 ((UINT16) Operand);
-  HigherBytes = (UINT32) SwapBytes16 ((UINT16) (Operand >> 16));
+  LowerBytes  = (UINT32) SwapBytes16 ((UINT16) Value);
+  HigherBytes = (UINT32) SwapBytes16 ((UINT16) (Value >> 16));
 
   return (LowerBytes << 16 | HigherBytes);
 }
diff --git a/MdePkg/Library/BaseLib/SwapBytes64.c b/MdePkg/Library/BaseLib/SwapBytes64.c
index ccbdadf306..5b54a9064b 100644
--- a/MdePkg/Library/BaseLib/SwapBytes64.c
+++ b/MdePkg/Library/BaseLib/SwapBytes64.c
@@ -24,16 +24,16 @@
   from little endian to big endian or vice versa. The byte swapped value is
   returned.
 
-  @param  Value Operand A 64-bit unsigned value.
+  @param  Value A 64-bit unsigned value.
 
-  @return The byte swapped Operand.
+  @return The byte swapped Value.
 
 **/
 UINT64
 EFIAPI
 SwapBytes64 (
-  IN      UINT64                    Operand
+  IN      UINT64                    Value
   )
 {
-  return InternalMathSwapBytes64 (Operand);
+  return InternalMathSwapBytes64 (Value);
 }
diff --git a/MdePkg/Library/BaseLib/SwitchStack.c b/MdePkg/Library/BaseLib/SwitchStack.c
index a6e33aec6e..32c64ca8d6 100644
--- a/MdePkg/Library/BaseLib/SwitchStack.c
+++ b/MdePkg/Library/BaseLib/SwitchStack.c
@@ -41,6 +41,7 @@
                       a single parameter of type VOID * that specifies the new backing 
                       store pointer.
 
+
 **/
 VOID
 EFIAPI
diff --git a/MdePkg/Library/BaseLib/Synchronization.c b/MdePkg/Library/BaseLib/Synchronization.c
index b84188e618..6956237efc 100644
--- a/MdePkg/Library/BaseLib/Synchronization.c
+++ b/MdePkg/Library/BaseLib/Synchronization.c
@@ -61,7 +61,7 @@ GetSpinLockProperties (
 SPIN_LOCK *
 EFIAPI
 InitializeSpinLock (
-  OUT     SPIN_LOCK                 *SpinLock
+  OUT      SPIN_LOCK                 *SpinLock
   )
 {
   ASSERT (SpinLock != NULL);
@@ -352,9 +352,8 @@ InterlockedCompareExchange64 (
                         operation.
   @param  CompareValue  Pointer value used in compare operation.
   @param  ExchangeValue Pointer value used in exchange operation.
-  
-  @return The original *Value before exchange.
 
+  @return The original *Value before exchange.
 **/
 VOID *
 EFIAPI
diff --git a/MdePkg/Library/BaseLib/SynchronizationGcc.c b/MdePkg/Library/BaseLib/SynchronizationGcc.c
index b479123863..49a09e747c 100644
--- a/MdePkg/Library/BaseLib/SynchronizationGcc.c
+++ b/MdePkg/Library/BaseLib/SynchronizationGcc.c
@@ -69,7 +69,7 @@ GetSpinLockProperties (
 SPIN_LOCK *
 EFIAPI
 InitializeSpinLock (
-  OUT     SPIN_LOCK                 *SpinLock
+  OUT      SPIN_LOCK                 *SpinLock
   )
 {
   ASSERT (SpinLock != NULL);
diff --git a/MdePkg/Library/BaseLib/SynchronizationMsc.c b/MdePkg/Library/BaseLib/SynchronizationMsc.c
index 66b211a2b8..1d20954ca3 100644
--- a/MdePkg/Library/BaseLib/SynchronizationMsc.c
+++ b/MdePkg/Library/BaseLib/SynchronizationMsc.c
@@ -72,7 +72,7 @@ GetSpinLockProperties (
 SPIN_LOCK *
 EFIAPI
 InitializeSpinLock (
-  OUT     SPIN_LOCK                 *SpinLock
+  OUT      SPIN_LOCK                 *SpinLock
   )
 {
   ASSERT (SpinLock != NULL);
@@ -373,9 +373,8 @@ InterlockedCompareExchange64 (
                         operation.
   @param  CompareValue  Pointer value used in compare operation.
   @param  ExchangeValue Pointer value used in exchange operation.
-  
-  @return The original *Value before exchange.
 
+  @return The original *Value before exchange.
 **/
 VOID *
 EFIAPI
diff --git a/MdePkg/Library/BaseLib/X86FxRestore.c b/MdePkg/Library/BaseLib/X86FxRestore.c
index a484b87836..5af4ed959b 100644
--- a/MdePkg/Library/BaseLib/X86FxRestore.c
+++ b/MdePkg/Library/BaseLib/X86FxRestore.c
@@ -34,7 +34,7 @@
 VOID
 EFIAPI
 AsmFxRestore (
-  IN CONST IA32_FX_BUFFER  *Buffer
+  IN      CONST IA32_FX_BUFFER      *Buffer
   )
 {
   ASSERT (Buffer != NULL);
diff --git a/MdePkg/Library/BaseLib/X86Msr.c b/MdePkg/Library/BaseLib/X86Msr.c
index 612b29c0e6..410ab2eb9e 100644
--- a/MdePkg/Library/BaseLib/X86Msr.c
+++ b/MdePkg/Library/BaseLib/X86Msr.c
@@ -40,7 +40,8 @@ AsmReadMsr32 (
 }
 
 /**
-  Zero-extend a 32-bit value and writes it to a Machine Specific Register(MSR).
+  Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.
+  The upper 32-bits of the MSR are set to zero.
 
   Writes the 32-bit value specified by Value to the MSR specified by Index. The
   upper 32-bits of the MSR write are set to zero. The 32-bit value written to
@@ -192,7 +193,7 @@ AsmMsrBitFieldRead32 (
 /**
   Writes a bit field to an MSR.
 
-  Writes Value to a bit field in the lower 32-bits of a  64-bit MSR. The bit
+  Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
   field is specified by the StartBit and the EndBit. All other bits in the
   destination MSR are preserved. The lower 32-bits of the MSR written is
   returned. The caller must either guarantee that Index and the data written 
@@ -464,7 +465,7 @@ AsmMsrAndThenOr64 (
   @param  EndBit    The ordinal of the most significant bit in the bit field.
                     Range 0..63.
 
-  @return The value written back to the MSR.
+  @return The value read from the MSR.
 
 **/
 UINT64
diff --git a/MdePkg/Library/BaseLib/X86ReadIdtr.c b/MdePkg/Library/BaseLib/X86ReadIdtr.c
index 94b2b10a20..e0ad60b7a6 100644
--- a/MdePkg/Library/BaseLib/X86ReadIdtr.c
+++ b/MdePkg/Library/BaseLib/X86ReadIdtr.c
@@ -18,7 +18,7 @@
 #include "BaseLibInternals.h"
 
 /**
-  Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.
+  Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.
 
   Reads and returns the current IDTR descriptor and returns it in Idtr. This
   function is only available on IA-32 and x64.
diff --git a/MdePkg/Library/BaseLib/X86Thunk.c b/MdePkg/Library/BaseLib/X86Thunk.c
index 7bcde8389d..019524b605 100644
--- a/MdePkg/Library/BaseLib/X86Thunk.c
+++ b/MdePkg/Library/BaseLib/X86Thunk.c
@@ -185,11 +185,47 @@ AsmPrepareThunk16 (
   Transfers control to a 16-bit real mode entry point and returns the results.
 
   Transfers control to a 16-bit real mode entry point and returns the results.
-  AsmPrepareThunk16() must be called with ThunkContext before this function is
-  used. This function must be called with interrupts disabled.
+  AsmPrepareThunk16() must be called with ThunkContext before this function is used.
+  This function must be called with interrupts disabled.
 
+  The register state from the RealModeState field of ThunkContext is restored just prior 
+  to calling the 16-bit real mode entry point.  This includes the EFLAGS field of RealModeState, 
+  which is used to set the interrupt state when a 16-bit real mode entry point is called.
+  Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.
+  The stack is initialized to the SS and ESP fields of RealModeState.  Any parameters passed to 
+  the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function.  
+  The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,
+  so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment 
+  and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry 
+  point must exit with a RETF instruction. The register state is captured into RealModeState immediately 
+  after the RETF instruction is executed.
+  
+  If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts, 
+  or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure 
+  the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode. 
+  
+  If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts, 
+  then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode.  
+  This includes the base vectors, the interrupt masks, and the edge/level trigger mode.
+  
+  If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code 
+  is invoked in big real mode.  Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.
+  
+  If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in 
+  ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to 
+  disable the A20 mask.
+  
+  If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in 
+  ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask.  If this INT 15 call fails, 
+  then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
+  
+  If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in 
+  ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
+    
   If ThunkContext is NULL, then ASSERT().
   If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
+  If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in 
+  ThunkAttributes, then ASSERT().
 
   @param  ThunkContext  A pointer to the context structure that describes the
                         16-bit real mode code to call.
@@ -225,10 +261,9 @@ AsmThunk16 (
   caller only need to perform a single 16-bit real mode thunk, then this
   service should be used. If the caller intends to make more than one 16-bit
   real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
-  once and AsmThunk16() can be called for each 16-bit real mode thunk. This
-  function must be called with interrupts disabled.
+  once and AsmThunk16() can be called for each 16-bit real mode thunk.
 
-  If ThunkContext is NULL, then ASSERT().
+  See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.
 
   @param  ThunkContext  A pointer to the context structure that describes the
                         16-bit real mode code to call.
diff --git a/MdePkg/Library/BaseLib/X86WriteIdtr.c b/MdePkg/Library/BaseLib/X86WriteIdtr.c
index a2c5b545b9..626ffaa75c 100644
--- a/MdePkg/Library/BaseLib/X86WriteIdtr.c
+++ b/MdePkg/Library/BaseLib/X86WriteIdtr.c
@@ -18,7 +18,7 @@
 #include "BaseLibInternals.h"
 
 /**
-  Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.
+  Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.
 
   Writes the current IDTR descriptor and returns it in Idtr. This function is
   only available on IA-32 and x64.