MdeModulePkg/CapsuleApp: Enhance Capsule-On-Disk related functions.

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1840

1. Add missing '\n' in usage.
2. Fix the dead loop of CapsuleApp -L.
3. Fix the bug that CapsuleApp -OD cannot perform capsules in sub-
folder.
4. Optimize the handling for option -NR and -OD to support both
'CapsuleApp <Capsule> -OD -NR' and 'CapsuleApp <Capsule> -NR -OD'.
5. Check if Capsule-On-Disk is supported by "OsIndicationsSupported"
variable firstly before processing capsules. If not supported, prompt
an error message and quit the process.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Chao B Zhang <chao.b.zhang@intel.com>
Signed-off-by: Wei6 Xu <wei6.xu@intel.com>
Reviewed-by: Chao B Zhang <chao.b.zhang@intel.com>
Acked-by: Hao A Wu <hao.a.wu@intel.com>
This commit is contained in:
xuwei6
2019-05-24 16:52:35 +08:00
committed by Zhang, Chao B
parent 0d4aa276d1
commit 6470a43160
3 changed files with 77 additions and 24 deletions

View File

@ -849,7 +849,7 @@ PrintUsage (
Print(L"Parameter:\n");
Print(L" -NR: No reset will be triggered for the capsule\n");
Print(L" with CAPSULE_FLAGS_PERSIST_ACROSS_RESET and without CAPSULE_FLAGS_INITIATE_RESET.\n");
Print(L" -OD: Delivery of Capsules via file on Mass Storage device.");
Print(L" -OD: Delivery of Capsules via file on Mass Storage device.\n");
Print(L" -S: Dump capsule report variable (EFI_CAPSULE_REPORT_GUID),\n");
Print(L" which is defined in UEFI specification.\n");
Print(L" -C: Clear capsule report variable (EFI_CAPSULE_REPORT_GUID),\n");
@ -1020,40 +1020,39 @@ UefiMain (
}
}
if (ParaOdIndex != 0) {
if (ParaOdIndex == Argc - 1) {
if (ParaOdIndex > ParaNrIndex) {
if (ParaNrIndex != 0) {
CapsuleLastIndex = ParaNrIndex - 1;
} else {
CapsuleLastIndex = ParaOdIndex - 1;
}
if (ParaOdIndex == Argc -1) {
MapFsStr = NULL;
} else if (ParaOdIndex == Argc - 2) {
MapFsStr = Argv[Argc-1];
} else {
Print (L"CapsuleApp: Invalid Position for -OD Options\n");
Print (L"CapsuleApp: Cannot specify more than one FS mapping!\n");
Status = EFI_INVALID_PARAMETER;
goto Done;
}
if (ParaNrIndex != 0) {
if (ParaNrIndex + 1 == ParaOdIndex) {
CapsuleLastIndex = ParaNrIndex - 1;
} else if (ParaOdIndex < ParaNrIndex) {
if (ParaOdIndex != 0) {
CapsuleLastIndex = ParaOdIndex - 1;
if (ParaOdIndex == ParaNrIndex - 1) {
MapFsStr = NULL;
} else if (ParaOdIndex == ParaNrIndex - 2) {
MapFsStr = Argv[ParaOdIndex + 1];
} else {
Print (L"CapsuleApp: Invalid Position for -NR Options\n");
Print (L"CapsuleApp: Cannot specify more than one FS mapping!\n");
Status = EFI_INVALID_PARAMETER;
goto Done;
}
} else {
CapsuleLastIndex = ParaOdIndex - 1;
CapsuleLastIndex = ParaNrIndex - 1;
}
} else {
if (ParaNrIndex != 0) {
if (ParaNrIndex == Argc -1) {
CapsuleLastIndex = ParaNrIndex - 1;
} else {
Print (L"CapsuleApp: Invalid Position for -NR Options\n");
Status = EFI_INVALID_PARAMETER;
goto Done;
}
} else {
CapsuleLastIndex = Argc - 1;
}
CapsuleLastIndex = Argc - 1;
}
CapsuleNum = CapsuleLastIndex - CapsuleFirstIndex + 1;