/** @file\r
A shell application that triggers capsule update process.\r
\r
- Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>\r
SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\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 <Protocol/SimpleFileSystem.h>\r
-#include <Protocol/ShellParameters.h>\r
-#include <Protocol/Shell.h>\r
-#include <Guid/FileInfo.h>\r
+#include "CapsuleApp.h"\r
\r
UINTN Argc;\r
CHAR16 **Argv;\r
\r
**/\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 <Protocol/GraphicsOutput.h>\r
-#include <Guid/GlobalVariable.h>\r
-#include <Guid/CapsuleReport.h>\r
-#include <Guid/SystemResourceTable.h>\r
-#include <Guid/FmpCapsule.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
-extern UINTN Argc;\r
-extern CHAR16 **Argv;\r
+#include "CapsuleApp.h"\r
\r
//\r
// Define how many block descriptors we want to test with.\r
UINTN CapsuleFirstIndex;\r
UINTN CapsuleLastIndex;\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
- 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
-/**\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
- This function parse application ARG.\r
-\r
- @return Status\r
-**/\r
-EFI_STATUS\r
-GetArg (\r
- VOID\r
- );\r
-\r
/**\r
Create UX capsule.\r
\r
Print(L"Parameter:\n");\r
Print(L" -NR: No reset will be triggered for the capsule\n");\r
Print(L" with CAPSULE_FLAGS_PERSIST_ACROSS_RESET and without CAPSULE_FLAGS_INITIATE_RESET.\n");\r
- Print(L" -OD: Delivery of Capsules via file on Mass Storage device.");\r
+ Print(L" -OD: Delivery of Capsules via file on Mass Storage device.\n");\r
Print(L" -S: Dump capsule report variable (EFI_CAPSULE_REPORT_GUID),\n");\r
Print(L" which is defined in UEFI specification.\n");\r
Print(L" -C: Clear capsule report variable (EFI_CAPSULE_REPORT_GUID),\n");\r
}\r
}\r
\r
- if (ParaOdIndex != 0) {\r
- if (ParaOdIndex == Argc - 1) {\r
+ if (ParaOdIndex > ParaNrIndex) {\r
+ if (ParaNrIndex != 0) {\r
+ CapsuleLastIndex = ParaNrIndex - 1;\r
+ } else {\r
+ CapsuleLastIndex = ParaOdIndex - 1;\r
+ }\r
+\r
+ if (ParaOdIndex == Argc -1) {\r
MapFsStr = NULL;\r
} else if (ParaOdIndex == Argc - 2) {\r
MapFsStr = Argv[Argc-1];\r
} else {\r
- Print (L"CapsuleApp: Invalid Position for -OD Options\n");\r
+ Print (L"CapsuleApp: Cannot specify more than one FS mapping!\n");\r
Status = EFI_INVALID_PARAMETER;\r
goto Done;\r
}\r
-\r
- if (ParaNrIndex != 0) {\r
- if (ParaNrIndex + 1 == ParaOdIndex) {\r
- CapsuleLastIndex = ParaNrIndex - 1;\r
- } else {\r
- Print (L"CapsuleApp: Invalid Position for -NR Options\n");\r
- Status = EFI_INVALID_PARAMETER;\r
- goto Done;\r
- }\r
- } else {\r
+ } else if (ParaOdIndex < ParaNrIndex) {\r
+ if (ParaOdIndex != 0) {\r
CapsuleLastIndex = ParaOdIndex - 1;\r
- }\r
- } else {\r
- if (ParaNrIndex != 0) {\r
- if (ParaNrIndex == Argc -1) {\r
- CapsuleLastIndex = ParaNrIndex - 1;\r
+ if (ParaOdIndex == ParaNrIndex - 1) {\r
+ MapFsStr = NULL;\r
+ } else if (ParaOdIndex == ParaNrIndex - 2) {\r
+ MapFsStr = Argv[ParaOdIndex + 1];\r
} else {\r
- Print (L"CapsuleApp: Invalid Position for -NR Options\n");\r
+ Print (L"CapsuleApp: Cannot specify more than one FS mapping!\n");\r
Status = EFI_INVALID_PARAMETER;\r
goto Done;\r
}\r
} else {\r
- CapsuleLastIndex = Argc - 1;\r
+ CapsuleLastIndex = ParaNrIndex - 1;\r
}\r
+ } else {\r
+ CapsuleLastIndex = Argc - 1;\r
}\r
\r
CapsuleNum = CapsuleLastIndex - CapsuleFirstIndex + 1;\r
--- /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
# This application can trigger capsule update process. It can also\r
# generate capsule image, or dump capsule variable information.\r
#\r
-# Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>\r
# SPDX-License-Identifier: BSD-2-Clause-Patent\r
#\r
##\r
\r
[Sources]\r
CapsuleApp.c\r
+ CapsuleApp.h\r
CapsuleDump.c\r
CapsuleOnDisk.c\r
AppSupport.c\r
\r
**/\r
\r
-#include <PiDxe.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/FileHandleLib.h>\r
-#include <Library/SortLib.h>\r
-#include <Library/UefiBootManagerLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Protocol/FirmwareManagement.h>\r
-#include <Protocol/SimpleFileSystem.h>\r
-#include <Protocol/Shell.h>\r
-#include <Guid/ImageAuthentication.h>\r
-#include <Guid/CapsuleReport.h>\r
-#include <Guid/SystemResourceTable.h>\r
-#include <Guid/FmpCapsule.h>\r
-#include <Guid/CapsuleVendor.h>\r
-#include <IndustryStandard/WindowsUxCapsule.h>\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
-/**\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 File not found\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
-**/\r
-EFI_STATUS\r
-WriteFileFromBuffer (\r
- IN CHAR16 *FileName,\r
- IN UINTN BufferSize,\r
- IN VOID *Buffer\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
- 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
-EFIAPI\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
+#include "CapsuleApp.h"\r
\r
/**\r
Validate if it is valid capsule header\r
\r
**/\r
INTN\r
-EFIAPI\r
CompareFileNameInAlphabet (\r
IN VOID *Left,\r
IN VOID *Right\r
//\r
// Get file count first\r
//\r
+ Status = FileHandleFindFirstFile (DirHandle, &FileInfo);\r
do {\r
- Status = FileHandleFindFirstFile (DirHandle, &FileInfo);\r
if (EFI_ERROR (Status) || FileInfo == NULL) {\r
Print (L"Get File Info Fail. Status = %r\n", Status);\r
goto Done;\r
//\r
// Get all file info\r
//\r
+ Status = FileHandleFindFirstFile (DirHandle, &FileInfo);\r
do {\r
- Status = FileHandleFindFirstFile (DirHandle, &FileInfo);\r
if (EFI_ERROR (Status) || FileInfo == NULL) {\r
Print (L"Get File Info Fail. Status = %r\n", Status);\r
goto Done;\r
SPDX-License-Identifier: BSD-2-Clause-Patent\r
\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/DevicePathLib.h>\r
-#include <Library/FileHandleLib.h>\r
-#include <Library/UefiBootManagerLib.h>\r
-#include <Protocol/SimpleFileSystem.h>\r
-#include <Protocol/Shell.h>\r
-#include <Guid/FileInfo.h>\r
-#include <Guid/GlobalVariable.h>\r
-#include <Guid/Gpt.h>\r
\r
-EFI_GUID mCapsuleOnDiskBootOptionGuid = { 0x4CC29BB7, 0x2413, 0x40A2, { 0xB0, 0x6D, 0x25, 0x3E, 0x37, 0x10, 0xF5, 0x32 } };\r
-\r
-/**\r
- Get shell protocol.\r
+#include "CapsuleApp.h"\r
\r
- @return Pointer to shell protocol.\r
-\r
-**/\r
-EFI_SHELL_PROTOCOL *\r
-GetShellProtocol (\r
- VOID\r
- );\r
+EFI_GUID mCapsuleOnDiskBootOptionGuid = { 0x4CC29BB7, 0x2413, 0x40A2, { 0xB0, 0x6D, 0x25, 0x3E, 0x37, 0x10, 0xF5, 0x32 } };\r
\r
/**\r
Get file name from file path.\r
\r
**/\r
EFI_STATUS\r
-EFIAPI\r
GetEfiSysPartitionFromBootOptionFilePath (\r
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
OUT EFI_DEVICE_PATH_PROTOCOL **FullPath,\r
\r
**/\r
EFI_STATUS\r
-EFIAPI\r
GetUpdateFileSystem (\r
IN CHAR16 *Map,\r
OUT UINT16 *BootNext,\r
return Status;\r
}\r
\r
+/**\r
+ Check if Capsule On Disk is supported.\r
+\r
+ @retval TRUE Capsule On Disk is supported.\r
+ @retval FALSE Capsule On Disk is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+IsCapsuleOnDiskSupported (\r
+ VOID\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ UINT64 OsIndicationsSupported;\r
+ UINTN DataSize;\r
+\r
+ DataSize = sizeof(UINT64);\r
+ Status = gRT->GetVariable (\r
+ L"OsIndicationsSupported",\r
+ &gEfiGlobalVariableGuid,\r
+ NULL,\r
+ &DataSize,\r
+ &OsIndicationsSupported\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return FALSE;\r
+ }\r
+\r
+ if (OsIndicationsSupported & EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED) {\r
+ return TRUE;\r
+ }\r
+\r
+ return FALSE;\r
+}\r
+\r
/**\r
Process Capsule On Disk.\r
\r
UINT16 BootNext;\r
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs;\r
BOOLEAN UpdateBootNext;\r
+ CHAR16 *FileName[MAX_CAPSULE_NUM];\r
+ UINTN Index;\r
+\r
+ //\r
+ // Check if Capsule On Disk is supported\r
+ //\r
+ if (!IsCapsuleOnDiskSupported ()) {\r
+ Print (L"CapsuleApp: Capsule On Disk is not supported.\n");\r
+ return EFI_UNSUPPORTED;\r
+ }\r
\r
//\r
// Get a valid file system from boot path\r
return Status;\r
}\r
\r
+ //\r
+ // Get file name from file path\r
+ //\r
+ for (Index = 0; Index < CapsuleNum; Index ++) {\r
+ FileName[Index] = GetFileNameFromPath (FilePath[Index]);\r
+ }\r
+\r
//\r
// Copy capsule image to '\efi\UpdateCapsule\'\r
//\r
- Status = WriteUpdateFile (CapsuleBuffer, CapsuleBufferSize, FilePath, CapsuleNum, Fs);\r
+ Status = WriteUpdateFile (CapsuleBuffer, CapsuleBufferSize, FileName, CapsuleNum, Fs);\r
if (EFI_ERROR (Status)) {\r
Print (L"CapsuleApp: capsule image could not be copied for update.\n");\r
return Status;\r