MdeModulePkg: Add PiDxeS3BootScriptLib
Signed-off-by: jljusten Reviewed-by: mdkinney Reviewed-by: rsun3 Reviewed-by: jyao1 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12224 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
		
							
								
								
									
										1753
									
								
								MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1753
									
								
								MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -0,0 +1,186 @@
 | 
			
		||||
/** @file
 | 
			
		||||
  This file declares the internal Framework Boot Script format used by
 | 
			
		||||
  the PI implementation of Script Saver and Executor.
 | 
			
		||||
 | 
			
		||||
  Copyright (c) 2006, 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_INTERNAL_FORMAT_H_
 | 
			
		||||
#define _BOOT_SCRIPT_INTERNAL_FORMAT_H_
 | 
			
		||||
 | 
			
		||||
#pragma pack(1)
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
// Boot Script Opcode Header Structure Definitions
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  UINT16  OpCode;
 | 
			
		||||
  UINT8   Length;
 | 
			
		||||
} EFI_BOOT_SCRIPT_GENERIC_HEADER;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  UINT16  OpCode;
 | 
			
		||||
  UINT8   Length;
 | 
			
		||||
  UINT16  Version;
 | 
			
		||||
  UINT32  TableLength;
 | 
			
		||||
  UINT16  Reserved[2];
 | 
			
		||||
} EFI_BOOT_SCRIPT_TABLE_HEADER;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  UINT16                OpCode;
 | 
			
		||||
  UINT8                 Length;
 | 
			
		||||
  UINT32                Width;
 | 
			
		||||
} EFI_BOOT_SCRIPT_COMMON_HEADER;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  UINT16                OpCode;
 | 
			
		||||
  UINT8                 Length;
 | 
			
		||||
  UINT32                Width;
 | 
			
		||||
  UINT32                Count;
 | 
			
		||||
  UINT64                Address;
 | 
			
		||||
} EFI_BOOT_SCRIPT_IO_WRITE;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  UINT16                OpCode;
 | 
			
		||||
  UINT8                 Length;
 | 
			
		||||
  UINT32                Width;
 | 
			
		||||
  UINT64                Address;
 | 
			
		||||
} EFI_BOOT_SCRIPT_IO_READ_WRITE;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  UINT16                OpCode;
 | 
			
		||||
  UINT8                 Length;
 | 
			
		||||
  UINT32                Width;
 | 
			
		||||
  UINT32                Count;
 | 
			
		||||
  UINT64                Address;
 | 
			
		||||
} EFI_BOOT_SCRIPT_MEM_WRITE;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  UINT16                OpCode;
 | 
			
		||||
  UINT8                 Length;
 | 
			
		||||
  UINT32                Width;
 | 
			
		||||
  UINT64                Address;
 | 
			
		||||
} EFI_BOOT_SCRIPT_MEM_READ_WRITE;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  UINT16                OpCode;
 | 
			
		||||
  UINT8                 Length;
 | 
			
		||||
  UINT32                Width;
 | 
			
		||||
  UINT32                Count;
 | 
			
		||||
  UINT64                Address;
 | 
			
		||||
} EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  UINT16                OpCode;
 | 
			
		||||
  UINT8                 Length;
 | 
			
		||||
  UINT32                Width;
 | 
			
		||||
  UINT32                Count;
 | 
			
		||||
  UINT64                Address;
 | 
			
		||||
  UINT16                Segment;
 | 
			
		||||
} EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  UINT16                OpCode;
 | 
			
		||||
  UINT8                 Length;
 | 
			
		||||
  UINT32                Width;
 | 
			
		||||
  UINT64                Address;
 | 
			
		||||
} EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  UINT16                OpCode;
 | 
			
		||||
  UINT8                 Length;
 | 
			
		||||
  UINT32                Width;
 | 
			
		||||
  UINT64                Address;
 | 
			
		||||
  UINT16                Segment;
 | 
			
		||||
} EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  UINT16                    OpCode;
 | 
			
		||||
  UINT8                     Length;
 | 
			
		||||
  UINT64                    SmBusAddress;
 | 
			
		||||
  UINT32                    Operation;
 | 
			
		||||
  UINT32                    DataSize;
 | 
			
		||||
} EFI_BOOT_SCRIPT_SMBUS_EXECUTE;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  UINT16  OpCode;
 | 
			
		||||
  UINT8   Length;
 | 
			
		||||
  UINT64  Duration;
 | 
			
		||||
} EFI_BOOT_SCRIPT_STALL;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  UINT16                OpCode;
 | 
			
		||||
  UINT8                 Length;
 | 
			
		||||
  EFI_PHYSICAL_ADDRESS  EntryPoint;
 | 
			
		||||
} EFI_BOOT_SCRIPT_DISPATCH;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  UINT16                OpCode;
 | 
			
		||||
  UINT8                 Length;
 | 
			
		||||
  EFI_PHYSICAL_ADDRESS  EntryPoint;
 | 
			
		||||
  EFI_PHYSICAL_ADDRESS  Context;
 | 
			
		||||
} EFI_BOOT_SCRIPT_DISPATCH_2;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  UINT16  OpCode;
 | 
			
		||||
  UINT8   Length;
 | 
			
		||||
  UINT32  Width;
 | 
			
		||||
  UINT64  Address;
 | 
			
		||||
  UINT64  Duration;
 | 
			
		||||
  UINT64  LoopTimes;
 | 
			
		||||
} EFI_BOOT_SCRIPT_MEM_POLL;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  UINT16  OpCode;
 | 
			
		||||
  UINT8   Length;
 | 
			
		||||
  UINT32                InformationLength;  
 | 
			
		||||
  EFI_PHYSICAL_ADDRESS  Information;
 | 
			
		||||
} EFI_BOOT_SCRIPT_INFORMATION;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  UINT16  OpCode;
 | 
			
		||||
  UINT8   Length;
 | 
			
		||||
  UINT32  Width;
 | 
			
		||||
  UINT64  Address;
 | 
			
		||||
  UINT64  Delay;
 | 
			
		||||
} EFI_BOOT_SCRIPT_IO_POLL;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  UINT16  OpCode;
 | 
			
		||||
  UINT8   Length;
 | 
			
		||||
  UINT32  Width;
 | 
			
		||||
  UINT64  Address;
 | 
			
		||||
  UINT64  Delay;
 | 
			
		||||
} EFI_BOOT_SCRIPT_PCI_CONFIG_POLL;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  UINT16  OpCode;
 | 
			
		||||
  UINT8   Length;
 | 
			
		||||
  UINT32  Width;
 | 
			
		||||
  UINT64  Address;
 | 
			
		||||
  UINT16  Segment;  
 | 
			
		||||
  UINT64  Delay;
 | 
			
		||||
} EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  UINT16  OpCode;
 | 
			
		||||
  UINT8   Length;
 | 
			
		||||
} EFI_BOOT_SCRIPT_TERMINATE;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#pragma pack()
 | 
			
		||||
 | 
			
		||||
#define BOOT_SCRIPT_NODE_MAX_LENGTH   1024
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										1852
									
								
								MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1852
									
								
								MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -0,0 +1,70 @@
 | 
			
		||||
## @file
 | 
			
		||||
# S3 boot script Library which could be used for multi phases. 
 | 
			
		||||
#
 | 
			
		||||
# Copyright (c) 2006 - 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.
 | 
			
		||||
#
 | 
			
		||||
##
 | 
			
		||||
 | 
			
		||||
[Defines]
 | 
			
		||||
  INF_VERSION                    = 0x00010005
 | 
			
		||||
  BASE_NAME                      = DxeS3BootScriptLib
 | 
			
		||||
  FILE_GUID                      = 57F9967B-26CD-4262-837A-55B8AA158254
 | 
			
		||||
  MODULE_TYPE                    = DXE_DRIVER
 | 
			
		||||
  VERSION_STRING                 = 1.0
 | 
			
		||||
  LIBRARY_CLASS                  = S3BootScriptLib|SEC PEIM PEI_CORE DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER DXE_SAL_DRIVER UEFI_DRIVER UEFI_APPLICATION
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  CONSTRUCTOR                    = S3BootScriptLibInitialize
 | 
			
		||||
 | 
			
		||||
#
 | 
			
		||||
# The following information is for reference only and not required by the build tools.
 | 
			
		||||
#
 | 
			
		||||
#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
[Sources]
 | 
			
		||||
  BootScriptSave.c
 | 
			
		||||
  BootScriptExecute.c
 | 
			
		||||
  InternalBootScriptLib.h
 | 
			
		||||
  BootScriptInternalFormat.h
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
[Packages]
 | 
			
		||||
  MdePkg/MdePkg.dec
 | 
			
		||||
  MdeModulePkg/MdeModulePkg.dec
 | 
			
		||||
 | 
			
		||||
[LibraryClasses]
 | 
			
		||||
  UefiBootServicesTableLib
 | 
			
		||||
  BaseLib
 | 
			
		||||
  BaseMemoryLib
 | 
			
		||||
  TimerLib
 | 
			
		||||
  DebugLib
 | 
			
		||||
  PcdLib
 | 
			
		||||
  UefiLib
 | 
			
		||||
  SmbusLib
 | 
			
		||||
  PciLib
 | 
			
		||||
  IoLib 
 | 
			
		||||
  LockBoxLib
 | 
			
		||||
  
 | 
			
		||||
[Guids]
 | 
			
		||||
  gEfiEventExitBootServicesGuid                  # ALWAYS_CONSUMED
 | 
			
		||||
 | 
			
		||||
[Protocols]
 | 
			
		||||
  gEfiSmmBase2ProtocolGuid                       # ALWAYS_CONSUMED
 | 
			
		||||
  gEfiDxeSmmReadyToLockProtocolGuid              # ALWAYS_CONSUMED
 | 
			
		||||
  gEfiSmmReadyToLockProtocolGuid                 # ALWAYS_CONSUMED
 | 
			
		||||
  
 | 
			
		||||
[Pcd]
 | 
			
		||||
  gEfiMdeModulePkgTokenSpaceGuid.PcdS3BootScriptTablePrivateDataPtr                   ## CONSUMES
 | 
			
		||||
  gEfiMdeModulePkgTokenSpaceGuid.PcdS3BootScriptRuntimeTableReservePageNumber         ## CONSUMES
 | 
			
		||||
 | 
			
		||||
[Depex]
 | 
			
		||||
  gPcdProtocolGuid 
 | 
			
		||||
@@ -0,0 +1,102 @@
 | 
			
		||||
/** @file
 | 
			
		||||
  Support for S3 boot script lib. This file defined some internal macro and internal 
 | 
			
		||||
  data structure
 | 
			
		||||
 
 | 
			
		||||
  Copyright (c) 2006 - 2011, 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 __INTERNAL_BOOT_SCRIPT_LIB__
 | 
			
		||||
#define __INTERNAL_BOOT_SCRIPT_LIB__
 | 
			
		||||
 | 
			
		||||
#include <PiDxe.h>
 | 
			
		||||
 | 
			
		||||
#include <Guid/EventGroup.h>
 | 
			
		||||
#include <Protocol/SmmBase2.h>
 | 
			
		||||
#include <Protocol/DxeSmmReadyToLock.h>
 | 
			
		||||
#include <Protocol/SmmReadyToLock.h>
 | 
			
		||||
 | 
			
		||||
#include <Library/S3BootScriptLib.h>
 | 
			
		||||
 | 
			
		||||
#include <Library/UefiBootServicesTableLib.h>
 | 
			
		||||
#include <Library/BaseLib.h>
 | 
			
		||||
#include <Library/PcdLib.h>
 | 
			
		||||
#include <Library/SmbusLib.h>
 | 
			
		||||
#include <Library/IoLib.h>
 | 
			
		||||
#include <Library/PciLib.h>
 | 
			
		||||
#include <Library/DebugLib.h>
 | 
			
		||||
#include <Library/BaseMemoryLib.h>
 | 
			
		||||
#include <Library/TimerLib.h>
 | 
			
		||||
#include <Library/UefiLib.h>
 | 
			
		||||
#include <Library/LockBoxLib.h>
 | 
			
		||||
 | 
			
		||||
#include "BootScriptInternalFormat.h"
 | 
			
		||||
 | 
			
		||||
#define MAX_IO_ADDRESS 0xFFFF
 | 
			
		||||
 | 
			
		||||
#define PCI_ADDRESS_ENCODE(A) (UINTN)PCI_LIB_ADDRESS( \
 | 
			
		||||
        (((A)& 0xff000000) >> 24), (((A) &0x00ff0000) >> 16), (((A) & 0xff00) >> 8), ((RShiftU64 ((A), 32) & 0xfff) | ((A)& 0xff)) \
 | 
			
		||||
        )
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
typedef union {
 | 
			
		||||
  UINT8 volatile  *Buf;
 | 
			
		||||
  UINT8 volatile  *Uint8;
 | 
			
		||||
  UINT16 volatile *Uint16;
 | 
			
		||||
  UINT32 volatile *Uint32;
 | 
			
		||||
  UINT64 volatile *Uint64;
 | 
			
		||||
  UINTN volatile   Uint;
 | 
			
		||||
} PTR;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// Minimum and maximum length for SMBus bus block protocols defined in SMBus spec 2.0.
 | 
			
		||||
//
 | 
			
		||||
#define MIN_SMBUS_BLOCK_LEN               1
 | 
			
		||||
#define MAX_SMBUS_BLOCK_LEN               32
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
// The boot script private data.
 | 
			
		||||
//
 | 
			
		||||
typedef struct {
 | 
			
		||||
  UINT8           *TableBase;
 | 
			
		||||
  UINT32          TableLength;               // Record the actual memory length 
 | 
			
		||||
  UINT16          TableMemoryPageNumber;     // Record the page number Allocated for the table 
 | 
			
		||||
  BOOLEAN         AtRuntime;                 // Record if current state is after SmmReadyToLock
 | 
			
		||||
  BOOLEAN         InSmm;                     // Record if this library is in SMM.
 | 
			
		||||
} SCRIPT_TABLE_PRIVATE_DATA;
 | 
			
		||||
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *DISPATCH_ENTRYPOINT_FUNC) (
 | 
			
		||||
  IN EFI_HANDLE ImageHandle,
 | 
			
		||||
  IN VOID       *Context
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
extern SCRIPT_TABLE_PRIVATE_DATA       *mS3BootScriptTablePtr;
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
// Define Opcode for Label which is implementation specific and no standard spec define.
 | 
			
		||||
//
 | 
			
		||||
#define  S3_BOOT_SCRIPT_LIB_LABEL_OPCODE    0xFE
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// The opcode indicate the start of the boot script table.
 | 
			
		||||
///
 | 
			
		||||
#define S3_BOOT_SCRIPT_LIB_TABLE_OPCODE                  0xAA
 | 
			
		||||
///
 | 
			
		||||
/// The opcode indicate the end of the boot script table.
 | 
			
		||||
///
 | 
			
		||||
#define S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE              0xFF
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif //__INTERNAL_BOOT_SCRIPT_LIB__
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user