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