summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Application/CapsuleApp
diff options
context:
space:
mode:
authorMichael Kubacki <michael.kubacki@microsoft.com>2021-12-05 14:54:02 -0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2021-12-07 17:24:28 +0000
commit1436aea4d5707e672672a11bda72be2c63c936c3 (patch)
tree370c9d5bd8823aa8ea7bce71a0f29bff71feff67 /MdeModulePkg/Application/CapsuleApp
parent7c7184e201a90a1d2376e615e55e3f4074731468 (diff)
downloadedk2-1436aea4d5707e672672a11bda72be2c63c936c3.tar.gz
edk2-1436aea4d5707e672672a11bda72be2c63c936c3.tar.bz2
edk2-1436aea4d5707e672672a11bda72be2c63c936c3.zip
MdeModulePkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the MdeModulePkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Diffstat (limited to 'MdeModulePkg/Application/CapsuleApp')
-rw-r--r--MdeModulePkg/Application/CapsuleApp/AppSupport.c76
-rw-r--r--MdeModulePkg/Application/CapsuleApp/CapsuleApp.c516
-rw-r--r--MdeModulePkg/Application/CapsuleApp/CapsuleApp.h50
-rw-r--r--MdeModulePkg/Application/CapsuleApp/CapsuleDump.c843
-rw-r--r--MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c333
5 files changed, 941 insertions, 877 deletions
diff --git a/MdeModulePkg/Application/CapsuleApp/AppSupport.c b/MdeModulePkg/Application/CapsuleApp/AppSupport.c
index 8fe70dc3b6..3b98ad07bf 100644
--- a/MdeModulePkg/Application/CapsuleApp/AppSupport.c
+++ b/MdeModulePkg/Application/CapsuleApp/AppSupport.c
@@ -8,9 +8,9 @@
#include "CapsuleApp.h"
-UINTN Argc;
-CHAR16 **Argv;
-EFI_SHELL_PROTOCOL *mShellProtocol = NULL;
+UINTN Argc;
+CHAR16 **Argv;
+EFI_SHELL_PROTOCOL *mShellProtocol = NULL;
/**
@@ -23,15 +23,15 @@ GetArg (
VOID
)
{
- EFI_STATUS Status;
- EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters;
+ EFI_STATUS Status;
+ EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters;
Status = gBS->HandleProtocol (
gImageHandle,
&gEfiShellParametersProtocolGuid,
- (VOID**)&ShellParameters
+ (VOID **)&ShellParameters
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
return Status;
}
@@ -50,13 +50,13 @@ GetShellProtocol (
VOID
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
if (mShellProtocol == NULL) {
Status = gBS->LocateProtocol (
&gEfiShellProtocolGuid,
NULL,
- (VOID **) &mShellProtocol
+ (VOID **)&mShellProtocol
);
if (EFI_ERROR (Status)) {
mShellProtocol = NULL;
@@ -79,19 +79,19 @@ GetShellProtocol (
**/
EFI_STATUS
ReadFileToBuffer (
- IN CHAR16 *FileName,
- OUT UINTN *BufferSize,
- OUT VOID **Buffer
+ IN CHAR16 *FileName,
+ OUT UINTN *BufferSize,
+ OUT VOID **Buffer
)
{
- EFI_STATUS Status;
- EFI_SHELL_PROTOCOL *ShellProtocol;
- SHELL_FILE_HANDLE Handle;
- UINT64 FileSize;
- UINTN TempBufferSize;
- VOID *TempBuffer;
-
- ShellProtocol = GetShellProtocol();
+ EFI_STATUS Status;
+ EFI_SHELL_PROTOCOL *ShellProtocol;
+ SHELL_FILE_HANDLE Handle;
+ UINT64 FileSize;
+ UINTN TempBufferSize;
+ VOID *TempBuffer;
+
+ ShellProtocol = GetShellProtocol ();
if (ShellProtocol == NULL) {
return EFI_NOT_FOUND;
}
@@ -117,8 +117,8 @@ ReadFileToBuffer (
return Status;
}
- TempBufferSize = (UINTN) FileSize;
- TempBuffer = AllocateZeroPool (TempBufferSize);
+ TempBufferSize = (UINTN)FileSize;
+ TempBuffer = AllocateZeroPool (TempBufferSize);
if (TempBuffer == NULL) {
ShellProtocol->CloseFile (Handle);
return EFI_OUT_OF_RESOURCES;
@@ -157,18 +157,18 @@ ReadFileToBuffer (
**/
EFI_STATUS
WriteFileFromBuffer (
- IN CHAR16 *FileName,
- IN UINTN BufferSize,
- IN VOID *Buffer
+ IN CHAR16 *FileName,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
)
{
- EFI_STATUS Status;
- EFI_SHELL_PROTOCOL *ShellProtocol;
- SHELL_FILE_HANDLE Handle;
- EFI_FILE_INFO *FileInfo;
- UINTN TempBufferSize;
+ EFI_STATUS Status;
+ EFI_SHELL_PROTOCOL *ShellProtocol;
+ SHELL_FILE_HANDLE Handle;
+ EFI_FILE_INFO *FileInfo;
+ UINTN TempBufferSize;
- ShellProtocol = GetShellProtocol();
+ ShellProtocol = GetShellProtocol ();
if (ShellProtocol == NULL) {
return EFI_NOT_FOUND;
}
@@ -202,24 +202,25 @@ WriteFileFromBuffer (
// Set the file size to 0.
//
FileInfo->FileSize = 0;
- Status = ShellProtocol->SetFileInfo (Handle, FileInfo);
+ Status = ShellProtocol->SetFileInfo (Handle, FileInfo);
if (EFI_ERROR (Status)) {
FreePool (FileInfo);
ShellProtocol->CloseFile (Handle);
return Status;
}
}
+
FreePool (FileInfo);
//
// Write the file data from the buffer
//
TempBufferSize = BufferSize;
- Status = ShellProtocol->WriteFile (
- Handle,
- &TempBufferSize,
- Buffer
- );
+ Status = ShellProtocol->WriteFile (
+ Handle,
+ &TempBufferSize,
+ Buffer
+ );
if (EFI_ERROR (Status)) {
ShellProtocol->CloseFile (Handle);
return Status;
@@ -229,4 +230,3 @@ WriteFileFromBuffer (
return EFI_SUCCESS;
}
-
diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
index 4034714773..d6fb9283d3 100644
--- a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
+++ b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
@@ -27,52 +27,54 @@ CreateBmpFmp (
VOID
)
{
- CHAR16 *OutputCapsuleName;
- VOID *BmpBuffer;
- UINTN FileSize;
- CHAR16 *BmpName;
- UINT8 *FullCapsuleBuffer;
- UINTN FullCapsuleBufferSize;
- EFI_DISPLAY_CAPSULE *DisplayCapsule;
- EFI_STATUS Status;
- EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop;
- EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL *GopBlt;
- UINTN GopBltSize;
- UINTN Height;
- UINTN Width;
-
- Status = gBS->LocateProtocol(&gEfiGraphicsOutputProtocolGuid, NULL, (VOID **)&Gop);
- if (EFI_ERROR(Status)) {
- Print(L"CapsuleApp: NO GOP is found.\n");
+ CHAR16 *OutputCapsuleName;
+ VOID *BmpBuffer;
+ UINTN FileSize;
+ CHAR16 *BmpName;
+ UINT8 *FullCapsuleBuffer;
+ UINTN FullCapsuleBufferSize;
+ EFI_DISPLAY_CAPSULE *DisplayCapsule;
+ EFI_STATUS Status;
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop;
+ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *GopBlt;
+ UINTN GopBltSize;
+ UINTN Height;
+ UINTN Width;
+
+ Status = gBS->LocateProtocol (&gEfiGraphicsOutputProtocolGuid, NULL, (VOID **)&Gop);
+ if (EFI_ERROR (Status)) {
+ Print (L"CapsuleApp: NO GOP is found.\n");
return EFI_UNSUPPORTED;
}
+
Info = Gop->Mode->Info;
- Print(L"Current GOP: Mode - %d, ", Gop->Mode->Mode);
- Print(L"HorizontalResolution - %d, ", Info->HorizontalResolution);
- Print(L"VerticalResolution - %d\n", Info->VerticalResolution);
+ Print (L"Current GOP: Mode - %d, ", Gop->Mode->Mode);
+ Print (L"HorizontalResolution - %d, ", Info->HorizontalResolution);
+ Print (L"VerticalResolution - %d\n", Info->VerticalResolution);
// HorizontalResolution >= BMP_IMAGE_HEADER.PixelWidth
// VerticalResolution >= BMP_IMAGE_HEADER.PixelHeight
if (Argc != 5) {
- Print(L"CapsuleApp: Incorrect parameter count.\n");
+ Print (L"CapsuleApp: Incorrect parameter count.\n");
return EFI_UNSUPPORTED;
}
- if (StrCmp(Argv[3], L"-O") != 0) {
- Print(L"CapsuleApp: NO output capsule name.\n");
+ if (StrCmp (Argv[3], L"-O") != 0) {
+ Print (L"CapsuleApp: NO output capsule name.\n");
return EFI_UNSUPPORTED;
}
+
OutputCapsuleName = Argv[4];
- BmpBuffer = NULL;
- FileSize = 0;
+ BmpBuffer = NULL;
+ FileSize = 0;
FullCapsuleBuffer = NULL;
BmpName = Argv[2];
- Status = ReadFileToBuffer(BmpName, &FileSize, &BmpBuffer);
- if (EFI_ERROR(Status)) {
- Print(L"CapsuleApp: BMP image (%s) is not found.\n", BmpName);
+ Status = ReadFileToBuffer (BmpName, &FileSize, &BmpBuffer);
+ if (EFI_ERROR (Status)) {
+ Print (L"CapsuleApp: BMP image (%s) is not found.\n", BmpName);
goto Done;
}
@@ -85,45 +87,48 @@ CreateBmpFmp (
&Height,
&Width
);
- if (EFI_ERROR(Status)) {
- Print(L"CapsuleApp: BMP image (%s) is not valid.\n", BmpName);
+ if (EFI_ERROR (Status)) {
+ Print (L"CapsuleApp: BMP image (%s) is not valid.\n", BmpName);
goto Done;
}
+
if (GopBlt != NULL) {
FreePool (GopBlt);
}
- Print(L"BMP image (%s), Width - %d, Height - %d\n", BmpName, Width, Height);
+
+ Print (L"BMP image (%s), Width - %d, Height - %d\n", BmpName, Width, Height);
if (Height > Info->VerticalResolution) {
Status = EFI_INVALID_PARAMETER;
- Print(L"CapsuleApp: BMP image (%s) height is larger than current resolution.\n", BmpName);
+ Print (L"CapsuleApp: BMP image (%s) height is larger than current resolution.\n", BmpName);
goto Done;
}
+
if (Width > Info->HorizontalResolution) {
Status = EFI_INVALID_PARAMETER;
- Print(L"CapsuleApp: BMP image (%s) width is larger than current resolution.\n", BmpName);
+ Print (L"CapsuleApp: BMP image (%s) width is larger than current resolution.\n", BmpName);
goto Done;
}
- FullCapsuleBufferSize = sizeof(EFI_DISPLAY_CAPSULE) + FileSize;
- FullCapsuleBuffer = AllocatePool(FullCapsuleBufferSize);
+ FullCapsuleBufferSize = sizeof (EFI_DISPLAY_CAPSULE) + FileSize;
+ FullCapsuleBuffer = AllocatePool (FullCapsuleBufferSize);
if (FullCapsuleBuffer == NULL) {
- Print(L"CapsuleApp: Capsule Buffer size (0x%x) too big.\n", FullCapsuleBufferSize);
+ Print (L"CapsuleApp: Capsule Buffer size (0x%x) too big.\n", FullCapsuleBufferSize);
Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
DisplayCapsule = (EFI_DISPLAY_CAPSULE *)FullCapsuleBuffer;
- CopyGuid(&DisplayCapsule->CapsuleHeader.CapsuleGuid, &gWindowsUxCapsuleGuid);
- DisplayCapsule->CapsuleHeader.HeaderSize = sizeof(DisplayCapsule->CapsuleHeader);
- DisplayCapsule->CapsuleHeader.Flags = CAPSULE_FLAGS_PERSIST_ACROSS_RESET;
+ CopyGuid (&DisplayCapsule->CapsuleHeader.CapsuleGuid, &gWindowsUxCapsuleGuid);
+ DisplayCapsule->CapsuleHeader.HeaderSize = sizeof (DisplayCapsule->CapsuleHeader);
+ DisplayCapsule->CapsuleHeader.Flags = CAPSULE_FLAGS_PERSIST_ACROSS_RESET;
DisplayCapsule->CapsuleHeader.CapsuleImageSize = (UINT32)FullCapsuleBufferSize;
- DisplayCapsule->ImagePayload.Version = 1;
- DisplayCapsule->ImagePayload.Checksum = 0;
+ DisplayCapsule->ImagePayload.Version = 1;
+ DisplayCapsule->ImagePayload.Checksum = 0;
DisplayCapsule->ImagePayload.ImageType = 0; // BMP
- DisplayCapsule->ImagePayload.Reserved = 0;
- DisplayCapsule->ImagePayload.Mode = Gop->Mode->Mode;
+ DisplayCapsule->ImagePayload.Reserved = 0;
+ DisplayCapsule->ImagePayload.Mode = Gop->Mode->Mode;
//
// Center the bitmap horizontally
@@ -140,26 +145,27 @@ CreateBmpFmp (
(UINT32)(((3 * Info->VerticalResolution) - (2 * Height)) / 4)
);
- Print(L"BMP image (%s), OffsetX - %d, OffsetY - %d\n",
+ Print (
+ L"BMP image (%s), OffsetX - %d, OffsetY - %d\n",
BmpName,
DisplayCapsule->ImagePayload.OffsetX,
DisplayCapsule->ImagePayload.OffsetY
);
- CopyMem((DisplayCapsule + 1), BmpBuffer, FileSize);
+ CopyMem ((DisplayCapsule + 1), BmpBuffer, FileSize);
- DisplayCapsule->ImagePayload.Checksum = CalculateCheckSum8(FullCapsuleBuffer, FullCapsuleBufferSize);
+ DisplayCapsule->ImagePayload.Checksum = CalculateCheckSum8 (FullCapsuleBuffer, FullCapsuleBufferSize);
- Status = WriteFileFromBuffer(OutputCapsuleName, FullCapsuleBufferSize, FullCapsuleBuffer);
- Print(L"CapsuleApp: Write %s %r\n", OutputCapsuleName, Status);
+ Status = WriteFileFromBuffer (OutputCapsuleName, FullCapsuleBufferSize, FullCapsuleBuffer);
+ Print (L"CapsuleApp: Write %s %r\n", OutputCapsuleName, Status);
Done:
if (BmpBuffer != NULL) {
- FreePool(BmpBuffer);
+ FreePool (BmpBuffer);
}
if (FullCapsuleBuffer != NULL) {
- FreePool(FullCapsuleBuffer);
+ FreePool (FullCapsuleBuffer);
}
return Status;
@@ -174,18 +180,19 @@ Done:
**/
EFI_GUID *
GetCapsuleImageTypeId (
- IN EFI_CAPSULE_HEADER *CapsuleHeader
+ IN EFI_CAPSULE_HEADER *CapsuleHeader
)
{
- EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER *FmpCapsuleHeader;
- UINT64 *ItemOffsetList;
- EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *ImageHeader;
+ EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER *FmpCapsuleHeader;
+ UINT64 *ItemOffsetList;
+ EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *ImageHeader;
FmpCapsuleHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER *)((UINT8 *)CapsuleHeader + CapsuleHeader->HeaderSize);
- ItemOffsetList = (UINT64 *)(FmpCapsuleHeader + 1);
+ ItemOffsetList = (UINT64 *)(FmpCapsuleHeader + 1);
if (FmpCapsuleHeader->PayloadItemCount == 0) {
return NULL;
}
+
ImageHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *)((UINT8 *)FmpCapsuleHeader + ItemOffsetList[FmpCapsuleHeader->EmbeddedDriverCount]);
return &ImageHeader->UpdateImageTypeId;
}
@@ -199,7 +206,7 @@ GetCapsuleImageTypeId (
**/
UINT32
GetEsrtFwType (
- IN EFI_GUID *ImageTypeId
+ IN EFI_GUID *ImageTypeId
)
{
EFI_STATUS Status;
@@ -210,12 +217,12 @@ GetEsrtFwType (
//
// Check ESRT
//
- Status = EfiGetSystemConfigurationTable(&gEfiSystemResourceTableGuid, (VOID **)&Esrt);
- if (!EFI_ERROR(Status)) {
- ASSERT(Esrt != NULL);
+ Status = EfiGetSystemConfigurationTable (&gEfiSystemResourceTableGuid, (VOID **)&Esrt);
+ if (!EFI_ERROR (Status)) {
+ ASSERT (Esrt != NULL);
EsrtEntry = (VOID *)(Esrt + 1);
for (Index = 0; Index < Esrt->FwResourceCount; Index++, EsrtEntry++) {
- if (CompareGuid(&EsrtEntry->FwClass, ImageTypeId)) {
+ if (CompareGuid (&EsrtEntry->FwClass, ImageTypeId)) {
return EsrtEntry->FwType;
}
}
@@ -238,19 +245,22 @@ GetEsrtFwType (
**/
BOOLEAN
IsValidCapsuleHeader (
- IN EFI_CAPSULE_HEADER *CapsuleHeader,
- IN UINT64 CapsuleSize
+ IN EFI_CAPSULE_HEADER *CapsuleHeader,
+ IN UINT64 CapsuleSize
)
{
if (CapsuleSize < sizeof (EFI_CAPSULE_HEADER)) {
return FALSE;
}
+
if (CapsuleHeader->CapsuleImageSize != CapsuleSize) {
return FALSE;
}
+
if (CapsuleHeader->HeaderSize > CapsuleHeader->CapsuleImageSize) {
return FALSE;
}
+
if (CapsuleHeader->HeaderSize < sizeof (EFI_CAPSULE_HEADER)) {
return FALSE;
}
@@ -271,7 +281,7 @@ IsFmpCapsuleGuid (
IN EFI_GUID *CapsuleGuid
)
{
- if (CompareGuid(&gEfiFmpCapsuleGuid, CapsuleGuid)) {
+ if (CompareGuid (&gEfiFmpCapsuleGuid, CapsuleGuid)) {
return TRUE;
}
@@ -291,96 +301,98 @@ CreateNestedFmp (
VOID
)
{
- CHAR16 *OutputCapsuleName;
- VOID *CapsuleBuffer;
- UINTN FileSize;
- CHAR16 *CapsuleName;
- UINT8 *FullCapsuleBuffer;
- UINTN FullCapsuleBufferSize;
- EFI_CAPSULE_HEADER *NestedCapsuleHeader;
- EFI_GUID *ImageTypeId;
- UINT32 FwType;
- EFI_STATUS Status;
+ CHAR16 *OutputCapsuleName;
+ VOID *CapsuleBuffer;
+ UINTN FileSize;
+ CHAR16 *CapsuleName;
+ UINT8 *FullCapsuleBuffer;
+ UINTN FullCapsuleBufferSize;
+ EFI_CAPSULE_HEADER *NestedCapsuleHeader;
+ EFI_GUID *ImageTypeId;
+ UINT32 FwType;
+ EFI_STATUS Status;
if (Argc != 5) {
- Print(L"CapsuleApp: Incorrect parameter count.\n");
+ Print (L"CapsuleApp: Incorrect parameter count.\n");
return EFI_UNSUPPORTED;
}
- if (StrCmp(Argv[3], L"-O") != 0) {
- Print(L"CapsuleApp: NO output capsule name.\n");
+ if (StrCmp (Argv[3], L"-O") != 0) {
+ Print (L"CapsuleApp: NO output capsule name.\n");
return EFI_UNSUPPORTED;
}
+
OutputCapsuleName = Argv[4];
- CapsuleBuffer = NULL;
- FileSize = 0;
+ CapsuleBuffer = NULL;
+ FileSize = 0;
FullCapsuleBuffer = NULL;
CapsuleName = Argv[2];
- Status = ReadFileToBuffer(CapsuleName, &FileSize, &CapsuleBuffer);
- if (EFI_ERROR(Status)) {
- Print(L"CapsuleApp: Capsule image (%s) is not found.\n", CapsuleName);
+ Status = ReadFileToBuffer (CapsuleName, &FileSize, &CapsuleBuffer);
+ if (EFI_ERROR (Status)) {
+ Print (L"CapsuleApp: Capsule image (%s) is not found.\n", CapsuleName);
goto Done;
}
+
if (!IsValidCapsuleHeader (CapsuleBuffer, FileSize)) {
- Print(L"CapsuleApp: Capsule image (%s) is not a valid capsule.\n", CapsuleName);
+ Print (L"CapsuleApp: Capsule image (%s) is not a valid capsule.\n", CapsuleName);
Status = EFI_INVALID_PARAMETER;
goto Done;
}
- if (!IsFmpCapsuleGuid (&((EFI_CAPSULE_HEADER *) CapsuleBuffer)->CapsuleGuid)) {
- Print(L"CapsuleApp: Capsule image (%s) is not a FMP capsule.\n", CapsuleName);
+ if (!IsFmpCapsuleGuid (&((EFI_CAPSULE_HEADER *)CapsuleBuffer)->CapsuleGuid)) {
+ Print (L"CapsuleApp: Capsule image (%s) is not a FMP capsule.\n", CapsuleName);
Status = EFI_INVALID_PARAMETER;
goto Done;
}
- ImageTypeId = GetCapsuleImageTypeId(CapsuleBuffer);
+ ImageTypeId = GetCapsuleImageTypeId (CapsuleBuffer);
if (ImageTypeId == NULL) {
- Print(L"CapsuleApp: Capsule ImageTypeId is not found.\n");
+ Print (L"CapsuleApp: Capsule ImageTypeId is not found.\n");
Status = EFI_INVALID_PARAMETER;
goto Done;
}
- FwType = GetEsrtFwType(ImageTypeId);
+
+ FwType = GetEsrtFwType (ImageTypeId);
if ((FwType != ESRT_FW_TYPE_SYSTEMFIRMWARE) && (FwType != ESRT_FW_TYPE_DEVICEFIRMWARE)) {
- Print(L"CapsuleApp: Capsule FwType is invalid.\n");
+ Print (L"CapsuleApp: Capsule FwType is invalid.\n");
Status = EFI_INVALID_PARAMETER;
goto Done;
}
FullCapsuleBufferSize = NESTED_CAPSULE_HEADER_SIZE + FileSize;
- FullCapsuleBuffer = AllocatePool(FullCapsuleBufferSize);
+ FullCapsuleBuffer = AllocatePool (FullCapsuleBufferSize);
if (FullCapsuleBuffer == NULL) {
- Print(L"CapsuleApp: Capsule Buffer size (0x%x) too big.\n", FullCapsuleBufferSize);
+ Print (L"CapsuleApp: Capsule Buffer size (0x%x) too big.\n", FullCapsuleBufferSize);
Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
NestedCapsuleHeader = (EFI_CAPSULE_HEADER *)FullCapsuleBuffer;
- ZeroMem(NestedCapsuleHeader, NESTED_CAPSULE_HEADER_SIZE);
- CopyGuid(&NestedCapsuleHeader->CapsuleGuid, ImageTypeId);
- NestedCapsuleHeader->HeaderSize = NESTED_CAPSULE_HEADER_SIZE;
- NestedCapsuleHeader->Flags = (FwType == ESRT_FW_TYPE_SYSTEMFIRMWARE) ? SYSTEM_FIRMWARE_FLAG : DEVICE_FIRMWARE_FLAG;
+ ZeroMem (NestedCapsuleHeader, NESTED_CAPSULE_HEADER_SIZE);
+ CopyGuid (&NestedCapsuleHeader->CapsuleGuid, ImageTypeId);
+ NestedCapsuleHeader->HeaderSize = NESTED_CAPSULE_HEADER_SIZE;
+ NestedCapsuleHeader->Flags = (FwType == ESRT_FW_TYPE_SYSTEMFIRMWARE) ? SYSTEM_FIRMWARE_FLAG : DEVICE_FIRMWARE_FLAG;
NestedCapsuleHeader->CapsuleImageSize = (UINT32)FullCapsuleBufferSize;
- CopyMem((UINT8 *)NestedCapsuleHeader + NestedCapsuleHeader->HeaderSize, CapsuleBuffer, FileSize);
+ CopyMem ((UINT8 *)NestedCapsuleHeader + NestedCapsuleHeader->HeaderSize, CapsuleBuffer, FileSize);
- Status = WriteFileFromBuffer(OutputCapsuleName, FullCapsuleBufferSize, FullCapsuleBuffer);
- Print(L"CapsuleApp: Write %s %r\n", OutputCapsuleName, Status);
+ Status = WriteFileFromBuffer (OutputCapsuleName, FullCapsuleBufferSize, FullCapsuleBuffer);
+ Print (L"CapsuleApp: Write %s %r\n", OutputCapsuleName, Status);
Done:
if (CapsuleBuffer != NULL) {
- FreePool(CapsuleBuffer);
+ FreePool (CapsuleBuffer);
}
if (FullCapsuleBuffer != NULL) {
- FreePool(FullCapsuleBuffer);
+ FreePool (FullCapsuleBuffer);
}
return Status;
}
-
/**
Clear capsule status variable.
@@ -391,19 +403,19 @@ ClearCapsuleStatusVariable (
VOID
)
{
- EFI_STATUS Status;
- UINT32 Index;
- CHAR16 CapsuleVarName[20];
- CHAR16 *TempVarName;
- BOOLEAN Found;
+ EFI_STATUS Status;
+ UINT32 Index;
+ CHAR16 CapsuleVarName[20];
+ CHAR16 *TempVarName;
+ BOOLEAN Found;
- StrCpyS (CapsuleVarName, sizeof(CapsuleVarName)/sizeof(CapsuleVarName[0]), L"Capsule");
+ StrCpyS (CapsuleVarName, sizeof (CapsuleVarName)/sizeof (CapsuleVarName[0]), L"Capsule");
TempVarName = CapsuleVarName + StrLen (CapsuleVarName);
- Index = 0;
+ Index = 0;
Found = FALSE;
while (TRUE) {
- UnicodeSPrint (TempVarName, 5 * sizeof(CHAR16), L"%04x", Index);
+ UnicodeSPrint (TempVarName, 5 * sizeof (CHAR16), L"%04x", Index);
Status = gRT->SetVariable (
CapsuleVarName,
@@ -418,6 +430,7 @@ ClearCapsuleStatusVariable (
//
break;
}
+
Found = TRUE;
Print (L"Clear %s %r\n", CapsuleVarName, Status);
@@ -447,10 +460,10 @@ ClearCapsuleStatusVariable (
**/
EFI_STATUS
BuildGatherList (
- IN VOID **CapsuleBuffer,
- IN UINTN *FileSize,
- IN UINTN CapsuleNum,
- OUT EFI_CAPSULE_BLOCK_DESCRIPTOR **BlockDescriptors
+ IN VOID **CapsuleBuffer,
+ IN UINTN *FileSize,
+ IN UINTN CapsuleNum,
+ OUT EFI_CAPSULE_BLOCK_DESCRIPTOR **BlockDescriptors
)
{
EFI_STATUS Status;
@@ -482,15 +495,15 @@ BuildGatherList (
Count = (INT32)(NumberOfDescriptors + 2) / 2;
}
- Size = Count * sizeof (EFI_CAPSULE_BLOCK_DESCRIPTOR);
- BlockDescriptors1 = AllocateRuntimeZeroPool (Size);
+ Size = Count * sizeof (EFI_CAPSULE_BLOCK_DESCRIPTOR);
+ BlockDescriptors1 = AllocateRuntimeZeroPool (Size);
if (BlockDescriptors1 == NULL) {
Print (L"CapsuleApp: failed to allocate memory for descriptors\n");
Status = EFI_OUT_OF_RESOURCES;
goto ERREXIT;
} else {
- Print (L"CapsuleApp: creating capsule descriptors at 0x%X\n", (UINTN) BlockDescriptors1);
- Print (L"CapsuleApp: capsule data starts at 0x%X with size 0x%X\n", (UINTN) CapsuleBuffer[Index], FileSize[Index]);
+ Print (L"CapsuleApp: creating capsule descriptors at 0x%X\n", (UINTN)BlockDescriptors1);
+ Print (L"CapsuleApp: capsule data starts at 0x%X with size 0x%X\n", (UINTN)CapsuleBuffer[Index], FileSize[Index]);
}
//
@@ -501,16 +514,16 @@ BuildGatherList (
}
if (BlockDescriptorPre != NULL) {
- BlockDescriptorPre->Union.ContinuationPointer = (UINTN) BlockDescriptors1;
- BlockDescriptorPre->Length = 0;
+ BlockDescriptorPre->Union.ContinuationPointer = (UINTN)BlockDescriptors1;
+ BlockDescriptorPre->Length = 0;
}
//
// Fill them in
//
- TempBlockPtr = BlockDescriptors1;
- TempDataPtr = CapsuleBuffer[Index];
- SizeLeft = FileSize[Index];
+ TempBlockPtr = BlockDescriptors1;
+ TempDataPtr = CapsuleBuffer[Index];
+ SizeLeft = FileSize[Index];
for (Number = 0; (Number < Count - 1) && (SizeLeft != 0); Number++) {
//
// Divide remaining data in half
@@ -524,10 +537,11 @@ BuildGatherList (
} else {
Size = SizeLeft;
}
- TempBlockPtr->Union.DataBlock = (UINTN)TempDataPtr;
- TempBlockPtr->Length = Size;
- Print (L"CapsuleApp: capsule block/size 0x%X/0x%X\n", (UINTN) TempDataPtr, Size);
- SizeLeft -= Size;
+
+ TempBlockPtr->Union.DataBlock = (UINTN)TempDataPtr;
+ TempBlockPtr->Length = Size;
+ Print (L"CapsuleApp: capsule block/size 0x%X/0x%X\n", (UINTN)TempDataPtr, Size);
+ SizeLeft -= Size;
TempDataPtr += Size;
TempBlockPtr++;
}
@@ -555,10 +569,10 @@ BuildGatherList (
//
// Point the first list's last element to point to this second list.
//
- TempBlockPtr->Union.ContinuationPointer = (UINTN) BlockDescriptors2;
+ TempBlockPtr->Union.ContinuationPointer = (UINTN)BlockDescriptors2;
- TempBlockPtr->Length = 0;
- TempBlockPtr = BlockDescriptors2;
+ TempBlockPtr->Length = 0;
+ TempBlockPtr = BlockDescriptors2;
for (Number = 0; Number < Count - 1; Number++) {
//
// If second-to-last one, then dump rest to this element
@@ -576,10 +590,10 @@ BuildGatherList (
}
}
- TempBlockPtr->Union.DataBlock = (UINTN)TempDataPtr;
- TempBlockPtr->Length = Size;
- Print (L"CapsuleApp: capsule block/size 0x%X/0x%X\n", (UINTN) TempDataPtr, Size);
- SizeLeft -= Size;
+ TempBlockPtr->Union.DataBlock = (UINTN)TempDataPtr;
+ TempBlockPtr->Length = Size;
+ Print (L"CapsuleApp: capsule block/size 0x%X/0x%X\n", (UINTN)TempDataPtr, Size);
+ SizeLeft -= Size;
TempDataPtr += Size;
TempBlockPtr++;
if (SizeLeft == 0) {
@@ -596,20 +610,20 @@ BuildGatherList (
// Null-terminate.
//
if (TempBlockPtr != NULL) {
- TempBlockPtr->Union.ContinuationPointer = (UINTN)NULL;
- TempBlockPtr->Length = 0;
- *BlockDescriptors = BlockDescriptorsHeader;
+ TempBlockPtr->Union.ContinuationPointer = (UINTN)NULL;
+ TempBlockPtr->Length = 0;
+ *BlockDescriptors = BlockDescriptorsHeader;
}
return EFI_SUCCESS;
ERREXIT:
if (BlockDescriptors1 != NULL) {
- FreePool(BlockDescriptors1);
+ FreePool (BlockDescriptors1);
}
if (BlockDescriptors2 != NULL) {
- FreePool(BlockDescriptors2);
+ FreePool (BlockDescriptors2);
}
return Status;
@@ -623,18 +637,18 @@ ERREXIT:
**/
VOID
CleanGatherList (
- IN EFI_CAPSULE_BLOCK_DESCRIPTOR *BlockDescriptors,
- IN UINTN CapsuleNum
+ IN EFI_CAPSULE_BLOCK_DESCRIPTOR *BlockDescriptors,
+ IN UINTN CapsuleNum
)
{
- EFI_CAPSULE_BLOCK_DESCRIPTOR *TempBlockPtr;
- EFI_CAPSULE_BLOCK_DESCRIPTOR *TempBlockPtr1;
- EFI_CAPSULE_BLOCK_DESCRIPTOR *TempBlockPtr2;
- UINTN Index;
+ EFI_CAPSULE_BLOCK_DESCRIPTOR *TempBlockPtr;
+ EFI_CAPSULE_BLOCK_DESCRIPTOR *TempBlockPtr1;
+ EFI_CAPSULE_BLOCK_DESCRIPTOR *TempBlockPtr2;
+ UINTN Index;
if (BlockDescriptors != NULL) {
TempBlockPtr1 = BlockDescriptors;
- while (1){
+ while (1) {
TempBlockPtr = TempBlockPtr1;
for (Index = 0; Index < CapsuleNum; Index++) {
if (TempBlockPtr[Index].Length == 0) {
@@ -646,8 +660,8 @@ CleanGatherList (
break;
}
- TempBlockPtr2 = (VOID *) ((UINTN) TempBlockPtr[Index].Union.ContinuationPointer);
- FreePool(TempBlockPtr1);
+ TempBlockPtr2 = (VOID *)((UINTN)TempBlockPtr[Index].Union.ContinuationPointer);
+ FreePool (TempBlockPtr1);
TempBlockPtr1 = TempBlockPtr2;
}
}
@@ -661,42 +675,42 @@ PrintUsage (
VOID
)
{
- Print(L"CapsuleApp: usage\n");
- Print(L" CapsuleApp <Capsule...> [-NR] [-OD [FSx]]\n");
- Print(L" CapsuleApp -S\n");
- Print(L" CapsuleApp -C\n");
- Print(L" CapsuleApp -P\n");
- Print(L" CapsuleApp -E\n");
- Print(L" CapsuleApp -L\n");
- Print(L" CapsuleApp -L INFO\n");
- Print(L" CapsuleApp -F\n");
- Print(L" CapsuleApp -G <BMP> -O <Capsule>\n");
- Print(L" CapsuleApp -N <Capsule> -O <NestedCapsule>\n");
- Print(L" CapsuleApp -D <Capsule>\n");
- Print(L" CapsuleApp -P GET <ImageTypeId> <Index> -O <FileName>\n");
- 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.\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");
- Print(L" which is defined in UEFI specification.\n");
- Print(L" -P: Dump UEFI FMP protocol info, or get image with specified\n");
- Print(L" ImageTypeId and Index (decimal format) to a file if 'GET'\n");
- Print(L" option is used.\n");
- Print(L" -E: Dump UEFI ESRT table info.\n");
- Print(L" -L: Dump provisioned capsule image information.\n");
- Print(L" -F: Dump all EFI System Partition.\n");
- Print(L" -G: Convert a BMP file to be an UX capsule,\n");
- Print(L" according to Windows Firmware Update document\n");
- Print(L" -N: Append a Capsule Header to an existing FMP capsule image\n");
- Print(L" with its ImageTypeId supported by the system,\n");
- Print(L" according to Windows Firmware Update document\n");
- Print(L" -O: Output new Capsule file name\n");
- Print(L" -D: Dump Capsule image header information, image payload\n");
- Print(L" information if it is an UX capsule and FMP header\n");
- Print(L" information if it is a FMP capsule.\n");
+ Print (L"CapsuleApp: usage\n");
+ Print (L" CapsuleApp <Capsule...> [-NR] [-OD [FSx]]\n");
+ Print (L" CapsuleApp -S\n");
+ Print (L" CapsuleApp -C\n");
+ Print (L" CapsuleApp -P\n");
+ Print (L" CapsuleApp -E\n");
+ Print (L" CapsuleApp -L\n");
+ Print (L" CapsuleApp -L INFO\n");
+ Print (L" CapsuleApp -F\n");
+ Print (L" CapsuleApp -G <BMP> -O <Capsule>\n");
+ Print (L" CapsuleApp -N <Capsule> -O <NestedCapsule>\n");
+ Print (L" CapsuleApp -D <Capsule>\n");
+ Print (L" CapsuleApp -P GET <ImageTypeId> <Index> -O <FileName>\n");
+ 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.\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");
+ Print (L" which is defined in UEFI specification.\n");
+ Print (L" -P: Dump UEFI FMP protocol info, or get image with specified\n");
+ Print (L" ImageTypeId and Index (decimal format) to a file if 'GET'\n");
+ Print (L" option is used.\n");
+ Print (L" -E: Dump UEFI ESRT table info.\n");
+ Print (L" -L: Dump provisioned capsule image information.\n");
+ Print (L" -F: Dump all EFI System Partition.\n");
+ Print (L" -G: Convert a BMP file to be an UX capsule,\n");
+ Print (L" according to Windows Firmware Update document\n");
+ Print (L" -N: Append a Capsule Header to an existing FMP capsule image\n");
+ Print (L" with its ImageTypeId supported by the system,\n");
+ Print (L" according to Windows Firmware Update document\n");
+ Print (L" -O: Output new Capsule file name\n");
+ Print (L" -D: Dump Capsule image header information, image payload\n");
+ Print (L" information if it is an UX capsule and FMP header\n");
+ Print (L" information if it is a FMP capsule.\n");
}
/**
@@ -738,54 +752,63 @@ UefiMain (
EFI_GUID ImageTypeId;
UINTN ImageIndex;
- BlockDescriptors = NULL;
- MapFsStr = NULL;
- CapsuleNum = 0;
+ BlockDescriptors = NULL;
+ MapFsStr = NULL;
+ CapsuleNum = 0;
- Status = GetArg();
- if (EFI_ERROR(Status)) {
- Print(L"Please use UEFI SHELL to run this application!\n", Status);
+ Status = GetArg ();
+ if (EFI_ERROR (Status)) {
+ Print (L"Please use UEFI SHELL to run this application!\n", Status);
return Status;
}
+
if (Argc < 2) {
- PrintUsage();
+ PrintUsage ();
return EFI_UNSUPPORTED;
}
- if (StrCmp(Argv[1], L"-D") == 0) {
+
+ if (StrCmp (Argv[1], L"-D") == 0) {
if (Argc != 3) {
- Print(L"CapsuleApp: Incorrect parameter count.\n");
+ Print (L"CapsuleApp: Incorrect parameter count.\n");
return EFI_UNSUPPORTED;
}
- Status = DumpCapsule(Argv[2]);
+
+ Status = DumpCapsule (Argv[2]);
return Status;
}
- if (StrCmp(Argv[1], L"-G") == 0) {
- Status = CreateBmpFmp();
+
+ if (StrCmp (Argv[1], L"-G") == 0) {
+ Status = CreateBmpFmp ();
return Status;
}
- if (StrCmp(Argv[1], L"-N") == 0) {
- Status = CreateNestedFmp();
+
+ if (StrCmp (Argv[1], L"-N") == 0) {
+ Status = CreateNestedFmp ();
return Status;
}
- if (StrCmp(Argv[1], L"-S") == 0) {
- Status = DumpCapsuleStatusVariable();
+
+ if (StrCmp (Argv[1], L"-S") == 0) {
+ Status = DumpCapsuleStatusVariable ();
return EFI_SUCCESS;
}
- if (StrCmp(Argv[1], L"-C") == 0) {
- Status = ClearCapsuleStatusVariable();
+
+ if (StrCmp (Argv[1], L"-C") == 0) {
+ Status = ClearCapsuleStatusVariable ();
return Status;
}
- if (StrCmp(Argv[1], L"-P") == 0) {
+
+ if (StrCmp (Argv[1], L"-P") == 0) {
if (Argc == 2) {
- DumpFmpData();
+ DumpFmpData ();
}
+
if (Argc >= 3) {
- if (StrCmp(Argv[2], L"GET") != 0) {
- Print(L"CapsuleApp: Unrecognized option(%s).\n", Argv[2]);
+ if (StrCmp (Argv[2], L"GET") != 0) {
+ Print (L"CapsuleApp: Unrecognized option(%s).\n", Argv[2]);
return EFI_UNSUPPORTED;
} else {
if (Argc != 7) {
- Print(L"CapsuleApp: Incorrect parameter count.\n");
+ Print (L"CapsuleApp: Incorrect parameter count.\n");
return EFI_UNSUPPORTED;
}
@@ -797,54 +820,58 @@ UefiMain (
Print (L"Invalid ImageTypeId - %s\n", Argv[3]);
return EFI_INVALID_PARAMETER;
}
- ImageIndex = StrDecimalToUintn(Argv[4]);
- if (StrCmp(Argv[5], L"-O") != 0) {
- Print(L"CapsuleApp: NO output file name.\n");
+
+ ImageIndex = StrDecimalToUintn (Argv[4]);
+ if (StrCmp (Argv[5], L"-O") != 0) {
+ Print (L"CapsuleApp: NO output file name.\n");
return EFI_UNSUPPORTED;
}
- DumpFmpImage(&ImageTypeId, ImageIndex, Argv[6]);
+
+ DumpFmpImage (&ImageTypeId, ImageIndex, Argv[6]);
}
}
+
return EFI_SUCCESS;
}
- if (StrCmp(Argv[1], L"-E") == 0) {
- DumpEsrtData();
+ if (StrCmp (Argv[1], L"-E") == 0) {
+ DumpEsrtData ();
return EFI_SUCCESS;
}
- if (StrCmp(Argv[1], L"-L") == 0) {
- if (Argc >= 3 && StrCmp(Argv[2], L"INFO") == 0) {
- DumpProvisionedCapsule(TRUE);
+ if (StrCmp (Argv[1], L"-L") == 0) {
+ if ((Argc >= 3) && (StrCmp (Argv[2], L"INFO") == 0)) {
+ DumpProvisionedCapsule (TRUE);
} else {
- DumpProvisionedCapsule(FALSE);
+ DumpProvisionedCapsule (FALSE);
}
+
return EFI_SUCCESS;
}
- if (StrCmp(Argv[1], L"-F") == 0) {
- DumpAllEfiSysPartition();
+ if (StrCmp (Argv[1], L"-F") == 0) {
+ DumpAllEfiSysPartition ();
return EFI_SUCCESS;
}
if (Argv[1][0] == L'-') {
- Print(L"CapsuleApp: Unrecognized option(%s).\n", Argv[1]);
+ Print (L"CapsuleApp: Unrecognized option(%s).\n", Argv[1]);
return EFI_UNSUPPORTED;
}
CapsuleFirstIndex = 1;
- NoReset = FALSE;
- CapsuleOnDisk = FALSE;
- ParaOdIndex = 0;
- ParaNrIndex = 0;
+ NoReset = FALSE;
+ CapsuleOnDisk = FALSE;
+ ParaOdIndex = 0;
+ ParaNrIndex = 0;
for (Index = 1; Index < Argc; Index++) {
- if (StrCmp(Argv[Index], L"-OD") == 0) {
- ParaOdIndex = Index;
+ if (StrCmp (Argv[Index], L"-OD") == 0) {
+ ParaOdIndex = Index;
CapsuleOnDisk = TRUE;
- } else if (StrCmp(Argv[Index], L"-NR") == 0) {
+ } else if (StrCmp (Argv[Index], L"-NR") == 0) {
ParaNrIndex = Index;
- NoReset = TRUE;
+ NoReset = TRUE;
}
}
@@ -886,37 +913,40 @@ UefiMain (
CapsuleNum = CapsuleLastIndex - CapsuleFirstIndex + 1;
if (CapsuleFirstIndex > CapsuleLastIndex) {
- Print(L"CapsuleApp: NO capsule image.\n");
+ Print (L"CapsuleApp: NO capsule image.\n");
return EFI_UNSUPPORTED;
}
+
if (CapsuleNum > MAX_CAPSULE_NUM) {
- Print(L"CapsuleApp: Too many capsule images.\n");
+ Print (L"CapsuleApp: Too many capsule images.\n");
return EFI_UNSUPPORTED;
}
- ZeroMem(&CapsuleBuffer, sizeof(CapsuleBuffer));
- ZeroMem(&CapsuleBufferSize, sizeof(CapsuleBufferSize));
+ ZeroMem (&CapsuleBuffer, sizeof (CapsuleBuffer));
+ ZeroMem (&CapsuleBufferSize, sizeof (CapsuleBufferSize));
BlockDescriptors = NULL;
for (Index = 0; Index < CapsuleNum; Index++) {
CapsuleName = Argv[CapsuleFirstIndex + Index];
- Status = ReadFileToBuffer(CapsuleName, &CapsuleBufferSize[Index], &CapsuleBuffer[Index]);
- if (EFI_ERROR(Status)) {
- Print(L"CapsuleApp: capsule image (%s) is not found.\n", CapsuleName);
+ Status = ReadFileToBuffer (CapsuleName, &CapsuleBufferSize[Index], &CapsuleBuffer[Index]);
+ if (EFI_ERROR (Status)) {
+ Print (L"CapsuleApp: capsule image (%s) is not found.\n", CapsuleName);
goto Done;
}
+
if (!IsValidCapsuleHeader (CapsuleBuffer[Index], CapsuleBufferSize[Index])) {
- Print(L"CapsuleApp: Capsule image (%s) is not a valid capsule.\n", CapsuleName);
+ Print (L"CapsuleApp: Capsule image (%s) is not a valid capsule.\n", CapsuleName);
return EFI_INVALID_PARAMETER;
}
+
CapsuleNames[Index] = CapsuleName;
}
//
// Every capsule use 2 descriptor 1 for data 1 for end
//
- Status = BuildGatherList(CapsuleBuffer, CapsuleBufferSize, CapsuleNum, &BlockDescriptors);
- if (EFI_ERROR(Status)) {
+ Status = BuildGatherList (CapsuleBuffer, CapsuleBufferSize, CapsuleNum, &BlockDescriptors);
+ if (EFI_ERROR (Status)) {
goto Done;
}
@@ -925,18 +955,19 @@ UefiMain (
//
NeedReset = FALSE;
for (Index = 0; Index < CapsuleNum; Index++) {
- CapsuleHeaderArray[Index] = (EFI_CAPSULE_HEADER *) CapsuleBuffer[Index];
+ CapsuleHeaderArray[Index] = (EFI_CAPSULE_HEADER *)CapsuleBuffer[Index];
if ((CapsuleHeaderArray[Index]->Flags & CAPSULE_FLAGS_PERSIST_ACROSS_RESET) != 0) {
NeedReset = TRUE;
}
}
+
CapsuleHeaderArray[CapsuleNum] = NULL;
//
// Inquire platform capability of UpdateCapsule.
//
Status = gRT->QueryCapsuleCapabilities (CapsuleHeaderArray, CapsuleNum, &MaxCapsuleSize, &ResetType);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
Print (L"CapsuleApp: failed to query capsule capability - %r\n", Status);
goto Done;
}
@@ -970,11 +1001,12 @@ UefiMain (
// Check whether the input capsule image has the flag of persist across system reset.
//
if (NeedReset) {
- Status = gRT->UpdateCapsule(CapsuleHeaderArray,CapsuleNum,(UINTN) BlockDescriptors);
+ Status = gRT->UpdateCapsule (CapsuleHeaderArray, CapsuleNum, (UINTN)BlockDescriptors);
if (Status != EFI_SUCCESS) {
Print (L"CapsuleApp: failed to update capsule - %r\n", Status);
goto Done;
}
+
//
// For capsule with CAPSULE_FLAGS_PERSIST_ACROSS_RESET + CAPSULE_FLAGS_INITIATE_RESET,
// a system reset should have been triggered by gRT->UpdateCapsule() calling above.
@@ -994,7 +1026,7 @@ UefiMain (
// For capsule who has no reset flag, only call UpdateCapsule Service without a
// system reset. The service will process the capsule immediately.
//
- Status = gRT->UpdateCapsule (CapsuleHeaderArray,CapsuleNum,(UINTN) BlockDescriptors);
+ Status = gRT->UpdateCapsule (CapsuleHeaderArray, CapsuleNum, (UINTN)BlockDescriptors);
if (Status != EFI_SUCCESS) {
Print (L"CapsuleApp: failed to update capsule - %r\n", Status);
}
@@ -1009,7 +1041,7 @@ Done:
}
}
- CleanGatherList(BlockDescriptors, CapsuleNum);
+ CleanGatherList (BlockDescriptors, CapsuleNum);
return Status;
}
diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.h b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.h
index 270d2359a3..255a2e0e1e 100644
--- a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.h
+++ b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.h
@@ -6,7 +6,6 @@
**/
-
#ifndef _CAPSULE_APP_H_
#define _CAPSULE_APP_H_
@@ -42,22 +41,22 @@
#define CAPSULE_HEADER_SIZE 0x20
#define NESTED_CAPSULE_HEADER_SIZE SIZE_4KB
-#define SYSTEM_FIRMWARE_FLAG 0x50000
-#define DEVICE_FIRMWARE_FLAG 0x78010
+#define SYSTEM_FIRMWARE_FLAG 0x50000
+#define DEVICE_FIRMWARE_FLAG 0x78010
-#define MAJOR_VERSION 1
-#define MINOR_VERSION 0
+#define MAJOR_VERSION 1
+#define MINOR_VERSION 0
-#define MAX_CAPSULE_NUM 10
+#define MAX_CAPSULE_NUM 10
//
// (20 * (6+5+2))+1) unicode characters from EFI FAT spec (doubled for bytes)
//
-#define MAX_FILE_NAME_SIZE 522
-#define MAX_FILE_NAME_LEN (MAX_FILE_NAME_SIZE / sizeof(CHAR16))
+#define MAX_FILE_NAME_SIZE 522
+#define MAX_FILE_NAME_LEN (MAX_FILE_NAME_SIZE / sizeof(CHAR16))
-extern UINTN Argc;
-extern CHAR16 **Argv;
+extern UINTN Argc;
+extern CHAR16 **Argv;
/**
@@ -81,7 +80,6 @@ GetShellProtocol (
VOID
);
-
/**
Read a file.
@@ -95,9 +93,9 @@ GetShellProtocol (
**/
EFI_STATUS
ReadFileToBuffer (
- IN CHAR16 *FileName,
- OUT UINTN *BufferSize,
- OUT VOID **Buffer
+ IN CHAR16 *FileName,
+ OUT UINTN *BufferSize,
+ OUT VOID **Buffer
);
/**
@@ -113,12 +111,11 @@ ReadFileToBuffer (
**/
EFI_STATUS
WriteFileFromBuffer (
- IN CHAR16 *FileName,
- IN UINTN BufferSize,
- IN VOID *Buffer
+ IN CHAR16 *FileName,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
);
-
/**
Dump capsule information
@@ -129,7 +126,7 @@ WriteFileFromBuffer (
**/
EFI_STATUS
DumpCapsule (
- IN CHAR16 *CapsuleName
+ IN CHAR16 *CapsuleName
);
/**
@@ -182,7 +179,7 @@ DumpEsrtData (
**/
VOID
DumpProvisionedCapsule (
- IN BOOLEAN DumpCapsuleInfo
+ IN BOOLEAN DumpCapsuleInfo
);
/**
@@ -193,7 +190,6 @@ DumpAllEfiSysPartition (
VOID
);
-
/**
Get SimpleFileSystem from boot option file path.
@@ -213,7 +209,6 @@ GetEfiSysPartitionFromBootOptionFilePath (
OUT EFI_SIMPLE_FILE_SYSTEM_PROTOCOL **Fs
);
-
/**
Process Capsule On Disk.
@@ -229,12 +224,11 @@ GetEfiSysPartitionFromBootOptionFilePath (
**/
EFI_STATUS
ProcessCapsuleOnDisk (
- IN VOID **CapsuleBuffer,
- IN UINTN *CapsuleBufferSize,
- IN CHAR16 **FilePath,
- IN CHAR16 *Map,
- IN UINTN CapsuleNum
+ IN VOID **CapsuleBuffer,
+ IN UINTN *CapsuleBufferSize,
+ IN CHAR16 **FilePath,
+ IN CHAR16 *Map,
+ IN UINTN CapsuleNum
);
#endif
-
diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c b/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c
index 5725e2f6dd..26ad60ce59 100644
--- a/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c
+++ b/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c
@@ -22,8 +22,8 @@
**/
BOOLEAN
IsValidCapsuleHeader (
- IN EFI_CAPSULE_HEADER *CapsuleHeader,
- IN UINT64 CapsuleSize
+ IN EFI_CAPSULE_HEADER *CapsuleHeader,
+ IN UINT64 CapsuleSize
);
/**
@@ -36,24 +36,24 @@ DumpUxCapsule (
IN EFI_CAPSULE_HEADER *CapsuleHeader
)
{
- EFI_DISPLAY_CAPSULE *DisplayCapsule;
+ EFI_DISPLAY_CAPSULE *DisplayCapsule;
+
DisplayCapsule = (EFI_DISPLAY_CAPSULE *)CapsuleHeader;
- Print(L"[UxCapsule]\n");
- Print(L"CapsuleHeader:\n");
- Print(L" CapsuleGuid - %g\n", &DisplayCapsule->CapsuleHeader.CapsuleGuid);
- Print(L" HeaderSize - 0x%x\n", DisplayCapsule->CapsuleHeader.HeaderSize);
- Print(L" Flags - 0x%x\n", DisplayCapsule->CapsuleHeader.Flags);
- Print(L" CapsuleImageSize - 0x%x\n", DisplayCapsule->CapsuleHeader.CapsuleImageSize);
- Print(L"ImagePayload:\n");
- Print(L" Version - 0x%x\n", DisplayCapsule->ImagePayload.Version);
- Print(L" Checksum - 0x%x\n", DisplayCapsule->ImagePayload.Checksum);
- Print(L" ImageType - 0x%x\n", DisplayCapsule->ImagePayload.ImageType);
- Print(L" Mode - 0x%x\n", DisplayCapsule->ImagePayload.Mode);
- Print(L" OffsetX - 0x%x\n", DisplayCapsule->ImagePayload.OffsetX);
- Print(L" OffsetY - 0x%x\n", DisplayCapsule->ImagePayload.OffsetY);
+ Print (L"[UxCapsule]\n");
+ Print (L"CapsuleHeader:\n");
+ Print (L" CapsuleGuid - %g\n", &DisplayCapsule->CapsuleHeader.CapsuleGuid);
+ Print (L" HeaderSize - 0x%x\n", DisplayCapsule->CapsuleHeader.HeaderSize);
+ Print (L" Flags - 0x%x\n", DisplayCapsule->CapsuleHeader.Flags);
+ Print (L" CapsuleImageSize - 0x%x\n", DisplayCapsule->CapsuleHeader.CapsuleImageSize);
+ Print (L"ImagePayload:\n");
+ Print (L" Version - 0x%x\n", DisplayCapsule->ImagePayload.Version);
+ Print (L" Checksum - 0x%x\n", DisplayCapsule->ImagePayload.Checksum);
+ Print (L" ImageType - 0x%x\n", DisplayCapsule->ImagePayload.ImageType);
+ Print (L" Mode - 0x%x\n", DisplayCapsule->ImagePayload.Mode);
+ Print (L" OffsetX - 0x%x\n", DisplayCapsule->ImagePayload.OffsetX);
+ Print (L" OffsetY - 0x%x\n", DisplayCapsule->ImagePayload.OffsetY);
}
-
/**
Dump a non-nested FMP capsule.
@@ -70,36 +70,36 @@ DumpFmpCapsule (
UINTN Count;
EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *FmpImageHeader;
- Print(L"[FmpCapsule]\n");
- Print(L"CapsuleHeader:\n");
- Print(L" CapsuleGuid - %g\n", &CapsuleHeader->CapsuleGuid);
- Print(L" HeaderSize - 0x%x\n", CapsuleHeader->HeaderSize);
- Print(L" Flags - 0x%x\n", CapsuleHeader->Flags);
- Print(L" CapsuleImageSize - 0x%x\n", CapsuleHeader->CapsuleImageSize);
+ Print (L"[FmpCapsule]\n");
+ Print (L"CapsuleHeader:\n");
+ Print (L" CapsuleGuid - %g\n", &CapsuleHeader->CapsuleGuid);
+ Print (L" HeaderSize - 0x%x\n", CapsuleHeader->HeaderSize);
+ Print (L" Flags - 0x%x\n", CapsuleHeader->Flags);
+ Print (L" CapsuleImageSize - 0x%x\n", CapsuleHeader->CapsuleImageSize);
FmpCapsuleHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER *)((UINT8 *)CapsuleHeader + CapsuleHeader->HeaderSize);
- ItemOffsetList = (UINT64 *)(FmpCapsuleHeader + 1);
- Print(L"FmpHeader:\n");
- Print(L" Version - 0x%x\n", FmpCapsuleHeader->Version);
- Print(L" EmbeddedDriverCount - 0x%x\n", FmpCapsuleHeader->EmbeddedDriverCount);
- Print(L" PayloadItemCount - 0x%x\n", FmpCapsuleHeader->PayloadItemCount);
+ ItemOffsetList = (UINT64 *)(FmpCapsuleHeader + 1);
+ Print (L"FmpHeader:\n");
+ Print (L" Version - 0x%x\n", FmpCapsuleHeader->Version);
+ Print (L" EmbeddedDriverCount - 0x%x\n", FmpCapsuleHeader->EmbeddedDriverCount);
+ Print (L" PayloadItemCount - 0x%x\n", FmpCapsuleHeader->PayloadItemCount);
Count = FmpCapsuleHeader->EmbeddedDriverCount + FmpCapsuleHeader->PayloadItemCount;
for (Index = 0; Index < Count; Index++) {
- Print(L" Offset[%d] - 0x%x\n", Index, ItemOffsetList[Index]);
+ Print (L" Offset[%d] - 0x%x\n", Index, ItemOffsetList[Index]);
}
for (Index = FmpCapsuleHeader->EmbeddedDriverCount; Index < Count; Index++) {
- Print(L"FmpPayload[%d] ImageHeader:\n", Index);
+ Print (L"FmpPayload[%d] ImageHeader:\n", Index);
FmpImageHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *)((UINT8 *)FmpCapsuleHeader + ItemOffsetList[Index]);
- Print(L" Version - 0x%x\n", FmpImageHeader->Version);
- Print(L" UpdateImageTypeId - %g\n", &FmpImageHeader->UpdateImageTypeId);
- Print(L" UpdateImageIndex - 0x%x\n", FmpImageHeader->UpdateImageIndex);
- Print(L" UpdateImageSize - 0x%x\n", FmpImageHeader->UpdateImageSize);
- Print(L" UpdateVendorCodeSize - 0x%x\n", FmpImageHeader->UpdateVendorCodeSize);
+ Print (L" Version - 0x%x\n", FmpImageHeader->Version);
+ Print (L" UpdateImageTypeId - %g\n", &FmpImageHeader->UpdateImageTypeId);
+ Print (L" UpdateImageIndex - 0x%x\n", FmpImageHeader->UpdateImageIndex);
+ Print (L" UpdateImageSize - 0x%x\n", FmpImageHeader->UpdateImageSize);
+ Print (L" UpdateVendorCodeSize - 0x%x\n", FmpImageHeader->UpdateVendorCodeSize);
if (FmpImageHeader->Version >= 2) {
- Print(L" UpdateHardwareInstance - 0x%lx\n", FmpImageHeader->UpdateHardwareInstance);
+ Print (L" UpdateHardwareInstance - 0x%lx\n", FmpImageHeader->UpdateHardwareInstance);
if (FmpImageHeader->Version >= EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER_INIT_VERSION) {
- Print(L" ImageCapsuleSupport - 0x%lx\n", FmpImageHeader->ImageCapsuleSupport);
+ Print (L" ImageCapsuleSupport - 0x%lx\n", FmpImageHeader->ImageCapsuleSupport);
}
}
}
@@ -115,7 +115,7 @@ DumpFmpCapsule (
**/
BOOLEAN
IsNestedFmpCapsule (
- IN EFI_CAPSULE_HEADER *CapsuleHeader
+ IN EFI_CAPSULE_HEADER *CapsuleHeader
)
{
EFI_STATUS Status;
@@ -130,12 +130,12 @@ IsNestedFmpCapsule (
// Check ESRT
//
EsrtGuidFound = FALSE;
- Status = EfiGetSystemConfigurationTable(&gEfiSystemResourceTableGuid, (VOID **)&Esrt);
- if (!EFI_ERROR(Status)) {
+ Status = EfiGetSystemConfigurationTable (&gEfiSystemResourceTableGuid, (VOID **)&Esrt);
+ if (!EFI_ERROR (Status)) {
ASSERT (Esrt != NULL);
EsrtEntry = (VOID *)(Esrt + 1);
for (Index = 0; Index < Esrt->FwResourceCount; Index++, EsrtEntry++) {
- if (CompareGuid(&EsrtEntry->FwClass, &CapsuleHeader->CapsuleGuid)) {
+ if (CompareGuid (&EsrtEntry->FwClass, &CapsuleHeader->CapsuleGuid)) {
EsrtGuidFound = TRUE;
break;
}
@@ -151,13 +151,15 @@ IsNestedFmpCapsule (
// FMP GUID after ESRT one
//
NestedCapsuleHeader = (EFI_CAPSULE_HEADER *)((UINT8 *)CapsuleHeader + CapsuleHeader->HeaderSize);
- NestedCapsuleSize = (UINTN)CapsuleHeader + CapsuleHeader->CapsuleImageSize- (UINTN)NestedCapsuleHeader;
- if (NestedCapsuleSize < sizeof(EFI_CAPSULE_HEADER)) {
+ NestedCapsuleSize = (UINTN)CapsuleHeader + CapsuleHeader->CapsuleImageSize- (UINTN)NestedCapsuleHeader;
+ if (NestedCapsuleSize < sizeof (EFI_CAPSULE_HEADER)) {
return FALSE;
}
- if (!CompareGuid(&NestedCapsuleHeader->CapsuleGuid, &gEfiFmpCapsuleGuid)) {
+
+ if (!CompareGuid (&NestedCapsuleHeader->CapsuleGuid, &gEfiFmpCapsuleGuid)) {
return FALSE;
}
+
return TRUE;
}
@@ -171,50 +173,53 @@ IsNestedFmpCapsule (
**/
EFI_STATUS
DumpCapsule (
- IN CHAR16 *CapsuleName
+ IN CHAR16 *CapsuleName
)
{
- VOID *Buffer;
- UINTN FileSize;
- EFI_CAPSULE_HEADER *CapsuleHeader;
- EFI_STATUS Status;
+ VOID *Buffer;
+ UINTN FileSize;
+ EFI_CAPSULE_HEADER *CapsuleHeader;
+ EFI_STATUS Status;
Buffer = NULL;
- Status = ReadFileToBuffer(CapsuleName, &FileSize, &Buffer);
- if (EFI_ERROR(Status)) {
- Print(L"CapsuleApp: Capsule (%s) is not found.\n", CapsuleName);
+ Status = ReadFileToBuffer (CapsuleName, &FileSize, &Buffer);
+ if (EFI_ERROR (Status)) {
+ Print (L"CapsuleApp: Capsule (%s) is not found.\n", CapsuleName);
goto Done;
}
+
if (!IsValidCapsuleHeader (Buffer, FileSize)) {
- Print(L"CapsuleApp: Capsule image (%s) is not a valid capsule.\n", CapsuleName);
+ Print (L"CapsuleApp: Capsule image (%s) is not a valid capsule.\n", CapsuleName);
Status = EFI_INVALID_PARAMETER;
goto Done;
}
CapsuleHeader = Buffer;
- if (CompareGuid(&CapsuleHeader->CapsuleGuid, &gWindowsUxCapsuleGuid)) {
- DumpUxCapsule(CapsuleHeader);
+ if (CompareGuid (&CapsuleHeader->CapsuleGuid, &gWindowsUxCapsuleGuid)) {
+ DumpUxCapsule (CapsuleHeader);
Status = EFI_SUCCESS;
goto Done;
}
- if (CompareGuid(&CapsuleHeader->CapsuleGuid, &gEfiFmpCapsuleGuid)) {
- DumpFmpCapsule(CapsuleHeader);
+ if (CompareGuid (&CapsuleHeader->CapsuleGuid, &gEfiFmpCapsuleGuid)) {
+ DumpFmpCapsule (CapsuleHeader);
}
- if (IsNestedFmpCapsule(CapsuleHeader)) {
- Print(L"[NestedCapsule]\n");
- Print(L"CapsuleHeader:\n");
- Print(L" CapsuleGuid - %g\n", &CapsuleHeader->CapsuleGuid);
- Print(L" HeaderSize - 0x%x\n", CapsuleHeader->HeaderSize);
- Print(L" Flags - 0x%x\n", CapsuleHeader->Flags);
- Print(L" CapsuleImageSize - 0x%x\n", CapsuleHeader->CapsuleImageSize);
- DumpFmpCapsule((EFI_CAPSULE_HEADER *)((UINTN)CapsuleHeader + CapsuleHeader->HeaderSize));
+
+ if (IsNestedFmpCapsule (CapsuleHeader)) {
+ Print (L"[NestedCapsule]\n");
+ Print (L"CapsuleHeader:\n");
+ Print (L" CapsuleGuid - %g\n", &CapsuleHeader->CapsuleGuid);
+ Print (L" HeaderSize - 0x%x\n", CapsuleHeader->HeaderSize);
+ Print (L" Flags - 0x%x\n", CapsuleHeader->Flags);
+ Print (L" CapsuleImageSize - 0x%x\n", CapsuleHeader->CapsuleImageSize);
+ DumpFmpCapsule ((EFI_CAPSULE_HEADER *)((UINTN)CapsuleHeader + CapsuleHeader->HeaderSize));
}
Done:
if (Buffer != NULL) {
- FreePool(Buffer);
+ FreePool (Buffer);
}
+
return Status;
}
@@ -241,80 +246,81 @@ DumpCapsuleStatusVariable (
CHAR16 *CapsuleFileName;
CHAR16 *CapsuleTarget;
- Status = GetVariable2(
+ Status = GetVariable2 (
L"CapsuleMax",
&gEfiCapsuleReportGuid,
(VOID **)&CapsuleIndex,
NULL
);
- if (!EFI_ERROR(Status)) {
+ if (!EFI_ERROR (Status)) {
ASSERT (CapsuleIndex != NULL);
- CopyMem(CapsuleIndexData, CapsuleIndex, 11 * sizeof(CHAR16));
+ CopyMem (CapsuleIndexData, CapsuleIndex, 11 * sizeof (CHAR16));
CapsuleIndexData[11] = 0;
- Print(L"CapsuleMax - %s\n", CapsuleIndexData);
- FreePool(CapsuleIndex);
+ Print (L"CapsuleMax - %s\n", CapsuleIndexData);
+ FreePool (CapsuleIndex);
}
- Status = GetVariable2(
+
+ Status = GetVariable2 (
L"CapsuleLast",
&gEfiCapsuleReportGuid,
(VOID **)&CapsuleIndex,
NULL
);
- if (!EFI_ERROR(Status)) {
+ if (!EFI_ERROR (Status)) {
ASSERT (CapsuleIndex != NULL);
- CopyMem(CapsuleIndexData, CapsuleIndex, 11 * sizeof(CHAR16));
+ CopyMem (CapsuleIndexData, CapsuleIndex, 11 * sizeof (CHAR16));
CapsuleIndexData[11] = 0;
- Print(L"CapsuleLast - %s\n", CapsuleIndexData);
- FreePool(CapsuleIndex);
+ Print (L"CapsuleLast - %s\n", CapsuleIndexData);
+ FreePool (CapsuleIndex);
}
-
- StrCpyS (CapsuleVarName, sizeof(CapsuleVarName)/sizeof(CapsuleVarName[0]), L"Capsule");
+ StrCpyS (CapsuleVarName, sizeof (CapsuleVarName)/sizeof (CapsuleVarName[0]), L"Capsule");
TempVarName = CapsuleVarName + StrLen (CapsuleVarName);
- Index = 0;
+ Index = 0;
while (TRUE) {
- UnicodeSPrint (TempVarName, 5 * sizeof(CHAR16), L"%04x", Index);
+ UnicodeSPrint (TempVarName, 5 * sizeof (CHAR16), L"%04x", Index);
Status = GetVariable2 (
CapsuleVarName,
&gEfiCapsuleReportGuid,
- (VOID **) &CapsuleResult,
+ (VOID **)&CapsuleResult,
NULL
);
if (Status == EFI_NOT_FOUND) {
break;
- } else if (EFI_ERROR(Status)) {
+ } else if (EFI_ERROR (Status)) {
continue;
}
+
ASSERT (CapsuleResult != NULL);
//
// display capsule process status
//
- if (CapsuleResult->VariableTotalSize >= sizeof(EFI_CAPSULE_RESULT_VARIABLE_HEADER)) {
+ if (CapsuleResult->VariableTotalSize >= sizeof (EFI_CAPSULE_RESULT_VARIABLE_HEADER)) {
Print (L"CapsuleName: %s\n", CapsuleVarName);
Print (L" Capsule Guid: %g\n", &CapsuleResult->CapsuleGuid);
Print (L" Capsule ProcessedTime: %t\n", &CapsuleResult->CapsuleProcessed);
Print (L" Capsule Status: %r\n", CapsuleResult->CapsuleStatus);
}
- if (CompareGuid(&CapsuleResult->CapsuleGuid, &gEfiFmpCapsuleGuid)) {
- if (CapsuleResult->VariableTotalSize >= sizeof(EFI_CAPSULE_RESULT_VARIABLE_HEADER) + sizeof(EFI_CAPSULE_RESULT_VARIABLE_FMP) + sizeof(CHAR16) * 2) {
+ if (CompareGuid (&CapsuleResult->CapsuleGuid, &gEfiFmpCapsuleGuid)) {
+ if (CapsuleResult->VariableTotalSize >= sizeof (EFI_CAPSULE_RESULT_VARIABLE_HEADER) + sizeof (EFI_CAPSULE_RESULT_VARIABLE_FMP) + sizeof (CHAR16) * 2) {
CapsuleResultFmp = (EFI_CAPSULE_RESULT_VARIABLE_FMP *)(CapsuleResult + 1);
- Print(L" Capsule FMP Version: 0x%x\n", CapsuleResultFmp->Version);
- Print(L" Capsule FMP PayloadIndex: 0x%x\n", CapsuleResultFmp->PayloadIndex);
- Print(L" Capsule FMP UpdateImageIndex: 0x%x\n", CapsuleResultFmp->UpdateImageIndex);
- Print(L" Capsule FMP UpdateImageTypeId: %g\n", &CapsuleResultFmp->UpdateImageTypeId);
+ Print (L" Capsule FMP Version: 0x%x\n", CapsuleResultFmp->Version);
+ Print (L" Capsule FMP PayloadIndex: 0x%x\n", CapsuleResultFmp->PayloadIndex);
+ Print (L" Capsule FMP UpdateImageIndex: 0x%x\n", CapsuleResultFmp->UpdateImageIndex);
+ Print (L" Capsule FMP UpdateImageTypeId: %g\n", &CapsuleResultFmp->UpdateImageTypeId);
CapsuleFileName = (CHAR16 *)(CapsuleResultFmp + 1);
- Print(L" Capsule FMP CapsuleFileName: \"%s\"\n", CapsuleFileName);
- CapsuleFileNameSize = StrSize(CapsuleFileName);
- CapsuleTarget = (CHAR16 *)((UINTN)CapsuleFileName + CapsuleFileNameSize);
- Print(L" Capsule FMP CapsuleTarget: \"%s\"\n", CapsuleTarget);
+ Print (L" Capsule FMP CapsuleFileName: \"%s\"\n", CapsuleFileName);
+ CapsuleFileNameSize = StrSize (CapsuleFileName);
+ CapsuleTarget = (CHAR16 *)((UINTN)CapsuleFileName + CapsuleFileNameSize);
+ Print (L" Capsule FMP CapsuleTarget: \"%s\"\n", CapsuleTarget);
}
}
- FreePool(CapsuleResult);
+ FreePool (CapsuleResult);
Index++;
if (Index > 0xFFFF) {
@@ -325,14 +331,14 @@ DumpCapsuleStatusVariable (
return EFI_SUCCESS;
}
-CHAR8 *mFwTypeString[] = {
+CHAR8 *mFwTypeString[] = {
"Unknown",
"SystemFirmware",
"DeviceFirmware",
"UefiDriver",
};
-CHAR8 *mLastAttemptStatusString[] = {
+CHAR8 *mLastAttemptStatusString[] = {
"Success",
"Error: Unsuccessful",
"Error: Insufficient Resources",
@@ -356,7 +362,7 @@ FwTypeToString (
IN UINT32 FwType
)
{
- if (FwType < sizeof(mFwTypeString) / sizeof(mFwTypeString[0])) {
+ if (FwType < sizeof (mFwTypeString) / sizeof (mFwTypeString[0])) {
return mFwTypeString[FwType];
} else {
return "Invalid";
@@ -375,7 +381,7 @@ LastAttemptStatusToString (
IN UINT32 LastAttemptStatus
)
{
- if (LastAttemptStatus < sizeof(mLastAttemptStatusString) / sizeof(mLastAttemptStatusString[0])) {
+ if (LastAttemptStatus < sizeof (mLastAttemptStatusString) / sizeof (mLastAttemptStatusString[0])) {
return mLastAttemptStatusString[LastAttemptStatus];
} else {
return "Error: Unknown";
@@ -392,13 +398,13 @@ DumpEsrtEntry (
IN EFI_SYSTEM_RESOURCE_ENTRY *EsrtEntry
)
{
- Print(L" FwClass - %g\n", &EsrtEntry->FwClass);
- Print(L" FwType - 0x%x (%a)\n", EsrtEntry->FwType, FwTypeToString(EsrtEntry->FwType));
- Print(L" FwVersion - 0x%x\n", EsrtEntry->FwVersion);
- Print(L" LowestSupportedFwVersion - 0x%x\n", EsrtEntry->LowestSupportedFwVersion);
- Print(L" CapsuleFlags - 0x%x\n", EsrtEntry->CapsuleFlags);
- Print(L" LastAttemptVersion - 0x%x\n", EsrtEntry->LastAttemptVersion);
- Print(L" LastAttemptStatus - 0x%x (%a)\n", EsrtEntry->LastAttemptStatus, LastAttemptStatusToString(EsrtEntry->LastAttemptStatus));
+ Print (L" FwClass - %g\n", &EsrtEntry->FwClass);
+ Print (L" FwType - 0x%x (%a)\n", EsrtEntry->FwType, FwTypeToString (EsrtEntry->FwType));
+ Print (L" FwVersion - 0x%x\n", EsrtEntry->FwVersion);
+ Print (L" LowestSupportedFwVersion - 0x%x\n", EsrtEntry->LowestSupportedFwVersion);
+ Print (L" CapsuleFlags - 0x%x\n", EsrtEntry->CapsuleFlags);
+ Print (L" LastAttemptVersion - 0x%x\n", EsrtEntry->LastAttemptVersion);
+ Print (L" LastAttemptStatus - 0x%x (%a)\n", EsrtEntry->LastAttemptStatus, LastAttemptStatusToString (EsrtEntry->LastAttemptStatus));
}
/**
@@ -415,18 +421,18 @@ DumpEsrt (
EFI_SYSTEM_RESOURCE_ENTRY *EsrtEntry;
if (Esrt == NULL) {
- return ;
+ return;
}
- Print(L"EFI_SYSTEM_RESOURCE_TABLE:\n");
- Print(L"FwResourceCount - 0x%x\n", Esrt->FwResourceCount);
- Print(L"FwResourceCountMax - 0x%x\n", Esrt->FwResourceCountMax);
- Print(L"FwResourceVersion - 0x%lx\n", Esrt->FwResourceVersion);
+ Print (L"EFI_SYSTEM_RESOURCE_TABLE:\n");
+ Print (L"FwResourceCount - 0x%x\n", Esrt->FwResourceCount);
+ Print (L"FwResourceCountMax - 0x%x\n", Esrt->FwResourceCountMax);
+ Print (L"FwResourceVersion - 0x%lx\n", Esrt->FwResourceVersion);
EsrtEntry = (VOID *)(Esrt + 1);
for (Index = 0; Index < Esrt->FwResourceCount; Index++) {
- Print(L"EFI_SYSTEM_RESOURCE_ENTRY (%d):\n", Index);
- DumpEsrtEntry(EsrtEntry);
+ Print (L"EFI_SYSTEM_RESOURCE_ENTRY (%d):\n", Index);
+ DumpEsrtEntry (EsrtEntry);
EsrtEntry++;
}
}
@@ -442,19 +448,19 @@ DumpEsrtData (
EFI_STATUS Status;
EFI_SYSTEM_RESOURCE_TABLE *Esrt;
- Print(L"##############\n");
- Print(L"# ESRT TABLE #\n");
- Print(L"##############\n");
+ Print (L"##############\n");
+ Print (L"# ESRT TABLE #\n");
+ Print (L"##############\n");
Status = EfiGetSystemConfigurationTable (&gEfiSystemResourceTableGuid, (VOID **)&Esrt);
- if (EFI_ERROR(Status)) {
- Print(L"ESRT - %r\n", Status);
+ if (EFI_ERROR (Status)) {
+ Print (L"ESRT - %r\n", Status);
return;
}
- DumpEsrt(Esrt);
- Print(L"\n");
-}
+ DumpEsrt (Esrt);
+ Print (L"\n");
+}
/**
Dump capsule information from CapsuleHeader
@@ -466,7 +472,7 @@ DumpEsrtData (
**/
EFI_STATUS
DumpCapsuleFromBuffer (
- IN EFI_CAPSULE_HEADER *CapsuleHeader
+ IN EFI_CAPSULE_HEADER *CapsuleHeader
)
{
if (CompareGuid (&CapsuleHeader->CapsuleGuid, &gWindowsUxCapsuleGuid)) {
@@ -477,6 +483,7 @@ DumpCapsuleFromBuffer (
if (CompareGuid (&CapsuleHeader->CapsuleGuid, &gEfiFmpCapsuleGuid)) {
DumpFmpCapsule (CapsuleHeader);
}
+
if (IsNestedFmpCapsule (CapsuleHeader)) {
Print (L"[NestedCapusule]\n");
Print (L"CapsuleHeader:\n");
@@ -501,13 +508,13 @@ DumpCapsuleFromBuffer (
STATIC
CHAR16 *
UpperCaseString (
- IN CHAR16 *Str
+ IN CHAR16 *Str
)
{
CHAR16 *Cptr;
for (Cptr = Str; *Cptr != L'\0'; Cptr++) {
- if (L'a' <= *Cptr && *Cptr <= L'z') {
+ if ((L'a' <= *Cptr) && (*Cptr <= L'z')) {
*Cptr = *Cptr - L'a' + L'A';
}
}
@@ -527,18 +534,19 @@ UpperCaseString (
STATIC
VOID
GetSubStringBeforePeriod (
- IN CHAR16 *Str,
- OUT CHAR16 *SubStr,
- OUT UINTN *SubStrLen
+ IN CHAR16 *Str,
+ OUT CHAR16 *SubStr,
+ OUT UINTN *SubStrLen
)
{
- UINTN Index;
+ UINTN Index;
+
for (Index = 0; Str[Index] != L'.' && Str[Index] != L'\0'; Index++) {
SubStr[Index] = Str[Index];
}
SubStr[Index] = L'\0';
- *SubStrLen = Index;
+ *SubStrLen = Index;
}
/**
@@ -552,16 +560,17 @@ GetSubStringBeforePeriod (
STATIC
VOID
PadStrInTail (
- IN CHAR16 *StrBuf,
- IN UINTN PadLen,
- IN CHAR16 Character
+ IN CHAR16 *StrBuf,
+ IN UINTN PadLen,
+ IN CHAR16 Character
)
{
- UINTN Index;
+ UINTN Index;
- for (Index = 0; StrBuf[Index] != L'\0'; Index++);
+ for (Index = 0; StrBuf[Index] != L'\0'; Index++) {
+ }
- while(PadLen != 0) {
+ while (PadLen != 0) {
StrBuf[Index] = Character;
Index++;
PadLen--;
@@ -587,18 +596,19 @@ SplitFileNameExtension (
OUT CHAR16 *FileNameExtension
)
{
- UINTN Index;
- UINTN StringLen;
+ UINTN Index;
+ UINTN StringLen;
- StringLen = StrLen(FileName);
- for (Index = StringLen; Index > 0 && FileName[Index] != L'.'; Index--);
+ StringLen = StrLen (FileName);
+ for (Index = StringLen; Index > 0 && FileName[Index] != L'.'; Index--) {
+ }
//
// No period exists. No FileName Extension
//
- if (Index == 0 && FileName[Index] != L'.') {
+ if ((Index == 0) && (FileName[Index] != L'.')) {
FileNameExtension[0] = L'\0';
- Index = StringLen;
+ Index = StringLen;
} else {
StrCpyS (FileNameExtension, MAX_FILE_NAME_LEN, &FileName[Index+1]);
}
@@ -623,8 +633,8 @@ SplitFileNameExtension (
**/
INTN
CompareFileNameInAlphabet (
- IN VOID *Left,
- IN VOID *Right
+ IN VOID *Left,
+ IN VOID *Right
)
{
EFI_FILE_INFO *FileInfo1;
@@ -639,8 +649,8 @@ CompareFileNameInAlphabet (
UINTN SubStrLen2;
INTN SubStrCmpResult;
- FileInfo1 = (EFI_FILE_INFO *) (*(UINTN *)Left);
- FileInfo2 = (EFI_FILE_INFO *) (*(UINTN *)Right);
+ FileInfo1 = (EFI_FILE_INFO *)(*(UINTN *)Left);
+ FileInfo2 = (EFI_FILE_INFO *)(*(UINTN *)Right);
SplitFileNameExtension (FileInfo1->FileName, FileName1, FileExtension1);
SplitFileNameExtension (FileInfo2->FileName, FileName2, FileExtension2);
@@ -656,7 +666,7 @@ CompareFileNameInAlphabet (
// Substr in NewFileName is longer. Pad tail with SPACE
//
PadStrInTail (TempSubStr2, SubStrLen1 - SubStrLen2, L' ');
- } else if (SubStrLen1 < SubStrLen2){
+ } else if (SubStrLen1 < SubStrLen2) {
//
// Substr in ListedFileName is longer. Pad tail with SPACE
//
@@ -685,29 +695,29 @@ CompareFileNameInAlphabet (
**/
EFI_STATUS
DumpCapsuleFromDisk (
- IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs,
- IN BOOLEAN DumpCapsuleInfo
+ IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs,
+ IN BOOLEAN DumpCapsuleInfo
)
{
- EFI_STATUS Status;
- EFI_FILE *Root;
- EFI_FILE *DirHandle;
- EFI_FILE *FileHandle;
- UINTN Index;
- UINTN FileSize;
- VOID *FileBuffer;
- EFI_FILE_INFO **FileInfoBuffer;
- EFI_FILE_INFO *FileInfo;
- UINTN FileCount;
- BOOLEAN NoFile;
-
- DirHandle = NULL;
- FileHandle = NULL;
- Index = 0;
- FileInfoBuffer = NULL;
- FileInfo = NULL;
- FileCount = 0;
- NoFile = FALSE;
+ EFI_STATUS Status;
+ EFI_FILE *Root;
+ EFI_FILE *DirHandle;
+ EFI_FILE *FileHandle;
+ UINTN Index;
+ UINTN FileSize;
+ VOID *FileBuffer;
+ EFI_FILE_INFO **FileInfoBuffer;
+ EFI_FILE_INFO *FileInfo;
+ UINTN FileCount;
+ BOOLEAN NoFile;
+
+ DirHandle = NULL;
+ FileHandle = NULL;
+ Index = 0;
+ FileInfoBuffer = NULL;
+ FileInfo = NULL;
+ FileCount = 0;
+ NoFile = FALSE;
Status = Fs->OpenVolume (Fs, &Root);
if (EFI_ERROR (Status)) {
@@ -715,7 +725,7 @@ DumpCapsuleFromDisk (
goto Done;
}
- Status = Root->Open (Root, &DirHandle, EFI_CAPSULE_FILE_DIRECTORY, EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE , 0);
+ Status = Root->Open (Root, &DirHandle, EFI_CAPSULE_FILE_DIRECTORY, EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE, 0);
if (EFI_ERROR (Status)) {
Print (L"Cannot open %s. Status = %r\n", EFI_CAPSULE_FILE_DIRECTORY, Status);
goto Done;
@@ -726,7 +736,7 @@ DumpCapsuleFromDisk (
//
Status = FileHandleFindFirstFile (DirHandle, &FileInfo);
do {
- if (EFI_ERROR (Status) || FileInfo == NULL) {
+ if (EFI_ERROR (Status) || (FileInfo == NULL)) {
Print (L"Get File Info Fail. Status = %r\n", Status);
goto Done;
}
@@ -753,6 +763,7 @@ DumpCapsuleFromDisk (
Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
+
NoFile = FALSE;
//
@@ -760,7 +771,7 @@ DumpCapsuleFromDisk (
//
Status = FileHandleFindFirstFile (DirHandle, &FileInfo);
do {
- if (EFI_ERROR (Status) || FileInfo == NULL) {
+ if (EFI_ERROR (Status) || (FileInfo == NULL)) {
Print (L"Get File Info Fail. Status = %r\n", Status);
goto Done;
}
@@ -783,7 +794,7 @@ DumpCapsuleFromDisk (
FileInfoBuffer,
FileCount,
sizeof (FileInfo),
- (SORT_COMPARE) CompareFileNameInAlphabet
+ (SORT_COMPARE)CompareFileNameInAlphabet
);
Print (L"The capsules will be performed by following order:\n");
@@ -797,16 +808,16 @@ DumpCapsuleFromDisk (
goto Done;
}
- Print(L"The infomation of the capsules:\n");
+ Print (L"The infomation of the capsules:\n");
for (Index = 0; Index < FileCount; Index++) {
FileHandle = NULL;
- Status = DirHandle->Open (DirHandle, &FileHandle, FileInfoBuffer[Index]->FileName, EFI_FILE_MODE_READ, 0);
+ Status = DirHandle->Open (DirHandle, &FileHandle, FileInfoBuffer[Index]->FileName, EFI_FILE_MODE_READ, 0);
if (EFI_ERROR (Status)) {
goto Done;
}
- Status = FileHandleGetSize (FileHandle, (UINT64 *) &FileSize);
+ Status = FileHandleGetSize (FileHandle, (UINT64 *)&FileSize);
if (EFI_ERROR (Status)) {
Print (L"Cannot read file %s. Status = %r\n", FileInfoBuffer[Index]->FileName, Status);
FileHandleClose (FileHandle);
@@ -830,7 +841,7 @@ DumpCapsuleFromDisk (
Print (L"**************************\n");
Print (L" %d.%s:\n", Index + 1, FileInfoBuffer[Index]->FileName);
Print (L"**************************\n");
- DumpCapsuleFromBuffer ((EFI_CAPSULE_HEADER *) FileBuffer);
+ DumpCapsuleFromBuffer ((EFI_CAPSULE_HEADER *)FileBuffer);
FileHandleClose (FileHandle);
FreePool (FileBuffer);
}
@@ -842,6 +853,7 @@ Done:
FreePool (FileInfoBuffer[Index]);
}
}
+
FreePool (FileInfoBuffer);
}
@@ -857,30 +869,32 @@ Done:
**/
VOID
DumpBlockDescriptors (
- IN EFI_CAPSULE_BLOCK_DESCRIPTOR *BlockDescriptors,
- IN BOOLEAN DumpCapsuleInfo
+ IN EFI_CAPSULE_BLOCK_DESCRIPTOR *BlockDescriptors,
+ IN BOOLEAN DumpCapsuleInfo
)
{
- EFI_CAPSULE_BLOCK_DESCRIPTOR *TempBlockPtr;
+ EFI_CAPSULE_BLOCK_DESCRIPTOR *TempBlockPtr;
TempBlockPtr = BlockDescriptors;
while (TRUE) {
if (TempBlockPtr->Length != 0) {
if (DumpCapsuleInfo) {
- Print(L"******************************************************\n");
+ Print (L"******************************************************\n");
}
- Print(L"Capsule data starts at 0x%08x with size 0x%08x\n", TempBlockPtr->Union.DataBlock, TempBlockPtr->Length);
+
+ Print (L"Capsule data starts at 0x%08x with size 0x%08x\n", TempBlockPtr->Union.DataBlock, TempBlockPtr->Length);
if (DumpCapsuleInfo) {
- Print(L"******************************************************\n");
- DumpCapsuleFromBuffer ((EFI_CAPSULE_HEADER *) (UINTN) TempBlockPtr->Union.DataBlock);
+ Print (L"******************************************************\n");
+ DumpCapsuleFromBuffer ((EFI_CAPSULE_HEADER *)(UINTN)TempBlockPtr->Union.DataBlock);
}
+
TempBlockPtr += 1;
} else {
if (TempBlockPtr->Union.ContinuationPointer == (UINTN)NULL) {
break;
} else {
- TempBlockPtr = (EFI_CAPSULE_BLOCK_DESCRIPTOR *) (UINTN) TempBlockPtr->Union.ContinuationPointer;
+ TempBlockPtr = (EFI_CAPSULE_BLOCK_DESCRIPTOR *)(UINTN)TempBlockPtr->Union.ContinuationPointer;
}
}
}
@@ -894,29 +908,29 @@ DumpBlockDescriptors (
**/
VOID
DumpProvisionedCapsule (
- IN BOOLEAN DumpCapsuleInfo
+ IN BOOLEAN DumpCapsuleInfo
)
{
- EFI_STATUS Status;
- CHAR16 CapsuleVarName[30];
- CHAR16 *TempVarName;
- UINTN Index;
- EFI_PHYSICAL_ADDRESS *CapsuleDataPtr64;
- UINT16 *BootNext;
- CHAR16 BootOptionName[20];
- EFI_BOOT_MANAGER_LOAD_OPTION BootNextOptionEntry;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs;
- EFI_SHELL_PROTOCOL *ShellProtocol;
-
- Index = 0;
- CapsuleDataPtr64 = NULL;
- BootNext = NULL;
+ EFI_STATUS Status;
+ CHAR16 CapsuleVarName[30];
+ CHAR16 *TempVarName;
+ UINTN Index;
+ EFI_PHYSICAL_ADDRESS *CapsuleDataPtr64;
+ UINT16 *BootNext;
+ CHAR16 BootOptionName[20];
+ EFI_BOOT_MANAGER_LOAD_OPTION BootNextOptionEntry;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs;
+ EFI_SHELL_PROTOCOL *ShellProtocol;
+
+ Index = 0;
+ CapsuleDataPtr64 = NULL;
+ BootNext = NULL;
ShellProtocol = GetShellProtocol ();
if (ShellProtocol == NULL) {
Print (L"Get Shell Protocol Fail\n");
- return ;
+ return;
}
//
@@ -925,7 +939,7 @@ DumpProvisionedCapsule (
Print (L"#########################\n");
Print (L"### Capsule on Memory ###\n");
Print (L"#########################\n");
- StrCpyS (CapsuleVarName, sizeof(CapsuleVarName)/sizeof(CHAR16), EFI_CAPSULE_VARIABLE_NAME);
+ StrCpyS (CapsuleVarName, sizeof (CapsuleVarName)/sizeof (CHAR16), EFI_CAPSULE_VARIABLE_NAME);
TempVarName = CapsuleVarName + StrLen (CapsuleVarName);
while (TRUE) {
if (Index > 0) {
@@ -939,21 +953,22 @@ DumpProvisionedCapsule (
}
Status = GetVariable2 (
- CapsuleVarName,
- &gEfiCapsuleVendorGuid,
- (VOID **) &CapsuleDataPtr64,
- NULL
- );
- if (EFI_ERROR (Status) || CapsuleDataPtr64 == NULL) {
+ CapsuleVarName,
+ &gEfiCapsuleVendorGuid,
+ (VOID **)&CapsuleDataPtr64,
+ NULL
+ );
+ if (EFI_ERROR (Status) || (CapsuleDataPtr64 == NULL)) {
if (Index == 0) {
Print (L"No data.\n");
}
+
break;
}
Index++;
Print (L"Capsule Description at 0x%08x\n", *CapsuleDataPtr64);
- DumpBlockDescriptors ((EFI_CAPSULE_BLOCK_DESCRIPTOR*) (UINTN) *CapsuleDataPtr64, DumpCapsuleInfo);
+ DumpBlockDescriptors ((EFI_CAPSULE_BLOCK_DESCRIPTOR *)(UINTN)*CapsuleDataPtr64, DumpCapsuleInfo);
}
//
@@ -965,10 +980,10 @@ DumpProvisionedCapsule (
Status = GetVariable2 (
L"BootNext",
&gEfiGlobalVariableGuid,
- (VOID **) &BootNext,
+ (VOID **)&BootNext,
NULL
- );
- if (EFI_ERROR (Status) || BootNext == NULL) {
+ );
+ if (EFI_ERROR (Status) || (BootNext == NULL)) {
Print (L"Get BootNext Variable Fail. Status = %r\n", Status);
} else {
UnicodeSPrint (BootOptionName, sizeof (BootOptionName), L"Boot%04x", *BootNext);
@@ -978,9 +993,9 @@ DumpProvisionedCapsule (
// Display description and device path
//
GetEfiSysPartitionFromBootOptionFilePath (BootNextOptionEntry.FilePath, &DevicePath, &Fs);
- if(!EFI_ERROR (Status)) {
+ if (!EFI_ERROR (Status)) {
Print (L"Capsules are provisioned on BootOption: %s\n", BootNextOptionEntry.Description);
- Print (L" %s %s\n", ShellProtocol->GetMapFromDevicePath (&DevicePath), ConvertDevicePathToText(DevicePath, TRUE, TRUE));
+ Print (L" %s %s\n", ShellProtocol->GetMapFromDevicePath (&DevicePath), ConvertDevicePathToText (DevicePath, TRUE, TRUE));
DumpCapsuleFromDisk (Fs, DumpCapsuleInfo);
}
}
@@ -1000,68 +1015,70 @@ DumpProvisionedCapsule (
**/
VOID
DumpFmpImageInfo (
- IN UINTN ImageInfoSize,
- IN EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo,
- IN UINT32 DescriptorVersion,
- IN UINT8 DescriptorCount,
- IN UINTN DescriptorSize,
- IN UINT32 PackageVersion,
- IN CHAR16 *PackageVersionName
+ IN UINTN ImageInfoSize,
+ IN EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo,
+ IN UINT32 DescriptorVersion,
+ IN UINT8 DescriptorCount,
+ IN UINTN DescriptorSize,
+ IN UINT32 PackageVersion,
+ IN CHAR16 *PackageVersionName
)
{
- EFI_FIRMWARE_IMAGE_DESCRIPTOR *CurrentImageInfo;
- UINTN Index;
- UINTN Index2;
-
- Print(L" DescriptorVersion - 0x%x\n", DescriptorVersion);
- Print(L" DescriptorCount - 0x%x\n", DescriptorCount);
- Print(L" DescriptorSize - 0x%x\n", DescriptorSize);
- Print(L" PackageVersion - 0x%x\n", PackageVersion);
- Print(L" PackageVersionName - \"%s\"\n", PackageVersionName);
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *CurrentImageInfo;
+ UINTN Index;
+ UINTN Index2;
+
+ Print (L" DescriptorVersion - 0x%x\n", DescriptorVersion);
+ Print (L" DescriptorCount - 0x%x\n", DescriptorCount);
+ Print (L" DescriptorSize - 0x%x\n", DescriptorSize);
+ Print (L" PackageVersion - 0x%x\n", PackageVersion);
+ Print (L" PackageVersionName - \"%s\"\n", PackageVersionName);
CurrentImageInfo = ImageInfo;
for (Index = 0; Index < DescriptorCount; Index++) {
- Print(L" ImageDescriptor (%d)\n", Index);
- Print(L" ImageIndex - 0x%x\n", CurrentImageInfo->ImageIndex);
- Print(L" ImageTypeId - %g\n", &CurrentImageInfo->ImageTypeId);
- Print(L" ImageId - 0x%lx\n", CurrentImageInfo->ImageId);
- Print(L" ImageIdName - \"%s\"\n", CurrentImageInfo->ImageIdName);
- Print(L" Version - 0x%x\n", CurrentImageInfo->Version);
- Print(L" VersionName - \"%s\"\n", CurrentImageInfo->VersionName);
- Print(L" Size - 0x%x\n", CurrentImageInfo->Size);
- Print(L" AttributesSupported - 0x%lx\n", CurrentImageInfo->AttributesSupported);
- Print(L" IMAGE_UPDATABLE - 0x%lx\n", CurrentImageInfo->AttributesSupported & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE);
- Print(L" RESET_REQUIRED - 0x%lx\n", CurrentImageInfo->AttributesSupported & IMAGE_ATTRIBUTE_RESET_REQUIRED);
- Print(L" AUTHENTICATION_REQUIRED - 0x%lx\n", CurrentImageInfo->AttributesSupported & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED);
- Print(L" IN_USE - 0x%lx\n", CurrentImageInfo->AttributesSupported & IMAGE_ATTRIBUTE_IN_USE);
- Print(L" UEFI_IMAGE - 0x%lx\n", CurrentImageInfo->AttributesSupported & IMAGE_ATTRIBUTE_UEFI_IMAGE);
- Print(L" AttributesSetting - 0x%lx\n", CurrentImageInfo->AttributesSetting);
- Print(L" IMAGE_UPDATABLE - 0x%lx\n", CurrentImageInfo->AttributesSetting & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE);
- Print(L" RESET_REQUIRED - 0x%lx\n", CurrentImageInfo->AttributesSetting & IMAGE_ATTRIBUTE_RESET_REQUIRED);
- Print(L" AUTHENTICATION_REQUIRED - 0x%lx\n", CurrentImageInfo->AttributesSetting & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED);
- Print(L" IN_USE - 0x%lx\n", CurrentImageInfo->AttributesSetting & IMAGE_ATTRIBUTE_IN_USE);
- Print(L" UEFI_IMAGE - 0x%lx\n", CurrentImageInfo->AttributesSetting & IMAGE_ATTRIBUTE_UEFI_IMAGE);
- Print(L" Compatibilities - 0x%lx\n", CurrentImageInfo->Compatibilities);
- Print(L" COMPATIB_CHECK_SUPPORTED - 0x%lx\n", CurrentImageInfo->Compatibilities & IMAGE_COMPATIBILITY_CHECK_SUPPORTED);
+ Print (L" ImageDescriptor (%d)\n", Index);
+ Print (L" ImageIndex - 0x%x\n", CurrentImageInfo->ImageIndex);
+ Print (L" ImageTypeId - %g\n", &CurrentImageInfo->ImageTypeId);
+ Print (L" ImageId - 0x%lx\n", CurrentImageInfo->ImageId);
+ Print (L" ImageIdName - \"%s\"\n", CurrentImageInfo->ImageIdName);
+ Print (L" Version - 0x%x\n", CurrentImageInfo->Version);
+ Print (L" VersionName - \"%s\"\n", CurrentImageInfo->VersionName);
+ Print (L" Size - 0x%x\n", CurrentImageInfo->Size);
+ Print (L" AttributesSupported - 0x%lx\n", CurrentImageInfo->AttributesSupported);
+ Print (L" IMAGE_UPDATABLE - 0x%lx\n", CurrentImageInfo->AttributesSupported & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE);
+ Print (L" RESET_REQUIRED - 0x%lx\n", CurrentImageInfo->AttributesSupported & IMAGE_ATTRIBUTE_RESET_REQUIRED);
+ Print (L" AUTHENTICATION_REQUIRED - 0x%lx\n", CurrentImageInfo->AttributesSupported & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED);
+ Print (L" IN_USE - 0x%lx\n", CurrentImageInfo->AttributesSupported & IMAGE_ATTRIBUTE_IN_USE);
+ Print (L" UEFI_IMAGE - 0x%lx\n", CurrentImageInfo->AttributesSupported & IMAGE_ATTRIBUTE_UEFI_IMAGE);
+ Print (L" AttributesSetting - 0x%lx\n", CurrentImageInfo->AttributesSetting);
+ Print (L" IMAGE_UPDATABLE - 0x%lx\n", CurrentImageInfo->AttributesSetting & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE);
+ Print (L" RESET_REQUIRED - 0x%lx\n", CurrentImageInfo->AttributesSetting & IMAGE_ATTRIBUTE_RESET_REQUIRED);
+ Print (L" AUTHENTICATION_REQUIRED - 0x%lx\n", CurrentImageInfo->AttributesSetting & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED);
+ Print (L" IN_USE - 0x%lx\n", CurrentImageInfo->AttributesSetting & IMAGE_ATTRIBUTE_IN_USE);
+ Print (L" UEFI_IMAGE - 0x%lx\n", CurrentImageInfo->AttributesSetting & IMAGE_ATTRIBUTE_UEFI_IMAGE);
+ Print (L" Compatibilities - 0x%lx\n", CurrentImageInfo->Compatibilities);
+ Print (L" COMPATIB_CHECK_SUPPORTED - 0x%lx\n", CurrentImageInfo->Compatibilities & IMAGE_COMPATIBILITY_CHECK_SUPPORTED);
if (DescriptorVersion > 1) {
- Print(L" LowestSupportedImageVersion - 0x%x\n", CurrentImageInfo->LowestSupportedImageVersion);
+ Print (L" LowestSupportedImageVersion - 0x%x\n", CurrentImageInfo->LowestSupportedImageVersion);
if (DescriptorVersion > 2) {
- Print(L" LastAttemptVersion - 0x%x\n", CurrentImageInfo->LastAttemptVersion);
- Print(L" LastAttemptStatus - 0x%x (%a)\n", CurrentImageInfo->LastAttemptStatus, LastAttemptStatusToString(CurrentImageInfo->LastAttemptStatus));
- Print(L" HardwareInstance - 0x%lx\n", CurrentImageInfo->HardwareInstance);
+ Print (L" LastAttemptVersion - 0x%x\n", CurrentImageInfo->LastAttemptVersion);
+ Print (L" LastAttemptStatus - 0x%x (%a)\n", CurrentImageInfo->LastAttemptStatus, LastAttemptStatusToString (CurrentImageInfo->LastAttemptStatus));
+ Print (L" HardwareInstance - 0x%lx\n", CurrentImageInfo->HardwareInstance);
if (DescriptorVersion > 3) {
- Print(L" Dependencies - ");
+ Print (L" Dependencies - ");
if (CurrentImageInfo->Dependencies == NULL) {
- Print(L"NULL\n");
+ Print (L"NULL\n");
} else {
Index2 = 0;
do {
- Print(L"%02x ", CurrentImageInfo->Dependencies->Dependencies[Index2]);
- } while (CurrentImageInfo->Dependencies->Dependencies[Index2 ++] != EFI_FMP_DEP_END);
- Print(L"\n");
+ Print (L"%02x ", CurrentImageInfo->Dependencies->Dependencies[Index2]);
+ } while (CurrentImageInfo->Dependencies->Dependencies[Index2++] != EFI_FMP_DEP_END);
+
+ Print (L"\n");
}
}
}
}
+
//
// Use DescriptorSize to move ImageInfo Pointer to stay compatible with different ImageInfo version
//
@@ -1080,24 +1097,24 @@ DumpFmpImageInfo (
**/
VOID
DumpFmpPackageInfo (
- IN UINT32 PackageVersion,
- IN CHAR16 *PackageVersionName,
- IN UINT32 PackageVersionNameMaxLen,
- IN UINT64 AttributesSupported,
- IN UINT64 AttributesSetting
+ IN UINT32 PackageVersion,
+ IN CHAR16 *PackageVersionName,
+ IN UINT32 PackageVersionNameMaxLen,
+ IN UINT64 AttributesSupported,
+ IN UINT64 AttributesSetting
)
{
- Print(L" PackageVersion - 0x%x\n", PackageVersion);
- Print(L" PackageVersionName - \"%s\"\n", PackageVersionName);
- Print(L" PackageVersionNameMaxLen - 0x%x\n", PackageVersionNameMaxLen);
- Print(L" AttributesSupported - 0x%lx\n", AttributesSupported);
- Print(L" IMAGE_UPDATABLE - 0x%lx\n", AttributesSupported & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE);
- Print(L" RESET_REQUIRED - 0x%lx\n", AttributesSupported & IMAGE_ATTRIBUTE_RESET_REQUIRED);
- Print(L" AUTHENTICATION_REQUIRED - 0x%lx\n", AttributesSupported & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED);
- Print(L" AttributesSetting - 0x%lx\n", AttributesSetting);
- Print(L" IMAGE_UPDATABLE - 0x%lx\n", AttributesSetting & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE);
- Print(L" RESET_REQUIRED - 0x%lx\n", AttributesSetting & IMAGE_ATTRIBUTE_RESET_REQUIRED);
- Print(L" AUTHENTICATION_REQUIRED - 0x%lx\n", AttributesSetting & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED);
+ Print (L" PackageVersion - 0x%x\n", PackageVersion);
+ Print (L" PackageVersionName - \"%s\"\n", PackageVersionName);
+ Print (L" PackageVersionNameMaxLen - 0x%x\n", PackageVersionNameMaxLen);
+ Print (L" AttributesSupported - 0x%lx\n", AttributesSupported);
+ Print (L" IMAGE_UPDATABLE - 0x%lx\n", AttributesSupported & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE);
+ Print (L" RESET_REQUIRED - 0x%lx\n", AttributesSupported & IMAGE_ATTRIBUTE_RESET_REQUIRED);
+ Print (L" AUTHENTICATION_REQUIRED - 0x%lx\n", AttributesSupported & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED);
+ Print (L" AttributesSetting - 0x%lx\n", AttributesSetting);
+ Print (L" IMAGE_UPDATABLE - 0x%lx\n", AttributesSetting & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE);
+ Print (L" RESET_REQUIRED - 0x%lx\n", AttributesSetting & IMAGE_ATTRIBUTE_RESET_REQUIRED);
+ Print (L" AUTHENTICATION_REQUIRED - 0x%lx\n", AttributesSetting & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED);
}
/**
@@ -1108,25 +1125,25 @@ DumpFmpData (
VOID
)
{
- EFI_STATUS Status;
- EFI_FIRMWARE_MANAGEMENT_PROTOCOL *Fmp;
- EFI_HANDLE *HandleBuffer;
- UINTN NumberOfHandles;
- UINTN Index;
- EFI_FIRMWARE_IMAGE_DESCRIPTOR *FmpImageInfoBuf;
- UINTN ImageInfoSize;
- UINT32 FmpImageInfoDescriptorVer;
- UINT8 FmpImageInfoCount;
- UINTN DescriptorSize;
- UINT32 PackageVersion;
- CHAR16 *PackageVersionName;
- UINT32 PackageVersionNameMaxLen;
- UINT64 AttributesSupported;
- UINT64 AttributesSetting;
-
- Print(L"############\n");
- Print(L"# FMP DATA #\n");
- Print(L"############\n");
+ EFI_STATUS Status;
+ EFI_FIRMWARE_MANAGEMENT_PROTOCOL *Fmp;
+ EFI_HANDLE *HandleBuffer;
+ UINTN NumberOfHandles;
+ UINTN Index;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *FmpImageInfoBuf;
+ UINTN ImageInfoSize;
+ UINT32 FmpImageInfoDescriptorVer;
+ UINT8 FmpImageInfoCount;
+ UINTN DescriptorSize;
+ UINT32 PackageVersion;
+ CHAR16 *PackageVersionName;
+ UINT32 PackageVersionNameMaxLen;
+ UINT64 AttributesSupported;
+ UINT64 AttributesSetting;
+
+ Print (L"############\n");
+ Print (L"# FMP DATA #\n");
+ Print (L"############\n");
Status = gBS->LocateHandleBuffer (
ByProtocol,
&gEfiFirmwareManagementProtocolGuid,
@@ -1134,32 +1151,32 @@ DumpFmpData (
&NumberOfHandles,
&HandleBuffer
);
- if (EFI_ERROR(Status)) {
- Print(L"FMP protocol - %r\n", EFI_NOT_FOUND);
+ if (EFI_ERROR (Status)) {
+ Print (L"FMP protocol - %r\n", EFI_NOT_FOUND);
return;
}
for (Index = 0; Index < NumberOfHandles; Index++) {
- Status = gBS->HandleProtocol(
+ Status = gBS->HandleProtocol (
HandleBuffer[Index],
&gEfiFirmwareManagementProtocolGuid,
(VOID **)&Fmp
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
continue;
}
ImageInfoSize = 0;
- Status = Fmp->GetImageInfo (
- Fmp,
- &ImageInfoSize,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL
- );
+ Status = Fmp->GetImageInfo (
+ Fmp,
+ &ImageInfoSize,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ );
if (Status != EFI_BUFFER_TOO_SMALL) {
continue;
}
@@ -1172,28 +1189,28 @@ DumpFmpData (
}
PackageVersionName = NULL;
- Status = Fmp->GetImageInfo (
- Fmp,
- &ImageInfoSize, // ImageInfoSize
- FmpImageInfoBuf, // ImageInfo
- &FmpImageInfoDescriptorVer, // DescriptorVersion
- &FmpImageInfoCount, // DescriptorCount
- &DescriptorSize, // DescriptorSize
- &PackageVersion, // PackageVersion
- &PackageVersionName // PackageVersionName
- );
+ Status = Fmp->GetImageInfo (
+ Fmp,
+ &ImageInfoSize, // ImageInfoSize
+ FmpImageInfoBuf, // ImageInfo
+ &FmpImageInfoDescriptorVer, // DescriptorVersion
+ &FmpImageInfoCount, // DescriptorCount
+ &DescriptorSize, // DescriptorSize
+ &PackageVersion, // PackageVersion
+ &PackageVersionName // PackageVersionName
+ );
//
// If FMP GetInformation interface failed, skip this resource
//
- if (EFI_ERROR(Status)) {
- Print(L"FMP (%d) ImageInfo - %r\n", Index, Status);
- FreePool(FmpImageInfoBuf);
+ if (EFI_ERROR (Status)) {
+ Print (L"FMP (%d) ImageInfo - %r\n", Index, Status);
+ FreePool (FmpImageInfoBuf);
continue;
}
- Print(L"FMP (%d) ImageInfo:\n", Index);
- DumpFmpImageInfo(
+ Print (L"FMP (%d) ImageInfo:\n", Index);
+ DumpFmpImageInfo (
ImageInfoSize, // ImageInfoSize
FmpImageInfoBuf, // ImageInfo
FmpImageInfoDescriptorVer, // DescriptorVersion
@@ -1204,27 +1221,28 @@ DumpFmpData (
);
if (PackageVersionName != NULL) {
- FreePool(PackageVersionName);
+ FreePool (PackageVersionName);
}
- FreePool(FmpImageInfoBuf);
+
+ FreePool (FmpImageInfoBuf);
//
// Get package info
//
PackageVersionName = NULL;
- Status = Fmp->GetPackageInfo (
- Fmp,
- &PackageVersion, // PackageVersion
- &PackageVersionName, // PackageVersionName
- &PackageVersionNameMaxLen, // PackageVersionNameMaxLen
- &AttributesSupported, // AttributesSupported
- &AttributesSetting // AttributesSetting
- );
- if (EFI_ERROR(Status)) {
- Print(L"FMP (%d) PackageInfo - %r\n", Index, Status);
+ Status = Fmp->GetPackageInfo (
+ Fmp,
+ &PackageVersion, // PackageVersion
+ &PackageVersionName, // PackageVersionName
+ &PackageVersionNameMaxLen, // PackageVersionNameMaxLen
+ &AttributesSupported, // AttributesSupported
+ &AttributesSetting // AttributesSetting
+ );
+ if (EFI_ERROR (Status)) {
+ Print (L"FMP (%d) PackageInfo - %r\n", Index, Status);
} else {
- Print(L"FMP (%d) ImageInfo:\n", Index);
- DumpFmpPackageInfo(
+ Print (L"FMP (%d) ImageInfo:\n", Index);
+ DumpFmpPackageInfo (
PackageVersion, // PackageVersion
PackageVersionName, // PackageVersionName
PackageVersionNameMaxLen, // PackageVersionNameMaxLen
@@ -1233,14 +1251,15 @@ DumpFmpData (
);
if (PackageVersionName != NULL) {
- FreePool(PackageVersionName);
+ FreePool (PackageVersionName);
}
}
}
- Print(L"\n");
+
+ Print (L"\n");
EXIT:
- FreePool(HandleBuffer);
+ FreePool (HandleBuffer);
}
/**
@@ -1256,22 +1275,24 @@ EXIT:
**/
BOOLEAN
IsThisFmpImageInfo (
- IN EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo,
- IN UINT8 DescriptorCount,
- IN UINTN DescriptorSize,
- IN EFI_GUID *ImageTypeId
+ IN EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo,
+ IN UINT8 DescriptorCount,
+ IN UINTN DescriptorSize,
+ IN EFI_GUID *ImageTypeId
)
{
- EFI_FIRMWARE_IMAGE_DESCRIPTOR *CurrentImageInfo;
- UINTN Index;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *CurrentImageInfo;
+ UINTN Index;
CurrentImageInfo = ImageInfo;
for (Index = 0; Index < DescriptorCount; Index++) {
if (CompareGuid (&CurrentImageInfo->ImageTypeId, ImageTypeId)) {
return TRUE;
}
+
CurrentImageInfo = (EFI_FIRMWARE_IMAGE_DESCRIPTOR *)((UINT8 *)CurrentImageInfo + DescriptorSize);
}
+
return FALSE;
}
@@ -1287,19 +1308,19 @@ FindFmpFromImageTypeId (
IN EFI_GUID *ImageTypeId
)
{
- EFI_STATUS Status;
- EFI_FIRMWARE_MANAGEMENT_PROTOCOL *Fmp;
- EFI_FIRMWARE_MANAGEMENT_PROTOCOL *TargetFmp;
- EFI_HANDLE *HandleBuffer;
- UINTN NumberOfHandles;
- UINTN Index;
- EFI_FIRMWARE_IMAGE_DESCRIPTOR *FmpImageInfoBuf;
- UINTN ImageInfoSize;
- UINT32 FmpImageInfoDescriptorVer;
- UINT8 FmpImageInfoCount;
- UINTN DescriptorSize;
- UINT32 PackageVersion;
- CHAR16 *PackageVersionName;
+ EFI_STATUS Status;
+ EFI_FIRMWARE_MANAGEMENT_PROTOCOL *Fmp;
+ EFI_FIRMWARE_MANAGEMENT_PROTOCOL *TargetFmp;
+ EFI_HANDLE *HandleBuffer;
+ UINTN NumberOfHandles;
+ UINTN Index;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *FmpImageInfoBuf;
+ UINTN ImageInfoSize;
+ UINT32 FmpImageInfoDescriptorVer;
+ UINT8 FmpImageInfoCount;
+ UINTN DescriptorSize;
+ UINT32 PackageVersion;
+ CHAR16 *PackageVersionName;
Status = gBS->LocateHandleBuffer (
ByProtocol,
@@ -1308,33 +1329,33 @@ FindFmpFromImageTypeId (
&NumberOfHandles,
&HandleBuffer
);
- if (EFI_ERROR(Status)) {
- Print(L"FMP protocol - %r\n", EFI_NOT_FOUND);
+ if (EFI_ERROR (Status)) {
+ Print (L"FMP protocol - %r\n", EFI_NOT_FOUND);
return NULL;
}
TargetFmp = NULL;
for (Index = 0; Index < NumberOfHandles; Index++) {
- Status = gBS->HandleProtocol(
+ Status = gBS->HandleProtocol (
HandleBuffer[Index],
&gEfiFirmwareManagementProtocolGuid,
(VOID **)&Fmp
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
continue;
}
ImageInfoSize = 0;
- Status = Fmp->GetImageInfo (
- Fmp,
- &ImageInfoSize,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL
- );
+ Status = Fmp->GetImageInfo (
+ Fmp,
+ &ImageInfoSize,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ );
if (Status != EFI_BUFFER_TOO_SMALL) {
continue;
}
@@ -1342,44 +1363,46 @@ FindFmpFromImageTypeId (
FmpImageInfoBuf = NULL;
FmpImageInfoBuf = AllocateZeroPool (ImageInfoSize);
if (FmpImageInfoBuf == NULL) {
- FreePool(HandleBuffer);
- Print(L"Out of resource\n");
+ FreePool (HandleBuffer);
+ Print (L"Out of resource\n");
return NULL;
}
PackageVersionName = NULL;
- Status = Fmp->GetImageInfo (
- Fmp,
- &ImageInfoSize, // ImageInfoSize
- FmpImageInfoBuf, // ImageInfo
- &FmpImageInfoDescriptorVer, // DescriptorVersion
- &FmpImageInfoCount, // DescriptorCount
- &DescriptorSize, // DescriptorSize
- &PackageVersion, // PackageVersion
- &PackageVersionName // PackageVersionName
- );
+ Status = Fmp->GetImageInfo (
+ Fmp,
+ &ImageInfoSize, // ImageInfoSize
+ FmpImageInfoBuf, // ImageInfo
+ &FmpImageInfoDescriptorVer, // DescriptorVersion
+ &FmpImageInfoCount, // DescriptorCount
+ &DescriptorSize, // DescriptorSize
+ &PackageVersion, // PackageVersion
+ &PackageVersionName // PackageVersionName
+ );
//
// If FMP GetInformation interface failed, skip this resource
//
- if (EFI_ERROR(Status)) {
- FreePool(FmpImageInfoBuf);
+ if (EFI_ERROR (Status)) {
+ FreePool (FmpImageInfoBuf);
continue;
}
if (PackageVersionName != NULL) {
- FreePool(PackageVersionName);
+ FreePool (PackageVersionName);
}
if (IsThisFmpImageInfo (FmpImageInfoBuf, FmpImageInfoCount, DescriptorSize, ImageTypeId)) {
TargetFmp = Fmp;
}
- FreePool(FmpImageInfoBuf);
+
+ FreePool (FmpImageInfoBuf);
if (TargetFmp != NULL) {
break;
}
}
- FreePool(HandleBuffer);
+
+ FreePool (HandleBuffer);
return TargetFmp;
}
@@ -1399,46 +1422,46 @@ DumpFmpImage (
IN CHAR16 *ImageName
)
{
- EFI_STATUS Status;
- EFI_FIRMWARE_MANAGEMENT_PROTOCOL *Fmp;
- VOID *Image;
- UINTN ImageSize;
+ EFI_STATUS Status;
+ EFI_FIRMWARE_MANAGEMENT_PROTOCOL *Fmp;
+ VOID *Image;
+ UINTN ImageSize;
Fmp = FindFmpFromImageTypeId (ImageTypeId);
if (Fmp == NULL) {
- Print(L"No FMP include ImageTypeId %g\n", ImageTypeId);
- return ;
+ Print (L"No FMP include ImageTypeId %g\n", ImageTypeId);
+ return;
}
if (ImageIndex > 0xFF) {
- Print(L"ImageIndex 0x%x too big\n", ImageIndex);
- return ;
+ Print (L"ImageIndex 0x%x too big\n", ImageIndex);
+ return;
}
- Image = Fmp;
+ Image = Fmp;
ImageSize = 0;
- Status = Fmp->GetImage (Fmp, (UINT8)ImageIndex, Image, &ImageSize);
+ Status = Fmp->GetImage (Fmp, (UINT8)ImageIndex, Image, &ImageSize);
if (Status != EFI_BUFFER_TOO_SMALL) {
- Print(L"Fmp->GetImage - %r\n", Status);
- return ;
+ Print (L"Fmp->GetImage - %r\n", Status);
+ return;
}
Image = AllocatePool (ImageSize);
if (Image == NULL) {
- Print(L"Allocate FmpImage 0x%x - %r\n", ImageSize, EFI_OUT_OF_RESOURCES);
- return ;
+ Print (L"Allocate FmpImage 0x%x - %r\n", ImageSize, EFI_OUT_OF_RESOURCES);
+ return;
}
Status = Fmp->GetImage (Fmp, (UINT8)ImageIndex, Image, &ImageSize);
- if (EFI_ERROR(Status)) {
- Print(L"Fmp->GetImage - %r\n", Status);
- return ;
+ if (EFI_ERROR (Status)) {
+ Print (L"Fmp->GetImage - %r\n", Status);
+ return;
}
- Status = WriteFileFromBuffer(ImageName, ImageSize, Image);
- Print(L"CapsuleApp: Dump %g ImageIndex (0x%x) to %s %r\n", ImageTypeId, ImageIndex, ImageName, Status);
+ Status = WriteFileFromBuffer (ImageName, ImageSize, Image);
+ Print (L"CapsuleApp: Dump %g ImageIndex (0x%x) to %s %r\n", ImageTypeId, ImageIndex, ImageName, Status);
FreePool (Image);
- return ;
+ return;
}
diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c b/MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c
index 77f9a1571f..5ce5a50f7b 100644
--- a/MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c
+++ b/MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c
@@ -8,7 +8,9 @@
#include "CapsuleApp.h"
-EFI_GUID mCapsuleOnDiskBootOptionGuid = { 0x4CC29BB7, 0x2413, 0x40A2, { 0xB0, 0x6D, 0x25, 0x3E, 0x37, 0x10, 0xF5, 0x32 } };
+EFI_GUID mCapsuleOnDiskBootOptionGuid = {
+ 0x4CC29BB7, 0x2413, 0x40A2, { 0xB0, 0x6D, 0x25, 0x3E, 0x37, 0x10, 0xF5, 0x32 }
+};
/**
Get file name from file path.
@@ -20,13 +22,13 @@ EFI_GUID mCapsuleOnDiskBootOptionGuid = { 0x4CC29BB7, 0x2413, 0x40A2, { 0xB0, 0x
**/
CHAR16 *
GetFileNameFromPath (
- CHAR16 *FilePath
+ CHAR16 *FilePath
)
{
- EFI_STATUS Status;
- EFI_SHELL_PROTOCOL *ShellProtocol;
- SHELL_FILE_HANDLE Handle;
- EFI_FILE_INFO *FileInfo;
+ EFI_STATUS Status;
+ EFI_SHELL_PROTOCOL *ShellProtocol;
+ SHELL_FILE_HANDLE Handle;
+ EFI_FILE_INFO *FileInfo;
ShellProtocol = GetShellProtocol ();
if (ShellProtocol == NULL) {
@@ -68,13 +70,13 @@ GetFileNameFromPath (
**/
BOOLEAN
IsEfiSysPartitionDevicePath (
- EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
- HARDDRIVE_DEVICE_PATH *Hd;
- EFI_HANDLE Handle;
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
+ HARDDRIVE_DEVICE_PATH *Hd;
+ EFI_HANDLE Handle;
//
// Check if the device path contains GPT node
@@ -83,12 +85,14 @@ IsEfiSysPartitionDevicePath (
while (!IsDevicePathEnd (TempDevicePath)) {
if ((DevicePathType (TempDevicePath) == MEDIA_DEVICE_PATH) &&
- (DevicePathSubType (TempDevicePath) == MEDIA_HARDDRIVE_DP)) {
+ (DevicePathSubType (TempDevicePath) == MEDIA_HARDDRIVE_DP))
+ {
Hd = (HARDDRIVE_DEVICE_PATH *)TempDevicePath;
if (Hd->MBRType == MBR_TYPE_EFI_PARTITION_TABLE_HEADER) {
break;
}
}
+
TempDevicePath = NextDevicePathNode (TempDevicePath);
}
@@ -112,19 +116,19 @@ DumpAllEfiSysPartition (
VOID
)
{
- EFI_HANDLE *SimpleFileSystemHandles;
- UINTN NumberSimpleFileSystemHandles;
- UINTN Index;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- UINTN NumberEfiSystemPartitions;
- EFI_SHELL_PROTOCOL *ShellProtocol;
+ EFI_HANDLE *SimpleFileSystemHandles;
+ UINTN NumberSimpleFileSystemHandles;
+ UINTN Index;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ UINTN NumberEfiSystemPartitions;
+ EFI_SHELL_PROTOCOL *ShellProtocol;
NumberEfiSystemPartitions = 0;
ShellProtocol = GetShellProtocol ();
if (ShellProtocol == NULL) {
- Print (L"Get Shell Protocol Fail\n");;
- return ;
+ Print (L"Get Shell Protocol Fail\n");
+ return;
}
Print (L"EFI System Partition list:\n");
@@ -141,12 +145,12 @@ DumpAllEfiSysPartition (
DevicePath = DevicePathFromHandle (SimpleFileSystemHandles[Index]);
if (IsEfiSysPartitionDevicePath (DevicePath)) {
NumberEfiSystemPartitions++;
- Print(L" %s\n %s\n", ShellProtocol->GetMapFromDevicePath (&DevicePath), ConvertDevicePathToText (DevicePath, TRUE, TRUE));
+ Print (L" %s\n %s\n", ShellProtocol->GetMapFromDevicePath (&DevicePath), ConvertDevicePathToText (DevicePath, TRUE, TRUE));
}
}
if (NumberEfiSystemPartitions == 0) {
- Print(L" No ESP found.\n");
+ Print (L" No ESP found.\n");
}
}
@@ -162,21 +166,22 @@ IsCapsuleProvisioned (
VOID
)
{
- EFI_STATUS Status;
- UINT64 OsIndication;
- UINTN DataSize;
+ EFI_STATUS Status;
+ UINT64 OsIndication;
+ UINTN DataSize;
OsIndication = 0;
- DataSize = sizeof(UINT64);
- Status = gRT->GetVariable (
- L"OsIndications",
- &gEfiGlobalVariableGuid,
- NULL,
- &DataSize,
- &OsIndication
- );
+ DataSize = sizeof (UINT64);
+ Status = gRT->GetVariable (
+ L"OsIndications",
+ &gEfiGlobalVariableGuid,
+ NULL,
+ &DataSize,
+ &OsIndication
+ );
if (!EFI_ERROR (Status) &&
- (OsIndication & EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED) != 0) {
+ ((OsIndication & EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED) != 0))
+ {
return TRUE;
}
@@ -199,11 +204,11 @@ GetEfiSysPartition (
OUT EFI_SIMPLE_FILE_SYSTEM_PROTOCOL **Fs
)
{
- EFI_HANDLE *SimpleFileSystemHandles;
- UINTN NumberSimpleFileSystemHandles;
- UINTN Index;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_STATUS Status;
+ EFI_HANDLE *SimpleFileSystemHandles;
+ UINTN NumberSimpleFileSystemHandles;
+ UINTN Index;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_STATUS Status;
Status = gBS->LocateHandleBuffer (
ByProtocol,
@@ -245,15 +250,15 @@ GetEfiSysPartition (
**/
EFI_STATUS
GetEfiSysPartitionFromDevPath (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- OUT EFI_DEVICE_PATH_PROTOCOL **FsDevicePath,
- OUT EFI_SIMPLE_FILE_SYSTEM_PROTOCOL **Fs
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ OUT EFI_DEVICE_PATH_PROTOCOL **FsDevicePath,
+ OUT EFI_SIMPLE_FILE_SYSTEM_PROTOCOL **Fs
)
{
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
- HARDDRIVE_DEVICE_PATH *Hd;
- EFI_HANDLE Handle;
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
+ HARDDRIVE_DEVICE_PATH *Hd;
+ EFI_HANDLE Handle;
//
// Check if the device path contains GPT node
@@ -261,12 +266,14 @@ GetEfiSysPartitionFromDevPath (
TempDevicePath = DevicePath;
while (!IsDevicePathEnd (TempDevicePath)) {
if ((DevicePathType (TempDevicePath) == MEDIA_DEVICE_PATH) &&
- (DevicePathSubType (TempDevicePath) == MEDIA_HARDDRIVE_DP)) {
+ (DevicePathSubType (TempDevicePath) == MEDIA_HARDDRIVE_DP))
+ {
Hd = (HARDDRIVE_DEVICE_PATH *)TempDevicePath;
if (Hd->MBRType == MBR_TYPE_EFI_PARTITION_TABLE_HEADER) {
break;
}
}
+
TempDevicePath = NextDevicePathNode (TempDevicePath);
}
@@ -310,13 +317,13 @@ GetEfiSysPartitionFromBootOptionFilePath (
OUT EFI_SIMPLE_FILE_SYSTEM_PROTOCOL **Fs
)
{
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *CurFullPath;
- EFI_DEVICE_PATH_PROTOCOL *PreFullPath;
- EFI_DEVICE_PATH_PROTOCOL *FsFullPath;
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL *CurFullPath;
+ EFI_DEVICE_PATH_PROTOCOL *PreFullPath;
+ EFI_DEVICE_PATH_PROTOCOL *FsFullPath;
CurFullPath = NULL;
- FsFullPath = NULL;
+ FsFullPath = NULL;
//
// Try every full device Path generated from bootoption
//
@@ -337,13 +344,14 @@ GetEfiSysPartitionFromBootOptionFilePath (
}
DEBUG_CODE_BEGIN ();
- CHAR16 *DevicePathStr;
+ CHAR16 *DevicePathStr;
+
+ DevicePathStr = ConvertDevicePathToText (CurFullPath, TRUE, TRUE);
+ if (DevicePathStr != NULL) {
+ DEBUG ((DEBUG_INFO, "Full device path %s\n", DevicePathStr));
+ FreePool (DevicePathStr);
+ }
- DevicePathStr = ConvertDevicePathToText (CurFullPath, TRUE, TRUE);
- if (DevicePathStr != NULL){
- DEBUG ((DEBUG_INFO, "Full device path %s\n", DevicePathStr));
- FreePool (DevicePathStr);
- }
DEBUG_CODE_END ();
Status = GetEfiSysPartitionFromDevPath (CurFullPath, &FsFullPath, Fs);
@@ -376,7 +384,7 @@ GetUpdateFileSystem (
OUT UINT16 *BootNext,
OUT EFI_SIMPLE_FILE_SYSTEM_PROTOCOL **Fs,
OUT BOOLEAN *UpdateBootNext
-)
+ )
{
EFI_STATUS Status;
CHAR16 BootOptionName[20];
@@ -396,7 +404,7 @@ GetUpdateFileSystem (
ShellProtocol = GetShellProtocol ();
if (ShellProtocol == NULL) {
- Print (L"Get Shell Protocol Fail\n");;
+ Print (L"Get Shell Protocol Fail\n");
return EFI_NOT_FOUND;
}
@@ -404,14 +412,14 @@ GetUpdateFileSystem (
// 1. If Fs is not assigned and there are capsule provisioned before,
// Get EFI system partition from BootNext.
//
- if (IsCapsuleProvisioned () && Map == NULL) {
+ if (IsCapsuleProvisioned () && (Map == NULL)) {
Status = GetVariable2 (
L"BootNext",
&gEfiGlobalVariableGuid,
(VOID **)&BootNextData,
NULL
);
- if (EFI_ERROR (Status) || BootNextData == NULL) {
+ if (EFI_ERROR (Status) || (BootNextData == NULL)) {
Print (L"Get Boot Next Data Fail. Status = %r\n", Status);
return EFI_NOT_FOUND;
} else {
@@ -419,11 +427,11 @@ GetUpdateFileSystem (
Status = EfiBootManagerVariableToLoadOption (BootOptionName, &BootNextOption);
if (!EFI_ERROR (Status)) {
DevicePath = BootNextOption.FilePath;
- Status = GetEfiSysPartitionFromBootOptionFilePath (DevicePath, &FullPath, Fs);
+ Status = GetEfiSysPartitionFromBootOptionFilePath (DevicePath, &FullPath, Fs);
if (!EFI_ERROR (Status)) {
*UpdateBootNext = FALSE;
- Print(L"Get EFI system partition from BootNext : %s\n", BootNextOption.Description);
- Print(L"%s %s\n", ShellProtocol->GetMapFromDevicePath (&FullPath), ConvertDevicePathToText (FullPath, TRUE, TRUE));
+ Print (L"Get EFI system partition from BootNext : %s\n", BootNextOption.Description);
+ Print (L"%s %s\n", ShellProtocol->GetMapFromDevicePath (&FullPath), ConvertDevicePathToText (FullPath, TRUE, TRUE));
return EFI_SUCCESS;
}
}
@@ -436,10 +444,10 @@ GetUpdateFileSystem (
if (Map != NULL) {
MappedDevicePath = ShellProtocol->GetDevicePathFromMap (Map);
if (MappedDevicePath == NULL) {
- Print(L"'%s' is not a valid mapping.\n", Map);
+ Print (L"'%s' is not a valid mapping.\n", Map);
return EFI_INVALID_PARAMETER;
} else if (!IsEfiSysPartitionDevicePath (DuplicateDevicePath (MappedDevicePath))) {
- Print(L"'%s' is not a EFI System Partition.\n", Map);
+ Print (L"'%s' is not a EFI System Partition.\n", Map);
return EFI_INVALID_PARAMETER;
}
}
@@ -448,9 +456,10 @@ GetUpdateFileSystem (
// 2. Get EFI system partition form boot options.
//
BootOptionBuffer = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);
- if ( (BootOptionBuffer == NULL) ||
- (BootOptionCount == 0 && Map == NULL)
- ) {
+ if ((BootOptionBuffer == NULL) ||
+ ((BootOptionCount == 0) && (Map == NULL))
+ )
+ {
return EFI_NOT_FOUND;
}
@@ -458,32 +467,34 @@ GetUpdateFileSystem (
//
// Get the boot option from the link list
//
- DevicePath = BootOptionBuffer[Index].FilePath;
+ DevicePath = BootOptionBuffer[Index].FilePath;
//
// Skip inactive or legacy boot options
//
- if ((BootOptionBuffer[Index].Attributes & LOAD_OPTION_ACTIVE) == 0 ||
- DevicePathType (DevicePath) == BBS_DEVICE_PATH) {
+ if (((BootOptionBuffer[Index].Attributes & LOAD_OPTION_ACTIVE) == 0) ||
+ (DevicePathType (DevicePath) == BBS_DEVICE_PATH))
+ {
continue;
}
DEBUG_CODE_BEGIN ();
- CHAR16 *DevicePathStr;
-
- DevicePathStr = ConvertDevicePathToText (DevicePath, TRUE, TRUE);
- if (DevicePathStr != NULL){
- DEBUG ((DEBUG_INFO, "Try BootOption %s\n", DevicePathStr));
- FreePool (DevicePathStr);
- } else {
- DEBUG ((DEBUG_INFO, "DevicePathToStr failed\n"));
- }
+ CHAR16 *DevicePathStr;
+
+ DevicePathStr = ConvertDevicePathToText (DevicePath, TRUE, TRUE);
+ if (DevicePathStr != NULL) {
+ DEBUG ((DEBUG_INFO, "Try BootOption %s\n", DevicePathStr));
+ FreePool (DevicePathStr);
+ } else {
+ DEBUG ((DEBUG_INFO, "DevicePathToStr failed\n"));
+ }
+
DEBUG_CODE_END ();
Status = GetEfiSysPartitionFromBootOptionFilePath (DevicePath, &FullPath, Fs);
if (!EFI_ERROR (Status)) {
if (Map == NULL) {
- *BootNext = (UINT16) BootOptionBuffer[Index].OptionNumber;
+ *BootNext = (UINT16)BootOptionBuffer[Index].OptionNumber;
*UpdateBootNext = TRUE;
Print (L"Found EFI system partition on Boot%04x: %s\n", *BootNext, BootOptionBuffer[Index].Description);
Print (L"%s %s\n", ShellProtocol->GetMapFromDevicePath (&FullPath), ConvertDevicePathToText (FullPath, TRUE, TRUE));
@@ -491,7 +502,7 @@ GetUpdateFileSystem (
}
if (StrnCmp (Map, ShellProtocol->GetMapFromDevicePath (&FullPath), StrLen (Map)) == 0) {
- *BootNext = (UINT16) BootOptionBuffer[Index].OptionNumber;
+ *BootNext = (UINT16)BootOptionBuffer[Index].OptionNumber;
*UpdateBootNext = TRUE;
Print (L"Found Boot Option on %s : %s\n", Map, BootOptionBuffer[Index].Description);
return EFI_SUCCESS;
@@ -507,11 +518,12 @@ GetUpdateFileSystem (
// If map is assigned, try to get ESP from mapped Fs.
//
DevicePath = DuplicateDevicePath (MappedDevicePath);
- Status = GetEfiSysPartitionFromDevPath (DevicePath, &FullPath, Fs);
+ Status = GetEfiSysPartitionFromDevPath (DevicePath, &FullPath, Fs);
if (EFI_ERROR (Status)) {
Print (L"Error: Cannot get EFI system partition from '%s' - %r\n", Map, Status);
return EFI_NOT_FOUND;
}
+
Print (L"Warning: Cannot find Boot Option on '%s'!\n", Map);
} else {
Status = GetEfiSysPartition (&DevicePath, Fs);
@@ -529,15 +541,16 @@ GetUpdateFileSystem (
LOAD_OPTION_ACTIVE,
L"UEFI Capsule On Disk",
DevicePath,
- (UINT8 *) &mCapsuleOnDiskBootOptionGuid,
- sizeof(EFI_GUID)
+ (UINT8 *)&mCapsuleOnDiskBootOptionGuid,
+ sizeof (EFI_GUID)
);
if (!EFI_ERROR (Status)) {
- Status = EfiBootManagerAddLoadOptionVariable (&NewOption, (UINTN) -1); {
+ Status = EfiBootManagerAddLoadOptionVariable (&NewOption, (UINTN)-1);
+ {
if (!EFI_ERROR (Status)) {
*UpdateBootNext = TRUE;
- *BootNext = (UINT16) NewOption.OptionNumber;
- Print (L" Boot%04x: %s\n", *BootNext, ConvertDevicePathToText(DevicePath, TRUE, TRUE));
+ *BootNext = (UINT16)NewOption.OptionNumber;
+ Print (L" Boot%04x: %s\n", *BootNext, ConvertDevicePathToText (DevicePath, TRUE, TRUE));
return EFI_SUCCESS;
}
}
@@ -564,25 +577,25 @@ GetUpdateFileSystem (
**/
EFI_STATUS
WriteUpdateFile (
- IN VOID **Buffer,
- IN UINTN *BufferSize,
- IN CHAR16 **FileName,
- IN UINTN BufferNum,
- IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs
-)
+ IN VOID **Buffer,
+ IN UINTN *BufferSize,
+ IN CHAR16 **FileName,
+ IN UINTN BufferNum,
+ IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs
+ )
{
- EFI_STATUS Status;
- EFI_FILE *Root;
- EFI_FILE *FileHandle;
- EFI_FILE_PROTOCOL *DirHandle;
- UINT64 FileInfo;
- VOID *Filebuffer;
- UINTN FileSize;
- UINTN Index;
+ EFI_STATUS Status;
+ EFI_FILE *Root;
+ EFI_FILE *FileHandle;
+ EFI_FILE_PROTOCOL *DirHandle;
+ UINT64 FileInfo;
+ VOID *Filebuffer;
+ UINTN FileSize;
+ UINTN Index;
- DirHandle = NULL;
- FileHandle = NULL;
- Index = 0;
+ DirHandle = NULL;
+ FileHandle = NULL;
+ Index = 0;
//
// Open Root from SFS
@@ -600,15 +613,16 @@ WriteUpdateFile (
if (EFI_ERROR (Status)) {
Status = Root->Open (Root, &DirHandle, L"\\EFI", EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, EFI_FILE_DIRECTORY);
if (EFI_ERROR (Status)) {
- Print(L"Unable to create %s directory\n", L"\\EFI");
+ Print (L"Unable to create %s directory\n", L"\\EFI");
return EFI_NOT_FOUND;
}
}
- Status = Root->Open (Root, &DirHandle, EFI_CAPSULE_FILE_DIRECTORY, EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE , 0);
+
+ Status = Root->Open (Root, &DirHandle, EFI_CAPSULE_FILE_DIRECTORY, EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE, 0);
if (EFI_ERROR (Status)) {
Status = Root->Open (Root, &DirHandle, EFI_CAPSULE_FILE_DIRECTORY, EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, EFI_FILE_DIRECTORY);
if (EFI_ERROR (Status)) {
- Print(L"Unable to create %s directory\n", EFI_CAPSULE_FILE_DIRECTORY);
+ Print (L"Unable to create %s directory\n", EFI_CAPSULE_FILE_DIRECTORY);
return EFI_NOT_FOUND;
}
}
@@ -643,7 +657,7 @@ WriteUpdateFile (
// Set the file size to 0.
//
FileInfo = 0;
- Status = FileHandleSetSize (FileHandle, FileInfo);
+ Status = FileHandleSetSize (FileHandle, FileInfo);
if (EFI_ERROR (Status)) {
Print (L"Error Deleting %s\n", FileName[Index]);
FileHandleClose (FileHandle);
@@ -655,8 +669,8 @@ WriteUpdateFile (
// Write Filebuffer to file
//
Filebuffer = Buffer[Index];
- FileSize = BufferSize[Index];
- Status = FileHandleWrite (FileHandle, &FileSize, Filebuffer);
+ FileSize = BufferSize[Index];
+ Status = FileHandleWrite (FileHandle, &FileSize, Filebuffer);
if (EFI_ERROR (Status)) {
Print (L"Unable to write Capsule Update to %s, Status = %r\n", FileName[Index], Status);
return EFI_NOT_FOUND;
@@ -680,36 +694,37 @@ WriteUpdateFile (
**/
EFI_STATUS
SetCapsuleStatusVariable (
- BOOLEAN SetCap
+ BOOLEAN SetCap
)
{
- EFI_STATUS Status;
- UINT64 OsIndication;
- UINTN DataSize;
+ EFI_STATUS Status;
+ UINT64 OsIndication;
+ UINTN DataSize;
OsIndication = 0;
- DataSize = sizeof(UINT64);
- Status = gRT->GetVariable (
- L"OsIndications",
- &gEfiGlobalVariableGuid,
- NULL,
- &DataSize,
- &OsIndication
- );
+ DataSize = sizeof (UINT64);
+ Status = gRT->GetVariable (
+ L"OsIndications",
+ &gEfiGlobalVariableGuid,
+ NULL,
+ &DataSize,
+ &OsIndication
+ );
if (EFI_ERROR (Status)) {
OsIndication = 0;
}
+
if (SetCap) {
OsIndication |= ((UINT64)EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED);
- }
- else {
+ } else {
OsIndication &= ~((UINT64)EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED);
}
+
Status = gRT->SetVariable (
L"OsIndications",
&gEfiGlobalVariableGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
- sizeof(UINT64),
+ sizeof (UINT64),
&OsIndication
);
@@ -728,18 +743,18 @@ IsCapsuleOnDiskSupported (
VOID
)
{
- EFI_STATUS Status;
- UINT64 OsIndicationsSupported;
- UINTN DataSize;
-
- DataSize = sizeof(UINT64);
- Status = gRT->GetVariable (
- L"OsIndicationsSupported",
- &gEfiGlobalVariableGuid,
- NULL,
- &DataSize,
- &OsIndicationsSupported
- );
+ 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;
}
@@ -766,19 +781,19 @@ IsCapsuleOnDiskSupported (
**/
EFI_STATUS
ProcessCapsuleOnDisk (
- IN VOID **CapsuleBuffer,
- IN UINTN *CapsuleBufferSize,
- IN CHAR16 **FilePath,
- IN CHAR16 *Map,
- IN UINTN CapsuleNum
+ IN VOID **CapsuleBuffer,
+ IN UINTN *CapsuleBufferSize,
+ IN CHAR16 **FilePath,
+ IN CHAR16 *Map,
+ IN UINTN CapsuleNum
)
{
- EFI_STATUS Status;
- UINT16 BootNext;
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs;
- BOOLEAN UpdateBootNext;
- CHAR16 *FileName[MAX_CAPSULE_NUM];
- UINTN Index;
+ EFI_STATUS Status;
+ UINT16 BootNext;
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs;
+ BOOLEAN UpdateBootNext;
+ CHAR16 *FileName[MAX_CAPSULE_NUM];
+ UINTN Index;
//
// Check if Capsule On Disk is supported
@@ -802,7 +817,7 @@ ProcessCapsuleOnDisk (
//
// Get file name from file path
//
- for (Index = 0; Index < CapsuleNum; Index ++) {
+ for (Index = 0; Index < CapsuleNum; Index++) {
FileName[Index] = GetFileNameFromPath (FilePath[Index]);
}
@@ -826,13 +841,13 @@ ProcessCapsuleOnDisk (
if (UpdateBootNext) {
Status = gRT->SetVariable (
- L"BootNext",
- &gEfiGlobalVariableGuid,
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
- sizeof(UINT16),
- &BootNext
- );
- if (EFI_ERROR (Status)){
+ L"BootNext",
+ &gEfiGlobalVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+ sizeof (UINT16),
+ &BootNext
+ );
+ if (EFI_ERROR (Status)) {
Print (L"CapsuleApp: unable to set BootNext variable.\n");
return Status;
}