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
9 #ifndef _CAPSULE_APP_H_
10 #define _CAPSULE_APP_H_
13 #include <Library/BaseLib.h>
14 #include <Library/DebugLib.h>
15 #include <Library/BaseMemoryLib.h>
16 #include <Library/MemoryAllocationLib.h>
17 #include <Library/UefiBootServicesTableLib.h>
18 #include <Library/UefiRuntimeServicesTableLib.h>
19 #include <Library/UefiLib.h>
20 #include <Library/PrintLib.h>
21 #include <Library/BmpSupportLib.h>
22 #include <Library/FileHandleLib.h>
23 #include <Library/SortLib.h>
24 #include <Library/UefiBootManagerLib.h>
25 #include <Library/DevicePathLib.h>
26 #include <Protocol/GraphicsOutput.h>
27 #include <Protocol/SimpleFileSystem.h>
28 #include <Protocol/ShellParameters.h>
29 #include <Protocol/Shell.h>
30 #include <Protocol/FirmwareManagement.h>
31 #include <Guid/GlobalVariable.h>
32 #include <Guid/CapsuleReport.h>
33 #include <Guid/SystemResourceTable.h>
34 #include <Guid/FmpCapsule.h>
35 #include <Guid/FileInfo.h>
36 #include <Guid/ImageAuthentication.h>
37 #include <Guid/CapsuleVendor.h>
39 #include <IndustryStandard/WindowsUxCapsule.h>
41 #define CAPSULE_HEADER_SIZE 0x20
43 #define NESTED_CAPSULE_HEADER_SIZE SIZE_4KB
44 #define SYSTEM_FIRMWARE_FLAG 0x50000
45 #define DEVICE_FIRMWARE_FLAG 0x78010
47 #define MAJOR_VERSION 1
48 #define MINOR_VERSION 0
50 #define MAX_CAPSULE_NUM 10
53 // (20 * (6+5+2))+1) unicode characters from EFI FAT spec (doubled for bytes)
55 #define MAX_FILE_NAME_SIZE 522
56 #define MAX_FILE_NAME_LEN (MAX_FILE_NAME_SIZE / sizeof(CHAR16))
63 This function parse application ARG.
75 @return Pointer to shell protocol.
86 @param[in] FileName The file to be read.
87 @param[out] BufferSize The file buffer size
88 @param[out] Buffer The file buffer
90 @retval EFI_SUCCESS Read file successfully
91 @retval EFI_NOT_FOUND Shell protocol or file not found
92 @retval others Read file failed
97 OUT UINTN
*BufferSize
,
104 @param[in] FileName The file to be written.
105 @param[in] BufferSize The file buffer size
106 @param[in] Buffer The file buffer
108 @retval EFI_SUCCESS Write file successfully
109 @retval EFI_NOT_FOUND Shell protocol not found
110 @retval others Write file failed
113 WriteFileFromBuffer (
120 Dump capsule information
122 @param[in] CapsuleName The name of the capsule image.
124 @retval EFI_SUCCESS The capsule information is dumped.
125 @retval EFI_UNSUPPORTED Input parameter is not valid.
129 IN CHAR16
*CapsuleName
133 Dump capsule status variable.
135 @retval EFI_SUCCESS The capsule status variable is dumped.
136 @retval EFI_UNSUPPORTED Input parameter is not valid.
139 DumpCapsuleStatusVariable (
144 Dump FMP protocol info.
154 @param[in] ImageTypeId The ImageTypeId of the FMP image.
155 It is used to identify the FMP protocol.
156 @param[in] ImageIndex The ImageIndex of the FMP image.
157 It is the input parameter for FMP->GetImage().
158 @param[in] ImageName The file name to hold the output FMP image.
162 IN EFI_GUID
*ImageTypeId
,
176 Dump Provisioned Capsule.
178 @param[in] DumpCapsuleInfo The flag to indicate whether to dump the capsule inforomation.
181 DumpProvisionedCapsule (
182 IN BOOLEAN DumpCapsuleInfo
186 Dump all EFI System Partition.
189 DumpAllEfiSysPartition (
194 Get SimpleFileSystem from boot option file path.
196 @param[in] DevicePath The file path of boot option
197 @param[out] FullPath The full device path of boot device
198 @param[out] Fs The file system within EfiSysPartition
200 @retval EFI_SUCCESS Get file system successfully
201 @retval EFI_NOT_FOUND No valid file system found
202 @retval others Get file system failed
206 GetEfiSysPartitionFromBootOptionFilePath (
207 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
208 OUT EFI_DEVICE_PATH_PROTOCOL
**FullPath
,
209 OUT EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
**Fs
213 Process Capsule On Disk.
215 @param[in] CapsuleBuffer An array of pointer to capsule images
216 @param[in] CapsuleBufferSize An array of UINTN to capsule images size
217 @param[in] FilePath An array of capsule images file path
218 @param[in] Map File system mapping string
219 @param[in] CapsuleNum The count of capsule images
221 @retval EFI_SUCCESS Capsule on disk success.
222 @retval others Capsule on disk fail.
226 ProcessCapsuleOnDisk (
227 IN VOID
**CapsuleBuffer
,
228 IN UINTN
*CapsuleBufferSize
,
229 IN CHAR16
**FilePath
,