summaryrefslogtreecommitdiff
path: root/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk
diff options
context:
space:
mode:
authorGuo Mang <mang.guo@intel.com>2017-04-27 11:30:22 +0800
committerGuo Mang <mang.guo@intel.com>2017-04-27 13:02:43 +0800
commit52e99d85a129b6124dad484f9f349fab8e02e488 (patch)
tree0839a52567104c32841237c149a6c2b1cb5c95b7 /EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk
parent7283449b45d2842b9123ada5129cb073e40b940a (diff)
downloadedk2-platforms-52e99d85a129b6124dad484f9f349fab8e02e488.tar.xz
EdkCompatibilityPkg: Remove unused Package
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Guo Mang <mang.guo@intel.com>
Diffstat (limited to 'EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk')
-rw-r--r--EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/BootScriptSaveOnS3SaveStateThunk.inf82
-rw-r--r--EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/IA32/DispatchExecute.c43
-rw-r--r--EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/ScriptSave.c993
-rw-r--r--EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/ScriptSave.h119
-rw-r--r--EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/X64/AsmDispatchExecute.S216
-rw-r--r--EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/X64/AsmDispatchExecute.asm216
-rw-r--r--EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/X64/DispatchExecute.c157
7 files changed, 0 insertions, 1826 deletions
diff --git a/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/BootScriptSaveOnS3SaveStateThunk.inf b/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/BootScriptSaveOnS3SaveStateThunk.inf
deleted file mode 100644
index def1ff0beb..0000000000
--- a/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/BootScriptSaveOnS3SaveStateThunk.inf
+++ /dev/null
@@ -1,82 +0,0 @@
-## @file
-# To implement Framework Boot Script Save protocol based on PI S3 Save State protocol
-#
-# Intel's Framework Boot Script Save Protocol is replaced by S3 Save State Protocol in PI.
-# This module produces Framework Boot Script Save protocol by consuming PI S3 Save State protocol
-#
-# Copyright (c) 2010 - 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.
-#
-#
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = BootScriptSaveOnS3SaveStateThunk
- FILE_GUID = 062ACC82-1D1E-4f61-AA94-8B0C47236A3D
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
-
- ENTRY_POINT = InitializeScriptSaveOnS3SaveState
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64
-#
-
-[Sources]
- ScriptSave.c
- ScriptSave.h
-
-[Sources.X64]
- X64/AsmDispatchExecute.asm
- X64/AsmDispatchExecute.S
- X64/DispatchExecute.c
-
-[Sources.Ia32]
- IA32/DispatchExecute.c
-
-[Packages]
- MdePkg/MdePkg.dec
- IntelFrameworkPkg/IntelFrameworkPkg.dec
- MdeModulePkg/MdeModulePkg.dec
- EdkCompatibilityPkg/EdkCompatibilityPkg.dec
-
-[LibraryClasses]
- UefiBootServicesTableLib
- UefiRuntimeServicesTableLib
- UefiDriverEntryPoint
- BaseMemoryLib
- MemoryAllocationLib
- DebugLib
- BaseLib
- PeCoffLib
- PcdLib
- DxeServicesLib
- CacheMaintenanceLib
- BaseMemoryLib
- DevicePathLib
- UefiLib
-
-[Protocols]
- gEfiBootScriptSaveProtocolGuid ## PRODUCES
- gEfiS3SaveStateProtocolGuid ## CONSUMES
-
-[Guids]
- gEdkiiMemoryProfileGuid
-
-[Pcd]
- gEfiEdkCompatibilityPkgTokenSpaceGuid.BootScriptThunkDataPtr
- gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfilePropertyMask
-
-[Depex]
- gEfiS3SaveStateProtocolGuid
-
diff --git a/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/IA32/DispatchExecute.c b/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/IA32/DispatchExecute.c
deleted file mode 100644
index 7a3c9143b6..0000000000
--- a/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/IA32/DispatchExecute.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/** @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) 2010, 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 "ScriptSave.h"
-/**
- 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 Function The 32bit code entry to be executed.
- @param Param1 The first parameter to pass to 32bit code
- @param Param2 The second parameter to pass to 32bit code
- @retval EFI_SUCCESS Execute 32bit code successfully.
- @retval other Something wrong when execute the 32bit code
-
-**/
-EFI_STATUS
-Execute32BitCode (
- IN UINT64 Function,
- IN UINT64 Param1,
- IN UINT64 Param2
- )
-{
- DISPATCH_ENTRYPOINT_FUNC EntryFunc;
- EFI_STATUS Status;
-
- EntryFunc = (DISPATCH_ENTRYPOINT_FUNC) (UINTN) (Function);
- Status = EntryFunc ((VOID *)(UINTN)Param1, (VOID *)(UINTN)Param2);
-
- return Status;
-}
-
diff --git a/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/ScriptSave.c b/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/ScriptSave.c
deleted file mode 100644
index a3503a5d30..0000000000
--- a/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/ScriptSave.c
+++ /dev/null
@@ -1,993 +0,0 @@
-/** @file
- Implementation for S3 Boot Script Save thunk driver.
- This thunk driver consumes PI S3SaveState protocol to produce framework S3BootScriptSave Protocol
-
- Copyright (c) 2010 - 2015, 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 "ScriptSave.h"
-
-EFI_HANDLE mHandle;
-EFI_BOOT_SCRIPT_SAVE_PROTOCOL mS3ScriptSave = {
- BootScriptWrite,
- BootScriptCloseTable
- };
-EFI_S3_SAVE_STATE_PROTOCOL *mS3SaveState;
-
-/**
- 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 Function The 32bit code entry to be executed.
- @param Param1 The first parameter to pass to 32bit code
- @param Param2 The second parameter to pass to 32bit code
- @retval EFI_SUCCESS Execute 32bit code successfully.
- @retval other Something wrong when execute the 32bit code
-
-**/
-EFI_STATUS
-Execute32BitCode (
- IN UINT64 Function,
- IN UINT64 Param1,
- IN UINT64 Param2
- );
-
-/**
- A stub to convert framework boot script dispatch to PI boot script dispatch.
-
- @param ImageHandle It should be is NULL.
- @param Context The first parameter to pass to 32bit code
-
- @return dispatch value.
-
-**/
-EFI_STATUS
-EFIAPI
-FrameworkBootScriptDispatchStub (
- IN EFI_HANDLE ImageHandle,
- IN VOID *Context
- )
-{
- EFI_STATUS Status;
- DISPATCH_ENTRYPOINT_FUNC EntryFunc;
- VOID *PeiServices;
- IA32_DESCRIPTOR Idtr;
-
- DEBUG ((EFI_D_ERROR, "FrameworkBootScriptDispatchStub - 0x%08x\n", (UINTN)Context));
-
- EntryFunc = (DISPATCH_ENTRYPOINT_FUNC) (UINTN) (Context);
- AsmReadIdtr (&Idtr);
- PeiServices = (VOID *)(UINTN)(*(UINT32 *)(Idtr.Base - sizeof (UINT32)));
-
- //
- // ECP assumes first parameter is NULL, and second parameter is PeiServices.
- //
- Status = Execute32BitCode ((UINT64)(UINTN)EntryFunc, 0, (UINT64)(UINTN)PeiServices);
-
- return Status;
-}
-
-/**
- Internal function to add IO write opcode to the table.
-
- @param Marker The variable argument list to get the opcode
- and associated attributes.
-
- @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
- @retval EFI_SUCCESS Opcode is added.
-
-**/
-EFI_STATUS
-BootScriptIoWrite (
- IN VA_LIST Marker
- )
-{
- EFI_BOOT_SCRIPT_WIDTH Width;
- UINT64 Address;
- UINTN Count;
- UINT8 *Buffer;
-
- Width = VA_ARG (Marker, EFI_BOOT_SCRIPT_WIDTH);
- Address = VA_ARG (Marker, UINT64);
- Count = VA_ARG (Marker, UINTN);
- Buffer = VA_ARG (Marker, UINT8 *);
-
- return mS3SaveState->Write (
- mS3SaveState,
- EFI_BOOT_SCRIPT_IO_WRITE_OPCODE,
- Width,
- Address,
- Count,
- Buffer
- );
-}
-/**
- Internal function to add IO read/write opcode to the table.
-
- @param Marker The variable argument list to get the opcode
- and associated attributes.
-
- @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
- @retval EFI_SUCCESS Opcode is added.
-
-**/
-EFI_STATUS
-BootScriptIoReadWrite (
- IN VA_LIST Marker
- )
-{
- EFI_BOOT_SCRIPT_WIDTH Width;
- UINT64 Address;
- UINT8 *Data;
- UINT8 *DataMask;
-
- Width = VA_ARG (Marker, EFI_BOOT_SCRIPT_WIDTH);
- Address = VA_ARG (Marker, UINT64);
- Data = VA_ARG (Marker, UINT8 *);
- DataMask = VA_ARG (Marker, UINT8 *);
-
- return mS3SaveState->Write (
- mS3SaveState,
- EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE,
- Width,
- Address,
- Data,
- DataMask
- );
-}
-
-/**
- Internal function to add memory write opcode to the table.
-
- @param Marker The variable argument list to get the opcode
- and associated attributes.
-
- @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
- @retval EFI_SUCCESS Opcode is added.
-
-**/
-EFI_STATUS
-BootScriptMemWrite (
- IN VA_LIST Marker
- )
-{
- EFI_BOOT_SCRIPT_WIDTH Width;
- UINT64 Address;
- UINTN Count;
- UINT8 *Buffer;
-
- Width = VA_ARG (Marker, EFI_BOOT_SCRIPT_WIDTH);
- Address = VA_ARG (Marker, UINT64);
- Count = VA_ARG (Marker, UINTN);
- Buffer = VA_ARG (Marker, UINT8 *);
-
- return mS3SaveState->Write (
- mS3SaveState,
- EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE,
- Width,
- Address,
- Count,
- Buffer
- );
-}
-
-/**
- Internal function to add memory read/write opcode to the table.
-
- @param Marker The variable argument list to get the opcode
- and associated attributes.
-
- @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
- @retval EFI_SUCCESS Opcode is added.
-
-**/
-EFI_STATUS
-BootScriptMemReadWrite (
- IN VA_LIST Marker
- )
-{
- EFI_BOOT_SCRIPT_WIDTH Width;
- UINT64 Address;
- UINT8 *Data;
- UINT8 *DataMask;
-
- Width = VA_ARG (Marker, EFI_BOOT_SCRIPT_WIDTH);
- Address = VA_ARG (Marker, UINT64);
- Data = VA_ARG (Marker, UINT8 *);
- DataMask = VA_ARG (Marker, UINT8 *);
-
- return mS3SaveState->Write (
- mS3SaveState,
- EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE,
- Width,
- Address,
- Data,
- DataMask
- );
-}
-
-/**
- Internal function to add PciCfg write opcode to the table.
-
- @param Marker The variable argument list to get the opcode
- and associated attributes.
-
- @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
- @retval EFI_SUCCESS Opcode is added.
-
-**/
-EFI_STATUS
-BootScriptPciCfgWrite (
- IN VA_LIST Marker
- )
-{
- EFI_BOOT_SCRIPT_WIDTH Width;
- UINT64 Address;
- UINTN Count;
- UINT8 *Buffer;
-
- Width = VA_ARG (Marker, EFI_BOOT_SCRIPT_WIDTH);
- Address = VA_ARG (Marker, UINT64);
- Count = VA_ARG (Marker, UINTN);
- Buffer = VA_ARG (Marker, UINT8 *);
-
- return mS3SaveState->Write (
- mS3SaveState,
- EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE,
- Width,
- Address,
- Count,
- Buffer
- );
-}
-
-/**
- Internal function to PciCfg read/write opcode to the table.
-
- @param Marker The variable argument list to get the opcode
- and associated attributes.
-
- @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
- @retval EFI_SUCCESS Opcode is added.
-
-**/
-EFI_STATUS
-BootScriptPciCfgReadWrite (
- IN VA_LIST Marker
- )
-{
- EFI_BOOT_SCRIPT_WIDTH Width;
- UINT64 Address;
- UINT8 *Data;
- UINT8 *DataMask;
-
- Width = VA_ARG (Marker, EFI_BOOT_SCRIPT_WIDTH);
- Address = VA_ARG (Marker, UINT64);
- Data = VA_ARG (Marker, UINT8 *);
- DataMask = VA_ARG (Marker, UINT8 *);
-
- return mS3SaveState->Write (
- mS3SaveState,
- EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE,
- Width,
- Address,
- Data,
- DataMask
- );
-}
-/**
- Internal function to add PciCfg2 write opcode to the table.
-
- @param Marker The variable argument list to get the opcode
- and associated attributes.
-
- @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
- @retval EFI_SUCCESS Opcode is added.
-
-**/
-EFI_STATUS
-BootScriptPciCfg2Write (
- IN VA_LIST Marker
- )
-{
- EFI_BOOT_SCRIPT_WIDTH Width;
- UINT64 Address;
- UINTN Count;
- UINT8 *Buffer;
- UINT16 Segment;
-
- Width = VA_ARG (Marker, EFI_BOOT_SCRIPT_WIDTH);
- Address = VA_ARG (Marker, UINT64);
- Count = VA_ARG (Marker, UINTN);
- Buffer = VA_ARG (Marker, UINT8 *);
- Segment = VA_ARG (Marker, UINT16);
-
- return mS3SaveState->Write (
- mS3SaveState,
- EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE,
- Width,
- Segment,
- Address,
- Count,
- Buffer
- );
-}
-
-/**
- Internal function to PciCfg2 read/write opcode to the table.
-
- @param Marker The variable argument list to get the opcode
- and associated attributes.
-
- @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
- @retval EFI_SUCCESS Opcode is added.
-
-**/
-EFI_STATUS
-BootScriptPciCfg2ReadWrite (
- IN VA_LIST Marker
- )
-{
- EFI_BOOT_SCRIPT_WIDTH Width;
- UINT16 Segment;
- UINT64 Address;
- UINT8 *Data;
- UINT8 *DataMask;
-
- Width = VA_ARG (Marker, EFI_BOOT_SCRIPT_WIDTH);
- Address = VA_ARG (Marker, UINT64);
- Segment = VA_ARG (Marker, UINT16);
- Data = VA_ARG (Marker, UINT8 *);
- DataMask = VA_ARG (Marker, UINT8 *);
-
- return mS3SaveState->Write (
- mS3SaveState,
- EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE,
- Width,
- Segment,
- Address,
- Data,
- DataMask
- );
-}
-/**
- Internal function to add smbus execute opcode to the table.
-
- @param Marker The variable argument list to get the opcode
- and associated attributes.
-
- @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
- @retval EFI_SUCCESS Opcode is added.
-
-**/
-EFI_STATUS
-BootScriptSmbusExecute (
- IN VA_LIST Marker
- )
-{
- EFI_SMBUS_DEVICE_ADDRESS SlaveAddress;
- EFI_SMBUS_DEVICE_COMMAND Command;
- EFI_SMBUS_OPERATION Operation;
- BOOLEAN PecCheck;
- VOID *Buffer;
- UINTN *DataSize;
-
- SlaveAddress.SmbusDeviceAddress = VA_ARG (Marker, UINTN);
- Command = VA_ARG (Marker, EFI_SMBUS_DEVICE_COMMAND);
- Operation = VA_ARG (Marker, EFI_SMBUS_OPERATION);
- PecCheck = VA_ARG (Marker, BOOLEAN);
- DataSize = VA_ARG (Marker, UINTN *);
- Buffer = VA_ARG (Marker, VOID *);
-
- return mS3SaveState->Write (
- mS3SaveState,
- EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE,
- SlaveAddress,
- Command,
- Operation,
- PecCheck,
- DataSize,
- Buffer
- );
-}
-/**
- Internal function to add stall opcode to the table.
-
- @param Marker The variable argument list to get the opcode
- and associated attributes.
-
- @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
- @retval EFI_SUCCESS Opcode is added.
-
-**/
-EFI_STATUS
-BootScriptStall (
- IN VA_LIST Marker
- )
-{
- UINT32 Duration;
-
- Duration = VA_ARG (Marker, UINT32);
-
- return mS3SaveState->Write (
- mS3SaveState,
- EFI_BOOT_SCRIPT_STALL_OPCODE,
- Duration
- );
-}
-
-/**
- Internal function to add Save jmp address according to DISPATCH_OPCODE.
- We ignore "Context" parameter
-
- @param Marker The variable argument list to get the opcode
- and associated attributes.
-
- @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
- @retval EFI_SUCCESS Opcode is added.
-
-**/
-EFI_STATUS
-BootScriptDispatch (
- IN VA_LIST Marker
- )
-{
- VOID *EntryPoint;
-
- EntryPoint = (VOID*)(UINTN)VA_ARG (Marker, EFI_PHYSICAL_ADDRESS);
- return mS3SaveState->Write (
- mS3SaveState,
- EFI_BOOT_SCRIPT_DISPATCH_OPCODE,
- EntryPoint
- );
-}
-
-/**
- Internal function to add Save jmp address according to DISPATCH_OPCODE.
- We ignore "Context" parameter.
- We need create thunk stub to convert PEI entrypoint (used in Framework version)
- to DXE entrypoint (defined in PI spec).
-
- @param Marker The variable argument list to get the opcode
- and associated attributes.
-
- @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
- @retval EFI_SUCCESS Opcode is added.
-
-**/
-EFI_STATUS
-FrameworkBootScriptDispatch (
- IN VA_LIST Marker
- )
-{
- VOID *EntryPoint;
- VOID *Context;
-
- EntryPoint = (VOID*)(UINTN)VA_ARG (Marker, EFI_PHYSICAL_ADDRESS);
-
- //
- // Register callback
- //
- Context = EntryPoint;
- EntryPoint = (VOID *)(UINTN)FrameworkBootScriptDispatchStub;
- return mS3SaveState->Write (
- mS3SaveState,
- EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE,
- EntryPoint,
- Context
- );
-}
-
-/**
- Internal function to add memory pool operation to the table.
-
- @param Marker The variable argument list to get the opcode
- and associated attributes.
-
- @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
- @retval EFI_SUCCESS Opcode is added.
-
-**/
-EFI_STATUS
-BootScriptMemPoll (
- IN VA_LIST Marker
- )
-{
- EFI_BOOT_SCRIPT_WIDTH Width;
- UINT64 Address;
- UINT8 *BitMask;
- UINT8 *BitValue;
- UINT64 Duration;
- UINT64 LoopTimes;
- UINT64 Delay;
-
- Width = VA_ARG (Marker, EFI_BOOT_SCRIPT_WIDTH);
- Address = VA_ARG (Marker, UINT64);
- BitMask = VA_ARG (Marker, UINT8 *);
- BitValue = VA_ARG (Marker, UINT8 *);
- Duration = (UINT64)VA_ARG (Marker, UINT64);
- LoopTimes = (UINT64)VA_ARG (Marker, UINT64);
- //
- // Framework version: Duration is used for Stall(), which is Microseconds.
- // Total time is: Duration(Microseconds) * LoopTimes.
- // PI version: Duration is always 100ns. Delay is LoopTimes.
- // Total time is: 100ns * Delay.
- // So Delay = Duration(Microseconds) * LoopTimes / 100ns
- // = Duration * 1000ns * LoopTimes / 100ns
- // = Duration * 10 * LoopTimes
- //
- Delay = MultU64x64 (MultU64x32 (Duration, 10), LoopTimes);
-
- //
- // Framework version: First BitMask, then BitValue
- // PI version: First Data, then DataMask
- // So we revert their order in function call
- //
- return mS3SaveState->Write (
- mS3SaveState,
- EFI_BOOT_SCRIPT_MEM_POLL_OPCODE,
- Width,
- Address,
- BitValue,
- BitMask,
- Delay
- );
-}
-
-/**
- Internal function to add Save jmp address according to DISPATCH_OPCODE2.
- The "Context" parameter is not ignored.
-
- @param Marker The variable argument list to get the opcode
- and associated attributes.
-
- @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
- @retval EFI_SUCCESS Opcode is added.
-
-**/
-EFI_STATUS
-BootScriptDispatch2 (
- IN VA_LIST Marker
- )
-{
- VOID *EntryPoint;
- VOID *Context;
-
- EntryPoint = (VOID*)(UINTN)VA_ARG (Marker, EFI_PHYSICAL_ADDRESS);
- Context = (VOID*)(UINTN)VA_ARG (Marker, EFI_PHYSICAL_ADDRESS);
-
- return mS3SaveState->Write (
- mS3SaveState,
- EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE,
- EntryPoint,
- Context
- );
-}
-/**
- Internal function to add the opcode link node to the link
- list.
- @param Marker The variable argument list to get the opcode
- and associated attributes.
-
- @retval EFI_OUT_OF_RESOURCES Not enought resource to complete the operations.
- @retval EFI_SUCCESS The opcode entry is added to the link list
- successfully.
-**/
-EFI_STATUS
-BootScriptInformation (
- IN VA_LIST Marker
- )
-{
- UINT32 InformationLength;
- EFI_PHYSICAL_ADDRESS Information;
-
- InformationLength = VA_ARG (Marker, UINT32);
- Information = VA_ARG (Marker, EFI_PHYSICAL_ADDRESS);
-
- return mS3SaveState->Write (
- mS3SaveState,
- EFI_BOOT_SCRIPT_INFORMATION_OPCODE,
- InformationLength,
- (VOID*)(UINTN)Information
- );
-}
-
-/**
- Adds a record into a specified Framework boot script table.
-
- This function is used to store a boot script record into a given boot
- script table. If the table specified by TableName is nonexistent in the
- system, a new table will automatically be created and then the script record
- will be added into the new table. A boot script table can add new script records
- until EFI_BOOT_SCRIPT_SAVE_PROTOCOL.CloseTable() is called. Currently, the only
- meaningful table name is EFI_ACPI_S3_RESUME_SCRIPT_TABLE. This function is
- responsible for allocating necessary memory for the script.
-
- This function has a variable parameter list. The exact parameter list depends on
- the OpCode that is passed into the function. If an unsupported OpCode or illegal
- parameter list is passed in, this function returns EFI_INVALID_PARAMETER.
- If there are not enough resources available for storing more scripts, this function returns
- EFI_OUT_OF_RESOURCES.
-
- @param This A pointer to the EFI_BOOT_SCRIPT_SAVE_PROTOCOL instance.
- @param TableName Name of the script table. Currently, the only meaningful value is
- EFI_ACPI_S3_RESUME_SCRIPT_TABLE.
- @param OpCode The operation code (opcode) number.
- @param ... Argument list that is specific to each opcode.
-
- @retval EFI_SUCCESS The operation succeeded. A record was added into the
- specified script table.
- @retval EFI_INVALID_PARAMETER The parameter is illegal or the given boot script is not supported.
- If the opcode is unknow or not supported because of the PCD
- Feature Flags.
- @retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script.
-
-**/
-EFI_STATUS
-EFIAPI
-BootScriptWrite (
- IN EFI_BOOT_SCRIPT_SAVE_PROTOCOL *This,
- IN UINT16 TableName,
- IN UINT16 OpCode,
- ...
- )
-{
- EFI_STATUS Status;
- VA_LIST Marker;
-
- if (TableName != FRAMEWORK_EFI_ACPI_S3_RESUME_SCRIPT_TABLE) {
- //
- // Only S3 boot script is supported for now
- //
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // Build script according to opcode
- //
- switch (OpCode) {
-
- case EFI_BOOT_SCRIPT_IO_WRITE_OPCODE:
- VA_START (Marker, OpCode);
- Status = BootScriptIoWrite (Marker);
- VA_END (Marker);
- break;
-
- case EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE:
- VA_START (Marker, OpCode);
- Status = BootScriptIoReadWrite (Marker);
- VA_END (Marker);
- break;
-
- case EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE:
- VA_START (Marker, OpCode);
- Status = BootScriptMemWrite (Marker);
- VA_END (Marker);
- break;
-
- case EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE:
- VA_START (Marker, OpCode);
- Status = BootScriptMemReadWrite (Marker);
- VA_END (Marker);
- break;
-
- case EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE:
- VA_START (Marker, OpCode);
- Status = BootScriptPciCfgWrite (Marker);
- VA_END (Marker);
- break;
-
- case EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE:
- VA_START (Marker, OpCode);
- Status = BootScriptPciCfgReadWrite (Marker);
- VA_END (Marker);
- break;
-
- case EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE:
- VA_START (Marker, OpCode);
- Status = BootScriptSmbusExecute (Marker);
- VA_END (Marker);
- break;
-
- case EFI_BOOT_SCRIPT_STALL_OPCODE:
- VA_START (Marker, OpCode);
- Status = BootScriptStall (Marker);
- VA_END (Marker);
-
- break;
-
- case EFI_BOOT_SCRIPT_DISPATCH_OPCODE:
- VA_START (Marker, OpCode);
- Status = FrameworkBootScriptDispatch (Marker);
- VA_END (Marker);
- break;
-
- case FRAMEWORK_EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE:
- VA_START (Marker, OpCode);
- Status = BootScriptDispatch2 (Marker);
- VA_END (Marker);
- break;
-
- case EFI_BOOT_SCRIPT_INFORMATION_OPCODE:
- VA_START (Marker, OpCode);
- Status = BootScriptInformation (Marker);
- VA_END (Marker);
- break;
-
- case FRAMEWORK_EFI_BOOT_SCRIPT_MEM_POLL_OPCODE:
- VA_START (Marker, OpCode);
- Status = BootScriptMemPoll (Marker);
- VA_END (Marker);
- break;
-
- case EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE:
- VA_START (Marker, OpCode);
- Status = BootScriptPciCfg2Write (Marker);
- VA_END (Marker);
- break;
-
- case EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE:
- VA_START (Marker, OpCode);
- Status = BootScriptPciCfg2ReadWrite (Marker);
- VA_END (Marker);
- break;
-
- default:
- Status = EFI_INVALID_PARAMETER;
- break;
- }
-
- return Status;
-}
-
-/**
- Closes the specified script table.
-
- This function closes the specified boot script table and returns the base address
- of the table. It allocates a new pool to duplicate all the boot scripts in the specified
- table. Once this function is called, the specified table will be destroyed after it is
- copied into the allocated pool. As a result, any attempts to add a script record into a
- closed table will cause a new table to be created. The base address of the allocated pool
- will be returned in Address. After using the boot script table, the caller is responsible
- for freeing the pool that is allocated by this function. If the boot script table,
- such as EFI_ACPI_S3_RESUME_SCRIPT_TABLE, is required to be stored in a nonperturbed
- memory region, the caller should copy the table into the nonperturbed memory region by itself.
-
- @param This A pointer to the EFI_BOOT_SCRIPT_SAVE_PROTOCOL instance.
- @param TableName Name of the script table. Currently, the only meaningful value is
- EFI_ACPI_S3_RESUME_SCRIPT_TABLE.
- @param Address A pointer to the physical address where the table begins.
-
- @retval EFI_SUCCESS The table was successfully returned.
- @retval EFI_NOT_FOUND The specified table was not created previously.
- @retval EFI_OUT_OF_RESOURCE Memory is insufficient to hold the reorganized boot script table.
- @retval EFI_UNSUPPORTED the table type is not EFI_ACPI_S3_RESUME_SCRIPT_TABLE
-
-**/
-EFI_STATUS
-EFIAPI
-BootScriptCloseTable (
- IN EFI_BOOT_SCRIPT_SAVE_PROTOCOL *This,
- IN UINT16 TableName,
- OUT EFI_PHYSICAL_ADDRESS *Address
- )
-{
- if (TableName != FRAMEWORK_EFI_ACPI_S3_RESUME_SCRIPT_TABLE) {
- //
- // Only S3 boot script is supported for now
- //
- return EFI_NOT_FOUND;
- }
- //
- // Here the close table is not implemented.
- //
-
- return EFI_UNSUPPORTED;
-}
-
-/**
- Register image to memory profile.
-
- @param FileName File name of the image.
- @param ImageBase Image base address.
- @param ImageSize Image size.
- @param FileType File type of the image.
-
-**/
-VOID
-RegisterMemoryProfileImage (
- IN EFI_GUID *FileName,
- IN PHYSICAL_ADDRESS ImageBase,
- IN UINT64 ImageSize,
- IN EFI_FV_FILETYPE FileType
- )
-{
- EFI_STATUS Status;
- EDKII_MEMORY_PROFILE_PROTOCOL *ProfileProtocol;
- MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FilePath;
- UINT8 TempBuffer[sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH) + sizeof (EFI_DEVICE_PATH_PROTOCOL)];
-
- if ((PcdGet8 (PcdMemoryProfilePropertyMask) & BIT0) != 0) {
-
- FilePath = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)TempBuffer;
- Status = gBS->LocateProtocol (&gEdkiiMemoryProfileGuid, NULL, (VOID **) &ProfileProtocol);
- if (!EFI_ERROR (Status)) {
- EfiInitializeFwVolDevicepathNode (FilePath, FileName);
- SetDevicePathEndNode (FilePath + 1);
-
- Status = ProfileProtocol->RegisterImage (
- ProfileProtocol,
- (EFI_DEVICE_PATH_PROTOCOL *) FilePath,
- ImageBase,
- ImageSize,
- FileType
- );
- }
- }
-}
-
-/**
- This routine is entry point of ScriptSave driver.
-
- @param ImageHandle Handle for this drivers loaded image protocol.
- @param SystemTable EFI system table.
-
- @retval EFI_OUT_OF_RESOURCES No enough resource
- @retval EFI_SUCCESS Succesfully installed the ScriptSave driver.
- @retval other Errors occured.
-
-**/
-EFI_STATUS
-EFIAPI
-InitializeScriptSaveOnS3SaveState (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- UINT8 *Buffer;
- UINTN BufferSize;
- PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
- BOOT_SCRIPT_THUNK_DATA *BootScriptThunkData;
- EFI_STATUS Status;
- VOID *DevicePath;
- EFI_PHYSICAL_ADDRESS MemoryAddress;
- UINTN PageNumber;
- EFI_HANDLE NewImageHandle;
-
- //
- // Test if the gEfiCallerIdGuid of this image is already installed. if not, the entry
- // point is loaded by DXE code which is the first time loaded. or else, it is already
- // be reloaded be itself.This is a work-around
- //
- Status = gBS->LocateProtocol (&gEfiCallerIdGuid, NULL, &DevicePath);
- if (EFI_ERROR (Status)) {
- //
- // This is the first-time loaded by DXE core. reload itself to RESERVED mem
- //
- //
- // A workaround: Here we install a dummy handle
- //
- NewImageHandle = NULL;
- Status = gBS->InstallProtocolInterface (
- &NewImageHandle,
- &gEfiCallerIdGuid,
- EFI_NATIVE_INTERFACE,
- NULL
- );
- ASSERT_EFI_ERROR (Status);
-
- Status = GetSectionFromAnyFv (
- &gEfiCallerIdGuid,
- EFI_SECTION_PE32,
- 0,
- (VOID **) &Buffer,
- &BufferSize
- );
- ASSERT_EFI_ERROR (Status);
- ImageContext.Handle = Buffer;
- ImageContext.ImageRead = PeCoffLoaderImageReadFromMemory;
- //
- // Get information about the image being loaded
- //
- Status = PeCoffLoaderGetImageInfo (&ImageContext);
- ASSERT_EFI_ERROR (Status);
-
- MemoryAddress = SIZE_4GB - 1;
- if (ImageContext.SectionAlignment > EFI_PAGE_SIZE) {
- PageNumber = EFI_SIZE_TO_PAGES ((UINTN) (ImageContext.ImageSize + ImageContext.SectionAlignment));
- } else {
- PageNumber = EFI_SIZE_TO_PAGES ((UINTN) ImageContext.ImageSize);
- }
- Status = gBS->AllocatePages (
- AllocateMaxAddress,
- EfiReservedMemoryType,
- PageNumber,
- &MemoryAddress
- );
- ASSERT_EFI_ERROR (Status);
- ImageContext.ImageAddress = (PHYSICAL_ADDRESS)(UINTN)MemoryAddress;
- //
- // Align buffer on section boundary
- //
- ImageContext.ImageAddress += ImageContext.SectionAlignment - 1;
- ImageContext.ImageAddress &= ~(ImageContext.SectionAlignment - 1);
- //
- // Load the image to our new buffer
- //
- Status = PeCoffLoaderLoadImage (&ImageContext);
- ASSERT_EFI_ERROR (Status);
-
- //
- // Relocate the image in our new buffer
- //
- Status = PeCoffLoaderRelocateImage (&ImageContext);
- ASSERT_EFI_ERROR (Status);
-
- //
- // Free the buffer allocated by ReadSection since the image has been relocated in the new buffer
- //
- gBS->FreePool (Buffer);
-
- //
- // Flush the instruction cache so the image data is written before we execute it
- //
- InvalidateInstructionCacheRange ((VOID *)(UINTN)ImageContext.ImageAddress, (UINTN)ImageContext.ImageSize);
-
- RegisterMemoryProfileImage (
- &gEfiCallerIdGuid,
- ImageContext.ImageAddress,
- ImageContext.ImageSize,
- EFI_FV_FILETYPE_DRIVER
- );
-
- Status = ((EFI_IMAGE_ENTRY_POINT)(UINTN)(ImageContext.EntryPoint)) (NewImageHandle, SystemTable);
- ASSERT_EFI_ERROR (Status);
-
- //
- // Additional step for BootScriptThunk integrity
- //
-
- //
- // Allocate BootScriptThunkData
- //
- BootScriptThunkData = AllocatePool (sizeof (BOOT_SCRIPT_THUNK_DATA));
- ASSERT (BootScriptThunkData != NULL);
-
- BootScriptThunkData->BootScriptThunkBase = ImageContext.ImageAddress;
- BootScriptThunkData->BootScriptThunkLength = ImageContext.ImageSize;
- //
- // Set BootScriptThunkData
- //
- PcdSet64 (BootScriptThunkDataPtr, (UINT64)(UINTN)BootScriptThunkData);
- return EFI_SUCCESS;
- } else {
- //
- // the entry point is invoked after reloading. following code only run in RESERVED mem
- //
-
- //
- // Locate and cache PI S3 Save State Protocol.
- //
- Status = gBS->LocateProtocol (
- &gEfiS3SaveStateProtocolGuid,
- NULL,
- (VOID **) &mS3SaveState
- );
- ASSERT_EFI_ERROR (Status);
-
- return gBS->InstallProtocolInterface (
- &mHandle,
- &gEfiBootScriptSaveProtocolGuid,
- EFI_NATIVE_INTERFACE,
- &mS3ScriptSave
- );
- }
-}
-
-
diff --git a/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/ScriptSave.h b/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/ScriptSave.h
deleted file mode 100644
index cac7b0b85c..0000000000
--- a/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/ScriptSave.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/** @file
- Header file for S3 Boot Script Saver thunk driver.
-
- Copyright (c) 2010 - 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.
-
-**/
-#ifndef __BOOT_SCRIPT_SAVE_ON_S3_SAVE_STATE_H__
-#define __BOOT_SCRIPT_SAVE_ON_S3_SAVE_STATE_H__
-#include <FrameworkDxe.h>
-
-#include <Protocol/BootScriptSave.h>
-#include <Protocol/S3SaveState.h>
-
-#include <Library/BaseLib.h>
-#include <Library/DebugLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Library/SmbusLib.h>
-#include <Library/PeCoffLib.h>
-#include <Library/PcdLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/DxeServicesLib.h>
-#include <Library/CacheMaintenanceLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/UefiLib.h>
-
-#include <Guid/BootScriptThunkData.h>
-#include <Guid/MemoryProfile.h>
-
-#include <IndustryStandard/SmBus.h>
-
-typedef
-EFI_STATUS
-(EFIAPI *DISPATCH_ENTRYPOINT_FUNC) (
- IN EFI_HANDLE ImageHandle,
- IN VOID *Context
- );
-
-/**
- Adds a record into a specified Framework boot script table.
-
- This function is used to store a boot script record into a given boot
- script table. If the table specified by TableName is nonexistent in the
- system, a new table will automatically be created and then the script record
- will be added into the new table. A boot script table can add new script records
- until EFI_BOOT_SCRIPT_SAVE_PROTOCOL.CloseTable() is called. Currently, the only
- meaningful table name is EFI_ACPI_S3_RESUME_SCRIPT_TABLE. This function is
- responsible for allocating necessary memory for the script.
-
- This function has a variable parameter list. The exact parameter list depends on
- the OpCode that is passed into the function. If an unsupported OpCode or illegal
- parameter list is passed in, this function returns EFI_INVALID_PARAMETER.
- If there are not enough resources available for storing more scripts, this function returns
- EFI_OUT_OF_RESOURCES.
-
- @param This A pointer to the EFI_BOOT_SCRIPT_SAVE_PROTOCOL instance.
- @param TableName Name of the script table. Currently, the only meaningful value is
- EFI_ACPI_S3_RESUME_SCRIPT_TABLE.
- @param OpCode The operation code (opcode) number.
- @param ... Argument list that is specific to each opcode.
-
- @retval EFI_SUCCESS The operation succeeded. A record was added into the
- specified script table.
- @retval EFI_INVALID_PARAMETER The parameter is illegal or the given boot script is not supported.
- If the opcode is unknow or not supported because of the PCD
- Feature Flags.
- @retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script.
-
-**/
-EFI_STATUS
-EFIAPI
-BootScriptWrite (
- IN EFI_BOOT_SCRIPT_SAVE_PROTOCOL *This,
- IN UINT16 TableName,
- IN UINT16 OpCode,
- ...
- );
-
-/**
- Closes the specified script table.
-
- This function closes the specified boot script table and returns the base address
- of the table. It allocates a new pool to duplicate all the boot scripts in the specified
- table. Once this function is called, the specified table will be destroyed after it is
- copied into the allocated pool. As a result, any attempts to add a script record into a
- closed table will cause a new table to be created. The base address of the allocated pool
- will be returned in Address. After using the boot script table, the caller is responsible
- for freeing the pool that is allocated by this function. If the boot script table,
- such as EFI_ACPI_S3_RESUME_SCRIPT_TABLE, is required to be stored in a nonperturbed
- memory region, the caller should copy the table into the nonperturbed memory region by itself.
-
- @param This A pointer to the EFI_BOOT_SCRIPT_SAVE_PROTOCOL instance.
- @param TableName Name of the script table. Currently, the only meaningful value is
- EFI_ACPI_S3_RESUME_SCRIPT_TABLE.
- @param Address A pointer to the physical address where the table begins.
-
- @retval EFI_SUCCESS The table was successfully returned.
- @retval EFI_NOT_FOUND The specified table was not created previously.
- @retval EFI_OUT_OF_RESOURCE Memory is insufficient to hold the reorganized boot script table.
- @retval EFI_UNSUPPORTED the table type is not EFI_ACPI_S3_RESUME_SCRIPT_TABLE
-
-**/
-EFI_STATUS
-EFIAPI
-BootScriptCloseTable (
- IN EFI_BOOT_SCRIPT_SAVE_PROTOCOL *This,
- IN UINT16 TableName,
- OUT EFI_PHYSICAL_ADDRESS *Address
- );
-
-#endif
diff --git a/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/X64/AsmDispatchExecute.S b/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/X64/AsmDispatchExecute.S
deleted file mode 100644
index 36f5fd5775..0000000000
--- a/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/X64/AsmDispatchExecute.S
+++ /dev/null
@@ -1,216 +0,0 @@
-#
-# Copyright (c) 2010, 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.
-#
-#
-# Module Name:
-#
-# AsmDispatchExecute.asm
-#
-# Abstract:
-#
-# This is the assembly code to transition from long mode to compatibility mode to execute 32-bit code and then
-# transit back to long mode.
-#
-#-------------------------------------------------------------------------------
-
-#----------------------------------------------------------------------------
-# Procedure: AsmExecute32BitCode
-#
-# Input: None
-#
-# Output: None
-#
-# Prototype: EFI_STATUS
-# AsmExecute32BitCode (
-# IN UINT64 Function,
-# IN UINT64 Param1,
-# IN UINT64 Param2,
-# IN IA32_DESCRIPTOR *InternalGdtr
-# );
-#
-#
-# Description: A thunk function to execute 32-bit code in long mode.
-#
-#----------------------------------------------------------------------------
-
-ASM_GLOBAL ASM_PFX(AsmExecute32BitCode)
-ASM_PFX(AsmExecute32BitCode):
- #
- # save orignal GDTR and CS
- #
- movl %ds, %eax
- push %rax
- movl %cs, %eax
- push %rax
- subq $0x10, %rsp
- sgdt (%rsp)
- #
- # load internal GDT
- #
- lgdt (%r9)
- #
- # Save general purpose register and rflag register
- #
- pushfq
- push %rdi
- push %rsi
- push %rbp
- push %rbx
-
- #
- # save CR3
- #
- movq %cr3, %rax
- movq %rax, %rbp
-
- #
- # Prepare the CS and return address for the transition from 32-bit to 64-bit mode
- #
- movq $0x10, %rax # load long mode selector
- shl $32, %rax
- lea ReloadCS(%rip), %r9 #Assume the ReloadCS is under 4G
- orq %r9, %rax
- push %rax
- #
- # Save parameters for 32-bit function call
- #
- movq %r8, %rax
- shl $32, %rax
- orq %rdx, %rax
- push %rax
- #
- # save the 32-bit function entry and the return address into stack which will be
- # retrieve in compatibility mode.
- #
- lea ReturnBack(%rip), %rax #Assume the ReloadCS is under 4G
- shl $32, %rax
- orq %rcx, %rax
- push %rax
-
- #
- # let rax save DS
- #
- movq $0x18, %rax
-
- #
- # Change to Compatible Segment
- #
- movq $8, %rcx # load compatible mode selector
- shl $32, %rcx
- lea Compatible(%rip), %rdx # assume address < 4G
- orq %rdx, %rcx
- push %rcx
- .byte 0xcb # retf
-
-Compatible:
- # reload DS/ES/SS to make sure they are correct referred to current GDT
- movw %ax, %ds
- movw %ax, %es
- movw %ax, %ss
-
- #
- # Disable paging
- #
- movq %cr0, %rcx
- btc $31, %ecx
- movq %rcx, %cr0
- #
- # Clear EFER.LME
- #
- movl $0xC0000080, %ecx
- rdmsr
- btc $8, %eax
- wrmsr
-
-# Now we are in protected mode
- #
- # Call 32-bit function. Assume the function entry address and parameter value is less than 4G
- #
- pop %rax # Here is the function entry
- #
- # Now the parameter is at the bottom of the stack, then call in to IA32 function.
- #
- jmp *%rax
-ReturnBack:
- pop %rcx # drop param1
- pop %rcx # drop param2
-
- #
- # restore CR4
- #
- movq %cr4, %rax
- bts $5, %eax
- movq %rax, %cr4
-
- #
- # restore CR3
- #
- movl %ebp, %eax
- movq %rax, %cr3
-
- #
- # Set EFER.LME to re-enable ia32-e
- #
- movl $0xC0000080, %ecx
- rdmsr
- bts $8, %eax
- wrmsr
- #
- # Enable paging
- #
- movq %cr0, %rax
- bts $31, %eax
- mov %rax, %cr0
-# Now we are in compatible mode
-
- #
- # Reload cs register
- #
- .byte 0xcb # retf
-ReloadCS:
- #
- # Now we're in Long Mode
- #
- #
- # Restore C register and eax hold the return status from 32-bit function.
- # Note: Do not touch rax from now which hold the return value from IA32 function
- #
- pop %rbx
- pop %rbp
- pop %rsi
- pop %rdi
- popfq
- #
- # Switch to orignal GDT and CS. here rsp is pointer to the orignal GDT descriptor.
- #
- lgdt (%rsp)
- #
- # drop GDT descriptor in stack
- #
- addq $0x10, %rsp
- #
- # switch to orignal CS and GDTR
- #
- pop %r9 # get CS
- shl $32, %r9 # rcx[32..47] <- Cs
- lea ReturnToLongMode(%rip), %rcx
- orq %r9, %rcx
- push %rcx
- .byte 0xcb # retf
-ReturnToLongMode:
- #
- # Reload original DS/ES/SS
- #
- pop %rcx
- movl %ecx, %ds
- movl %ecx, %es
- movl %ecx, %ss
- ret
-
diff --git a/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/X64/AsmDispatchExecute.asm b/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/X64/AsmDispatchExecute.asm
deleted file mode 100644
index 2d5d92056e..0000000000
--- a/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/X64/AsmDispatchExecute.asm
+++ /dev/null
@@ -1,216 +0,0 @@
-;
-; Copyright (c) 2010, 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.
-;
-;
-; Module Name:
-;
-; AsmDispatchExecute.asm
-;
-; Abstract:
-;
-; This is the assembly code to transition from long mode to compatibility mode to execute 32-bit code and then
-; transit back to long mode.
-;
-;-------------------------------------------------------------------------------
- .code
-;----------------------------------------------------------------------------
-; Procedure: AsmExecute32BitCode
-;
-; Input: None
-;
-; Output: None
-;
-; Prototype: EFI_STATUS
-; AsmExecute32BitCode (
-; IN UINT64 Function,
-; IN UINT64 Param1,
-; IN UINT64 Param2,
-; IN IA32_DESCRIPTOR *InternalGdtr
-; );
-;
-;
-; Description: A thunk function to execute 32-bit code in long mode.
-;
-;----------------------------------------------------------------------------
-AsmExecute32BitCode PROC
- ;
- ; save orignal GDTR and CS
- ;
- mov rax, ds
- push rax
- mov rax, cs
- push rax
- sub rsp, 10h
- sgdt fword ptr [rsp]
- ;
- ; load internal GDT
- ;
- lgdt fword ptr [r9]
- ;
- ; Save general purpose register and rflag register
- ;
- pushfq
- push rdi
- push rsi
- push rbp
- push rbx
-
- ;
- ; save CR3
- ;
- mov rax, cr3
- mov rbp, rax
-
- ;
- ; Prepare the CS and return address for the transition from 32-bit to 64-bit mode
- ;
- mov rax, 10h ; load long mode selector
- shl rax, 32
- mov r9, OFFSET ReloadCS ;Assume the ReloadCS is under 4G
- or rax, r9
- push rax
- ;
- ; Save parameters for 32-bit function call
- ;
- mov rax, r8
- shl rax, 32
- or rax, rdx
- push rax
- ;
- ; save the 32-bit function entry and the return address into stack which will be
- ; retrieve in compatibility mode.
- ;
- mov rax, OFFSET ReturnBack ;Assume the ReloadCS is under 4G
- shl rax, 32
- or rax, rcx
- push rax
-
- ;
- ; let rax save DS
- ;
- mov rax, 018h
-
- ;
- ; Change to Compatible Segment
- ;
- mov rcx, 08h ; load compatible mode selector
- shl rcx, 32
- mov rdx, OFFSET Compatible ; assume address < 4G
- or rcx, rdx
- push rcx
- retf
-
-Compatible:
- ; reload DS/ES/SS to make sure they are correct referred to current GDT
- mov ds, ax
- mov es, ax
- mov ss, ax
-
- ;
- ; Disable paging
- ;
- mov rcx, cr0
- btc ecx, 31
- mov cr0, rcx
- ;
- ; Clear EFER.LME
- ;
- mov ecx, 0C0000080h
- rdmsr
- btc eax, 8
- wrmsr
-
-; Now we are in protected mode
- ;
- ; Call 32-bit function. Assume the function entry address and parameter value is less than 4G
- ;
- pop rax ; Here is the function entry
- ;
- ; Now the parameter is at the bottom of the stack, then call in to IA32 function.
- ;
- jmp rax
-ReturnBack:
- pop rcx ; drop param1
- pop rcx ; drop param2
-
- ;
- ; restore CR4
- ;
- mov rax, cr4
- bts eax, 5
- mov cr4, rax
-
- ;
- ; restore CR3
- ;
- mov eax, ebp
- mov cr3, rax
-
- ;
- ; Set EFER.LME to re-enable ia32-e
- ;
- mov ecx, 0C0000080h
- rdmsr
- bts eax, 8
- wrmsr
- ;
- ; Enable paging
- ;
- mov rax, cr0
- bts eax, 31
- mov cr0, rax
-; Now we are in compatible mode
-
- ;
- ; Reload cs register
- ;
- retf
-ReloadCS:
- ;
- ; Now we're in Long Mode
- ;
- ;
- ; Restore C register and eax hold the return status from 32-bit function.
- ; Note: Do not touch rax from now which hold the return value from IA32 function
- ;
- pop rbx
- pop rbp
- pop rsi
- pop rdi
- popfq
- ;
- ; Switch to orignal GDT and CS. here rsp is pointer to the orignal GDT descriptor.
- ;
- lgdt fword ptr[rsp]
- ;
- ; drop GDT descriptor in stack
- ;
- add rsp, 10h
- ;
- ; switch to orignal CS and GDTR
- ;
- pop r9 ; get CS
- shl r9, 32 ; rcx[32..47] <- Cs
- mov rcx, OFFSET @F
- or rcx, r9
- push rcx
- retf
-@@:
- ;
- ; Reload original DS/ES/SS
- ;
- pop rcx
- mov ds, rcx
- mov es, rcx
- mov ss, rcx
- ret
-AsmExecute32BitCode ENDP
-
- END
diff --git a/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/X64/DispatchExecute.c b/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/X64/DispatchExecute.c
deleted file mode 100644
index 20567bddeb..0000000000
--- a/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/X64/DispatchExecute.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/** @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) 2010 - 2012, 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 "ScriptSave.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;
-
-///
-/// Byte packed structure for an IA-32 Interrupt Gate Descriptor.
-///
-typedef union {
- struct {
- UINT32 OffsetLow:16; ///< Offset bits 15..0.
- UINT32 Selector:16; ///< Selector.
- UINT32 Reserved_0:8; ///< Reserved.
- UINT32 GateType:8; ///< Gate Type. See #defines above.
- UINT32 OffsetHigh:16; ///< Offset bits 31..16.
- } Bits;
- UINT64 Uint64;
-} IA32_IDT_ENTRY;
-#pragma pack()
-
-#define COMPATIBILITY_MODE_SELECTOR 8
-
-//
-// Global Descriptor Table (GDT)
-//
-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 Function The 32bit code entry to be executed.
- @param Param1 The first parameter to pass to 32bit code
- @param Param2 The second parameter to pass to 32bit code
- @param InternalGdtr The GDT and GDT descriptor used by this library
-
- @retval EFI_SUCCESS Execute 32bit code successfully.
- @retval other Something wrong when execute the 32bit code
-**/
-EFI_STATUS
-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 Function The 32bit code entry to be executed.
- @param Param1 The first parameter to pass to 32bit code
- @param Param2 The second parameter to pass to 32bit code
- @retval EFI_SUCCESS Execute 32bit code successfully.
- @retval other Something wrong when execute the 32bit code
-
-**/
-EFI_STATUS
-Execute32BitCode (
- IN UINT64 Function,
- IN UINT64 Param1,
- IN UINT64 Param2
- )
-{
- EFI_STATUS Status;
- IA32_DESCRIPTOR *Ia32Idtr;
- IA32_DESCRIPTOR X64Idtr;
- UINTN Ia32IdtEntryCount;
- UINTN Index;
- IA32_IDT_ENTRY *Ia32IdtEntry;
-
- //
- // Save x64 IDT Descriptor
- //
- AsmReadIdtr ((IA32_DESCRIPTOR *) &X64Idtr);
-
- //
- // Get the IA32 IDT Descriptor saved in 16 bytes in front of X64 IDT table.
- //
- Ia32Idtr = (IA32_DESCRIPTOR *) (UINTN) (X64Idtr.Base - 16);
- Ia32IdtEntryCount = (Ia32Idtr->Limit + 1) / sizeof (IA32_IDT_ENTRY);
-
- Ia32IdtEntry = (IA32_IDT_ENTRY *)(Ia32Idtr->Base);
- for (Index = 0; Index < Ia32IdtEntryCount; Index ++ ) {
- //
- // Use the new Code Selector value
- //
- Ia32IdtEntry[Index].Bits.Selector = COMPATIBILITY_MODE_SELECTOR;
- }
-
- //
- // Setup IA32 IDT table for 32-bit framework Boot Script code
- //
- AsmWriteIdtr (Ia32Idtr);
-
- ASSERT (Function != 0);
-
- Status = AsmExecute32BitCode (
- Function,
- Param1,
- Param2,
- &mGdt
- );
-
- //
- // Restore X64 IDT table
- //
- AsmWriteIdtr ((IA32_DESCRIPTOR *) &X64Idtr);
-
- return Status;
-}
-