4 Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>
5 Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
7 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #ifndef _CAPSULE_COMMON_HEADER_
12 #define _CAPSULE_COMMON_HEADER_
15 // 8 extra pages for PF handler.
17 #define EXTRA_PAGE_TABLE_PAGES 8
19 #define PAGING_1G_ADDRESS_MASK_64 0x000FFFFFC0000000ull
22 // This capsule PEIM puts its private data at the start of the
23 // coalesced capsule. Here's the structure definition.
25 #define EFI_CAPSULE_PEIM_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('C', 'a', 'p', 'P')
30 UINT64 CapsuleAllImageSize
;
32 UINT64 CapsuleOffset
[1];
33 } EFI_CAPSULE_PEIM_PRIVATE_DATA
;
38 /// The physical start address of the resource region.
40 EFI_PHYSICAL_ADDRESS PhysicalStart
;
42 /// The number of bytes of the resource region.
44 UINT64 ResourceLength
;
45 } MEMORY_RESOURCE_DESCRIPTOR
;
47 #define CAPSULE_TEST_SIGNATURE SIGNATURE_32('T', 'E', 'S', 'T')
49 #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
52 EFI_PHYSICAL_ADDRESS EntryPoint
;
53 EFI_PHYSICAL_ADDRESS StackBufferBase
;
54 UINT64 StackBufferLength
;
55 EFI_PHYSICAL_ADDRESS JumpBuffer
;
56 EFI_PHYSICAL_ADDRESS BlockListAddr
;
57 EFI_PHYSICAL_ADDRESS MemoryResource
;
58 EFI_PHYSICAL_ADDRESS MemoryBase64Ptr
;
59 EFI_PHYSICAL_ADDRESS MemorySize64Ptr
;
60 BOOLEAN Page1GSupport
;
61 UINT64 AddressEncMask
;
62 } SWITCH_32_TO_64_CONTEXT
;
66 EFI_PHYSICAL_ADDRESS ReturnEntryPoint
;
70 // Be careful about the Base field of IA32_DESCRIPTOR
71 // that is UINTN type.
72 // To extend new field for this structure, add it to
73 // right before this Gdtr field.
76 } SWITCH_64_TO_32_CONTEXT
;
81 The function to coalesce a fragmented capsule in memory.
83 @param PeiServices General purpose services available to every PEIM.
84 @param BlockListBuffer Point to the buffer of Capsule Descriptor Variables.
85 @param MemoryResource Pointer to the buffer of memory resource descriptor.
86 @param MemoryBase Pointer to the base of a block of memory that we can walk
87 all over while trying to coalesce our buffers.
88 On output, this variable will hold the base address of
90 @param MemorySize Size of the memory region pointed to by MemoryBase.
91 On output, this variable will contain the size of the
94 @retval EFI_NOT_FOUND if we can't determine the boot mode
95 if the boot mode is not flash-update
96 if we could not find the capsule descriptors
98 @retval EFI_BUFFER_TOO_SMALL
99 if we could not coalesce the capsule in the memory
100 region provided to us
102 @retval EFI_SUCCESS if there's no capsule, or if we processed the
103 capsule successfully.
107 CapsuleDataCoalesce (
108 IN EFI_PEI_SERVICES
**PeiServices
,
109 IN EFI_PHYSICAL_ADDRESS
*BlockListBuffer
,
110 IN MEMORY_RESOURCE_DESCRIPTOR
*MemoryResource
,
111 IN OUT VOID
**MemoryBase
,
112 IN OUT UINTN
*MemorySize