2011-09-02 13:34:35 +02:00
|
|
|
/** @file
|
|
|
|
Common header file.
|
|
|
|
|
2016-04-26 06:52:42 +02:00
|
|
|
Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>
|
2017-02-26 18:43:04 +01:00
|
|
|
Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
|
|
|
|
|
2019-04-04 01:05:13 +02:00
|
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
2011-09-02 13:34:35 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
|
2011-09-05 11:53:37 +02:00
|
|
|
#ifndef _CAPSULE_COMMON_HEADER_
|
|
|
|
#define _CAPSULE_COMMON_HEADER_
|
2011-09-02 13:34:35 +02:00
|
|
|
|
2015-07-27 05:04:41 +02:00
|
|
|
//
|
|
|
|
// 8 extra pages for PF handler.
|
|
|
|
//
|
|
|
|
#define EXTRA_PAGE_TABLE_PAGES 8
|
|
|
|
|
2017-02-26 18:43:04 +01:00
|
|
|
#define PAGING_1G_ADDRESS_MASK_64 0x000FFFFFC0000000ull
|
|
|
|
|
2011-09-02 13:34:35 +02:00
|
|
|
//
|
|
|
|
// This capsule PEIM puts its private data at the start of the
|
|
|
|
// coalesced capsule. Here's the structure definition.
|
|
|
|
//
|
2014-01-17 04:51:01 +01:00
|
|
|
#define EFI_CAPSULE_PEIM_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('C', 'a', 'p', 'P')
|
2011-09-02 13:34:35 +02:00
|
|
|
|
2014-01-17 04:51:01 +01:00
|
|
|
#pragma pack(1)
|
2011-09-02 13:34:35 +02:00
|
|
|
typedef struct {
|
2014-01-17 04:51:01 +01:00
|
|
|
UINT64 Signature;
|
|
|
|
UINT64 CapsuleAllImageSize;
|
|
|
|
UINT64 CapsuleNumber;
|
|
|
|
UINT64 CapsuleOffset[1];
|
2011-09-02 13:34:35 +02:00
|
|
|
} EFI_CAPSULE_PEIM_PRIVATE_DATA;
|
2014-01-17 04:51:01 +01:00
|
|
|
#pragma pack()
|
2011-09-02 13:34:35 +02:00
|
|
|
|
2016-04-26 06:52:42 +02:00
|
|
|
typedef struct {
|
|
|
|
///
|
|
|
|
/// The physical start address of the resource region.
|
|
|
|
///
|
|
|
|
EFI_PHYSICAL_ADDRESS PhysicalStart;
|
|
|
|
///
|
|
|
|
/// The number of bytes of the resource region.
|
|
|
|
///
|
|
|
|
UINT64 ResourceLength;
|
|
|
|
} MEMORY_RESOURCE_DESCRIPTOR;
|
|
|
|
|
2011-09-02 13:34:35 +02:00
|
|
|
#define CAPSULE_TEST_SIGNATURE SIGNATURE_32('T', 'E', 'S', 'T')
|
|
|
|
|
2011-09-05 11:53:37 +02:00
|
|
|
#if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
|
2015-07-27 05:04:41 +02:00
|
|
|
#pragma pack(1)
|
2011-09-02 13:34:35 +02:00
|
|
|
typedef struct {
|
|
|
|
EFI_PHYSICAL_ADDRESS EntryPoint;
|
|
|
|
EFI_PHYSICAL_ADDRESS StackBufferBase;
|
|
|
|
UINT64 StackBufferLength;
|
|
|
|
EFI_PHYSICAL_ADDRESS JumpBuffer;
|
|
|
|
EFI_PHYSICAL_ADDRESS BlockListAddr;
|
2016-04-26 06:52:42 +02:00
|
|
|
EFI_PHYSICAL_ADDRESS MemoryResource;
|
2011-09-02 13:34:35 +02:00
|
|
|
EFI_PHYSICAL_ADDRESS MemoryBase64Ptr;
|
|
|
|
EFI_PHYSICAL_ADDRESS MemorySize64Ptr;
|
2015-07-27 05:04:41 +02:00
|
|
|
BOOLEAN Page1GSupport;
|
2017-02-26 18:43:04 +01:00
|
|
|
UINT64 AddressEncMask;
|
2011-09-02 13:34:35 +02:00
|
|
|
} SWITCH_32_TO_64_CONTEXT;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
UINT16 ReturnCs;
|
|
|
|
EFI_PHYSICAL_ADDRESS ReturnEntryPoint;
|
|
|
|
UINT64 ReturnStatus;
|
2015-07-27 05:04:41 +02:00
|
|
|
//
|
|
|
|
// NOTICE:
|
|
|
|
// Be careful about the Base field of IA32_DESCRIPTOR
|
|
|
|
// that is UINTN type.
|
|
|
|
// To extend new field for this structure, add it to
|
|
|
|
// right before this Gdtr field.
|
|
|
|
//
|
2011-09-02 13:34:35 +02:00
|
|
|
IA32_DESCRIPTOR Gdtr;
|
|
|
|
} SWITCH_64_TO_32_CONTEXT;
|
2015-07-27 05:04:41 +02:00
|
|
|
#pragma pack()
|
2011-09-05 11:53:37 +02:00
|
|
|
#endif
|
2011-09-02 13:34:35 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
The function to coalesce a fragmented capsule in memory.
|
|
|
|
|
|
|
|
@param PeiServices General purpose services available to every PEIM.
|
|
|
|
@param BlockListBuffer Point to the buffer of Capsule Descriptor Variables.
|
2016-04-26 06:52:42 +02:00
|
|
|
@param MemoryResource Pointer to the buffer of memory resource descriptor.
|
2011-09-02 13:34:35 +02:00
|
|
|
@param MemoryBase Pointer to the base of a block of memory that we can walk
|
|
|
|
all over while trying to coalesce our buffers.
|
|
|
|
On output, this variable will hold the base address of
|
|
|
|
a coalesced capsule.
|
|
|
|
@param MemorySize Size of the memory region pointed to by MemoryBase.
|
|
|
|
On output, this variable will contain the size of the
|
|
|
|
coalesced capsule.
|
|
|
|
|
|
|
|
@retval EFI_NOT_FOUND if we can't determine the boot mode
|
|
|
|
if the boot mode is not flash-update
|
|
|
|
if we could not find the capsule descriptors
|
|
|
|
|
|
|
|
@retval EFI_BUFFER_TOO_SMALL
|
|
|
|
if we could not coalesce the capsule in the memory
|
|
|
|
region provided to us
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS if there's no capsule, or if we processed the
|
|
|
|
capsule successfully.
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
CapsuleDataCoalesce (
|
|
|
|
IN EFI_PEI_SERVICES **PeiServices,
|
2016-04-26 06:52:42 +02:00
|
|
|
IN EFI_PHYSICAL_ADDRESS *BlockListBuffer,
|
|
|
|
IN MEMORY_RESOURCE_DESCRIPTOR *MemoryResource,
|
2011-09-02 13:34:35 +02:00
|
|
|
IN OUT VOID **MemoryBase,
|
|
|
|
IN OUT UINTN *MemorySize
|
|
|
|
);
|
|
|
|
|
|
|
|
#endif
|