2011-08-30 00:17:27 +02:00
|
|
|
/** @file
|
2016-08-17 10:51:55 +02:00
|
|
|
Support for S3 boot script lib. This file defined some internal macro and internal
|
2011-08-30 00:17:27 +02:00
|
|
|
data structure
|
2016-08-17 10:51:55 +02:00
|
|
|
|
2016-08-08 12:20:58 +02:00
|
|
|
Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
|
2011-08-30 00:17:27 +02:00
|
|
|
|
2019-04-04 01:05:13 +02:00
|
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
2011-08-30 00:17:27 +02:00
|
|
|
|
|
|
|
**/
|
2021-12-05 23:54:02 +01:00
|
|
|
|
2011-08-30 00:17:27 +02:00
|
|
|
#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>
|
2015-09-15 09:49:12 +02:00
|
|
|
#include <Protocol/SmmExitBootServices.h>
|
|
|
|
#include <Protocol/SmmLegacyBoot.h>
|
2011-08-30 00:17:27 +02:00
|
|
|
|
|
|
|
#include <Library/S3BootScriptLib.h>
|
|
|
|
|
|
|
|
#include <Library/UefiBootServicesTableLib.h>
|
|
|
|
#include <Library/BaseLib.h>
|
|
|
|
#include <Library/PcdLib.h>
|
|
|
|
#include <Library/SmbusLib.h>
|
|
|
|
#include <Library/IoLib.h>
|
2016-08-08 12:20:58 +02:00
|
|
|
#include <Library/PciSegmentLib.h>
|
2011-08-30 00:17:27 +02:00
|
|
|
#include <Library/DebugLib.h>
|
|
|
|
#include <Library/BaseMemoryLib.h>
|
|
|
|
#include <Library/TimerLib.h>
|
|
|
|
#include <Library/UefiLib.h>
|
|
|
|
#include <Library/LockBoxLib.h>
|
|
|
|
|
|
|
|
#include "BootScriptInternalFormat.h"
|
|
|
|
|
2021-12-05 23:54:02 +01:00
|
|
|
#define MAX_IO_ADDRESS 0xFFFF
|
2011-08-30 00:17:27 +02:00
|
|
|
|
2011-11-28 07:19:36 +01:00
|
|
|
//
|
2016-08-08 12:20:58 +02:00
|
|
|
// Macro to convert a UEFI PCI address + segment to a PCI Segment Library PCI address
|
2011-11-28 07:19:36 +01:00
|
|
|
//
|
2021-12-05 23:54:02 +01:00
|
|
|
#define PCI_ADDRESS_ENCODE(S, A) PCI_SEGMENT_LIB_ADDRESS(\
|
2016-08-08 12:20:58 +02:00
|
|
|
S, \
|
|
|
|
((((UINTN)(A)) & 0xff000000) >> 24), \
|
|
|
|
((((UINTN)(A)) & 0x00ff0000) >> 16), \
|
|
|
|
((((UINTN)(A)) & 0xff00) >> 8), \
|
|
|
|
((RShiftU64 ((A), 32) & 0xfff) | ((A) & 0xff)) \
|
|
|
|
)
|
2011-08-30 00:17:27 +02:00
|
|
|
|
|
|
|
typedef union {
|
2021-12-05 23:54:02 +01:00
|
|
|
UINT8 volatile *Buf;
|
|
|
|
UINT8 volatile *Uint8;
|
|
|
|
UINT16 volatile *Uint16;
|
|
|
|
UINT32 volatile *Uint32;
|
|
|
|
UINT64 volatile *Uint64;
|
|
|
|
UINTN volatile Uint;
|
2011-08-30 00:17:27 +02:00
|
|
|
} PTR;
|
|
|
|
|
|
|
|
// Minimum and maximum length for SMBus bus block protocols defined in SMBus spec 2.0.
|
|
|
|
//
|
2021-12-05 23:54:02 +01:00
|
|
|
#define MIN_SMBUS_BLOCK_LEN 1
|
|
|
|
#define MAX_SMBUS_BLOCK_LEN 32
|
2011-08-30 00:17:27 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// The boot script private data.
|
|
|
|
//
|
|
|
|
typedef struct {
|
2021-12-05 23:54:02 +01:00
|
|
|
UINT8 *TableBase;
|
|
|
|
UINT32 TableLength; // Record the actual memory length
|
|
|
|
UINT16 TableMemoryPageNumber; // Record the page number Allocated for the table
|
|
|
|
BOOLEAN InSmm; // Record if this library is in SMM.
|
|
|
|
BOOLEAN AtRuntime; // Record if current state is after SmmExitBootServices or SmmLegacyBoot.
|
|
|
|
UINT32 BootTimeScriptLength; // Maintain boot time script length in LockBox after SmmReadyToLock in SMM.
|
|
|
|
BOOLEAN SmmLocked; // Record if current state is after SmmReadyToLock
|
|
|
|
BOOLEAN BackFromS3; // Indicate that the system is back from S3.
|
2011-08-30 00:17:27 +02:00
|
|
|
} SCRIPT_TABLE_PRIVATE_DATA;
|
|
|
|
|
|
|
|
typedef
|
|
|
|
EFI_STATUS
|
2021-12-05 23:54:02 +01:00
|
|
|
(EFIAPI *DISPATCH_ENTRYPOINT_FUNC)(
|
2011-08-30 00:17:27 +02:00
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN VOID *Context
|
|
|
|
);
|
|
|
|
|
2021-12-05 23:54:02 +01:00
|
|
|
extern SCRIPT_TABLE_PRIVATE_DATA *mS3BootScriptTablePtr;
|
2011-08-30 00:17:27 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Define Opcode for Label which is implementation specific and no standard spec define.
|
|
|
|
//
|
2021-12-05 23:54:02 +01:00
|
|
|
#define S3_BOOT_SCRIPT_LIB_LABEL_OPCODE 0xFE
|
2011-08-30 00:17:27 +02:00
|
|
|
|
|
|
|
///
|
|
|
|
/// The opcode indicate the start of the boot script table.
|
|
|
|
///
|
2021-12-05 23:54:02 +01:00
|
|
|
#define S3_BOOT_SCRIPT_LIB_TABLE_OPCODE 0xAA
|
2011-08-30 00:17:27 +02:00
|
|
|
///
|
|
|
|
/// The opcode indicate the end of the boot script table.
|
|
|
|
///
|
2021-12-05 23:54:02 +01:00
|
|
|
#define S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE 0xFF
|
2011-08-30 00:17:27 +02:00
|
|
|
|
|
|
|
#endif //__INTERNAL_BOOT_SCRIPT_LIB__
|