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

@@ -23,6 +23,8 @@
#include <Guid/GlobalVariable.h>
#include <Guid/Gpt.h>
#define MAX_CAPSULE_NUM 10
EFI_GUID mCapsuleOnDiskBootOptionGuid = { 0x4CC29BB7, 0x2413, 0x40A2, { 0xB0, 0x6D, 0x25, 0x3E, 0x37, 0x10, 0xF5, 0x32 } };
/**
@@ -744,6 +746,41 @@ SetCapsuleStatusVariable (
return Status;
}
/**
Check if Capsule On Disk is supported.
@retval TRUE Capsule On Disk is supported.
@retval FALSE Capsule On Disk is not supported.
**/
BOOLEAN
IsCapsuleOnDiskSupported (
VOID
)
{
EFI_STATUS Status;
UINT64 OsIndicationsSupported;
UINTN DataSize;
DataSize = sizeof(UINT64);
Status = gRT->GetVariable (
L"OsIndicationsSupported",
&gEfiGlobalVariableGuid,
NULL,
&DataSize,
&OsIndicationsSupported
);
if (EFI_ERROR (Status)) {
return FALSE;
}
if (OsIndicationsSupported & EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED) {
return TRUE;
}
return FALSE;
}
/**
Process Capsule On Disk.
@@ -770,6 +807,16 @@ ProcessCapsuleOnDisk (
UINT16 BootNext;
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs;
BOOLEAN UpdateBootNext;
CHAR16 *FileName[MAX_CAPSULE_NUM];
UINTN Index;
//
// Check if Capsule On Disk is supported
//
if (!IsCapsuleOnDiskSupported ()) {
Print (L"CapsuleApp: Capsule On Disk is not supported.\n");
return EFI_UNSUPPORTED;
}
//
// Get a valid file system from boot path
@@ -782,10 +829,17 @@ ProcessCapsuleOnDisk (
return Status;
}
//
// Get file name from file path
//
for (Index = 0; Index < CapsuleNum; Index ++) {
FileName[Index] = GetFileNameFromPath (FilePath[Index]);
}
//
// Copy capsule image to '\efi\UpdateCapsule\'
//
Status = WriteUpdateFile (CapsuleBuffer, CapsuleBufferSize, FilePath, CapsuleNum, Fs);
Status = WriteUpdateFile (CapsuleBuffer, CapsuleBufferSize, FileName, CapsuleNum, Fs);
if (EFI_ERROR (Status)) {
Print (L"CapsuleApp: capsule image could not be copied for update.\n");
return Status;