OvmfPkg: Apply uncrustify changes

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737

Apply uncrustify changes to .c/.h files in the OvmfPkg 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: Andrew Fish <afish@apple.com>
This commit is contained in:
Michael Kubacki
2021-12-05 14:54:09 -08:00
committed by mergify[bot]
parent d1050b9dff
commit ac0a286f4d
445 changed files with 30894 additions and 26369 deletions

View File

@@ -27,31 +27,31 @@
#pragma pack (1)
typedef struct {
EFI_DEVICE_PATH_PROTOCOL FilePathHeader;
CHAR16 FilePath[ARRAY_SIZE (L"kernel")];
EFI_DEVICE_PATH_PROTOCOL FilePathHeader;
CHAR16 FilePath[ARRAY_SIZE (L"kernel")];
} KERNEL_FILE_DEVPATH;
typedef struct {
VENDOR_DEVICE_PATH VenMediaNode;
KERNEL_FILE_DEVPATH FileNode;
EFI_DEVICE_PATH_PROTOCOL EndNode;
VENDOR_DEVICE_PATH VenMediaNode;
KERNEL_FILE_DEVPATH FileNode;
EFI_DEVICE_PATH_PROTOCOL EndNode;
} KERNEL_VENMEDIA_FILE_DEVPATH;
#pragma pack ()
STATIC CONST KERNEL_VENMEDIA_FILE_DEVPATH mKernelDevicePath = {
STATIC CONST KERNEL_VENMEDIA_FILE_DEVPATH mKernelDevicePath = {
{
{
MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP,
{ sizeof (VENDOR_DEVICE_PATH) }
{ sizeof (VENDOR_DEVICE_PATH) }
},
QEMU_KERNEL_LOADER_FS_MEDIA_GUID
}, {
}, {
{
MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP,
{ sizeof (KERNEL_FILE_DEVPATH) }
{ sizeof (KERNEL_FILE_DEVPATH) }
},
L"kernel",
}, {
}, {
END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE,
{ sizeof (EFI_DEVICE_PATH_PROTOCOL) }
}
@@ -60,37 +60,48 @@ STATIC CONST KERNEL_VENMEDIA_FILE_DEVPATH mKernelDevicePath = {
STATIC
VOID
FreeLegacyImage (
IN OVMF_LOADED_X86_LINUX_KERNEL *LoadedImage
IN OVMF_LOADED_X86_LINUX_KERNEL *LoadedImage
)
{
if (LoadedImage->SetupBuf != NULL) {
FreePages (LoadedImage->SetupBuf,
EFI_SIZE_TO_PAGES (LoadedImage->SetupSize));
FreePages (
LoadedImage->SetupBuf,
EFI_SIZE_TO_PAGES (LoadedImage->SetupSize)
);
}
if (LoadedImage->KernelBuf != NULL) {
FreePages (LoadedImage->KernelBuf,
EFI_SIZE_TO_PAGES (LoadedImage->KernelInitialSize));
FreePages (
LoadedImage->KernelBuf,
EFI_SIZE_TO_PAGES (LoadedImage->KernelInitialSize)
);
}
if (LoadedImage->CommandLine != NULL) {
FreePages (LoadedImage->CommandLine,
EFI_SIZE_TO_PAGES (LoadedImage->CommandLineSize));
FreePages (
LoadedImage->CommandLine,
EFI_SIZE_TO_PAGES (LoadedImage->CommandLineSize)
);
}
if (LoadedImage->InitrdData != NULL) {
FreePages (LoadedImage->InitrdData,
EFI_SIZE_TO_PAGES (LoadedImage->InitrdSize));
FreePages (
LoadedImage->InitrdData,
EFI_SIZE_TO_PAGES (LoadedImage->InitrdSize)
);
}
}
STATIC
EFI_STATUS
QemuLoadLegacyImage (
OUT EFI_HANDLE *ImageHandle
OUT EFI_HANDLE *ImageHandle
)
{
EFI_STATUS Status;
UINTN KernelSize;
UINTN SetupSize;
OVMF_LOADED_X86_LINUX_KERNEL *LoadedImage;
EFI_STATUS Status;
UINTN KernelSize;
UINTN SetupSize;
OVMF_LOADED_X86_LINUX_KERNEL *LoadedImage;
QemuFwCfgSelectItem (QemuFwCfgItemKernelSize);
KernelSize = (UINTN)QemuFwCfgRead32 ();
@@ -98,7 +109,7 @@ QemuLoadLegacyImage (
QemuFwCfgSelectItem (QemuFwCfgItemKernelSetupSize);
SetupSize = (UINTN)QemuFwCfgRead32 ();
if (KernelSize == 0 || SetupSize == 0) {
if ((KernelSize == 0) || (SetupSize == 0)) {
DEBUG ((DEBUG_INFO, "qemu -kernel was not used.\n"));
return EFI_NOT_FOUND;
}
@@ -109,8 +120,9 @@ QemuLoadLegacyImage (
}
LoadedImage->SetupSize = SetupSize;
LoadedImage->SetupBuf = LoadLinuxAllocateKernelSetupPages (
EFI_SIZE_TO_PAGES (LoadedImage->SetupSize));
LoadedImage->SetupBuf = LoadLinuxAllocateKernelSetupPages (
EFI_SIZE_TO_PAGES (LoadedImage->SetupSize)
);
if (LoadedImage->SetupBuf == NULL) {
DEBUG ((DEBUG_ERROR, "Unable to allocate memory for kernel setup!\n"));
Status = EFI_OUT_OF_RESOURCES;
@@ -123,8 +135,10 @@ QemuLoadLegacyImage (
QemuFwCfgReadBytes (LoadedImage->SetupSize, LoadedImage->SetupBuf);
DEBUG ((DEBUG_INFO, " [done]\n"));
Status = LoadLinuxCheckKernelSetup (LoadedImage->SetupBuf,
LoadedImage->SetupSize);
Status = LoadLinuxCheckKernelSetup (
LoadedImage->SetupBuf,
LoadedImage->SetupSize
);
if (EFI_ERROR (Status)) {
goto FreeImage;
}
@@ -135,7 +149,9 @@ QemuLoadLegacyImage (
}
LoadedImage->KernelInitialSize = LoadLinuxGetKernelSize (
LoadedImage->SetupBuf, KernelSize);
LoadedImage->SetupBuf,
KernelSize
);
if (LoadedImage->KernelInitialSize == 0) {
Status = EFI_UNSUPPORTED;
goto FreeImage;
@@ -163,18 +179,23 @@ QemuLoadLegacyImage (
if (LoadedImage->CommandLineSize > 0) {
LoadedImage->CommandLine = LoadLinuxAllocateCommandLinePages (
EFI_SIZE_TO_PAGES (
LoadedImage->CommandLineSize));
LoadedImage->CommandLineSize
)
);
if (LoadedImage->CommandLine == NULL) {
DEBUG ((DEBUG_ERROR, "Unable to allocate memory for kernel command line!\n"));
Status = EFI_OUT_OF_RESOURCES;
goto FreeImage;
}
QemuFwCfgSelectItem (QemuFwCfgItemCommandLineData);
QemuFwCfgReadBytes (LoadedImage->CommandLineSize, LoadedImage->CommandLine);
}
Status = LoadLinuxSetCommandLine (LoadedImage->SetupBuf,
LoadedImage->CommandLine);
Status = LoadLinuxSetCommandLine (
LoadedImage->SetupBuf,
LoadedImage->CommandLine
);
if (EFI_ERROR (Status)) {
goto FreeImage;
}
@@ -185,33 +206,45 @@ QemuLoadLegacyImage (
if (LoadedImage->InitrdSize > 0) {
LoadedImage->InitrdData = LoadLinuxAllocateInitrdPages (
LoadedImage->SetupBuf,
EFI_SIZE_TO_PAGES (LoadedImage->InitrdSize));
EFI_SIZE_TO_PAGES (LoadedImage->InitrdSize)
);
if (LoadedImage->InitrdData == NULL) {
DEBUG ((DEBUG_ERROR, "Unable to allocate memory for initrd!\n"));
Status = EFI_OUT_OF_RESOURCES;
goto FreeImage;
}
DEBUG ((DEBUG_INFO, "Initrd size: 0x%x\n",
(UINT32)LoadedImage->InitrdSize));
DEBUG ((
DEBUG_INFO,
"Initrd size: 0x%x\n",
(UINT32)LoadedImage->InitrdSize
));
DEBUG ((DEBUG_INFO, "Reading initrd image ..."));
QemuFwCfgSelectItem (QemuFwCfgItemInitrdData);
QemuFwCfgReadBytes (LoadedImage->InitrdSize, LoadedImage->InitrdData);
DEBUG ((DEBUG_INFO, " [done]\n"));
}
Status = LoadLinuxSetInitrd (LoadedImage->SetupBuf, LoadedImage->InitrdData,
LoadedImage->InitrdSize);
Status = LoadLinuxSetInitrd (
LoadedImage->SetupBuf,
LoadedImage->InitrdData,
LoadedImage->InitrdSize
);
if (EFI_ERROR (Status)) {
goto FreeImage;
}
*ImageHandle = NULL;
Status = gBS->InstallProtocolInterface (ImageHandle,
&gOvmfLoadedX86LinuxKernelProtocolGuid, EFI_NATIVE_INTERFACE,
LoadedImage);
Status = gBS->InstallProtocolInterface (
ImageHandle,
&gOvmfLoadedX86LinuxKernelProtocolGuid,
EFI_NATIVE_INTERFACE,
LoadedImage
);
if (EFI_ERROR (Status)) {
goto FreeImage;
}
return EFI_SUCCESS;
FreeImage:
@@ -224,7 +257,7 @@ FreeImageDesc:
STATIC
EFI_STATUS
QemuStartLegacyImage (
IN EFI_HANDLE ImageHandle
IN EFI_HANDLE ImageHandle
)
{
EFI_STATUS Status;
@@ -248,7 +281,7 @@ QemuStartLegacyImage (
STATIC
EFI_STATUS
QemuUnloadLegacyImage (
IN EFI_HANDLE ImageHandle
IN EFI_HANDLE ImageHandle
)
{
EFI_STATUS Status;
@@ -266,8 +299,11 @@ QemuUnloadLegacyImage (
return EFI_INVALID_PARAMETER;
}
Status = gBS->UninstallProtocolInterface (ImageHandle,
&gOvmfLoadedX86LinuxKernelProtocolGuid, LoadedImage);
Status = gBS->UninstallProtocolInterface (
ImageHandle,
&gOvmfLoadedX86LinuxKernelProtocolGuid,
LoadedImage
);
ASSERT_EFI_ERROR (Status);
FreeLegacyImage (LoadedImage);
@@ -294,15 +330,15 @@ QemuUnloadLegacyImage (
EFI_STATUS
EFIAPI
QemuLoadKernelImage (
OUT EFI_HANDLE *ImageHandle
OUT EFI_HANDLE *ImageHandle
)
{
EFI_STATUS Status;
EFI_HANDLE KernelImageHandle;
EFI_LOADED_IMAGE_PROTOCOL *KernelLoadedImage;
UINTN CommandLineSize;
CHAR8 *CommandLine;
UINTN InitrdSize;
EFI_STATUS Status;
EFI_HANDLE KernelImageHandle;
EFI_LOADED_IMAGE_PROTOCOL *KernelLoadedImage;
UINTN CommandLineSize;
CHAR8 *CommandLine;
UINTN InitrdSize;
//
// Redundant assignment to work around GCC48/GCC49 limitations.
@@ -321,26 +357,26 @@ QemuLoadKernelImage (
&KernelImageHandle
);
switch (Status) {
case EFI_SUCCESS:
break;
case EFI_SUCCESS:
break;
case EFI_NOT_FOUND:
//
// The image does not exist - no -kernel image was supplied via the
// command line so no point in invoking the legacy fallback
//
return EFI_NOT_FOUND;
case EFI_NOT_FOUND:
//
// The image does not exist - no -kernel image was supplied via the
// command line so no point in invoking the legacy fallback
//
return EFI_NOT_FOUND;
case EFI_SECURITY_VIOLATION:
//
// Since the image has been loaded, we need to unload it before proceeding
// to the EFI_ACCESS_DENIED case below.
//
gBS->UnloadImage (KernelImageHandle);
case EFI_SECURITY_VIOLATION:
//
// Since the image has been loaded, we need to unload it before proceeding
// to the EFI_ACCESS_DENIED case below.
//
gBS->UnloadImage (KernelImageHandle);
//
// Fall through
//
case EFI_ACCESS_DENIED:
case EFI_ACCESS_DENIED:
//
// We are running with UEFI secure boot enabled, and the image failed to
// authenticate. For compatibility reasons, we fall back to the legacy
@@ -348,23 +384,28 @@ QemuLoadKernelImage (
//
// Fall through
//
case EFI_UNSUPPORTED:
//
// The image is not natively supported or cross-type supported. Let's try
// loading it using the loader that parses the bzImage metadata directly.
//
Status = QemuLoadLegacyImage (&KernelImageHandle);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: QemuLoadLegacyImage(): %r\n", __FUNCTION__,
Status));
return Status;
}
*ImageHandle = KernelImageHandle;
return EFI_SUCCESS;
case EFI_UNSUPPORTED:
//
// The image is not natively supported or cross-type supported. Let's try
// loading it using the loader that parses the bzImage metadata directly.
//
Status = QemuLoadLegacyImage (&KernelImageHandle);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
"%a: QemuLoadLegacyImage(): %r\n",
__FUNCTION__,
Status
));
return Status;
}
default:
DEBUG ((DEBUG_ERROR, "%a: LoadImage(): %r\n", __FUNCTION__, Status));
return Status;
*ImageHandle = KernelImageHandle;
return EFI_SUCCESS;
default:
DEBUG ((DEBUG_ERROR, "%a: LoadImage(): %r\n", __FUNCTION__, Status));
return Status;
}
//
@@ -399,8 +440,11 @@ QemuLoadKernelImage (
// Verify NUL-termination of the command line.
//
if (CommandLine[CommandLineSize - 1] != '\0') {
DEBUG ((DEBUG_ERROR, "%a: kernel command line is not NUL-terminated\n",
__FUNCTION__));
DEBUG ((
DEBUG_ERROR,
"%a: kernel command line is not NUL-terminated\n",
__FUNCTION__
));
Status = EFI_PROTOCOL_ERROR;
goto FreeCommandLine;
}
@@ -408,7 +452,7 @@ QemuLoadKernelImage (
//
// Drop the terminating NUL, convert to UTF-16.
//
KernelLoadedImage->LoadOptionsSize = (UINT32) ((CommandLineSize - 1) * 2);
KernelLoadedImage->LoadOptionsSize = (UINT32)((CommandLineSize - 1) * 2);
}
QemuFwCfgSelectItem (QemuFwCfgItemInitrdSize);
@@ -430,10 +474,11 @@ QemuLoadKernelImage (
KernelLoadedImage->LoadOptionsSize += 2;
KernelLoadedImage->LoadOptions = AllocatePool (
KernelLoadedImage->LoadOptionsSize);
KernelLoadedImage->LoadOptionsSize
);
if (KernelLoadedImage->LoadOptions == NULL) {
KernelLoadedImage->LoadOptionsSize = 0;
Status = EFI_OUT_OF_RESOURCES;
Status = EFI_OUT_OF_RESOURCES;
goto FreeCommandLine;
}
@@ -444,17 +489,22 @@ QemuLoadKernelImage (
(CommandLineSize == 0) ? "" : CommandLine,
(InitrdSize == 0) ? "" : " initrd=initrd"
);
DEBUG ((DEBUG_INFO, "%a: command line: \"%s\"\n", __FUNCTION__,
(CHAR16 *)KernelLoadedImage->LoadOptions));
DEBUG ((
DEBUG_INFO,
"%a: command line: \"%s\"\n",
__FUNCTION__,
(CHAR16 *)KernelLoadedImage->LoadOptions
));
}
*ImageHandle = KernelImageHandle;
Status = EFI_SUCCESS;
Status = EFI_SUCCESS;
FreeCommandLine:
if (CommandLineSize > 0) {
FreePool (CommandLine);
}
UnloadImage:
if (EFI_ERROR (Status)) {
gBS->UnloadImage (KernelImageHandle);
@@ -481,7 +531,7 @@ UnloadImage:
EFI_STATUS
EFIAPI
QemuStartKernelImage (
IN OUT EFI_HANDLE *ImageHandle
IN OUT EFI_HANDLE *ImageHandle
)
{
EFI_STATUS Status;
@@ -504,9 +554,9 @@ QemuStartKernelImage (
NULL, // ExitDataSize
NULL // ExitData
);
#ifdef MDE_CPU_IA32
#ifdef MDE_CPU_IA32
if (Status == EFI_UNSUPPORTED) {
EFI_HANDLE KernelImageHandle;
EFI_HANDLE KernelImageHandle;
//
// On IA32, EFI_UNSUPPORTED means that the image's machine type is X64 while
@@ -524,6 +574,7 @@ QemuStartKernelImage (
//
return Status;
}
//
// Swap in the legacy-loaded image.
//
@@ -531,7 +582,8 @@ QemuStartKernelImage (
*ImageHandle = KernelImageHandle;
return QemuStartLegacyImage (KernelImageHandle);
}
#endif
#endif
return Status;
}
@@ -551,11 +603,11 @@ QemuStartKernelImage (
EFI_STATUS
EFIAPI
QemuUnloadKernelImage (
IN EFI_HANDLE ImageHandle
IN EFI_HANDLE ImageHandle
)
{
EFI_LOADED_IMAGE_PROTOCOL *KernelLoadedImage;
EFI_STATUS Status;
EFI_LOADED_IMAGE_PROTOCOL *KernelLoadedImage;
EFI_STATUS Status;
Status = gBS->OpenProtocol (
ImageHandle,
@@ -588,6 +640,7 @@ QemuUnloadKernelImage (
FreePool (KernelLoadedImage->LoadOptions);
KernelLoadedImage->LoadOptions = NULL;
}
KernelLoadedImage->LoadOptionsSize = 0;
return gBS->UnloadImage (ImageHandle);