]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/CapsulePei/Common/CommonHeader.h
CapsulePei coalesce need add more sanity check for each Capsule Fragment.
[mirror_edk2.git] / MdeModulePkg / Universal / CapsulePei / Common / CommonHeader.h
1 /** @file
2 Common header file.
3
4 Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef _CAPSULE_COMMON_HEADER_
16 #define _CAPSULE_COMMON_HEADER_
17
18 //
19 // This capsule PEIM puts its private data at the start of the
20 // coalesced capsule. Here's the structure definition.
21 //
22 #define EFI_CAPSULE_PEIM_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('C', 'a', 'p', 'P')
23
24 #pragma pack(1)
25 typedef struct {
26 UINT64 Signature;
27 UINT64 CapsuleAllImageSize;
28 UINT64 CapsuleNumber;
29 UINT64 CapsuleOffset[1];
30 } EFI_CAPSULE_PEIM_PRIVATE_DATA;
31 #pragma pack()
32
33 #define CAPSULE_TEST_SIGNATURE SIGNATURE_32('T', 'E', 'S', 'T')
34
35 #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
36 typedef struct {
37 EFI_PHYSICAL_ADDRESS EntryPoint;
38 EFI_PHYSICAL_ADDRESS StackBufferBase;
39 UINT64 StackBufferLength;
40 EFI_PHYSICAL_ADDRESS JumpBuffer;
41 EFI_PHYSICAL_ADDRESS BlockListAddr;
42 EFI_PHYSICAL_ADDRESS MemoryBase64Ptr;
43 EFI_PHYSICAL_ADDRESS MemorySize64Ptr;
44 } SWITCH_32_TO_64_CONTEXT;
45
46 typedef struct {
47 UINT16 ReturnCs;
48 EFI_PHYSICAL_ADDRESS ReturnEntryPoint;
49 UINT64 ReturnStatus;
50 IA32_DESCRIPTOR Gdtr;
51 } SWITCH_64_TO_32_CONTEXT;
52 #endif
53
54 /**
55 The function to coalesce a fragmented capsule in memory.
56
57 @param PeiServices General purpose services available to every PEIM.
58 @param BlockListBuffer Point to the buffer of Capsule Descriptor Variables.
59 @param MemoryBase Pointer to the base of a block of memory that we can walk
60 all over while trying to coalesce our buffers.
61 On output, this variable will hold the base address of
62 a coalesced capsule.
63 @param MemorySize Size of the memory region pointed to by MemoryBase.
64 On output, this variable will contain the size of the
65 coalesced capsule.
66
67 @retval EFI_NOT_FOUND if we can't determine the boot mode
68 if the boot mode is not flash-update
69 if we could not find the capsule descriptors
70
71 @retval EFI_BUFFER_TOO_SMALL
72 if we could not coalesce the capsule in the memory
73 region provided to us
74
75 @retval EFI_SUCCESS if there's no capsule, or if we processed the
76 capsule successfully.
77 **/
78 EFI_STATUS
79 EFIAPI
80 CapsuleDataCoalesce (
81 IN EFI_PEI_SERVICES **PeiServices,
82 IN IN EFI_PHYSICAL_ADDRESS *BlockListBuffer,
83 IN OUT VOID **MemoryBase,
84 IN OUT UINTN *MemorySize
85 );
86
87 #endif