2 A shell application that triggers capsule update process.
4 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #ifndef _CAPSULE_APP_H_
11 #define _CAPSULE_APP_H_
14 #include <Library/BaseLib.h>
15 #include <Library/DebugLib.h>
16 #include <Library/BaseMemoryLib.h>
17 #include <Library/MemoryAllocationLib.h>
18 #include <Library/UefiBootServicesTableLib.h>
19 #include <Library/UefiRuntimeServicesTableLib.h>
20 #include <Library/UefiLib.h>
21 #include <Library/PrintLib.h>
22 #include <Library/BmpSupportLib.h>
23 #include <Library/FileHandleLib.h>
24 #include <Library/SortLib.h>
25 #include <Library/UefiBootManagerLib.h>
26 #include <Library/DevicePathLib.h>
27 #include <Protocol/GraphicsOutput.h>
28 #include <Protocol/SimpleFileSystem.h>
29 #include <Protocol/ShellParameters.h>
30 #include <Protocol/Shell.h>
31 #include <Protocol/FirmwareManagement.h>
32 #include <Guid/GlobalVariable.h>
33 #include <Guid/CapsuleReport.h>
34 #include <Guid/SystemResourceTable.h>
35 #include <Guid/FmpCapsule.h>
36 #include <Guid/FileInfo.h>
37 #include <Guid/ImageAuthentication.h>
38 #include <Guid/CapsuleVendor.h>
40 #include <IndustryStandard/WindowsUxCapsule.h>
42 #define CAPSULE_HEADER_SIZE 0x20
44 #define NESTED_CAPSULE_HEADER_SIZE SIZE_4KB
45 #define SYSTEM_FIRMWARE_FLAG 0x50000
46 #define DEVICE_FIRMWARE_FLAG 0x78010
48 #define MAJOR_VERSION 1
49 #define MINOR_VERSION 0
51 #define MAX_CAPSULE_NUM 10
54 // (20 * (6+5+2))+1) unicode characters from EFI FAT spec (doubled for bytes)
56 #define MAX_FILE_NAME_SIZE 522
57 #define MAX_FILE_NAME_LEN (MAX_FILE_NAME_SIZE / sizeof(CHAR16))
64 This function parse application ARG.
76 @return Pointer to shell protocol.
88 @param[in] FileName The file to be read.
89 @param[out] BufferSize The file buffer size
90 @param[out] Buffer The file buffer
92 @retval EFI_SUCCESS Read file successfully
93 @retval EFI_NOT_FOUND Shell protocol or file not found
94 @retval others Read file failed
99 OUT UINTN
*BufferSize
,
106 @param[in] FileName The file to be written.
107 @param[in] BufferSize The file buffer size
108 @param[in] Buffer The file buffer
110 @retval EFI_SUCCESS Write file successfully
111 @retval EFI_NOT_FOUND Shell protocol not found
112 @retval others Write file failed
115 WriteFileFromBuffer (
123 Dump capsule information
125 @param[in] CapsuleName The name of the capsule image.
127 @retval EFI_SUCCESS The capsule information is dumped.
128 @retval EFI_UNSUPPORTED Input parameter is not valid.
132 IN CHAR16
*CapsuleName
136 Dump capsule status variable.
138 @retval EFI_SUCCESS The capsule status variable is dumped.
139 @retval EFI_UNSUPPORTED Input parameter is not valid.
142 DumpCapsuleStatusVariable (
147 Dump FMP protocol info.
157 @param[in] ImageTypeId The ImageTypeId of the FMP image.
158 It is used to identify the FMP protocol.
159 @param[in] ImageIndex The ImageIndex of the FMP image.
160 It is the input parameter for FMP->GetImage().
161 @param[in] ImageName The file name to hold the output FMP image.
165 IN EFI_GUID
*ImageTypeId
,
179 Dump Provisioned Capsule.
181 @param[in] DumpCapsuleInfo The flag to indicate whether to dump the capsule inforomation.
184 DumpProvisionedCapsule (
185 IN BOOLEAN DumpCapsuleInfo
189 Dump all EFI System Partition.
192 DumpAllEfiSysPartition (
198 Get SimpleFileSystem from boot option file path.
200 @param[in] DevicePath The file path of boot option
201 @param[out] FullPath The full device path of boot device
202 @param[out] Fs The file system within EfiSysPartition
204 @retval EFI_SUCCESS Get file system successfully
205 @retval EFI_NOT_FOUND No valid file system found
206 @retval others Get file system failed
210 GetEfiSysPartitionFromBootOptionFilePath (
211 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
212 OUT EFI_DEVICE_PATH_PROTOCOL
**FullPath
,
213 OUT EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
**Fs
218 Process Capsule On Disk.
220 @param[in] CapsuleBuffer An array of pointer to capsule images
221 @param[in] CapsuleBufferSize An array of UINTN to capsule images size
222 @param[in] FilePath An array of capsule images file path
223 @param[in] Map File system mapping string
224 @param[in] CapsuleNum The count of capsule images
226 @retval EFI_SUCCESS Capsule on disk success.
227 @retval others Capsule on disk fail.
231 ProcessCapsuleOnDisk (
232 IN VOID
**CapsuleBuffer
,
233 IN UINTN
*CapsuleBufferSize
,
234 IN CHAR16
**FilePath
,