]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/CapsulePei/Common/CommonHeader.h
MdeModulePkg: Replace [Ascii|Unicode]ValueToString
[mirror_edk2.git] / MdeModulePkg / Universal / CapsulePei / Common / CommonHeader.h
1 /** @file
2 Common header file.
3
4 Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>
5 Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
6
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 **/
16
17 #ifndef _CAPSULE_COMMON_HEADER_
18 #define _CAPSULE_COMMON_HEADER_
19
20 //
21 // 8 extra pages for PF handler.
22 //
23 #define EXTRA_PAGE_TABLE_PAGES 8
24
25 #define PAGING_1G_ADDRESS_MASK_64 0x000FFFFFC0000000ull
26
27 //
28 // This capsule PEIM puts its private data at the start of the
29 // coalesced capsule. Here's the structure definition.
30 //
31 #define EFI_CAPSULE_PEIM_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('C', 'a', 'p', 'P')
32
33 #pragma pack(1)
34 typedef struct {
35 UINT64 Signature;
36 UINT64 CapsuleAllImageSize;
37 UINT64 CapsuleNumber;
38 UINT64 CapsuleOffset[1];
39 } EFI_CAPSULE_PEIM_PRIVATE_DATA;
40 #pragma pack()
41
42 typedef struct {
43 ///
44 /// The physical start address of the resource region.
45 ///
46 EFI_PHYSICAL_ADDRESS PhysicalStart;
47 ///
48 /// The number of bytes of the resource region.
49 ///
50 UINT64 ResourceLength;
51 } MEMORY_RESOURCE_DESCRIPTOR;
52
53 #define CAPSULE_TEST_SIGNATURE SIGNATURE_32('T', 'E', 'S', 'T')
54
55 #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
56 #pragma pack(1)
57 typedef struct {
58 EFI_PHYSICAL_ADDRESS EntryPoint;
59 EFI_PHYSICAL_ADDRESS StackBufferBase;
60 UINT64 StackBufferLength;
61 EFI_PHYSICAL_ADDRESS JumpBuffer;
62 EFI_PHYSICAL_ADDRESS BlockListAddr;
63 EFI_PHYSICAL_ADDRESS MemoryResource;
64 EFI_PHYSICAL_ADDRESS MemoryBase64Ptr;
65 EFI_PHYSICAL_ADDRESS MemorySize64Ptr;
66 BOOLEAN Page1GSupport;
67 UINT64 AddressEncMask;
68 } SWITCH_32_TO_64_CONTEXT;
69
70 typedef struct {
71 UINT16 ReturnCs;
72 EFI_PHYSICAL_ADDRESS ReturnEntryPoint;
73 UINT64 ReturnStatus;
74 //
75 // NOTICE:
76 // Be careful about the Base field of IA32_DESCRIPTOR
77 // that is UINTN type.
78 // To extend new field for this structure, add it to
79 // right before this Gdtr field.
80 //
81 IA32_DESCRIPTOR Gdtr;
82 } SWITCH_64_TO_32_CONTEXT;
83 #pragma pack()
84 #endif
85
86 /**
87 The function to coalesce a fragmented capsule in memory.
88
89 @param PeiServices General purpose services available to every PEIM.
90 @param BlockListBuffer Point to the buffer of Capsule Descriptor Variables.
91 @param MemoryResource Pointer to the buffer of memory resource descriptor.
92 @param MemoryBase Pointer to the base of a block of memory that we can walk
93 all over while trying to coalesce our buffers.
94 On output, this variable will hold the base address of
95 a coalesced capsule.
96 @param MemorySize Size of the memory region pointed to by MemoryBase.
97 On output, this variable will contain the size of the
98 coalesced capsule.
99
100 @retval EFI_NOT_FOUND if we can't determine the boot mode
101 if the boot mode is not flash-update
102 if we could not find the capsule descriptors
103
104 @retval EFI_BUFFER_TOO_SMALL
105 if we could not coalesce the capsule in the memory
106 region provided to us
107
108 @retval EFI_SUCCESS if there's no capsule, or if we processed the
109 capsule successfully.
110 **/
111 EFI_STATUS
112 EFIAPI
113 CapsuleDataCoalesce (
114 IN EFI_PEI_SERVICES **PeiServices,
115 IN EFI_PHYSICAL_ADDRESS *BlockListBuffer,
116 IN MEMORY_RESOURCE_DESCRIPTOR *MemoryResource,
117 IN OUT VOID **MemoryBase,
118 IN OUT UINTN *MemorySize
119 );
120
121 #endif