--- /dev/null
+/** @file\r
+ A shell application that triggers capsule update process.\r
+\r
+ Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+\r
+#ifndef _CAPSULE_APP_H_\r
+#define _CAPSULE_APP_H_\r
+\r
+#include <Uefi.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiRuntimeServicesTableLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/PrintLib.h>\r
+#include <Library/BmpSupportLib.h>\r
+#include <Library/FileHandleLib.h>\r
+#include <Library/SortLib.h>\r
+#include <Library/UefiBootManagerLib.h>\r
+#include <Library/DevicePathLib.h>\r
+#include <Protocol/GraphicsOutput.h>\r
+#include <Protocol/SimpleFileSystem.h>\r
+#include <Protocol/ShellParameters.h>\r
+#include <Protocol/Shell.h>\r
+#include <Protocol/FirmwareManagement.h>\r
+#include <Guid/GlobalVariable.h>\r
+#include <Guid/CapsuleReport.h>\r
+#include <Guid/SystemResourceTable.h>\r
+#include <Guid/FmpCapsule.h>\r
+#include <Guid/FileInfo.h>\r
+#include <Guid/ImageAuthentication.h>\r
+#include <Guid/CapsuleVendor.h>\r
+#include <Guid/Gpt.h>\r
+#include <IndustryStandard/WindowsUxCapsule.h>\r
+\r
+#define CAPSULE_HEADER_SIZE 0x20\r
+\r
+#define NESTED_CAPSULE_HEADER_SIZE SIZE_4KB\r
+#define SYSTEM_FIRMWARE_FLAG 0x50000\r
+#define DEVICE_FIRMWARE_FLAG 0x78010\r
+\r
+#define MAJOR_VERSION 1\r
+#define MINOR_VERSION 0\r
+\r
+#define MAX_CAPSULE_NUM 10\r
+\r
+//\r
+// (20 * (6+5+2))+1) unicode characters from EFI FAT spec (doubled for bytes)\r
+//\r
+#define MAX_FILE_NAME_SIZE 522\r
+#define MAX_FILE_NAME_LEN (MAX_FILE_NAME_SIZE / sizeof(CHAR16))\r
+\r
+extern UINTN Argc;\r
+extern CHAR16 **Argv;\r
+\r
+/**\r
+\r
+ This function parse application ARG.\r
+\r
+ @return Status\r
+**/\r
+EFI_STATUS\r
+GetArg (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ Get shell protocol.\r
+\r
+ @return Pointer to shell protocol.\r
+\r
+**/\r
+EFI_SHELL_PROTOCOL *\r
+GetShellProtocol (\r
+ VOID\r
+ );\r
+\r
+\r
+/**\r
+ Read a file.\r
+\r
+ @param[in] FileName The file to be read.\r
+ @param[out] BufferSize The file buffer size\r
+ @param[out] Buffer The file buffer\r
+\r
+ @retval EFI_SUCCESS Read file successfully\r
+ @retval EFI_NOT_FOUND Shell protocol or file not found\r
+ @retval others Read file failed\r
+**/\r
+EFI_STATUS\r
+ReadFileToBuffer (\r
+ IN CHAR16 *FileName,\r
+ OUT UINTN *BufferSize,\r
+ OUT VOID **Buffer\r
+ );\r
+\r
+/**\r
+ Write a file.\r
+\r
+ @param[in] FileName The file to be written.\r
+ @param[in] BufferSize The file buffer size\r
+ @param[in] Buffer The file buffer\r
+\r
+ @retval EFI_SUCCESS Write file successfully\r
+ @retval EFI_NOT_FOUND Shell protocol not found\r
+ @retval others Write file failed\r
+**/\r
+EFI_STATUS\r
+WriteFileFromBuffer (\r
+ IN CHAR16 *FileName,\r
+ IN UINTN BufferSize,\r
+ IN VOID *Buffer\r
+ );\r
+\r
+\r
+/**\r
+ Dump capsule information\r
+\r
+ @param[in] CapsuleName The name of the capsule image.\r
+\r
+ @retval EFI_SUCCESS The capsule information is dumped.\r
+ @retval EFI_UNSUPPORTED Input parameter is not valid.\r
+**/\r
+EFI_STATUS\r
+DumpCapsule (\r
+ IN CHAR16 *CapsuleName\r
+ );\r
+\r
+/**\r
+ Dump capsule status variable.\r
+\r
+ @retval EFI_SUCCESS The capsule status variable is dumped.\r
+ @retval EFI_UNSUPPORTED Input parameter is not valid.\r
+**/\r
+EFI_STATUS\r
+DumpCapsuleStatusVariable (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ Dump FMP protocol info.\r
+**/\r
+VOID\r
+DumpFmpData (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ Dump FMP image data.\r
+\r
+ @param[in] ImageTypeId The ImageTypeId of the FMP image.\r
+ It is used to identify the FMP protocol.\r
+ @param[in] ImageIndex The ImageIndex of the FMP image.\r
+ It is the input parameter for FMP->GetImage().\r
+ @param[in] ImageName The file name to hold the output FMP image.\r
+**/\r
+VOID\r
+DumpFmpImage (\r
+ IN EFI_GUID *ImageTypeId,\r
+ IN UINTN ImageIndex,\r
+ IN CHAR16 *ImageName\r
+ );\r
+\r
+/**\r
+ Dump ESRT info.\r
+**/\r
+VOID\r
+DumpEsrtData (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ Dump Provisioned Capsule.\r
+\r
+ @param[in] DumpCapsuleInfo The flag to indicate whether to dump the capsule inforomation.\r
+**/\r
+VOID\r
+DumpProvisionedCapsule (\r
+ IN BOOLEAN DumpCapsuleInfo\r
+ );\r
+\r
+/**\r
+ Dump all EFI System Partition.\r
+**/\r
+VOID\r
+DumpAllEfiSysPartition (\r
+ VOID\r
+ );\r
+\r
+\r
+/**\r
+ Get SimpleFileSystem from boot option file path.\r
+\r
+ @param[in] DevicePath The file path of boot option\r
+ @param[out] FullPath The full device path of boot device\r
+ @param[out] Fs The file system within EfiSysPartition\r
+\r
+ @retval EFI_SUCCESS Get file system successfully\r
+ @retval EFI_NOT_FOUND No valid file system found\r
+ @retval others Get file system failed\r
+\r
+**/\r
+EFI_STATUS\r
+GetEfiSysPartitionFromBootOptionFilePath (\r
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
+ OUT EFI_DEVICE_PATH_PROTOCOL **FullPath,\r
+ OUT EFI_SIMPLE_FILE_SYSTEM_PROTOCOL **Fs\r
+ );\r
+\r
+\r
+/**\r
+ Process Capsule On Disk.\r
+\r
+ @param[in] CapsuleBuffer An array of pointer to capsule images\r
+ @param[in] CapsuleBufferSize An array of UINTN to capsule images size\r
+ @param[in] FilePath An array of capsule images file path\r
+ @param[in] Map File system mapping string\r
+ @param[in] CapsuleNum The count of capsule images\r
+\r
+ @retval EFI_SUCCESS Capsule on disk success.\r
+ @retval others Capsule on disk fail.\r
+\r
+**/\r
+EFI_STATUS\r
+ProcessCapsuleOnDisk (\r
+ IN VOID **CapsuleBuffer,\r
+ IN UINTN *CapsuleBufferSize,\r
+ IN CHAR16 **FilePath,\r
+ IN CHAR16 *Map,\r
+ IN UINTN CapsuleNum\r
+ );\r
+\r
+#endif\r
+\r