]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Application/CapsuleApp/CapsuleApp.h
MdeModulePkg/CapsuleApp: Enhance Capsule-On-Disk related functions.
[mirror_edk2.git] / MdeModulePkg / Application / CapsuleApp / CapsuleApp.h
CommitLineData
8165570e
WX
1/** @file\r
2 A shell application that triggers capsule update process.\r
3\r
4 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>\r
5 SPDX-License-Identifier: BSD-2-Clause-Patent\r
6\r
7**/\r
8\r
9\r
10#ifndef _CAPSULE_APP_H_\r
11#define _CAPSULE_APP_H_\r
12\r
13#include <Uefi.h>\r
14#include <Library/BaseLib.h>\r
15#include <Library/DebugLib.h>\r
16#include <Library/BaseMemoryLib.h>\r
17#include <Library/MemoryAllocationLib.h>\r
18#include <Library/UefiBootServicesTableLib.h>\r
19#include <Library/UefiRuntimeServicesTableLib.h>\r
20#include <Library/UefiLib.h>\r
21#include <Library/PrintLib.h>\r
22#include <Library/BmpSupportLib.h>\r
23#include <Library/FileHandleLib.h>\r
24#include <Library/SortLib.h>\r
25#include <Library/UefiBootManagerLib.h>\r
26#include <Library/DevicePathLib.h>\r
27#include <Protocol/GraphicsOutput.h>\r
28#include <Protocol/SimpleFileSystem.h>\r
29#include <Protocol/ShellParameters.h>\r
30#include <Protocol/Shell.h>\r
31#include <Protocol/FirmwareManagement.h>\r
32#include <Guid/GlobalVariable.h>\r
33#include <Guid/CapsuleReport.h>\r
34#include <Guid/SystemResourceTable.h>\r
35#include <Guid/FmpCapsule.h>\r
36#include <Guid/FileInfo.h>\r
37#include <Guid/ImageAuthentication.h>\r
38#include <Guid/CapsuleVendor.h>\r
39#include <Guid/Gpt.h>\r
40#include <IndustryStandard/WindowsUxCapsule.h>\r
41\r
42#define CAPSULE_HEADER_SIZE 0x20\r
43\r
44#define NESTED_CAPSULE_HEADER_SIZE SIZE_4KB\r
45#define SYSTEM_FIRMWARE_FLAG 0x50000\r
46#define DEVICE_FIRMWARE_FLAG 0x78010\r
47\r
48#define MAJOR_VERSION 1\r
49#define MINOR_VERSION 0\r
50\r
51#define MAX_CAPSULE_NUM 10\r
52\r
53//\r
54// (20 * (6+5+2))+1) unicode characters from EFI FAT spec (doubled for bytes)\r
55//\r
56#define MAX_FILE_NAME_SIZE 522\r
57#define MAX_FILE_NAME_LEN (MAX_FILE_NAME_SIZE / sizeof(CHAR16))\r
58\r
59extern UINTN Argc;\r
60extern CHAR16 **Argv;\r
61\r
62/**\r
63\r
64 This function parse application ARG.\r
65\r
66 @return Status\r
67**/\r
68EFI_STATUS\r
69GetArg (\r
70 VOID\r
71 );\r
72\r
73/**\r
74 Get shell protocol.\r
75\r
76 @return Pointer to shell protocol.\r
77\r
78**/\r
79EFI_SHELL_PROTOCOL *\r
80GetShellProtocol (\r
81 VOID\r
82 );\r
83\r
84\r
85/**\r
86 Read a file.\r
87\r
88 @param[in] FileName The file to be read.\r
89 @param[out] BufferSize The file buffer size\r
90 @param[out] Buffer The file buffer\r
91\r
92 @retval EFI_SUCCESS Read file successfully\r
93 @retval EFI_NOT_FOUND Shell protocol or file not found\r
94 @retval others Read file failed\r
95**/\r
96EFI_STATUS\r
97ReadFileToBuffer (\r
98 IN CHAR16 *FileName,\r
99 OUT UINTN *BufferSize,\r
100 OUT VOID **Buffer\r
101 );\r
102\r
103/**\r
104 Write a file.\r
105\r
106 @param[in] FileName The file to be written.\r
107 @param[in] BufferSize The file buffer size\r
108 @param[in] Buffer The file buffer\r
109\r
110 @retval EFI_SUCCESS Write file successfully\r
111 @retval EFI_NOT_FOUND Shell protocol not found\r
112 @retval others Write file failed\r
113**/\r
114EFI_STATUS\r
115WriteFileFromBuffer (\r
116 IN CHAR16 *FileName,\r
117 IN UINTN BufferSize,\r
118 IN VOID *Buffer\r
119 );\r
120\r
121\r
122/**\r
123 Dump capsule information\r
124\r
125 @param[in] CapsuleName The name of the capsule image.\r
126\r
127 @retval EFI_SUCCESS The capsule information is dumped.\r
128 @retval EFI_UNSUPPORTED Input parameter is not valid.\r
129**/\r
130EFI_STATUS\r
131DumpCapsule (\r
132 IN CHAR16 *CapsuleName\r
133 );\r
134\r
135/**\r
136 Dump capsule status variable.\r
137\r
138 @retval EFI_SUCCESS The capsule status variable is dumped.\r
139 @retval EFI_UNSUPPORTED Input parameter is not valid.\r
140**/\r
141EFI_STATUS\r
142DumpCapsuleStatusVariable (\r
143 VOID\r
144 );\r
145\r
146/**\r
147 Dump FMP protocol info.\r
148**/\r
149VOID\r
150DumpFmpData (\r
151 VOID\r
152 );\r
153\r
154/**\r
155 Dump FMP image data.\r
156\r
157 @param[in] ImageTypeId The ImageTypeId of the FMP image.\r
158 It is used to identify the FMP protocol.\r
159 @param[in] ImageIndex The ImageIndex of the FMP image.\r
160 It is the input parameter for FMP->GetImage().\r
161 @param[in] ImageName The file name to hold the output FMP image.\r
162**/\r
163VOID\r
164DumpFmpImage (\r
165 IN EFI_GUID *ImageTypeId,\r
166 IN UINTN ImageIndex,\r
167 IN CHAR16 *ImageName\r
168 );\r
169\r
170/**\r
171 Dump ESRT info.\r
172**/\r
173VOID\r
174DumpEsrtData (\r
175 VOID\r
176 );\r
177\r
178/**\r
179 Dump Provisioned Capsule.\r
180\r
181 @param[in] DumpCapsuleInfo The flag to indicate whether to dump the capsule inforomation.\r
182**/\r
183VOID\r
184DumpProvisionedCapsule (\r
185 IN BOOLEAN DumpCapsuleInfo\r
186 );\r
187\r
188/**\r
189 Dump all EFI System Partition.\r
190**/\r
191VOID\r
192DumpAllEfiSysPartition (\r
193 VOID\r
194 );\r
195\r
196\r
197/**\r
198 Get SimpleFileSystem from boot option file path.\r
199\r
200 @param[in] DevicePath The file path of boot option\r
201 @param[out] FullPath The full device path of boot device\r
202 @param[out] Fs The file system within EfiSysPartition\r
203\r
204 @retval EFI_SUCCESS Get file system successfully\r
205 @retval EFI_NOT_FOUND No valid file system found\r
206 @retval others Get file system failed\r
207\r
208**/\r
209EFI_STATUS\r
210GetEfiSysPartitionFromBootOptionFilePath (\r
211 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
212 OUT EFI_DEVICE_PATH_PROTOCOL **FullPath,\r
213 OUT EFI_SIMPLE_FILE_SYSTEM_PROTOCOL **Fs\r
214 );\r
215\r
216\r
217/**\r
218 Process Capsule On Disk.\r
219\r
220 @param[in] CapsuleBuffer An array of pointer to capsule images\r
221 @param[in] CapsuleBufferSize An array of UINTN to capsule images size\r
222 @param[in] FilePath An array of capsule images file path\r
223 @param[in] Map File system mapping string\r
224 @param[in] CapsuleNum The count of capsule images\r
225\r
226 @retval EFI_SUCCESS Capsule on disk success.\r
227 @retval others Capsule on disk fail.\r
228\r
229**/\r
230EFI_STATUS\r
231ProcessCapsuleOnDisk (\r
232 IN VOID **CapsuleBuffer,\r
233 IN UINTN *CapsuleBufferSize,\r
234 IN CHAR16 **FilePath,\r
235 IN CHAR16 *Map,\r
236 IN UINTN CapsuleNum\r
237 );\r
238\r
239#endif\r
240\r