]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BaseLib/BaseLibInternals.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdePkg / Library / BaseLib / BaseLibInternals.h
index a60310ab6f14978d5099d82f5a40b7607839ea9c..d61e60438531664bb3d197603ba81794140f567c 100644 (file)
@@ -1,14 +1,8 @@
 /** @file\r
   Declaration of internal functions in BaseLib.\r
 \r
-  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-  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
+  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -41,8 +35,8 @@
 UINT64\r
 EFIAPI\r
 InternalMathLShiftU64 (\r
-  IN      UINT64                    Operand,\r
-  IN      UINTN                     Count\r
+  IN      UINT64  Operand,\r
+  IN      UINTN   Count\r
   );\r
 \r
 /**\r
@@ -61,8 +55,8 @@ InternalMathLShiftU64 (
 UINT64\r
 EFIAPI\r
 InternalMathRShiftU64 (\r
-  IN      UINT64                    Operand,\r
-  IN      UINTN                     Count\r
+  IN      UINT64  Operand,\r
+  IN      UINTN   Count\r
   );\r
 \r
 /**\r
@@ -81,8 +75,8 @@ InternalMathRShiftU64 (
 UINT64\r
 EFIAPI\r
 InternalMathARShiftU64 (\r
-  IN      UINT64                    Operand,\r
-  IN      UINTN                     Count\r
+  IN      UINT64  Operand,\r
+  IN      UINTN   Count\r
   );\r
 \r
 /**\r
@@ -102,8 +96,8 @@ InternalMathARShiftU64 (
 UINT64\r
 EFIAPI\r
 InternalMathLRotU64 (\r
-  IN      UINT64                    Operand,\r
-  IN      UINTN                     Count\r
+  IN      UINT64  Operand,\r
+  IN      UINTN   Count\r
   );\r
 \r
 /**\r
@@ -123,8 +117,8 @@ InternalMathLRotU64 (
 UINT64\r
 EFIAPI\r
 InternalMathRRotU64 (\r
-  IN      UINT64                    Operand,\r
-  IN      UINTN                     Count\r
+  IN      UINT64  Operand,\r
+  IN      UINTN   Count\r
   );\r
 \r
 /**\r
@@ -142,7 +136,7 @@ InternalMathRRotU64 (
 UINT64\r
 EFIAPI\r
 InternalMathSwapBytes64 (\r
-  IN      UINT64                    Operand\r
+  IN      UINT64  Operand\r
   );\r
 \r
 /**\r
@@ -162,8 +156,8 @@ InternalMathSwapBytes64 (
 UINT64\r
 EFIAPI\r
 InternalMathMultU64x32 (\r
-  IN      UINT64                    Multiplicand,\r
-  IN      UINT32                    Multiplier\r
+  IN      UINT64  Multiplicand,\r
+  IN      UINT32  Multiplier\r
   );\r
 \r
 /**\r
@@ -183,8 +177,8 @@ InternalMathMultU64x32 (
 UINT64\r
 EFIAPI\r
 InternalMathMultU64x64 (\r
-  IN      UINT64                    Multiplicand,\r
-  IN      UINT64                    Multiplier\r
+  IN      UINT64  Multiplicand,\r
+  IN      UINT64  Multiplier\r
   );\r
 \r
 /**\r
@@ -204,8 +198,8 @@ InternalMathMultU64x64 (
 UINT64\r
 EFIAPI\r
 InternalMathDivU64x32 (\r
-  IN      UINT64                    Dividend,\r
-  IN      UINT32                    Divisor\r
+  IN      UINT64  Dividend,\r
+  IN      UINT32  Divisor\r
   );\r
 \r
 /**\r
@@ -225,8 +219,8 @@ InternalMathDivU64x32 (
 UINT32\r
 EFIAPI\r
 InternalMathModU64x32 (\r
-  IN      UINT64                    Dividend,\r
-  IN      UINT32                    Divisor\r
+  IN      UINT64  Dividend,\r
+  IN      UINT32  Divisor\r
   );\r
 \r
 /**\r
@@ -249,9 +243,9 @@ InternalMathModU64x32 (
 UINT64\r
 EFIAPI\r
 InternalMathDivRemU64x32 (\r
-  IN      UINT64                    Dividend,\r
-  IN      UINT32                    Divisor,\r
-  OUT     UINT32                    *Remainder OPTIONAL\r
+  IN      UINT64  Dividend,\r
+  IN      UINT32  Divisor,\r
+  OUT     UINT32  *Remainder OPTIONAL\r
   );\r
 \r
 /**\r
@@ -274,9 +268,9 @@ InternalMathDivRemU64x32 (
 UINT64\r
 EFIAPI\r
 InternalMathDivRemU64x64 (\r
-  IN      UINT64                    Dividend,\r
-  IN      UINT64                    Divisor,\r
-  OUT     UINT64                    *Remainder OPTIONAL\r
+  IN      UINT64  Dividend,\r
+  IN      UINT64  Divisor,\r
+  OUT     UINT64  *Remainder OPTIONAL\r
   );\r
 \r
 /**\r
@@ -299,9 +293,9 @@ InternalMathDivRemU64x64 (
 INT64\r
 EFIAPI\r
 InternalMathDivRemS64x64 (\r
-  IN      INT64                     Dividend,\r
-  IN      INT64                     Divisor,\r
-  OUT     INT64                     *Remainder  OPTIONAL\r
+  IN      INT64  Dividend,\r
+  IN      INT64  Divisor,\r
+  OUT     INT64  *Remainder  OPTIONAL\r
   );\r
 \r
 /**\r
@@ -332,41 +326,12 @@ VOID
 EFIAPI\r
 InternalSwitchStack (\r
   IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,\r
-  IN      VOID                      *Context1,   OPTIONAL\r
-  IN      VOID                      *Context2,   OPTIONAL\r
+  IN      VOID                      *Context1    OPTIONAL,\r
+  IN      VOID                      *Context2    OPTIONAL,\r
   IN      VOID                      *NewStack,\r
   IN      VA_LIST                   Marker\r
   );\r
 \r
-\r
-/**\r
-  Worker function that locates the Node in the List.\r
-\r
-  By searching the List, finds the location of the Node in List. At the same time,\r
-  verifies the validity of this list.\r
-\r
-  If List is NULL, then ASSERT().\r
-  If List->ForwardLink is NULL, then ASSERT().\r
-  If List->backLink is NULL, then ASSERT().\r
-  If Node is NULL, 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  List  A pointer to a node in a linked list.\r
-  @param  Node  A pointer to one nod.\r
-\r
-  @retval TRUE   Node is in List.\r
-  @retval FALSE  Node isn't in List, or List is invalid.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-IsNodeInList (\r
-  IN      CONST LIST_ENTRY      *List,\r
-  IN      CONST LIST_ENTRY      *Node\r
-  );\r
-\r
 /**\r
   Worker function that returns a bit field from Operand.\r
 \r
@@ -382,12 +347,11 @@ IsNodeInList (
 UINTN\r
 EFIAPI\r
 BitFieldReadUint (\r
-  IN      UINTN                     Operand,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit\r
+  IN      UINTN  Operand,\r
+  IN      UINTN  StartBit,\r
+  IN      UINTN  EndBit\r
   );\r
 \r
-\r
 /**\r
   Worker function that reads a bit field from Operand, performs a bitwise OR,\r
   and returns the result.\r
@@ -407,13 +371,12 @@ BitFieldReadUint (
 UINTN\r
 EFIAPI\r
 BitFieldOrUint (\r
-  IN      UINTN                     Operand,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit,\r
-  IN      UINTN                     OrData\r
+  IN      UINTN  Operand,\r
+  IN      UINTN  StartBit,\r
+  IN      UINTN  EndBit,\r
+  IN      UINTN  OrData\r
   );\r
 \r
-\r
 /**\r
   Worker function that reads a bit field from Operand, performs a bitwise AND,\r
   and returns the result.\r
@@ -433,13 +396,12 @@ BitFieldOrUint (
 UINTN\r
 EFIAPI\r
 BitFieldAndUint (\r
-  IN      UINTN                     Operand,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit,\r
-  IN      UINTN                     AndData\r
+  IN      UINTN  Operand,\r
+  IN      UINTN  StartBit,\r
+  IN      UINTN  EndBit,\r
+  IN      UINTN  AndData\r
   );\r
 \r
-\r
 /**\r
   Worker function that checks ASSERT condition for JumpBuffer\r
 \r
@@ -457,7 +419,6 @@ InternalAssertJumpBuffer (
   IN      BASE_LIBRARY_JUMP_BUFFER  *JumpBuffer\r
   );\r
 \r
-\r
 /**\r
   Restores the CPU context that was saved with SetJump().\r
 \r
@@ -476,6 +437,121 @@ InternalLongJump (
   IN      UINTN                     Value\r
   );\r
 \r
+/**\r
+  Check if a Unicode character is a decimal character.\r
+\r
+  This internal function checks if a Unicode character is a\r
+  decimal character. The valid decimal character is from\r
+  L'0' to L'9'.\r
+\r
+  @param  Char  The character to check against.\r
+\r
+  @retval TRUE  If the Char is a decmial character.\r
+  @retval FALSE If the Char is not a decmial character.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+InternalIsDecimalDigitCharacter (\r
+  IN      CHAR16  Char\r
+  );\r
+\r
+/**\r
+  Convert a Unicode character to numerical value.\r
+\r
+  This internal function only deal with Unicode character\r
+  which maps to a valid hexadecimal ASII character, i.e.\r
+  L'0' to L'9', L'a' to L'f' or L'A' to L'F'. For other\r
+  Unicode character, the value returned does not make sense.\r
+\r
+  @param  Char  The character to convert.\r
+\r
+  @return The numerical value converted.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+InternalHexCharToUintn (\r
+  IN      CHAR16  Char\r
+  );\r
+\r
+/**\r
+  Check if a Unicode character is a hexadecimal character.\r
+\r
+  This internal function checks if a Unicode character is a\r
+  decimal character.  The valid hexadecimal character is\r
+  L'0' to L'9', L'a' to L'f', or L'A' to L'F'.\r
+\r
+\r
+  @param  Char  The character to check against.\r
+\r
+  @retval TRUE  If the Char is a hexadecmial character.\r
+  @retval FALSE If the Char is not a hexadecmial character.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+InternalIsHexaDecimalDigitCharacter (\r
+  IN      CHAR16  Char\r
+  );\r
+\r
+/**\r
+  Check if a ASCII character is a decimal character.\r
+\r
+  This internal function checks if a Unicode character is a\r
+  decimal character. The valid decimal character is from\r
+  '0' to '9'.\r
+\r
+  @param  Char  The character to check against.\r
+\r
+  @retval TRUE  If the Char is a decmial character.\r
+  @retval FALSE If the Char is not a decmial character.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+InternalAsciiIsDecimalDigitCharacter (\r
+  IN      CHAR8  Char\r
+  );\r
+\r
+/**\r
+  Check if a ASCII character is a hexadecimal character.\r
+\r
+  This internal function checks if a ASCII character is a\r
+  decimal character.  The valid hexadecimal character is\r
+  L'0' to L'9', L'a' to L'f', or L'A' to L'F'.\r
+\r
+\r
+  @param  Char  The character to check against.\r
+\r
+  @retval TRUE  If the Char is a hexadecmial character.\r
+  @retval FALSE If the Char is not a hexadecmial character.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+InternalAsciiIsHexaDecimalDigitCharacter (\r
+  IN      CHAR8  Char\r
+  );\r
+\r
+/**\r
+  Convert a ASCII character to numerical value.\r
+\r
+  This internal function only deal with Unicode character\r
+  which maps to a valid hexadecimal ASII character, i.e.\r
+  '0' to '9', 'a' to 'f' or 'A' to 'F'. For other\r
+  ASCII character, the value returned does not make sense.\r
+\r
+  @param  Char  The character to convert.\r
+\r
+  @return The numerical value converted.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+InternalAsciiHexCharToUintn (\r
+  IN      CHAR8  Char\r
+  );\r
 \r
 //\r
 // Ia32 and x64 specific functions\r
@@ -494,7 +570,7 @@ InternalLongJump (
 VOID\r
 EFIAPI\r
 InternalX86ReadGdtr (\r
-  OUT     IA32_DESCRIPTOR           *Gdtr\r
+  OUT     IA32_DESCRIPTOR  *Gdtr\r
   );\r
 \r
 /**\r
@@ -509,7 +585,7 @@ InternalX86ReadGdtr (
 VOID\r
 EFIAPI\r
 InternalX86WriteGdtr (\r
-  IN      CONST IA32_DESCRIPTOR     *Gdtr\r
+  IN      CONST IA32_DESCRIPTOR  *Gdtr\r
   );\r
 \r
 /**\r
@@ -524,7 +600,7 @@ InternalX86WriteGdtr (
 VOID\r
 EFIAPI\r
 InternalX86ReadIdtr (\r
-  OUT     IA32_DESCRIPTOR           *Idtr\r
+  OUT     IA32_DESCRIPTOR  *Idtr\r
   );\r
 \r
 /**\r
@@ -539,7 +615,7 @@ InternalX86ReadIdtr (
 VOID\r
 EFIAPI\r
 InternalX86WriteIdtr (\r
-  IN      CONST IA32_DESCRIPTOR     *Idtr\r
+  IN      CONST IA32_DESCRIPTOR  *Idtr\r
   );\r
 \r
 /**\r
@@ -555,7 +631,7 @@ InternalX86WriteIdtr (
 VOID\r
 EFIAPI\r
 InternalX86FxSave (\r
-  OUT     IA32_FX_BUFFER            *Buffer\r
+  OUT     IA32_FX_BUFFER  *Buffer\r
   );\r
 \r
 /**\r
@@ -571,7 +647,7 @@ InternalX86FxSave (
 VOID\r
 EFIAPI\r
 InternalX86FxRestore (\r
-  IN      CONST IA32_FX_BUFFER      *Buffer\r
+  IN      CONST IA32_FX_BUFFER  *Buffer\r
   );\r
 \r
 /**\r
@@ -611,8 +687,8 @@ VOID
 EFIAPI\r
 InternalX86EnablePaging32 (\r
   IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,\r
-  IN      VOID                      *Context1,  OPTIONAL\r
-  IN      VOID                      *Context2,  OPTIONAL\r
+  IN      VOID                      *Context1   OPTIONAL,\r
+  IN      VOID                      *Context2   OPTIONAL,\r
   IN      VOID                      *NewStack\r
   );\r
 \r
@@ -650,8 +726,8 @@ VOID
 EFIAPI\r
 InternalX86DisablePaging32 (\r
   IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,\r
-  IN      VOID                      *Context1,  OPTIONAL\r
-  IN      VOID                      *Context2,  OPTIONAL\r
+  IN      VOID                      *Context1   OPTIONAL,\r
+  IN      VOID                      *Context2   OPTIONAL,\r
   IN      VOID                      *NewStack\r
   );\r
 \r
@@ -685,11 +761,11 @@ InternalX86DisablePaging32 (
 VOID\r
 EFIAPI\r
 InternalX86EnablePaging64 (\r
-  IN      UINT16                    Cs,\r
-  IN      UINT64                    EntryPoint,\r
-  IN      UINT64                    Context1,  OPTIONAL\r
-  IN      UINT64                    Context2,  OPTIONAL\r
-  IN      UINT64                    NewStack\r
+  IN      UINT16  Cs,\r
+  IN      UINT64  EntryPoint,\r
+  IN      UINT64  Context1   OPTIONAL,\r
+  IN      UINT64  Context2   OPTIONAL,\r
+  IN      UINT64  NewStack\r
   );\r
 \r
 /**\r
@@ -721,931 +797,57 @@ InternalX86EnablePaging64 (
 VOID\r
 EFIAPI\r
 InternalX86DisablePaging64 (\r
-  IN      UINT16                    Cs,\r
-  IN      UINT32                    EntryPoint,\r
-  IN      UINT32                    Context1,  OPTIONAL\r
-  IN      UINT32                    Context2,  OPTIONAL\r
-  IN      UINT32                    NewStack\r
-  );\r
-\r
-\r
-#elif defined (MDE_CPU_IPF)\r
-//\r
-//\r
-// IPF specific functions\r
-//\r
-\r
-/**\r
-  Reads control register DCR.\r
-\r
-  This is a worker function for AsmReadControlRegister()\r
-  when its parameter Index is IPF_CONTROL_REGISTER_DCR.\r
-\r
-  @return The 64-bit control register DCR.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadControlRegisterDcr (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads control register ITM.\r
-\r
-  This is a worker function for AsmReadControlRegister()\r
-  when its parameter Index is IPF_CONTROL_REGISTER_ITM.\r
-\r
-  @return The 64-bit control register ITM.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadControlRegisterItm (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads control register IVA.\r
-\r
-  This is a worker function for AsmReadControlRegister()\r
-  when its parameter Index is IPF_CONTROL_REGISTER_IVA.\r
-\r
-  @return The 64-bit control register IVA.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadControlRegisterIva (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads control register PTA.\r
-\r
-  This is a worker function for AsmReadControlRegister()\r
-  when its parameter Index is IPF_CONTROL_REGISTER_PTA.\r
-\r
-  @return The 64-bit control register PTA.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadControlRegisterPta (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads control register IPSR.\r
-\r
-  This is a worker function for AsmReadControlRegister()\r
-  when its parameter Index is IPF_CONTROL_REGISTER_IPSR.\r
-\r
-  @return The 64-bit control register IPSR.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadControlRegisterIpsr (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads control register ISR.\r
-\r
-  This is a worker function for AsmReadControlRegister()\r
-  when its parameter Index is IPF_CONTROL_REGISTER_ISR.\r
-\r
-  @return The 64-bit control register ISR.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadControlRegisterIsr (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads control register IIP.\r
-\r
-  This is a worker function for AsmReadControlRegister()\r
-  when its parameter Index is IPF_CONTROL_REGISTER_IIP.\r
-\r
-  @return The 64-bit control register IIP.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadControlRegisterIip (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads control register IFA.\r
-\r
-  This is a worker function for AsmReadControlRegister()\r
-  when its parameter Index is IPF_CONTROL_REGISTER_IFA.\r
-\r
-  @return The 64-bit control register IFA.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadControlRegisterIfa (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads control register ITIR.\r
-\r
-  This is a worker function for AsmReadControlRegister()\r
-  when its parameter Index is IPF_CONTROL_REGISTER_ITIR.\r
-\r
-  @return The 64-bit control register ITIR.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadControlRegisterItir (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads control register IIPA.\r
-\r
-  This is a worker function for AsmReadControlRegister()\r
-  when its parameter Index is IPF_CONTROL_REGISTER_IIPA.\r
-\r
-  @return The 64-bit control register IIPA.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadControlRegisterIipa (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads control register IFS.\r
-\r
-  This is a worker function for AsmReadControlRegister()\r
-  when its parameter Index is IPF_CONTROL_REGISTER_IFS.\r
-\r
-  @return The 64-bit control register IFS.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadControlRegisterIfs (\r
-  VOID\r
+  IN      UINT16  Cs,\r
+  IN      UINT32  EntryPoint,\r
+  IN      UINT32  Context1   OPTIONAL,\r
+  IN      UINT32  Context2   OPTIONAL,\r
+  IN      UINT32  NewStack\r
   );\r
 \r
-\r
-/**\r
-  Reads control register IIM.\r
-\r
-  This is a worker function for AsmReadControlRegister()\r
-  when its parameter Index is IPF_CONTROL_REGISTER_IIM.\r
-\r
-  @return The 64-bit control register IIM.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadControlRegisterIim (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads control register IHA.\r
-\r
-  This is a worker function for AsmReadControlRegister()\r
-  when its parameter Index is IPF_CONTROL_REGISTER_IHA.\r
-\r
-  @return The 64-bit control register IHA.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadControlRegisterIha (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads control register LID.\r
-\r
-  This is a worker function for AsmReadControlRegister()\r
-  when its parameter Index is IPF_CONTROL_REGISTER_LID.\r
-\r
-  @return The 64-bit control register LID.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadControlRegisterLid (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads control register IVR.\r
-\r
-  This is a worker function for AsmReadControlRegister()\r
-  when its parameter Index is IPF_CONTROL_REGISTER_IVR.\r
-\r
-  @return The 64-bit control register IVR.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadControlRegisterIvr (\r
-  VOID\r
-  );\r
-\r
-\r
 /**\r
-  Reads control register TPR.\r
+  Generates a 16-bit random number through RDRAND instruction.\r
 \r
-  This is a worker function for AsmReadControlRegister()\r
-  when its parameter Index is IPF_CONTROL_REGISTER_TPR.\r
+  @param[out]  Rand     Buffer pointer to store the random result.\r
 \r
-  @return The 64-bit control register TPR.\r
+  @retval TRUE          RDRAND call was successful.\r
+  @retval FALSE         Failed attempts to call RDRAND.\r
 \r
-**/\r
-UINT64\r
+ **/\r
+BOOLEAN\r
 EFIAPI\r
-AsmReadControlRegisterTpr (\r
-  VOID\r
+InternalX86RdRand16 (\r
+  OUT     UINT16  *Rand\r
   );\r
 \r
-\r
 /**\r
-  Reads control register EOI.\r
+  Generates a 32-bit random number through RDRAND instruction.\r
 \r
-  This is a worker function for AsmReadControlRegister()\r
-  when its parameter Index is IPF_CONTROL_REGISTER_EOI.\r
+  @param[out]  Rand     Buffer pointer to store the random result.\r
 \r
-  @return The 64-bit control register EOI.\r
+  @retval TRUE          RDRAND call was successful.\r
+  @retval FALSE         Failed attempts to call RDRAND.\r
 \r
 **/\r
-UINT64\r
+BOOLEAN\r
 EFIAPI\r
-AsmReadControlRegisterEoi (\r
-  VOID\r
+InternalX86RdRand32 (\r
+  OUT     UINT32  *Rand\r
   );\r
 \r
-\r
 /**\r
-  Reads control register IRR0.\r
+  Generates a 64-bit random number through RDRAND instruction.\r
 \r
-  This is a worker function for AsmReadControlRegister()\r
-  when its parameter Index is IPF_CONTROL_REGISTER_IRR0.\r
 \r
-  @return The 64-bit control register IRR0.\r
+  @param[out]  Rand     Buffer pointer to store the random result.\r
 \r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadControlRegisterIrr0 (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads control register IRR1.\r
-\r
-  This is a worker function for AsmReadControlRegister()\r
-  when its parameter Index is IPF_CONTROL_REGISTER_IRR1.\r
-\r
-  @return The 64-bit control register IRR1.\r
+  @retval TRUE          RDRAND call was successful.\r
+  @retval FALSE         Failed attempts to call RDRAND.\r
 \r
 **/\r
-UINT64\r
-EFIAPI\r
-AsmReadControlRegisterIrr1 (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads control register IRR2.\r
-\r
-  This is a worker function for AsmReadControlRegister()\r
-  when its parameter Index is IPF_CONTROL_REGISTER_IRR2.\r
-\r
-  @return The 64-bit control register IRR2.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadControlRegisterIrr2 (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads control register IRR3.\r
-\r
-  This is a worker function for AsmReadControlRegister()\r
-  when its parameter Index is IPF_CONTROL_REGISTER_IRR3.\r
-\r
-  @return The 64-bit control register IRR3.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadControlRegisterIrr3 (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads control register ITV.\r
-\r
-  This is a worker function for AsmReadControlRegister()\r
-  when its parameter Index is IPF_CONTROL_REGISTER_ITV.\r
-\r
-  @return The 64-bit control register ITV.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadControlRegisterItv (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads control register PMV.\r
-\r
-  This is a worker function for AsmReadControlRegister()\r
-  when its parameter Index is IPF_CONTROL_REGISTER_PMV.\r
-\r
-  @return The 64-bit control register PMV.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadControlRegisterPmv (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads control register CMCV.\r
-\r
-  This is a worker function for AsmReadControlRegister()\r
-  when its parameter Index is IPF_CONTROL_REGISTER_CMCV.\r
-\r
-  @return The 64-bit control register CMCV.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadControlRegisterCmcv (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads control register LRR0.\r
-\r
-  This is a worker function for AsmReadControlRegister()\r
-  when its parameter Index is IPF_CONTROL_REGISTER_LRR0.\r
-\r
-  @return The 64-bit control register LRR0.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadControlRegisterLrr0 (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads control register LRR1.\r
-\r
-  This is a worker function for AsmReadControlRegister()\r
-  when its parameter Index is IPF_CONTROL_REGISTER_LRR1.\r
-\r
-  @return The 64-bit control register LRR1.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadControlRegisterLrr1 (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads application register K0.\r
-\r
-  This is a worker function for AsmReadApplicationRegister()\r
-  when its parameter Index is IPF_APPLICATION_REGISTER_K0.\r
-\r
-  @return The 64-bit application register K0.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadApplicationRegisterK0 (\r
-  VOID\r
-  );\r
-\r
-\r
-\r
-/**\r
-  Reads application register K1.\r
-\r
-  This is a worker function for AsmReadApplicationRegister()\r
-  when its parameter Index is IPF_APPLICATION_REGISTER_K1.\r
-\r
-  @return The 64-bit application register K1.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadApplicationRegisterK1 (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads application register K2.\r
-\r
-  This is a worker function for AsmReadApplicationRegister()\r
-  when its parameter Index is IPF_APPLICATION_REGISTER_K2.\r
-\r
-  @return The 64-bit application register K2.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadApplicationRegisterK2 (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads application register K3.\r
-\r
-  This is a worker function for AsmReadApplicationRegister()\r
-  when its parameter Index is IPF_APPLICATION_REGISTER_K3.\r
-\r
-  @return The 64-bit application register K3.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadApplicationRegisterK3 (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads application register K4.\r
-\r
-  This is a worker function for AsmReadApplicationRegister()\r
-  when its parameter Index is IPF_APPLICATION_REGISTER_K4.\r
-\r
-  @return The 64-bit application register K4.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadApplicationRegisterK4 (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads application register K5.\r
-\r
-  This is a worker function for AsmReadApplicationRegister()\r
-  when its parameter Index is IPF_APPLICATION_REGISTER_K5.\r
-\r
-  @return The 64-bit application register K5.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadApplicationRegisterK5 (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads application register K6.\r
-\r
-  This is a worker function for AsmReadApplicationRegister()\r
-  when its parameter Index is IPF_APPLICATION_REGISTER_K6.\r
-\r
-  @return The 64-bit application register K6.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadApplicationRegisterK6 (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads application register K7.\r
-\r
-  This is a worker function for AsmReadApplicationRegister()\r
-  when its parameter Index is IPF_APPLICATION_REGISTER_K7.\r
-\r
-  @return The 64-bit application register K7.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadApplicationRegisterK7 (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads application register RSC.\r
-\r
-  This is a worker function for AsmReadApplicationRegister()\r
-  when its parameter Index is IPF_APPLICATION_REGISTER_RSC.\r
-\r
-  @return The 64-bit application register RSC.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadApplicationRegisterRsc (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads application register BSP.\r
-\r
-  This is a worker function for AsmReadApplicationRegister()\r
-  when its parameter Index is IPF_APPLICATION_REGISTER_BSP.\r
-\r
-  @return The 64-bit application register BSP.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadApplicationRegisterBsp (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads application register BSPSTORE.\r
-\r
-  This is a worker function for AsmReadApplicationRegister()\r
-  when its parameter Index is IPF_APPLICATION_REGISTER_BSPSTORE.\r
-\r
-  @return The 64-bit application register BSPSTORE.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadApplicationRegisterBspstore (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads application register RNAT.\r
-\r
-  This is a worker function for AsmReadApplicationRegister()\r
-  when its parameter Index is IPF_APPLICATION_REGISTER_RNAT.\r
-\r
-  @return The 64-bit application register RNAT.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadApplicationRegisterRnat (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads application register FCR.\r
-\r
-  This is a worker function for AsmReadApplicationRegister()\r
-  when its parameter Index is IPF_APPLICATION_REGISTER_FCR.\r
-\r
-  @return The 64-bit application register FCR.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadApplicationRegisterFcr (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads application register EFLAG.\r
-\r
-  This is a worker function for AsmReadApplicationRegister()\r
-  when its parameter Index is IPF_APPLICATION_REGISTER_EFLAG.\r
-\r
-  @return The 64-bit application register EFLAG.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadApplicationRegisterEflag (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads application register CSD.\r
-\r
-  This is a worker function for AsmReadApplicationRegister()\r
-  when its parameter Index is IPF_APPLICATION_REGISTER_CSD.\r
-\r
-  @return The 64-bit application register CSD.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadApplicationRegisterCsd (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads application register SSD.\r
-\r
-  This is a worker function for AsmReadApplicationRegister()\r
-  when its parameter Index is IPF_APPLICATION_REGISTER_SSD.\r
-\r
-  @return The 64-bit application register SSD.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadApplicationRegisterSsd (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads application register CFLG.\r
-\r
-  This is a worker function for AsmReadApplicationRegister()\r
-  when its parameter Index is IPF_APPLICATION_REGISTER_CFLG.\r
-\r
-  @return The 64-bit application register CFLG.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadApplicationRegisterCflg (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads application register FSR.\r
-\r
-  This is a worker function for AsmReadApplicationRegister()\r
-  when its parameter Index is IPF_APPLICATION_REGISTER_FSR.\r
-\r
-  @return The 64-bit application register FSR.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadApplicationRegisterFsr (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads application register FIR.\r
-\r
-  This is a worker function for AsmReadApplicationRegister()\r
-  when its parameter Index is IPF_APPLICATION_REGISTER_FIR.\r
-\r
-  @return The 64-bit application register FIR.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadApplicationRegisterFir (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads application register FDR.\r
-\r
-  This is a worker function for AsmReadApplicationRegister()\r
-  when its parameter Index is IPF_APPLICATION_REGISTER_FDR.\r
-\r
-  @return The 64-bit application register FDR.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadApplicationRegisterFdr (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads application register CCV.\r
-\r
-  This is a worker function for AsmReadApplicationRegister()\r
-  when its parameter Index is IPF_APPLICATION_REGISTER_CCV.\r
-\r
-  @return The 64-bit application register CCV.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadApplicationRegisterCcv (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads application register UNAT.\r
-\r
-  This is a worker function for AsmReadApplicationRegister()\r
-  when its parameter Index is IPF_APPLICATION_REGISTER_UNAT.\r
-\r
-  @return The 64-bit application register UNAT.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadApplicationRegisterUnat (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads application register FPSR.\r
-\r
-  This is a worker function for AsmReadApplicationRegister()\r
-  when its parameter Index is IPF_APPLICATION_REGISTER_FPSR.\r
-\r
-  @return The 64-bit application register FPSR.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadApplicationRegisterFpsr (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads application register ITC.\r
-\r
-  This is a worker function for AsmReadApplicationRegister()\r
-  when its parameter Index is IPF_APPLICATION_REGISTER_ITC.\r
-\r
-  @return The 64-bit application register ITC.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadApplicationRegisterItc (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads application register PFS.\r
-\r
-  This is a worker function for AsmReadApplicationRegister()\r
-  when its parameter Index is IPF_APPLICATION_REGISTER_PFS.\r
-\r
-  @return The 64-bit application register PFS.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadApplicationRegisterPfs (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads application register LC.\r
-\r
-  This is a worker function for AsmReadApplicationRegister()\r
-  when its parameter Index is IPF_APPLICATION_REGISTER_LC.\r
-\r
-  @return The 64-bit application register LC.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadApplicationRegisterLc (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Reads application register EC.\r
-\r
-  This is a worker function for AsmReadApplicationRegister()\r
-  when its parameter Index is IPF_APPLICATION_REGISTER_EC.\r
-\r
-  @return The 64-bit application register EC.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadApplicationRegisterEc (\r
-  VOID\r
-  );\r
-\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
-/**\r
-  Internal worker function to invalidate a range of instruction cache lines\r
-  in the cache coherency domain of the calling CPU.\r
-\r
-  Internal worker function to invalidate the instruction cache lines specified\r
-  by Address and Length. If Address is not aligned on a cache line boundary,\r
-  then entire instruction cache line containing Address is invalidated. If\r
-  Address + Length is not aligned on a cache line boundary, then the entire\r
-  instruction cache line containing Address + Length -1 is invalidated. This\r
-  function may choose to invalidate the entire instruction cache if that is more\r
-  efficient than invalidating the specified range. If Length is 0, the no instruction\r
-  cache lines are invalidated. Address is returned.\r
-  This function is only available on IPF.\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
+BOOLEAN\r
 EFIAPI\r
-InternalFlushCacheRange (\r
-  IN      VOID                      *Address,\r
-  IN      UINTN                     Length\r
+InternalX86RdRand64  (\r
+  OUT     UINT64  *Rand\r
   );\r
 \r
 #else\r