Add IntelFspWrapper to support boot EDKII on FSP bin.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed off by: Jiewen Yao <jiewen.yao@intel.com> Reviewed by: Ravi Rangarajan <ravi.p.rangarajan@intel.com> Reviewed by: Maurice Ma <maurice.ma@intel.com> Reviewed by: Giri Mudusuru <giri.p.mudusuru@intel.com> Reviewed by: Liming Gao <liming.gao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15676 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
/** @file
|
||||
Execute 32-bit code in Long Mode.
|
||||
Provide a thunk function to transition from long mode to compatibility mode to execute 32-bit code and then transit
|
||||
back to long mode.
|
||||
|
||||
Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#include <Uefi.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <FspApi.h>
|
||||
|
||||
#pragma pack(1)
|
||||
typedef union {
|
||||
struct {
|
||||
UINT32 LimitLow : 16;
|
||||
UINT32 BaseLow : 16;
|
||||
UINT32 BaseMid : 8;
|
||||
UINT32 Type : 4;
|
||||
UINT32 System : 1;
|
||||
UINT32 Dpl : 2;
|
||||
UINT32 Present : 1;
|
||||
UINT32 LimitHigh : 4;
|
||||
UINT32 Software : 1;
|
||||
UINT32 Reserved : 1;
|
||||
UINT32 DefaultSize : 1;
|
||||
UINT32 Granularity : 1;
|
||||
UINT32 BaseHigh : 8;
|
||||
} Bits;
|
||||
UINT64 Uint64;
|
||||
} IA32_GDT;
|
||||
#pragma pack()
|
||||
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED IA32_GDT mGdtEntries[] = {
|
||||
{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, /* 0x0: reserve */
|
||||
{{0xFFFF, 0, 0, 0xB, 1, 0, 1, 0xF, 0, 0, 1, 1, 0}}, /* 0x8: compatibility mode */
|
||||
{{0xFFFF, 0, 0, 0xB, 1, 0, 1, 0xF, 0, 1, 0, 1, 0}}, /* 0x10: for long mode */
|
||||
{{0xFFFF, 0, 0, 0x3, 1, 0, 1, 0xF, 0, 0, 1, 1, 0}}, /* 0x18: data */
|
||||
{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, /* 0x20: reserve */
|
||||
};
|
||||
|
||||
//
|
||||
// IA32 Gdt register
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED IA32_DESCRIPTOR mGdt = {
|
||||
sizeof (mGdtEntries) - 1,
|
||||
(UINTN) mGdtEntries
|
||||
};
|
||||
|
||||
/**
|
||||
Assembly function to transition from long mode to compatibility mode to execute 32-bit code and then transit back to
|
||||
long mode.
|
||||
|
||||
@param[in] Function The 32bit code entry to be executed.
|
||||
@param[in] Param1 The first parameter to pass to 32bit code
|
||||
@param[in] Param2 The second parameter to pass to 32bit code
|
||||
@param[in] InternalGdtr The GDT and GDT descriptor used by this library
|
||||
|
||||
@return status.
|
||||
**/
|
||||
UINT32
|
||||
AsmExecute32BitCode (
|
||||
IN UINT64 Function,
|
||||
IN UINT64 Param1,
|
||||
IN UINT64 Param2,
|
||||
IN IA32_DESCRIPTOR *InternalGdtr
|
||||
);
|
||||
|
||||
/**
|
||||
Wrapper for a thunk to transition from long mode to compatibility mode to execute 32-bit code and then transit back to
|
||||
long mode.
|
||||
|
||||
@param[in] Function The 32bit code entry to be executed.
|
||||
@param[in] Param1 The first parameter to pass to 32bit code.
|
||||
|
||||
@return FSP_STATUS.
|
||||
**/
|
||||
FSP_STATUS
|
||||
Execute32BitCode (
|
||||
IN UINT64 Function,
|
||||
IN UINT64 Param1
|
||||
)
|
||||
{
|
||||
return AsmExecute32BitCode (Function, Param1, 0, &mGdt);
|
||||
}
|
||||
|
Reference in New Issue
Block a user