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