A shell application that triggers capsule update process.\r
\r
Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\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 <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
}\r
\r
//\r
- // Record descirptor header\r
+ // Record descriptor header\r
//\r
if (Index == 0) {\r
BlockDescriptorsHeader = BlockDescriptors1;\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
EFI_GUID ImageTypeId;\r
UINTN ImageIndex;\r
\r
- MapFsStr = NULL;\r
- CapsuleNum = 0;\r
+ BlockDescriptors = NULL;\r
+ MapFsStr = NULL;\r
+ CapsuleNum = 0;\r
\r
Status = GetArg();\r
if (EFI_ERROR(Status)) {\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