]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BaseLib/BaseLibInternals.h
1. added functions header for BaseUefiDecompressLi
[mirror_edk2.git] / MdePkg / Library / BaseLib / BaseLibInternals.h
index 0c32e1bd2c46b74cbf2620bf298f4c30e7a8ab26..3a4ff07f069977d22233b9506a482b6586c2c095 100644 (file)
 // Math functions\r
 //\r
 \r
+/**\r
+  Worker functons that shifts a 64-bit integer left between 0 and 63 bits. The low bits\r
+  are filled with zeros. The shifted value is returned.\r
+\r
+  This function shifts the 64-bit value Operand to the left by Count bits. The\r
+  low Count bits are set to zero. The shifted value is returned.\r
+\r
+  @param  Operand The 64-bit operand to shift left.\r
+  @param  Count   The number of bits to shift left.\r
+\r
+  @return Operand << Count\r
+\r
+**/\r
 UINT64\r
 EFIAPI\r
 InternalMathLShiftU64 (\r
@@ -28,6 +41,19 @@ InternalMathLShiftU64 (
   IN      UINTN                     Count\r
   );\r
 \r
+/**\r
+  Worker functon that shifts a 64-bit integer right between 0 and 63 bits. This high bits \r
+  are filled with zeros. The shifted value is returned.\r
+\r
+  This function shifts the 64-bit value Operand to the right by Count bits. The\r
+  high Count bits are set to zero. The shifted value is returned.\r
+\r
+  @param  Operand The 64-bit operand to shift right.\r
+  @param  Count   The number of bits to shift right.\r
+\r
+  @return Operand >> Count\r
+\r
+**/\r
 UINT64\r
 EFIAPI\r
 InternalMathRShiftU64 (\r
@@ -35,6 +61,19 @@ InternalMathRShiftU64 (
   IN      UINTN                     Count\r
   );\r
 \r
+/**\r
+  Worker function that shifts a 64-bit integer right between 0 and 63 bits. The high bits\r
+  are filled with original integer's bit 63. The shifted value is returned.\r
+\r
+  This function shifts the 64-bit value Operand to the right by Count bits. The\r
+  high Count bits are set to bit 63 of Operand.  The shifted value is returned.\r
+\r
+  @param  Operand The 64-bit operand to shift right.\r
+  @param  Count   The number of bits to shift right.\r
+\r
+  @return Operand arithmetically shifted right by Count\r
+\r
+**/\r
 UINT64\r
 EFIAPI\r
 InternalMathARShiftU64 (\r
@@ -42,6 +81,20 @@ InternalMathARShiftU64 (
   IN      UINTN                     Count\r
   );\r
 \r
+/**\r
+  Worker function that rotates a 64-bit integer left between 0 and 63 bits, filling \r
+  the low bits with the high bits that were rotated.\r
+\r
+  This function rotates the 64-bit value Operand to the left by Count bits. The\r
+  low Count bits are fill with the high Count bits of Operand. The rotated\r
+  value is returned.\r
+\r
+  @param  Operand The 64-bit operand to rotate left.\r
+  @param  Count   The number of bits to rotate left.\r
+\r
+  @return Operand <<< Count\r
+\r
+**/\r
 UINT64\r
 EFIAPI\r
 InternalMathLRotU64 (\r
@@ -49,6 +102,20 @@ InternalMathLRotU64 (
   IN      UINTN                     Count\r
   );\r
 \r
+/**\r
+  Worker function that rotates a 64-bit integer right between 0 and 63 bits, filling\r
+  the high bits with the high low bits that were rotated.\r
+\r
+  This function rotates the 64-bit value Operand to the right by Count bits.\r
+  The high Count bits are fill with the low Count bits of Operand. The rotated\r
+  value is returned.\r
+\r
+  @param  Operand The 64-bit operand to rotate right.\r
+  @param  Count   The number of bits to rotate right.\r
+\r
+  @return Operand >>> Count\r
+\r
+**/\r
 UINT64\r
 EFIAPI\r
 InternalMathRRotU64 (\r
@@ -56,12 +123,38 @@ InternalMathRRotU64 (
   IN      UINTN                     Count\r
   );\r
 \r
+/**\r
+  Worker function that switches the endianess of a 64-bit integer.\r
+\r
+  This function swaps the bytes in a 64-bit unsigned value to switch the value\r
+  from little endian to big endian or vice versa. The byte swapped value is\r
+  returned.\r
+\r
+  @param  Operand A 64-bit unsigned value.\r
+\r
+  @return The byte swaped Operand.\r
+\r
+**/\r
 UINT64\r
 EFIAPI\r
 InternalMathSwapBytes64 (\r
   IN      UINT64                    Operand\r
   );\r
 \r
+/**\r
+  Worker function that multiples a 64-bit unsigned integer by a 32-bit unsigned integer\r
+  and generates a 64-bit unsigned result.\r
+\r
+  This function multiples the 64-bit unsigned value Multiplicand by the 32-bit\r
+  unsigned value Multiplier and generates a 64-bit unsigned result. This 64-\r
+  bit unsigned result is returned.\r
+\r
+  @param  Multiplicand  A 64-bit unsigned value.\r
+  @param  Multiplier    A 32-bit unsigned value.\r
+\r
+  @return Multiplicand * Multiplier\r
+\r
+**/\r
 UINT64\r
 EFIAPI\r
 InternalMathMultU64x32 (\r
@@ -69,6 +162,20 @@ InternalMathMultU64x32 (
   IN      UINT32                    Multiplier\r
   );\r
 \r
+/**\r
+  Worker function that multiples a 64-bit unsigned integer by a 64-bit unsigned integer\r
+  and generates a 64-bit unsigned result.\r
+\r
+  This function multiples the 64-bit unsigned value Multiplicand by the 64-bit\r
+  unsigned value Multiplier and generates a 64-bit unsigned result. This 64-\r
+  bit unsigned result is returned.\r
+\r
+  @param  Multiplicand  A 64-bit unsigned value.\r
+  @param  Multiplier    A 64-bit unsigned value.\r
+\r
+  @return Multiplicand * Multiplier\r
+\r
+**/\r
 UINT64\r
 EFIAPI\r
 InternalMathMultU64x64 (\r
@@ -76,6 +183,20 @@ InternalMathMultU64x64 (
   IN      UINT64                    Multiplier\r
   );\r
 \r
+/**\r
+  Worker function that divides a 64-bit unsigned integer by a 32-bit unsigned integer and \r
+  generates a 64-bit unsigned result.\r
\r
+  This function divides the 64-bit unsigned value Dividend by the 32-bit\r
+  unsigned value Divisor and generates a 64-bit unsigned quotient. This\r
+  function returns the 64-bit unsigned quotient.\r
+\r
+   @param  Dividend  A 64-bit unsigned value.\r
+  @param  Divisor   A 32-bit unsigned value.\r
+\r
+  @return Dividend / Divisor\r
+\r
+**/\r
 UINT64\r
 EFIAPI\r
 InternalMathDivU64x32 (\r
@@ -83,6 +204,20 @@ InternalMathDivU64x32 (
   IN      UINT32                    Divisor\r
   );\r
 \r
+/**\r
+  Worker function that divides a 64-bit unsigned integer by a 32-bit unsigned integer and \r
+  generates a 32-bit unsigned remainder.\r
+\r
+  This function divides the 64-bit unsigned value Dividend by the 32-bit\r
+  unsigned value Divisor and generates a 32-bit remainder. This function\r
+  returns the 32-bit unsigned remainder.\r
+\r
+  @param  Dividend  A 64-bit unsigned value.\r
+  @param  Divisor   A 32-bit unsigned value.\r
+\r
+  @return Dividend % Divisor\r
+\r
+**/\r
 UINT32\r
 EFIAPI\r
 InternalMathModU64x32 (\r
@@ -90,6 +225,23 @@ InternalMathModU64x32 (
   IN      UINT32                    Divisor\r
   );\r
 \r
+/**\r
+  Worker function that divides a 64-bit unsigned integer by a 32-bit unsigned integer and\r
+  generates a 64-bit unsigned result and an optional 32-bit unsigned remainder.\r
+\r
+  This function divides the 64-bit unsigned value Dividend by the 32-bit\r
+  unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r
+  is not NULL, then the 32-bit unsigned remainder is returned in Remainder.\r
+  This function returns the 64-bit unsigned quotient.\r
+\r
+  @param  Dividend  A 64-bit unsigned value.\r
+  @param  Divisor   A 32-bit unsigned value.\r
+  @param  Remainder A pointer to a 32-bit unsigned value. This parameter is\r
+                    optional and may be NULL.\r
+\r
+  @return Dividend / Divisor\r
+\r
+**/\r
 UINT64\r
 EFIAPI\r
 InternalMathDivRemU64x32 (\r
@@ -98,6 +250,23 @@ InternalMathDivRemU64x32 (
   OUT     UINT32                    *Remainder\r
   );\r
 \r
+/**\r
+  Worker function that divides a 64-bit unsigned integer by a 64-bit unsigned integer and \r
+  generates a 64-bit unsigned result and an optional 64-bit unsigned remainder.\r
+\r
+  This function divides the 64-bit unsigned value Dividend by the 64-bit\r
+  unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r
+  is not NULL, then the 64-bit unsigned remainder is returned in Remainder.\r
+  This function returns the 64-bit unsigned quotient.\r
+\r
+  @param  Dividend  A 64-bit unsigned value.\r
+  @param  Divisor   A 64-bit unsigned value.\r
+  @param  Remainder A pointer to a 64-bit unsigned value. This parameter is\r
+                    optional and may be NULL.\r
+\r
+  @return Dividend / Divisor\r
+\r
+**/\r
 UINT64\r
 EFIAPI\r
 InternalMathDivRemU64x64 (\r
@@ -106,16 +275,48 @@ InternalMathDivRemU64x64 (
   OUT     UINT64                    *Remainder\r
   );\r
 \r
+/**\r
+  Worker function that divides a 64-bit signed integer by a 64-bit signed integer and \r
+  generates a  64-bit signed result and a optional 64-bit signed remainder.\r
+\r
+  This function divides the 64-bit unsigned value Dividend by the 64-bit\r
+  unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r
+  is not NULL, then the 64-bit unsigned remainder is returned in Remainder.\r
+  This function returns the 64-bit unsigned quotient.\r
+\r
+  @param  Dividend  A 64-bit signed value.\r
+  @param  Divisor   A 64-bit signed value.\r
+  @param  Remainder A pointer to a 64-bit signed value. This parameter is\r
+                    optional and may be NULL.\r
+\r
+  @return Dividend / Divisor\r
+\r
+**/\r
 INT64\r
-EFIAPI\r
 InternalMathDivRemS64x64 (\r
   IN      INT64                     Dividend,\r
   IN      INT64                     Divisor,\r
-  OUT     INT64                     *Remainder\r
+  OUT     INT64                     *Remainder  OPTIONAL\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
+  @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
+\r
+**/\r
 VOID\r
-EFIAPI\r
 InternalSwitchStack (\r
   IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,\r
   IN      VOID                      *Context1,\r
@@ -127,42 +328,131 @@ InternalSwitchStack (
 // Ia32 and x64 specific functions\r
 //\r
 \r
+/**\r
+  Reads the current Global Descriptor Table Register(GDTR) descriptor.\r
+\r
+  Reads and returns the current GDTR descriptor and returns it in Gdtr. This\r
+  function is only available on IA-32 and X64.\r
+\r
+  @param  Gdtr  Pointer to a GDTR descriptor.\r
+\r
+**/\r
 VOID\r
 EFIAPI\r
 InternalX86ReadGdtr (\r
   OUT     IA32_DESCRIPTOR           *Gdtr\r
   );\r
 \r
+/**\r
+  Writes the current Global Descriptor Table Register (GDTR) descriptor.\r
+\r
+  Writes and the current GDTR descriptor specified by Gdtr. This function is\r
+  only available on IA-32 and X64.\r
+\r
+  @param  Gdtr  Pointer to a GDTR descriptor.\r
+\r
+**/\r
 VOID\r
 EFIAPI\r
 InternalX86WriteGdtr (\r
   IN      CONST IA32_DESCRIPTOR     *Gdtr\r
   );\r
 \r
+/**\r
+  Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.\r
+\r
+  Reads and returns the current IDTR descriptor and returns it in Idtr. This\r
+  function is only available on IA-32 and X64.\r
+\r
+  @param  Idtr  Pointer to a IDTR descriptor.\r
+\r
+**/\r
 VOID\r
 EFIAPI\r
 InternalX86ReadIdtr (\r
   OUT     IA32_DESCRIPTOR           *Idtr\r
   );\r
 \r
+/**\r
+  Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.\r
+\r
+  Writes the current IDTR descriptor and returns it in Idtr. This function is\r
+  only available on IA-32 and X64.\r
+\r
+  @param  Idtr  Pointer to a IDTR descriptor.\r
+\r
+**/\r
 VOID\r
 EFIAPI\r
 InternalX86WriteIdtr (\r
   IN      CONST IA32_DESCRIPTOR     *Idtr\r
   );\r
 \r
+/**\r
+  Save the current floating point/SSE/SSE2 context to a buffer.\r
+\r
+  Saves the current floating point/SSE/SSE2 state to the buffer specified by\r
+  Buffer. Buffer must be aligned on a 16-byte boundary. This function is only\r
+  available on IA-32 and X64.\r
+\r
+  @param  Buffer  Pointer to a buffer to save the floating point/SSE/SSE2 context.\r
+\r
+**/\r
 VOID\r
 EFIAPI\r
 InternalX86FxSave (\r
   OUT     IA32_FX_BUFFER            *Buffer\r
   );\r
 \r
+/**\r
+  Restores the current floating point/SSE/SSE2 context from a buffer.\r
+\r
+  Restores the current floating point/SSE/SSE2 state from the buffer specified\r
+  by Buffer. Buffer must be aligned on a 16-byte boundary. This function is\r
+  only available on IA-32 and X64.\r
+\r
+  @param  Buffer  Pointer to a buffer to save the floating point/SSE/SSE2 context.\r
+\r
+**/\r
 VOID\r
 EFIAPI\r
 InternalX86FxRestore (\r
   IN      CONST IA32_FX_BUFFER      *Buffer\r
   );\r
 \r
+/**\r
+  Enables the 32-bit paging mode on the CPU.\r
+\r
+  Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r
+  must be properly initialized prior to calling this service. This function\r
+  assumes the current execution mode is 32-bit protected mode. This function is\r
+  only available on IA-32. After the 32-bit paging mode is enabled, control is\r
+  transferred 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
+  There are a number of constraints that must be followed before calling this\r
+  function:\r
+  1)  Interrupts must be disabled.\r
+  2)  The caller must be in 32-bit protected mode with flat descriptors. This\r
+      means all descriptors must have a base of 0 and a limit of 4GB.\r
+  3)  CR0 and CR4 must be compatible with 32-bit protected mode with flat\r
+      descriptors.\r
+  4)  CR3 must point to valid page tables that will be used once the transition\r
+      is complete, and those page tables must guarantee that the pages for this\r
+      function and the stack are identity mapped.\r
+\r
+  @param  EntryPoint  A pointer to function to call with the new stack after\r
+                      paging is enabled.\r
+  @param  Context1    A pointer to the context to pass into the EntryPoint\r
+                      function as the first parameter after paging is enabled.\r
+  @param  Context2    A pointer to the context to pass into the EntryPoint\r
+                      function as the second parameter after paging is enabled.\r
+  @param  NewStack    A pointer to the new stack to use for the EntryPoint\r
+                      function after paging is enabled.\r
+\r
+**/\r
 VOID\r
 EFIAPI\r
 InternalX86EnablePaging32 (\r
@@ -172,6 +462,36 @@ InternalX86EnablePaging32 (
   IN      VOID                      *NewStack\r
   );\r
 \r
+/**\r
+  Disables the 32-bit paging mode on the CPU.\r
+\r
+  Disables the 32-bit paging mode on the CPU and returns to 32-bit protected\r
+  mode. This function assumes the current execution mode is 32-paged protected\r
+  mode. This function is only available on IA-32. After the 32-bit paging mode\r
+  is disabled, control is transferred to the function specified by EntryPoint\r
+  using the new stack specified by NewStack and passing in the parameters\r
+  specified by Context1 and Context2. Context1 and Context2 are optional and\r
+  may be NULL. The function EntryPoint must never return.\r
+\r
+  There are a number of constraints that must be followed before calling this\r
+  function:\r
+  1)  Interrupts must be disabled.\r
+  2)  The caller must be in 32-bit paged mode.\r
+  3)  CR0, CR3, and CR4 must be compatible with 32-bit paged mode.\r
+  4)  CR3 must point to valid page tables that guarantee that the pages for\r
+      this function and the stack are identity mapped.\r
+\r
+  @param  EntryPoint  A pointer to function to call with the new stack after\r
+                      paging is disabled.\r
+  @param  Context1    A pointer to the context to pass into the EntryPoint\r
+                      function as the first parameter after paging is disabled.\r
+  @param  Context2    A pointer to the context to pass into the EntryPoint\r
+                      function as the second parameter after paging is\r
+                      disabled.\r
+  @param  NewStack    A pointer to the new stack to use for the EntryPoint\r
+                      function after paging is disabled.\r
+\r
+**/\r
 VOID\r
 EFIAPI\r
 InternalX86DisablePaging32 (\r
@@ -181,6 +501,33 @@ InternalX86DisablePaging32 (
   IN      VOID                      *NewStack\r
   );\r
 \r
+/**\r
+  Enables the 64-bit paging mode on the CPU.\r
+\r
+  Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r
+  must be properly initialized prior to calling this service. This function\r
+  assumes the current execution mode is 32-bit protected mode with flat\r
+  descriptors. This function is only available on IA-32. After the 64-bit\r
+  paging mode is enabled, control is transferred to the function specified by\r
+  EntryPoint using the new stack specified by NewStack and passing in the\r
+  parameters specified by Context1 and Context2. Context1 and Context2 are\r
+  optional and may be 0. The function EntryPoint must never return.\r
+\r
+  @param  Cs          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
+                      the new stack after paging is enabled.\r
+  @param  Context1    The 64-bit virtual address of the context to pass into\r
+                      the EntryPoint function as the first parameter after\r
+                      paging is enabled.\r
+  @param  Context2    The 64-bit virtual address of the context to pass into\r
+                      the EntryPoint function as the second parameter after\r
+                      paging is enabled.\r
+  @param  NewStack    The 64-bit virtual address of the new stack to use for\r
+                      the EntryPoint function after paging is enabled.\r
+\r
+**/\r
 VOID\r
 EFIAPI\r
 InternalX86EnablePaging64 (\r
@@ -191,6 +538,32 @@ InternalX86EnablePaging64 (
   IN      UINT64                    NewStack\r
   );\r
 \r
+/**\r
+  Disables the 64-bit paging mode on the CPU.\r
+\r
+  Disables the 64-bit paging mode on the CPU and returns to 32-bit protected\r
+  mode. This function assumes the current execution mode is 64-paging mode.\r
+  This function is only available on X64. After the 64-bit paging mode is\r
+  disabled, control is transferred to the function specified by EntryPoint\r
+  using the new stack specified by NewStack and passing in the parameters\r
+  specified by Context1 and Context2. Context1 and Context2 are optional and\r
+  may be 0. The function EntryPoint must never return.\r
+\r
+  @param  Cs          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
+                      the new stack after paging is disabled.\r
+  @param  Context1    The 64-bit virtual address of the context to pass into\r
+                      the EntryPoint function as the first parameter after\r
+                      paging is disabled.\r
+  @param  Context2    The 64-bit virtual address of the context to pass into\r
+                      the EntryPoint function as the second parameter after\r
+                      paging is disabled.\r
+  @param  NewStack    The 64-bit virtual address of the new stack to use for\r
+                      the EntryPoint function after paging is disabled.\r
+\r
+**/\r
 VOID\r
 EFIAPI\r
 InternalX86DisablePaging64 (\r