2006-04-22 00:54:32 +02:00
|
|
|
/** @file
|
|
|
|
Declaration of internal functions in BaseLib.
|
|
|
|
|
|
|
|
Copyright (c) 2006, 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__
|
|
|
|
|
|
|
|
//
|
|
|
|
// Math functions
|
|
|
|
//
|
|
|
|
|
2006-07-19 19:37:07 +02:00
|
|
|
/**
|
2006-07-20 04:48:06 +02:00
|
|
|
Shifts a 64-bit integer left between 0 and 63 bits. The low bits
|
2006-07-19 19:37:07 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
**/
|
2006-04-22 00:54:32 +02:00
|
|
|
UINT64
|
|
|
|
EFIAPI
|
|
|
|
InternalMathLShiftU64 (
|
|
|
|
IN UINT64 Operand,
|
|
|
|
IN UINTN Count
|
|
|
|
);
|
|
|
|
|
2006-07-19 19:37:07 +02:00
|
|
|
/**
|
2006-07-20 04:48:06 +02:00
|
|
|
Shifts a 64-bit integer right between 0 and 63 bits. This high bits
|
2006-07-19 19:37:07 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
**/
|
2006-04-22 00:54:32 +02:00
|
|
|
UINT64
|
|
|
|
EFIAPI
|
|
|
|
InternalMathRShiftU64 (
|
|
|
|
IN UINT64 Operand,
|
|
|
|
IN UINTN Count
|
|
|
|
);
|
|
|
|
|
2006-07-19 19:37:07 +02:00
|
|
|
/**
|
2006-07-20 04:48:06 +02:00
|
|
|
Shifts a 64-bit integer right between 0 and 63 bits. The high bits
|
2006-07-19 19:37:07 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
**/
|
2006-04-22 00:54:32 +02:00
|
|
|
UINT64
|
|
|
|
EFIAPI
|
|
|
|
InternalMathARShiftU64 (
|
|
|
|
IN UINT64 Operand,
|
|
|
|
IN UINTN Count
|
|
|
|
);
|
|
|
|
|
2006-07-19 19:37:07 +02:00
|
|
|
/**
|
2006-07-20 04:48:06 +02:00
|
|
|
Rotates a 64-bit integer left between 0 and 63 bits, filling
|
2006-07-19 19:37:07 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
**/
|
2006-04-22 00:54:32 +02:00
|
|
|
UINT64
|
|
|
|
EFIAPI
|
|
|
|
InternalMathLRotU64 (
|
|
|
|
IN UINT64 Operand,
|
|
|
|
IN UINTN Count
|
|
|
|
);
|
|
|
|
|
2006-07-19 19:37:07 +02:00
|
|
|
/**
|
2006-07-20 04:48:06 +02:00
|
|
|
Rotates a 64-bit integer right between 0 and 63 bits, filling
|
2006-07-19 19:37:07 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
**/
|
2006-04-22 00:54:32 +02:00
|
|
|
UINT64
|
|
|
|
EFIAPI
|
|
|
|
InternalMathRRotU64 (
|
|
|
|
IN UINT64 Operand,
|
|
|
|
IN UINTN Count
|
|
|
|
);
|
|
|
|
|
2006-07-19 19:37:07 +02:00
|
|
|
/**
|
2006-07-20 04:48:06 +02:00
|
|
|
Switches the endianess of a 64-bit integer.
|
2006-07-19 19:37:07 +02:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
**/
|
2006-04-22 00:54:32 +02:00
|
|
|
UINT64
|
|
|
|
EFIAPI
|
|
|
|
InternalMathSwapBytes64 (
|
|
|
|
IN UINT64 Operand
|
|
|
|
);
|
|
|
|
|
2006-07-19 19:37:07 +02:00
|
|
|
/**
|
2006-07-20 04:48:06 +02:00
|
|
|
Multiples a 64-bit unsigned integer by a 32-bit unsigned integer
|
2006-07-19 19:37:07 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
**/
|
2006-04-22 00:54:32 +02:00
|
|
|
UINT64
|
|
|
|
EFIAPI
|
|
|
|
InternalMathMultU64x32 (
|
|
|
|
IN UINT64 Multiplicand,
|
|
|
|
IN UINT32 Multiplier
|
|
|
|
);
|
|
|
|
|
2006-07-19 19:37:07 +02:00
|
|
|
/**
|
2006-07-20 04:48:06 +02:00
|
|
|
Multiples a 64-bit unsigned integer by a 64-bit unsigned integer
|
2006-07-19 19:37:07 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
**/
|
2006-04-22 00:54:32 +02:00
|
|
|
UINT64
|
|
|
|
EFIAPI
|
|
|
|
InternalMathMultU64x64 (
|
|
|
|
IN UINT64 Multiplicand,
|
|
|
|
IN UINT64 Multiplier
|
|
|
|
);
|
|
|
|
|
2006-07-19 19:37:07 +02:00
|
|
|
/**
|
2006-07-20 04:48:06 +02:00
|
|
|
Divides a 64-bit unsigned integer by a 32-bit unsigned integer and
|
2006-07-19 19:37:07 +02:00
|
|
|
generates a 64-bit unsigned result.
|
2006-07-20 04:48:06 +02:00
|
|
|
|
2006-07-19 19:37:07 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
**/
|
2006-04-22 00:54:32 +02:00
|
|
|
UINT64
|
|
|
|
EFIAPI
|
|
|
|
InternalMathDivU64x32 (
|
|
|
|
IN UINT64 Dividend,
|
|
|
|
IN UINT32 Divisor
|
|
|
|
);
|
|
|
|
|
2006-07-19 19:37:07 +02:00
|
|
|
/**
|
2006-07-20 04:48:06 +02:00
|
|
|
Divides a 64-bit unsigned integer by a 32-bit unsigned integer and
|
2006-07-19 19:37:07 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
**/
|
2006-04-22 00:54:32 +02:00
|
|
|
UINT32
|
|
|
|
EFIAPI
|
|
|
|
InternalMathModU64x32 (
|
|
|
|
IN UINT64 Dividend,
|
|
|
|
IN UINT32 Divisor
|
|
|
|
);
|
|
|
|
|
2006-07-19 19:37:07 +02:00
|
|
|
/**
|
2006-07-20 04:48:06 +02:00
|
|
|
Divides a 64-bit unsigned integer by a 32-bit unsigned integer and
|
2006-07-19 19:37:07 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
**/
|
2006-04-22 00:54:32 +02:00
|
|
|
UINT64
|
|
|
|
EFIAPI
|
|
|
|
InternalMathDivRemU64x32 (
|
|
|
|
IN UINT64 Dividend,
|
|
|
|
IN UINT32 Divisor,
|
|
|
|
OUT UINT32 *Remainder
|
|
|
|
);
|
|
|
|
|
2006-07-19 19:37:07 +02:00
|
|
|
/**
|
2006-07-20 04:48:06 +02:00
|
|
|
Divides a 64-bit unsigned integer by a 64-bit unsigned integer and
|
2006-07-19 19:37:07 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
**/
|
2006-04-22 00:54:32 +02:00
|
|
|
UINT64
|
|
|
|
EFIAPI
|
|
|
|
InternalMathDivRemU64x64 (
|
|
|
|
IN UINT64 Dividend,
|
|
|
|
IN UINT64 Divisor,
|
|
|
|
OUT UINT64 *Remainder
|
|
|
|
);
|
|
|
|
|
2006-07-19 19:37:07 +02:00
|
|
|
/**
|
2006-07-20 04:48:06 +02:00
|
|
|
Divides a 64-bit signed integer by a 64-bit signed integer and
|
2006-07-19 19:37:07 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
**/
|
2006-04-22 00:54:32 +02:00
|
|
|
INT64
|
|
|
|
InternalMathDivRemS64x64 (
|
|
|
|
IN INT64 Dividend,
|
|
|
|
IN INT64 Divisor,
|
2006-07-19 19:37:07 +02:00
|
|
|
OUT INT64 *Remainder OPTIONAL
|
2006-07-20 04:48:06 +02:00
|
|
|
);
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-07-19 19:37:07 +02:00
|
|
|
/**
|
|
|
|
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.
|
|
|
|
|
|
|
|
**/
|
2006-06-02 09:58:31 +02:00
|
|
|
VOID
|
2006-07-20 04:48:06 +02:00
|
|
|
EFIAPI
|
2006-06-02 09:58:31 +02:00
|
|
|
InternalSwitchStack (
|
|
|
|
IN SWITCH_STACK_ENTRY_POINT EntryPoint,
|
|
|
|
IN VOID *Context1,
|
|
|
|
IN VOID *Context2,
|
|
|
|
IN VOID *NewStack
|
|
|
|
);
|
|
|
|
|
2006-04-22 00:54:32 +02:00
|
|
|
//
|
|
|
|
// Ia32 and x64 specific functions
|
|
|
|
//
|
|
|
|
|
2006-07-19 19:37:07 +02:00
|
|
|
/**
|
|
|
|
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.
|
|
|
|
|
|
|
|
**/
|
2006-04-22 00:54:32 +02:00
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
InternalX86ReadGdtr (
|
|
|
|
OUT IA32_DESCRIPTOR *Gdtr
|
|
|
|
);
|
|
|
|
|
2006-07-19 19:37:07 +02:00
|
|
|
/**
|
|
|
|
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.
|
|
|
|
|
|
|
|
**/
|
2006-04-22 00:54:32 +02:00
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
InternalX86WriteGdtr (
|
|
|
|
IN CONST IA32_DESCRIPTOR *Gdtr
|
|
|
|
);
|
|
|
|
|
2006-07-19 19:37:07 +02:00
|
|
|
/**
|
|
|
|
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.
|
|
|
|
|
|
|
|
**/
|
2006-04-22 00:54:32 +02:00
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
InternalX86ReadIdtr (
|
|
|
|
OUT IA32_DESCRIPTOR *Idtr
|
|
|
|
);
|
|
|
|
|
2006-07-19 19:37:07 +02:00
|
|
|
/**
|
|
|
|
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.
|
|
|
|
|
|
|
|
**/
|
2006-04-22 00:54:32 +02:00
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
InternalX86WriteIdtr (
|
|
|
|
IN CONST IA32_DESCRIPTOR *Idtr
|
|
|
|
);
|
|
|
|
|
2006-07-19 19:37:07 +02:00
|
|
|
/**
|
|
|
|
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.
|
|
|
|
|
|
|
|
**/
|
2006-04-22 00:54:32 +02:00
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
InternalX86FxSave (
|
|
|
|
OUT IA32_FX_BUFFER *Buffer
|
|
|
|
);
|
|
|
|
|
2006-07-19 19:37:07 +02:00
|
|
|
/**
|
|
|
|
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.
|
|
|
|
|
|
|
|
**/
|
2006-04-22 00:54:32 +02:00
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
InternalX86FxRestore (
|
|
|
|
IN CONST IA32_FX_BUFFER *Buffer
|
|
|
|
);
|
|
|
|
|
2006-07-19 19:37:07 +02:00
|
|
|
/**
|
|
|
|
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.
|
|
|
|
|
|
|
|
**/
|
2006-04-22 00:54:32 +02:00
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
InternalX86EnablePaging32 (
|
|
|
|
IN SWITCH_STACK_ENTRY_POINT EntryPoint,
|
|
|
|
IN VOID *Context1, OPTIONAL
|
|
|
|
IN VOID *Context2, OPTIONAL
|
|
|
|
IN VOID *NewStack
|
|
|
|
);
|
|
|
|
|
2006-07-19 19:37:07 +02:00
|
|
|
/**
|
|
|
|
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.
|
|
|
|
|
|
|
|
**/
|
2006-04-22 00:54:32 +02:00
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
InternalX86DisablePaging32 (
|
|
|
|
IN SWITCH_STACK_ENTRY_POINT EntryPoint,
|
|
|
|
IN VOID *Context1, OPTIONAL
|
|
|
|
IN VOID *Context2, OPTIONAL
|
|
|
|
IN VOID *NewStack
|
|
|
|
);
|
|
|
|
|
2006-07-19 19:37:07 +02:00
|
|
|
/**
|
|
|
|
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.
|
|
|
|
|
|
|
|
**/
|
2006-04-22 00:54:32 +02:00
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
InternalX86EnablePaging64 (
|
|
|
|
IN UINT16 Cs,
|
|
|
|
IN UINT64 EntryPoint,
|
|
|
|
IN UINT64 Context1, OPTIONAL
|
|
|
|
IN UINT64 Context2, OPTIONAL
|
|
|
|
IN UINT64 NewStack
|
|
|
|
);
|
|
|
|
|
2006-07-19 19:37:07 +02:00
|
|
|
/**
|
|
|
|
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.
|
|
|
|
|
|
|
|
**/
|
2006-04-22 00:54:32 +02:00
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
InternalX86DisablePaging64 (
|
|
|
|
IN UINT16 Cs,
|
|
|
|
IN UINT32 EntryPoint,
|
|
|
|
IN UINT32 Context1, OPTIONAL
|
|
|
|
IN UINT32 Context2, OPTIONAL
|
|
|
|
IN UINT32 NewStack
|
|
|
|
);
|
|
|
|
|
|
|
|
#endif
|