-/** @file
- Declaration of internal functions in BaseLib.
-
- Copyright (c) 2006 - 2007, Intel Corporation<BR>
- All rights reserved. This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
- Module Name: BaseLibInternals.h
-
-**/
-
-#ifndef __BASE_LIB_INTERNALS__
-#define __BASE_LIB_INTERNALS__
-
-#define QUIENT_MAX_UINTN_DIVIDED_BY_10 ((UINTN) -1 / 10)
-#define REMINDER_MAX_UINTN_DIVIDED_BY_10 ((UINTN) -1 % 10)
-
-#define QUIENT_MAX_UINTN_DIVIDED_BY_16 ((UINTN) -1 / 16)
-#define REMINDER_MAX_UINTN_DIVIDED_BY_16 ((UINTN) -1 % 16)
-
-#define QUIENT_MAX_UINT64_DIVIDED_BY_10 ((UINT64) -1 / 10)
-#define REMINDER_MAX_UINT64_DIVIDED_BY_10 ((UINT64) -1 % 10)
-
-#define QUIENT_MAX_UINT64_DIVIDED_BY_16 ((UINT64) -1 / 16)
-#define REMINDER_MAX_UINT64_DIVIDED_BY_16 ((UINT64) -1 % 16)
-
-//
-// Math functions
-//
-
-/**
- Shifts a 64-bit integer left between 0 and 63 bits. The low bits
- are filled with zeros. The shifted value is returned.
-
- This function shifts the 64-bit value Operand to the left by Count bits. The
- low Count bits are set to zero. The shifted value is returned.
-
- @param Operand The 64-bit operand to shift left.
- @param Count The number of bits to shift left.
-
- @return Operand << Count
-
-**/
-UINT64
-EFIAPI
-InternalMathLShiftU64 (
- IN UINT64 Operand,
- IN UINTN Count
- );
-
-/**
- Shifts a 64-bit integer right between 0 and 63 bits. This high bits
- are filled with zeros. The shifted value is returned.
-
- This function shifts the 64-bit value Operand to the right by Count bits. The
- high Count bits are set to zero. The shifted value is returned.
-
- @param Operand The 64-bit operand to shift right.
- @param Count The number of bits to shift right.
-
- @return Operand >> Count
-
-**/
-UINT64
-EFIAPI
-InternalMathRShiftU64 (
- IN UINT64 Operand,
- IN UINTN Count
- );
-
-/**
- Shifts a 64-bit integer right between 0 and 63 bits. The high bits
- are filled with original integer's bit 63. The shifted value is returned.
-
- 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.
-
- @param Operand The 64-bit operand to shift right.
- @param Count The number of bits to shift right.
-
- @return Operand arithmetically shifted right by Count
-
-**/
-UINT64
-EFIAPI
-InternalMathARShiftU64 (
- IN UINT64 Operand,
- IN UINTN Count
- );
-
-/**
- Rotates a 64-bit integer left between 0 and 63 bits, filling
- the low bits with the high bits that were rotated.
-
- This function rotates the 64-bit value Operand to the left by Count bits. The
- low Count bits are fill with the high Count bits of Operand. The rotated
- value is returned.
-
- @param Operand The 64-bit operand to rotate left.
- @param Count The number of bits to rotate left.
-
- @return Operand <<< Count
-
-**/
-UINT64
-EFIAPI
-InternalMathLRotU64 (
- IN UINT64 Operand,
- IN UINTN Count
- );
-
-/**
- Rotates a 64-bit integer right between 0 and 63 bits, filling
- the high bits with the high low bits that were rotated.
-
- This function rotates the 64-bit value Operand to the right by Count bits.
- The high Count bits are fill with the low Count bits of Operand. The rotated
- value is returned.
-
- @param Operand The 64-bit operand to rotate right.
- @param Count The number of bits to rotate right.
-
- @return Operand >>> Count
-
-**/
-UINT64
-EFIAPI
-InternalMathRRotU64 (
- IN UINT64 Operand,
- IN UINTN Count
- );
-
-/**
- Switches the endianess of a 64-bit integer.
-
- This function swaps the bytes in a 64-bit unsigned value to switch the value
- from little endian to big endian or vice versa. The byte swapped value is
- returned.
-
- @param Operand A 64-bit unsigned value.
-
- @return The byte swaped Operand.
-
-**/
-UINT64
-EFIAPI
-InternalMathSwapBytes64 (
- IN UINT64 Operand
- );
-
-/**
- Multiples a 64-bit unsigned integer by a 32-bit unsigned integer
- and generates a 64-bit unsigned result.
-
- This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
- unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
- bit unsigned result is returned.
-
- @param Multiplicand A 64-bit unsigned value.
- @param Multiplier A 32-bit unsigned value.
-
- @return Multiplicand * Multiplier
-
-**/
-UINT64
-EFIAPI
-InternalMathMultU64x32 (
- IN UINT64 Multiplicand,
- IN UINT32 Multiplier
- );
-
-/**
- Multiples a 64-bit unsigned integer by a 64-bit unsigned integer
- and generates a 64-bit unsigned result.
-
- This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
- unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
- bit unsigned result is returned.
-
- @param Multiplicand A 64-bit unsigned value.
- @param Multiplier A 64-bit unsigned value.
-
- @return Multiplicand * Multiplier
-
-**/
-UINT64
-EFIAPI
-InternalMathMultU64x64 (
- IN UINT64 Multiplicand,
- IN UINT64 Multiplier
- );
-
-/**
- Divides a 64-bit unsigned integer by a 32-bit unsigned integer and
- generates a 64-bit unsigned result.
-
- This function divides the 64-bit unsigned value Dividend by the 32-bit
- 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 Divisor A 32-bit unsigned value.
-
- @return Dividend / Divisor
-
-**/
-UINT64
-EFIAPI
-InternalMathDivU64x32 (
- IN UINT64 Dividend,
- IN UINT32 Divisor
- );
-
-/**
- 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
- returns the 32-bit unsigned remainder.
-
- @param Dividend A 64-bit unsigned value.
- @param Divisor A 32-bit unsigned value.
-
- @return Dividend % Divisor
-
-**/
-UINT32
-EFIAPI
-InternalMathModU64x32 (
- IN UINT64 Dividend,
- IN UINT32 Divisor
- );
-
-/**
- Divides a 64-bit unsigned integer by a 32-bit unsigned integer and
- generates a 64-bit unsigned result and an optional 32-bit unsigned remainder.
-
- This function divides the 64-bit unsigned value Dividend by the 32-bit
- unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
- is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
- This function returns the 64-bit unsigned quotient.
-
- @param Dividend A 64-bit unsigned value.
- @param Divisor A 32-bit unsigned value.
- @param Remainder A pointer to a 32-bit unsigned value. This parameter is
- optional and may be NULL.
-
- @return Dividend / Divisor
-
-**/
-UINT64
-EFIAPI
-InternalMathDivRemU64x32 (
- IN UINT64 Dividend,
- IN UINT32 Divisor,
- OUT UINT32 *Remainder
- );
-
-/**
- Divides a 64-bit unsigned integer by a 64-bit unsigned integer and
- generates a 64-bit unsigned result and an optional 64-bit unsigned remainder.
-
- This function divides the 64-bit unsigned value Dividend by the 64-bit
- unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
- is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
- This function returns the 64-bit unsigned quotient.
-
- @param Dividend A 64-bit unsigned value.
- @param Divisor A 64-bit unsigned value.
- @param Remainder A pointer to a 64-bit unsigned value. This parameter is
- optional and may be NULL.
-
- @return Dividend / Divisor
-
-**/
-UINT64
-EFIAPI
-InternalMathDivRemU64x64 (
- IN UINT64 Dividend,
- IN UINT64 Divisor,
- OUT UINT64 *Remainder
- );
-
-/**
- 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.
-
- This function divides the 64-bit unsigned value Dividend by the 64-bit
- unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
- is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
- This function returns the 64-bit unsigned quotient.
-
- @param Dividend A 64-bit signed value.
- @param Divisor A 64-bit signed value.
- @param Remainder A pointer to a 64-bit signed value. This parameter is
- optional and may be NULL.
-
- @return Dividend / Divisor
-
-**/
-INT64
-InternalMathDivRemS64x64 (
- IN INT64 Dividend,
- IN INT64 Divisor,
- OUT INT64 *Remainder OPTIONAL
- );
-
-/**
- Transfers control to a function starting with a new stack.
-
- Transfers control to the function specified by EntryPoint using the new stack
- specified by NewStack and passing in the parameters specified by Context1 and
- Context2. Context1 and Context2 are optional and may be NULL. The function
- EntryPoint must never return.
-
- @param EntryPoint A pointer to function to call with the new stack.
- @param Context1 A pointer to the context to pass into the EntryPoint
- function.
- @param Context2 A pointer to the context to pass into the EntryPoint
- function.
- @param NewStack A pointer to the new stack to use for the EntryPoint
- function.
-
-**/
-VOID
-EFIAPI
-InternalSwitchStack (
- IN SWITCH_STACK_ENTRY_POINT EntryPoint,
- IN VOID *Context1,
- IN VOID *Context2,
- IN VOID *NewStack
- );
-
-//
-// Ia32 and x64 specific functions
-//
-
-/**
- Reads the current Global Descriptor Table Register(GDTR) descriptor.
-
- Reads and returns the current GDTR descriptor and returns it in Gdtr. This
- function is only available on IA-32 and X64.
-
- @param Gdtr Pointer to a GDTR descriptor.
-
-**/
-VOID
-EFIAPI
-InternalX86ReadGdtr (
- OUT IA32_DESCRIPTOR *Gdtr
- );
-
-/**
- Writes the current Global Descriptor Table Register (GDTR) descriptor.
-
- Writes and the current GDTR descriptor specified by Gdtr. This function is
- only available on IA-32 and X64.
-
- @param Gdtr Pointer to a GDTR descriptor.
-
-**/
-VOID
-EFIAPI
-InternalX86WriteGdtr (
- IN CONST IA32_DESCRIPTOR *Gdtr
- );
-
-/**
- Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.
-
- Reads and returns the current IDTR descriptor and returns it in Idtr. This
- function is only available on IA-32 and X64.
-
- @param Idtr Pointer to a IDTR descriptor.
-
-**/
-VOID
-EFIAPI
-InternalX86ReadIdtr (
- OUT IA32_DESCRIPTOR *Idtr
- );
-
-/**
- Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.
-
- Writes the current IDTR descriptor and returns it in Idtr. This function is
- only available on IA-32 and X64.
-
- @param Idtr Pointer to a IDTR descriptor.
-
-**/
-VOID
-EFIAPI
-InternalX86WriteIdtr (
- IN CONST IA32_DESCRIPTOR *Idtr
- );
-
-/**
- Save the current floating point/SSE/SSE2 context to a buffer.
-
- Saves the current floating point/SSE/SSE2 state to the buffer specified by
- Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
- available on IA-32 and X64.
-
- @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
-
-**/
-VOID
-EFIAPI
-InternalX86FxSave (
- OUT IA32_FX_BUFFER *Buffer
- );
-
-/**
- Restores the current floating point/SSE/SSE2 context from a buffer.
-
- Restores the current floating point/SSE/SSE2 state from the buffer specified
- by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
- only available on IA-32 and X64.
-
- @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
-
-**/
-VOID
-EFIAPI
-InternalX86FxRestore (
- IN CONST IA32_FX_BUFFER *Buffer
- );
-
-/**
- Enables the 32-bit paging mode on the CPU.
-
- Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
- must be properly initialized prior to calling this service. This function
- assumes the current execution mode is 32-bit protected mode. This function is
- only available on IA-32. After the 32-bit paging mode is enabled, control is
- transferred to the function specified by EntryPoint using the new stack
- specified by NewStack and passing in the parameters specified by Context1 and
- Context2. Context1 and Context2 are optional and may be NULL. The function
- EntryPoint must never return.
-
- There are a number of constraints that must be followed before calling this
- function:
- 1) Interrupts must be disabled.
- 2) The caller must be in 32-bit protected mode with flat descriptors. This
- means all descriptors must have a base of 0 and a limit of 4GB.
- 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
- descriptors.
- 4) CR3 must point to valid page tables that will be used once the transition
- is complete, and those page tables must guarantee that the pages for this
- function and the stack are identity mapped.
-
- @param EntryPoint A pointer to function to call with the new stack after
- paging is enabled.
- @param Context1 A pointer to the context to pass into the EntryPoint
- function as the first parameter after paging is enabled.
- @param Context2 A pointer to the context to pass into the EntryPoint
- function as the second parameter after paging is enabled.
- @param NewStack A pointer to the new stack to use for the EntryPoint
- function after paging is enabled.
-
-**/
-VOID
-EFIAPI
-InternalX86EnablePaging32 (
- IN SWITCH_STACK_ENTRY_POINT EntryPoint,
- IN VOID *Context1, OPTIONAL
- IN VOID *Context2, OPTIONAL
- IN VOID *NewStack
- );
-
-/**
- Disables the 32-bit paging mode on the CPU.
-
- Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
- mode. This function assumes the current execution mode is 32-paged protected
- mode. This function is only available on IA-32. After the 32-bit paging mode
- is disabled, control is transferred to the function specified by EntryPoint
- using the new stack specified by NewStack and passing in the parameters
- specified by Context1 and Context2. Context1 and Context2 are optional and
- may be NULL. The function EntryPoint must never return.
-
- There are a number of constraints that must be followed before calling this
- function:
- 1) Interrupts must be disabled.
- 2) The caller must be in 32-bit paged mode.
- 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
- 4) CR3 must point to valid page tables that guarantee that the pages for
- this function and the stack are identity mapped.
-
- @param EntryPoint A pointer to function to call with the new stack after
- paging is disabled.
- @param Context1 A pointer to the context to pass into the EntryPoint
- function as the first parameter after paging is disabled.
- @param Context2 A pointer to the context to pass into the EntryPoint
- function as the second parameter after paging is
- disabled.
- @param NewStack A pointer to the new stack to use for the EntryPoint
- function after paging is disabled.
-
-**/
-VOID
-EFIAPI
-InternalX86DisablePaging32 (
- IN SWITCH_STACK_ENTRY_POINT EntryPoint,
- IN VOID *Context1, OPTIONAL
- IN VOID *Context2, OPTIONAL
- IN VOID *NewStack
- );
-
-/**
- Enables the 64-bit paging mode on the CPU.
-
- Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
- must be properly initialized prior to calling this service. This function
- assumes the current execution mode is 32-bit protected mode with flat
- descriptors. This function is only available on IA-32. After the 64-bit
- paging mode is enabled, control is transferred to the function specified by
- EntryPoint using the new stack specified by NewStack and passing in the
- parameters specified by Context1 and Context2. Context1 and Context2 are
- optional and may be 0. The function EntryPoint must never return.
-
- @param Cs The 16-bit selector to load in the CS before EntryPoint
- is called. The descriptor in the GDT that this selector
- references must be setup for long mode.
- @param EntryPoint The 64-bit virtual address of the function to call with
- the new stack after paging is enabled.
- @param Context1 The 64-bit virtual address of the context to pass into
- the EntryPoint function as the first parameter after
- paging is enabled.
- @param Context2 The 64-bit virtual address of the context to pass into
- the EntryPoint function as the second parameter after
- paging is enabled.
- @param NewStack The 64-bit virtual address of the new stack to use for
- the EntryPoint function after paging is enabled.
-
-**/
-VOID
-EFIAPI
-InternalX86EnablePaging64 (
- IN UINT16 Cs,
- IN UINT64 EntryPoint,
- IN UINT64 Context1, OPTIONAL
- IN UINT64 Context2, OPTIONAL
- IN UINT64 NewStack
- );
-
-/**
- Disables the 64-bit paging mode on the CPU.
-
- Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
- mode. This function assumes the current execution mode is 64-paging mode.
- This function is only available on X64. After the 64-bit paging mode is
- disabled, control is transferred to the function specified by EntryPoint
- using the new stack specified by NewStack and passing in the parameters
- specified by Context1 and Context2. Context1 and Context2 are optional and
- may be 0. The function EntryPoint must never return.
-
- @param Cs The 16-bit selector to load in the CS before EntryPoint
- is called. The descriptor in the GDT that this selector
- references must be setup for 32-bit protected mode.
- @param EntryPoint The 64-bit virtual address of the function to call with
- the new stack after paging is disabled.
- @param Context1 The 64-bit virtual address of the context to pass into
- the EntryPoint function as the first parameter after
- paging is disabled.
- @param Context2 The 64-bit virtual address of the context to pass into
- the EntryPoint function as the second parameter after
- paging is disabled.
- @param NewStack The 64-bit virtual address of the new stack to use for
- the EntryPoint function after paging is disabled.
-
-**/
-VOID
-EFIAPI
-InternalX86DisablePaging64 (
- IN UINT16 Cs,
- IN UINT32 EntryPoint,
- IN UINT32 Context1, OPTIONAL
- IN UINT32 Context2, OPTIONAL
- IN UINT32 NewStack
- );
-
-/**
- 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 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
- equal to PcdMaximumLinkedListLength, then ASSERT().
-
- @param List A pointer to a node in a linked list.
- @param Node A pointer to one nod.
-
- @retval TRUE Node is in List
- @retval FALSE Node isn't in List, or List is invalid
-
-**/
-BOOLEAN
-IsNodeInList (
- IN CONST LIST_ENTRY *List,
- IN CONST LIST_ENTRY *Node
- );
-
-/**
- Performs an atomic increment of an 32-bit unsigned integer.
-
- Performs an atomic increment of the 32-bit unsigned integer specified by
- Value and returns the incremented value. The increment operation must be
- performed using MP safe mechanisms. The state of the return value is not
- guaranteed to be MP safe.
-
- @param Value A pointer to the 32-bit value to increment.
-
- @return The incremented value.
-
-**/
-UINT32
-EFIAPI
-InternalSyncIncrement (
- IN volatile UINT32 *Value
- );
-
-/**
- Performs an atomic decrement of an 32-bit unsigned integer.
-
- Performs an atomic decrement of the 32-bit unsigned integer specified by
- Value and returns the decrement value. The decrement operation must be
- performed using MP safe mechanisms. The state of the return value is not
- guaranteed to be MP safe.
-
- @param Value A pointer to the 32-bit value to decrement.
-
- @return The decrement value.
-
-**/
-UINT32
-EFIAPI
-InternalSyncDecrement (
- IN volatile UINT32 *Value
- );
-
-/**
- Performs an atomic compare exchange operation on a 32-bit unsigned integer.
-
- Performs an atomic compare exchange operation on the 32-bit unsigned integer
- specified by Value. If Value is equal to CompareValue, then Value is set to
- ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,
- then Value is returned. The compare exchange operation must be performed using
- MP safe mechanisms.
-
- @param Value A pointer to the 32-bit value for the compare exchange
- operation.
- @param CompareValue 32-bit value used in compare operation.
- @param ExchangeValue 32-bit value used in exchange operation.
-
- @return The original *Value before exchange.
-
-**/
-UINT32
-EFIAPI
-InternalSyncCompareExchange32 (
- IN volatile UINT32 *Value,
- IN UINT32 CompareValue,
- IN UINT32 ExchangeValue
- );
-
-/**
- Performs an atomic compare exchange operation on a 64-bit unsigned integer.
-
- Performs an atomic compare exchange operation on the 64-bit unsigned integer specified
- by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and
- CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.
- The compare exchange operation must be performed using MP safe mechanisms.
-
- @param Value A pointer to the 64-bit value for the compare exchange
- operation.
- @param CompareValue 64-bit value used in compare operation.
- @param ExchangeValue 64-bit value used in exchange operation.
-
- @return The original *Value before exchange.
-
-**/
-UINT64
-EFIAPI
-InternalSyncCompareExchange64 (
- IN volatile UINT64 *Value,
- IN UINT64 CompareValue,
- IN UINT64 ExchangeValue
- );
-
-/**
- Worker function that returns a bit field from Operand
-
- Returns the bitfield specified by the StartBit and the EndBit from Operand.
-
- @param Operand Operand on which to perform the bitfield operation.
- @param StartBit The ordinal of the least significant bit in the bit field.
- @param EndBit The ordinal of the most significant bit in the bit field.
-
- @return The bit field read.
-
-**/
-unsigned int
-BitFieldReadUint (
- IN unsigned int Operand,
- IN UINTN StartBit,
- IN UINTN EndBit
- );
-
-/**
- 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
- in Operand and the value specified by AndData. All other bits in Operand are
- preserved. The new value is returned.
-
- @param Operand Operand on which to perform the bitfield operation.
- @param StartBit The ordinal of the least significant bit in the bit field.
- @param EndBit The ordinal of the most significant bit in the bit field.
- @param OrData The value to OR with the read value from the value
-
- @return The new value.
-
-**/
-unsigned int
-BitFieldOrUint (
- IN unsigned int Operand,
- IN UINTN StartBit,
- IN UINTN EndBit,
- IN unsigned int OrData
- );
-
-/**
- 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
- in Operand and the value specified by AndData. All other bits in Operand are
- preserved. The new value is returned.
-
- @param Operand Operand on which to perform the bitfield operation.
- @param StartBit The ordinal of the least significant bit in the bit field.
- @param EndBit The ordinal of the most significant bit in the bit field.
- @param AndData The value to And with the read value from the value
-
- @return The new value.
-
-**/
-unsigned int
-BitFieldAndUint (
- IN unsigned int Operand,
- IN UINTN StartBit,
- IN UINTN EndBit,
- IN unsigned int AndData
- );
-
-/**
- Worker function that checks ASSERT condition for JumpBuffer
-
- Checks ASSERT condition for JumpBuffer.
-
- If JumpBuffer is NULL, 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.
-
-**/
-VOID
-InternalAssertJumpBuffer (
- IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer
- );
-
-/**
- Restores the CPU context that was saved with SetJump().
-
- Restores the CPU context from the buffer specified by JumpBuffer.
- This function never returns to the caller.
- Instead is resumes execution based on the state of JumpBuffer.
-
- @param JumpBuffer A pointer to CPU context buffer.
- @param Value The value to return when the SetJump() context is restored.
-
-**/
-VOID
-EFIAPI
-InternalLongJump (
- IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,
- IN UINTN Value
- );
-
-#endif
+/** @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
+\r
+**/\r
+\r
+#ifndef __BASE_LIB_INTERNALS__\r
+#define __BASE_LIB_INTERNALS__\r
+\r
+#include <Base.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/PcdLib.h>\r
+\r
+//\r
+// Math functions\r
+//\r
+\r
+/**\r
+ 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
+ IN UINT64 Operand,\r
+ IN UINTN Count\r
+ );\r
+\r
+/**\r
+ Shifts a 64-bit integer right between 0 and 63 bits. The 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
+ IN UINT64 Operand,\r
+ IN UINTN Count\r
+ );\r
+\r
+/**\r
+ 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
+ IN UINT64 Operand,\r
+ IN UINTN Count\r
+ );\r
+\r
+/**\r
+ 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 filled 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
+ IN UINT64 Operand,\r
+ IN UINTN Count\r
+ );\r
+\r
+/**\r
+ 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 filled 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
+ IN UINT64 Operand,\r
+ IN UINTN Count\r
+ );\r
+\r
+/**\r
+ 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 swapped Operand.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+InternalMathSwapBytes64 (\r
+ IN UINT64 Operand\r
+ );\r
+\r
+/**\r
+ Multiplies a 64-bit unsigned integer by a 32-bit unsigned integer\r
+ and generates a 64-bit unsigned result.\r
+\r
+ This function multiplies 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
+ IN UINT64 Multiplicand,\r
+ IN UINT32 Multiplier\r
+ );\r
+\r
+/**\r
+ Multiplies 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
+ IN UINT64 Multiplicand,\r
+ IN UINT64 Multiplier\r
+ );\r
+\r
+/**\r
+ 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
+ IN UINT64 Dividend,\r
+ IN UINT32 Divisor\r
+ );\r
+\r
+/**\r
+ 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
+ IN UINT64 Dividend,\r
+ IN UINT32 Divisor\r
+ );\r
+\r
+/**\r
+ 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
+ IN UINT64 Dividend,\r
+ IN UINT32 Divisor,\r
+ OUT UINT32 *Remainder OPTIONAL\r
+ );\r
+\r
+/**\r
+ 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
+ IN UINT64 Dividend,\r
+ IN UINT64 Divisor,\r
+ OUT UINT64 *Remainder OPTIONAL\r
+ );\r
+\r
+/**\r
+ Divides a 64-bit signed integer by a 64-bit signed integer and\r
+ generates a 64-bit signed result and an optional 64-bit signed remainder.\r
+\r
+ This function divides the 64-bit signed value Dividend by the 64-bit\r
+ signed value Divisor and generates a 64-bit signed quotient. If Remainder\r
+ is not NULL, then the 64-bit signed remainder is returned in Remainder.\r
+ This function returns the 64-bit signed 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 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\r
+ new stack specified by NewStack and passing in the parameters specified\r
+ by Context1 and Context2. Context1 and Context2 are optional and may\r
+ be NULL. The function EntryPoint must never return.\r
+ Marker will be ignored on IA-32, x64, and EBC.\r
+ IPF CPUs expect one additional parameter of type VOID * that specifies\r
+ the new backing store pointer.\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 Marker VA_LIST marker for the variable argument list.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+InternalSwitchStack (\r
+ IN SWITCH_STACK_ENTRY_POINT EntryPoint,\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 PcdMaximumLinkedListLength 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
+ Returns the bitfield specified by the StartBit and the EndBit from Operand.\r
+\r
+ @param Operand Operand on which to perform the bitfield operation.\r
+ @param StartBit The ordinal of the least significant bit in the bit field.\r
+ @param EndBit The ordinal of the most significant bit in the bit field.\r
+\r
+ @return The bit field read.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+BitFieldReadUint (\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
+\r
+ Performs a bitwise OR between the bit field specified by StartBit and EndBit\r
+ in Operand and the value specified by AndData. All other bits in Operand are\r
+ preserved. The new value is returned.\r
+\r
+ @param Operand Operand on which to perform the bitfield operation.\r
+ @param StartBit The ordinal of the least significant bit in the bit field.\r
+ @param EndBit The ordinal of the most significant bit in the bit field.\r
+ @param OrData The value to OR with the read value from the value\r
+\r
+ @return The new value.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+BitFieldOrUint (\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
+\r
+ Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
+ in Operand and the value specified by AndData. All other bits in Operand are\r
+ preserved. The new value is returned.\r
+\r
+ @param Operand Operand on which to perform the bitfield operation.\r
+ @param StartBit The ordinal of the least significant bit in the bit field.\r
+ @param EndBit The ordinal of the most significant bit in the bit field.\r
+ @param AndData The value to And with the read value from the value\r
+\r
+ @return The new value.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+BitFieldAndUint (\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
+ Checks ASSERT condition for JumpBuffer.\r
+\r
+ If JumpBuffer is NULL, then ASSERT().\r
+ For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().\r
+\r
+ @param JumpBuffer A pointer to CPU context buffer.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+InternalAssertJumpBuffer (\r
+ IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer\r
+ );\r
+\r
+\r
+/**\r
+ Restores the CPU context that was saved with SetJump().\r
+\r
+ Restores the CPU context from the buffer specified by JumpBuffer.\r
+ This function never returns to the caller.\r
+ Instead is resumes execution based on the state of JumpBuffer.\r
+\r
+ @param JumpBuffer A pointer to CPU context buffer.\r
+ @param Value The value to return when the SetJump() context is restored.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+InternalLongJump (\r
+ IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,\r
+ IN UINTN Value\r
+ );\r
+\r
+\r
+//\r
+// Ia32 and x64 specific functions\r
+//\r
+#if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)\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 The 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 The 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 The pointer to an 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 The pointer to an 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 The 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 The 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
+ IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r
+ IN VOID *Context1, OPTIONAL\r
+ IN VOID *Context2, OPTIONAL\r
+ 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
+ IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r
+ IN VOID *Context1, OPTIONAL\r
+ IN VOID *Context2, OPTIONAL\r
+ 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
+ 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
+ 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
+ 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
+ );\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
+\r
+ This is a worker function for AsmReadControlRegister()\r
+ when its parameter Index is IPF_CONTROL_REGISTER_TPR.\r
+\r
+ @return The 64-bit control register TPR.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmReadControlRegisterTpr (\r
+ VOID\r
+ );\r
+\r
+\r
+/**\r
+ Reads control register EOI.\r
+\r
+ This is a worker function for AsmReadControlRegister()\r
+ when its parameter Index is IPF_CONTROL_REGISTER_EOI.\r
+\r
+ @return The 64-bit control register EOI.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmReadControlRegisterEoi (\r
+ VOID\r
+ );\r
+\r
+\r
+/**\r
+ Reads control register IRR0.\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
+\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
+\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
+EFIAPI\r
+InternalFlushCacheRange (\r
+ IN VOID *Address,\r
+ IN UINTN Length\r
+ );\r
+\r
+#else\r
+\r
+#endif\r
+\r
+#endif\r