summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/Library
diff options
context:
space:
mode:
authorMichael Kubacki <michael.kubacki@microsoft.com>2021-12-05 14:54:09 -0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2021-12-07 17:24:28 +0000
commitac0a286f4d747a4c6c603a7b225917293cbe1e9f (patch)
tree32654f2b35755afc961e2c97296b2dec5762da75 /OvmfPkg/Library
parentd1050b9dff1cace252aff86630bfdb59dff5f507 (diff)
downloadedk2-ac0a286f4d747a4c6c603a7b225917293cbe1e9f.tar.gz
edk2-ac0a286f4d747a4c6c603a7b225917293cbe1e9f.tar.bz2
edk2-ac0a286f4d747a4c6c603a7b225917293cbe1e9f.zip
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>
Diffstat (limited to 'OvmfPkg/Library')
-rw-r--r--OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.c26
-rw-r--r--OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c22
-rw-r--r--OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.c32
-rw-r--r--OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c14
-rw-r--r--OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptSevLibInternal.c12
-rw-r--r--OvmfPkg/Library/BaseMemEncryptSevLib/Ia32/MemEncryptSevLib.c24
-rw-r--r--OvmfPkg/Library/BaseMemEncryptSevLib/PeiDxeMemEncryptSevLibInternal.c14
-rw-r--r--OvmfPkg/Library/BaseMemEncryptSevLib/PeiMemEncryptSevLibInternal.c16
-rw-r--r--OvmfPkg/Library/BaseMemEncryptSevLib/SecMemEncryptSevLibInternal.c14
-rw-r--r--OvmfPkg/Library/BaseMemEncryptSevLib/X64/MemEncryptSevLib.c25
-rw-r--r--OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c269
-rw-r--r--OvmfPkg/Library/BaseMemEncryptSevLib/X64/SecVirtualMemory.c22
-rw-r--r--OvmfPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.c34
-rw-r--r--OvmfPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.h37
-rw-r--r--OvmfPkg/Library/BasePciCapLib/BasePciCapLib.c368
-rw-r--r--OvmfPkg/Library/BasePciCapLib/BasePciCapLib.h22
-rw-r--r--OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.c78
-rw-r--r--OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.h16
-rw-r--r--OvmfPkg/Library/BhyveFwCtlLib/BhyveFwCtlLib.c188
-rw-r--r--OvmfPkg/Library/BlobVerifierLibNull/BlobVerifierNull.c6
-rw-r--r--OvmfPkg/Library/DxePciLibI440FxQ35/PciLib.c195
-rw-r--r--OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.c34
-rw-r--r--OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c170
-rw-r--r--OvmfPkg/Library/LoadLinuxLib/Linux.c527
-rw-r--r--OvmfPkg/Library/LoadLinuxLib/LinuxGdt.c47
-rw-r--r--OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.h13
-rw-r--r--OvmfPkg/Library/LockBoxLib/LockBoxDxe.c42
-rw-r--r--OvmfPkg/Library/LockBoxLib/LockBoxLib.c169
-rw-r--r--OvmfPkg/Library/LockBoxLib/LockBoxLib.h12
-rw-r--r--OvmfPkg/Library/NvVarsFileLib/FsAccess.c168
-rw-r--r--OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c10
-rw-r--r--OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.h6
-rw-r--r--OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c75
-rw-r--r--OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridge.h4
-rw-r--r--OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLib.c12
-rw-r--r--OvmfPkg/Library/PciHostBridgeLibScan/ScanForRootBridges.c207
-rw-r--r--OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c278
-rw-r--r--OvmfPkg/Library/PlatformBmPrintScLib/StatusCodeHandler.c176
-rw-r--r--OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c805
-rw-r--r--OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h33
-rw-r--r--OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c68
-rw-r--r--OvmfPkg/Library/PlatformBootManagerLib/QemuKernel.c21
-rw-r--r--OvmfPkg/Library/PlatformBootManagerLibBhyve/BdsPlatform.c744
-rw-r--r--OvmfPkg/Library/PlatformBootManagerLibBhyve/BdsPlatform.h33
-rw-r--r--OvmfPkg/Library/PlatformBootManagerLibBhyve/PlatformData.c56
-rw-r--r--OvmfPkg/Library/PlatformBootManagerLibGrub/BdsPlatform.c685
-rw-r--r--OvmfPkg/Library/PlatformBootManagerLibGrub/BdsPlatform.h33
-rw-r--r--OvmfPkg/Library/PlatformBootManagerLibGrub/PlatformData.c68
-rw-r--r--OvmfPkg/Library/PlatformBootManagerLibGrub/QemuKernel.c21
-rw-r--r--OvmfPkg/Library/PlatformDebugLibIoPort/DebugIoPortQemu.c2
-rw-r--r--OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c70
-rw-r--r--OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.c7
-rw-r--r--OvmfPkg/Library/PlatformFvbLibNull/PlatformFvbLibNull.c29
-rw-r--r--OvmfPkg/Library/PxeBcPcdProducerLib/PxeBcPcd.c22
-rw-r--r--OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.c110
-rw-r--r--OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.h10
-rw-r--r--OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c1054
-rw-r--r--OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c192
-rw-r--r--OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c62
-rw-r--r--OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h7
-rw-r--r--OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibMmio.c230
-rw-r--r--OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgNull.c22
-rw-r--r--OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c38
-rw-r--r--OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSec.c14
-rw-r--r--OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3Base.c8
-rw-r--r--OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3BasePei.c23
-rw-r--r--OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3Dxe.c441
-rw-r--r--OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3Pei.c6
-rw-r--r--OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3PeiDxe.c13
-rw-r--r--OvmfPkg/Library/QemuFwCfgSimpleParserLib/QemuFwCfgSimpleParser.c186
-rw-r--r--OvmfPkg/Library/ResetSystemLib/BaseResetShutdown.c24
-rw-r--r--OvmfPkg/Library/ResetSystemLib/DxeResetShutdown.c28
-rw-r--r--OvmfPkg/Library/ResetSystemLib/DxeResetSystemLibMicrovm.c7
-rw-r--r--OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c41
-rw-r--r--OvmfPkg/Library/ResetSystemLib/ResetSystemLibMicrovm.c74
-rw-r--r--OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.c366
-rw-r--r--OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.h13
-rw-r--r--OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.c113
-rw-r--r--OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c114
-rw-r--r--OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQemu.c14
-rw-r--r--OvmfPkg/Library/Tcg2PhysicalPresenceLibNull/DxeTcg2PhysicalPresenceLib.c2
-rw-r--r--OvmfPkg/Library/Tcg2PhysicalPresenceLibQemu/DxeTcg2PhysicalPresenceLib.c252
-rw-r--r--OvmfPkg/Library/TlsAuthConfigLib/TlsAuthConfigLib.c142
-rw-r--r--OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.c78
-rw-r--r--OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.h8
-rw-r--r--OvmfPkg/Library/VirtioLib/VirtioLib.c153
-rw-r--r--OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c117
-rw-r--r--OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h77
-rw-r--r--OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c167
-rw-r--r--OvmfPkg/Library/VmgExitLib/PeiDxeVmgExitVcHandler.c6
-rw-r--r--OvmfPkg/Library/VmgExitLib/SecVmgExitVcHandler.c6
-rw-r--r--OvmfPkg/Library/VmgExitLib/VmgExitLib.c51
-rw-r--r--OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c1193
-rw-r--r--OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c249
-rw-r--r--OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.c52
-rw-r--r--OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c18
-rw-r--r--OvmfPkg/Library/XenHypercallLib/XenHypercall.c45
-rw-r--r--OvmfPkg/Library/XenIoMmioLib/XenIoMmioLib.c93
-rw-r--r--OvmfPkg/Library/XenPlatformLib/XenPlatformLib.c11
-rw-r--r--OvmfPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.c62
100 files changed, 6640 insertions, 5433 deletions
diff --git a/OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.c b/OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.c
index 3d73111ced..13c6dcac1f 100644
--- a/OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.c
+++ b/OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.c
@@ -30,20 +30,20 @@
**/
VOID
InternalAcpiDelay (
- IN UINT32 Delay
+ IN UINT32 Delay
)
{
- UINT32 Ticks;
- UINT32 Times;
+ UINT32 Ticks;
+ UINT32 Times;
- Times = Delay >> 22;
- Delay &= BIT22 - 1;
+ Times = Delay >> 22;
+ Delay &= BIT22 - 1;
do {
//
// The target timer count is calculated here
//
- Ticks = InternalAcpiGetTimerTick () + Delay;
- Delay = BIT22;
+ Ticks = InternalAcpiGetTimerTick () + Delay;
+ Delay = BIT22;
//
// Wait until time out
// Delay >= 2^23 could not be handled by this function
@@ -68,7 +68,7 @@ InternalAcpiDelay (
UINTN
EFIAPI
MicroSecondDelay (
- IN UINTN MicroSeconds
+ IN UINTN MicroSeconds
)
{
InternalAcpiDelay (
@@ -96,7 +96,7 @@ MicroSecondDelay (
UINTN
EFIAPI
NanoSecondDelay (
- IN UINTN NanoSeconds
+ IN UINTN NanoSeconds
)
{
InternalAcpiDelay (
@@ -158,8 +158,8 @@ GetPerformanceCounter (
UINT64
EFIAPI
GetPerformanceCounterProperties (
- OUT UINT64 *StartValue OPTIONAL,
- OUT UINT64 *EndValue OPTIONAL
+ OUT UINT64 *StartValue OPTIONAL,
+ OUT UINT64 *EndValue OPTIONAL
)
{
if (StartValue != NULL) {
@@ -187,7 +187,7 @@ GetPerformanceCounterProperties (
UINT64
EFIAPI
GetTimeInNanoSecond (
- IN UINT64 Ticks
+ IN UINT64 Ticks
)
{
UINT64 NanoSeconds;
@@ -204,7 +204,7 @@ GetTimeInNanoSecond (
// Frequency < 0x100000000, so Remainder < 0x100000000, then (Remainder * 1,000,000,000)
// will not overflow 64-bit.
//
- NanoSeconds += DivU64x32 (MultU64x32 ((UINT64) Remainder, 1000000000u), ACPI_TIMER_FREQUENCY);
+ NanoSeconds += DivU64x32 (MultU64x32 ((UINT64)Remainder, 1000000000u), ACPI_TIMER_FREQUENCY);
return NanoSeconds;
}
diff --git a/OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c b/OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c
index 7c593e8be1..1d33c86313 100644
--- a/OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c
+++ b/OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c
@@ -14,7 +14,7 @@
//
// Cached ACPI Timer IO Address
//
-STATIC UINT32 mAcpiTimerIoAddr;
+STATIC UINT32 mAcpiTimerIoAddr;
/**
The constructor function caches the ACPI tick counter address, and,
@@ -29,12 +29,12 @@ AcpiTimerLibConstructor (
VOID
)
{
- UINT16 HostBridgeDevId;
- UINTN Pmba;
- UINT32 PmbaAndVal;
- UINT32 PmbaOrVal;
- UINTN AcpiCtlReg;
- UINT8 AcpiEnBit;
+ UINT16 HostBridgeDevId;
+ UINTN Pmba;
+ UINT32 PmbaAndVal;
+ UINT32 PmbaOrVal;
+ UINTN AcpiCtlReg;
+ UINT8 AcpiEnBit;
//
// Query Host Bridge DID to determine platform type
@@ -56,8 +56,12 @@ AcpiTimerLibConstructor (
AcpiEnBit = ICH9_ACPI_CNTL_ACPI_EN;
break;
default:
- DEBUG ((DEBUG_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n",
- __FUNCTION__, HostBridgeDevId));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Unknown Host Bridge Device ID: 0x%04x\n",
+ __FUNCTION__,
+ HostBridgeDevId
+ ));
ASSERT (FALSE);
return RETURN_UNSUPPORTED;
}
diff --git a/OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.c b/OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.c
index 52f3ea2dbf..54a288d52f 100644
--- a/OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.c
+++ b/OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.c
@@ -27,12 +27,12 @@ AcpiTimerLibConstructor (
VOID
)
{
- UINT16 HostBridgeDevId;
- UINTN Pmba;
- UINT32 PmbaAndVal;
- UINT32 PmbaOrVal;
- UINTN AcpiCtlReg;
- UINT8 AcpiEnBit;
+ UINT16 HostBridgeDevId;
+ UINTN Pmba;
+ UINT32 PmbaAndVal;
+ UINT32 PmbaOrVal;
+ UINTN AcpiCtlReg;
+ UINT8 AcpiEnBit;
//
// Query Host Bridge DID to determine platform type
@@ -54,8 +54,12 @@ AcpiTimerLibConstructor (
AcpiEnBit = ICH9_ACPI_CNTL_ACPI_EN;
break;
default:
- DEBUG ((DEBUG_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n",
- __FUNCTION__, HostBridgeDevId));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Unknown Host Bridge Device ID: 0x%04x\n",
+ __FUNCTION__,
+ HostBridgeDevId
+ ));
ASSERT (FALSE);
return RETURN_UNSUPPORTED;
}
@@ -93,8 +97,8 @@ InternalAcpiGetTimerTick (
VOID
)
{
- UINT16 HostBridgeDevId;
- UINTN Pmba;
+ UINT16 HostBridgeDevId;
+ UINTN Pmba;
//
// Query Host Bridge DID to determine platform type
@@ -108,8 +112,12 @@ InternalAcpiGetTimerTick (
Pmba = POWER_MGMT_REGISTER_Q35 (ICH9_PMBASE);
break;
default:
- DEBUG ((DEBUG_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n",
- __FUNCTION__, HostBridgeDevId));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Unknown Host Bridge Device ID: 0x%04x\n",
+ __FUNCTION__,
+ HostBridgeDevId
+ ));
ASSERT (FALSE);
return 0;
}
diff --git a/OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c b/OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c
index 09076c0ade..01f28b2916 100644
--- a/OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c
+++ b/OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c
@@ -15,7 +15,7 @@
//
// Cached ACPI Timer IO Address
//
-STATIC UINT32 mAcpiTimerIoAddr;
+STATIC UINT32 mAcpiTimerIoAddr;
/**
The constructor function caches the ACPI tick counter address
@@ -36,8 +36,8 @@ AcpiTimerLibConstructor (
VOID
)
{
- UINT16 HostBridgeDevId;
- UINTN Pmba;
+ UINT16 HostBridgeDevId;
+ UINTN Pmba;
//
// Query Host Bridge DID to determine platform type
@@ -51,8 +51,12 @@ AcpiTimerLibConstructor (
Pmba = POWER_MGMT_REGISTER_Q35 (ICH9_PMBASE);
break;
default:
- DEBUG ((DEBUG_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n",
- __FUNCTION__, HostBridgeDevId));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Unknown Host Bridge Device ID: 0x%04x\n",
+ __FUNCTION__,
+ HostBridgeDevId
+ ));
ASSERT (FALSE);
return RETURN_UNSUPPORTED;
}
diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptSevLibInternal.c b/OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptSevLibInternal.c
index 2816f859a0..4fee7b2ab3 100644
--- a/OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptSevLibInternal.c
+++ b/OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptSevLibInternal.c
@@ -17,12 +17,12 @@
#include <Register/Cpuid.h>
#include <Uefi/UefiBaseType.h>
-STATIC BOOLEAN mSevStatus = FALSE;
-STATIC BOOLEAN mSevEsStatus = FALSE;
-STATIC BOOLEAN mSevStatusChecked = FALSE;
+STATIC BOOLEAN mSevStatus = FALSE;
+STATIC BOOLEAN mSevEsStatus = FALSE;
+STATIC BOOLEAN mSevStatusChecked = FALSE;
-STATIC UINT64 mSevEncryptionMask = 0;
-STATIC BOOLEAN mSevEncryptionMaskSaved = FALSE;
+STATIC UINT64 mSevEncryptionMask = 0;
+STATIC BOOLEAN mSevEncryptionMaskSaved = FALSE;
/**
Reads and sets the status of SEV features.
@@ -137,7 +137,7 @@ MemEncryptSevGetEncryptionMask (
)
{
if (!mSevEncryptionMaskSaved) {
- mSevEncryptionMask = PcdGet64 (PcdPteMemoryEncryptionAddressOrMask);
+ mSevEncryptionMask = PcdGet64 (PcdPteMemoryEncryptionAddressOrMask);
mSevEncryptionMaskSaved = TRUE;
}
diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/Ia32/MemEncryptSevLib.c b/OvmfPkg/Library/BaseMemEncryptSevLib/Ia32/MemEncryptSevLib.c
index be260e0d10..9bd66301fc 100644
--- a/OvmfPkg/Library/BaseMemEncryptSevLib/Ia32/MemEncryptSevLib.c
+++ b/OvmfPkg/Library/BaseMemEncryptSevLib/Ia32/MemEncryptSevLib.c
@@ -35,9 +35,9 @@
RETURN_STATUS
EFIAPI
MemEncryptSevClearPageEncMask (
- IN PHYSICAL_ADDRESS Cr3BaseAddress,
- IN PHYSICAL_ADDRESS BaseAddress,
- IN UINTN NumPages
+ IN PHYSICAL_ADDRESS Cr3BaseAddress,
+ IN PHYSICAL_ADDRESS BaseAddress,
+ IN UINTN NumPages
)
{
//
@@ -66,9 +66,9 @@ MemEncryptSevClearPageEncMask (
RETURN_STATUS
EFIAPI
MemEncryptSevSetPageEncMask (
- IN PHYSICAL_ADDRESS Cr3BaseAddress,
- IN PHYSICAL_ADDRESS BaseAddress,
- IN UINTN NumPages
+ IN PHYSICAL_ADDRESS Cr3BaseAddress,
+ IN PHYSICAL_ADDRESS BaseAddress,
+ IN UINTN NumPages
)
{
//
@@ -95,9 +95,9 @@ MemEncryptSevSetPageEncMask (
MEM_ENCRYPT_SEV_ADDRESS_RANGE_STATE
EFIAPI
MemEncryptSevGetAddressRangeState (
- IN PHYSICAL_ADDRESS Cr3BaseAddress,
- IN PHYSICAL_ADDRESS BaseAddress,
- IN UINTN Length
+ IN PHYSICAL_ADDRESS Cr3BaseAddress,
+ IN PHYSICAL_ADDRESS BaseAddress,
+ IN UINTN Length
)
{
//
@@ -126,9 +126,9 @@ MemEncryptSevGetAddressRangeState (
RETURN_STATUS
EFIAPI
MemEncryptSevClearMmioPageEncMask (
- IN PHYSICAL_ADDRESS Cr3BaseAddress,
- IN PHYSICAL_ADDRESS BaseAddress,
- IN UINTN NumPages
+ IN PHYSICAL_ADDRESS Cr3BaseAddress,
+ IN PHYSICAL_ADDRESS BaseAddress,
+ IN UINTN NumPages
)
{
//
diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/PeiDxeMemEncryptSevLibInternal.c b/OvmfPkg/Library/BaseMemEncryptSevLib/PeiDxeMemEncryptSevLibInternal.c
index b4a9f464e2..78ea16ae06 100644
--- a/OvmfPkg/Library/BaseMemEncryptSevLib/PeiDxeMemEncryptSevLibInternal.c
+++ b/OvmfPkg/Library/BaseMemEncryptSevLib/PeiDxeMemEncryptSevLibInternal.c
@@ -34,15 +34,15 @@
RETURN_STATUS
EFIAPI
MemEncryptSevLocateInitialSmramSaveStateMapPages (
- OUT UINTN *BaseAddress,
- OUT UINTN *NumberOfPages
+ OUT UINTN *BaseAddress,
+ OUT UINTN *NumberOfPages
)
{
- UINTN MapStart;
- UINTN MapEnd;
- UINTN MapPagesStart; // MapStart rounded down to page boundary
- UINTN MapPagesEnd; // MapEnd rounded up to page boundary
- UINTN MapPagesSize; // difference between MapPagesStart and MapPagesEnd
+ UINTN MapStart;
+ UINTN MapEnd;
+ UINTN MapPagesStart; // MapStart rounded down to page boundary
+ UINTN MapPagesEnd; // MapEnd rounded up to page boundary
+ UINTN MapPagesSize; // difference between MapPagesStart and MapPagesEnd
if (!FeaturePcdGet (PcdSmmSmramRequire)) {
return RETURN_UNSUPPORTED;
diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/PeiMemEncryptSevLibInternal.c b/OvmfPkg/Library/BaseMemEncryptSevLib/PeiMemEncryptSevLibInternal.c
index e2fd109d12..c4aa74a0a2 100644
--- a/OvmfPkg/Library/BaseMemEncryptSevLib/PeiMemEncryptSevLibInternal.c
+++ b/OvmfPkg/Library/BaseMemEncryptSevLib/PeiMemEncryptSevLibInternal.c
@@ -17,12 +17,12 @@
#include <Register/Cpuid.h>
#include <Uefi/UefiBaseType.h>
-STATIC BOOLEAN mSevStatus = FALSE;
-STATIC BOOLEAN mSevEsStatus = FALSE;
-STATIC BOOLEAN mSevStatusChecked = FALSE;
+STATIC BOOLEAN mSevStatus = FALSE;
+STATIC BOOLEAN mSevEsStatus = FALSE;
+STATIC BOOLEAN mSevStatusChecked = FALSE;
-STATIC UINT64 mSevEncryptionMask = 0;
-STATIC BOOLEAN mSevEncryptionMaskSaved = FALSE;
+STATIC UINT64 mSevEncryptionMask = 0;
+STATIC BOOLEAN mSevEncryptionMaskSaved = FALSE;
/**
Reads and sets the status of SEV features.
@@ -43,8 +43,8 @@ InternalMemEncryptSevStatus (
ReadSevMsr = FALSE;
- SevEsWorkArea = (SEC_SEV_ES_WORK_AREA *) FixedPcdGet32 (PcdSevEsWorkAreaBase);
- if (SevEsWorkArea != NULL && SevEsWorkArea->EncryptionMask != 0) {
+ SevEsWorkArea = (SEC_SEV_ES_WORK_AREA *)FixedPcdGet32 (PcdSevEsWorkAreaBase);
+ if ((SevEsWorkArea != NULL) && (SevEsWorkArea->EncryptionMask != 0)) {
//
// The MSR has been read before, so it is safe to read it again and avoid
// having to validate the CPUID information.
@@ -139,7 +139,7 @@ MemEncryptSevGetEncryptionMask (
if (!mSevEncryptionMaskSaved) {
SEC_SEV_ES_WORK_AREA *SevEsWorkArea;
- SevEsWorkArea = (SEC_SEV_ES_WORK_AREA *) FixedPcdGet32 (PcdSevEsWorkAreaBase);
+ SevEsWorkArea = (SEC_SEV_ES_WORK_AREA *)FixedPcdGet32 (PcdSevEsWorkAreaBase);
if (SevEsWorkArea != NULL) {
mSevEncryptionMask = SevEsWorkArea->EncryptionMask;
} else {
diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/SecMemEncryptSevLibInternal.c b/OvmfPkg/Library/BaseMemEncryptSevLib/SecMemEncryptSevLibInternal.c
index 56d8f3f318..b5b3656414 100644
--- a/OvmfPkg/Library/BaseMemEncryptSevLib/SecMemEncryptSevLibInternal.c
+++ b/OvmfPkg/Library/BaseMemEncryptSevLib/SecMemEncryptSevLibInternal.c
@@ -35,8 +35,8 @@ InternalMemEncryptSevStatus (
ReadSevMsr = FALSE;
- SevEsWorkArea = (SEC_SEV_ES_WORK_AREA *) FixedPcdGet32 (PcdSevEsWorkAreaBase);
- if (SevEsWorkArea != NULL && SevEsWorkArea->EncryptionMask != 0) {
+ SevEsWorkArea = (SEC_SEV_ES_WORK_AREA *)FixedPcdGet32 (PcdSevEsWorkAreaBase);
+ if ((SevEsWorkArea != NULL) && (SevEsWorkArea->EncryptionMask != 0)) {
//
// The MSR has been read before, so it is safe to read it again and avoid
// having to validate the CPUID information.
@@ -74,7 +74,7 @@ MemEncryptSevEsIsEnabled (
VOID
)
{
- MSR_SEV_STATUS_REGISTER Msr;
+ MSR_SEV_STATUS_REGISTER Msr;
Msr.Uint32 = InternalMemEncryptSevStatus ();
@@ -93,7 +93,7 @@ MemEncryptSevIsEnabled (
VOID
)
{
- MSR_SEV_STATUS_REGISTER Msr;
+ MSR_SEV_STATUS_REGISTER Msr;
Msr.Uint32 = InternalMemEncryptSevStatus ();
@@ -115,7 +115,7 @@ MemEncryptSevGetEncryptionMask (
SEC_SEV_ES_WORK_AREA *SevEsWorkArea;
UINT64 EncryptionMask;
- SevEsWorkArea = (SEC_SEV_ES_WORK_AREA *) FixedPcdGet32 (PcdSevEsWorkAreaBase);
+ SevEsWorkArea = (SEC_SEV_ES_WORK_AREA *)FixedPcdGet32 (PcdSevEsWorkAreaBase);
if (SevEsWorkArea != NULL) {
EncryptionMask = SevEsWorkArea->EncryptionMask;
} else {
@@ -147,8 +147,8 @@ MemEncryptSevGetEncryptionMask (
RETURN_STATUS
EFIAPI
MemEncryptSevLocateInitialSmramSaveStateMapPages (
- OUT UINTN *BaseAddress,
- OUT UINTN *NumberOfPages
+ OUT UINTN *BaseAddress,
+ OUT UINTN *NumberOfPages
)
{
return RETURN_UNSUPPORTED;
diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/MemEncryptSevLib.c b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/MemEncryptSevLib.c
index a57e8fd37f..e7c703bb9a 100644
--- a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/MemEncryptSevLib.c
+++ b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/MemEncryptSevLib.c
@@ -37,9 +37,9 @@
RETURN_STATUS
EFIAPI
MemEncryptSevClearPageEncMask (
- IN PHYSICAL_ADDRESS Cr3BaseAddress,
- IN PHYSICAL_ADDRESS BaseAddress,
- IN UINTN NumPages
+ IN PHYSICAL_ADDRESS Cr3BaseAddress,
+ IN PHYSICAL_ADDRESS BaseAddress,
+ IN UINTN NumPages
)
{
return InternalMemEncryptSevSetMemoryDecrypted (
@@ -69,9 +69,9 @@ MemEncryptSevClearPageEncMask (
RETURN_STATUS
EFIAPI
MemEncryptSevSetPageEncMask (
- IN PHYSICAL_ADDRESS Cr3BaseAddress,
- IN PHYSICAL_ADDRESS BaseAddress,
- IN UINTN NumPages
+ IN PHYSICAL_ADDRESS Cr3BaseAddress,
+ IN PHYSICAL_ADDRESS BaseAddress,
+ IN UINTN NumPages
)
{
return InternalMemEncryptSevSetMemoryEncrypted (
@@ -99,9 +99,9 @@ MemEncryptSevSetPageEncMask (
MEM_ENCRYPT_SEV_ADDRESS_RANGE_STATE
EFIAPI
MemEncryptSevGetAddressRangeState (
- IN PHYSICAL_ADDRESS Cr3BaseAddress,
- IN PHYSICAL_ADDRESS BaseAddress,
- IN UINTN Length
+ IN PHYSICAL_ADDRESS Cr3BaseAddress,
+ IN PHYSICAL_ADDRESS BaseAddress,
+ IN UINTN Length
)
{
return InternalMemEncryptSevGetAddressRangeState (
@@ -131,9 +131,9 @@ MemEncryptSevGetAddressRangeState (
RETURN_STATUS
EFIAPI
MemEncryptSevClearMmioPageEncMask (
- IN PHYSICAL_ADDRESS Cr3BaseAddress,
- IN PHYSICAL_ADDRESS BaseAddress,
- IN UINTN NumPages
+ IN PHYSICAL_ADDRESS Cr3BaseAddress,
+ IN PHYSICAL_ADDRESS BaseAddress,
+ IN UINTN NumPages
)
{
return InternalMemEncryptSevClearMmioPageEncMask (
@@ -141,5 +141,4 @@ MemEncryptSevClearMmioPageEncMask (
BaseAddress,
EFI_PAGES_TO_SIZE (NumPages)
);
-
}
diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c
index c696745f9d..bbc48ff6d8 100644
--- a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c
+++ b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c
@@ -18,13 +18,13 @@
#include "VirtualMemory.h"
-STATIC BOOLEAN mAddressEncMaskChecked = FALSE;
-STATIC UINT64 mAddressEncMask;
-STATIC PAGE_TABLE_POOL *mPageTablePool = NULL;
+STATIC BOOLEAN mAddressEncMaskChecked = FALSE;
+STATIC UINT64 mAddressEncMask;
+STATIC PAGE_TABLE_POOL *mPageTablePool = NULL;
typedef enum {
- SetCBit,
- ClearCBit
+ SetCBit,
+ ClearCBit
} MAP_RANGE_MODE;
/**
@@ -39,7 +39,7 @@ InternalGetMemEncryptionAddressMask (
VOID
)
{
- UINT64 EncryptionMask;
+ UINT64 EncryptionMask;
if (mAddressEncMaskChecked) {
return mAddressEncMask;
@@ -47,7 +47,7 @@ InternalGetMemEncryptionAddressMask (
EncryptionMask = MemEncryptSevGetEncryptionMask ();
- mAddressEncMask = EncryptionMask & PAGING_1G_ADDRESS_MASK_64;
+ mAddressEncMask = EncryptionMask & PAGING_1G_ADDRESS_MASK_64;
mAddressEncMaskChecked = TRUE;
return mAddressEncMask;
@@ -74,18 +74,18 @@ InternalGetMemEncryptionAddressMask (
STATIC
BOOLEAN
InitializePageTablePool (
- IN UINTN PoolPages
+ IN UINTN PoolPages
)
{
- VOID *Buffer;
+ VOID *Buffer;
//
// Always reserve at least PAGE_TABLE_POOL_UNIT_PAGES, including one page for
// header.
//
PoolPages += 1; // Add one page for header.
- PoolPages = ((PoolPages - 1) / PAGE_TABLE_POOL_UNIT_PAGES + 1) *
- PAGE_TABLE_POOL_UNIT_PAGES;
+ PoolPages = ((PoolPages - 1) / PAGE_TABLE_POOL_UNIT_PAGES + 1) *
+ PAGE_TABLE_POOL_UNIT_PAGES;
Buffer = AllocateAlignedPages (PoolPages, PAGE_TABLE_POOL_ALIGNMENT);
if (Buffer == NULL) {
DEBUG ((DEBUG_ERROR, "ERROR: Out of aligned pages\r\n"));
@@ -96,19 +96,19 @@ InitializePageTablePool (
// Link all pools into a list for easier track later.
//
if (mPageTablePool == NULL) {
- mPageTablePool = Buffer;
+ mPageTablePool = Buffer;
mPageTablePool->NextPool = mPageTablePool;
} else {
((PAGE_TABLE_POOL *)Buffer)->NextPool = mPageTablePool->NextPool;
- mPageTablePool->NextPool = Buffer;
- mPageTablePool = Buffer;
+ mPageTablePool->NextPool = Buffer;
+ mPageTablePool = Buffer;
}
//
// Reserve one page for pool header.
//
- mPageTablePool->FreePages = PoolPages - 1;
- mPageTablePool->Offset = EFI_PAGES_TO_SIZE (1);
+ mPageTablePool->FreePages = PoolPages - 1;
+ mPageTablePool->Offset = EFI_PAGES_TO_SIZE (1);
return TRUE;
}
@@ -134,10 +134,10 @@ STATIC
VOID *
EFIAPI
AllocatePageTableMemory (
- IN UINTN Pages
+ IN UINTN Pages
)
{
- VOID *Buffer;
+ VOID *Buffer;
if (Pages == 0) {
return NULL;
@@ -146,8 +146,9 @@ AllocatePageTableMemory (
//
// Renew the pool if necessary.
//
- if (mPageTablePool == NULL ||
- Pages > mPageTablePool->FreePages) {
+ if ((mPageTablePool == NULL) ||
+ (Pages > mPageTablePool->FreePages))
+ {
if (!InitializePageTablePool (Pages)) {
return NULL;
}
@@ -155,8 +156,8 @@ AllocatePageTableMemory (
Buffer = (UINT8 *)mPageTablePool + mPageTablePool->Offset;
- mPageTablePool->Offset += EFI_PAGES_TO_SIZE (Pages);
- mPageTablePool->FreePages -= Pages;
+ mPageTablePool->Offset += EFI_PAGES_TO_SIZE (Pages);
+ mPageTablePool->FreePages -= Pages;
DEBUG ((
DEBUG_VERBOSE,
@@ -170,7 +171,6 @@ AllocatePageTableMemory (
return Buffer;
}
-
/**
Split 2M page to 4K.
@@ -184,19 +184,19 @@ AllocatePageTableMemory (
STATIC
VOID
Split2MPageTo4K (
- IN PHYSICAL_ADDRESS PhysicalAddress,
- IN OUT UINT64 *PageEntry2M,
- IN PHYSICAL_ADDRESS StackBase,
- IN UINTN StackSize
+ IN PHYSICAL_ADDRESS PhysicalAddress,
+ IN OUT UINT64 *PageEntry2M,
+ IN PHYSICAL_ADDRESS StackBase,
+ IN UINTN StackSize
)
{
- PHYSICAL_ADDRESS PhysicalAddress4K;
- UINTN IndexOfPageTableEntries;
- PAGE_TABLE_4K_ENTRY *PageTableEntry;
- PAGE_TABLE_4K_ENTRY *PageTableEntry1;
- UINT64 AddressEncMask;
+ PHYSICAL_ADDRESS PhysicalAddress4K;
+ UINTN IndexOfPageTableEntries;
+ PAGE_TABLE_4K_ENTRY *PageTableEntry;
+ PAGE_TABLE_4K_ENTRY *PageTableEntry1;
+ UINT64 AddressEncMask;
- PageTableEntry = AllocatePageTableMemory(1);
+ PageTableEntry = AllocatePageTableMemory (1);
PageTableEntry1 = PageTableEntry;
@@ -210,15 +210,17 @@ Split2MPageTo4K (
IndexOfPageTableEntries < 512;
(IndexOfPageTableEntries++,
PageTableEntry++,
- PhysicalAddress4K += SIZE_4KB)) {
+ PhysicalAddress4K += SIZE_4KB))
+ {
//
// Fill in the Page Table entries
//
- PageTableEntry->Uint64 = (UINT64) PhysicalAddress4K | AddressEncMask;
+ PageTableEntry->Uint64 = (UINT64)PhysicalAddress4K | AddressEncMask;
PageTableEntry->Bits.ReadWrite = 1;
- PageTableEntry->Bits.Present = 1;
+ PageTableEntry->Bits.Present = 1;
if ((PhysicalAddress4K >= StackBase) &&
- (PhysicalAddress4K < StackBase + StackSize)) {
+ (PhysicalAddress4K < StackBase + StackSize))
+ {
//
// Set Nx bit for stack.
//
@@ -244,9 +246,9 @@ Split2MPageTo4K (
STATIC
VOID
SetPageTablePoolReadOnly (
- IN UINTN PageTableBase,
- IN EFI_PHYSICAL_ADDRESS Address,
- IN BOOLEAN Level4Paging
+ IN UINTN PageTableBase,
+ IN EFI_PHYSICAL_ADDRESS Address,
+ IN BOOLEAN Level4Paging
)
{
UINTN Index;
@@ -286,12 +288,12 @@ SetPageTablePoolReadOnly (
LevelSize[3] = SIZE_1GB;
LevelSize[4] = SIZE_512GB;
- AddressEncMask = InternalGetMemEncryptionAddressMask();
- PageTable = (UINT64 *)(UINTN)PageTableBase;
- PoolUnitSize = PAGE_TABLE_POOL_UNIT_SIZE;
+ AddressEncMask = InternalGetMemEncryptionAddressMask ();
+ PageTable = (UINT64 *)(UINTN)PageTableBase;
+ PoolUnitSize = PAGE_TABLE_POOL_UNIT_SIZE;
for (Level = (Level4Paging) ? 4 : 3; Level > 0; --Level) {
- Index = ((UINTN)RShiftU64 (Address, LevelShift[Level]));
+ Index = ((UINTN)RShiftU64 (Address, LevelShift[Level]));
Index &= PAGING_PAE_INDEX_MASK;
PageAttr = PageTable[Index];
@@ -319,14 +321,13 @@ SetPageTablePoolReadOnly (
ASSERT (Index < EFI_PAGE_SIZE/sizeof (UINT64));
PageTable[Index] &= ~(UINT64)IA32_PG_RW;
- PoolUnitSize -= LevelSize[Level];
+ PoolUnitSize -= LevelSize[Level];
++Index;
}
}
break;
-
} else {
//
// The smaller granularity of page must be needed.
@@ -338,18 +339,20 @@ SetPageTablePoolReadOnly (
PhysicalAddress = PageAttr & LevelMask[Level];
for (EntryIndex = 0;
- EntryIndex < EFI_PAGE_SIZE/sizeof (UINT64);
- ++EntryIndex) {
+ EntryIndex < EFI_PAGE_SIZE/sizeof (UINT64);
+ ++EntryIndex)
+ {
NewPageTable[EntryIndex] = PhysicalAddress | AddressEncMask |
IA32_PG_P | IA32_PG_RW;
if (Level > 2) {
NewPageTable[EntryIndex] |= IA32_PG_PS;
}
+
PhysicalAddress += LevelSize[Level - 1];
}
PageTable[Index] = (UINT64)(UINTN)NewPageTable | AddressEncMask |
- IA32_PG_P | IA32_PG_RW;
+ IA32_PG_P | IA32_PG_RW;
PageTable = NewPageTable;
}
}
@@ -365,14 +368,14 @@ SetPageTablePoolReadOnly (
STATIC
VOID
EnablePageTableProtection (
- IN UINTN PageTableBase,
- IN BOOLEAN Level4Paging
+ IN UINTN PageTableBase,
+ IN BOOLEAN Level4Paging
)
{
- PAGE_TABLE_POOL *HeadPool;
- PAGE_TABLE_POOL *Pool;
- UINT64 PoolSize;
- EFI_PHYSICAL_ADDRESS Address;
+ PAGE_TABLE_POOL *HeadPool;
+ PAGE_TABLE_POOL *Pool;
+ UINT64 PoolSize;
+ EFI_PHYSICAL_ADDRESS Address;
if (mPageTablePool == NULL) {
return;
@@ -383,7 +386,7 @@ EnablePageTableProtection (
// remember original one in advance.
//
HeadPool = mPageTablePool;
- Pool = HeadPool;
+ Pool = HeadPool;
do {
Address = (EFI_PHYSICAL_ADDRESS)(UINTN)Pool;
PoolSize = Pool->Offset + EFI_PAGES_TO_SIZE (Pool->FreePages);
@@ -394,17 +397,15 @@ EnablePageTableProtection (
// the protection to them one by one.
//
while (PoolSize > 0) {
- SetPageTablePoolReadOnly(PageTableBase, Address, Level4Paging);
- Address += PAGE_TABLE_POOL_UNIT_SIZE;
- PoolSize -= PAGE_TABLE_POOL_UNIT_SIZE;
+ SetPageTablePoolReadOnly (PageTableBase, Address, Level4Paging);
+ Address += PAGE_TABLE_POOL_UNIT_SIZE;
+ PoolSize -= PAGE_TABLE_POOL_UNIT_SIZE;
}
Pool = Pool->NextPool;
} while (Pool != HeadPool);
-
}
-
/**
Split 1G page to 2M.
@@ -418,18 +419,18 @@ EnablePageTableProtection (
STATIC
VOID
Split1GPageTo2M (
- IN PHYSICAL_ADDRESS PhysicalAddress,
- IN OUT UINT64 *PageEntry1G,
- IN PHYSICAL_ADDRESS StackBase,
- IN UINTN StackSize
+ IN PHYSICAL_ADDRESS PhysicalAddress,
+ IN OUT UINT64 *PageEntry1G,
+ IN PHYSICAL_ADDRESS StackBase,
+ IN UINTN StackSize
)
{
- PHYSICAL_ADDRESS PhysicalAddress2M;
- UINTN IndexOfPageDirectoryEntries;
- PAGE_TABLE_ENTRY *PageDirectoryEntry;
- UINT64 AddressEncMask;
+ PHYSICAL_ADDRESS PhysicalAddress2M;
+ UINTN IndexOfPageDirectoryEntries;
+ PAGE_TABLE_ENTRY *PageDirectoryEntry;
+ UINT64 AddressEncMask;
- PageDirectoryEntry = AllocatePageTableMemory(1);
+ PageDirectoryEntry = AllocatePageTableMemory (1);
AddressEncMask = InternalGetMemEncryptionAddressMask ();
ASSERT (PageDirectoryEntry != NULL);
@@ -445,9 +446,11 @@ Split1GPageTo2M (
IndexOfPageDirectoryEntries < 512;
(IndexOfPageDirectoryEntries++,
PageDirectoryEntry++,
- PhysicalAddress2M += SIZE_2MB)) {
+ PhysicalAddress2M += SIZE_2MB))
+ {
if ((PhysicalAddress2M < StackBase + StackSize) &&
- ((PhysicalAddress2M + SIZE_2MB) > StackBase)) {
+ ((PhysicalAddress2M + SIZE_2MB) > StackBase))
+ {
//
// Need to split this 2M page that covers stack range.
//
@@ -461,15 +464,14 @@ Split1GPageTo2M (
//
// Fill in the Page Directory entries
//
- PageDirectoryEntry->Uint64 = (UINT64) PhysicalAddress2M | AddressEncMask;
+ PageDirectoryEntry->Uint64 = (UINT64)PhysicalAddress2M | AddressEncMask;
PageDirectoryEntry->Bits.ReadWrite = 1;
- PageDirectoryEntry->Bits.Present = 1;
- PageDirectoryEntry->Bits.MustBe1 = 1;
+ PageDirectoryEntry->Bits.Present = 1;
+ PageDirectoryEntry->Bits.MustBe1 = 1;
}
}
}
-
/**
Set or Clear the memory encryption bit
@@ -478,12 +480,12 @@ Split1GPageTo2M (
**/
STATIC VOID
-SetOrClearCBit(
- IN OUT UINT64* PageTablePointer,
- IN MAP_RANGE_MODE Mode
+SetOrClearCBit (
+ IN OUT UINT64 *PageTablePointer,
+ IN MAP_RANGE_MODE Mode
)
{
- UINT64 AddressEncMask;
+ UINT64 AddressEncMask;
AddressEncMask = InternalGetMemEncryptionAddressMask ();
@@ -492,7 +494,6 @@ SetOrClearCBit(
} else {
*PageTablePointer &= ~AddressEncMask;
}
-
}
/**
@@ -511,7 +512,6 @@ IsReadOnlyPageWriteProtected (
return ((AsmReadCr0 () & BIT16) != 0);
}
-
/**
Disable Write Protect on pages marked as read-only.
**/
@@ -521,7 +521,7 @@ DisableReadOnlyPageWriteProtect (
VOID
)
{
- AsmWriteCr0 (AsmReadCr0() & ~BIT16);
+ AsmWriteCr0 (AsmReadCr0 () & ~BIT16);
}
/**
@@ -533,10 +533,9 @@ EnableReadOnlyPageWriteProtect (
VOID
)
{
- AsmWriteCr0 (AsmReadCr0() | BIT16);
+ AsmWriteCr0 (AsmReadCr0 () | BIT16);
}
-
/**
This function either sets or clears memory encryption bit for the memory
region specified by PhysicalAddress and Length from the current page table
@@ -568,23 +567,23 @@ STATIC
RETURN_STATUS
EFIAPI
SetMemoryEncDec (
- IN PHYSICAL_ADDRESS Cr3BaseAddress,
- IN PHYSICAL_ADDRESS PhysicalAddress,
- IN UINTN Length,
- IN MAP_RANGE_MODE Mode,
- IN BOOLEAN CacheFlush
+ IN PHYSICAL_ADDRESS Cr3BaseAddress,
+ IN PHYSICAL_ADDRESS PhysicalAddress,
+ IN UINTN Length,
+ IN MAP_RANGE_MODE Mode,
+ IN BOOLEAN CacheFlush
)
{
- PAGE_MAP_AND_DIRECTORY_POINTER *PageMapLevel4Entry;
- PAGE_MAP_AND_DIRECTORY_POINTER *PageUpperDirectoryPointerEntry;
- PAGE_MAP_AND_DIRECTORY_POINTER *PageDirectoryPointerEntry;
- PAGE_TABLE_1G_ENTRY *PageDirectory1GEntry;
- PAGE_TABLE_ENTRY *PageDirectory2MEntry;
- PAGE_TABLE_4K_ENTRY *PageTableEntry;
- UINT64 PgTableMask;
- UINT64 AddressEncMask;
- BOOLEAN IsWpEnabled;
- RETURN_STATUS Status;
+ PAGE_MAP_AND_DIRECTORY_POINTER *PageMapLevel4Entry;
+ PAGE_MAP_AND_DIRECTORY_POINTER *PageUpperDirectoryPointerEntry;
+ PAGE_MAP_AND_DIRECTORY_POINTER *PageDirectoryPointerEntry;
+ PAGE_TABLE_1G_ENTRY *PageDirectory1GEntry;
+ PAGE_TABLE_ENTRY *PageDirectory2MEntry;
+ PAGE_TABLE_4K_ENTRY *PageTableEntry;
+ UINT64 PgTableMask;
+ UINT64 AddressEncMask;
+ BOOLEAN IsWpEnabled;
+ RETURN_STATUS Status;
//
// Set PageMapLevel4Entry to suppress incorrect compiler/analyzer warnings.
@@ -623,7 +622,7 @@ SetMemoryEncDec (
// with correct C-bit
//
if (CacheFlush) {
- WriteBackInvalidateDataCacheRange((VOID*) (UINTN)PhysicalAddress, Length);
+ WriteBackInvalidateDataCacheRange ((VOID *)(UINTN)PhysicalAddress, Length);
}
//
@@ -636,17 +635,16 @@ SetMemoryEncDec (
Status = EFI_SUCCESS;
- while (Length != 0)
- {
+ while (Length != 0) {
//
// If Cr3BaseAddress is not specified then read the current CR3
//
if (Cr3BaseAddress == 0) {
- Cr3BaseAddress = AsmReadCr3();
+ Cr3BaseAddress = AsmReadCr3 ();
}
- PageMapLevel4Entry = (VOID*) (Cr3BaseAddress & ~PgTableMask);
- PageMapLevel4Entry += PML4_OFFSET(PhysicalAddress);
+ PageMapLevel4Entry = (VOID *)(Cr3BaseAddress & ~PgTableMask);
+ PageMapLevel4Entry += PML4_OFFSET (PhysicalAddress);
if (!PageMapLevel4Entry->Bits.Present) {
DEBUG ((
DEBUG_ERROR,
@@ -660,10 +658,10 @@ SetMemoryEncDec (
}
PageDirectory1GEntry = (VOID *)(
- (PageMapLevel4Entry->Bits.PageTableBaseAddress <<
- 12) & ~PgTableMask
- );
- PageDirectory1GEntry += PDP_OFFSET(PhysicalAddress);
+ (PageMapLevel4Entry->Bits.PageTableBaseAddress <<
+ 12) & ~PgTableMask
+ );
+ PageDirectory1GEntry += PDP_OFFSET (PhysicalAddress);
if (!PageDirectory1GEntry->Bits.Present) {
DEBUG ((
DEBUG_ERROR,
@@ -684,8 +682,8 @@ SetMemoryEncDec (
// Valid 1GB page
// If we have at least 1GB to go, we can just update this entry
//
- if ((PhysicalAddress & (BIT30 - 1)) == 0 && Length >= BIT30) {
- SetOrClearCBit(&PageDirectory1GEntry->Uint64, Mode);
+ if (((PhysicalAddress & (BIT30 - 1)) == 0) && (Length >= BIT30)) {
+ SetOrClearCBit (&PageDirectory1GEntry->Uint64, Mode);
DEBUG ((
DEBUG_VERBOSE,
"%a:%a: updated 1GB entry for Physical=0x%Lx\n",
@@ -694,7 +692,7 @@ SetMemoryEncDec (
PhysicalAddress
));
PhysicalAddress += BIT30;
- Length -= BIT30;
+ Length -= BIT30;
} else {
//
// We must split the page
@@ -722,10 +720,10 @@ SetMemoryEncDec (
(PAGE_MAP_AND_DIRECTORY_POINTER *)PageDirectory1GEntry;
PageDirectory2MEntry =
(VOID *)(
- (PageUpperDirectoryPointerEntry->Bits.PageTableBaseAddress <<
- 12) & ~PgTableMask
- );
- PageDirectory2MEntry += PDE_OFFSET(PhysicalAddress);
+ (PageUpperDirectoryPointerEntry->Bits.PageTableBaseAddress <<
+ 12) & ~PgTableMask
+ );
+ PageDirectory2MEntry += PDE_OFFSET (PhysicalAddress);
if (!PageDirectory2MEntry->Bits.Present) {
DEBUG ((
DEBUG_ERROR,
@@ -737,6 +735,7 @@ SetMemoryEncDec (
Status = RETURN_NO_MAPPING;
goto Done;
}
+
//
// If the MustBe1 bit is not a 1, it's not a 2MB entry
//
@@ -745,10 +744,10 @@ SetMemoryEncDec (
// Valid 2MB page
// If we have at least 2MB left to go, we can just update this entry
//
- if ((PhysicalAddress & (BIT21-1)) == 0 && Length >= BIT21) {
+ if (((PhysicalAddress & (BIT21-1)) == 0) && (Length >= BIT21)) {
SetOrClearCBit (&PageDirectory2MEntry->Uint64, Mode);
PhysicalAddress += BIT21;
- Length -= BIT21;
+ Length -= BIT21;
} else {
//
// We must split up this page into 4K pages
@@ -773,10 +772,10 @@ SetMemoryEncDec (
(PAGE_MAP_AND_DIRECTORY_POINTER *)PageDirectory2MEntry;
PageTableEntry =
(VOID *)(
- (PageDirectoryPointerEntry->Bits.PageTableBaseAddress <<
- 12) & ~PgTableMask
- );
- PageTableEntry += PTE_OFFSET(PhysicalAddress);
+ (PageDirectoryPointerEntry->Bits.PageTableBaseAddress <<
+ 12) & ~PgTableMask
+ );
+ PageTableEntry += PTE_OFFSET (PhysicalAddress);
if (!PageTableEntry->Bits.Present) {
DEBUG ((
DEBUG_ERROR,
@@ -788,9 +787,10 @@ SetMemoryEncDec (
Status = RETURN_NO_MAPPING;
goto Done;
}
+
SetOrClearCBit (&PageTableEntry->Uint64, Mode);
PhysicalAddress += EFI_PAGE_SIZE;
- Length -= EFI_PAGE_SIZE;
+ Length -= EFI_PAGE_SIZE;
}
}
}
@@ -806,7 +806,7 @@ SetMemoryEncDec (
//
// Flush TLB
//
- CpuFlushTlb();
+ CpuFlushTlb ();
Done:
//
@@ -838,12 +838,11 @@ Done:
RETURN_STATUS
EFIAPI
InternalMemEncryptSevSetMemoryDecrypted (
- IN PHYSICAL_ADDRESS Cr3BaseAddress,
- IN PHYSICAL_ADDRESS PhysicalAddress,
- IN UINTN Length
+ IN PHYSICAL_ADDRESS Cr3BaseAddress,
+ IN PHYSICAL_ADDRESS PhysicalAddress,
+ IN UINTN Length
)
{
-
return SetMemoryEncDec (
Cr3BaseAddress,
PhysicalAddress,
@@ -872,9 +871,9 @@ InternalMemEncryptSevSetMemoryDecrypted (
RETURN_STATUS
EFIAPI
InternalMemEncryptSevSetMemoryEncrypted (
- IN PHYSICAL_ADDRESS Cr3BaseAddress,
- IN PHYSICAL_ADDRESS PhysicalAddress,
- IN UINTN Length
+ IN PHYSICAL_ADDRESS Cr3BaseAddress,
+ IN PHYSICAL_ADDRESS PhysicalAddress,
+ IN UINTN Length
)
{
return SetMemoryEncDec (
@@ -905,9 +904,9 @@ InternalMemEncryptSevSetMemoryEncrypted (
RETURN_STATUS
EFIAPI
InternalMemEncryptSevClearMmioPageEncMask (
- IN PHYSICAL_ADDRESS Cr3BaseAddress,
- IN PHYSICAL_ADDRESS PhysicalAddress,
- IN UINTN Length
+ IN PHYSICAL_ADDRESS Cr3BaseAddress,
+ IN PHYSICAL_ADDRESS PhysicalAddress,
+ IN UINTN Length
)
{
return SetMemoryEncDec (
diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SecVirtualMemory.c b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SecVirtualMemory.c
index a155c8729b..b5dc70a924 100644
--- a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SecVirtualMemory.c
+++ b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SecVirtualMemory.c
@@ -25,9 +25,9 @@ InternalGetMemEncryptionAddressMask (
VOID
)
{
- UINT64 EncryptionMask;
+ UINT64 EncryptionMask;
- EncryptionMask = MemEncryptSevGetEncryptionMask ();
+ EncryptionMask = MemEncryptSevGetEncryptionMask ();
EncryptionMask &= PAGING_1G_ADDRESS_MASK_64;
return EncryptionMask;
@@ -52,9 +52,9 @@ InternalGetMemEncryptionAddressMask (
RETURN_STATUS
EFIAPI
InternalMemEncryptSevSetMemoryDecrypted (
- IN PHYSICAL_ADDRESS Cr3BaseAddress,
- IN PHYSICAL_ADDRESS PhysicalAddress,
- IN UINTN Length
+ IN PHYSICAL_ADDRESS Cr3BaseAddress,
+ IN PHYSICAL_ADDRESS PhysicalAddress,
+ IN UINTN Length
)
{
//
@@ -84,9 +84,9 @@ InternalMemEncryptSevSetMemoryDecrypted (
RETURN_STATUS
EFIAPI
InternalMemEncryptSevSetMemoryEncrypted (
- IN PHYSICAL_ADDRESS Cr3BaseAddress,
- IN PHYSICAL_ADDRESS PhysicalAddress,
- IN UINTN Length
+ IN PHYSICAL_ADDRESS Cr3BaseAddress,
+ IN PHYSICAL_ADDRESS PhysicalAddress,
+ IN UINTN Length
)
{
//
@@ -114,9 +114,9 @@ InternalMemEncryptSevSetMemoryEncrypted (
RETURN_STATUS
EFIAPI
InternalMemEncryptSevClearMmioPageEncMask (
- IN PHYSICAL_ADDRESS Cr3BaseAddress,
- IN PHYSICAL_ADDRESS PhysicalAddress,
- IN UINTN Length
+ IN PHYSICAL_ADDRESS Cr3BaseAddress,
+ IN PHYSICAL_ADDRESS PhysicalAddress,
+ IN UINTN Length
)
{
//
diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.c b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.c
index 36aabcf556..2b759cafbf 100644
--- a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.c
+++ b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.c
@@ -96,10 +96,10 @@ InternalMemEncryptSevGetAddressRangeState (
// If Cr3BaseAddress is not specified then read the current CR3
//
if (Cr3BaseAddress == 0) {
- Cr3BaseAddress = AsmReadCr3();
+ Cr3BaseAddress = AsmReadCr3 ();
}
- AddressEncMask = MemEncryptSevGetEncryptionMask ();
+ AddressEncMask = MemEncryptSevGetEncryptionMask ();
AddressEncMask &= PAGING_1G_ADDRESS_MASK_64;
PgTableMask = AddressEncMask | EFI_PAGE_MASK;
@@ -110,21 +110,21 @@ InternalMemEncryptSevGetAddressRangeState (
// Encryption is on a page basis, so start at the beginning of the
// virtual address page boundary and walk page-by-page.
//
- Address = (PHYSICAL_ADDRESS) (UINTN) BaseAddress & ~EFI_PAGE_MASK;
+ Address = (PHYSICAL_ADDRESS)(UINTN)BaseAddress & ~EFI_PAGE_MASK;
AddressEnd = (PHYSICAL_ADDRESS)
- (UINTN) (BaseAddress + Length);
+ (UINTN)(BaseAddress + Length);
while (Address < AddressEnd) {
- PageMapLevel4Entry = (VOID*) (Cr3BaseAddress & ~PgTableMask);
+ PageMapLevel4Entry = (VOID *)(Cr3BaseAddress & ~PgTableMask);
PageMapLevel4Entry += PML4_OFFSET (Address);
if (!PageMapLevel4Entry->Bits.Present) {
return MemEncryptSevAddressRangeError;
}
- PageDirectory1GEntry = (VOID *) (
- (PageMapLevel4Entry->Bits.PageTableBaseAddress <<
- 12) & ~PgTableMask
- );
+ PageDirectory1GEntry = (VOID *)(
+ (PageMapLevel4Entry->Bits.PageTableBaseAddress <<
+ 12) & ~PgTableMask
+ );
PageDirectory1GEntry += PDP_OFFSET (Address);
if (!PageDirectory1GEntry->Bits.Present) {
return MemEncryptSevAddressRangeError;
@@ -151,12 +151,12 @@ InternalMemEncryptSevGetAddressRangeState (
// Actually a PDP
//
PageUpperDirectoryPointerEntry =
- (PAGE_MAP_AND_DIRECTORY_POINTER *) PageDirectory1GEntry;
+ (PAGE_MAP_AND_DIRECTORY_POINTER *)PageDirectory1GEntry;
PageDirectory2MEntry =
- (VOID *) (
- (PageUpperDirectoryPointerEntry->Bits.PageTableBaseAddress <<
- 12) & ~PgTableMask
- );
+ (VOID *)(
+ (PageUpperDirectoryPointerEntry->Bits.PageTableBaseAddress <<
+ 12) & ~PgTableMask
+ );
PageDirectory2MEntry += PDE_OFFSET (Address);
if (!PageDirectory2MEntry->Bits.Present) {
return MemEncryptSevAddressRangeError;
@@ -186,9 +186,9 @@ InternalMemEncryptSevGetAddressRangeState (
(PAGE_MAP_AND_DIRECTORY_POINTER *)PageDirectory2MEntry;
PageTableEntry =
(VOID *)(
- (PageDirectoryPointerEntry->Bits.PageTableBaseAddress <<
- 12) & ~PgTableMask
- );
+ (PageDirectoryPointerEntry->Bits.PageTableBaseAddress <<
+ 12) & ~PgTableMask
+ );
PageTableEntry += PTE_OFFSET (Address);
if (!PageTableEntry->Bits.Present) {
return MemEncryptSevAddressRangeError;
diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.h b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.h
index 21bbbd1c4f..93e3d08589 100644
--- a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.h
+++ b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.h
@@ -22,19 +22,19 @@
#include <Library/MemoryAllocationLib.h>
#include <Uefi.h>
-#define SYS_CODE64_SEL 0x38
+#define SYS_CODE64_SEL 0x38
-#define PAGE_TABLE_POOL_ALIGNMENT BASE_2MB
-#define PAGE_TABLE_POOL_UNIT_SIZE SIZE_2MB
+#define PAGE_TABLE_POOL_ALIGNMENT BASE_2MB
+#define PAGE_TABLE_POOL_UNIT_SIZE SIZE_2MB
#define PAGE_TABLE_POOL_UNIT_PAGES \
EFI_SIZE_TO_PAGES (PAGE_TABLE_POOL_UNIT_SIZE)
#define PAGE_TABLE_POOL_ALIGN_MASK \
(~(EFI_PHYSICAL_ADDRESS)(PAGE_TABLE_POOL_ALIGNMENT - 1))
typedef struct {
- VOID *NextPool;
- UINTN Offset;
- UINTN FreePages;
+ VOID *NextPool;
+ UINTN Offset;
+ UINTN FreePages;
} PAGE_TABLE_POOL;
/**
@@ -68,9 +68,9 @@ InternalGetMemEncryptionAddressMask (
RETURN_STATUS
EFIAPI
InternalMemEncryptSevSetMemoryDecrypted (
- IN PHYSICAL_ADDRESS Cr3BaseAddress,
- IN PHYSICAL_ADDRESS PhysicalAddress,
- IN UINTN Length
+ IN PHYSICAL_ADDRESS Cr3BaseAddress,
+ IN PHYSICAL_ADDRESS PhysicalAddress,
+ IN UINTN Length
);
/**
@@ -92,9 +92,9 @@ InternalMemEncryptSevSetMemoryDecrypted (
RETURN_STATUS
EFIAPI
InternalMemEncryptSevSetMemoryEncrypted (
- IN PHYSICAL_ADDRESS Cr3BaseAddress,
- IN PHYSICAL_ADDRESS PhysicalAddress,
- IN UINTN Length
+ IN PHYSICAL_ADDRESS Cr3BaseAddress,
+ IN PHYSICAL_ADDRESS PhysicalAddress,
+ IN UINTN Length
);
/**
@@ -115,9 +115,9 @@ InternalMemEncryptSevSetMemoryEncrypted (
MEM_ENCRYPT_SEV_ADDRESS_RANGE_STATE
EFIAPI
InternalMemEncryptSevGetAddressRangeState (
- IN PHYSICAL_ADDRESS Cr3BaseAddress,
- IN PHYSICAL_ADDRESS BaseAddress,
- IN UINTN Length
+ IN PHYSICAL_ADDRESS Cr3BaseAddress,
+ IN PHYSICAL_ADDRESS BaseAddress,
+ IN UINTN Length
);
/**
@@ -139,8 +139,9 @@ InternalMemEncryptSevGetAddressRangeState (
RETURN_STATUS
EFIAPI
InternalMemEncryptSevClearMmioPageEncMask (
- IN PHYSICAL_ADDRESS Cr3BaseAddress,
- IN PHYSICAL_ADDRESS PhysicalAddress,
- IN UINTN Length
+ IN PHYSICAL_ADDRESS Cr3BaseAddress,
+ IN PHYSICAL_ADDRESS PhysicalAddress,
+ IN UINTN Length
);
+
#endif
diff --git a/OvmfPkg/Library/BasePciCapLib/BasePciCapLib.c b/OvmfPkg/Library/BasePciCapLib/BasePciCapLib.c
index c6f2c72650..4215e6cdaa 100644
--- a/OvmfPkg/Library/BasePciCapLib/BasePciCapLib.c
+++ b/OvmfPkg/Library/BasePciCapLib/BasePciCapLib.c
@@ -17,7 +17,6 @@
#include "BasePciCapLib.h"
-
/**
Compare a standalone PCI_CAP_KEY against a PCI_CAP containing an embedded
PCI_CAP_KEY.
@@ -36,12 +35,12 @@ STATIC
INTN
EFIAPI
ComparePciCapKey (
- IN CONST VOID *PciCapKey,
- IN CONST VOID *PciCap
+ IN CONST VOID *PciCapKey,
+ IN CONST VOID *PciCap
)
{
- CONST PCI_CAP_KEY *Key1;
- CONST PCI_CAP_KEY *Key2;
+ CONST PCI_CAP_KEY *Key1;
+ CONST PCI_CAP_KEY *Key2;
Key1 = PciCapKey;
Key2 = &((CONST PCI_CAP *)PciCap)->Key;
@@ -49,25 +48,30 @@ ComparePciCapKey (
if (Key1->Domain < Key2->Domain) {
return -1;
}
+
if (Key1->Domain > Key2->Domain) {
return 1;
}
+
if (Key1->CapId < Key2->CapId) {
return -1;
}
+
if (Key1->CapId > Key2->CapId) {
return 1;
}
+
if (Key1->Instance < Key2->Instance) {
return -1;
}
+
if (Key1->Instance > Key2->Instance) {
return 1;
}
+
return 0;
}
-
/**
Compare two PCI_CAP objects based on PCI_CAP.Key.
@@ -85,17 +89,16 @@ STATIC
INTN
EFIAPI
ComparePciCap (
- IN CONST VOID *PciCap1,
- IN CONST VOID *PciCap2
+ IN CONST VOID *PciCap1,
+ IN CONST VOID *PciCap2
)
{
- CONST PCI_CAP_KEY *PciCap1Key;
+ CONST PCI_CAP_KEY *PciCap1Key;
PciCap1Key = &((CONST PCI_CAP *)PciCap1)->Key;
return ComparePciCapKey (PciCap1Key, PciCap2);
}
-
/**
Compare the standalone UINT16 config space offset of a capability header
against a PCI_CAP containing an embedded Offset.
@@ -114,12 +117,12 @@ STATIC
INTN
EFIAPI
ComparePciCapOffsetKey (
- IN CONST VOID *CapHdrOffset,
- IN CONST VOID *PciCap
+ IN CONST VOID *CapHdrOffset,
+ IN CONST VOID *PciCap
)
{
- UINT16 Offset1;
- UINT16 Offset2;
+ UINT16 Offset1;
+ UINT16 Offset2;
Offset1 = *(CONST UINT16 *)CapHdrOffset;
Offset2 = ((CONST PCI_CAP *)PciCap)->Offset;
@@ -130,7 +133,6 @@ ComparePciCapOffsetKey (
return Offset1 - Offset2;
}
-
/**
Compare two PCI_CAP objects based on PCI_CAP.Offset.
@@ -148,12 +150,12 @@ STATIC
INTN
EFIAPI
ComparePciCapOffset (
- IN CONST VOID *PciCap1,
- IN CONST VOID *PciCap2
+ IN CONST VOID *PciCap1,
+ IN CONST VOID *PciCap2
)
{
- UINT16 Offset1;
- UINT16 Offset2;
+ UINT16 Offset1;
+ UINT16 Offset2;
Offset1 = ((CONST PCI_CAP *)PciCap1)->Offset;
Offset2 = ((CONST PCI_CAP *)PciCap2)->Offset;
@@ -164,7 +166,6 @@ ComparePciCapOffset (
return Offset1 - Offset2;
}
-
/**
Insert a new instance of the PCI capability given by (Domain, CapId) in
CapList.
@@ -205,22 +206,24 @@ ComparePciCapOffset (
STATIC
RETURN_STATUS
InsertPciCap (
- IN OUT PCI_CAP_LIST *CapList,
- IN OUT ORDERED_COLLECTION *CapHdrOffsets,
- IN PCI_CAP_DOMAIN Domain,
- IN UINT16 CapId,
- IN UINT16 Offset,
- IN UINT8 Version
+ IN OUT PCI_CAP_LIST *CapList,
+ IN OUT ORDERED_COLLECTION *CapHdrOffsets,
+ IN PCI_CAP_DOMAIN Domain,
+ IN UINT16 CapId,
+ IN UINT16 Offset,
+ IN UINT8 Version
)
{
- PCI_CAP *PciCap;
- RETURN_STATUS Status;
- ORDERED_COLLECTION_ENTRY *PciCapEntry;
- PCI_CAP *InstanceZero;
+ PCI_CAP *PciCap;
+ RETURN_STATUS Status;
+ ORDERED_COLLECTION_ENTRY *PciCapEntry;
+ PCI_CAP *InstanceZero;
ASSERT ((Offset & 0x3) == 0);
- ASSERT (Offset < (Domain == PciCapNormal ?
- PCI_MAX_CONFIG_OFFSET : PCI_EXP_MAX_CONFIG_OFFSET));
+ ASSERT (
+ Offset < (Domain == PciCapNormal ?
+ PCI_MAX_CONFIG_OFFSET : PCI_EXP_MAX_CONFIG_OFFSET)
+ );
ASSERT (Domain == PciCapExtended || Version == 0);
//
@@ -237,6 +240,7 @@ InsertPciCap (
if (PciCap == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
PciCap->Key.Domain = Domain;
PciCap->Key.CapId = CapId;
PciCap->Key.Instance = 0;
@@ -248,12 +252,16 @@ InsertPciCap (
//
// Add PciCap to CapList.
//
- Status = OrderedCollectionInsert (CapList->Capabilities, &PciCapEntry,
- PciCap);
+ Status = OrderedCollectionInsert (
+ CapList->Capabilities,
+ &PciCapEntry,
+ PciCap
+ );
if (RETURN_ERROR (Status)) {
if (Status == RETURN_OUT_OF_RESOURCES) {
goto FreePciCap;
}
+
ASSERT (Status == RETURN_ALREADY_STARTED);
//
// PciCap is not the first instance of (Domain, CapId). Add it as a new
@@ -261,17 +269,21 @@ InsertPciCap (
// we don't bump the instance count maintained in Instance#0 just yet, to
// keep rollback on errors simple.
//
- InstanceZero = OrderedCollectionUserStruct (PciCapEntry);
- PciCap->Key.Instance = InstanceZero->NumInstancesUnion.NumInstances;
+ InstanceZero = OrderedCollectionUserStruct (PciCapEntry);
+ PciCap->Key.Instance = InstanceZero->NumInstancesUnion.NumInstances;
PciCap->NumInstancesUnion.InstanceZero = InstanceZero;
ASSERT (PciCap->Key.Instance > 0);
- Status = OrderedCollectionInsert (CapList->Capabilities, &PciCapEntry,
- PciCap);
+ Status = OrderedCollectionInsert (
+ CapList->Capabilities,
+ &PciCapEntry,
+ PciCap
+ );
if (Status == RETURN_OUT_OF_RESOURCES) {
goto FreePciCap;
}
}
+
//
// At this point, PciCap has been inserted in CapList->Capabilities, either
// with Instance==0 or with Instance>0. PciCapEntry is the iterator that
@@ -295,6 +307,7 @@ InsertPciCap (
//
Status = RETURN_DEVICE_ERROR;
}
+
goto DeletePciCapFromCapList;
}
@@ -312,6 +325,7 @@ InsertPciCap (
InstanceZero->NumInstancesUnion.NumInstances++;
}
+
return RETURN_SUCCESS;
DeletePciCapFromCapList:
@@ -323,7 +337,6 @@ FreePciCap:
return Status;
}
-
/**
Calculate the MaxSizeHint member for a PCI_CAP object.
@@ -347,11 +360,11 @@ FreePciCap:
STATIC
VOID
CalculatePciCapMaxSizeHint (
- IN OUT PCI_CAP *PciCap,
- IN PCI_CAP *NextPciCap OPTIONAL
+ IN OUT PCI_CAP *PciCap,
+ IN PCI_CAP *NextPciCap OPTIONAL
)
{
- UINT16 ConfigSpaceSize;
+ UINT16 ConfigSpaceSize;
ConfigSpaceSize = (PciCap->Key.Domain == PciCapNormal ?
PCI_MAX_CONFIG_OFFSET : PCI_EXP_MAX_CONFIG_OFFSET);
@@ -372,14 +385,14 @@ CalculatePciCapMaxSizeHint (
// PciCap extends from PciCap->Offset to NextPciCap->Offset (if any), except
// it cannot cross config space boundary.
//
- if (NextPciCap == NULL || NextPciCap->Offset >= ConfigSpaceSize) {
+ if ((NextPciCap == NULL) || (NextPciCap->Offset >= ConfigSpaceSize)) {
PciCap->MaxSizeHint = ConfigSpaceSize - PciCap->Offset;
return;
}
+
PciCap->MaxSizeHint = NextPciCap->Offset - PciCap->Offset;
}
-
/**
Debug dump a PCI_CAP_LIST object at the DEBUG_VERBOSE level.
@@ -389,18 +402,19 @@ STATIC
VOID
EFIAPI
DebugDumpPciCapList (
- IN PCI_CAP_LIST *CapList
+ IN PCI_CAP_LIST *CapList
)
{
DEBUG_CODE_BEGIN ();
- ORDERED_COLLECTION_ENTRY *PciCapEntry;
+ ORDERED_COLLECTION_ENTRY *PciCapEntry;
for (PciCapEntry = OrderedCollectionMin (CapList->Capabilities);
PciCapEntry != NULL;
- PciCapEntry = OrderedCollectionNext (PciCapEntry)) {
- PCI_CAP *PciCap;
- RETURN_STATUS Status;
- PCI_CAP_INFO Info;
+ PciCapEntry = OrderedCollectionNext (PciCapEntry))
+ {
+ PCI_CAP *PciCap;
+ RETURN_STATUS Status;
+ PCI_CAP_INFO Info;
PciCap = OrderedCollectionUserStruct (PciCapEntry);
Status = PciCapGetInfo (PciCap, &Info);
@@ -409,16 +423,24 @@ DebugDumpPciCapList (
//
ASSERT_RETURN_ERROR (Status);
- DEBUG ((DEBUG_VERBOSE,
- "%a:%a: %a 0x%04x %03u/%03u v0x%x @0x%03x+0x%03x\n", gEfiCallerBaseName,
- __FUNCTION__, (Info.Domain == PciCapNormal ? "Norm" : "Extd"),
- Info.CapId, Info.Instance, Info.NumInstances, Info.Version, Info.Offset,
- Info.MaxSizeHint));
+ DEBUG ((
+ DEBUG_VERBOSE,
+ "%a:%a: %a 0x%04x %03u/%03u v0x%x @0x%03x+0x%03x\n",
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ (Info.Domain == PciCapNormal ? "Norm" : "Extd"),
+ Info.CapId,
+ Info.Instance,
+ Info.NumInstances,
+ Info.Version,
+ Info.Offset,
+ Info.MaxSizeHint
+ ));
}
+
DEBUG_CODE_END ();
}
-
/**
Empty a collection of PCI_CAP structures, optionally releasing the referenced
PCI_CAP structures themselves. Release the collection at last.
@@ -435,17 +457,18 @@ DebugDumpPciCapList (
STATIC
VOID
EmptyAndUninitPciCapCollection (
- IN OUT ORDERED_COLLECTION *PciCapCollection,
- IN BOOLEAN FreePciCap
+ IN OUT ORDERED_COLLECTION *PciCapCollection,
+ IN BOOLEAN FreePciCap
)
{
- ORDERED_COLLECTION_ENTRY *PciCapEntry;
- ORDERED_COLLECTION_ENTRY *NextEntry;
+ ORDERED_COLLECTION_ENTRY *PciCapEntry;
+ ORDERED_COLLECTION_ENTRY *NextEntry;
for (PciCapEntry = OrderedCollectionMin (PciCapCollection);
PciCapEntry != NULL;
- PciCapEntry = NextEntry) {
- PCI_CAP *PciCap;
+ PciCapEntry = NextEntry)
+ {
+ PCI_CAP *PciCap;
NextEntry = OrderedCollectionNext (PciCapEntry);
OrderedCollectionDelete (PciCapCollection, PciCapEntry, (VOID **)&PciCap);
@@ -453,10 +476,10 @@ EmptyAndUninitPciCapCollection (
FreePool (PciCap);
}
}
+
OrderedCollectionUninit (PciCapCollection);
}
-
/**
Parse the capabilities lists (both normal and extended, as applicable) of a
PCI device.
@@ -492,16 +515,16 @@ EmptyAndUninitPciCapCollection (
RETURN_STATUS
EFIAPI
PciCapListInit (
- IN PCI_CAP_DEV *PciDevice,
- OUT PCI_CAP_LIST **CapList
+ IN PCI_CAP_DEV *PciDevice,
+ OUT PCI_CAP_LIST **CapList
)
{
- PCI_CAP_LIST *OutCapList;
- RETURN_STATUS Status;
- ORDERED_COLLECTION *CapHdrOffsets;
- UINT16 PciStatusReg;
- BOOLEAN DeviceIsExpress;
- ORDERED_COLLECTION_ENTRY *OffsetEntry;
+ PCI_CAP_LIST *OutCapList;
+ RETURN_STATUS Status;
+ ORDERED_COLLECTION *CapHdrOffsets;
+ UINT16 PciStatusReg;
+ BOOLEAN DeviceIsExpress;
+ ORDERED_COLLECTION_ENTRY *OffsetEntry;
//
// Allocate the output structure.
@@ -510,12 +533,15 @@ PciCapListInit (
if (OutCapList == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// The OutCapList->Capabilities collection owns the PCI_CAP structures and
// orders them based on PCI_CAP.Key.
//
- OutCapList->Capabilities = OrderedCollectionInit (ComparePciCap,
- ComparePciCapKey);
+ OutCapList->Capabilities = OrderedCollectionInit (
+ ComparePciCap,
+ ComparePciCapKey
+ );
if (OutCapList->Capabilities == NULL) {
Status = RETURN_OUT_OF_RESOURCES;
goto FreeOutCapList;
@@ -525,8 +551,10 @@ PciCapListInit (
// The (temporary) CapHdrOffsets collection only references PCI_CAP
// structures, and orders them based on PCI_CAP.Offset.
//
- CapHdrOffsets = OrderedCollectionInit (ComparePciCapOffset,
- ComparePciCapOffsetKey);
+ CapHdrOffsets = OrderedCollectionInit (
+ ComparePciCapOffset,
+ ComparePciCapOffsetKey
+ );
if (CapHdrOffsets == NULL) {
Status = RETURN_OUT_OF_RESOURCES;
goto FreeCapabilities;
@@ -542,19 +570,28 @@ PciCapListInit (
// Check whether a normal capabilities list is present. If there's none,
// that's not an error; we'll just return OutCapList->Capabilities empty.
//
- Status = PciDevice->ReadConfig (PciDevice, PCI_PRIMARY_STATUS_OFFSET,
- &PciStatusReg, sizeof PciStatusReg);
+ Status = PciDevice->ReadConfig (
+ PciDevice,
+ PCI_PRIMARY_STATUS_OFFSET,
+ &PciStatusReg,
+ sizeof PciStatusReg
+ );
if (RETURN_ERROR (Status)) {
goto FreeCapHdrOffsets;
}
+
if ((PciStatusReg & EFI_PCI_STATUS_CAPABILITY) != 0) {
- UINT8 NormalCapHdrOffset;
+ UINT8 NormalCapHdrOffset;
//
// Fetch the start offset of the normal capabilities list.
//
- Status = PciDevice->ReadConfig (PciDevice, PCI_CAPBILITY_POINTER_OFFSET,
- &NormalCapHdrOffset, sizeof NormalCapHdrOffset);
+ Status = PciDevice->ReadConfig (
+ PciDevice,
+ PCI_CAPBILITY_POINTER_OFFSET,
+ &NormalCapHdrOffset,
+ sizeof NormalCapHdrOffset
+ );
if (RETURN_ERROR (Status)) {
goto FreeCapHdrOffsets;
}
@@ -564,16 +601,26 @@ PciCapListInit (
//
NormalCapHdrOffset &= 0xFC;
while (NormalCapHdrOffset > 0) {
- EFI_PCI_CAPABILITY_HDR NormalCapHdr;
-
- Status = PciDevice->ReadConfig (PciDevice, NormalCapHdrOffset,
- &NormalCapHdr, sizeof NormalCapHdr);
+ EFI_PCI_CAPABILITY_HDR NormalCapHdr;
+
+ Status = PciDevice->ReadConfig (
+ PciDevice,
+ NormalCapHdrOffset,
+ &NormalCapHdr,
+ sizeof NormalCapHdr
+ );
if (RETURN_ERROR (Status)) {
goto FreeCapHdrOffsets;
}
- Status = InsertPciCap (OutCapList, CapHdrOffsets, PciCapNormal,
- NormalCapHdr.CapabilityID, NormalCapHdrOffset, 0);
+ Status = InsertPciCap (
+ OutCapList,
+ CapHdrOffsets,
+ PciCapNormal,
+ NormalCapHdr.CapabilityID,
+ NormalCapHdrOffset,
+ 0
+ );
if (RETURN_ERROR (Status)) {
goto FreeCapHdrOffsets;
}
@@ -581,6 +628,7 @@ PciCapListInit (
if (NormalCapHdr.CapabilityID == EFI_PCI_CAPABILITY_ID_PCIEXP) {
DeviceIsExpress = TRUE;
}
+
NormalCapHdrOffset = NormalCapHdr.NextItemPtr & 0xFC;
}
}
@@ -590,39 +638,51 @@ PciCapListInit (
// capabilities list. It starts right after the normal config space.
//
if (DeviceIsExpress) {
- UINT16 ExtendedCapHdrOffset;
+ UINT16 ExtendedCapHdrOffset;
ExtendedCapHdrOffset = PCI_MAX_CONFIG_OFFSET;
while (ExtendedCapHdrOffset > 0) {
- PCI_EXPRESS_EXTENDED_CAPABILITIES_HEADER ExtendedCapHdr;
-
- Status = PciDevice->ReadConfig (PciDevice, ExtendedCapHdrOffset,
- &ExtendedCapHdr, sizeof ExtendedCapHdr);
+ PCI_EXPRESS_EXTENDED_CAPABILITIES_HEADER ExtendedCapHdr;
+
+ Status = PciDevice->ReadConfig (
+ PciDevice,
+ ExtendedCapHdrOffset,
+ &ExtendedCapHdr,
+ sizeof ExtendedCapHdr
+ );
//
// If the first extended config space access fails, assume the device has
// no extended capabilities. If the first extended config space access
// succeeds but we read an "all bits zero" extended capability header,
// that means (by spec) the device has no extended capabilities.
//
- if (ExtendedCapHdrOffset == PCI_MAX_CONFIG_OFFSET &&
+ if ((ExtendedCapHdrOffset == PCI_MAX_CONFIG_OFFSET) &&
(RETURN_ERROR (Status) ||
- IsZeroBuffer (&ExtendedCapHdr, sizeof ExtendedCapHdr))) {
+ IsZeroBuffer (&ExtendedCapHdr, sizeof ExtendedCapHdr)))
+ {
break;
}
+
if (RETURN_ERROR (Status)) {
goto FreeCapHdrOffsets;
}
- Status = InsertPciCap (OutCapList, CapHdrOffsets, PciCapExtended,
- (UINT16)ExtendedCapHdr.CapabilityId, ExtendedCapHdrOffset,
- (UINT8)ExtendedCapHdr.CapabilityVersion);
+ Status = InsertPciCap (
+ OutCapList,
+ CapHdrOffsets,
+ PciCapExtended,
+ (UINT16)ExtendedCapHdr.CapabilityId,
+ ExtendedCapHdrOffset,
+ (UINT8)ExtendedCapHdr.CapabilityVersion
+ );
if (RETURN_ERROR (Status)) {
goto FreeCapHdrOffsets;
}
ExtendedCapHdrOffset = ExtendedCapHdr.NextCapabilityOffset & 0xFFC;
- if (ExtendedCapHdrOffset > 0 &&
- ExtendedCapHdrOffset < PCI_MAX_CONFIG_OFFSET) {
+ if ((ExtendedCapHdrOffset > 0) &&
+ (ExtendedCapHdrOffset < PCI_MAX_CONFIG_OFFSET))
+ {
//
// Invalid capability pointer.
//
@@ -642,8 +702,8 @@ PciCapListInit (
//
OffsetEntry = OrderedCollectionMin (CapHdrOffsets);
if (OffsetEntry != NULL) {
- ORDERED_COLLECTION_ENTRY *NextOffsetEntry;
- PCI_CAP *PciCap;
+ ORDERED_COLLECTION_ENTRY *NextOffsetEntry;
+ PCI_CAP *PciCap;
//
// Initialize NextOffsetEntry to the iterator of the PCI_CAP object with
@@ -655,21 +715,23 @@ PciCapListInit (
// highest Offset.
//
while (NextOffsetEntry != NULL) {
- PCI_CAP *NextPciCap;
+ PCI_CAP *NextPciCap;
OrderedCollectionDelete (CapHdrOffsets, OffsetEntry, (VOID **)&PciCap);
NextPciCap = OrderedCollectionUserStruct (NextOffsetEntry);
CalculatePciCapMaxSizeHint (PciCap, NextPciCap);
- OffsetEntry = NextOffsetEntry;
+ OffsetEntry = NextOffsetEntry;
NextOffsetEntry = OrderedCollectionNext (OffsetEntry);
}
+
//
// Calculate MaxSizeHint for the PCI_CAP object with the highest Offset.
//
OrderedCollectionDelete (CapHdrOffsets, OffsetEntry, (VOID **)&PciCap);
CalculatePciCapMaxSizeHint (PciCap, NULL);
}
+
ASSERT (OrderedCollectionIsEmpty (CapHdrOffsets));
OrderedCollectionUninit (CapHdrOffsets);
@@ -687,12 +749,16 @@ FreeOutCapList:
FreePool (OutCapList);
ASSERT (RETURN_ERROR (Status));
- DEBUG ((DEBUG_ERROR, "%a:%a: %r\n", gEfiCallerBaseName, __FUNCTION__,
- Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a:%a: %r\n",
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ Status
+ ));
return Status;
}
-
/**
Free the resources used by CapList.
@@ -702,14 +768,13 @@ FreeOutCapList:
VOID
EFIAPI
PciCapListUninit (
- IN PCI_CAP_LIST *CapList
+ IN PCI_CAP_LIST *CapList
)
{
EmptyAndUninitPciCapCollection (CapList->Capabilities, TRUE);
FreePool (CapList);
}
-
/**
Locate a capability instance in the parsed capabilities lists.
@@ -746,15 +811,15 @@ PciCapListUninit (
RETURN_STATUS
EFIAPI
PciCapListFindCap (
- IN PCI_CAP_LIST *CapList,
- IN PCI_CAP_DOMAIN Domain,
- IN UINT16 CapId,
- IN UINT16 Instance,
- OUT PCI_CAP **Cap OPTIONAL
+ IN PCI_CAP_LIST *CapList,
+ IN PCI_CAP_DOMAIN Domain,
+ IN UINT16 CapId,
+ IN UINT16 Instance,
+ OUT PCI_CAP **Cap OPTIONAL
)
{
- PCI_CAP_KEY Key;
- ORDERED_COLLECTION_ENTRY *PciCapEntry;
+ PCI_CAP_KEY Key;
+ ORDERED_COLLECTION_ENTRY *PciCapEntry;
Key.Domain = Domain;
Key.CapId = CapId;
@@ -764,13 +829,14 @@ PciCapListFindCap (
if (PciCapEntry == NULL) {
return RETURN_NOT_FOUND;
}
+
if (Cap != NULL) {
*Cap = OrderedCollectionUserStruct (PciCapEntry);
}
+
return RETURN_SUCCESS;
}
-
/**
Locate the first instance of the capability given by (Domain, CapId) such
that the instance's Version is greater than or equal to MinVersion.
@@ -807,15 +873,15 @@ PciCapListFindCap (
RETURN_STATUS
EFIAPI
PciCapListFindCapVersion (
- IN PCI_CAP_LIST *CapList,
- IN PCI_CAP_DOMAIN Domain,
- IN UINT16 CapId,
- IN UINT8 MinVersion,
- OUT PCI_CAP **Cap OPTIONAL
+ IN PCI_CAP_LIST *CapList,
+ IN PCI_CAP_DOMAIN Domain,
+ IN UINT16 CapId,
+ IN UINT8 MinVersion,
+ OUT PCI_CAP **Cap OPTIONAL
)
{
- PCI_CAP_KEY Key;
- ORDERED_COLLECTION_ENTRY *PciCapEntry;
+ PCI_CAP_KEY Key;
+ ORDERED_COLLECTION_ENTRY *PciCapEntry;
//
// Start the version checks at Instance#0 of (Domain, CapId).
@@ -826,8 +892,9 @@ PciCapListFindCapVersion (
for (PciCapEntry = OrderedCollectionFind (CapList->Capabilities, &Key);
PciCapEntry != NULL;
- PciCapEntry = OrderedCollectionNext (PciCapEntry)) {
- PCI_CAP *PciCap;
+ PciCapEntry = OrderedCollectionNext (PciCapEntry))
+ {
+ PCI_CAP *PciCap;
PciCap = OrderedCollectionUserStruct (PciCapEntry);
//
@@ -835,9 +902,10 @@ PciCapListFindCapVersion (
// adjacent to each other, so stop searching if either Domain or CapId
// changes.
//
- if (PciCap->Key.Domain != Domain || PciCap->Key.CapId != CapId) {
+ if ((PciCap->Key.Domain != Domain) || (PciCap->Key.CapId != CapId)) {
break;
}
+
if (PciCap->Version >= MinVersion) {
//
// Match found.
@@ -845,13 +913,14 @@ PciCapListFindCapVersion (
if (Cap != NULL) {
*Cap = PciCap;
}
+
return RETURN_SUCCESS;
}
}
+
return RETURN_NOT_FOUND;
}
-
/**
Get information about a PCI Capability instance.
@@ -869,11 +938,11 @@ PciCapListFindCapVersion (
RETURN_STATUS
EFIAPI
PciCapGetInfo (
- IN PCI_CAP *Cap,
- OUT PCI_CAP_INFO *Info
+ IN PCI_CAP *Cap,
+ OUT PCI_CAP_INFO *Info
)
{
- PCI_CAP *InstanceZero;
+ PCI_CAP *InstanceZero;
ASSERT (Info != NULL);
@@ -891,7 +960,6 @@ PciCapGetInfo (
return RETURN_SUCCESS;
}
-
/**
Read a slice of a capability instance.
@@ -931,11 +999,11 @@ PciCapGetInfo (
RETURN_STATUS
EFIAPI
PciCapRead (
- IN PCI_CAP_DEV *PciDevice,
- IN PCI_CAP *Cap,
- IN UINT16 SourceOffsetInCap,
- OUT VOID *DestinationBuffer,
- IN UINT16 Size
+ IN PCI_CAP_DEV *PciDevice,
+ IN PCI_CAP *Cap,
+ IN UINT16 SourceOffsetInCap,
+ OUT VOID *DestinationBuffer,
+ IN UINT16 Size
)
{
//
@@ -945,10 +1013,14 @@ PciCapRead (
if (SourceOffsetInCap + Size > Cap->MaxSizeHint) {
return RETURN_BAD_BUFFER_SIZE;
}
- return PciDevice->ReadConfig (PciDevice, Cap->Offset + SourceOffsetInCap,
- DestinationBuffer, Size);
-}
+ return PciDevice->ReadConfig (
+ PciDevice,
+ Cap->Offset + SourceOffsetInCap,
+ DestinationBuffer,
+ Size
+ );
+}
/**
Write a slice of a capability instance.
@@ -990,11 +1062,11 @@ PciCapRead (
RETURN_STATUS
EFIAPI
PciCapWrite (
- IN PCI_CAP_DEV *PciDevice,
- IN PCI_CAP *Cap,
- IN UINT16 DestinationOffsetInCap,
- IN VOID *SourceBuffer,
- IN UINT16 Size
+ IN PCI_CAP_DEV *PciDevice,
+ IN PCI_CAP *Cap,
+ IN UINT16 DestinationOffsetInCap,
+ IN VOID *SourceBuffer,
+ IN UINT16 Size
)
{
//
@@ -1004,7 +1076,11 @@ PciCapWrite (
if (DestinationOffsetInCap + Size > Cap->MaxSizeHint) {
return RETURN_BAD_BUFFER_SIZE;
}
- return PciDevice->WriteConfig (PciDevice,
- Cap->Offset + DestinationOffsetInCap, SourceBuffer,
- Size);
+
+ return PciDevice->WriteConfig (
+ PciDevice,
+ Cap->Offset + DestinationOffsetInCap,
+ SourceBuffer,
+ Size
+ );
}
diff --git a/OvmfPkg/Library/BasePciCapLib/BasePciCapLib.h b/OvmfPkg/Library/BasePciCapLib/BasePciCapLib.h
index e84dab62c5..b836fd593c 100644
--- a/OvmfPkg/Library/BasePciCapLib/BasePciCapLib.h
+++ b/OvmfPkg/Library/BasePciCapLib/BasePciCapLib.h
@@ -18,9 +18,9 @@
// for insertion and lookup.
//
typedef struct {
- PCI_CAP_DOMAIN Domain;
- UINT16 CapId;
- UINT16 Instance;
+ PCI_CAP_DOMAIN Domain;
+ UINT16 CapId;
+ UINT16 Instance;
} PCI_CAP_KEY;
//
@@ -29,26 +29,26 @@ typedef struct {
// NumInstances needs maintenance in one object only, per (Domain, CapId) pair.
//
typedef union {
- UINT16 NumInstances;
- PCI_CAP *InstanceZero;
+ UINT16 NumInstances;
+ PCI_CAP *InstanceZero;
} PCI_CAP_NUM_INSTANCES;
//
// Complete the incomplete PCI_CAP structure here.
//
struct PCI_CAP {
- PCI_CAP_KEY Key;
- PCI_CAP_NUM_INSTANCES NumInstancesUnion;
- UINT16 Offset;
- UINT16 MaxSizeHint;
- UINT8 Version;
+ PCI_CAP_KEY Key;
+ PCI_CAP_NUM_INSTANCES NumInstancesUnion;
+ UINT16 Offset;
+ UINT16 MaxSizeHint;
+ UINT8 Version;
};
//
// Complete the incomplete PCI_CAP_LIST structure here.
//
struct PCI_CAP_LIST {
- ORDERED_COLLECTION *Capabilities;
+ ORDERED_COLLECTION *Capabilities;
};
#endif // __BASE_PCI_CAP_LIB_H__
diff --git a/OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.c b/OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.c
index 81f2a3eb06..8e7ea583fa 100644
--- a/OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.c
+++ b/OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.c
@@ -14,7 +14,6 @@
#include "BasePciCapPciSegmentLib.h"
-
/**
Read the config space of a given PCI device (both normal and extended).
@@ -44,17 +43,17 @@ STATIC
RETURN_STATUS
EFIAPI
SegmentDevReadConfig (
- IN PCI_CAP_DEV *PciDevice,
- IN UINT16 SourceOffset,
- OUT VOID *DestinationBuffer,
- IN UINT16 Size
+ IN PCI_CAP_DEV *PciDevice,
+ IN UINT16 SourceOffset,
+ OUT VOID *DestinationBuffer,
+ IN UINT16 Size
)
{
- SEGMENT_DEV *SegmentDev;
- UINT16 ConfigSpaceSize;
- UINT64 SourceAddress;
+ SEGMENT_DEV *SegmentDev;
+ UINT16 ConfigSpaceSize;
+ UINT64 SourceAddress;
- SegmentDev = SEGMENT_DEV_FROM_PCI_CAP_DEV (PciDevice);
+ SegmentDev = SEGMENT_DEV_FROM_PCI_CAP_DEV (PciDevice);
ConfigSpaceSize = (SegmentDev->MaxDomain == PciCapNormal ?
PCI_MAX_CONFIG_OFFSET : PCI_EXP_MAX_CONFIG_OFFSET);
//
@@ -64,14 +63,18 @@ SegmentDevReadConfig (
if (SourceOffset + Size > ConfigSpaceSize) {
return RETURN_UNSUPPORTED;
}
- SourceAddress = PCI_SEGMENT_LIB_ADDRESS (SegmentDev->SegmentNr,
- SegmentDev->BusNr, SegmentDev->DeviceNr,
- SegmentDev->FunctionNr, SourceOffset);
+
+ SourceAddress = PCI_SEGMENT_LIB_ADDRESS (
+ SegmentDev->SegmentNr,
+ SegmentDev->BusNr,
+ SegmentDev->DeviceNr,
+ SegmentDev->FunctionNr,
+ SourceOffset
+ );
PciSegmentReadBuffer (SourceAddress, Size, DestinationBuffer);
return RETURN_SUCCESS;
}
-
/**
Write the config space of a given PCI device (both normal and extended).
@@ -101,17 +104,17 @@ STATIC
RETURN_STATUS
EFIAPI
SegmentDevWriteConfig (
- IN PCI_CAP_DEV *PciDevice,
- IN UINT16 DestinationOffset,
- IN VOID *SourceBuffer,
- IN UINT16 Size
+ IN PCI_CAP_DEV *PciDevice,
+ IN UINT16 DestinationOffset,
+ IN VOID *SourceBuffer,
+ IN UINT16 Size
)
{
- SEGMENT_DEV *SegmentDev;
- UINT16 ConfigSpaceSize;
- UINT64 DestinationAddress;
+ SEGMENT_DEV *SegmentDev;
+ UINT16 ConfigSpaceSize;
+ UINT64 DestinationAddress;
- SegmentDev = SEGMENT_DEV_FROM_PCI_CAP_DEV (PciDevice);
+ SegmentDev = SEGMENT_DEV_FROM_PCI_CAP_DEV (PciDevice);
ConfigSpaceSize = (SegmentDev->MaxDomain == PciCapNormal ?
PCI_MAX_CONFIG_OFFSET : PCI_EXP_MAX_CONFIG_OFFSET);
//
@@ -121,14 +124,18 @@ SegmentDevWriteConfig (
if (DestinationOffset + Size > ConfigSpaceSize) {
return RETURN_UNSUPPORTED;
}
- DestinationAddress = PCI_SEGMENT_LIB_ADDRESS (SegmentDev->SegmentNr,
- SegmentDev->BusNr, SegmentDev->DeviceNr,
- SegmentDev->FunctionNr, DestinationOffset);
+
+ DestinationAddress = PCI_SEGMENT_LIB_ADDRESS (
+ SegmentDev->SegmentNr,
+ SegmentDev->BusNr,
+ SegmentDev->DeviceNr,
+ SegmentDev->FunctionNr,
+ DestinationOffset
+ );
PciSegmentWriteBuffer (DestinationAddress, Size, SourceBuffer);
return RETURN_SUCCESS;
}
-
/**
Create a PCI_CAP_DEV object from the PCI Segment:Bus:Device.Function
quadruplet. The config space accessors are based upon PciSegmentLib.
@@ -168,17 +175,17 @@ SegmentDevWriteConfig (
RETURN_STATUS
EFIAPI
PciCapPciSegmentDeviceInit (
- IN PCI_CAP_DOMAIN MaxDomain,
- IN UINT16 Segment,
- IN UINT8 Bus,
- IN UINT8 Device,
- IN UINT8 Function,
- OUT PCI_CAP_DEV **PciDevice
+ IN PCI_CAP_DOMAIN MaxDomain,
+ IN UINT16 Segment,
+ IN UINT8 Bus,
+ IN UINT8 Device,
+ IN UINT8 Function,
+ OUT PCI_CAP_DEV **PciDevice
)
{
- SEGMENT_DEV *SegmentDev;
+ SEGMENT_DEV *SegmentDev;
- if (Device > PCI_MAX_DEVICE || Function > PCI_MAX_FUNC) {
+ if ((Device > PCI_MAX_DEVICE) || (Function > PCI_MAX_FUNC)) {
return RETURN_INVALID_PARAMETER;
}
@@ -200,7 +207,6 @@ PciCapPciSegmentDeviceInit (
return RETURN_SUCCESS;
}
-
/**
Free the resources used by PciDevice.
@@ -210,10 +216,10 @@ PciCapPciSegmentDeviceInit (
VOID
EFIAPI
PciCapPciSegmentDeviceUninit (
- IN PCI_CAP_DEV *PciDevice
+ IN PCI_CAP_DEV *PciDevice
)
{
- SEGMENT_DEV *SegmentDev;
+ SEGMENT_DEV *SegmentDev;
SegmentDev = SEGMENT_DEV_FROM_PCI_CAP_DEV (PciDevice);
FreePool (SegmentDev);
diff --git a/OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.h b/OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.h
index a806bf320d..5d587ceca3 100644
--- a/OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.h
+++ b/OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.h
@@ -14,25 +14,25 @@
#include <Library/PciCapPciSegmentLib.h>
-#define SEGMENT_DEV_SIG SIGNATURE_64 ('P', 'C', 'P', 'S', 'G', 'M', 'N', 'T')
+#define SEGMENT_DEV_SIG SIGNATURE_64 ('P', 'C', 'P', 'S', 'G', 'M', 'N', 'T')
typedef struct {
//
// Signature identifying the derived class.
//
- UINT64 Signature;
+ UINT64 Signature;
//
// Members added by the derived class, specific to the use of PciSegmentLib.
//
- PCI_CAP_DOMAIN MaxDomain;
- UINT16 SegmentNr;
- UINT8 BusNr;
- UINT8 DeviceNr;
- UINT8 FunctionNr;
+ PCI_CAP_DOMAIN MaxDomain;
+ UINT16 SegmentNr;
+ UINT8 BusNr;
+ UINT8 DeviceNr;
+ UINT8 FunctionNr;
//
// Base class.
//
- PCI_CAP_DEV BaseDevice;
+ PCI_CAP_DEV BaseDevice;
} SEGMENT_DEV;
#define SEGMENT_DEV_FROM_PCI_CAP_DEV(PciDevice) \
diff --git a/OvmfPkg/Library/BhyveFwCtlLib/BhyveFwCtlLib.c b/OvmfPkg/Library/BhyveFwCtlLib/BhyveFwCtlLib.c
index f1f7b2e0d2..cc3e64f0c4 100644
--- a/OvmfPkg/Library/BhyveFwCtlLib/BhyveFwCtlLib.c
+++ b/OvmfPkg/Library/BhyveFwCtlLib/BhyveFwCtlLib.c
@@ -18,15 +18,15 @@
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
-#define FW_PORT 0x510
-#define FW_IPORT 0x511
+#define FW_PORT 0x510
+#define FW_IPORT 0x511
/* Transport protocol basic operations */
-#define OP_NULL 1
-#define OP_ECHO 2
-#define OP_GET 3
-#define OP_GET_LEN 4
-#define OP_SET 5
+#define OP_NULL 1
+#define OP_ECHO 2
+#define OP_GET 3
+#define OP_GET_LEN 4
+#define OP_SET 5
/* Transport protocol error returns */
#define T_ESUCCESS 0
@@ -34,17 +34,17 @@
#define T_E2BIG 7
#define T_EMSGSIZE 40
-#define ROUNDUP(x, y) ((((x)+((y)-1))/(y))*(y))
+#define ROUNDUP(x, y) ((((x)+((y)-1))/(y))*(y))
-STATIC CONST CHAR8 mBhyveSig[4] = { 'B', 'H', 'Y', 'V' };
+STATIC CONST CHAR8 mBhyveSig[4] = { 'B', 'H', 'Y', 'V' };
-STATIC BOOLEAN mBhyveFwCtlSupported = FALSE;
+STATIC BOOLEAN mBhyveFwCtlSupported = FALSE;
-STATIC INT32 mBhyveFwCtlTxid = 0xa5;
+STATIC INT32 mBhyveFwCtlTxid = 0xa5;
/* XXX Maybe a better inbuilt version of this ? */
typedef struct {
- VOID *Base;
+ VOID *Base;
UINT32 Len;
} BIO_VEC;
@@ -59,27 +59,27 @@ STATIC
RETURN_STATUS
EFIAPI
BhyveFwCtl_CvtErr (
- IN UINT32 errno
+ IN UINT32 errno
)
{
- RETURN_STATUS Status;
+ RETURN_STATUS Status;
switch (errno) {
- case T_ESUCCESS:
- Status = RETURN_SUCCESS;
- break;
- case T_ENOENT:
- Status = RETURN_NOT_FOUND;
- break;
- case T_E2BIG:
- Status = RETURN_INVALID_PARAMETER;
- break;
- case T_EMSGSIZE:
- Status = RETURN_BUFFER_TOO_SMALL;
- break;
- default:
- Status = RETURN_PROTOCOL_ERROR;
- break;
+ case T_ESUCCESS:
+ Status = RETURN_SUCCESS;
+ break;
+ case T_ENOENT:
+ Status = RETURN_NOT_FOUND;
+ break;
+ case T_E2BIG:
+ Status = RETURN_INVALID_PARAMETER;
+ break;
+ case T_EMSGSIZE:
+ Status = RETURN_BUFFER_TOO_SMALL;
+ break;
+ default:
+ Status = RETURN_PROTOCOL_ERROR;
+ break;
}
return Status;
@@ -89,17 +89,18 @@ STATIC
UINT32
EFIAPI
BIov_WLen (
- IN BIO_VEC b[]
+ IN BIO_VEC b[]
)
{
- UINT32 i;
- UINT32 tLen;
+ UINT32 i;
+ UINT32 tLen;
tLen = 0;
if (b != NULL) {
- for (i = 0; b[i].Base != NULL; i++)
- tLen += ROUNDUP (b[i].Len, sizeof(UINT32));
+ for (i = 0; b[i].Base != NULL; i++) {
+ tLen += ROUNDUP (b[i].Len, sizeof (UINT32));
+ }
}
return tLen;
@@ -113,21 +114,22 @@ STATIC
UINT32
BIov_Send_Rem (
IN UINT32 *Data,
- IN UINT32 Len
+ IN UINT32 Len
)
{
union {
- UINT8 c[4];
+ UINT8 c[4];
UINT32 w;
} u;
- UINT8 *cdata;
- UINT32 i;
+ UINT8 *cdata;
+ UINT32 i;
cdata = (UINT8 *)Data;
- u.w = 0;
+ u.w = 0;
- for (i = 0; i < Len; i++)
+ for (i = 0; i < Len; i++) {
u.c[i] = *cdata++;
+ }
return u.w;
}
@@ -140,16 +142,16 @@ STATIC
VOID
BIov_Send (
IN char *Data,
- IN UINT32 Len
+ IN UINT32 Len
)
{
- UINT32 *LData;
+ UINT32 *LData;
LData = (UINT32 *)Data;
- while (Len > sizeof(UINT32)) {
+ while (Len > sizeof (UINT32)) {
IoWrite32 (FW_PORT, *LData++);
- Len -= sizeof(UINT32);
+ Len -= sizeof (UINT32);
}
if (Len > 0) {
@@ -163,10 +165,10 @@ BIov_Send (
STATIC
VOID
BIov_SendAll (
- IN BIO_VEC b[]
- )
+ IN BIO_VEC b[]
+ )
{
- INT32 i;
+ INT32 i;
if (b != NULL) {
for (i = 0; b[i].Base; i++) {
@@ -181,22 +183,23 @@ BIov_SendAll (
STATIC
VOID
EFIAPI
-BhyveFwCtl_MsgSend(
- IN UINT32 OpCode,
+BhyveFwCtl_MsgSend (
+ IN UINT32 OpCode,
IN BIO_VEC Data[]
)
{
BIO_VEC hIov[4];
- UINT32 Hdr[3];
- UINT32 i;
+ UINT32 Hdr[3];
+ UINT32 i;
/* Set up header as an iovec */
for (i = 0; i < 3; i++) {
hIov[i].Base = &Hdr[i];
- hIov[i].Len = sizeof(Hdr[0]);
+ hIov[i].Len = sizeof (Hdr[0]);
}
+
hIov[i].Base = NULL;
- hIov[i].Len = 0;
+ hIov[i].Len = 0;
/* Initialize header */
Hdr[0] = BIov_WLen (hIov) + BIov_WLen (Data);
@@ -214,13 +217,13 @@ BhyveFwCtl_MsgSend(
STATIC
RETURN_STATUS
EFIAPI
-BhyveFwCtl_MsgRecv(
- OUT MSG_RX_HDR *Rhdr,
- OUT BIO_VEC Data[]
+BhyveFwCtl_MsgRecv (
+ OUT MSG_RX_HDR *Rhdr,
+ OUT BIO_VEC Data[]
)
{
RETURN_STATUS Status;
- UINT32 *Dp;
+ UINT32 *Dp;
UINT32 Rd;
UINT32 remLen;
INT32 oLen;
@@ -228,7 +231,6 @@ BhyveFwCtl_MsgRecv(
Rd = IoRead32 (FW_PORT);
if (Rd < sizeof (MSG_RX_HDR)) {
- ;
}
/* Read in header and setup initial error */
@@ -241,7 +243,7 @@ BhyveFwCtl_MsgRecv(
Status = BhyveFwCtl_CvtErr (Rhdr->Err);
remLen = Rd - sizeof (MSG_RX_HDR);
- xLen = 0;
+ xLen = 0;
/*
* A few cases to handle:
@@ -250,47 +252,48 @@ BhyveFwCtl_MsgRecv(
* - the response is zero-length
*/
if (Data != NULL) {
- Dp = (UINT32 *)Data[0].Base;
+ Dp = (UINT32 *)Data[0].Base;
oLen = remLen;
if (remLen > Data[0].Len) {
Status = RETURN_BUFFER_TOO_SMALL;
- xLen = remLen - Data[0].Len;
- oLen = remLen = Data[0].Len;
+ xLen = remLen - Data[0].Len;
+ oLen = remLen = Data[0].Len;
}
+
while (remLen > 0) {
- *Dp++ = IoRead32 (FW_PORT);
+ *Dp++ = IoRead32 (FW_PORT);
remLen -= sizeof (UINT32);
}
+
Data[0].Len = oLen;
} else {
/* No user data, but data returned - drop */
if (remLen > 0) {
Status = RETURN_BUFFER_TOO_SMALL;
- xLen = remLen;
+ xLen = remLen;
}
}
/* Drop additional data */
while (xLen > 0) {
- (void) IoRead32 (FW_PORT);
+ (void)IoRead32 (FW_PORT);
xLen -= sizeof (UINT32);
}
return Status;
}
-
STATIC
RETURN_STATUS
EFIAPI
-BhyveFwCtl_Msg(
- IN UINT32 OpCode,
- IN BIO_VEC Sdata[],
- OUT BIO_VEC Rdata[]
- )
+BhyveFwCtl_Msg (
+ IN UINT32 OpCode,
+ IN BIO_VEC Sdata[],
+ OUT BIO_VEC Rdata[]
+ )
{
- MSG_RX_HDR Rh;
- RETURN_STATUS Status;
+ MSG_RX_HDR Rh;
+ RETURN_STATUS Status;
Status = RETURN_SUCCESS;
@@ -306,11 +309,11 @@ STATIC
RETURN_STATUS
EFIAPI
BhyveFwCtlGetLen (
- IN CONST CHAR8 *Name,
- IN OUT UINT32 *Size
+ IN CONST CHAR8 *Name,
+ IN OUT UINT32 *Size
)
{
- BIO_VEC Req[2], Resp[2];
+ BIO_VEC Req[2], Resp[2];
RETURN_STATUS Status;
Req[0].Base = (VOID *)Name;
@@ -326,7 +329,7 @@ BhyveFwCtlGetLen (
return Status;
}
-#define FMAXSZ 1024
+#define FMAXSZ 1024
STATIC struct {
UINT64 fSize;
UINT32 fData[FMAXSZ];
@@ -336,18 +339,19 @@ STATIC
RETURN_STATUS
EFIAPI
BhyveFwCtlGetVal (
- IN CONST CHAR8 *Name,
- OUT VOID *Item,
- IN OUT UINT32 *Size
+ IN CONST CHAR8 *Name,
+ OUT VOID *Item,
+ IN OUT UINT32 *Size
)
{
- BIO_VEC Req[2];
- BIO_VEC Resp[2];
+ BIO_VEC Req[2];
+ BIO_VEC Resp[2];
RETURN_STATUS Status;
/* Make sure temp buffer is larger than passed-in size */
- if (*Size > sizeof (FwGetvalBuf.fData))
- return RETURN_INVALID_PARAMETER;
+ if (*Size > sizeof (FwGetvalBuf.fData)) {
+ return RETURN_INVALID_PARAMETER;
+ }
Req[0].Base = (VOID *)Name;
Req[0].Len = (UINT32)AsciiStrLen (Name) + 1;
@@ -378,26 +382,26 @@ BhyveFwCtlGetVal (
RETURN_STATUS
EFIAPI
BhyveFwCtlGet (
- IN CONST CHAR8 *Name,
- OUT VOID *Item,
- IN OUT UINTN *Size
+ IN CONST CHAR8 *Name,
+ OUT VOID *Item,
+ IN OUT UINTN *Size
)
{
- RETURN_STATUS Status;
+ RETURN_STATUS Status;
- if (mBhyveFwCtlSupported == FALSE)
+ if (mBhyveFwCtlSupported == FALSE) {
return RETURN_UNSUPPORTED;
+ }
if (Item == NULL) {
- Status = BhyveFwCtlGetLen (Name, (UINT32*)Size);
+ Status = BhyveFwCtlGetLen (Name, (UINT32 *)Size);
} else {
- Status = BhyveFwCtlGetVal (Name, Item, (UINT32*)Size);
+ Status = BhyveFwCtlGetVal (Name, Item, (UINT32 *)Size);
}
return Status;
}
-
/**
Library initialization. Probe the host to see if the f/w ctl
interface is supported.
diff --git a/OvmfPkg/Library/BlobVerifierLibNull/BlobVerifierNull.c b/OvmfPkg/Library/BlobVerifierLibNull/BlobVerifierNull.c
index 975d4dd52f..e817c3cc95 100644
--- a/OvmfPkg/Library/BlobVerifierLibNull/BlobVerifierNull.c
+++ b/OvmfPkg/Library/BlobVerifierLibNull/BlobVerifierNull.c
@@ -24,9 +24,9 @@
EFI_STATUS
EFIAPI
VerifyBlob (
- IN CONST CHAR16 *BlobName,
- IN CONST VOID *Buf,
- IN UINT32 BufSize
+ IN CONST CHAR16 *BlobName,
+ IN CONST VOID *Buf,
+ IN UINT32 BufSize
)
{
return EFI_SUCCESS;
diff --git a/OvmfPkg/Library/DxePciLibI440FxQ35/PciLib.c b/OvmfPkg/Library/DxePciLibI440FxQ35/PciLib.c
index 1839f11f33..ab620688f1 100644
--- a/OvmfPkg/Library/DxePciLibI440FxQ35/PciLib.c
+++ b/OvmfPkg/Library/DxePciLibI440FxQ35/PciLib.c
@@ -15,7 +15,6 @@
**/
-
#include <Base.h>
#include <IndustryStandard/Q35MchIch9.h>
@@ -25,7 +24,7 @@
#include <Library/PciExpressLib.h>
#include <Library/PcdLib.h>
-STATIC BOOLEAN mRunningOnQ35;
+STATIC BOOLEAN mRunningOnQ35;
RETURN_STATUS
EFIAPI
@@ -88,7 +87,7 @@ PciRegisterForRuntimeAccess (
UINT8
EFIAPI
PciRead8 (
- IN UINTN Address
+ IN UINTN Address
)
{
return mRunningOnQ35 ?
@@ -115,8 +114,8 @@ PciRead8 (
UINT8
EFIAPI
PciWrite8 (
- IN UINTN Address,
- IN UINT8 Value
+ IN UINTN Address,
+ IN UINT8 Value
)
{
return mRunningOnQ35 ?
@@ -147,8 +146,8 @@ PciWrite8 (
UINT8
EFIAPI
PciOr8 (
- IN UINTN Address,
- IN UINT8 OrData
+ IN UINTN Address,
+ IN UINT8 OrData
)
{
return mRunningOnQ35 ?
@@ -179,8 +178,8 @@ PciOr8 (
UINT8
EFIAPI
PciAnd8 (
- IN UINTN Address,
- IN UINT8 AndData
+ IN UINTN Address,
+ IN UINT8 AndData
)
{
return mRunningOnQ35 ?
@@ -213,9 +212,9 @@ PciAnd8 (
UINT8
EFIAPI
PciAndThenOr8 (
- IN UINTN Address,
- IN UINT8 AndData,
- IN UINT8 OrData
+ IN UINTN Address,
+ IN UINT8 AndData,
+ IN UINT8 OrData
)
{
return mRunningOnQ35 ?
@@ -247,9 +246,9 @@ PciAndThenOr8 (
UINT8
EFIAPI
PciBitFieldRead8 (
- IN UINTN Address,
- IN UINTN StartBit,
- IN UINTN EndBit
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit
)
{
return mRunningOnQ35 ?
@@ -284,10 +283,10 @@ PciBitFieldRead8 (
UINT8
EFIAPI
PciBitFieldWrite8 (
- IN UINTN Address,
- IN UINTN StartBit,
- IN UINTN EndBit,
- IN UINT8 Value
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 Value
)
{
return mRunningOnQ35 ?
@@ -325,10 +324,10 @@ PciBitFieldWrite8 (
UINT8
EFIAPI
PciBitFieldOr8 (
- IN UINTN Address,
- IN UINTN StartBit,
- IN UINTN EndBit,
- IN UINT8 OrData
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 OrData
)
{
return mRunningOnQ35 ?
@@ -366,10 +365,10 @@ PciBitFieldOr8 (
UINT8
EFIAPI
PciBitFieldAnd8 (
- IN UINTN Address,
- IN UINTN StartBit,
- IN UINTN EndBit,
- IN UINT8 AndData
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 AndData
)
{
return mRunningOnQ35 ?
@@ -411,11 +410,11 @@ PciBitFieldAnd8 (
UINT8
EFIAPI
PciBitFieldAndThenOr8 (
- IN UINTN Address,
- IN UINTN StartBit,
- IN UINTN EndBit,
- IN UINT8 AndData,
- IN UINT8 OrData
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 AndData,
+ IN UINT8 OrData
)
{
return mRunningOnQ35 ?
@@ -442,7 +441,7 @@ PciBitFieldAndThenOr8 (
UINT16
EFIAPI
PciRead16 (
- IN UINTN Address
+ IN UINTN Address
)
{
return mRunningOnQ35 ?
@@ -470,8 +469,8 @@ PciRead16 (
UINT16
EFIAPI
PciWrite16 (
- IN UINTN Address,
- IN UINT16 Value
+ IN UINTN Address,
+ IN UINT16 Value
)
{
return mRunningOnQ35 ?
@@ -503,8 +502,8 @@ PciWrite16 (
UINT16
EFIAPI
PciOr16 (
- IN UINTN Address,
- IN UINT16 OrData
+ IN UINTN Address,
+ IN UINT16 OrData
)
{
return mRunningOnQ35 ?
@@ -536,8 +535,8 @@ PciOr16 (
UINT16
EFIAPI
PciAnd16 (
- IN UINTN Address,
- IN UINT16 AndData
+ IN UINTN Address,
+ IN UINT16 AndData
)
{
return mRunningOnQ35 ?
@@ -571,9 +570,9 @@ PciAnd16 (
UINT16
EFIAPI
PciAndThenOr16 (
- IN UINTN Address,
- IN UINT16 AndData,
- IN UINT16 OrData
+ IN UINTN Address,
+ IN UINT16 AndData,
+ IN UINT16 OrData
)
{
return mRunningOnQ35 ?
@@ -606,9 +605,9 @@ PciAndThenOr16 (
UINT16
EFIAPI
PciBitFieldRead16 (
- IN UINTN Address,
- IN UINTN StartBit,
- IN UINTN EndBit
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit
)
{
return mRunningOnQ35 ?
@@ -644,10 +643,10 @@ PciBitFieldRead16 (
UINT16
EFIAPI
PciBitFieldWrite16 (
- IN UINTN Address,
- IN UINTN StartBit,
- IN UINTN EndBit,
- IN UINT16 Value
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 Value
)
{
return mRunningOnQ35 ?
@@ -686,10 +685,10 @@ PciBitFieldWrite16 (
UINT16
EFIAPI
PciBitFieldOr16 (
- IN UINTN Address,
- IN UINTN StartBit,
- IN UINTN EndBit,
- IN UINT16 OrData
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 OrData
)
{
return mRunningOnQ35 ?
@@ -728,10 +727,10 @@ PciBitFieldOr16 (
UINT16
EFIAPI
PciBitFieldAnd16 (
- IN UINTN Address,
- IN UINTN StartBit,
- IN UINTN EndBit,
- IN UINT16 AndData
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 AndData
)
{
return mRunningOnQ35 ?
@@ -774,11 +773,11 @@ PciBitFieldAnd16 (
UINT16
EFIAPI
PciBitFieldAndThenOr16 (
- IN UINTN Address,
- IN UINTN StartBit,
- IN UINTN EndBit,
- IN UINT16 AndData,
- IN UINT16 OrData
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 AndData,
+ IN UINT16 OrData
)
{
return mRunningOnQ35 ?
@@ -805,7 +804,7 @@ PciBitFieldAndThenOr16 (
UINT32
EFIAPI
PciRead32 (
- IN UINTN Address
+ IN UINTN Address
)
{
return mRunningOnQ35 ?
@@ -833,8 +832,8 @@ PciRead32 (
UINT32
EFIAPI
PciWrite32 (
- IN UINTN Address,
- IN UINT32 Value
+ IN UINTN Address,
+ IN UINT32 Value
)
{
return mRunningOnQ35 ?
@@ -866,8 +865,8 @@ PciWrite32 (
UINT32
EFIAPI
PciOr32 (
- IN UINTN Address,
- IN UINT32 OrData
+ IN UINTN Address,
+ IN UINT32 OrData
)
{
return mRunningOnQ35 ?
@@ -899,8 +898,8 @@ PciOr32 (
UINT32
EFIAPI
PciAnd32 (
- IN UINTN Address,
- IN UINT32 AndData
+ IN UINTN Address,
+ IN UINT32 AndData
)
{
return mRunningOnQ35 ?
@@ -934,9 +933,9 @@ PciAnd32 (
UINT32
EFIAPI
PciAndThenOr32 (
- IN UINTN Address,
- IN UINT32 AndData,
- IN UINT32 OrData
+ IN UINTN Address,
+ IN UINT32 AndData,
+ IN UINT32 OrData
)
{
return mRunningOnQ35 ?
@@ -969,9 +968,9 @@ PciAndThenOr32 (
UINT32
EFIAPI
PciBitFieldRead32 (
- IN UINTN Address,
- IN UINTN StartBit,
- IN UINTN EndBit
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit
)
{
return mRunningOnQ35 ?
@@ -1007,10 +1006,10 @@ PciBitFieldRead32 (
UINT32
EFIAPI
PciBitFieldWrite32 (
- IN UINTN Address,
- IN UINTN StartBit,
- IN UINTN EndBit,
- IN UINT32 Value
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 Value
)
{
return mRunningOnQ35 ?
@@ -1049,10 +1048,10 @@ PciBitFieldWrite32 (
UINT32
EFIAPI
PciBitFieldOr32 (
- IN UINTN Address,
- IN UINTN StartBit,
- IN UINTN EndBit,
- IN UINT32 OrData
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 OrData
)
{
return mRunningOnQ35 ?
@@ -1091,10 +1090,10 @@ PciBitFieldOr32 (
UINT32
EFIAPI
PciBitFieldAnd32 (
- IN UINTN Address,
- IN UINTN StartBit,
- IN UINTN EndBit,
- IN UINT32 AndData
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 AndData
)
{
return mRunningOnQ35 ?
@@ -1137,11 +1136,11 @@ PciBitFieldAnd32 (
UINT32
EFIAPI
PciBitFieldAndThenOr32 (
- IN UINTN Address,
- IN UINTN StartBit,
- IN UINTN EndBit,
- IN UINT32 AndData,
- IN UINT32 OrData
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 AndData,
+ IN UINT32 OrData
)
{
return mRunningOnQ35 ?
@@ -1175,9 +1174,9 @@ PciBitFieldAndThenOr32 (
UINTN
EFIAPI
PciReadBuffer (
- IN UINTN StartAddress,
- IN UINTN Size,
- OUT VOID *Buffer
+ IN UINTN StartAddress,
+ IN UINTN Size,
+ OUT VOID *Buffer
)
{
return mRunningOnQ35 ?
@@ -1212,9 +1211,9 @@ PciReadBuffer (
UINTN
EFIAPI
PciWriteBuffer (
- IN UINTN StartAddress,
- IN UINTN Size,
- IN VOID *Buffer
+ IN UINTN StartAddress,
+ IN UINTN Size,
+ IN VOID *Buffer
)
{
return mRunningOnQ35 ?
diff --git a/OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.c b/OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.c
index 9c890013e3..9840676ff8 100644
--- a/OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.c
+++ b/OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.c
@@ -13,7 +13,6 @@
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeLib.h>
-
/**
This function will be called following a call to the
EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL Read function.
@@ -30,16 +29,15 @@
VOID
EFIAPI
PlatformFvbDataRead (
- IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,
- IN EFI_LBA Lba,
- IN UINTN Offset,
- IN UINTN NumBytes,
- IN UINT8 *Buffer
+ IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,
+ IN EFI_LBA Lba,
+ IN UINTN Offset,
+ IN UINTN NumBytes,
+ IN UINT8 *Buffer
)
{
}
-
/**
This function will be called following a call to the
EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL Write function.
@@ -54,26 +52,26 @@ PlatformFvbDataRead (
VOID
EFIAPI
PlatformFvbDataWritten (
- IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,
- IN EFI_LBA Lba,
- IN UINTN Offset,
- IN UINTN NumBytes,
- IN UINT8 *Buffer
+ IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,
+ IN EFI_LBA Lba,
+ IN UINTN Offset,
+ IN UINTN NumBytes,
+ IN UINT8 *Buffer
)
{
- STATIC EFI_EVENT EventToSignal = NULL;
+ STATIC EFI_EVENT EventToSignal = NULL;
if (!EfiAtRuntime ()) {
if (EventToSignal == NULL) {
- EventToSignal = (EFI_EVENT)(UINTN) PcdGet64 (PcdEmuVariableEvent);
+ EventToSignal = (EFI_EVENT)(UINTN)PcdGet64 (PcdEmuVariableEvent);
}
+
if (EventToSignal != NULL) {
gBS->SignalEvent (EventToSignal);
}
}
}
-
/**
This function will be called following a call to the
EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL Erase function.
@@ -88,10 +86,8 @@ PlatformFvbDataWritten (
VOID
EFIAPI
PlatformFvbBlocksErased (
- IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,
- IN VA_LIST List
+ IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,
+ IN VA_LIST List
)
{
}
-
-
diff --git a/OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c b/OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c
index 66e029397b..c751b10679 100644
--- a/OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c
+++ b/OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c
@@ -22,49 +22,49 @@
#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;
typedef struct {
- VENDOR_DEVICE_PATH VenMediaNode;
- EFI_DEVICE_PATH_PROTOCOL EndNode;
+ VENDOR_DEVICE_PATH VenMediaNode;
+ EFI_DEVICE_PATH_PROTOCOL EndNode;
} SINGLE_VENMEDIA_NODE_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) }
}
};
-STATIC CONST SINGLE_VENMEDIA_NODE_DEVPATH mQemuKernelLoaderFsDevicePath = {
+STATIC CONST SINGLE_VENMEDIA_NODE_DEVPATH mQemuKernelLoaderFsDevicePath = {
{
{
MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP,
- { sizeof (VENDOR_DEVICE_PATH) }
+ { sizeof (VENDOR_DEVICE_PATH) }
},
QEMU_KERNEL_LOADER_FS_MEDIA_GUID
- }, {
+ }, {
END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE,
{ sizeof (EFI_DEVICE_PATH_PROTOCOL) }
}
@@ -73,28 +73,31 @@ STATIC CONST SINGLE_VENMEDIA_NODE_DEVPATH mQemuKernelLoaderFsDevicePath = {
STATIC
EFI_STATUS
GetQemuKernelLoaderBlobSize (
- IN EFI_FILE_HANDLE Root,
- IN CHAR16 *FileName,
- OUT UINTN *Size
+ IN EFI_FILE_HANDLE Root,
+ IN CHAR16 *FileName,
+ OUT UINTN *Size
)
{
- EFI_STATUS Status;
- EFI_FILE_HANDLE FileHandle;
- UINT64 FileSize;
+ EFI_STATUS Status;
+ EFI_FILE_HANDLE FileHandle;
+ UINT64 FileSize;
Status = Root->Open (Root, &FileHandle, FileName, EFI_FILE_MODE_READ, 0);
if (EFI_ERROR (Status)) {
return Status;
}
+
Status = FileHandleGetSize (FileHandle, &FileSize);
if (EFI_ERROR (Status)) {
goto CloseFile;
}
+
if (FileSize > MAX_UINTN) {
Status = EFI_UNSUPPORTED;
goto CloseFile;
}
- *Size = (UINTN)FileSize;
+
+ *Size = (UINTN)FileSize;
Status = EFI_SUCCESS;
CloseFile:
FileHandle->Close (FileHandle);
@@ -104,29 +107,32 @@ CloseFile:
STATIC
EFI_STATUS
ReadWholeQemuKernelLoaderBlob (
- IN EFI_FILE_HANDLE Root,
- IN CHAR16 *FileName,
- IN UINTN Size,
- OUT VOID *Buffer
+ IN EFI_FILE_HANDLE Root,
+ IN CHAR16 *FileName,
+ IN UINTN Size,
+ OUT VOID *Buffer
)
{
- EFI_STATUS Status;
- EFI_FILE_HANDLE FileHandle;
- UINTN ReadSize;
+ EFI_STATUS Status;
+ EFI_FILE_HANDLE FileHandle;
+ UINTN ReadSize;
Status = Root->Open (Root, &FileHandle, FileName, EFI_FILE_MODE_READ, 0);
if (EFI_ERROR (Status)) {
return Status;
}
+
ReadSize = Size;
- Status = FileHandle->Read (FileHandle, &ReadSize, Buffer);
+ Status = FileHandle->Read (FileHandle, &ReadSize, Buffer);
if (EFI_ERROR (Status)) {
goto CloseFile;
}
+
if (ReadSize != Size) {
Status = EFI_PROTOCOL_ERROR;
goto CloseFile;
}
+
Status = EFI_SUCCESS;
CloseFile:
FileHandle->Close (FileHandle);
@@ -155,19 +161,19 @@ CloseFile:
EFI_STATUS
EFIAPI
QemuLoadKernelImage (
- OUT EFI_HANDLE *ImageHandle
+ OUT EFI_HANDLE *ImageHandle
)
{
- EFI_STATUS Status;
- EFI_HANDLE KernelImageHandle;
- EFI_LOADED_IMAGE_PROTOCOL *KernelLoadedImage;
- EFI_DEVICE_PATH_PROTOCOL *DevicePathNode;
- EFI_HANDLE FsVolumeHandle;
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *FsProtocol;
- EFI_FILE_HANDLE Root;
- UINTN CommandLineSize;
- CHAR8 *CommandLine;
- UINTN InitrdSize;
+ EFI_STATUS Status;
+ EFI_HANDLE KernelImageHandle;
+ EFI_LOADED_IMAGE_PROTOCOL *KernelLoadedImage;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePathNode;
+ EFI_HANDLE FsVolumeHandle;
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *FsProtocol;
+ EFI_FILE_HANDLE Root;
+ UINTN CommandLineSize;
+ CHAR8 *CommandLine;
+ UINTN InitrdSize;
//
// Load the image. This should call back into the QEMU EFI loader file system.
@@ -181,20 +187,24 @@ QemuLoadKernelImage (
&KernelImageHandle
);
switch (Status) {
- case EFI_SUCCESS:
- break;
-
- case EFI_SECURITY_VIOLATION:
- //
- // In this case, the image was loaded but failed to authenticate.
- //
- Status = EFI_ACCESS_DENIED;
- goto UnloadImage;
-
- default:
- DEBUG ((Status == EFI_NOT_FOUND ? DEBUG_INFO : DEBUG_ERROR,
- "%a: LoadImage(): %r\n", __FUNCTION__, Status));
- return Status;
+ case EFI_SUCCESS:
+ break;
+
+ case EFI_SECURITY_VIOLATION:
+ //
+ // In this case, the image was loaded but failed to authenticate.
+ //
+ Status = EFI_ACCESS_DENIED;
+ goto UnloadImage;
+
+ default:
+ DEBUG ((
+ Status == EFI_NOT_FOUND ? DEBUG_INFO : DEBUG_ERROR,
+ "%a: LoadImage(): %r\n",
+ __FUNCTION__,
+ Status
+ ));
+ return Status;
}
//
@@ -215,11 +225,11 @@ QemuLoadKernelImage (
// used to query the "initrd" and to read the "cmdline" synthetic files.
//
DevicePathNode = (EFI_DEVICE_PATH_PROTOCOL *)&mQemuKernelLoaderFsDevicePath;
- Status = gBS->LocateDevicePath (
- &gEfiSimpleFileSystemProtocolGuid,
- &DevicePathNode,
- &FsVolumeHandle
- );
+ Status = gBS->LocateDevicePath (
+ &gEfiSimpleFileSystemProtocolGuid,
+ &DevicePathNode,
+ &FsVolumeHandle
+ );
if (EFI_ERROR (Status)) {
goto UnloadImage;
}
@@ -252,8 +262,12 @@ QemuLoadKernelImage (
goto CloseRoot;
}
- Status = ReadWholeQemuKernelLoaderBlob (Root, L"cmdline", CommandLineSize,
- CommandLine);
+ Status = ReadWholeQemuKernelLoaderBlob (
+ Root,
+ L"cmdline",
+ CommandLineSize,
+ CommandLine
+ );
if (EFI_ERROR (Status)) {
goto FreeCommandLine;
}
@@ -262,8 +276,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;
}
@@ -295,10 +312,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;
}
@@ -309,17 +327,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);
}
+
CloseRoot:
Root->Close (Root);
UnloadImage:
@@ -348,7 +371,7 @@ UnloadImage:
EFI_STATUS
EFIAPI
QemuStartKernelImage (
- IN OUT EFI_HANDLE *ImageHandle
+ IN OUT EFI_HANDLE *ImageHandle
)
{
return gBS->StartImage (
@@ -374,11 +397,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,
@@ -396,6 +419,7 @@ QemuUnloadKernelImage (
FreePool (KernelLoadedImage->LoadOptions);
KernelLoadedImage->LoadOptions = NULL;
}
+
KernelLoadedImage->LoadOptionsSize = 0;
return gBS->UnloadImage (ImageHandle);
diff --git a/OvmfPkg/Library/LoadLinuxLib/Linux.c b/OvmfPkg/Library/LoadLinuxLib/Linux.c
index c5022f6636..ce3d760380 100644
--- a/OvmfPkg/Library/LoadLinuxLib/Linux.c
+++ b/OvmfPkg/Library/LoadLinuxLib/Linux.c
@@ -8,7 +8,6 @@
#include "LoadLinuxLib.h"
-
/**
A simple check of the kernel setup image
@@ -26,21 +25,20 @@ STATIC
EFI_STATUS
EFIAPI
BasicKernelSetupCheck (
- IN VOID *KernelSetup
+ IN VOID *KernelSetup
)
{
- return LoadLinuxCheckKernelSetup(KernelSetup, sizeof (struct boot_params));
+ return LoadLinuxCheckKernelSetup (KernelSetup, sizeof (struct boot_params));
}
-
EFI_STATUS
EFIAPI
LoadLinuxCheckKernelSetup (
- IN VOID *KernelSetup,
- IN UINTN KernelSetupSize
+ IN VOID *KernelSetup,
+ IN UINTN KernelSetupSize
)
{
- struct boot_params *Bp;
+ struct boot_params *Bp;
if (KernelSetup == NULL) {
return EFI_INVALID_PARAMETER;
@@ -50,34 +48,34 @@ LoadLinuxCheckKernelSetup (
return EFI_UNSUPPORTED;
}
- Bp = (struct boot_params*) KernelSetup;
+ Bp = (struct boot_params *)KernelSetup;
if ((Bp->hdr.signature != 0xAA55) || // Check boot sector signature
(Bp->hdr.header != SETUP_HDR) ||
(Bp->hdr.version < 0x205) || // We only support relocatable kernels
(!Bp->hdr.relocatable_kernel)
- ) {
+ )
+ {
return EFI_UNSUPPORTED;
} else {
return EFI_SUCCESS;
}
}
-
UINTN
EFIAPI
LoadLinuxGetKernelSize (
- IN VOID *KernelSetup,
- IN UINTN KernelSize
+ IN VOID *KernelSetup,
+ IN UINTN KernelSize
)
{
- struct boot_params *Bp;
+ struct boot_params *Bp;
if (EFI_ERROR (BasicKernelSetupCheck (KernelSetup))) {
return 0;
}
- Bp = (struct boot_params*) KernelSetup;
+ Bp = (struct boot_params *)KernelSetup;
if (Bp->hdr.version > 0x20a) {
return Bp->hdr.init_size;
@@ -89,25 +87,24 @@ LoadLinuxGetKernelSize (
}
}
-
-VOID*
+VOID *
EFIAPI
LoadLinuxAllocateKernelSetupPages (
- IN UINTN Pages
+ IN UINTN Pages
)
{
- EFI_STATUS Status;
- EFI_PHYSICAL_ADDRESS Address;
+ EFI_STATUS Status;
+ EFI_PHYSICAL_ADDRESS Address;
Address = BASE_1GB;
- Status = gBS->AllocatePages (
- AllocateMaxAddress,
- EfiLoaderData,
- Pages,
- &Address
- );
+ Status = gBS->AllocatePages (
+ AllocateMaxAddress,
+ EfiLoaderData,
+ Pages,
+ &Address
+ );
if (!EFI_ERROR (Status)) {
- return (VOID*)(UINTN) Address;
+ return (VOID *)(UINTN)Address;
} else {
return NULL;
}
@@ -116,19 +113,19 @@ LoadLinuxAllocateKernelSetupPages (
EFI_STATUS
EFIAPI
LoadLinuxInitializeKernelSetup (
- IN VOID *KernelSetup
+ IN VOID *KernelSetup
)
{
- EFI_STATUS Status;
- UINTN SetupEnd;
- struct boot_params *Bp;
+ EFI_STATUS Status;
+ UINTN SetupEnd;
+ struct boot_params *Bp;
Status = BasicKernelSetupCheck (KernelSetup);
if (EFI_ERROR (Status)) {
return Status;
}
- Bp = (struct boot_params*) KernelSetup;
+ Bp = (struct boot_params *)KernelSetup;
SetupEnd = 0x202 + (Bp->hdr.jump & 0xff);
@@ -137,29 +134,32 @@ LoadLinuxInitializeKernelSetup (
//
ZeroMem (KernelSetup, 0x1f1);
ZeroMem (((UINT8 *)KernelSetup) + SetupEnd, 4096 - SetupEnd);
- DEBUG ((DEBUG_INFO, "Cleared kernel setup 0-0x1f1, 0x%Lx-0x1000\n",
- (UINT64)SetupEnd));
+ DEBUG ((
+ DEBUG_INFO,
+ "Cleared kernel setup 0-0x1f1, 0x%Lx-0x1000\n",
+ (UINT64)SetupEnd
+ ));
return EFI_SUCCESS;
}
-VOID*
+VOID *
EFIAPI
LoadLinuxAllocateKernelPages (
- IN VOID *KernelSetup,
- IN UINTN Pages
+ IN VOID *KernelSetup,
+ IN UINTN Pages
)
{
- EFI_STATUS Status;
- EFI_PHYSICAL_ADDRESS KernelAddress;
- UINT32 Loop;
- struct boot_params *Bp;
+ EFI_STATUS Status;
+ EFI_PHYSICAL_ADDRESS KernelAddress;
+ UINT32 Loop;
+ struct boot_params *Bp;
if (EFI_ERROR (BasicKernelSetupCheck (KernelSetup))) {
return NULL;
}
- Bp = (struct boot_params*) KernelSetup;
+ Bp = (struct boot_params *)KernelSetup;
for (Loop = 1; Loop < 512; Loop++) {
KernelAddress = MultU64x32 (
@@ -173,113 +173,110 @@ LoadLinuxAllocateKernelPages (
&KernelAddress
);
if (!EFI_ERROR (Status)) {
- return (VOID*)(UINTN) KernelAddress;
+ return (VOID *)(UINTN)KernelAddress;
}
}
return NULL;
}
-
-VOID*
+VOID *
EFIAPI
LoadLinuxAllocateCommandLinePages (
- IN UINTN Pages
+ IN UINTN Pages
)
{
- EFI_STATUS Status;
- EFI_PHYSICAL_ADDRESS Address;
+ EFI_STATUS Status;
+ EFI_PHYSICAL_ADDRESS Address;
Address = 0xa0000;
- Status = gBS->AllocatePages (
- AllocateMaxAddress,
- EfiLoaderData,
- Pages,
- &Address
- );
+ Status = gBS->AllocatePages (
+ AllocateMaxAddress,
+ EfiLoaderData,
+ Pages,
+ &Address
+ );
if (!EFI_ERROR (Status)) {
- return (VOID*)(UINTN) Address;
+ return (VOID *)(UINTN)Address;
} else {
return NULL;
}
}
-
-VOID*
+VOID *
EFIAPI
LoadLinuxAllocateInitrdPages (
- IN VOID *KernelSetup,
- IN UINTN Pages
+ IN VOID *KernelSetup,
+ IN UINTN Pages
)
{
- EFI_STATUS Status;
- EFI_PHYSICAL_ADDRESS Address;
+ EFI_STATUS Status;
+ EFI_PHYSICAL_ADDRESS Address;
- struct boot_params *Bp;
+ struct boot_params *Bp;
if (EFI_ERROR (BasicKernelSetupCheck (KernelSetup))) {
return NULL;
}
- Bp = (struct boot_params*) KernelSetup;
+ Bp = (struct boot_params *)KernelSetup;
- Address = (EFI_PHYSICAL_ADDRESS)(UINTN) Bp->hdr.ramdisk_max;
- Status = gBS->AllocatePages (
- AllocateMaxAddress,
- EfiLoaderData,
- Pages,
- &Address
- );
+ Address = (EFI_PHYSICAL_ADDRESS)(UINTN)Bp->hdr.ramdisk_max;
+ Status = gBS->AllocatePages (
+ AllocateMaxAddress,
+ EfiLoaderData,
+ Pages,
+ &Address
+ );
if (!EFI_ERROR (Status)) {
- return (VOID*)(UINTN) Address;
+ return (VOID *)(UINTN)Address;
} else {
return NULL;
}
}
-
STATIC
VOID
SetupLinuxMemmap (
- IN OUT struct boot_params *Bp
+ IN OUT struct boot_params *Bp
)
{
- EFI_STATUS Status;
- UINT8 TmpMemoryMap[1];
- UINTN MapKey;
- UINTN DescriptorSize;
- UINT32 DescriptorVersion;
- UINTN MemoryMapSize;
- EFI_MEMORY_DESCRIPTOR *MemoryMap;
- EFI_MEMORY_DESCRIPTOR *MemoryMapPtr;
- UINTN Index;
- struct efi_info *Efi;
- struct e820_entry *LastE820;
- struct e820_entry *E820;
- UINTN E820EntryCount;
- EFI_PHYSICAL_ADDRESS LastEndAddr;
+ EFI_STATUS Status;
+ UINT8 TmpMemoryMap[1];
+ UINTN MapKey;
+ UINTN DescriptorSize;
+ UINT32 DescriptorVersion;
+ UINTN MemoryMapSize;
+ EFI_MEMORY_DESCRIPTOR *MemoryMap;
+ EFI_MEMORY_DESCRIPTOR *MemoryMapPtr;
+ UINTN Index;
+ struct efi_info *Efi;
+ struct e820_entry *LastE820;
+ struct e820_entry *E820;
+ UINTN E820EntryCount;
+ EFI_PHYSICAL_ADDRESS LastEndAddr;
//
// Get System MemoryMapSize
//
MemoryMapSize = sizeof (TmpMemoryMap);
- Status = gBS->GetMemoryMap (
- &MemoryMapSize,
- (EFI_MEMORY_DESCRIPTOR *)TmpMemoryMap,
- &MapKey,
- &DescriptorSize,
- &DescriptorVersion
- );
+ Status = gBS->GetMemoryMap (
+ &MemoryMapSize,
+ (EFI_MEMORY_DESCRIPTOR *)TmpMemoryMap,
+ &MapKey,
+ &DescriptorSize,
+ &DescriptorVersion
+ );
ASSERT (Status == EFI_BUFFER_TOO_SMALL);
//
// Enlarge space here, because we will allocate pool now.
//
MemoryMapSize += EFI_PAGE_SIZE;
- Status = gBS->AllocatePool (
- EfiLoaderData,
- MemoryMapSize,
- (VOID **) &MemoryMap
- );
+ Status = gBS->AllocatePool (
+ EfiLoaderData,
+ MemoryMapSize,
+ (VOID **)&MemoryMap
+ );
ASSERT_EFI_ERROR (Status);
//
@@ -294,70 +291,72 @@ SetupLinuxMemmap (
);
ASSERT_EFI_ERROR (Status);
- LastE820 = NULL;
- E820 = &Bp->e820_map[0];
+ LastE820 = NULL;
+ E820 = &Bp->e820_map[0];
E820EntryCount = 0;
- LastEndAddr = 0;
- MemoryMapPtr = MemoryMap;
+ LastEndAddr = 0;
+ MemoryMapPtr = MemoryMap;
for (Index = 0; Index < (MemoryMapSize / DescriptorSize); Index++) {
- UINTN E820Type = 0;
+ UINTN E820Type = 0;
if (MemoryMap->NumberOfPages == 0) {
continue;
}
- switch(MemoryMap->Type) {
- case EfiReservedMemoryType:
- case EfiRuntimeServicesCode:
- case EfiRuntimeServicesData:
- case EfiMemoryMappedIO:
- case EfiMemoryMappedIOPortSpace:
- case EfiPalCode:
- E820Type = E820_RESERVED;
- break;
-
- case EfiUnusableMemory:
- E820Type = E820_UNUSABLE;
- break;
-
- case EfiACPIReclaimMemory:
- E820Type = E820_ACPI;
- break;
-
- case EfiLoaderCode:
- case EfiLoaderData:
- case EfiBootServicesCode:
- case EfiBootServicesData:
- case EfiConventionalMemory:
- E820Type = E820_RAM;
- break;
-
- case EfiACPIMemoryNVS:
- E820Type = E820_NVS;
- break;
-
- default:
- DEBUG ((
- DEBUG_ERROR,
- "Invalid EFI memory descriptor type (0x%x)!\n",
- MemoryMap->Type
- ));
- continue;
+ switch (MemoryMap->Type) {
+ case EfiReservedMemoryType:
+ case EfiRuntimeServicesCode:
+ case EfiRuntimeServicesData:
+ case EfiMemoryMappedIO:
+ case EfiMemoryMappedIOPortSpace:
+ case EfiPalCode:
+ E820Type = E820_RESERVED;
+ break;
+
+ case EfiUnusableMemory:
+ E820Type = E820_UNUSABLE;
+ break;
+
+ case EfiACPIReclaimMemory:
+ E820Type = E820_ACPI;
+ break;
+
+ case EfiLoaderCode:
+ case EfiLoaderData:
+ case EfiBootServicesCode:
+ case EfiBootServicesData:
+ case EfiConventionalMemory:
+ E820Type = E820_RAM;
+ break;
+
+ case EfiACPIMemoryNVS:
+ E820Type = E820_NVS;
+ break;
+
+ default:
+ DEBUG ((
+ DEBUG_ERROR,
+ "Invalid EFI memory descriptor type (0x%x)!\n",
+ MemoryMap->Type
+ ));
+ continue;
}
if ((LastE820 != NULL) &&
- (LastE820->type == (UINT32) E820Type) &&
- (MemoryMap->PhysicalStart == LastEndAddr)) {
- LastE820->size += EFI_PAGES_TO_SIZE ((UINTN) MemoryMap->NumberOfPages);
- LastEndAddr += EFI_PAGES_TO_SIZE ((UINTN) MemoryMap->NumberOfPages);
+ (LastE820->type == (UINT32)E820Type) &&
+ (MemoryMap->PhysicalStart == LastEndAddr))
+ {
+ LastE820->size += EFI_PAGES_TO_SIZE ((UINTN)MemoryMap->NumberOfPages);
+ LastEndAddr += EFI_PAGES_TO_SIZE ((UINTN)MemoryMap->NumberOfPages);
} else {
if (E820EntryCount >= ARRAY_SIZE (Bp->e820_map)) {
break;
}
- E820->type = (UINT32) E820Type;
- E820->addr = MemoryMap->PhysicalStart;
- E820->size = EFI_PAGES_TO_SIZE ((UINTN) MemoryMap->NumberOfPages);
- LastE820 = E820;
+
+ E820->type = (UINT32)E820Type;
+ E820->addr = MemoryMap->PhysicalStart;
+ E820->size = EFI_PAGES_TO_SIZE ((UINTN)MemoryMap->NumberOfPages);
+ LastE820 = E820;
LastEndAddr = E820->addr + E820->size;
E820++;
E820EntryCount++;
@@ -368,85 +367,83 @@ SetupLinuxMemmap (
//
MemoryMap = (EFI_MEMORY_DESCRIPTOR *)((UINTN)MemoryMap + DescriptorSize);
}
- Bp->e820_entries = (UINT8) E820EntryCount;
- Efi = &Bp->efi_info;
- Efi->efi_systab = (UINT32)(UINTN) gST;
- Efi->efi_memdesc_size = (UINT32) DescriptorSize;
+ Bp->e820_entries = (UINT8)E820EntryCount;
+
+ Efi = &Bp->efi_info;
+ Efi->efi_systab = (UINT32)(UINTN)gST;
+ Efi->efi_memdesc_size = (UINT32)DescriptorSize;
Efi->efi_memdesc_version = DescriptorVersion;
- Efi->efi_memmap = (UINT32)(UINTN) MemoryMapPtr;
- Efi->efi_memmap_size = (UINT32) MemoryMapSize;
-#ifdef MDE_CPU_IA32
+ Efi->efi_memmap = (UINT32)(UINTN)MemoryMapPtr;
+ Efi->efi_memmap_size = (UINT32)MemoryMapSize;
+ #ifdef MDE_CPU_IA32
Efi->efi_loader_signature = SIGNATURE_32 ('E', 'L', '3', '2');
-#else
- Efi->efi_systab_hi = (UINT32) (((UINT64)(UINTN) gST) >> 32);
- Efi->efi_memmap_hi = (UINT32) (((UINT64)(UINTN) MemoryMapPtr) >> 32);
+ #else
+ Efi->efi_systab_hi = (UINT32)(((UINT64)(UINTN)gST) >> 32);
+ Efi->efi_memmap_hi = (UINT32)(((UINT64)(UINTN)MemoryMapPtr) >> 32);
Efi->efi_loader_signature = SIGNATURE_32 ('E', 'L', '6', '4');
-#endif
+ #endif
gBS->ExitBootServices (gImageHandle, MapKey);
}
-
EFI_STATUS
EFIAPI
LoadLinuxSetCommandLine (
- IN OUT VOID *KernelSetup,
- IN CHAR8 *CommandLine
+ IN OUT VOID *KernelSetup,
+ IN CHAR8 *CommandLine
)
{
- EFI_STATUS Status;
- struct boot_params *Bp;
+ EFI_STATUS Status;
+ struct boot_params *Bp;
Status = BasicKernelSetupCheck (KernelSetup);
if (EFI_ERROR (Status)) {
return Status;
}
- Bp = (struct boot_params*) KernelSetup;
+ Bp = (struct boot_params *)KernelSetup;
- Bp->hdr.cmd_line_ptr = (UINT32)(UINTN) CommandLine;
+ Bp->hdr.cmd_line_ptr = (UINT32)(UINTN)CommandLine;
return EFI_SUCCESS;
}
-
EFI_STATUS
EFIAPI
LoadLinuxSetInitrd (
- IN OUT VOID *KernelSetup,
- IN VOID *Initrd,
- IN UINTN InitrdSize
+ IN OUT VOID *KernelSetup,
+ IN VOID *Initrd,
+ IN UINTN InitrdSize
)
{
- EFI_STATUS Status;
- struct boot_params *Bp;
+ EFI_STATUS Status;
+ struct boot_params *Bp;
Status = BasicKernelSetupCheck (KernelSetup);
if (EFI_ERROR (Status)) {
return Status;
}
- Bp = (struct boot_params*) KernelSetup;
+ Bp = (struct boot_params *)KernelSetup;
- Bp->hdr.ramdisk_start = (UINT32)(UINTN) Initrd;
- Bp->hdr.ramdisk_len = (UINT32) InitrdSize;
+ Bp->hdr.ramdisk_start = (UINT32)(UINTN)Initrd;
+ Bp->hdr.ramdisk_len = (UINT32)InitrdSize;
return EFI_SUCCESS;
}
-
STATIC VOID
FindBits (
- unsigned long Mask,
- UINT8 *Pos,
- UINT8 *Size
+ unsigned long Mask,
+ UINT8 *Pos,
+ UINT8 *Size
)
{
- UINT8 First, Len;
+ UINT8 First, Len;
First = 0;
- Len = 0;
+ Len = 0;
if (Mask) {
while (!(Mask & 0x1)) {
@@ -459,23 +456,23 @@ FindBits (
Len++;
}
}
- *Pos = First;
+
+ *Pos = First;
*Size = Len;
}
-
STATIC
EFI_STATUS
SetupGraphicsFromGop (
- struct screen_info *Si,
- EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop
+ struct screen_info *Si,
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop
)
{
- EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
- EFI_STATUS Status;
- UINTN Size;
+ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
+ EFI_STATUS Status;
+ UINTN Size;
- Status = Gop->QueryMode(Gop, Gop->Mode->Mode, &Size, &Info);
+ Status = Gop->QueryMode (Gop, Gop->Mode->Mode, &Size, &Info);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -485,88 +482,98 @@ SetupGraphicsFromGop (
/* EFI framebuffer */
Si->orig_video_isVGA = 0x70;
- Si->orig_x = 0;
- Si->orig_y = 0;
- Si->orig_video_page = 0;
- Si->orig_video_mode = 0;
- Si->orig_video_cols = 0;
- Si->orig_video_lines = 0;
+ Si->orig_x = 0;
+ Si->orig_y = 0;
+ Si->orig_video_page = 0;
+ Si->orig_video_mode = 0;
+ Si->orig_video_cols = 0;
+ Si->orig_video_lines = 0;
Si->orig_video_ega_bx = 0;
Si->orig_video_points = 0;
- Si->lfb_base = (UINT32) Gop->Mode->FrameBufferBase;
- Si->lfb_size = (UINT32) Gop->Mode->FrameBufferSize;
- Si->lfb_width = (UINT16) Info->HorizontalResolution;
- Si->lfb_height = (UINT16) Info->VerticalResolution;
- Si->pages = 1;
+ Si->lfb_base = (UINT32)Gop->Mode->FrameBufferBase;
+ Si->lfb_size = (UINT32)Gop->Mode->FrameBufferSize;
+ Si->lfb_width = (UINT16)Info->HorizontalResolution;
+ Si->lfb_height = (UINT16)Info->VerticalResolution;
+ Si->pages = 1;
Si->vesapm_seg = 0;
Si->vesapm_off = 0;
if (Info->PixelFormat == PixelRedGreenBlueReserved8BitPerColor) {
- Si->lfb_depth = 32;
- Si->red_size = 8;
- Si->red_pos = 0;
- Si->green_size = 8;
- Si->green_pos = 8;
- Si->blue_size = 8;
- Si->blue_pos = 16;
- Si->rsvd_size = 8;
- Si->rsvd_pos = 24;
- Si->lfb_linelength = (UINT16) (Info->PixelsPerScanLine * 4);
-
+ Si->lfb_depth = 32;
+ Si->red_size = 8;
+ Si->red_pos = 0;
+ Si->green_size = 8;
+ Si->green_pos = 8;
+ Si->blue_size = 8;
+ Si->blue_pos = 16;
+ Si->rsvd_size = 8;
+ Si->rsvd_pos = 24;
+ Si->lfb_linelength = (UINT16)(Info->PixelsPerScanLine * 4);
} else if (Info->PixelFormat == PixelBlueGreenRedReserved8BitPerColor) {
- Si->lfb_depth = 32;
- Si->red_size = 8;
- Si->red_pos = 16;
- Si->green_size = 8;
- Si->green_pos = 8;
- Si->blue_size = 8;
- Si->blue_pos = 0;
- Si->rsvd_size = 8;
- Si->rsvd_pos = 24;
- Si->lfb_linelength = (UINT16) (Info->PixelsPerScanLine * 4);
+ Si->lfb_depth = 32;
+ Si->red_size = 8;
+ Si->red_pos = 16;
+ Si->green_size = 8;
+ Si->green_pos = 8;
+ Si->blue_size = 8;
+ Si->blue_pos = 0;
+ Si->rsvd_size = 8;
+ Si->rsvd_pos = 24;
+ Si->lfb_linelength = (UINT16)(Info->PixelsPerScanLine * 4);
} else if (Info->PixelFormat == PixelBitMask) {
- FindBits(Info->PixelInformation.RedMask,
- &Si->red_pos, &Si->red_size);
- FindBits(Info->PixelInformation.GreenMask,
- &Si->green_pos, &Si->green_size);
- FindBits(Info->PixelInformation.BlueMask,
- &Si->blue_pos, &Si->blue_size);
- FindBits(Info->PixelInformation.ReservedMask,
- &Si->rsvd_pos, &Si->rsvd_size);
+ FindBits (
+ Info->PixelInformation.RedMask,
+ &Si->red_pos,
+ &Si->red_size
+ );
+ FindBits (
+ Info->PixelInformation.GreenMask,
+ &Si->green_pos,
+ &Si->green_size
+ );
+ FindBits (
+ Info->PixelInformation.BlueMask,
+ &Si->blue_pos,
+ &Si->blue_size
+ );
+ FindBits (
+ Info->PixelInformation.ReservedMask,
+ &Si->rsvd_pos,
+ &Si->rsvd_size
+ );
Si->lfb_depth = Si->red_size + Si->green_size +
- Si->blue_size + Si->rsvd_size;
- Si->lfb_linelength = (UINT16) ((Info->PixelsPerScanLine * Si->lfb_depth) / 8);
+ Si->blue_size + Si->rsvd_size;
+ Si->lfb_linelength = (UINT16)((Info->PixelsPerScanLine * Si->lfb_depth) / 8);
} else {
- Si->lfb_depth = 4;
- Si->red_size = 0;
- Si->red_pos = 0;
- Si->green_size = 0;
- Si->green_pos = 0;
- Si->blue_size = 0;
- Si->blue_pos = 0;
- Si->rsvd_size = 0;
- Si->rsvd_pos = 0;
+ Si->lfb_depth = 4;
+ Si->red_size = 0;
+ Si->red_pos = 0;
+ Si->green_size = 0;
+ Si->green_pos = 0;
+ Si->blue_size = 0;
+ Si->blue_pos = 0;
+ Si->rsvd_size = 0;
+ Si->rsvd_pos = 0;
Si->lfb_linelength = Si->lfb_width / 2;
}
return Status;
}
-
STATIC
EFI_STATUS
SetupGraphics (
- IN OUT struct boot_params *Bp
+ IN OUT struct boot_params *Bp
)
{
- EFI_STATUS Status;
- EFI_HANDLE *HandleBuffer;
- UINTN HandleCount;
- UINTN Index;
- EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop;
+ EFI_STATUS Status;
+ EFI_HANDLE *HandleBuffer;
+ UINTN HandleCount;
+ UINTN Index;
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop;
- ZeroMem ((VOID*)&Bp->screen_info, sizeof(Bp->screen_info));
+ ZeroMem ((VOID *)&Bp->screen_info, sizeof (Bp->screen_info));
Status = gBS->LocateHandleBuffer (
ByProtocol,
@@ -580,7 +587,7 @@ SetupGraphics (
Status = gBS->HandleProtocol (
HandleBuffer[Index],
&gEfiGraphicsOutputProtocolGuid,
- (VOID*) &Gop
+ (VOID *)&Gop
);
if (EFI_ERROR (Status)) {
continue;
@@ -599,11 +606,10 @@ SetupGraphics (
return EFI_NOT_FOUND;
}
-
STATIC
EFI_STATUS
SetupLinuxBootParams (
- IN OUT struct boot_params *Bp
+ IN OUT struct boot_params *Bp
)
{
SetupGraphics (Bp);
@@ -613,7 +619,6 @@ SetupLinuxBootParams (
return EFI_SUCCESS;
}
-
EFI_STATUS
EFIAPI
LoadLinux (
@@ -621,7 +626,7 @@ LoadLinux (
IN OUT VOID *KernelSetup
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
struct boot_params *Bp;
Status = BasicKernelSetupCheck (KernelSetup);
@@ -629,9 +634,9 @@ LoadLinux (
return Status;
}
- Bp = (struct boot_params *) KernelSetup;
+ Bp = (struct boot_params *)KernelSetup;
- if (Bp->hdr.version < 0x205 || !Bp->hdr.relocatable_kernel) {
+ if ((Bp->hdr.version < 0x205) || !Bp->hdr.relocatable_kernel) {
//
// We only support relocatable kernels
//
@@ -640,13 +645,14 @@ LoadLinux (
InitLinuxDescriptorTables ();
- Bp->hdr.code32_start = (UINT32)(UINTN) Kernel;
- if (Bp->hdr.version >= 0x20c && Bp->hdr.handover_offset &&
- (Bp->hdr.xloadflags & (sizeof (UINTN) == 4 ? BIT2 : BIT3))) {
+ Bp->hdr.code32_start = (UINT32)(UINTN)Kernel;
+ if ((Bp->hdr.version >= 0x20c) && Bp->hdr.handover_offset &&
+ (Bp->hdr.xloadflags & ((sizeof (UINTN) == 4) ? BIT2 : BIT3)))
+ {
DEBUG ((DEBUG_INFO, "Jumping to kernel EFI handover point at ofs %x\n", Bp->hdr.handover_offset));
DisableInterrupts ();
- JumpToUefiKernel ((VOID*) gImageHandle, (VOID*) gST, KernelSetup, Kernel);
+ JumpToUefiKernel ((VOID *)gImageHandle, (VOID *)gST, KernelSetup, Kernel);
}
//
@@ -657,8 +663,7 @@ LoadLinux (
DEBUG ((DEBUG_INFO, "Jumping to kernel\n"));
DisableInterrupts ();
SetLinuxDescriptorTables ();
- JumpToKernel (Kernel, (VOID*) KernelSetup);
+ JumpToKernel (Kernel, (VOID *)KernelSetup);
return EFI_SUCCESS;
}
-
diff --git a/OvmfPkg/Library/LoadLinuxLib/LinuxGdt.c b/OvmfPkg/Library/LoadLinuxLib/LinuxGdt.c
index d90e999d82..8f1e2375b6 100644
--- a/OvmfPkg/Library/LoadLinuxLib/LinuxGdt.c
+++ b/OvmfPkg/Library/LoadLinuxLib/LinuxGdt.c
@@ -8,7 +8,6 @@
#include "LoadLinuxLib.h"
-
//
// Local structure definitions
//
@@ -20,33 +19,33 @@
//
typedef struct _GDT_ENTRY {
- UINT16 Limit15_0;
- UINT16 Base15_0;
- UINT8 Base23_16;
- UINT8 Type;
- UINT8 Limit19_16_and_flags;
- UINT8 Base31_24;
+ UINT16 Limit15_0;
+ UINT16 Base15_0;
+ UINT8 Base23_16;
+ UINT8 Type;
+ UINT8 Limit19_16_and_flags;
+ UINT8 Base31_24;
} GDT_ENTRY;
typedef
-struct _GDT_ENTRIES {
- GDT_ENTRY Null;
- GDT_ENTRY Null2;
- GDT_ENTRY Linear;
- GDT_ENTRY LinearCode;
- GDT_ENTRY TaskSegment;
- GDT_ENTRY Spare4;
- GDT_ENTRY Spare5;
+ struct _GDT_ENTRIES {
+ GDT_ENTRY Null;
+ GDT_ENTRY Null2;
+ GDT_ENTRY Linear;
+ GDT_ENTRY LinearCode;
+ GDT_ENTRY TaskSegment;
+ GDT_ENTRY Spare4;
+ GDT_ENTRY Spare5;
} GDT_ENTRIES;
#pragma pack ()
-STATIC GDT_ENTRIES *mGdt = NULL;
+STATIC GDT_ENTRIES *mGdt = NULL;
//
// Global descriptor table (GDT) Template
//
-STATIC GDT_ENTRIES GdtTemplate = {
+STATIC GDT_ENTRIES GdtTemplate = {
//
// Null
//
@@ -146,7 +145,6 @@ InitLinuxDescriptorTables (
// Initialize all GDT entries
//
CopyMem (mGdt, &GdtTemplate, sizeof (GdtTemplate));
-
}
/**
@@ -158,18 +156,17 @@ SetLinuxDescriptorTables (
VOID
)
{
- IA32_DESCRIPTOR GdtPtr;
- IA32_DESCRIPTOR IdtPtr;
+ IA32_DESCRIPTOR GdtPtr;
+ IA32_DESCRIPTOR IdtPtr;
//
// Write GDT register
//
- GdtPtr.Base = (UINT32)(UINTN)(VOID*) mGdt;
- GdtPtr.Limit = (UINT16) (sizeof (GdtTemplate) - 1);
+ GdtPtr.Base = (UINT32)(UINTN)(VOID *)mGdt;
+ GdtPtr.Limit = (UINT16)(sizeof (GdtTemplate) - 1);
AsmWriteGdtr (&GdtPtr);
- IdtPtr.Base = (UINT32) 0;
- IdtPtr.Limit = (UINT16) 0;
+ IdtPtr.Base = (UINT32)0;
+ IdtPtr.Limit = (UINT16)0;
AsmWriteIdtr (&IdtPtr);
}
-
diff --git a/OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.h b/OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.h
index daaecb6154..deb9b6e861 100644
--- a/OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.h
+++ b/OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.h
@@ -26,17 +26,17 @@
VOID
EFIAPI
JumpToKernel (
- VOID *KernelStart,
- VOID *KernelBootParams
+ VOID *KernelStart,
+ VOID *KernelBootParams
);
VOID
EFIAPI
JumpToUefiKernel (
- EFI_HANDLE ImageHandle,
- EFI_SYSTEM_TABLE *SystemTable,
- VOID *KernelBootParams,
- VOID *KernelStart
+ EFI_HANDLE ImageHandle,
+ EFI_SYSTEM_TABLE *SystemTable,
+ VOID *KernelBootParams,
+ VOID *KernelStart
);
VOID
@@ -50,4 +50,3 @@ SetLinuxDescriptorTables (
);
#endif
-
diff --git a/OvmfPkg/Library/LockBoxLib/LockBoxDxe.c b/OvmfPkg/Library/LockBoxLib/LockBoxDxe.c
index 7dc2eea239..c9d679cb84 100644
--- a/OvmfPkg/Library/LockBoxLib/LockBoxDxe.c
+++ b/OvmfPkg/Library/LockBoxLib/LockBoxDxe.c
@@ -29,17 +29,17 @@
STATIC
VOID *
AllocateMemoryBelow4G (
- IN EFI_MEMORY_TYPE MemoryType,
- IN UINTN Size
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN Size
)
{
UINTN Pages;
EFI_PHYSICAL_ADDRESS Address;
EFI_STATUS Status;
- VOID* Buffer;
+ VOID *Buffer;
UINTN AllocRemaining;
- Pages = EFI_SIZE_TO_PAGES (Size);
+ Pages = EFI_SIZE_TO_PAGES (Size);
Address = 0xffffffff;
//
@@ -49,36 +49,35 @@ AllocateMemoryBelow4G (
// allocations, and use these to allocate memory for small buffers.
//
ASSERT (mLockBoxGlobal->Signature == LOCK_BOX_GLOBAL_SIGNATURE);
- if ((UINTN) mLockBoxGlobal->SubPageRemaining >= Size) {
- Buffer = (VOID*)(UINTN) mLockBoxGlobal->SubPageBuffer;
- mLockBoxGlobal->SubPageBuffer += (UINT32) Size;
- mLockBoxGlobal->SubPageRemaining -= (UINT32) Size;
+ if ((UINTN)mLockBoxGlobal->SubPageRemaining >= Size) {
+ Buffer = (VOID *)(UINTN)mLockBoxGlobal->SubPageBuffer;
+ mLockBoxGlobal->SubPageBuffer += (UINT32)Size;
+ mLockBoxGlobal->SubPageRemaining -= (UINT32)Size;
return Buffer;
}
- Status = gBS->AllocatePages (
- AllocateMaxAddress,
- MemoryType,
- Pages,
- &Address
- );
+ Status = gBS->AllocatePages (
+ AllocateMaxAddress,
+ MemoryType,
+ Pages,
+ &Address
+ );
if (EFI_ERROR (Status)) {
return NULL;
}
- Buffer = (VOID *) (UINTN) Address;
+ Buffer = (VOID *)(UINTN)Address;
ZeroMem (Buffer, EFI_PAGES_TO_SIZE (Pages));
AllocRemaining = EFI_PAGES_TO_SIZE (Pages) - Size;
- if (AllocRemaining > (UINTN) mLockBoxGlobal->SubPageRemaining) {
- mLockBoxGlobal->SubPageBuffer = (UINT32) (Address + Size);
- mLockBoxGlobal->SubPageRemaining = (UINT32) AllocRemaining;
+ if (AllocRemaining > (UINTN)mLockBoxGlobal->SubPageRemaining) {
+ mLockBoxGlobal->SubPageBuffer = (UINT32)(Address + Size);
+ mLockBoxGlobal->SubPageRemaining = (UINT32)AllocRemaining;
}
return Buffer;
}
-
/**
Allocates a buffer of type EfiACPIMemoryNVS.
@@ -102,7 +101,6 @@ AllocateAcpiNvsPool (
return AllocateMemoryBelow4G (EfiACPIMemoryNVS, AllocationSize);
}
-
EFI_STATUS
EFIAPI
LockBoxDxeLibInitialize (
@@ -110,8 +108,8 @@ LockBoxDxeLibInitialize (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
- VOID *Interface;
+ EFI_STATUS Status;
+ VOID *Interface;
Status = LockBoxLibInitialize ();
if (!EFI_ERROR (Status)) {
diff --git a/OvmfPkg/Library/LockBoxLib/LockBoxLib.c b/OvmfPkg/Library/LockBoxLib/LockBoxLib.c
index 95ab4332e7..2000afeeb8 100644
--- a/OvmfPkg/Library/LockBoxLib/LockBoxLib.c
+++ b/OvmfPkg/Library/LockBoxLib/LockBoxLib.c
@@ -18,17 +18,17 @@
#pragma pack(1)
typedef struct {
- EFI_GUID Guid;
- EFI_PHYSICAL_ADDRESS OrigAddress;
- EFI_PHYSICAL_ADDRESS CopyAddress;
- UINT32 Size;
- UINT64 Attributes;
+ EFI_GUID Guid;
+ EFI_PHYSICAL_ADDRESS OrigAddress;
+ EFI_PHYSICAL_ADDRESS CopyAddress;
+ UINT32 Size;
+ UINT64 Attributes;
} LOCK_BOX_ENTRY;
#pragma pack()
-LOCK_BOX_GLOBAL *mLockBoxGlobal = NULL;
-STATIC LOCK_BOX_ENTRY *StartOfEntries = NULL;
-STATIC LOCK_BOX_ENTRY *EndOfEntries = NULL;
+LOCK_BOX_GLOBAL *mLockBoxGlobal = NULL;
+STATIC LOCK_BOX_ENTRY *StartOfEntries = NULL;
+STATIC LOCK_BOX_ENTRY *EndOfEntries = NULL;
RETURN_STATUS
EFIAPI
@@ -36,7 +36,7 @@ LockBoxLibInitialize (
VOID
)
{
- UINTN NumEntries;
+ UINTN NumEntries;
ASSERT (!FeaturePcdGet (PcdSmmSmramRequire));
@@ -44,10 +44,10 @@ LockBoxLibInitialize (
return RETURN_UNSUPPORTED;
}
- mLockBoxGlobal = (LOCK_BOX_GLOBAL *)(UINTN) PcdGet32 (PcdOvmfLockBoxStorageBase);
- StartOfEntries = ((LOCK_BOX_ENTRY *) (mLockBoxGlobal + 1));
- NumEntries = ((PcdGet32 (PcdOvmfLockBoxStorageSize) - sizeof (LOCK_BOX_GLOBAL)) /
- sizeof (LOCK_BOX_ENTRY));
+ mLockBoxGlobal = (LOCK_BOX_GLOBAL *)(UINTN)PcdGet32 (PcdOvmfLockBoxStorageBase);
+ StartOfEntries = ((LOCK_BOX_ENTRY *)(mLockBoxGlobal + 1));
+ NumEntries = ((PcdGet32 (PcdOvmfLockBoxStorageSize) - sizeof (LOCK_BOX_GLOBAL)) /
+ sizeof (LOCK_BOX_ENTRY));
EndOfEntries = StartOfEntries + NumEntries;
if (mLockBoxGlobal->Signature != LOCK_BOX_GLOBAL_SIGNATURE) {
//
@@ -57,10 +57,10 @@ LockBoxLibInitialize (
//
mLockBoxGlobal->Signature = LOCK_BOX_GLOBAL_SIGNATURE;
}
+
return RETURN_SUCCESS;
}
-
/**
Find LockBox entry based on GUID.
@@ -80,13 +80,13 @@ STATIC
LOCK_BOX_ENTRY *
EFIAPI
FindHeaderByGuid (
- IN CONST EFI_GUID *Guid
+ IN CONST EFI_GUID *Guid
)
{
- LOCK_BOX_ENTRY *Header;
+ LOCK_BOX_ENTRY *Header;
for (Header = StartOfEntries; Header < EndOfEntries; Header++) {
- if (Header->Size == 0 || CompareGuid (Guid, &Header->Guid)) {
+ if ((Header->Size == 0) || CompareGuid (Guid, &Header->Guid)) {
return Header;
}
}
@@ -94,7 +94,6 @@ FindHeaderByGuid (
return NULL;
}
-
/**
This function will save confidential information to lockbox.
@@ -115,18 +114,24 @@ FindHeaderByGuid (
RETURN_STATUS
EFIAPI
SaveLockBox (
- IN GUID *Guid,
- IN VOID *Buffer,
- IN UINTN Length
+ IN GUID *Guid,
+ IN VOID *Buffer,
+ IN UINTN Length
)
{
- LOCK_BOX_ENTRY *Header;
+ LOCK_BOX_ENTRY *Header;
VOID *CopyBuffer;
- DEBUG ((DEBUG_VERBOSE, "%a: Guid=%g Buffer=%p Length=0x%x\n", __FUNCTION__,
- Guid, Buffer, (UINT32) Length));
+ DEBUG ((
+ DEBUG_VERBOSE,
+ "%a: Guid=%g Buffer=%p Length=0x%x\n",
+ __FUNCTION__,
+ Guid,
+ Buffer,
+ (UINT32)Length
+ ));
- if (Guid == NULL || Buffer == NULL || Length == 0) {
+ if ((Guid == NULL) || (Buffer == NULL) || (Length == 0)) {
return RETURN_INVALID_PARAMETER;
}
@@ -152,9 +157,9 @@ SaveLockBox (
// overwrite the current terminator header with new metadata
//
CopyGuid (&Header->Guid, Guid);
- Header->OrigAddress = (UINTN) Buffer;
- Header->CopyAddress = (UINTN) CopyBuffer;
- Header->Size = (UINT32) Length;
+ Header->OrigAddress = (UINTN)Buffer;
+ Header->CopyAddress = (UINTN)CopyBuffer;
+ Header->Size = (UINT32)Length;
Header->Attributes = 0;
//
@@ -165,7 +170,6 @@ SaveLockBox (
return RETURN_SUCCESS;
}
-
/**
This function will set lockbox attributes.
@@ -183,29 +187,34 @@ SaveLockBox (
RETURN_STATUS
EFIAPI
SetLockBoxAttributes (
- IN GUID *Guid,
- IN UINT64 Attributes
+ IN GUID *Guid,
+ IN UINT64 Attributes
)
{
- LOCK_BOX_ENTRY *Header;
+ LOCK_BOX_ENTRY *Header;
- DEBUG ((DEBUG_VERBOSE, "%a: Guid=%g Attributes=0x%Lx\n", __FUNCTION__, Guid,
- Attributes));
+ DEBUG ((
+ DEBUG_VERBOSE,
+ "%a: Guid=%g Attributes=0x%Lx\n",
+ __FUNCTION__,
+ Guid,
+ Attributes
+ ));
if (Guid == NULL) {
return RETURN_INVALID_PARAMETER;
}
Header = FindHeaderByGuid (Guid);
- if (!Header || Header->Size == 0) {
+ if (!Header || (Header->Size == 0)) {
return RETURN_NOT_FOUND;
}
+
Header->Attributes = Attributes;
return RETURN_SUCCESS;
}
-
/**
This function will update confidential information to lockbox.
@@ -233,37 +242,43 @@ SetLockBoxAttributes (
RETURN_STATUS
EFIAPI
UpdateLockBox (
- IN GUID *Guid,
- IN UINTN Offset,
- IN VOID *Buffer,
- IN UINTN Length
+ IN GUID *Guid,
+ IN UINTN Offset,
+ IN VOID *Buffer,
+ IN UINTN Length
)
{
- LOCK_BOX_ENTRY *Header;
-
- DEBUG ((DEBUG_VERBOSE, "%a: Guid=%g Offset=0x%x Length=0x%x\n", __FUNCTION__,
- Guid, (UINT32) Offset, (UINT32) Length));
-
- if (Guid == NULL || Buffer == NULL || Length == 0) {
+ LOCK_BOX_ENTRY *Header;
+
+ DEBUG ((
+ DEBUG_VERBOSE,
+ "%a: Guid=%g Offset=0x%x Length=0x%x\n",
+ __FUNCTION__,
+ Guid,
+ (UINT32)Offset,
+ (UINT32)Length
+ ));
+
+ if ((Guid == NULL) || (Buffer == NULL) || (Length == 0)) {
return RETURN_INVALID_PARAMETER;
}
Header = FindHeaderByGuid (Guid);
- if (!Header || Header->Size == 0) {
+ if (!Header || (Header->Size == 0)) {
return RETURN_NOT_FOUND;
}
- if (Header->Size < Offset ||
- Length > Header->Size - Offset) {
+ if ((Header->Size < Offset) ||
+ (Length > Header->Size - Offset))
+ {
return RETURN_BUFFER_TOO_SMALL;
}
- CopyMem ((UINT8 *)(UINTN) (Header->CopyAddress) + Offset, Buffer, Length);
+ CopyMem ((UINT8 *)(UINTN)(Header->CopyAddress) + Offset, Buffer, Length);
return RETURN_SUCCESS;
}
-
/**
This function will restore confidential information from lockbox.
@@ -290,24 +305,30 @@ UpdateLockBox (
RETURN_STATUS
EFIAPI
RestoreLockBox (
- IN GUID *Guid,
- IN VOID *Buffer OPTIONAL,
- IN OUT UINTN *Length OPTIONAL
+ IN GUID *Guid,
+ IN VOID *Buffer OPTIONAL,
+ IN OUT UINTN *Length OPTIONAL
)
{
- LOCK_BOX_ENTRY *Header;
+ LOCK_BOX_ENTRY *Header;
- DEBUG ((DEBUG_VERBOSE, "%a: Guid=%g Buffer=%p\n", __FUNCTION__, Guid,
- Buffer));
+ DEBUG ((
+ DEBUG_VERBOSE,
+ "%a: Guid=%g Buffer=%p\n",
+ __FUNCTION__,
+ Guid,
+ Buffer
+ ));
if ((Guid == NULL) ||
((Buffer == NULL) && (Length != NULL)) ||
- ((Buffer != NULL) && (Length == NULL))) {
+ ((Buffer != NULL) && (Length == NULL)))
+ {
return EFI_INVALID_PARAMETER;
}
Header = FindHeaderByGuid (Guid);
- if (!Header || Header->Size == 0) {
+ if (!Header || (Header->Size == 0)) {
return RETURN_NOT_FOUND;
}
@@ -315,10 +336,12 @@ RestoreLockBox (
if (!(Header->Attributes & LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE)) {
return RETURN_WRITE_PROTECTED;
}
+
if (Header->OrigAddress + (Header->Size - 1) > MAX_ADDRESS) {
return RETURN_UNSUPPORTED;
}
- Buffer = (VOID *)(UINTN) Header->OrigAddress;
+
+ Buffer = (VOID *)(UINTN)Header->OrigAddress;
}
//
@@ -332,15 +355,15 @@ RestoreLockBox (
*Length = Header->Size;
return EFI_BUFFER_TOO_SMALL;
}
+
*Length = Header->Size;
}
- CopyMem (Buffer, (VOID*)(UINTN) Header->CopyAddress, Header->Size);
+ CopyMem (Buffer, (VOID *)(UINTN)Header->CopyAddress, Header->Size);
return RETURN_SUCCESS;
}
-
/**
This function will restore confidential information from all lockbox which
have RestoreInPlace attribute.
@@ -356,22 +379,30 @@ RestoreAllLockBoxInPlace (
VOID
)
{
- LOCK_BOX_ENTRY *Header;
+ LOCK_BOX_ENTRY *Header;
for (Header = StartOfEntries;
Header < EndOfEntries && Header->Size > 0;
- Header++) {
+ Header++)
+ {
if (Header->Attributes & LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE) {
- VOID *Buffer;
+ VOID *Buffer;
if (Header->OrigAddress + (Header->Size - 1) > MAX_ADDRESS) {
return RETURN_UNSUPPORTED;
}
- Buffer = (VOID *)(UINTN) Header->OrigAddress;
- CopyMem (Buffer, (VOID*)(UINTN)Header->CopyAddress, Header->Size);
- DEBUG ((DEBUG_VERBOSE, "%a: Guid=%g Buffer=%p\n", __FUNCTION__,
- &Header->Guid, Buffer));
+
+ Buffer = (VOID *)(UINTN)Header->OrigAddress;
+ CopyMem (Buffer, (VOID *)(UINTN)Header->CopyAddress, Header->Size);
+ DEBUG ((
+ DEBUG_VERBOSE,
+ "%a: Guid=%g Buffer=%p\n",
+ __FUNCTION__,
+ &Header->Guid,
+ Buffer
+ ));
}
}
+
return RETURN_SUCCESS;
}
diff --git a/OvmfPkg/Library/LockBoxLib/LockBoxLib.h b/OvmfPkg/Library/LockBoxLib/LockBoxLib.h
index d654ea6398..a5392c9124 100644
--- a/OvmfPkg/Library/LockBoxLib/LockBoxLib.h
+++ b/OvmfPkg/Library/LockBoxLib/LockBoxLib.h
@@ -12,14 +12,14 @@
#pragma pack(1)
typedef struct {
- UINT32 Signature;
- UINT32 SubPageBuffer;
- UINT32 SubPageRemaining;
+ UINT32 Signature;
+ UINT32 SubPageBuffer;
+ UINT32 SubPageRemaining;
} LOCK_BOX_GLOBAL;
-#define LOCK_BOX_GLOBAL_SIGNATURE SIGNATURE_32('L', 'B', 'G', 'S')
+#define LOCK_BOX_GLOBAL_SIGNATURE SIGNATURE_32('L', 'B', 'G', 'S')
-extern LOCK_BOX_GLOBAL *mLockBoxGlobal;
+extern LOCK_BOX_GLOBAL *mLockBoxGlobal;
#pragma pack()
@@ -43,12 +43,10 @@ AllocateAcpiNvsPool (
IN UINTN AllocationSize
);
-
RETURN_STATUS
EFIAPI
LockBoxLibInitialize (
VOID
);
-
#endif
diff --git a/OvmfPkg/Library/NvVarsFileLib/FsAccess.c b/OvmfPkg/Library/NvVarsFileLib/FsAccess.c
index 2ba03522fb..3f515bd034 100644
--- a/OvmfPkg/Library/NvVarsFileLib/FsAccess.c
+++ b/OvmfPkg/Library/NvVarsFileLib/FsAccess.c
@@ -12,7 +12,6 @@
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
-
/**
Open the NvVars file for reading or writing
@@ -26,14 +25,14 @@
**/
EFI_STATUS
GetNvVarsFile (
- IN EFI_HANDLE FsHandle,
- IN BOOLEAN ReadingFile,
- OUT EFI_FILE_HANDLE *NvVarsFile
+ IN EFI_HANDLE FsHandle,
+ IN BOOLEAN ReadingFile,
+ OUT EFI_FILE_HANDLE *NvVarsFile
)
{
- EFI_STATUS Status;
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs;
- EFI_FILE_HANDLE Root;
+ EFI_STATUS Status;
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs;
+ EFI_FILE_HANDLE Root;
//
// Get the FileSystem protocol on that handle
@@ -63,19 +62,18 @@ GetNvVarsFile (
NvVarsFile,
L"NvVars",
ReadingFile ?
- EFI_FILE_MODE_READ :
- (
- EFI_FILE_MODE_CREATE |
- EFI_FILE_MODE_READ |
- EFI_FILE_MODE_WRITE
- ),
+ EFI_FILE_MODE_READ :
+ (
+ EFI_FILE_MODE_CREATE |
+ EFI_FILE_MODE_READ |
+ EFI_FILE_MODE_WRITE
+ ),
0
);
return Status;
}
-
/**
Open the NvVars file for reading or writing
@@ -87,15 +85,15 @@ GetNvVarsFile (
**/
VOID
NvVarsFileReadCheckup (
- IN EFI_FILE_HANDLE File,
- OUT BOOLEAN *Exists,
- OUT UINTN *Size
+ IN EFI_FILE_HANDLE File,
+ OUT BOOLEAN *Exists,
+ OUT UINTN *Size
)
{
- EFI_FILE_INFO *FileInfo;
+ EFI_FILE_INFO *FileInfo;
*Exists = FALSE;
- *Size = 0;
+ *Size = 0;
FileInfo = FileHandleGetInfo (File);
if (FileInfo == NULL) {
@@ -108,12 +106,11 @@ NvVarsFileReadCheckup (
}
*Exists = TRUE;
- *Size = (UINTN) FileInfo->FileSize;
+ *Size = (UINTN)FileInfo->FileSize;
FreePool (FileInfo);
}
-
/**
Open the NvVars file for reading or writing
@@ -125,11 +122,11 @@ NvVarsFileReadCheckup (
**/
EFI_STATUS
FileHandleEmpty (
- IN EFI_FILE_HANDLE File
+ IN EFI_FILE_HANDLE File
)
{
- EFI_STATUS Status;
- EFI_FILE_INFO *FileInfo;
+ EFI_STATUS Status;
+ EFI_FILE_INFO *FileInfo;
//
// Retrieve the FileInfo structure
@@ -160,14 +157,13 @@ FileHandleEmpty (
// Set the file size to 0.
//
FileInfo->FileSize = 0;
- Status = FileHandleSetInfo (File, FileInfo);
+ Status = FileHandleSetInfo (File, FileInfo);
FreePool (FileInfo);
return Status;
}
-
/**
Reads a file to a newly allocated buffer
@@ -178,18 +174,18 @@ FileHandleEmpty (
contents. NULL if an error occurred.
**/
-VOID*
+VOID *
FileHandleReadToNewBuffer (
- IN EFI_FILE_HANDLE FileHandle,
- IN UINTN ReadSize
+ IN EFI_FILE_HANDLE FileHandle,
+ IN UINTN ReadSize
)
{
- EFI_STATUS Status;
- UINTN ActualReadSize;
- VOID *FileContents;
+ EFI_STATUS Status;
+ UINTN ActualReadSize;
+ VOID *FileContents;
ActualReadSize = ReadSize;
- FileContents = AllocatePool (ReadSize);
+ FileContents = AllocatePool (ReadSize);
if (FileContents != NULL) {
Status = FileHandleRead (
FileHandle,
@@ -205,7 +201,6 @@ FileHandleReadToNewBuffer (
return FileContents;
}
-
/**
Reads the contents of the NvVars file on the file system
@@ -216,15 +211,15 @@ FileHandleReadToNewBuffer (
**/
EFI_STATUS
ReadNvVarsFile (
- IN EFI_HANDLE FsHandle
+ IN EFI_HANDLE FsHandle
)
{
- EFI_STATUS Status;
- EFI_FILE_HANDLE File;
- UINTN FileSize;
- BOOLEAN FileExists;
- VOID *FileContents;
- EFI_HANDLE SerializedVariables;
+ EFI_STATUS Status;
+ EFI_FILE_HANDLE File;
+ UINTN FileSize;
+ BOOLEAN FileExists;
+ VOID *FileContents;
+ EFI_HANDLE SerializedVariables;
Status = GetNvVarsFile (FsHandle, TRUE, &File);
if (EFI_ERROR (Status)) {
@@ -265,7 +260,6 @@ ReadNvVarsFile (
return Status;
}
-
/**
Writes a variable to indicate that the NV variables
have been loaded from the file system.
@@ -277,28 +271,27 @@ SetNvVarsVariable (
VOID
)
{
- BOOLEAN VarData;
- UINTN Size;
+ BOOLEAN VarData;
+ UINTN Size;
//
// Write a variable to indicate we've already loaded the
// variable data. If it is found, we skip the loading on
// subsequent attempts.
//
- Size = sizeof (VarData);
+ Size = sizeof (VarData);
VarData = TRUE;
gRT->SetVariable (
L"NvVars",
&gEfiSimpleFileSystemProtocolGuid,
EFI_VARIABLE_NON_VOLATILE |
- EFI_VARIABLE_BOOTSERVICE_ACCESS |
- EFI_VARIABLE_RUNTIME_ACCESS,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS |
+ EFI_VARIABLE_RUNTIME_ACCESS,
Size,
- (VOID*) &VarData
+ (VOID *)&VarData
);
}
-
/**
Loads the non-volatile variables from the NvVars file on the
given file system.
@@ -310,12 +303,12 @@ SetNvVarsVariable (
**/
EFI_STATUS
LoadNvVarsFromFs (
- EFI_HANDLE FsHandle
+ EFI_HANDLE FsHandle
)
{
- EFI_STATUS Status;
- BOOLEAN VarData;
- UINTN Size;
+ EFI_STATUS Status;
+ BOOLEAN VarData;
+ UINTN Size;
DEBUG ((DEBUG_INFO, "FsAccess.c: LoadNvVarsFromFs\n"));
@@ -328,15 +321,15 @@ LoadNvVarsFromFs (
// want to re-load the file as it would overwrite newer changes
// made to the variables.
//
- Size = sizeof (VarData);
+ Size = sizeof (VarData);
VarData = TRUE;
- Status = gRT->GetVariable (
- L"NvVars",
- &gEfiSimpleFileSystemProtocolGuid,
- NULL,
- &Size,
- (VOID*) &VarData
- );
+ Status = gRT->GetVariable (
+ L"NvVars",
+ &gEfiSimpleFileSystemProtocolGuid,
+ NULL,
+ &Size,
+ (VOID *)&VarData
+ );
if (Status == EFI_SUCCESS) {
DEBUG ((DEBUG_INFO, "NV Variables were already loaded\n"));
return EFI_ALREADY_STARTED;
@@ -356,7 +349,7 @@ LoadNvVarsFromFs (
// variable data. If it is found, we skip the loading on
// subsequent attempts.
//
- SetNvVarsVariable();
+ SetNvVarsVariable ();
DEBUG ((
DEBUG_INFO,
@@ -367,22 +360,21 @@ LoadNvVarsFromFs (
return Status;
}
-
STATIC
RETURN_STATUS
EFIAPI
IterateVariablesCallbackAddAllNvVariables (
- IN VOID *Context,
- IN CHAR16 *VariableName,
- IN EFI_GUID *VendorGuid,
- IN UINT32 Attributes,
- IN UINTN DataSize,
- IN VOID *Data
+ IN VOID *Context,
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ IN UINT32 Attributes,
+ IN UINTN DataSize,
+ IN VOID *Data
)
{
EFI_HANDLE Instance;
- Instance = (EFI_HANDLE) Context;
+ Instance = (EFI_HANDLE)Context;
//
// Only save non-volatile variables
@@ -401,7 +393,6 @@ IterateVariablesCallbackAddAllNvVariables (
);
}
-
/**
Saves the non-volatile variables into the NvVars file on the
given file system.
@@ -413,15 +404,15 @@ IterateVariablesCallbackAddAllNvVariables (
**/
EFI_STATUS
SaveNvVarsToFs (
- EFI_HANDLE FsHandle
+ EFI_HANDLE FsHandle
)
{
- EFI_STATUS Status;
- EFI_FILE_HANDLE File;
- UINTN WriteSize;
- UINTN VariableDataSize;
- VOID *VariableData;
- EFI_HANDLE SerializedVariables;
+ EFI_STATUS Status;
+ EFI_FILE_HANDLE File;
+ UINTN WriteSize;
+ UINTN VariableDataSize;
+ VOID *VariableData;
+ EFI_HANDLE SerializedVariables;
SerializedVariables = NULL;
@@ -432,19 +423,19 @@ SaveNvVarsToFs (
Status = SerializeVariablesIterateSystemVariables (
IterateVariablesCallbackAddAllNvVariables,
- (VOID*) SerializedVariables
+ (VOID *)SerializedVariables
);
if (EFI_ERROR (Status)) {
return Status;
}
- VariableData = NULL;
+ VariableData = NULL;
VariableDataSize = 0;
- Status = SerializeVariablesToBuffer (
- SerializedVariables,
- NULL,
- &VariableDataSize
- );
+ Status = SerializeVariablesToBuffer (
+ SerializedVariables,
+ NULL,
+ &VariableDataSize
+ );
if (Status == RETURN_BUFFER_TOO_SMALL) {
VariableData = AllocatePool (VariableDataSize);
if (VariableData == NULL) {
@@ -483,7 +474,7 @@ SaveNvVarsToFs (
}
WriteSize = VariableDataSize;
- Status = FileHandleWrite (File, &WriteSize, VariableData);
+ Status = FileHandleWrite (File, &WriteSize, VariableData);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -496,13 +487,10 @@ SaveNvVarsToFs (
// variable data. If it is found, we skip the loading on
// subsequent attempts.
//
- SetNvVarsVariable();
+ SetNvVarsVariable ();
DEBUG ((DEBUG_INFO, "Saved NV Variables to NvVars file\n"));
}
return Status;
-
}
-
-
diff --git a/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c b/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c
index 65ab6a06e1..21b71524ea 100644
--- a/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c
+++ b/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c
@@ -10,8 +10,7 @@
#include <Library/DebugLib.h>
#include <Library/NvVarsFileLib.h>
-EFI_HANDLE mNvVarsFileLibFsHandle = NULL;
-
+EFI_HANDLE mNvVarsFileLibFsHandle = NULL;
/**
Attempts to connect the NvVarsFileLib to the specified file system.
@@ -26,10 +25,10 @@ EFI_HANDLE mNvVarsFileLibFsHandle = NULL;
EFI_STATUS
EFIAPI
ConnectNvVarsToFileSystem (
- IN EFI_HANDLE FsHandle
+ IN EFI_HANDLE FsHandle
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// We might fail to load the variable, since the file system initially
@@ -49,7 +48,6 @@ ConnectNvVarsToFileSystem (
return Status;
}
-
/**
Update non-volatile variables stored on the file system.
@@ -73,5 +71,3 @@ UpdateNvVarsOnFileSystem (
return SaveNvVarsToFs (mNvVarsFileLibFsHandle);
}
}
-
-
diff --git a/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.h b/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.h
index d602ae1fa8..15161cbddc 100644
--- a/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.h
+++ b/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.h
@@ -33,10 +33,9 @@
**/
EFI_STATUS
LoadNvVarsFromFs (
- EFI_HANDLE FsHandle
+ EFI_HANDLE FsHandle
);
-
/**
Saves the non-volatile variables into the NvVars file on the
given file system.
@@ -48,8 +47,7 @@ LoadNvVarsFromFs (
**/
EFI_STATUS
SaveNvVarsToFs (
- EFI_HANDLE FsHandle
+ EFI_HANDLE FsHandle
);
#endif
-
diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
index 835efffcca..c36b6f34c4 100644
--- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
+++ b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
@@ -16,8 +16,7 @@
#include <Protocol/PciHostBridgeResourceAllocation.h> // EFI_PCI_HOST_BRIDGE...
#include <Protocol/PciRootBridgeIo.h> // EFI_PCI_ATTRIBUTE_I...
-STATIC PCI_ROOT_BRIDGE_APERTURE mNonExistAperture = { MAX_UINT64, 0 };
-
+STATIC PCI_ROOT_BRIDGE_APERTURE mNonExistAperture = { MAX_UINT64, 0 };
/**
Return all the root bridge instances in an array.
@@ -31,59 +30,58 @@ STATIC PCI_ROOT_BRIDGE_APERTURE mNonExistAperture = { MAX_UINT64, 0 };
PCI_ROOT_BRIDGE *
EFIAPI
PciHostBridgeGetRootBridges (
- UINTN *Count
+ UINTN *Count
)
{
- UINT64 Attributes;
- UINT64 AllocationAttributes;
- PCI_ROOT_BRIDGE_APERTURE Io;
- PCI_ROOT_BRIDGE_APERTURE Mem;
- PCI_ROOT_BRIDGE_APERTURE MemAbove4G;
+ UINT64 Attributes;
+ UINT64 AllocationAttributes;
+ PCI_ROOT_BRIDGE_APERTURE Io;
+ PCI_ROOT_BRIDGE_APERTURE Mem;
+ PCI_ROOT_BRIDGE_APERTURE MemAbove4G;
ZeroMem (&Io, sizeof (Io));
ZeroMem (&Mem, sizeof (Mem));
ZeroMem (&MemAbove4G, sizeof (MemAbove4G));
Attributes = EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO |
- EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO |
- EFI_PCI_ATTRIBUTE_ISA_IO_16 |
- EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO |
- EFI_PCI_ATTRIBUTE_VGA_MEMORY |
- EFI_PCI_ATTRIBUTE_VGA_IO_16 |
- EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16;
+ EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO |
+ EFI_PCI_ATTRIBUTE_ISA_IO_16 |
+ EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO |
+ EFI_PCI_ATTRIBUTE_VGA_MEMORY |
+ EFI_PCI_ATTRIBUTE_VGA_IO_16 |
+ EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16;
AllocationAttributes = EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM;
if (PcdGet64 (PcdPciMmio64Size) > 0) {
AllocationAttributes |= EFI_PCI_HOST_BRIDGE_MEM64_DECODE;
- MemAbove4G.Base = PcdGet64 (PcdPciMmio64Base);
- MemAbove4G.Limit = PcdGet64 (PcdPciMmio64Base) +
- PcdGet64 (PcdPciMmio64Size) - 1;
+ MemAbove4G.Base = PcdGet64 (PcdPciMmio64Base);
+ MemAbove4G.Limit = PcdGet64 (PcdPciMmio64Base) +
+ PcdGet64 (PcdPciMmio64Size) - 1;
} else {
CopyMem (&MemAbove4G, &mNonExistAperture, sizeof (mNonExistAperture));
}
- Io.Base = PcdGet64 (PcdPciIoBase);
- Io.Limit = PcdGet64 (PcdPciIoBase) + (PcdGet64 (PcdPciIoSize) - 1);
- Mem.Base = PcdGet64 (PcdPciMmio32Base);
+ Io.Base = PcdGet64 (PcdPciIoBase);
+ Io.Limit = PcdGet64 (PcdPciIoBase) + (PcdGet64 (PcdPciIoSize) - 1);
+ Mem.Base = PcdGet64 (PcdPciMmio32Base);
Mem.Limit = PcdGet64 (PcdPciMmio32Base) + (PcdGet64 (PcdPciMmio32Size) - 1);
return PciHostBridgeUtilityGetRootBridges (
- Count,
- Attributes,
- AllocationAttributes,
- FALSE,
- PcdGet16 (PcdOvmfHostBridgePciDevId) != INTEL_Q35_MCH_DEVICE_ID,
- 0,
- PCI_MAX_BUS,
- &Io,
- &Mem,
- &MemAbove4G,
- &mNonExistAperture,
- &mNonExistAperture
- );
+ Count,
+ Attributes,
+ AllocationAttributes,
+ FALSE,
+ PcdGet16 (PcdOvmfHostBridgePciDevId) != INTEL_Q35_MCH_DEVICE_ID,
+ 0,
+ PCI_MAX_BUS,
+ &Io,
+ &Mem,
+ &MemAbove4G,
+ &mNonExistAperture,
+ &mNonExistAperture
+ );
}
-
/**
Free the root bridge instances array returned from
PciHostBridgeGetRootBridges().
@@ -94,14 +92,13 @@ PciHostBridgeGetRootBridges (
VOID
EFIAPI
PciHostBridgeFreeRootBridges (
- PCI_ROOT_BRIDGE *Bridges,
- UINTN Count
+ PCI_ROOT_BRIDGE *Bridges,
+ UINTN Count
)
{
PciHostBridgeUtilityFreeRootBridges (Bridges, Count);
}
-
/**
Inform the platform that the resource conflict happens.
@@ -119,8 +116,8 @@ PciHostBridgeFreeRootBridges (
VOID
EFIAPI
PciHostBridgeResourceConflict (
- EFI_HANDLE HostBridgeHandle,
- VOID *Configuration
+ EFI_HANDLE HostBridgeHandle,
+ VOID *Configuration
)
{
PciHostBridgeUtilityResourceConflict (Configuration);
diff --git a/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridge.h b/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridge.h
index cb05220161..43ab2b2f97 100644
--- a/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridge.h
+++ b/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridge.h
@@ -11,5 +11,5 @@
PCI_ROOT_BRIDGE *
ScanForRootBridges (
- UINTN *NumberOfRootBridges
-);
+ UINTN *NumberOfRootBridges
+ );
diff --git a/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLib.c b/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLib.c
index ac8d1033df..ddcdd8886d 100644
--- a/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLib.c
+++ b/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLib.c
@@ -24,13 +24,12 @@
PCI_ROOT_BRIDGE *
EFIAPI
PciHostBridgeGetRootBridges (
- UINTN *Count
+ UINTN *Count
)
{
return ScanForRootBridges (Count);
}
-
/**
Free the root bridge instances array returned from
PciHostBridgeGetRootBridges().
@@ -41,14 +40,13 @@ PciHostBridgeGetRootBridges (
VOID
EFIAPI
PciHostBridgeFreeRootBridges (
- PCI_ROOT_BRIDGE *Bridges,
- UINTN Count
+ PCI_ROOT_BRIDGE *Bridges,
+ UINTN Count
)
{
PciHostBridgeUtilityFreeRootBridges (Bridges, Count);
}
-
/**
Inform the platform that the resource conflict happens.
@@ -66,8 +64,8 @@ PciHostBridgeFreeRootBridges (
VOID
EFIAPI
PciHostBridgeResourceConflict (
- EFI_HANDLE HostBridgeHandle,
- VOID *Configuration
+ EFI_HANDLE HostBridgeHandle,
+ VOID *Configuration
)
{
PciHostBridgeUtilityResourceConflict (Configuration);
diff --git a/OvmfPkg/Library/PciHostBridgeLibScan/ScanForRootBridges.c b/OvmfPkg/Library/PciHostBridgeLibScan/ScanForRootBridges.c
index a6126a1aea..5fb02a89b9 100644
--- a/OvmfPkg/Library/PciHostBridgeLibScan/ScanForRootBridges.c
+++ b/OvmfPkg/Library/PciHostBridgeLibScan/ScanForRootBridges.c
@@ -23,9 +23,9 @@
STATIC
VOID
PcatPciRootBridgeBarExisted (
- IN UINTN Address,
- OUT UINT32 *OriginalValue,
- OUT UINT32 *Value
+ IN UINTN Address,
+ OUT UINT32 *OriginalValue,
+ OUT UINT32 *Value
)
{
//
@@ -48,15 +48,15 @@ PcatPciRootBridgeBarExisted (
EnableInterrupts ();
}
-#define PCI_COMMAND_DECODE ((UINT16)(EFI_PCI_COMMAND_IO_SPACE | \
+#define PCI_COMMAND_DECODE ((UINT16)(EFI_PCI_COMMAND_IO_SPACE |\
EFI_PCI_COMMAND_MEMORY_SPACE))
STATIC
VOID
PcatPciRootBridgeDecodingDisable (
- IN UINTN Address
+ IN UINTN Address
)
{
- UINT16 Value;
+ UINT16 Value;
Value = PciRead16 (Address);
if (Value & PCI_COMMAND_DECODE) {
@@ -67,59 +67,63 @@ PcatPciRootBridgeDecodingDisable (
STATIC
VOID
PcatPciRootBridgeParseBars (
- IN UINT16 Command,
- IN UINTN Bus,
- IN UINTN Device,
- IN UINTN Function,
- IN UINTN BarOffsetBase,
- IN UINTN BarOffsetEnd,
- IN PCI_ROOT_BRIDGE_APERTURE *Io,
- IN PCI_ROOT_BRIDGE_APERTURE *Mem,
- IN PCI_ROOT_BRIDGE_APERTURE *MemAbove4G
-
-)
+ IN UINT16 Command,
+ IN UINTN Bus,
+ IN UINTN Device,
+ IN UINTN Function,
+ IN UINTN BarOffsetBase,
+ IN UINTN BarOffsetEnd,
+ IN PCI_ROOT_BRIDGE_APERTURE *Io,
+ IN PCI_ROOT_BRIDGE_APERTURE *Mem,
+ IN PCI_ROOT_BRIDGE_APERTURE *MemAbove4G
+
+ )
{
- UINT32 OriginalValue;
- UINT32 Value;
- UINT32 OriginalUpperValue;
- UINT32 UpperValue;
- UINT64 Mask;
- UINTN Offset;
- UINT64 Base;
- UINT64 Length;
- UINT64 Limit;
- PCI_ROOT_BRIDGE_APERTURE *MemAperture;
+ UINT32 OriginalValue;
+ UINT32 Value;
+ UINT32 OriginalUpperValue;
+ UINT32 UpperValue;
+ UINT64 Mask;
+ UINTN Offset;
+ UINT64 Base;
+ UINT64 Length;
+ UINT64 Limit;
+ PCI_ROOT_BRIDGE_APERTURE *MemAperture;
// Disable address decoding for every device before OVMF starts sizing it
PcatPciRootBridgeDecodingDisable (
PCI_LIB_ADDRESS (Bus, Device, Function, PCI_COMMAND_OFFSET)
- );
+ );
for (Offset = BarOffsetBase; Offset < BarOffsetEnd; Offset += sizeof (UINT32)) {
PcatPciRootBridgeBarExisted (
PCI_LIB_ADDRESS (Bus, Device, Function, Offset),
- &OriginalValue, &Value
- );
+ &OriginalValue,
+ &Value
+ );
if (Value == 0) {
continue;
}
+
if ((Value & BIT0) == BIT0) {
//
// IO Bar
//
if (Command & EFI_PCI_COMMAND_IO_SPACE) {
- Mask = 0xfffffffc;
- Base = OriginalValue & Mask;
+ Mask = 0xfffffffc;
+ Base = OriginalValue & Mask;
Length = ((~(Value & Mask)) & Mask) + 0x04;
if (!(Value & 0xFFFF0000)) {
Length &= 0x0000FFFF;
}
+
Limit = Base + Length - 1;
if (Base < Limit) {
if (Io->Base > Base) {
Io->Base = Base;
}
+
if (Io->Limit < Limit) {
Io->Limit = Limit;
}
@@ -130,9 +134,8 @@ PcatPciRootBridgeParseBars (
// Mem Bar
//
if (Command & EFI_PCI_COMMAND_MEMORY_SPACE) {
-
- Mask = 0xfffffff0;
- Base = OriginalValue & Mask;
+ Mask = 0xfffffff0;
+ Base = OriginalValue & Mask;
Length = Value & Mask;
if ((Value & (BIT1 | BIT2)) == 0) {
@@ -151,10 +154,10 @@ PcatPciRootBridgeParseBars (
PCI_LIB_ADDRESS (Bus, Device, Function, Offset),
&OriginalUpperValue,
&UpperValue
- );
+ );
- Base = Base | LShiftU64 ((UINT64) OriginalUpperValue, 32);
- Length = Length | LShiftU64 ((UINT64) UpperValue, 32);
+ Base = Base | LShiftU64 ((UINT64)OriginalUpperValue, 32);
+ Length = Length | LShiftU64 ((UINT64)UpperValue, 32);
Length = (~Length) + 1;
if (Base < BASE_4GB) {
@@ -169,6 +172,7 @@ PcatPciRootBridgeParseBars (
if (MemAperture->Base > Base) {
MemAperture->Base = Base;
}
+
if (MemAperture->Limit < Limit) {
MemAperture->Limit = Limit;
}
@@ -178,31 +182,30 @@ PcatPciRootBridgeParseBars (
}
}
-STATIC PCI_ROOT_BRIDGE_APERTURE mNonExistAperture = { MAX_UINT64, 0 };
+STATIC PCI_ROOT_BRIDGE_APERTURE mNonExistAperture = { MAX_UINT64, 0 };
PCI_ROOT_BRIDGE *
ScanForRootBridges (
- UINTN *NumberOfRootBridges
+ UINTN *NumberOfRootBridges
)
{
- UINTN PrimaryBus;
- UINTN SubBus;
- UINT8 Device;
- UINT8 Function;
- UINTN NumberOfDevices;
- UINTN Address;
- PCI_TYPE01 Pci;
- UINT64 Attributes;
- UINT64 Base;
- UINT64 Limit;
- UINT64 Value;
- PCI_ROOT_BRIDGE_APERTURE Io, Mem, MemAbove4G, *MemAperture;
- PCI_ROOT_BRIDGE *RootBridges;
- UINTN BarOffsetEnd;
-
+ UINTN PrimaryBus;
+ UINTN SubBus;
+ UINT8 Device;
+ UINT8 Function;
+ UINTN NumberOfDevices;
+ UINTN Address;
+ PCI_TYPE01 Pci;
+ UINT64 Attributes;
+ UINT64 Base;
+ UINT64 Limit;
+ UINT64 Value;
+ PCI_ROOT_BRIDGE_APERTURE Io, Mem, MemAbove4G, *MemAperture;
+ PCI_ROOT_BRIDGE *RootBridges;
+ UINTN BarOffsetEnd;
*NumberOfRootBridges = 0;
- RootBridges = NULL;
+ RootBridges = NULL;
//
// After scanning all the PCI devices on the PCI root bridge's primary bus,
@@ -210,7 +213,7 @@ ScanForRootBridges (
// root bridge's subordinate bus number + 1.
//
for (PrimaryBus = 0; PrimaryBus <= PCI_MAX_BUS; PrimaryBus = SubBus + 1) {
- SubBus = PrimaryBus;
+ SubBus = PrimaryBus;
Attributes = 0;
ZeroMem (&Io, sizeof (Io));
@@ -221,9 +224,7 @@ ScanForRootBridges (
// Scan all the PCI devices on the primary bus of the PCI root bridge
//
for (Device = 0, NumberOfDevices = 0; Device <= PCI_MAX_DEVICE; Device++) {
-
for (Function = 0; Function <= PCI_MAX_FUNC; Function++) {
-
//
// Compute the PCI configuration address of the PCI device to probe
//
@@ -290,16 +291,18 @@ ScanForRootBridges (
// Get the I/O range that the PPB is decoding
//
Value = Pci.Bridge.IoBase & 0x0f;
- Base = ((UINT32) Pci.Bridge.IoBase & 0xf0) << 8;
- Limit = (((UINT32) Pci.Bridge.IoLimit & 0xf0) << 8) | 0x0fff;
+ Base = ((UINT32)Pci.Bridge.IoBase & 0xf0) << 8;
+ Limit = (((UINT32)Pci.Bridge.IoLimit & 0xf0) << 8) | 0x0fff;
if (Value == BIT0) {
- Base |= ((UINT32) Pci.Bridge.IoBaseUpper16 << 16);
- Limit |= ((UINT32) Pci.Bridge.IoLimitUpper16 << 16);
+ Base |= ((UINT32)Pci.Bridge.IoBaseUpper16 << 16);
+ Limit |= ((UINT32)Pci.Bridge.IoLimitUpper16 << 16);
}
+
if (Base < Limit) {
if (Io.Base > Base) {
Io.Base = Base;
}
+
if (Io.Limit < Limit) {
Io.Limit = Limit;
}
@@ -308,12 +311,13 @@ ScanForRootBridges (
//
// Get the Memory range that the PPB is decoding
//
- Base = ((UINT32) Pci.Bridge.MemoryBase & 0xfff0) << 16;
- Limit = (((UINT32) Pci.Bridge.MemoryLimit & 0xfff0) << 16) | 0xfffff;
+ Base = ((UINT32)Pci.Bridge.MemoryBase & 0xfff0) << 16;
+ Limit = (((UINT32)Pci.Bridge.MemoryLimit & 0xfff0) << 16) | 0xfffff;
if (Base < Limit) {
if (Mem.Base > Base) {
Mem.Base = Base;
}
+
if (Mem.Limit < Limit) {
Mem.Limit = Limit;
}
@@ -324,19 +328,21 @@ ScanForRootBridges (
// and merge it into Memory range
//
Value = Pci.Bridge.PrefetchableMemoryBase & 0x0f;
- Base = ((UINT32) Pci.Bridge.PrefetchableMemoryBase & 0xfff0) << 16;
- Limit = (((UINT32) Pci.Bridge.PrefetchableMemoryLimit & 0xfff0)
+ Base = ((UINT32)Pci.Bridge.PrefetchableMemoryBase & 0xfff0) << 16;
+ Limit = (((UINT32)Pci.Bridge.PrefetchableMemoryLimit & 0xfff0)
<< 16) | 0xfffff;
MemAperture = &Mem;
if (Value == BIT0) {
- Base |= LShiftU64 (Pci.Bridge.PrefetchableBaseUpper32, 32);
- Limit |= LShiftU64 (Pci.Bridge.PrefetchableLimitUpper32, 32);
+ Base |= LShiftU64 (Pci.Bridge.PrefetchableBaseUpper32, 32);
+ Limit |= LShiftU64 (Pci.Bridge.PrefetchableLimitUpper32, 32);
MemAperture = &MemAbove4G;
}
+
if (Base < Limit) {
if (MemAperture->Base > Base) {
MemAperture->Base = Base;
}
+
if (MemAperture->Limit < Limit) {
MemAperture->Limit = Limit;
}
@@ -346,18 +352,22 @@ ScanForRootBridges (
// Look at the PPB Configuration for legacy decoding attributes
//
if ((Pci.Bridge.BridgeControl & EFI_PCI_BRIDGE_CONTROL_ISA)
- == EFI_PCI_BRIDGE_CONTROL_ISA) {
+ == EFI_PCI_BRIDGE_CONTROL_ISA)
+ {
Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO;
Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO_16;
Attributes |= EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO;
}
+
if ((Pci.Bridge.BridgeControl & EFI_PCI_BRIDGE_CONTROL_VGA)
- == EFI_PCI_BRIDGE_CONTROL_VGA) {
+ == EFI_PCI_BRIDGE_CONTROL_VGA)
+ {
Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO;
Attributes |= EFI_PCI_ATTRIBUTE_VGA_MEMORY;
Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO;
if ((Pci.Bridge.BridgeControl & EFI_PCI_BRIDGE_CONTROL_VGA_16)
- != 0) {
+ != 0)
+ {
Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16;
Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO_16;
}
@@ -382,21 +392,28 @@ ScanForRootBridges (
OFFSET_OF (PCI_TYPE00, Device.Bar),
BarOffsetEnd,
&Io,
- &Mem, &MemAbove4G
- );
+ &Mem,
+ &MemAbove4G
+ );
//
// See if the PCI device is an IDE controller
//
- if (IS_CLASS2 (&Pci, PCI_CLASS_MASS_STORAGE,
- PCI_CLASS_MASS_STORAGE_IDE)) {
+ if (IS_CLASS2 (
+ &Pci,
+ PCI_CLASS_MASS_STORAGE,
+ PCI_CLASS_MASS_STORAGE_IDE
+ ))
+ {
if (Pci.Hdr.ClassCode[0] & 0x80) {
Attributes |= EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO;
Attributes |= EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO;
}
+
if (Pci.Hdr.ClassCode[0] & 0x01) {
Attributes |= EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO;
}
+
if (Pci.Hdr.ClassCode[0] & 0x04) {
Attributes |= EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO;
}
@@ -408,7 +425,8 @@ ScanForRootBridges (
//
if (IS_CLASS2 (&Pci, PCI_CLASS_OLD, PCI_CLASS_OLD_VGA) ||
IS_CLASS2 (&Pci, PCI_CLASS_DISPLAY, PCI_CLASS_DISPLAY_VGA)
- ) {
+ )
+ {
Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO;
Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16;
Attributes |= EFI_PCI_ATTRIBUTE_VGA_MEMORY;
@@ -421,9 +439,10 @@ ScanForRootBridges (
// or ISA_POSITIVE_DECODE Bridge device
//
if (Pci.Hdr.ClassCode[2] == PCI_CLASS_BRIDGE) {
- if (Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_ISA ||
- Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_EISA ||
- Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_ISA_PDECODE) {
+ if ((Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_ISA) ||
+ (Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_EISA) ||
+ (Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_ISA_PDECODE))
+ {
Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO;
Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO_16;
Attributes |= EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO;
@@ -434,7 +453,7 @@ ScanForRootBridges (
// If this device is not a multi function device, then skip the rest
// of this PCI device
//
- if (Function == 0 && !IS_PCI_MULTI_FUNC (&Pci)) {
+ if ((Function == 0) && !IS_PCI_MULTI_FUNC (&Pci)) {
break;
}
}
@@ -446,18 +465,26 @@ ScanForRootBridges (
//
if (NumberOfDevices > 0) {
RootBridges = ReallocatePool (
- (*NumberOfRootBridges) * sizeof (PCI_ROOT_BRIDGE),
- (*NumberOfRootBridges + 1) * sizeof (PCI_ROOT_BRIDGE),
- RootBridges
- );
+ (*NumberOfRootBridges) * sizeof (PCI_ROOT_BRIDGE),
+ (*NumberOfRootBridges + 1) * sizeof (PCI_ROOT_BRIDGE),
+ RootBridges
+ );
ASSERT (RootBridges != NULL);
PciHostBridgeUtilityInitRootBridge (
- Attributes, Attributes, 0,
- FALSE, TRUE /* NoExtendedConfigSpace */,
- (UINT8) PrimaryBus, (UINT8) SubBus,
- &Io, &Mem, &MemAbove4G, &mNonExistAperture, &mNonExistAperture,
+ Attributes,
+ Attributes,
+ 0,
+ FALSE,
+ TRUE /* NoExtendedConfigSpace */,
+ (UINT8)PrimaryBus,
+ (UINT8)SubBus,
+ &Io,
+ &Mem,
+ &MemAbove4G,
+ &mNonExistAperture,
+ &mNonExistAperture,
&RootBridges[*NumberOfRootBridges]
- );
+ );
RootBridges[*NumberOfRootBridges].ResourceAssigned = TRUE;
//
// Increment the index for the next PCI Root Bridge
diff --git a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c
index d2296f3308..92e1ea812f 100644
--- a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c
+++ b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c
@@ -20,35 +20,32 @@
#include <Library/PciLib.h>
#include <Library/QemuFwCfgLib.h>
-
#pragma pack(1)
typedef struct {
- ACPI_HID_DEVICE_PATH AcpiDevicePath;
- EFI_DEVICE_PATH_PROTOCOL EndDevicePath;
+ ACPI_HID_DEVICE_PATH AcpiDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL EndDevicePath;
} OVMF_PCI_ROOT_BRIDGE_DEVICE_PATH;
#pragma pack ()
-
GLOBAL_REMOVE_IF_UNREFERENCED
-CHAR16 *mPciHostBridgeUtilityLibAcpiAddressSpaceTypeStr[] = {
+CHAR16 *mPciHostBridgeUtilityLibAcpiAddressSpaceTypeStr[] = {
L"Mem", L"I/O", L"Bus"
};
-
STATIC
CONST
-OVMF_PCI_ROOT_BRIDGE_DEVICE_PATH mRootBridgeDevicePathTemplate = {
+OVMF_PCI_ROOT_BRIDGE_DEVICE_PATH mRootBridgeDevicePathTemplate = {
{
{
ACPI_DEVICE_PATH,
ACPI_DP,
{
- (UINT8) (sizeof(ACPI_HID_DEVICE_PATH)),
- (UINT8) ((sizeof(ACPI_HID_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (ACPI_HID_DEVICE_PATH)),
+ (UINT8)((sizeof (ACPI_HID_DEVICE_PATH)) >> 8)
}
},
- EISA_PNP_ID(0x0A03), // HID
- 0 // UID
+ EISA_PNP_ID (0x0A03), // HID
+ 0 // UID
},
{
@@ -61,7 +58,6 @@ OVMF_PCI_ROOT_BRIDGE_DEVICE_PATH mRootBridgeDevicePathTemplate = {
}
};
-
/**
Utility function to initialize a PCI_ROOT_BRIDGE structure.
@@ -112,22 +108,22 @@ OVMF_PCI_ROOT_BRIDGE_DEVICE_PATH mRootBridgeDevicePathTemplate = {
EFI_STATUS
EFIAPI
PciHostBridgeUtilityInitRootBridge (
- IN UINT64 Supports,
- IN UINT64 Attributes,
- IN UINT64 AllocAttributes,
- IN BOOLEAN DmaAbove4G,
- IN BOOLEAN NoExtendedConfigSpace,
- IN UINT8 RootBusNumber,
- IN UINT8 MaxSubBusNumber,
- IN PCI_ROOT_BRIDGE_APERTURE *Io,
- IN PCI_ROOT_BRIDGE_APERTURE *Mem,
- IN PCI_ROOT_BRIDGE_APERTURE *MemAbove4G,
- IN PCI_ROOT_BRIDGE_APERTURE *PMem,
- IN PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G,
- OUT PCI_ROOT_BRIDGE *RootBus
+ IN UINT64 Supports,
+ IN UINT64 Attributes,
+ IN UINT64 AllocAttributes,
+ IN BOOLEAN DmaAbove4G,
+ IN BOOLEAN NoExtendedConfigSpace,
+ IN UINT8 RootBusNumber,
+ IN UINT8 MaxSubBusNumber,
+ IN PCI_ROOT_BRIDGE_APERTURE *Io,
+ IN PCI_ROOT_BRIDGE_APERTURE *Mem,
+ IN PCI_ROOT_BRIDGE_APERTURE *MemAbove4G,
+ IN PCI_ROOT_BRIDGE_APERTURE *PMem,
+ IN PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G,
+ OUT PCI_ROOT_BRIDGE *RootBus
)
{
- OVMF_PCI_ROOT_BRIDGE_DEVICE_PATH *DevicePath;
+ OVMF_PCI_ROOT_BRIDGE_DEVICE_PATH *DevicePath;
//
// Be safe if other fields are added to PCI_ROOT_BRIDGE later.
@@ -142,8 +138,8 @@ PciHostBridgeUtilityInitRootBridge (
RootBus->DmaAbove4G = DmaAbove4G;
RootBus->AllocationAttributes = AllocAttributes;
- RootBus->Bus.Base = RootBusNumber;
- RootBus->Bus.Limit = MaxSubBusNumber;
+ RootBus->Bus.Base = RootBusNumber;
+ RootBus->Bus.Limit = MaxSubBusNumber;
CopyMem (&RootBus->Io, Io, sizeof (*Io));
CopyMem (&RootBus->Mem, Mem, sizeof (*Mem));
CopyMem (&RootBus->MemAbove4G, MemAbove4G, sizeof (*MemAbove4G));
@@ -152,22 +148,28 @@ PciHostBridgeUtilityInitRootBridge (
RootBus->NoExtendedConfigSpace = NoExtendedConfigSpace;
- DevicePath = AllocateCopyPool (sizeof mRootBridgeDevicePathTemplate,
- &mRootBridgeDevicePathTemplate);
+ DevicePath = AllocateCopyPool (
+ sizeof mRootBridgeDevicePathTemplate,
+ &mRootBridgeDevicePathTemplate
+ );
if (DevicePath == NULL) {
DEBUG ((DEBUG_ERROR, "%a: %r\n", __FUNCTION__, EFI_OUT_OF_RESOURCES));
return EFI_OUT_OF_RESOURCES;
}
+
DevicePath->AcpiDevicePath.UID = RootBusNumber;
- RootBus->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)DevicePath;
+ RootBus->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)DevicePath;
- DEBUG ((DEBUG_INFO,
+ DEBUG ((
+ DEBUG_INFO,
"%a: populated root bus %d, with room for %d subordinate bus(es)\n",
- __FUNCTION__, RootBusNumber, MaxSubBusNumber - RootBusNumber));
+ __FUNCTION__,
+ RootBusNumber,
+ MaxSubBusNumber - RootBusNumber
+ ));
return EFI_SUCCESS;
}
-
/**
Utility function to uninitialize a PCI_ROOT_BRIDGE structure set up with
PciHostBridgeUtilityInitRootBridge().
@@ -180,13 +182,12 @@ PciHostBridgeUtilityInitRootBridge (
VOID
EFIAPI
PciHostBridgeUtilityUninitRootBridge (
- IN PCI_ROOT_BRIDGE *RootBus
+ IN PCI_ROOT_BRIDGE *RootBus
)
{
FreePool (RootBus->DevicePath);
}
-
/**
Utility function to return all the root bridge instances in an array.
@@ -219,34 +220,40 @@ PciHostBridgeUtilityUninitRootBridge (
PCI_ROOT_BRIDGE *
EFIAPI
PciHostBridgeUtilityGetRootBridges (
- OUT UINTN *Count,
- IN UINT64 Attributes,
- IN UINT64 AllocationAttributes,
- IN BOOLEAN DmaAbove4G,
- IN BOOLEAN NoExtendedConfigSpace,
- IN UINTN BusMin,
- IN UINTN BusMax,
- IN PCI_ROOT_BRIDGE_APERTURE *Io,
- IN PCI_ROOT_BRIDGE_APERTURE *Mem,
- IN PCI_ROOT_BRIDGE_APERTURE *MemAbove4G,
- IN PCI_ROOT_BRIDGE_APERTURE *PMem,
- IN PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G
+ OUT UINTN *Count,
+ IN UINT64 Attributes,
+ IN UINT64 AllocationAttributes,
+ IN BOOLEAN DmaAbove4G,
+ IN BOOLEAN NoExtendedConfigSpace,
+ IN UINTN BusMin,
+ IN UINTN BusMax,
+ IN PCI_ROOT_BRIDGE_APERTURE *Io,
+ IN PCI_ROOT_BRIDGE_APERTURE *Mem,
+ IN PCI_ROOT_BRIDGE_APERTURE *MemAbove4G,
+ IN PCI_ROOT_BRIDGE_APERTURE *PMem,
+ IN PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G
)
{
- EFI_STATUS Status;
- FIRMWARE_CONFIG_ITEM FwCfgItem;
- UINTN FwCfgSize;
- UINT64 ExtraRootBridges;
- PCI_ROOT_BRIDGE *Bridges;
- UINTN Initialized;
- UINTN LastRootBridgeNumber;
- UINTN RootBridgeNumber;
+ EFI_STATUS Status;
+ FIRMWARE_CONFIG_ITEM FwCfgItem;
+ UINTN FwCfgSize;
+ UINT64 ExtraRootBridges;
+ PCI_ROOT_BRIDGE *Bridges;
+ UINTN Initialized;
+ UINTN LastRootBridgeNumber;
+ UINTN RootBridgeNumber;
*Count = 0;
- if (BusMin > BusMax || BusMax > PCI_MAX_BUS) {
- DEBUG ((DEBUG_ERROR, "%a: invalid bus range with BusMin %Lu and BusMax "
- "%Lu\n", __FUNCTION__, (UINT64)BusMin, (UINT64)BusMax));
+ if ((BusMin > BusMax) || (BusMax > PCI_MAX_BUS)) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: invalid bus range with BusMin %Lu and BusMax "
+ "%Lu\n",
+ __FUNCTION__,
+ (UINT64)BusMin,
+ (UINT64)BusMax
+ ));
return NULL;
}
@@ -255,7 +262,7 @@ PciHostBridgeUtilityGetRootBridges (
// search below. If there is no hint, the feature is missing.
//
Status = QemuFwCfgFindFile ("etc/extra-pci-roots", &FwCfgItem, &FwCfgSize);
- if (EFI_ERROR (Status) || FwCfgSize != sizeof ExtraRootBridges) {
+ if (EFI_ERROR (Status) || (FwCfgSize != sizeof ExtraRootBridges)) {
ExtraRootBridges = 0;
} else {
QemuFwCfgSelectItem (FwCfgItem);
@@ -269,12 +276,22 @@ PciHostBridgeUtilityGetRootBridges (
// invalid behavior.
//
if (ExtraRootBridges > BusMax - BusMin) {
- DEBUG ((DEBUG_ERROR, "%a: invalid count of extra root buses (%Lu) "
- "reported by QEMU\n", __FUNCTION__, ExtraRootBridges));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: invalid count of extra root buses (%Lu) "
+ "reported by QEMU\n",
+ __FUNCTION__,
+ ExtraRootBridges
+ ));
return NULL;
}
- DEBUG ((DEBUG_INFO, "%a: %Lu extra root buses reported by QEMU\n",
- __FUNCTION__, ExtraRootBridges));
+
+ DEBUG ((
+ DEBUG_INFO,
+ "%a: %Lu extra root buses reported by QEMU\n",
+ __FUNCTION__,
+ ExtraRootBridges
+ ));
}
//
@@ -285,6 +302,7 @@ PciHostBridgeUtilityGetRootBridges (
DEBUG ((DEBUG_ERROR, "%a: %r\n", __FUNCTION__, EFI_OUT_OF_RESOURCES));
return NULL;
}
+
Initialized = 0;
//
@@ -299,15 +317,24 @@ PciHostBridgeUtilityGetRootBridges (
//
for (RootBridgeNumber = BusMin + 1;
RootBridgeNumber <= BusMax && Initialized < ExtraRootBridges;
- ++RootBridgeNumber) {
- UINTN Device;
+ ++RootBridgeNumber)
+ {
+ UINTN Device;
for (Device = 0; Device <= PCI_MAX_DEVICE; ++Device) {
- if (PciRead16 (PCI_LIB_ADDRESS (RootBridgeNumber, Device, 0,
- PCI_VENDOR_ID_OFFSET)) != MAX_UINT16) {
+ if (PciRead16 (
+ PCI_LIB_ADDRESS (
+ RootBridgeNumber,
+ Device,
+ 0,
+ PCI_VENDOR_ID_OFFSET
+ )
+ ) != MAX_UINT16)
+ {
break;
}
}
+
if (Device <= PCI_MAX_DEVICE) {
//
// Found the next root bus. We can now install the *previous* one,
@@ -315,23 +342,24 @@ PciHostBridgeUtilityGetRootBridges (
// subordinate buses that might exist behind PCI bridges hanging off it.
//
Status = PciHostBridgeUtilityInitRootBridge (
- Attributes,
- Attributes,
- AllocationAttributes,
- DmaAbove4G,
- NoExtendedConfigSpace,
- (UINT8) LastRootBridgeNumber,
- (UINT8) (RootBridgeNumber - 1),
- Io,
- Mem,
- MemAbove4G,
- PMem,
- PMemAbove4G,
- &Bridges[Initialized]
- );
+ Attributes,
+ Attributes,
+ AllocationAttributes,
+ DmaAbove4G,
+ NoExtendedConfigSpace,
+ (UINT8)LastRootBridgeNumber,
+ (UINT8)(RootBridgeNumber - 1),
+ Io,
+ Mem,
+ MemAbove4G,
+ PMem,
+ PMemAbove4G,
+ &Bridges[Initialized]
+ );
if (EFI_ERROR (Status)) {
goto FreeBridges;
}
+
++Initialized;
LastRootBridgeNumber = RootBridgeNumber;
}
@@ -342,23 +370,24 @@ PciHostBridgeUtilityGetRootBridges (
// we've found no extra root buses).
//
Status = PciHostBridgeUtilityInitRootBridge (
- Attributes,
- Attributes,
- AllocationAttributes,
- DmaAbove4G,
- NoExtendedConfigSpace,
- (UINT8) LastRootBridgeNumber,
- (UINT8) BusMax,
- Io,
- Mem,
- MemAbove4G,
- PMem,
- PMemAbove4G,
- &Bridges[Initialized]
- );
+ Attributes,
+ Attributes,
+ AllocationAttributes,
+ DmaAbove4G,
+ NoExtendedConfigSpace,
+ (UINT8)LastRootBridgeNumber,
+ (UINT8)BusMax,
+ Io,
+ Mem,
+ MemAbove4G,
+ PMem,
+ PMemAbove4G,
+ &Bridges[Initialized]
+ );
if (EFI_ERROR (Status)) {
goto FreeBridges;
}
+
++Initialized;
*Count = Initialized;
@@ -374,7 +403,6 @@ FreeBridges:
return NULL;
}
-
/**
Utility function to free root bridge instances array from
PciHostBridgeUtilityGetRootBridges().
@@ -385,13 +413,14 @@ FreeBridges:
VOID
EFIAPI
PciHostBridgeUtilityFreeRootBridges (
- IN PCI_ROOT_BRIDGE *Bridges,
- IN UINTN Count
+ IN PCI_ROOT_BRIDGE *Bridges,
+ IN UINTN Count
)
{
- if (Bridges == NULL && Count == 0) {
+ if ((Bridges == NULL) && (Count == 0)) {
return;
}
+
ASSERT (Bridges != NULL && Count > 0);
do {
@@ -402,7 +431,6 @@ PciHostBridgeUtilityFreeRootBridges (
FreePool (Bridges);
}
-
/**
Utility function to inform the platform that the resource conflict happens.
@@ -423,38 +451,46 @@ PciHostBridgeUtilityResourceConflict (
IN VOID *Configuration
)
{
- EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptor;
- UINTN RootBridgeIndex;
+ EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptor;
+ UINTN RootBridgeIndex;
+
DEBUG ((DEBUG_ERROR, "PciHostBridge: Resource conflict happens!\n"));
RootBridgeIndex = 0;
- Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *) Configuration;
+ Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)Configuration;
while (Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR) {
DEBUG ((DEBUG_ERROR, "RootBridge[%d]:\n", RootBridgeIndex++));
- for (; Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR; Descriptor++) {
- ASSERT (Descriptor->ResType <
- ARRAY_SIZE (mPciHostBridgeUtilityLibAcpiAddressSpaceTypeStr)
- );
- DEBUG ((DEBUG_ERROR, " %s: Length/Alignment = 0x%lx / 0x%lx\n",
- mPciHostBridgeUtilityLibAcpiAddressSpaceTypeStr[Descriptor->ResType],
- Descriptor->AddrLen, Descriptor->AddrRangeMax
- ));
+ for ( ; Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR; Descriptor++) {
+ ASSERT (
+ Descriptor->ResType <
+ ARRAY_SIZE (mPciHostBridgeUtilityLibAcpiAddressSpaceTypeStr)
+ );
+ DEBUG ((
+ DEBUG_ERROR,
+ " %s: Length/Alignment = 0x%lx / 0x%lx\n",
+ mPciHostBridgeUtilityLibAcpiAddressSpaceTypeStr[Descriptor->ResType],
+ Descriptor->AddrLen,
+ Descriptor->AddrRangeMax
+ ));
if (Descriptor->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) {
- DEBUG ((DEBUG_ERROR, " Granularity/SpecificFlag = %ld / %02x%s\n",
- Descriptor->AddrSpaceGranularity, Descriptor->SpecificFlag,
- ((Descriptor->SpecificFlag &
- EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFETCHABLE
- ) != 0) ? L" (Prefetchable)" : L""
- ));
+ DEBUG ((
+ DEBUG_ERROR,
+ " Granularity/SpecificFlag = %ld / %02x%s\n",
+ Descriptor->AddrSpaceGranularity,
+ Descriptor->SpecificFlag,
+ ((Descriptor->SpecificFlag &
+ EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFETCHABLE
+ ) != 0) ? L" (Prefetchable)" : L""
+ ));
}
}
+
//
// Skip the END descriptor for root bridge
//
ASSERT (Descriptor->Desc == ACPI_END_TAG_DESCRIPTOR);
Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)(
- (EFI_ACPI_END_TAG_DESCRIPTOR *)Descriptor + 1
- );
+ (EFI_ACPI_END_TAG_DESCRIPTOR *)Descriptor + 1
+ );
}
}
-
diff --git a/OvmfPkg/Library/PlatformBmPrintScLib/StatusCodeHandler.c b/OvmfPkg/Library/PlatformBmPrintScLib/StatusCodeHandler.c
index 594ab105e2..065673d904 100644
--- a/OvmfPkg/Library/PlatformBmPrintScLib/StatusCodeHandler.c
+++ b/OvmfPkg/Library/PlatformBmPrintScLib/StatusCodeHandler.c
@@ -36,16 +36,14 @@
#include <Pi/PiStatusCode.h>
-
//
// Convenience variables for the status codes that are relevant for LoadImage()
// and StartImage() preparations and return codes.
//
-STATIC EFI_STATUS_CODE_VALUE mLoadPrep;
-STATIC EFI_STATUS_CODE_VALUE mLoadFail;
-STATIC EFI_STATUS_CODE_VALUE mStartPrep;
-STATIC EFI_STATUS_CODE_VALUE mStartFail;
-
+STATIC EFI_STATUS_CODE_VALUE mLoadPrep;
+STATIC EFI_STATUS_CODE_VALUE mLoadFail;
+STATIC EFI_STATUS_CODE_VALUE mStartPrep;
+STATIC EFI_STATUS_CODE_VALUE mStartFail;
/**
Handle status codes reported through ReportStatusCodeLib /
@@ -79,29 +77,31 @@ STATIC
EFI_STATUS
EFIAPI
HandleStatusCode (
- IN EFI_STATUS_CODE_TYPE CodeType,
- IN EFI_STATUS_CODE_VALUE Value,
- IN UINT32 Instance,
- IN EFI_GUID *CallerId,
- IN EFI_STATUS_CODE_DATA *Data
+ IN EFI_STATUS_CODE_TYPE CodeType,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID *CallerId,
+ IN EFI_STATUS_CODE_DATA *Data
)
{
- UINTN VariableSize;
- UINT16 BootCurrent;
- EFI_STATUS Status;
- CHAR16 BootOptionName[ARRAY_SIZE (L"Boot####")];
- EFI_BOOT_MANAGER_LOAD_OPTION BmBootOption;
- BOOLEAN DevPathStringIsDynamic;
- CHAR16 *DevPathString;
+ UINTN VariableSize;
+ UINT16 BootCurrent;
+ EFI_STATUS Status;
+ CHAR16 BootOptionName[ARRAY_SIZE (L"Boot####")];
+ EFI_BOOT_MANAGER_LOAD_OPTION BmBootOption;
+ BOOLEAN DevPathStringIsDynamic;
+ CHAR16 *DevPathString;
//
// Ignore all status codes that are irrelevant for LoadImage() and
// StartImage() preparations and return codes.
//
- if (Value != mLoadPrep && Value != mLoadFail &&
- Value != mStartPrep && Value != mStartFail) {
+ if ((Value != mLoadPrep) && (Value != mLoadFail) &&
+ (Value != mStartPrep) && (Value != mStartFail))
+ {
return EFI_SUCCESS;
}
+
//
// Ignore status codes that are not reported by the same containing module.
//
@@ -112,13 +112,18 @@ HandleStatusCode (
//
// Sanity-check Data in case of failure reports.
//
- if ((Value == mLoadFail || Value == mStartFail) &&
- (Data == NULL ||
- Data->HeaderSize != sizeof *Data ||
- Data->Size != sizeof (EFI_RETURN_STATUS_EXTENDED_DATA) - sizeof *Data ||
- !CompareGuid (&Data->Type, &gEfiStatusCodeSpecificDataGuid))) {
- DEBUG ((DEBUG_ERROR, "%a:%a: malformed Data\n", gEfiCallerBaseName,
- __FUNCTION__));
+ if (((Value == mLoadFail) || (Value == mStartFail)) &&
+ ((Data == NULL) ||
+ (Data->HeaderSize != sizeof *Data) ||
+ (Data->Size != sizeof (EFI_RETURN_STATUS_EXTENDED_DATA) - sizeof *Data) ||
+ !CompareGuid (&Data->Type, &gEfiStatusCodeSpecificDataGuid)))
+ {
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a:%a: malformed Data\n",
+ gEfiCallerBaseName,
+ __FUNCTION__
+ ));
return EFI_INVALID_PARAMETER;
}
@@ -126,33 +131,59 @@ HandleStatusCode (
// Get the number of the Boot#### option that the status code applies to.
//
VariableSize = sizeof BootCurrent;
- Status = gRT->GetVariable (EFI_BOOT_CURRENT_VARIABLE_NAME,
- &gEfiGlobalVariableGuid, NULL /* Attributes */,
- &VariableSize, &BootCurrent);
+ Status = gRT->GetVariable (
+ EFI_BOOT_CURRENT_VARIABLE_NAME,
+ &gEfiGlobalVariableGuid,
+ NULL /* Attributes */,
+ &VariableSize,
+ &BootCurrent
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a:%a: failed to get %g:\"%s\": %r\n",
- gEfiCallerBaseName, __FUNCTION__, &gEfiGlobalVariableGuid,
- EFI_BOOT_CURRENT_VARIABLE_NAME, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a:%a: failed to get %g:\"%s\": %r\n",
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ &gEfiGlobalVariableGuid,
+ EFI_BOOT_CURRENT_VARIABLE_NAME,
+ Status
+ ));
return Status;
}
+
if (VariableSize != sizeof BootCurrent) {
- DEBUG ((DEBUG_ERROR, "%a:%a: got %Lu bytes for %g:\"%s\", expected %Lu\n",
- gEfiCallerBaseName, __FUNCTION__, (UINT64)VariableSize,
- &gEfiGlobalVariableGuid, EFI_BOOT_CURRENT_VARIABLE_NAME,
- (UINT64)sizeof BootCurrent));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a:%a: got %Lu bytes for %g:\"%s\", expected %Lu\n",
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ (UINT64)VariableSize,
+ &gEfiGlobalVariableGuid,
+ EFI_BOOT_CURRENT_VARIABLE_NAME,
+ (UINT64)sizeof BootCurrent
+ ));
return EFI_INCOMPATIBLE_VERSION;
}
//
// Get the Boot#### option that the status code applies to.
//
- UnicodeSPrint (BootOptionName, sizeof BootOptionName, L"Boot%04x",
- BootCurrent);
+ UnicodeSPrint (
+ BootOptionName,
+ sizeof BootOptionName,
+ L"Boot%04x",
+ BootCurrent
+ );
Status = EfiBootManagerVariableToLoadOption (BootOptionName, &BmBootOption);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR,
+ DEBUG ((
+ DEBUG_ERROR,
"%a:%a: EfiBootManagerVariableToLoadOption(\"%s\"): %r\n",
- gEfiCallerBaseName, __FUNCTION__, BootOptionName, Status));
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ BootOptionName,
+ Status
+ ));
return Status;
}
@@ -160,20 +191,20 @@ HandleStatusCode (
// Format the device path.
//
DevPathStringIsDynamic = TRUE;
- DevPathString = ConvertDevicePathToText (
- BmBootOption.FilePath,
- FALSE, // DisplayOnly
- FALSE // AllowShortcuts
- );
+ DevPathString = ConvertDevicePathToText (
+ BmBootOption.FilePath,
+ FALSE, // DisplayOnly
+ FALSE // AllowShortcuts
+ );
if (DevPathString == NULL) {
DevPathStringIsDynamic = FALSE;
- DevPathString = L"<out of memory while formatting device path>";
+ DevPathString = L"<out of memory while formatting device path>";
}
//
// Print the message to the console.
//
- if (Value == mLoadPrep || Value == mStartPrep) {
+ if ((Value == mLoadPrep) || (Value == mStartPrep)) {
Print (
L"%a: %a %s \"%s\" from %s\n",
gEfiCallerBaseName,
@@ -200,11 +231,11 @@ HandleStatusCode (
if (DevPathStringIsDynamic) {
FreePool (DevPathString);
}
+
EfiBootManagerFreeLoadOption (&BmBootOption);
return EFI_SUCCESS;
}
-
/**
Unregister HandleStatusCode() at ExitBootServices().
@@ -219,17 +250,16 @@ STATIC
VOID
EFIAPI
UnregisterAtExitBootServices (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- EFI_RSC_HANDLER_PROTOCOL *StatusCodeRouter;
+ EFI_RSC_HANDLER_PROTOCOL *StatusCodeRouter;
StatusCodeRouter = Context;
StatusCodeRouter->Unregister (HandleStatusCode);
}
-
/**
Register a status code handler for printing the Boot Manager's LoadImage()
and StartImage() preparations, and return codes, to the UEFI console.
@@ -246,12 +276,15 @@ PlatformBmPrintScRegisterHandler (
VOID
)
{
- EFI_STATUS Status;
- EFI_RSC_HANDLER_PROTOCOL *StatusCodeRouter;
- EFI_EVENT ExitBootEvent;
-
- Status = gBS->LocateProtocol (&gEfiRscHandlerProtocolGuid,
- NULL /* Registration */, (VOID **)&StatusCodeRouter);
+ EFI_STATUS Status;
+ EFI_RSC_HANDLER_PROTOCOL *StatusCodeRouter;
+ EFI_EVENT ExitBootEvent;
+
+ Status = gBS->LocateProtocol (
+ &gEfiRscHandlerProtocolGuid,
+ NULL /* Registration */,
+ (VOID **)&StatusCodeRouter
+ );
ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
return Status;
@@ -260,9 +293,9 @@ PlatformBmPrintScRegisterHandler (
//
// Set the EFI_STATUS_CODE_VALUE convenience variables.
//
- mLoadPrep = PcdGet32 (PcdProgressCodeOsLoaderLoad);
- mLoadFail = (EFI_SOFTWARE_DXE_BS_DRIVER |
- EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR);
+ mLoadPrep = PcdGet32 (PcdProgressCodeOsLoaderLoad);
+ mLoadFail = (EFI_SOFTWARE_DXE_BS_DRIVER |
+ EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR);
mStartPrep = PcdGet32 (PcdProgressCodeOsLoaderStart);
mStartFail = (EFI_SOFTWARE_DXE_BS_DRIVER |
EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED);
@@ -272,8 +305,13 @@ PlatformBmPrintScRegisterHandler (
//
Status = StatusCodeRouter->Register (HandleStatusCode, TPL_CALLBACK);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a:%a: failed to register status code handler: %r\n",
- gEfiCallerBaseName, __FUNCTION__, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a:%a: failed to register status code handler: %r\n",
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ Status
+ ));
return Status;
}
@@ -294,8 +332,14 @@ PlatformBmPrintScRegisterHandler (
//
// We have to unregister the callback right now, and fail the function.
//
- DEBUG ((DEBUG_ERROR, "%a:%a: failed to create ExitBootServices() event: "
- "%r\n", gEfiCallerBaseName, __FUNCTION__, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a:%a: failed to create ExitBootServices() event: "
+ "%r\n",
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ Status
+ ));
StatusCodeRouter->Unregister (HandleStatusCode);
return Status;
}
diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
index 1408d94f7d..f73c59dfff 100644
--- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
+++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
@@ -14,22 +14,21 @@
#include <Library/Tcg2PhysicalPresenceLib.h>
#include <Library/XenPlatformLib.h>
-
//
// Global data
//
-VOID *mEfiDevPathNotifyReg;
-EFI_EVENT mEfiDevPathEvent;
-VOID *mEmuVariableEventReg;
-EFI_EVENT mEmuVariableEvent;
-UINT16 mHostBridgeDevId;
+VOID *mEfiDevPathNotifyReg;
+EFI_EVENT mEfiDevPathEvent;
+VOID *mEmuVariableEventReg;
+EFI_EVENT mEmuVariableEvent;
+UINT16 mHostBridgeDevId;
//
// Table of host IRQs matching PCI IRQs A-D
// (for configuring PCI Interrupt Line register)
//
-CONST UINT8 PciHostIrqs[] = {
+CONST UINT8 PciHostIrqs[] = {
0x0a, // LNKA, LNKE
0x0a, // LNKB, LNKF
0x0b, // LNKC, LNKG
@@ -61,7 +60,6 @@ EFI_STATUS
IN PCI_TYPE00 *Pci
);
-
//
// Function prototypes
//
@@ -75,7 +73,7 @@ VisitAllInstancesOfProtocol (
EFI_STATUS
VisitAllPciInstancesOfProtocol (
- IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction
+ IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction
);
VOID
@@ -85,24 +83,24 @@ InstallDevicePathCallback (
VOID
PlatformRegisterFvBootOption (
- EFI_GUID *FileGuid,
- CHAR16 *Description,
- UINT32 Attributes
+ EFI_GUID *FileGuid,
+ CHAR16 *Description,
+ UINT32 Attributes
)
{
- EFI_STATUS Status;
- INTN OptionIndex;
- EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
- EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
- UINTN BootOptionCount;
- MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
- EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_STATUS Status;
+ INTN OptionIndex;
+ EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
+ EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
+ UINTN BootOptionCount;
+ MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
Status = gBS->HandleProtocol (
gImageHandle,
&gEfiLoadedImageProtocolGuid,
- (VOID **) &LoadedImage
+ (VOID **)&LoadedImage
);
ASSERT_EFI_ERROR (Status);
@@ -111,7 +109,7 @@ PlatformRegisterFvBootOption (
ASSERT (DevicePath != NULL);
DevicePath = AppendDevicePathNode (
DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *) &FileNode
+ (EFI_DEVICE_PATH_PROTOCOL *)&FileNode
);
ASSERT (DevicePath != NULL);
@@ -129,17 +127,21 @@ PlatformRegisterFvBootOption (
FreePool (DevicePath);
BootOptions = EfiBootManagerGetLoadOptions (
- &BootOptionCount, LoadOptionTypeBoot
+ &BootOptionCount,
+ LoadOptionTypeBoot
);
OptionIndex = EfiBootManagerFindLoadOption (
- &NewOption, BootOptions, BootOptionCount
+ &NewOption,
+ BootOptions,
+ BootOptionCount
);
if (OptionIndex == -1) {
Status = EfiBootManagerAddLoadOptionVariable (&NewOption, MAX_UINTN);
ASSERT_EFI_ERROR (Status);
}
+
EfiBootManagerFreeLoadOption (&NewOption);
EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
}
@@ -163,27 +165,30 @@ RemoveStaleFvFileOptions (
VOID
)
{
- EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
- UINTN BootOptionCount;
- UINTN Index;
+ EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
+ UINTN BootOptionCount;
+ UINTN Index;
- BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount,
- LoadOptionTypeBoot);
+ BootOptions = EfiBootManagerGetLoadOptions (
+ &BootOptionCount,
+ LoadOptionTypeBoot
+ );
for (Index = 0; Index < BootOptionCount; ++Index) {
- EFI_DEVICE_PATH_PROTOCOL *Node1, *Node2, *SearchNode;
- EFI_STATUS Status;
- EFI_HANDLE FvHandle;
+ EFI_DEVICE_PATH_PROTOCOL *Node1, *Node2, *SearchNode;
+ EFI_STATUS Status;
+ EFI_HANDLE FvHandle;
//
// If the device path starts with neither MemoryMapped(...) nor Fv(...),
// then keep the boot option.
//
Node1 = BootOptions[Index].FilePath;
- if (!(DevicePathType (Node1) == HARDWARE_DEVICE_PATH &&
- DevicePathSubType (Node1) == HW_MEMMAP_DP) &&
- !(DevicePathType (Node1) == MEDIA_DEVICE_PATH &&
- DevicePathSubType (Node1) == MEDIA_PIWG_FW_VOL_DP)) {
+ if (!((DevicePathType (Node1) == HARDWARE_DEVICE_PATH) &&
+ (DevicePathSubType (Node1) == HW_MEMMAP_DP)) &&
+ !((DevicePathType (Node1) == MEDIA_DEVICE_PATH) &&
+ (DevicePathSubType (Node1) == MEDIA_PIWG_FW_VOL_DP)))
+ {
continue;
}
@@ -192,8 +197,9 @@ RemoveStaleFvFileOptions (
// option.
//
Node2 = NextDevicePathNode (Node1);
- if (DevicePathType (Node2) != MEDIA_DEVICE_PATH ||
- DevicePathSubType (Node2) != MEDIA_PIWG_FW_FILE_DP) {
+ if ((DevicePathType (Node2) != MEDIA_DEVICE_PATH) ||
+ (DevicePathSubType (Node2) != MEDIA_PIWG_FW_FILE_DP))
+ {
continue;
}
@@ -204,23 +210,29 @@ RemoveStaleFvFileOptions (
// boot option.
//
SearchNode = Node1;
- Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid,
- &SearchNode, &FvHandle);
+ Status = gBS->LocateDevicePath (
+ &gEfiFirmwareVolume2ProtocolGuid,
+ &SearchNode,
+ &FvHandle
+ );
if (!EFI_ERROR (Status)) {
//
// The firmware volume was found; now let's see if it contains the FvFile
// identified by GUID.
//
- EFI_FIRMWARE_VOLUME2_PROTOCOL *FvProtocol;
- MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFileNode;
- UINTN BufferSize;
- EFI_FV_FILETYPE FoundType;
- EFI_FV_FILE_ATTRIBUTES FileAttributes;
- UINT32 AuthenticationStatus;
-
- Status = gBS->HandleProtocol (FvHandle, &gEfiFirmwareVolume2ProtocolGuid,
- (VOID **)&FvProtocol);
+ EFI_FIRMWARE_VOLUME2_PROTOCOL *FvProtocol;
+ MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFileNode;
+ UINTN BufferSize;
+ EFI_FV_FILETYPE FoundType;
+ EFI_FV_FILE_ATTRIBUTES FileAttributes;
+ UINT32 AuthenticationStatus;
+
+ Status = gBS->HandleProtocol (
+ FvHandle,
+ &gEfiFirmwareVolume2ProtocolGuid,
+ (VOID **)&FvProtocol
+ );
ASSERT_EFI_ERROR (Status);
FvFileNode = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)Node2;
@@ -249,23 +261,29 @@ RemoveStaleFvFileOptions (
// Delete the boot option.
//
Status = EfiBootManagerDeleteLoadOptionVariable (
- BootOptions[Index].OptionNumber, LoadOptionTypeBoot);
+ BootOptions[Index].OptionNumber,
+ LoadOptionTypeBoot
+ );
DEBUG_CODE_BEGIN ();
- CHAR16 *DevicePathString;
+ CHAR16 *DevicePathString;
+
+ DevicePathString = ConvertDevicePathToText (
+ BootOptions[Index].FilePath,
+ FALSE,
+ FALSE
+ );
+ DEBUG ((
+ EFI_ERROR (Status) ? DEBUG_WARN : DEBUG_VERBOSE,
+ "%a: removing stale Boot#%04x %s: %r\n",
+ __FUNCTION__,
+ (UINT32)BootOptions[Index].OptionNumber,
+ DevicePathString == NULL ? L"<unavailable>" : DevicePathString,
+ Status
+ ));
+ if (DevicePathString != NULL) {
+ FreePool (DevicePathString);
+ }
- DevicePathString = ConvertDevicePathToText(BootOptions[Index].FilePath,
- FALSE, FALSE);
- DEBUG ((
- EFI_ERROR (Status) ? DEBUG_WARN : DEBUG_VERBOSE,
- "%a: removing stale Boot#%04x %s: %r\n",
- __FUNCTION__,
- (UINT32)BootOptions[Index].OptionNumber,
- DevicePathString == NULL ? L"<unavailable>" : DevicePathString,
- Status
- ));
- if (DevicePathString != NULL) {
- FreePool (DevicePathString);
- }
DEBUG_CODE_END ();
}
@@ -277,18 +295,18 @@ PlatformRegisterOptionsAndKeys (
VOID
)
{
- EFI_STATUS Status;
- EFI_INPUT_KEY Enter;
- EFI_INPUT_KEY F2;
- EFI_INPUT_KEY Esc;
- EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
+ EFI_STATUS Status;
+ EFI_INPUT_KEY Enter;
+ EFI_INPUT_KEY F2;
+ EFI_INPUT_KEY Esc;
+ EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
//
// Register ENTER as CONTINUE key
//
Enter.ScanCode = SCAN_NULL;
Enter.UnicodeChar = CHAR_CARRIAGE_RETURN;
- Status = EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL);
+ Status = EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL);
ASSERT_EFI_ERROR (Status);
//
@@ -298,14 +316,22 @@ PlatformRegisterOptionsAndKeys (
F2.UnicodeChar = CHAR_NULL;
Esc.ScanCode = SCAN_ESC;
Esc.UnicodeChar = CHAR_NULL;
- Status = EfiBootManagerGetBootManagerMenu (&BootOption);
+ Status = EfiBootManagerGetBootManagerMenu (&BootOption);
ASSERT_EFI_ERROR (Status);
Status = EfiBootManagerAddKeyOptionVariable (
- NULL, (UINT16) BootOption.OptionNumber, 0, &F2, NULL
+ NULL,
+ (UINT16)BootOption.OptionNumber,
+ 0,
+ &F2,
+ NULL
);
ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
Status = EfiBootManagerAddKeyOptionVariable (
- NULL, (UINT16) BootOption.OptionNumber, 0, &Esc, NULL
+ NULL,
+ (UINT16)BootOption.OptionNumber,
+ 0,
+ &Esc,
+ NULL
);
ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
}
@@ -322,9 +348,9 @@ STATIC
EFI_STATUS
EFIAPI
ConnectVirtioPciRng (
- IN EFI_HANDLE Handle,
- IN VOID *Instance,
- IN VOID *Context
+ IN EFI_HANDLE Handle,
+ IN VOID *Instance,
+ IN VOID *Context
);
STATIC
@@ -336,6 +362,7 @@ SaveS3BootScript (
//
// BDS Platform Functions
//
+
/**
Do the platform init, can be customized by OEM/IBV
@@ -355,16 +382,19 @@ PlatformBootManagerBeforeConsole (
VOID
)
{
- EFI_HANDLE Handle;
- EFI_STATUS Status;
- UINT16 FrontPageTimeout;
- RETURN_STATUS PcdStatus;
+ EFI_HANDLE Handle;
+ EFI_STATUS Status;
+ UINT16 FrontPageTimeout;
+ RETURN_STATUS PcdStatus;
DEBUG ((DEBUG_INFO, "PlatformBootManagerBeforeConsole\n"));
InstallDevicePathCallback ();
- VisitAllInstancesOfProtocol (&gEfiPciRootBridgeIoProtocolGuid,
- ConnectRootBridge, NULL);
+ VisitAllInstancesOfProtocol (
+ &gEfiPciRootBridgeIoProtocolGuid,
+ ConnectRootBridge,
+ NULL
+ );
//
// Signal the ACPI platform driver that it can download QEMU ACPI tables.
@@ -391,7 +421,8 @@ PlatformBootManagerBeforeConsole (
// We need to connect all trusted consoles for TCG PP. Here we treat all
// consoles in OVMF to be trusted consoles.
PlatformInitializeConsole (
- XenDetected() ? gXenPlatformConsole : gPlatformConsole);
+ XenDetected () ? gXenPlatformConsole : gPlatformConsole
+ );
//
// Process TPM PPI request; this may require keyboard input
@@ -403,9 +434,12 @@ PlatformBootManagerBeforeConsole (
// Any TPM 2 Physical Presence Interface opcode must be handled before.
//
Handle = NULL;
- Status = gBS->InstallProtocolInterface (&Handle,
- &gEfiDxeSmmReadyToLockProtocolGuid, EFI_NATIVE_INTERFACE,
- NULL);
+ Status = gBS->InstallProtocolInterface (
+ &Handle,
+ &gEfiDxeSmmReadyToLockProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ NULL
+ );
ASSERT_EFI_ERROR (Status);
//
@@ -415,7 +449,7 @@ PlatformBootManagerBeforeConsole (
EfiBootManagerDispatchDeferredImages ();
FrontPageTimeout = GetFrontPageTimeoutFromQemu ();
- PcdStatus = PcdSet16S (PcdPlatformBootTimeOut, FrontPageTimeout);
+ PcdStatus = PcdSet16S (PcdPlatformBootTimeOut, FrontPageTimeout);
ASSERT_RETURN_ERROR (PcdStatus);
//
// Reflect the PCD in the standard Timeout variable.
@@ -444,11 +478,13 @@ PlatformBootManagerBeforeConsole (
// Install both VIRTIO_DEVICE_PROTOCOL and (dependent) EFI_RNG_PROTOCOL
// instances on Virtio PCI RNG devices.
//
- VisitAllInstancesOfProtocol (&gEfiPciIoProtocolGuid, ConnectVirtioPciRng,
- NULL);
+ VisitAllInstancesOfProtocol (
+ &gEfiPciIoProtocolGuid,
+ ConnectVirtioPciRng,
+ NULL
+ );
}
-
EFI_STATUS
EFIAPI
ConnectRootBridge (
@@ -457,7 +493,7 @@ ConnectRootBridge (
IN VOID *Context
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Make the PCI bus driver connect the root bridge, non-recursively. This
@@ -473,34 +509,39 @@ ConnectRootBridge (
return Status;
}
-
STATIC
EFI_STATUS
EFIAPI
ConnectVirtioPciRng (
- IN EFI_HANDLE Handle,
- IN VOID *Instance,
- IN VOID *Context
+ IN EFI_HANDLE Handle,
+ IN VOID *Instance,
+ IN VOID *Context
)
{
- EFI_PCI_IO_PROTOCOL *PciIo;
- EFI_STATUS Status;
- UINT16 VendorId;
- UINT16 DeviceId;
- UINT8 RevisionId;
- BOOLEAN Virtio10;
- UINT16 SubsystemId;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ EFI_STATUS Status;
+ UINT16 VendorId;
+ UINT16 DeviceId;
+ UINT8 RevisionId;
+ BOOLEAN Virtio10;
+ UINT16 SubsystemId;
PciIo = Instance;
//
// Read and check VendorId.
//
- Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint16, PCI_VENDOR_ID_OFFSET,
- 1, &VendorId);
+ Status = PciIo->Pci.Read (
+ PciIo,
+ EfiPciIoWidthUint16,
+ PCI_VENDOR_ID_OFFSET,
+ 1,
+ &VendorId
+ );
if (EFI_ERROR (Status)) {
goto Error;
}
+
if (VendorId != VIRTIO_VENDOR_ID) {
return EFI_SUCCESS;
}
@@ -508,13 +549,24 @@ ConnectVirtioPciRng (
//
// Read DeviceId and RevisionId.
//
- Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint16, PCI_DEVICE_ID_OFFSET,
- 1, &DeviceId);
+ Status = PciIo->Pci.Read (
+ PciIo,
+ EfiPciIoWidthUint16,
+ PCI_DEVICE_ID_OFFSET,
+ 1,
+ &DeviceId
+ );
if (EFI_ERROR (Status)) {
goto Error;
}
- Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, PCI_REVISION_ID_OFFSET,
- 1, &RevisionId);
+
+ Status = PciIo->Pci.Read (
+ PciIo,
+ EfiPciIoWidthUint8,
+ PCI_REVISION_ID_OFFSET,
+ 1,
+ &RevisionId
+ );
if (EFI_ERROR (Status)) {
goto Error;
}
@@ -526,10 +578,11 @@ ConnectVirtioPciRng (
// SubsystemId will only play a sanity-check role. Otherwise, DeviceId can
// only be sanity-checked, and SubsystemId will decide.
//
- if (DeviceId == 0x1040 + VIRTIO_SUBSYSTEM_ENTROPY_SOURCE &&
- RevisionId >= 0x01) {
+ if ((DeviceId == 0x1040 + VIRTIO_SUBSYSTEM_ENTROPY_SOURCE) &&
+ (RevisionId >= 0x01))
+ {
Virtio10 = TRUE;
- } else if (DeviceId >= 0x1000 && DeviceId <= 0x103F && RevisionId == 0x00) {
+ } else if ((DeviceId >= 0x1000) && (DeviceId <= 0x103F) && (RevisionId == 0x00)) {
Virtio10 = FALSE;
} else {
return EFI_SUCCESS;
@@ -538,13 +591,20 @@ ConnectVirtioPciRng (
//
// Read and check SubsystemId as dictated by Virtio10.
//
- Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint16,
- PCI_SUBSYSTEM_ID_OFFSET, 1, &SubsystemId);
+ Status = PciIo->Pci.Read (
+ PciIo,
+ EfiPciIoWidthUint16,
+ PCI_SUBSYSTEM_ID_OFFSET,
+ 1,
+ &SubsystemId
+ );
if (EFI_ERROR (Status)) {
goto Error;
}
- if ((Virtio10 && SubsystemId >= 0x40) ||
- (!Virtio10 && SubsystemId == VIRTIO_SUBSYSTEM_ENTROPY_SOURCE)) {
+
+ if ((Virtio10 && (SubsystemId >= 0x40)) ||
+ (!Virtio10 && (SubsystemId == VIRTIO_SUBSYSTEM_ENTROPY_SOURCE)))
+ {
Status = gBS->ConnectController (
Handle, // ControllerHandle
NULL, // DriverImageHandle -- connect all drivers
@@ -555,6 +615,7 @@ ConnectVirtioPciRng (
goto Error;
}
}
+
return EFI_SUCCESS;
Error:
@@ -562,7 +623,6 @@ Error:
return Status;
}
-
/**
Add IsaKeyboard to ConIn; add IsaSerial to ConOut, ConIn, ErrOut.
@@ -576,7 +636,7 @@ Error:
**/
EFI_STATUS
PrepareLpcBridgeDevicePath (
- IN EFI_HANDLE DeviceHandle
+ IN EFI_HANDLE DeviceHandle
)
{
EFI_STATUS Status;
@@ -585,50 +645,59 @@ PrepareLpcBridgeDevicePath (
CHAR16 *DevPathStr;
DevicePath = NULL;
- Status = gBS->HandleProtocol (
- DeviceHandle,
- &gEfiDevicePathProtocolGuid,
- (VOID*)&DevicePath
- );
+ Status = gBS->HandleProtocol (
+ DeviceHandle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID *)&DevicePath
+ );
if (EFI_ERROR (Status)) {
return Status;
}
+
TempDevicePath = DevicePath;
//
// Register Keyboard
//
- DevicePath = AppendDevicePathNode (DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *)&gPnpPs2KeyboardDeviceNode);
+ DevicePath = AppendDevicePathNode (
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gPnpPs2KeyboardDeviceNode
+ );
EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);
//
// Register COM1
//
- DevicePath = TempDevicePath;
+ DevicePath = TempDevicePath;
gPnp16550ComPortDeviceNode.UID = 0;
- DevicePath = AppendDevicePathNode (DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode);
- DevicePath = AppendDevicePathNode (DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);
- DevicePath = AppendDevicePathNode (DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);
+ DevicePath = AppendDevicePathNode (
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode
+ );
+ DevicePath = AppendDevicePathNode (
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode
+ );
+ DevicePath = AppendDevicePathNode (
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode
+ );
//
// Print Device Path
//
DevPathStr = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
if (DevPathStr != NULL) {
- DEBUG((
+ DEBUG ((
DEBUG_INFO,
"BdsPlatform.c+%d: COM%d DevPath: %s\n",
DEBUG_LINE_NUMBER,
gPnp16550ComPortDeviceNode.UID + 1,
DevPathStr
));
- FreePool(DevPathStr);
+ FreePool (DevPathStr);
}
EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
@@ -638,29 +707,35 @@ PrepareLpcBridgeDevicePath (
//
// Register COM2
//
- DevicePath = TempDevicePath;
+ DevicePath = TempDevicePath;
gPnp16550ComPortDeviceNode.UID = 1;
- DevicePath = AppendDevicePathNode (DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode);
- DevicePath = AppendDevicePathNode (DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);
- DevicePath = AppendDevicePathNode (DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);
+ DevicePath = AppendDevicePathNode (
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode
+ );
+ DevicePath = AppendDevicePathNode (
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode
+ );
+ DevicePath = AppendDevicePathNode (
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode
+ );
//
// Print Device Path
//
DevPathStr = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
if (DevPathStr != NULL) {
- DEBUG((
+ DEBUG ((
DEBUG_INFO,
"BdsPlatform.c+%d: COM%d DevPath: %s\n",
DEBUG_LINE_NUMBER,
gPnp16550ComPortDeviceNode.UID + 1,
DevPathStr
));
- FreePool(DevPathStr);
+ FreePool (DevPathStr);
}
EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
@@ -671,16 +746,18 @@ PrepareLpcBridgeDevicePath (
}
typedef struct {
- VENDOR_DEVICE_PATH Guid;
- EFI_DEVICE_PATH_PROTOCOL End;
+ VENDOR_DEVICE_PATH Guid;
+ EFI_DEVICE_PATH_PROTOCOL End;
} SERIAL_DEVICE_PATH;
-SERIAL_DEVICE_PATH serialDevicePath = {
+SERIAL_DEVICE_PATH serialDevicePath = {
{
- { HARDWARE_DEVICE_PATH, HW_VENDOR_DP, { sizeof (VENDOR_DEVICE_PATH), 0} },
+ { HARDWARE_DEVICE_PATH, HW_VENDOR_DP, { sizeof (VENDOR_DEVICE_PATH), 0 }
+ },
EDKII_SERIAL_PORT_LIB_VENDOR_GUID
},
- { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { sizeof (EFI_DEVICE_PATH_PROTOCOL), 0 } }
+ { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { sizeof (EFI_DEVICE_PATH_PROTOCOL), 0 }
+ }
};
VOID
@@ -696,11 +773,15 @@ PrepareMicrovmDevicePath (
return;
}
- DevicePath = (EFI_DEVICE_PATH_PROTOCOL*)&serialDevicePath;
- DevicePath = AppendDevicePathNode (DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);
- DevicePath = AppendDevicePathNode (DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);
+ DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)&serialDevicePath;
+ DevicePath = AppendDevicePathNode (
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode
+ );
+ DevicePath = AppendDevicePathNode (
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode
+ );
EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);
@@ -709,19 +790,19 @@ PrepareMicrovmDevicePath (
EFI_STATUS
GetGopDevicePath (
- IN EFI_DEVICE_PATH_PROTOCOL *PciDevicePath,
- OUT EFI_DEVICE_PATH_PROTOCOL **GopDevicePath
- )
+ IN EFI_DEVICE_PATH_PROTOCOL *PciDevicePath,
+ OUT EFI_DEVICE_PATH_PROTOCOL **GopDevicePath
+ )
{
- UINTN Index;
- EFI_STATUS Status;
- EFI_HANDLE PciDeviceHandle;
- EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
- EFI_DEVICE_PATH_PROTOCOL *TempPciDevicePath;
- UINTN GopHandleCount;
- EFI_HANDLE *GopHandleBuffer;
-
- if (PciDevicePath == NULL || GopDevicePath == NULL) {
+ UINTN Index;
+ EFI_STATUS Status;
+ EFI_HANDLE PciDeviceHandle;
+ EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *TempPciDevicePath;
+ UINTN GopHandleCount;
+ EFI_HANDLE *GopHandleBuffer;
+
+ if ((PciDevicePath == NULL) || (GopDevicePath == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -760,16 +841,21 @@ GetGopDevicePath (
// Add all the child handles as possible Console Device
//
for (Index = 0; Index < GopHandleCount; Index++) {
- Status = gBS->HandleProtocol (GopHandleBuffer[Index],
- &gEfiDevicePathProtocolGuid, (VOID*)&TempDevicePath);
+ Status = gBS->HandleProtocol (
+ GopHandleBuffer[Index],
+ &gEfiDevicePathProtocolGuid,
+ (VOID *)&TempDevicePath
+ );
if (EFI_ERROR (Status)) {
continue;
}
+
if (CompareMem (
PciDevicePath,
TempDevicePath,
GetDevicePathSize (PciDevicePath) - END_DEVICE_PATH_LENGTH
- ) == 0) {
+ ) == 0)
+ {
//
// In current implementation, we only enable one of the child handles
// as console device, i.e. sotre one of the child handle's device
@@ -787,6 +873,7 @@ GetGopDevicePath (
EfiBootManagerUpdateConsoleVariable (ConOutDev, TempDevicePath, NULL);
}
}
+
gBS->FreePool (GopHandleBuffer);
}
@@ -805,7 +892,7 @@ GetGopDevicePath (
**/
EFI_STATUS
PreparePciDisplayDevicePath (
- IN EFI_HANDLE DeviceHandle
+ IN EFI_HANDLE DeviceHandle
)
{
EFI_STATUS Status;
@@ -814,11 +901,11 @@ PreparePciDisplayDevicePath (
DevicePath = NULL;
GopDevicePath = NULL;
- Status = gBS->HandleProtocol (
- DeviceHandle,
- &gEfiDevicePathProtocolGuid,
- (VOID*)&DevicePath
- );
+ Status = gBS->HandleProtocol (
+ DeviceHandle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID *)&DevicePath
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -844,26 +931,30 @@ PreparePciDisplayDevicePath (
**/
EFI_STATUS
PreparePciSerialDevicePath (
- IN EFI_HANDLE DeviceHandle
+ IN EFI_HANDLE DeviceHandle
)
{
EFI_STATUS Status;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
DevicePath = NULL;
- Status = gBS->HandleProtocol (
- DeviceHandle,
- &gEfiDevicePathProtocolGuid,
- (VOID*)&DevicePath
- );
+ Status = gBS->HandleProtocol (
+ DeviceHandle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID *)&DevicePath
+ );
if (EFI_ERROR (Status)) {
return Status;
}
- DevicePath = AppendDevicePathNode (DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);
- DevicePath = AppendDevicePathNode (DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);
+ DevicePath = AppendDevicePathNode (
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode
+ );
+ DevicePath = AppendDevicePathNode (
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode
+ );
EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);
@@ -879,24 +970,24 @@ VisitAllInstancesOfProtocol (
IN VOID *Context
)
{
- EFI_STATUS Status;
- UINTN HandleCount;
- EFI_HANDLE *HandleBuffer;
- UINTN Index;
- VOID *Instance;
+ EFI_STATUS Status;
+ UINTN HandleCount;
+ EFI_HANDLE *HandleBuffer;
+ UINTN Index;
+ VOID *Instance;
//
// Start to check all the PciIo to find all possible device
//
- HandleCount = 0;
+ HandleCount = 0;
HandleBuffer = NULL;
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- Id,
- NULL,
- &HandleCount,
- &HandleBuffer
- );
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ Id,
+ NULL,
+ &HandleCount,
+ &HandleBuffer
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -907,11 +998,11 @@ VisitAllInstancesOfProtocol (
continue;
}
- Status = (*CallBackFunction) (
- HandleBuffer[Index],
- Instance,
- Context
- );
+ Status = (*CallBackFunction)(
+ HandleBuffer[Index],
+ Instance,
+ Context
+ );
}
gBS->FreePool (HandleBuffer);
@@ -919,7 +1010,6 @@ VisitAllInstancesOfProtocol (
return EFI_SUCCESS;
}
-
EFI_STATUS
EFIAPI
VisitingAPciInstance (
@@ -928,49 +1018,45 @@ VisitingAPciInstance (
IN VOID *Context
)
{
- EFI_STATUS Status;
- EFI_PCI_IO_PROTOCOL *PciIo;
- PCI_TYPE00 Pci;
+ EFI_STATUS Status;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ PCI_TYPE00 Pci;
- PciIo = (EFI_PCI_IO_PROTOCOL*) Instance;
+ PciIo = (EFI_PCI_IO_PROTOCOL *)Instance;
//
// Check for all PCI device
//
Status = PciIo->Pci.Read (
- PciIo,
- EfiPciIoWidthUint32,
- 0,
- sizeof (Pci) / sizeof (UINT32),
- &Pci
- );
+ PciIo,
+ EfiPciIoWidthUint32,
+ 0,
+ sizeof (Pci) / sizeof (UINT32),
+ &Pci
+ );
if (EFI_ERROR (Status)) {
return Status;
}
- return (*(VISIT_PCI_INSTANCE_CALLBACK)(UINTN) Context) (
- Handle,
- PciIo,
- &Pci
- );
-
+ return (*(VISIT_PCI_INSTANCE_CALLBACK)(UINTN)Context)(
+ Handle,
+ PciIo,
+ &Pci
+ );
}
-
-
EFI_STATUS
VisitAllPciInstances (
- IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction
+ IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction
)
{
return VisitAllInstancesOfProtocol (
&gEfiPciIoProtocolGuid,
VisitingAPciInstance,
- (VOID*)(UINTN) CallBackFunction
+ (VOID *)(UINTN)CallBackFunction
);
}
-
/**
Do platform specific PCI Device check and add them to
ConOut, ConIn, ErrOut.
@@ -992,14 +1078,14 @@ DetectAndPreparePlatformPciDevicePath (
IN PCI_TYPE00 *Pci
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = PciIo->Attributes (
- PciIo,
- EfiPciIoAttributeOperationEnable,
- EFI_PCI_DEVICE_ENABLE,
- NULL
- );
+ PciIo,
+ EfiPciIoAttributeOperationEnable,
+ EFI_PCI_DEVICE_ENABLE,
+ NULL
+ );
ASSERT_EFI_ERROR (Status);
//
@@ -1010,7 +1096,8 @@ DetectAndPreparePlatformPciDevicePath (
(Pci->Hdr.VendorId == 0x8086) &&
(Pci->Hdr.DeviceId == 0x7000)
)
- ) {
+ )
+ {
//
// Add IsaKeyboard to ConIn,
// add IsaSerial to ConOut, ConIn, ErrOut
@@ -1019,6 +1106,7 @@ DetectAndPreparePlatformPciDevicePath (
PrepareLpcBridgeDevicePath (Handle);
return EFI_SUCCESS;
}
+
//
// Here we decide which Serial device to enable in PCI bus
//
@@ -1046,7 +1134,6 @@ DetectAndPreparePlatformPciDevicePath (
return Status;
}
-
/**
Connect the predefined platform default console device.
@@ -1056,10 +1143,10 @@ DetectAndPreparePlatformPciDevicePath (
**/
VOID
PlatformInitializeConsole (
- IN PLATFORM_CONSOLE_CONNECT_ENTRY *PlatformConsole
+ IN PLATFORM_CONSOLE_CONNECT_ENTRY *PlatformConsole
)
{
- UINTN Index;
+ UINTN Index;
//
// Do platform specific PCI Device check and add them to ConOut, ConIn,
@@ -1079,21 +1166,31 @@ PlatformInitializeConsole (
// Update the console variable with the connect type
//
if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {
- EfiBootManagerUpdateConsoleVariable (ConIn,
- PlatformConsole[Index].DevicePath, NULL);
+ EfiBootManagerUpdateConsoleVariable (
+ ConIn,
+ PlatformConsole[Index].DevicePath,
+ NULL
+ );
}
+
if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {
- EfiBootManagerUpdateConsoleVariable (ConOut,
- PlatformConsole[Index].DevicePath, NULL);
+ EfiBootManagerUpdateConsoleVariable (
+ ConOut,
+ PlatformConsole[Index].DevicePath,
+ NULL
+ );
}
+
if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {
- EfiBootManagerUpdateConsoleVariable (ErrOut,
- PlatformConsole[Index].DevicePath, NULL);
+ EfiBootManagerUpdateConsoleVariable (
+ ErrOut,
+ PlatformConsole[Index].DevicePath,
+ NULL
+ );
}
}
}
-
/**
Configure PCI Interrupt Line register for applicable devices
Ported from SeaBIOS, src/fw/pciinit.c, *_pci_slot_get_irq()
@@ -1124,15 +1221,15 @@ SetPciIntLine (
Status = EFI_SUCCESS;
if (PciHdr->Device.InterruptPin != 0) {
-
DevPathNode = DevicePathFromHandle (Handle);
ASSERT (DevPathNode != NULL);
DevPath = DevPathNode;
RootBusNumber = 0;
- if (DevicePathType (DevPathNode) == ACPI_DEVICE_PATH &&
- DevicePathSubType (DevPathNode) == ACPI_DP &&
- ((ACPI_HID_DEVICE_PATH *)DevPathNode)->HID == EISA_PNP_ID(0x0A03)) {
+ if ((DevicePathType (DevPathNode) == ACPI_DEVICE_PATH) &&
+ (DevicePathSubType (DevPathNode) == ACPI_DP) &&
+ (((ACPI_HID_DEVICE_PATH *)DevPathNode)->HID == EISA_PNP_ID (0x0A03)))
+ {
RootBusNumber = ((ACPI_HID_DEVICE_PATH *)DevPathNode)->UID;
}
@@ -1140,13 +1237,13 @@ SetPciIntLine (
// Compute index into PciHostIrqs[] table by walking
// the device path and adding up all device numbers
//
- Status = EFI_NOT_FOUND;
+ Status = EFI_NOT_FOUND;
RootSlot = 0;
- Idx = PciHdr->Device.InterruptPin - 1;
+ Idx = PciHdr->Device.InterruptPin - 1;
while (!IsDevicePathEnd (DevPathNode)) {
- if (DevicePathType (DevPathNode) == HARDWARE_DEVICE_PATH &&
- DevicePathSubType (DevPathNode) == HW_PCI_DP) {
-
+ if ((DevicePathType (DevPathNode) == HARDWARE_DEVICE_PATH) &&
+ (DevicePathSubType (DevPathNode) == HW_PCI_DP))
+ {
Idx += ((PCI_DEVICE_PATH *)DevPathNode)->Device;
//
@@ -1157,18 +1254,20 @@ SetPciIntLine (
// Q35 cases with more than 24 slots on the root bus.
//
if (Status != EFI_SUCCESS) {
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
RootSlot = ((PCI_DEVICE_PATH *)DevPathNode)->Device;
}
}
DevPathNode = NextDevicePathNode (DevPathNode);
}
+
if (EFI_ERROR (Status)) {
return Status;
}
- if (RootBusNumber == 0 && RootSlot == 0) {
- DEBUG((
+
+ if ((RootBusNumber == 0) && (RootSlot == 0)) {
+ DEBUG ((
DEBUG_ERROR,
"%a: PCI host bridge (00:00.0) should have no interrupts!\n",
__FUNCTION__
@@ -1200,29 +1299,39 @@ SetPciIntLine (
//
Idx -= RootSlot;
}
+
break;
default:
ASSERT (FALSE); // should never get here
}
- Idx %= ARRAY_SIZE (PciHostIrqs);
+
+ Idx %= ARRAY_SIZE (PciHostIrqs);
IrqLine = PciHostIrqs[Idx];
DEBUG_CODE_BEGIN ();
{
- CHAR16 *DevPathString;
- STATIC CHAR16 Fallback[] = L"<failed to convert>";
- UINTN Segment, Bus, Device, Function;
+ CHAR16 *DevPathString;
+ STATIC CHAR16 Fallback[] = L"<failed to convert>";
+ UINTN Segment, Bus, Device, Function;
DevPathString = ConvertDevicePathToText (DevPath, FALSE, FALSE);
if (DevPathString == NULL) {
DevPathString = Fallback;
}
+
Status = PciIo->GetLocation (PciIo, &Segment, &Bus, &Device, &Function);
ASSERT_EFI_ERROR (Status);
- DEBUG ((DEBUG_VERBOSE, "%a: [%02x:%02x.%x] %s -> 0x%02x\n", __FUNCTION__,
- (UINT32)Bus, (UINT32)Device, (UINT32)Function, DevPathString,
- IrqLine));
+ DEBUG ((
+ DEBUG_VERBOSE,
+ "%a: [%02x:%02x.%x] %s -> 0x%02x\n",
+ __FUNCTION__,
+ (UINT32)Bus,
+ (UINT32)Device,
+ (UINT32)Function,
+ DevPathString,
+ IrqLine
+ ));
if (DevPathString != Fallback) {
FreePool (DevPathString);
@@ -1234,18 +1343,17 @@ SetPciIntLine (
// Set PCI Interrupt Line register for this device to PciHostIrqs[Idx]
//
Status = PciIo->Pci.Write (
- PciIo,
- EfiPciIoWidthUint8,
- PCI_INT_LINE_OFFSET,
- 1,
- &IrqLine
- );
+ PciIo,
+ EfiPciIoWidthUint8,
+ PCI_INT_LINE_OFFSET,
+ 1,
+ &IrqLine
+ );
}
return Status;
}
-
VOID
PciAcpiInitialization (
)
@@ -1290,8 +1398,13 @@ PciAcpiInitialization (
//
return;
}
- DEBUG ((DEBUG_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n",
- __FUNCTION__, mHostBridgeDevId));
+
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Unknown Host Bridge Device ID: 0x%04x\n",
+ __FUNCTION__,
+ mHostBridgeDevId
+ ));
ASSERT (FALSE);
return;
}
@@ -1323,13 +1436,14 @@ ConnectRecursivelyIfPciMassStorage (
// Recognize PCI Mass Storage, and Xen PCI devices
//
if (IS_CLASS1 (PciHeader, PCI_CLASS_MASS_STORAGE) ||
- (XenDetected() && IS_CLASS2 (PciHeader, 0xFF, 0x80))) {
+ (XenDetected () && IS_CLASS2 (PciHeader, 0xFF, 0x80)))
+ {
DevicePath = NULL;
- Status = gBS->HandleProtocol (
- Handle,
- &gEfiDevicePathProtocolGuid,
- (VOID*)&DevicePath
- );
+ Status = gBS->HandleProtocol (
+ Handle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID *)&DevicePath
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -1339,29 +1453,27 @@ ConnectRecursivelyIfPciMassStorage (
//
DevPathStr = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
if (DevPathStr != NULL) {
- DEBUG((
+ DEBUG ((
DEBUG_INFO,
"Found %s device: %s\n",
(IS_CLASS1 (PciHeader, PCI_CLASS_MASS_STORAGE) ?
L"Mass Storage" :
L"Xen"
- ),
+ ),
DevPathStr
));
- FreePool(DevPathStr);
+ FreePool (DevPathStr);
}
Status = gBS->ConnectController (Handle, NULL, NULL, TRUE);
if (EFI_ERROR (Status)) {
return Status;
}
-
}
return EFI_SUCCESS;
}
-
/**
This notification function is invoked when the
EMU Variable FVB has been changed.
@@ -1373,15 +1485,14 @@ ConnectRecursivelyIfPciMassStorage (
VOID
EFIAPI
EmuVariablesUpdatedCallback (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
DEBUG ((DEBUG_INFO, "EmuVariablesUpdatedCallback\n"));
UpdateNvVarsOnFileSystem ();
}
-
EFI_STATUS
EFIAPI
VisitingFileSystemInstance (
@@ -1404,7 +1515,7 @@ VisitingFileSystemInstance (
}
ConnectedToFileSystem = TRUE;
- mEmuVariableEvent =
+ mEmuVariableEvent =
EfiCreateProtocolNotifyEvent (
&gEfiDevicePathProtocolGuid,
TPL_CALLBACK,
@@ -1412,14 +1523,15 @@ VisitingFileSystemInstance (
NULL,
&mEmuVariableEventReg
);
- PcdStatus = PcdSet64S (PcdEmuVariableEvent,
- (UINT64)(UINTN) mEmuVariableEvent);
+ PcdStatus = PcdSet64S (
+ PcdEmuVariableEvent,
+ (UINT64)(UINTN)mEmuVariableEvent
+ );
ASSERT_RETURN_ERROR (PcdStatus);
return EFI_SUCCESS;
}
-
VOID
PlatformBdsRestoreNvVarsFromHardDisk (
)
@@ -1430,7 +1542,6 @@ PlatformBdsRestoreNvVarsFromHardDisk (
VisitingFileSystemInstance,
NULL
);
-
}
/**
@@ -1443,8 +1554,8 @@ PlatformBdsConnectSequence (
VOID
)
{
- UINTN Index;
- RETURN_STATUS Status;
+ UINTN Index;
+ RETURN_STATUS Status;
DEBUG ((DEBUG_INFO, "PlatformBdsConnectSequence\n"));
@@ -1485,12 +1596,15 @@ SaveS3BootScript (
VOID
)
{
- EFI_STATUS Status;
- EFI_S3_SAVE_STATE_PROTOCOL *BootScript;
- STATIC CONST UINT8 Info[] = { 0xDE, 0xAD, 0xBE, 0xEF };
+ EFI_STATUS Status;
+ EFI_S3_SAVE_STATE_PROTOCOL *BootScript;
+ STATIC CONST UINT8 Info[] = { 0xDE, 0xAD, 0xBE, 0xEF };
- Status = gBS->LocateProtocol (&gEfiS3SaveStateProtocolGuid, NULL,
- (VOID **) &BootScript);
+ Status = gBS->LocateProtocol (
+ &gEfiS3SaveStateProtocolGuid,
+ NULL,
+ (VOID **)&BootScript
+ );
ASSERT_EFI_ERROR (Status);
//
@@ -1498,13 +1612,15 @@ SaveS3BootScript (
// implementation embeds a deep copy of the info in the boot script, rather
// than storing just a pointer to runtime or NVS storage.
//
- Status = BootScript->Write(BootScript, EFI_BOOT_SCRIPT_INFORMATION_OPCODE,
- (UINT32) sizeof Info,
- (EFI_PHYSICAL_ADDRESS)(UINTN) &Info);
+ Status = BootScript->Write (
+ BootScript,
+ EFI_BOOT_SCRIPT_INFORMATION_OPCODE,
+ (UINT32)sizeof Info,
+ (EFI_PHYSICAL_ADDRESS)(UINTN)&Info
+ );
ASSERT_EFI_ERROR (Status);
}
-
/**
Do the platform specific action after the console is ready
@@ -1524,13 +1640,16 @@ PlatformBootManagerAfterConsole (
VOID
)
{
- EFI_BOOT_MODE BootMode;
+ EFI_BOOT_MODE BootMode;
DEBUG ((DEBUG_INFO, "PlatformBootManagerAfterConsole\n"));
if (PcdGetBool (PcdOvmfFlashVariablesEnable)) {
- DEBUG ((DEBUG_INFO, "PlatformBdsPolicyBehavior: not restoring NvVars "
- "from disk since flash variables appear to be supported.\n"));
+ DEBUG ((
+ DEBUG_INFO,
+ "PlatformBdsPolicyBehavior: not restoring NvVars "
+ "from disk since flash variables appear to be supported.\n"
+ ));
} else {
//
// Try to restore variables from the hard disk early so
@@ -1577,7 +1696,9 @@ PlatformBootManagerAfterConsole (
// Register UEFI Shell
//
PlatformRegisterFvBootOption (
- &gUefiShellFileGuid, L"EFI Internal Shell", LOAD_OPTION_ACTIVE
+ &gUefiShellFileGuid,
+ L"EFI Internal Shell",
+ LOAD_OPTION_ACTIVE
);
RemoveStaleFvFileOptions ();
@@ -1597,31 +1718,31 @@ PlatformBootManagerAfterConsole (
VOID
EFIAPI
NotifyDevPath (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- EFI_HANDLE Handle;
- EFI_STATUS Status;
- UINTN BufferSize;
- EFI_DEVICE_PATH_PROTOCOL *DevPathNode;
- ATAPI_DEVICE_PATH *Atapi;
+ EFI_HANDLE Handle;
+ EFI_STATUS Status;
+ UINTN BufferSize;
+ EFI_DEVICE_PATH_PROTOCOL *DevPathNode;
+ ATAPI_DEVICE_PATH *Atapi;
//
// Examine all new handles
//
- for (;;) {
+ for ( ; ;) {
//
// Get the next handle
//
BufferSize = sizeof (Handle);
- Status = gBS->LocateHandle (
- ByRegisterNotify,
- NULL,
- mEfiDevPathNotifyReg,
- &BufferSize,
- &Handle
- );
+ Status = gBS->LocateHandle (
+ ByRegisterNotify,
+ NULL,
+ mEfiDevPathNotifyReg,
+ &BufferSize,
+ &Handle
+ );
//
// If not found, we're done
@@ -1637,8 +1758,11 @@ NotifyDevPath (
//
// Get the DevicePath protocol on that handle
//
- Status = gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid,
- (VOID **)&DevPathNode);
+ Status = gBS->HandleProtocol (
+ Handle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID **)&DevPathNode
+ );
ASSERT_EFI_ERROR (Status);
while (!IsDevicePathEnd (DevPathNode)) {
@@ -1646,16 +1770,17 @@ NotifyDevPath (
// Find the handler to dump this device path node
//
if (
- (DevicePathType(DevPathNode) == MESSAGING_DEVICE_PATH) &&
- (DevicePathSubType(DevPathNode) == MSG_ATAPI_DP)
- ) {
- Atapi = (ATAPI_DEVICE_PATH*) DevPathNode;
+ (DevicePathType (DevPathNode) == MESSAGING_DEVICE_PATH) &&
+ (DevicePathSubType (DevPathNode) == MSG_ATAPI_DP)
+ )
+ {
+ Atapi = (ATAPI_DEVICE_PATH *)DevPathNode;
PciOr16 (
PCI_LIB_ADDRESS (
0,
1,
1,
- (Atapi->PrimarySecondary == 1) ? 0x42: 0x40
+ (Atapi->PrimarySecondary == 1) ? 0x42 : 0x40
),
BIT15
);
@@ -1671,7 +1796,6 @@ NotifyDevPath (
return;
}
-
VOID
InstallDevicePathCallback (
VOID
@@ -1679,12 +1803,12 @@ InstallDevicePathCallback (
{
DEBUG ((DEBUG_INFO, "Registered NotifyDevPath Event\n"));
mEfiDevPathEvent = EfiCreateProtocolNotifyEvent (
- &gEfiDevicePathProtocolGuid,
- TPL_CALLBACK,
- NotifyDevPath,
- NULL,
- &mEfiDevPathNotifyReg
- );
+ &gEfiDevicePathProtocolGuid,
+ TPL_CALLBACK,
+ NotifyDevPath,
+ NULL,
+ &mEfiDevPathNotifyReg
+ );
}
/**
@@ -1696,12 +1820,12 @@ InstallDevicePathCallback (
VOID
EFIAPI
PlatformBootManagerWaitCallback (
- UINT16 TimeoutRemain
+ UINT16 TimeoutRemain
)
{
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION White;
- UINT16 TimeoutInitial;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION White;
+ UINT16 TimeoutInitial;
TimeoutInitial = PcdGet16 (PcdPlatformBootTimeOut);
@@ -1740,10 +1864,10 @@ PlatformBootManagerUnableToBoot (
VOID
)
{
- EFI_STATUS Status;
- EFI_INPUT_KEY Key;
- EFI_BOOT_MANAGER_LOAD_OPTION BootManagerMenu;
- UINTN Index;
+ EFI_STATUS Status;
+ EFI_INPUT_KEY Key;
+ EFI_BOOT_MANAGER_LOAD_OPTION BootManagerMenu;
+ UINTN Index;
//
// BootManagerMenu doesn't contain the correct information when return status
@@ -1753,6 +1877,7 @@ PlatformBootManagerUnableToBoot (
if (EFI_ERROR (Status)) {
return;
}
+
//
// Normally BdsDxe does not print anything to the system console, but this is
// a last resort -- the end-user will likely not see any DEBUG messages
@@ -1782,7 +1907,7 @@ PlatformBootManagerUnableToBoot (
}
}
- for (;;) {
+ for ( ; ;) {
EfiBootManagerBoot (&BootManagerMenu);
}
}
diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h
index 153e215101..1676d61616 100644
--- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h
+++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h
@@ -17,7 +17,6 @@ Abstract:
#ifndef _PLATFORM_SPECIFIC_BDS_PLATFORM_H_
#define _PLATFORM_SPECIFIC_BDS_PLATFORM_H_
-
#include <PiDxe.h>
#include <IndustryStandard/Pci.h>
@@ -64,11 +63,11 @@ Abstract:
#include <OvmfPlatforms.h>
-extern EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[];
-extern ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode;
-extern ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode;
-extern UART_DEVICE_PATH gUartDeviceNode;
-extern VENDOR_DEVICE_PATH gTerminalTypeDeviceNode;
+extern EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[];
+extern ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode;
+extern ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode;
+extern UART_DEVICE_PATH gUartDeviceNode;
+extern VENDOR_DEVICE_PATH gTerminalTypeDeviceNode;
#define PCI_DEVICE_PATH_NODE(Func, Dev) \
{ \
@@ -150,20 +149,20 @@ extern VENDOR_DEVICE_PATH gTerminalTypeDeviceNode;
} \
}
-#define PCI_CLASS_SCC 0x07
-#define PCI_SUBCLASS_SERIAL 0x00
-#define PCI_IF_16550 0x02
-#define IS_PCI_16550SERIAL(_p) IS_CLASS3 (_p, PCI_CLASS_SCC, PCI_SUBCLASS_SERIAL, PCI_IF_16550)
-#define IS_PCI_ISA_PDECODE(_p) IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_ISA_PDECODE, 0)
+#define PCI_CLASS_SCC 0x07
+#define PCI_SUBCLASS_SERIAL 0x00
+#define PCI_IF_16550 0x02
+#define IS_PCI_16550SERIAL(_p) IS_CLASS3 (_p, PCI_CLASS_SCC, PCI_SUBCLASS_SERIAL, PCI_IF_16550)
+#define IS_PCI_ISA_PDECODE(_p) IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_ISA_PDECODE, 0)
typedef struct {
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- UINTN ConnectType;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ UINTN ConnectType;
} PLATFORM_CONSOLE_CONNECT_ENTRY;
-#define CONSOLE_OUT BIT0
-#define CONSOLE_IN BIT1
-#define STD_ERROR BIT2
+#define CONSOLE_OUT BIT0
+#define CONSOLE_IN BIT1
+#define STD_ERROR BIT2
extern PLATFORM_CONSOLE_CONNECT_ENTRY gPlatformConsole[];
extern PLATFORM_CONSOLE_CONNECT_ENTRY gXenPlatformConsole[];
@@ -173,7 +172,7 @@ extern PLATFORM_CONSOLE_CONNECT_ENTRY gXenPlatformConsole[];
VOID
PlatformInitializeConsole (
- IN PLATFORM_CONSOLE_CONNECT_ENTRY *PlatformConsole
+ IN PLATFORM_CONSOLE_CONNECT_ENTRY *PlatformConsole
);
/**
diff --git a/OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c b/OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c
index 2858c3dfd5..6536d9fe36 100644
--- a/OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c
+++ b/OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c
@@ -16,10 +16,10 @@
//
#pragma pack (1)
typedef struct {
- VENDOR_DEVICE_PATH VendorHardware;
- UART_DEVICE_PATH Uart;
- VENDOR_DEVICE_PATH TerminalType;
- EFI_DEVICE_PATH_PROTOCOL End;
+ VENDOR_DEVICE_PATH VendorHardware;
+ UART_DEVICE_PATH Uart;
+ VENDOR_DEVICE_PATH TerminalType;
+ EFI_DEVICE_PATH_PROTOCOL End;
} VENDOR_UART_DEVICE_PATH;
#pragma pack ()
@@ -28,8 +28,8 @@ typedef struct {
//
#pragma pack (1)
typedef struct {
- USB_CLASS_DEVICE_PATH Keyboard;
- EFI_DEVICE_PATH_PROTOCOL End;
+ USB_CLASS_DEVICE_PATH Keyboard;
+ EFI_DEVICE_PATH_PROTOCOL End;
} USB_KEYBOARD_DEVICE_PATH;
#pragma pack ()
@@ -38,33 +38,32 @@ typedef struct {
//
#pragma pack (1)
typedef struct {
- VENDOR_DEVICE_PATH Vendor;
- ACPI_ADR_DEVICE_PATH AcpiAdr;
- EFI_DEVICE_PATH_PROTOCOL End;
+ VENDOR_DEVICE_PATH Vendor;
+ ACPI_ADR_DEVICE_PATH AcpiAdr;
+ EFI_DEVICE_PATH_PROTOCOL End;
} VENDOR_RAMFB_DEVICE_PATH;
#pragma pack ()
-ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode = gPnpPs2Keyboard;
-ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode = gPnp16550ComPort;
-UART_DEVICE_PATH gUartDeviceNode = gUart;
-VENDOR_DEVICE_PATH gTerminalTypeDeviceNode = gPcAnsiTerminal;
+ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode = gPnpPs2Keyboard;
+ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode = gPnp16550ComPort;
+UART_DEVICE_PATH gUartDeviceNode = gUart;
+VENDOR_DEVICE_PATH gTerminalTypeDeviceNode = gPcAnsiTerminal;
//
// Platform specific keyboard device path
//
-
//
// Debug Agent UART Device Path
//
-VENDOR_UART_DEVICE_PATH gDebugAgentUartDevicePath = {
+VENDOR_UART_DEVICE_PATH gDebugAgentUartDevicePath = {
{
{
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{
- (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
- (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
+ (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}
},
EFI_DEBUG_AGENT_GUID,
@@ -74,8 +73,8 @@ VENDOR_UART_DEVICE_PATH gDebugAgentUartDevicePath = {
MESSAGING_DEVICE_PATH,
MSG_UART_DP,
{
- (UINT8) (sizeof (UART_DEVICE_PATH)),
- (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (UART_DEVICE_PATH)),
+ (UINT8)((sizeof (UART_DEVICE_PATH)) >> 8)
}
},
0, // Reserved
@@ -88,7 +87,7 @@ VENDOR_UART_DEVICE_PATH gDebugAgentUartDevicePath = {
gEndEntire
};
-STATIC USB_KEYBOARD_DEVICE_PATH gUsbKeyboardDevicePath = {
+STATIC USB_KEYBOARD_DEVICE_PATH gUsbKeyboardDevicePath = {
{
{
MESSAGING_DEVICE_PATH,
@@ -107,14 +106,14 @@ STATIC USB_KEYBOARD_DEVICE_PATH gUsbKeyboardDevicePath = {
gEndEntire
};
-STATIC VENDOR_RAMFB_DEVICE_PATH gQemuRamfbDevicePath = {
+STATIC VENDOR_RAMFB_DEVICE_PATH gQemuRamfbDevicePath = {
{
{
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{
- (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
- (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
+ (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}
},
QEMU_RAMFB_GUID,
@@ -124,8 +123,8 @@ STATIC VENDOR_RAMFB_DEVICE_PATH gQemuRamfbDevicePath = {
ACPI_DEVICE_PATH,
ACPI_ADR_DP,
{
- (UINT8) (sizeof (ACPI_ADR_DEVICE_PATH)),
- (UINT8) ((sizeof (ACPI_ADR_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (ACPI_ADR_DEVICE_PATH)),
+ (UINT8)((sizeof (ACPI_ADR_DEVICE_PATH)) >> 8)
}
},
ACPI_DISPLAY_ADR (
@@ -142,14 +141,14 @@ STATIC VENDOR_RAMFB_DEVICE_PATH gQemuRamfbDevicePath = {
gEndEntire
};
-STATIC VENDOR_UART_DEVICE_PATH gXenConsoleDevicePath = {
+STATIC VENDOR_UART_DEVICE_PATH gXenConsoleDevicePath = {
{
{
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{
- (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
- (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
+ (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}
},
EDKII_SERIAL_PORT_LIB_VENDOR_GUID
@@ -159,8 +158,8 @@ STATIC VENDOR_UART_DEVICE_PATH gXenConsoleDevicePath = {
MESSAGING_DEVICE_PATH,
MSG_UART_DP,
{
- (UINT8) (sizeof (UART_DEVICE_PATH)),
- (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (UART_DEVICE_PATH)),
+ (UINT8)((sizeof (UART_DEVICE_PATH)) >> 8)
}
},
0,
@@ -176,9 +175,9 @@ STATIC VENDOR_UART_DEVICE_PATH gXenConsoleDevicePath = {
//
// Predefined platform default console device path
//
-PLATFORM_CONSOLE_CONNECT_ENTRY gPlatformConsole[] = {
+PLATFORM_CONSOLE_CONNECT_ENTRY gPlatformConsole[] = {
{
- (EFI_DEVICE_PATH_PROTOCOL *) &gDebugAgentUartDevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gDebugAgentUartDevicePath,
(CONSOLE_OUT | CONSOLE_IN | STD_ERROR)
},
{
@@ -195,7 +194,7 @@ PLATFORM_CONSOLE_CONNECT_ENTRY gPlatformConsole[] = {
}
};
-PLATFORM_CONSOLE_CONNECT_ENTRY gXenPlatformConsole[] = {
+PLATFORM_CONSOLE_CONNECT_ENTRY gXenPlatformConsole[] = {
{
(EFI_DEVICE_PATH_PROTOCOL *)&gXenConsoleDevicePath,
(CONSOLE_OUT | CONSOLE_IN | STD_ERROR)
@@ -209,5 +208,4 @@ PLATFORM_CONSOLE_CONNECT_ENTRY gXenPlatformConsole[] = {
//
// Predefined platform connect sequence
//
-EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[] = { NULL };
-
+EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[] = { NULL };
diff --git a/OvmfPkg/Library/PlatformBootManagerLib/QemuKernel.c b/OvmfPkg/Library/PlatformBootManagerLib/QemuKernel.c
index c625592177..1e66e3c452 100644
--- a/OvmfPkg/Library/PlatformBootManagerLib/QemuKernel.c
+++ b/OvmfPkg/Library/PlatformBootManagerLib/QemuKernel.c
@@ -13,14 +13,13 @@
#include <Library/ReportStatusCodeLib.h>
#include <Library/UefiLib.h>
-
EFI_STATUS
TryRunningQemuKernel (
VOID
)
{
- EFI_STATUS Status;
- EFI_HANDLE KernelImageHandle;
+ EFI_STATUS Status;
+ EFI_HANDLE KernelImageHandle;
Status = QemuLoadKernelImage (&KernelImageHandle);
if (EFI_ERROR (Status)) {
@@ -30,18 +29,24 @@ TryRunningQemuKernel (
//
// Signal the EVT_SIGNAL_READY_TO_BOOT event
//
- EfiSignalEventReadyToBoot();
+ EfiSignalEventReadyToBoot ();
- REPORT_STATUS_CODE (EFI_PROGRESS_CODE,
- (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT));
+ REPORT_STATUS_CODE (
+ EFI_PROGRESS_CODE,
+ (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT)
+ );
//
// Start the image.
//
Status = QemuStartKernelImage (&KernelImageHandle);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: QemuStartKernelImage(): %r\n", __FUNCTION__,
- Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: QemuStartKernelImage(): %r\n",
+ __FUNCTION__,
+ Status
+ ));
}
QemuUnloadKernelImage (KernelImageHandle);
diff --git a/OvmfPkg/Library/PlatformBootManagerLibBhyve/BdsPlatform.c b/OvmfPkg/Library/PlatformBootManagerLibBhyve/BdsPlatform.c
index 32b70a46d0..119f24b330 100644
--- a/OvmfPkg/Library/PlatformBootManagerLibBhyve/BdsPlatform.c
+++ b/OvmfPkg/Library/PlatformBootManagerLibBhyve/BdsPlatform.c
@@ -19,17 +19,17 @@
// Global data
//
-VOID *mEfiDevPathNotifyReg;
-EFI_EVENT mEfiDevPathEvent;
-VOID *mEmuVariableEventReg;
-EFI_EVENT mEmuVariableEvent;
-UINT16 mHostBridgeDevId;
+VOID *mEfiDevPathNotifyReg;
+EFI_EVENT mEfiDevPathEvent;
+VOID *mEmuVariableEventReg;
+EFI_EVENT mEmuVariableEvent;
+UINT16 mHostBridgeDevId;
//
// Table of host IRQs matching PCI IRQs A-D
// (for configuring PCI Interrupt Line register)
//
-CONST UINT8 PciHostIrqs[] = {
+CONST UINT8 PciHostIrqs[] = {
0x0a, 0x0a, 0x0b, 0x0b
};
@@ -58,7 +58,6 @@ EFI_STATUS
IN PCI_TYPE00 *Pci
);
-
//
// Function prototypes
//
@@ -72,7 +71,7 @@ VisitAllInstancesOfProtocol (
EFI_STATUS
VisitAllPciInstancesOfProtocol (
- IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction
+ IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction
);
VOID
@@ -82,24 +81,24 @@ InstallDevicePathCallback (
VOID
PlatformRegisterFvBootOption (
- EFI_GUID *FileGuid,
- CHAR16 *Description,
- UINT32 Attributes
+ EFI_GUID *FileGuid,
+ CHAR16 *Description,
+ UINT32 Attributes
)
{
- EFI_STATUS Status;
- INTN OptionIndex;
- EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
- EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
- UINTN BootOptionCount;
- MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
- EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_STATUS Status;
+ INTN OptionIndex;
+ EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
+ EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
+ UINTN BootOptionCount;
+ MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
Status = gBS->HandleProtocol (
gImageHandle,
&gEfiLoadedImageProtocolGuid,
- (VOID **) &LoadedImage
+ (VOID **)&LoadedImage
);
ASSERT_EFI_ERROR (Status);
@@ -108,7 +107,7 @@ PlatformRegisterFvBootOption (
ASSERT (DevicePath != NULL);
DevicePath = AppendDevicePathNode (
DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *) &FileNode
+ (EFI_DEVICE_PATH_PROTOCOL *)&FileNode
);
ASSERT (DevicePath != NULL);
@@ -126,17 +125,21 @@ PlatformRegisterFvBootOption (
FreePool (DevicePath);
BootOptions = EfiBootManagerGetLoadOptions (
- &BootOptionCount, LoadOptionTypeBoot
+ &BootOptionCount,
+ LoadOptionTypeBoot
);
OptionIndex = EfiBootManagerFindLoadOption (
- &NewOption, BootOptions, BootOptionCount
+ &NewOption,
+ BootOptions,
+ BootOptionCount
);
if (OptionIndex == -1) {
Status = EfiBootManagerAddLoadOptionVariable (&NewOption, MAX_UINTN);
ASSERT_EFI_ERROR (Status);
}
+
EfiBootManagerFreeLoadOption (&NewOption);
EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
}
@@ -160,27 +163,30 @@ RemoveStaleFvFileOptions (
VOID
)
{
- EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
- UINTN BootOptionCount;
- UINTN Index;
+ EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
+ UINTN BootOptionCount;
+ UINTN Index;
- BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount,
- LoadOptionTypeBoot);
+ BootOptions = EfiBootManagerGetLoadOptions (
+ &BootOptionCount,
+ LoadOptionTypeBoot
+ );
for (Index = 0; Index < BootOptionCount; ++Index) {
- EFI_DEVICE_PATH_PROTOCOL *Node1, *Node2, *SearchNode;
- EFI_STATUS Status;
- EFI_HANDLE FvHandle;
+ EFI_DEVICE_PATH_PROTOCOL *Node1, *Node2, *SearchNode;
+ EFI_STATUS Status;
+ EFI_HANDLE FvHandle;
//
// If the device path starts with neither MemoryMapped(...) nor Fv(...),
// then keep the boot option.
//
Node1 = BootOptions[Index].FilePath;
- if (!(DevicePathType (Node1) == HARDWARE_DEVICE_PATH &&
- DevicePathSubType (Node1) == HW_MEMMAP_DP) &&
- !(DevicePathType (Node1) == MEDIA_DEVICE_PATH &&
- DevicePathSubType (Node1) == MEDIA_PIWG_FW_VOL_DP)) {
+ if (!((DevicePathType (Node1) == HARDWARE_DEVICE_PATH) &&
+ (DevicePathSubType (Node1) == HW_MEMMAP_DP)) &&
+ !((DevicePathType (Node1) == MEDIA_DEVICE_PATH) &&
+ (DevicePathSubType (Node1) == MEDIA_PIWG_FW_VOL_DP)))
+ {
continue;
}
@@ -189,8 +195,9 @@ RemoveStaleFvFileOptions (
// option.
//
Node2 = NextDevicePathNode (Node1);
- if (DevicePathType (Node2) != MEDIA_DEVICE_PATH ||
- DevicePathSubType (Node2) != MEDIA_PIWG_FW_FILE_DP) {
+ if ((DevicePathType (Node2) != MEDIA_DEVICE_PATH) ||
+ (DevicePathSubType (Node2) != MEDIA_PIWG_FW_FILE_DP))
+ {
continue;
}
@@ -201,23 +208,29 @@ RemoveStaleFvFileOptions (
// boot option.
//
SearchNode = Node1;
- Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid,
- &SearchNode, &FvHandle);
+ Status = gBS->LocateDevicePath (
+ &gEfiFirmwareVolume2ProtocolGuid,
+ &SearchNode,
+ &FvHandle
+ );
if (!EFI_ERROR (Status)) {
//
// The firmware volume was found; now let's see if it contains the FvFile
// identified by GUID.
//
- EFI_FIRMWARE_VOLUME2_PROTOCOL *FvProtocol;
- MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFileNode;
- UINTN BufferSize;
- EFI_FV_FILETYPE FoundType;
- EFI_FV_FILE_ATTRIBUTES FileAttributes;
- UINT32 AuthenticationStatus;
-
- Status = gBS->HandleProtocol (FvHandle, &gEfiFirmwareVolume2ProtocolGuid,
- (VOID **)&FvProtocol);
+ EFI_FIRMWARE_VOLUME2_PROTOCOL *FvProtocol;
+ MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFileNode;
+ UINTN BufferSize;
+ EFI_FV_FILETYPE FoundType;
+ EFI_FV_FILE_ATTRIBUTES FileAttributes;
+ UINT32 AuthenticationStatus;
+
+ Status = gBS->HandleProtocol (
+ FvHandle,
+ &gEfiFirmwareVolume2ProtocolGuid,
+ (VOID **)&FvProtocol
+ );
ASSERT_EFI_ERROR (Status);
FvFileNode = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)Node2;
@@ -246,23 +259,29 @@ RemoveStaleFvFileOptions (
// Delete the boot option.
//
Status = EfiBootManagerDeleteLoadOptionVariable (
- BootOptions[Index].OptionNumber, LoadOptionTypeBoot);
+ BootOptions[Index].OptionNumber,
+ LoadOptionTypeBoot
+ );
DEBUG_CODE_BEGIN ();
- CHAR16 *DevicePathString;
+ CHAR16 *DevicePathString;
+
+ DevicePathString = ConvertDevicePathToText (
+ BootOptions[Index].FilePath,
+ FALSE,
+ FALSE
+ );
+ DEBUG ((
+ EFI_ERROR (Status) ? DEBUG_WARN : DEBUG_VERBOSE,
+ "%a: removing stale Boot#%04x %s: %r\n",
+ __FUNCTION__,
+ (UINT32)BootOptions[Index].OptionNumber,
+ DevicePathString == NULL ? L"<unavailable>" : DevicePathString,
+ Status
+ ));
+ if (DevicePathString != NULL) {
+ FreePool (DevicePathString);
+ }
- DevicePathString = ConvertDevicePathToText(BootOptions[Index].FilePath,
- FALSE, FALSE);
- DEBUG ((
- EFI_ERROR (Status) ? DEBUG_WARN : DEBUG_VERBOSE,
- "%a: removing stale Boot#%04x %s: %r\n",
- __FUNCTION__,
- (UINT32)BootOptions[Index].OptionNumber,
- DevicePathString == NULL ? L"<unavailable>" : DevicePathString,
- Status
- ));
- if (DevicePathString != NULL) {
- FreePool (DevicePathString);
- }
DEBUG_CODE_END ();
}
@@ -274,18 +293,18 @@ PlatformRegisterOptionsAndKeys (
VOID
)
{
- EFI_STATUS Status;
- EFI_INPUT_KEY Enter;
- EFI_INPUT_KEY F2;
- EFI_INPUT_KEY Esc;
- EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
+ EFI_STATUS Status;
+ EFI_INPUT_KEY Enter;
+ EFI_INPUT_KEY F2;
+ EFI_INPUT_KEY Esc;
+ EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
//
// Register ENTER as CONTINUE key
//
Enter.ScanCode = SCAN_NULL;
Enter.UnicodeChar = CHAR_CARRIAGE_RETURN;
- Status = EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL);
+ Status = EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL);
ASSERT_EFI_ERROR (Status);
//
@@ -295,14 +314,22 @@ PlatformRegisterOptionsAndKeys (
F2.UnicodeChar = CHAR_NULL;
Esc.ScanCode = SCAN_ESC;
Esc.UnicodeChar = CHAR_NULL;
- Status = EfiBootManagerGetBootManagerMenu (&BootOption);
+ Status = EfiBootManagerGetBootManagerMenu (&BootOption);
ASSERT_EFI_ERROR (Status);
Status = EfiBootManagerAddKeyOptionVariable (
- NULL, (UINT16) BootOption.OptionNumber, 0, &F2, NULL
+ NULL,
+ (UINT16)BootOption.OptionNumber,
+ 0,
+ &F2,
+ NULL
);
ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
Status = EfiBootManagerAddKeyOptionVariable (
- NULL, (UINT16) BootOption.OptionNumber, 0, &Esc, NULL
+ NULL,
+ (UINT16)BootOption.OptionNumber,
+ 0,
+ &Esc,
+ NULL
);
ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
}
@@ -319,9 +346,9 @@ STATIC
EFI_STATUS
EFIAPI
ConnectVirtioPciRng (
- IN EFI_HANDLE Handle,
- IN VOID *Instance,
- IN VOID *Context
+ IN EFI_HANDLE Handle,
+ IN VOID *Instance,
+ IN VOID *Context
);
STATIC
@@ -333,6 +360,7 @@ SaveS3BootScript (
//
// BDS Platform Functions
//
+
/**
Do the platform init, can be customized by OEM/IBV
@@ -352,14 +380,17 @@ PlatformBootManagerBeforeConsole (
VOID
)
{
- EFI_HANDLE Handle;
- EFI_STATUS Status;
+ EFI_HANDLE Handle;
+ EFI_STATUS Status;
DEBUG ((DEBUG_INFO, "PlatformBootManagerBeforeConsole\n"));
InstallDevicePathCallback ();
- VisitAllInstancesOfProtocol (&gEfiPciRootBridgeIoProtocolGuid,
- ConnectRootBridge, NULL);
+ VisitAllInstancesOfProtocol (
+ &gEfiPciRootBridgeIoProtocolGuid,
+ ConnectRootBridge,
+ NULL
+ );
//
// Signal the ACPI platform driver that it can download QEMU ACPI tables.
@@ -389,9 +420,12 @@ PlatformBootManagerBeforeConsole (
// Any TPM 2 Physical Presence Interface opcode must be handled before.
//
Handle = NULL;
- Status = gBS->InstallProtocolInterface (&Handle,
- &gEfiDxeSmmReadyToLockProtocolGuid, EFI_NATIVE_INTERFACE,
- NULL);
+ Status = gBS->InstallProtocolInterface (
+ &Handle,
+ &gEfiDxeSmmReadyToLockProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ NULL
+ );
ASSERT_EFI_ERROR (Status);
//
@@ -406,11 +440,13 @@ PlatformBootManagerBeforeConsole (
// Install both VIRTIO_DEVICE_PROTOCOL and (dependent) EFI_RNG_PROTOCOL
// instances on Virtio PCI RNG devices.
//
- VisitAllInstancesOfProtocol (&gEfiPciIoProtocolGuid, ConnectVirtioPciRng,
- NULL);
+ VisitAllInstancesOfProtocol (
+ &gEfiPciIoProtocolGuid,
+ ConnectVirtioPciRng,
+ NULL
+ );
}
-
EFI_STATUS
EFIAPI
ConnectRootBridge (
@@ -419,7 +455,7 @@ ConnectRootBridge (
IN VOID *Context
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Make the PCI bus driver connect the root bridge, non-recursively. This
@@ -435,34 +471,39 @@ ConnectRootBridge (
return Status;
}
-
STATIC
EFI_STATUS
EFIAPI
ConnectVirtioPciRng (
- IN EFI_HANDLE Handle,
- IN VOID *Instance,
- IN VOID *Context
+ IN EFI_HANDLE Handle,
+ IN VOID *Instance,
+ IN VOID *Context
)
{
- EFI_PCI_IO_PROTOCOL *PciIo;
- EFI_STATUS Status;
- UINT16 VendorId;
- UINT16 DeviceId;
- UINT8 RevisionId;
- BOOLEAN Virtio10;
- UINT16 SubsystemId;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ EFI_STATUS Status;
+ UINT16 VendorId;
+ UINT16 DeviceId;
+ UINT8 RevisionId;
+ BOOLEAN Virtio10;
+ UINT16 SubsystemId;
PciIo = Instance;
//
// Read and check VendorId.
//
- Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint16, PCI_VENDOR_ID_OFFSET,
- 1, &VendorId);
+ Status = PciIo->Pci.Read (
+ PciIo,
+ EfiPciIoWidthUint16,
+ PCI_VENDOR_ID_OFFSET,
+ 1,
+ &VendorId
+ );
if (EFI_ERROR (Status)) {
goto Error;
}
+
if (VendorId != VIRTIO_VENDOR_ID) {
return EFI_SUCCESS;
}
@@ -470,13 +511,24 @@ ConnectVirtioPciRng (
//
// Read DeviceId and RevisionId.
//
- Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint16, PCI_DEVICE_ID_OFFSET,
- 1, &DeviceId);
+ Status = PciIo->Pci.Read (
+ PciIo,
+ EfiPciIoWidthUint16,
+ PCI_DEVICE_ID_OFFSET,
+ 1,
+ &DeviceId
+ );
if (EFI_ERROR (Status)) {
goto Error;
}
- Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, PCI_REVISION_ID_OFFSET,
- 1, &RevisionId);
+
+ Status = PciIo->Pci.Read (
+ PciIo,
+ EfiPciIoWidthUint8,
+ PCI_REVISION_ID_OFFSET,
+ 1,
+ &RevisionId
+ );
if (EFI_ERROR (Status)) {
goto Error;
}
@@ -488,10 +540,11 @@ ConnectVirtioPciRng (
// SubsystemId will only play a sanity-check role. Otherwise, DeviceId can
// only be sanity-checked, and SubsystemId will decide.
//
- if (DeviceId == 0x1040 + VIRTIO_SUBSYSTEM_ENTROPY_SOURCE &&
- RevisionId >= 0x01) {
+ if ((DeviceId == 0x1040 + VIRTIO_SUBSYSTEM_ENTROPY_SOURCE) &&
+ (RevisionId >= 0x01))
+ {
Virtio10 = TRUE;
- } else if (DeviceId >= 0x1000 && DeviceId <= 0x103F && RevisionId == 0x00) {
+ } else if ((DeviceId >= 0x1000) && (DeviceId <= 0x103F) && (RevisionId == 0x00)) {
Virtio10 = FALSE;
} else {
return EFI_SUCCESS;
@@ -500,13 +553,20 @@ ConnectVirtioPciRng (
//
// Read and check SubsystemId as dictated by Virtio10.
//
- Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint16,
- PCI_SUBSYSTEM_ID_OFFSET, 1, &SubsystemId);
+ Status = PciIo->Pci.Read (
+ PciIo,
+ EfiPciIoWidthUint16,
+ PCI_SUBSYSTEM_ID_OFFSET,
+ 1,
+ &SubsystemId
+ );
if (EFI_ERROR (Status)) {
goto Error;
}
- if ((Virtio10 && SubsystemId >= 0x40) ||
- (!Virtio10 && SubsystemId == VIRTIO_SUBSYSTEM_ENTROPY_SOURCE)) {
+
+ if ((Virtio10 && (SubsystemId >= 0x40)) ||
+ (!Virtio10 && (SubsystemId == VIRTIO_SUBSYSTEM_ENTROPY_SOURCE)))
+ {
Status = gBS->ConnectController (
Handle, // ControllerHandle
NULL, // DriverImageHandle -- connect all drivers
@@ -517,6 +577,7 @@ ConnectVirtioPciRng (
goto Error;
}
}
+
return EFI_SUCCESS;
Error:
@@ -524,7 +585,6 @@ Error:
return Status;
}
-
/**
Add IsaKeyboard to ConIn; add IsaSerial to ConOut, ConIn, ErrOut.
@@ -538,7 +598,7 @@ Error:
**/
EFI_STATUS
PrepareLpcBridgeDevicePath (
- IN EFI_HANDLE DeviceHandle
+ IN EFI_HANDLE DeviceHandle
)
{
EFI_STATUS Status;
@@ -547,50 +607,59 @@ PrepareLpcBridgeDevicePath (
CHAR16 *DevPathStr;
DevicePath = NULL;
- Status = gBS->HandleProtocol (
- DeviceHandle,
- &gEfiDevicePathProtocolGuid,
- (VOID*)&DevicePath
- );
+ Status = gBS->HandleProtocol (
+ DeviceHandle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID *)&DevicePath
+ );
if (EFI_ERROR (Status)) {
return Status;
}
+
TempDevicePath = DevicePath;
//
// Register Keyboard
//
- DevicePath = AppendDevicePathNode (DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *)&gPnpPs2KeyboardDeviceNode);
+ DevicePath = AppendDevicePathNode (
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gPnpPs2KeyboardDeviceNode
+ );
EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);
//
// Register COM1
//
- DevicePath = TempDevicePath;
+ DevicePath = TempDevicePath;
gPnp16550ComPortDeviceNode.UID = 0;
- DevicePath = AppendDevicePathNode (DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode);
- DevicePath = AppendDevicePathNode (DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);
- DevicePath = AppendDevicePathNode (DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);
+ DevicePath = AppendDevicePathNode (
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode
+ );
+ DevicePath = AppendDevicePathNode (
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode
+ );
+ DevicePath = AppendDevicePathNode (
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode
+ );
//
// Print Device Path
//
DevPathStr = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
if (DevPathStr != NULL) {
- DEBUG((
+ DEBUG ((
DEBUG_INFO,
"BdsPlatform.c+%d: COM%d DevPath: %s\n",
DEBUG_LINE_NUMBER,
gPnp16550ComPortDeviceNode.UID + 1,
DevPathStr
));
- FreePool(DevPathStr);
+ FreePool (DevPathStr);
}
EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
@@ -604,19 +673,19 @@ PrepareLpcBridgeDevicePath (
EFI_STATUS
GetGopDevicePath (
- IN EFI_DEVICE_PATH_PROTOCOL *PciDevicePath,
- OUT EFI_DEVICE_PATH_PROTOCOL **GopDevicePath
- )
+ IN EFI_DEVICE_PATH_PROTOCOL *PciDevicePath,
+ OUT EFI_DEVICE_PATH_PROTOCOL **GopDevicePath
+ )
{
- UINTN Index;
- EFI_STATUS Status;
- EFI_HANDLE PciDeviceHandle;
- EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
- EFI_DEVICE_PATH_PROTOCOL *TempPciDevicePath;
- UINTN GopHandleCount;
- EFI_HANDLE *GopHandleBuffer;
-
- if (PciDevicePath == NULL || GopDevicePath == NULL) {
+ UINTN Index;
+ EFI_STATUS Status;
+ EFI_HANDLE PciDeviceHandle;
+ EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *TempPciDevicePath;
+ UINTN GopHandleCount;
+ EFI_HANDLE *GopHandleBuffer;
+
+ if ((PciDevicePath == NULL) || (GopDevicePath == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -655,16 +724,21 @@ GetGopDevicePath (
// Add all the child handles as possible Console Device
//
for (Index = 0; Index < GopHandleCount; Index++) {
- Status = gBS->HandleProtocol (GopHandleBuffer[Index],
- &gEfiDevicePathProtocolGuid, (VOID*)&TempDevicePath);
+ Status = gBS->HandleProtocol (
+ GopHandleBuffer[Index],
+ &gEfiDevicePathProtocolGuid,
+ (VOID *)&TempDevicePath
+ );
if (EFI_ERROR (Status)) {
continue;
}
+
if (CompareMem (
PciDevicePath,
TempDevicePath,
GetDevicePathSize (PciDevicePath) - END_DEVICE_PATH_LENGTH
- ) == 0) {
+ ) == 0)
+ {
//
// In current implementation, we only enable one of the child handles
// as console device, i.e. sotre one of the child handle's device
@@ -682,6 +756,7 @@ GetGopDevicePath (
EfiBootManagerUpdateConsoleVariable (ConOutDev, TempDevicePath, NULL);
}
}
+
gBS->FreePool (GopHandleBuffer);
}
@@ -700,7 +775,7 @@ GetGopDevicePath (
**/
EFI_STATUS
PreparePciDisplayDevicePath (
- IN EFI_HANDLE DeviceHandle
+ IN EFI_HANDLE DeviceHandle
)
{
EFI_STATUS Status;
@@ -709,11 +784,11 @@ PreparePciDisplayDevicePath (
DevicePath = NULL;
GopDevicePath = NULL;
- Status = gBS->HandleProtocol (
- DeviceHandle,
- &gEfiDevicePathProtocolGuid,
- (VOID*)&DevicePath
- );
+ Status = gBS->HandleProtocol (
+ DeviceHandle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID *)&DevicePath
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -739,26 +814,30 @@ PreparePciDisplayDevicePath (
**/
EFI_STATUS
PreparePciSerialDevicePath (
- IN EFI_HANDLE DeviceHandle
+ IN EFI_HANDLE DeviceHandle
)
{
EFI_STATUS Status;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
DevicePath = NULL;
- Status = gBS->HandleProtocol (
- DeviceHandle,
- &gEfiDevicePathProtocolGuid,
- (VOID*)&DevicePath
- );
+ Status = gBS->HandleProtocol (
+ DeviceHandle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID *)&DevicePath
+ );
if (EFI_ERROR (Status)) {
return Status;
}
- DevicePath = AppendDevicePathNode (DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);
- DevicePath = AppendDevicePathNode (DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);
+ DevicePath = AppendDevicePathNode (
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode
+ );
+ DevicePath = AppendDevicePathNode (
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode
+ );
EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);
@@ -774,24 +853,24 @@ VisitAllInstancesOfProtocol (
IN VOID *Context
)
{
- EFI_STATUS Status;
- UINTN HandleCount;
- EFI_HANDLE *HandleBuffer;
- UINTN Index;
- VOID *Instance;
+ EFI_STATUS Status;
+ UINTN HandleCount;
+ EFI_HANDLE *HandleBuffer;
+ UINTN Index;
+ VOID *Instance;
//
// Start to check all the PciIo to find all possible device
//
- HandleCount = 0;
+ HandleCount = 0;
HandleBuffer = NULL;
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- Id,
- NULL,
- &HandleCount,
- &HandleBuffer
- );
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ Id,
+ NULL,
+ &HandleCount,
+ &HandleBuffer
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -802,11 +881,11 @@ VisitAllInstancesOfProtocol (
continue;
}
- Status = (*CallBackFunction) (
- HandleBuffer[Index],
- Instance,
- Context
- );
+ Status = (*CallBackFunction)(
+ HandleBuffer[Index],
+ Instance,
+ Context
+ );
}
gBS->FreePool (HandleBuffer);
@@ -814,7 +893,6 @@ VisitAllInstancesOfProtocol (
return EFI_SUCCESS;
}
-
EFI_STATUS
EFIAPI
VisitingAPciInstance (
@@ -823,49 +901,45 @@ VisitingAPciInstance (
IN VOID *Context
)
{
- EFI_STATUS Status;
- EFI_PCI_IO_PROTOCOL *PciIo;
- PCI_TYPE00 Pci;
+ EFI_STATUS Status;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ PCI_TYPE00 Pci;
- PciIo = (EFI_PCI_IO_PROTOCOL*) Instance;
+ PciIo = (EFI_PCI_IO_PROTOCOL *)Instance;
//
// Check for all PCI device
//
Status = PciIo->Pci.Read (
- PciIo,
- EfiPciIoWidthUint32,
- 0,
- sizeof (Pci) / sizeof (UINT32),
- &Pci
- );
+ PciIo,
+ EfiPciIoWidthUint32,
+ 0,
+ sizeof (Pci) / sizeof (UINT32),
+ &Pci
+ );
if (EFI_ERROR (Status)) {
return Status;
}
- return (*(VISIT_PCI_INSTANCE_CALLBACK)(UINTN) Context) (
- Handle,
- PciIo,
- &Pci
- );
-
+ return (*(VISIT_PCI_INSTANCE_CALLBACK)(UINTN)Context)(
+ Handle,
+ PciIo,
+ &Pci
+ );
}
-
-
EFI_STATUS
VisitAllPciInstances (
- IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction
+ IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction
)
{
return VisitAllInstancesOfProtocol (
&gEfiPciIoProtocolGuid,
VisitingAPciInstance,
- (VOID*)(UINTN) CallBackFunction
+ (VOID *)(UINTN)CallBackFunction
);
}
-
/**
Do platform specific PCI Device check and add them to
ConOut, ConIn, ErrOut.
@@ -887,14 +961,14 @@ DetectAndPreparePlatformPciDevicePath (
IN PCI_TYPE00 *Pci
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = PciIo->Attributes (
- PciIo,
- EfiPciIoAttributeOperationEnable,
- EFI_PCI_DEVICE_ENABLE,
- NULL
- );
+ PciIo,
+ EfiPciIoAttributeOperationEnable,
+ EFI_PCI_DEVICE_ENABLE,
+ NULL
+ );
ASSERT_EFI_ERROR (Status);
//
@@ -905,7 +979,8 @@ DetectAndPreparePlatformPciDevicePath (
(Pci->Hdr.VendorId == 0x8086) &&
(Pci->Hdr.DeviceId == 0x7000)
)
- ) {
+ )
+ {
//
// Add IsaKeyboard to ConIn,
// add IsaSerial to ConOut, ConIn, ErrOut
@@ -914,6 +989,7 @@ DetectAndPreparePlatformPciDevicePath (
PrepareLpcBridgeDevicePath (Handle);
return EFI_SUCCESS;
}
+
//
// Here we decide which Serial device to enable in PCI bus
//
@@ -941,7 +1017,6 @@ DetectAndPreparePlatformPciDevicePath (
return Status;
}
-
/**
Connect the predefined platform default console device.
@@ -951,10 +1026,10 @@ DetectAndPreparePlatformPciDevicePath (
**/
VOID
PlatformInitializeConsole (
- IN PLATFORM_CONSOLE_CONNECT_ENTRY *PlatformConsole
+ IN PLATFORM_CONSOLE_CONNECT_ENTRY *PlatformConsole
)
{
- UINTN Index;
+ UINTN Index;
//
// Do platform specific PCI Device check and add them to ConOut, ConIn,
@@ -972,21 +1047,31 @@ PlatformInitializeConsole (
// Update the console variable with the connect type
//
if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {
- EfiBootManagerUpdateConsoleVariable (ConIn,
- PlatformConsole[Index].DevicePath, NULL);
+ EfiBootManagerUpdateConsoleVariable (
+ ConIn,
+ PlatformConsole[Index].DevicePath,
+ NULL
+ );
}
+
if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {
- EfiBootManagerUpdateConsoleVariable (ConOut,
- PlatformConsole[Index].DevicePath, NULL);
+ EfiBootManagerUpdateConsoleVariable (
+ ConOut,
+ PlatformConsole[Index].DevicePath,
+ NULL
+ );
}
+
if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {
- EfiBootManagerUpdateConsoleVariable (ErrOut,
- PlatformConsole[Index].DevicePath, NULL);
+ EfiBootManagerUpdateConsoleVariable (
+ ErrOut,
+ PlatformConsole[Index].DevicePath,
+ NULL
+ );
}
}
}
-
/**
Configure PCI Interrupt Line register for applicable devices
Ported from SeaBIOS, src/fw/pciinit.c, *_pci_slot_get_irq()
@@ -1017,15 +1102,15 @@ SetPciIntLine (
Status = EFI_SUCCESS;
if (PciHdr->Device.InterruptPin != 0) {
-
DevPathNode = DevicePathFromHandle (Handle);
ASSERT (DevPathNode != NULL);
DevPath = DevPathNode;
RootBusNumber = 0;
- if (DevicePathType (DevPathNode) == ACPI_DEVICE_PATH &&
- DevicePathSubType (DevPathNode) == ACPI_DP &&
- ((ACPI_HID_DEVICE_PATH *)DevPathNode)->HID == EISA_PNP_ID(0x0A03)) {
+ if ((DevicePathType (DevPathNode) == ACPI_DEVICE_PATH) &&
+ (DevicePathSubType (DevPathNode) == ACPI_DP) &&
+ (((ACPI_HID_DEVICE_PATH *)DevPathNode)->HID == EISA_PNP_ID (0x0A03)))
+ {
RootBusNumber = ((ACPI_HID_DEVICE_PATH *)DevPathNode)->UID;
}
@@ -1033,13 +1118,13 @@ SetPciIntLine (
// Compute index into PciHostIrqs[] table by walking
// the device path and adding up all device numbers
//
- Status = EFI_NOT_FOUND;
+ Status = EFI_NOT_FOUND;
RootSlot = 0;
- Idx = PciHdr->Device.InterruptPin - 1;
+ Idx = PciHdr->Device.InterruptPin - 1;
while (!IsDevicePathEnd (DevPathNode)) {
- if (DevicePathType (DevPathNode) == HARDWARE_DEVICE_PATH &&
- DevicePathSubType (DevPathNode) == HW_PCI_DP) {
-
+ if ((DevicePathType (DevPathNode) == HARDWARE_DEVICE_PATH) &&
+ (DevicePathSubType (DevPathNode) == HW_PCI_DP))
+ {
Idx += ((PCI_DEVICE_PATH *)DevPathNode)->Device;
//
@@ -1050,18 +1135,20 @@ SetPciIntLine (
// Q35 cases with more than 24 slots on the root bus.
//
if (Status != EFI_SUCCESS) {
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
RootSlot = ((PCI_DEVICE_PATH *)DevPathNode)->Device;
}
}
DevPathNode = NextDevicePathNode (DevPathNode);
}
+
if (EFI_ERROR (Status)) {
return Status;
}
- if (RootBusNumber == 0 && RootSlot == 0) {
- DEBUG((
+
+ if ((RootBusNumber == 0) && (RootSlot == 0)) {
+ DEBUG ((
DEBUG_ERROR,
"%a: PCI host bridge (00:00.0) should have no interrupts!\n",
__FUNCTION__
@@ -1095,29 +1182,39 @@ SetPciIntLine (
//
Idx -= RootSlot;
}
+
break;
default:
ASSERT (FALSE); // should never get here
}
- Idx %= ARRAY_SIZE (PciHostIrqs);
+
+ Idx %= ARRAY_SIZE (PciHostIrqs);
IrqLine = PciHostIrqs[Idx];
DEBUG_CODE_BEGIN ();
{
- CHAR16 *DevPathString;
- STATIC CHAR16 Fallback[] = L"<failed to convert>";
- UINTN Segment, Bus, Device, Function;
+ CHAR16 *DevPathString;
+ STATIC CHAR16 Fallback[] = L"<failed to convert>";
+ UINTN Segment, Bus, Device, Function;
DevPathString = ConvertDevicePathToText (DevPath, FALSE, FALSE);
if (DevPathString == NULL) {
DevPathString = Fallback;
}
+
Status = PciIo->GetLocation (PciIo, &Segment, &Bus, &Device, &Function);
ASSERT_EFI_ERROR (Status);
- DEBUG ((DEBUG_VERBOSE, "%a: [%02x:%02x.%x] %s -> 0x%02x\n", __FUNCTION__,
- (UINT32)Bus, (UINT32)Device, (UINT32)Function, DevPathString,
- IrqLine));
+ DEBUG ((
+ DEBUG_VERBOSE,
+ "%a: [%02x:%02x.%x] %s -> 0x%02x\n",
+ __FUNCTION__,
+ (UINT32)Bus,
+ (UINT32)Device,
+ (UINT32)Function,
+ DevPathString,
+ IrqLine
+ ));
if (DevPathString != Fallback) {
FreePool (DevPathString);
@@ -1129,18 +1226,17 @@ SetPciIntLine (
// Set PCI Interrupt Line register for this device to PciHostIrqs[Idx]
//
Status = PciIo->Pci.Write (
- PciIo,
- EfiPciIoWidthUint8,
- PCI_INT_LINE_OFFSET,
- 1,
- &IrqLine
- );
+ PciIo,
+ EfiPciIoWidthUint8,
+ PCI_INT_LINE_OFFSET,
+ 1,
+ &IrqLine
+ );
}
return Status;
}
-
VOID
PciAcpiInitialization (
)
@@ -1179,8 +1275,12 @@ PciAcpiInitialization (
PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x6b), 0x0b); // H
break;
default:
- DEBUG ((DEBUG_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n",
- __FUNCTION__, mHostBridgeDevId));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Unknown Host Bridge Device ID: 0x%04x\n",
+ __FUNCTION__,
+ mHostBridgeDevId
+ ));
ASSERT (FALSE);
return;
}
@@ -1213,11 +1313,11 @@ ConnectRecursivelyIfPciMassStorage (
//
if (IS_CLASS1 (PciHeader, PCI_CLASS_MASS_STORAGE)) {
DevicePath = NULL;
- Status = gBS->HandleProtocol (
- Handle,
- &gEfiDevicePathProtocolGuid,
- (VOID*)&DevicePath
- );
+ Status = gBS->HandleProtocol (
+ Handle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID *)&DevicePath
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -1227,29 +1327,27 @@ ConnectRecursivelyIfPciMassStorage (
//
DevPathStr = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
if (DevPathStr != NULL) {
- DEBUG((
+ DEBUG ((
DEBUG_INFO,
"Found %s device: %s\n",
(IS_CLASS1 (PciHeader, PCI_CLASS_MASS_STORAGE) ?
L"Mass Storage" :
L"Xen"
- ),
+ ),
DevPathStr
));
- FreePool(DevPathStr);
+ FreePool (DevPathStr);
}
Status = gBS->ConnectController (Handle, NULL, NULL, TRUE);
if (EFI_ERROR (Status)) {
return Status;
}
-
}
return EFI_SUCCESS;
}
-
/**
This notification function is invoked when the
EMU Variable FVB has been changed.
@@ -1261,15 +1359,14 @@ ConnectRecursivelyIfPciMassStorage (
VOID
EFIAPI
EmuVariablesUpdatedCallback (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
DEBUG ((DEBUG_INFO, "EmuVariablesUpdatedCallback\n"));
UpdateNvVarsOnFileSystem ();
}
-
EFI_STATUS
EFIAPI
VisitingFileSystemInstance (
@@ -1292,7 +1389,7 @@ VisitingFileSystemInstance (
}
ConnectedToFileSystem = TRUE;
- mEmuVariableEvent =
+ mEmuVariableEvent =
EfiCreateProtocolNotifyEvent (
&gEfiDevicePathProtocolGuid,
TPL_CALLBACK,
@@ -1300,14 +1397,15 @@ VisitingFileSystemInstance (
NULL,
&mEmuVariableEventReg
);
- PcdStatus = PcdSet64S (PcdEmuVariableEvent,
- (UINT64)(UINTN) mEmuVariableEvent);
+ PcdStatus = PcdSet64S (
+ PcdEmuVariableEvent,
+ (UINT64)(UINTN)mEmuVariableEvent
+ );
ASSERT_RETURN_ERROR (PcdStatus);
return EFI_SUCCESS;
}
-
VOID
PlatformBdsRestoreNvVarsFromHardDisk (
)
@@ -1318,7 +1416,6 @@ PlatformBdsRestoreNvVarsFromHardDisk (
VisitingFileSystemInstance,
NULL
);
-
}
/**
@@ -1331,7 +1428,7 @@ PlatformBdsConnectSequence (
VOID
)
{
- UINTN Index;
+ UINTN Index;
DEBUG ((DEBUG_INFO, "PlatformBdsConnectSequence\n"));
@@ -1363,8 +1460,8 @@ PlatformBdsConnectSequence (
Note that DxeSmmReadyToLock must be signaled after this function returns;
otherwise the script wouldn't be saved actually.
**/
-#if defined(__GNUC__)
-__attribute__((unused))
+#if defined (__GNUC__)
+__attribute__ ((unused))
#endif
STATIC
VOID
@@ -1372,12 +1469,15 @@ SaveS3BootScript (
VOID
)
{
- EFI_STATUS Status;
- EFI_S3_SAVE_STATE_PROTOCOL *BootScript;
- STATIC CONST UINT8 Info[] = { 0xDE, 0xAD, 0xBE, 0xEF };
+ EFI_STATUS Status;
+ EFI_S3_SAVE_STATE_PROTOCOL *BootScript;
+ STATIC CONST UINT8 Info[] = { 0xDE, 0xAD, 0xBE, 0xEF };
- Status = gBS->LocateProtocol (&gEfiS3SaveStateProtocolGuid, NULL,
- (VOID **) &BootScript);
+ Status = gBS->LocateProtocol (
+ &gEfiS3SaveStateProtocolGuid,
+ NULL,
+ (VOID **)&BootScript
+ );
ASSERT_EFI_ERROR (Status);
//
@@ -1385,13 +1485,15 @@ SaveS3BootScript (
// implementation embeds a deep copy of the info in the boot script, rather
// than storing just a pointer to runtime or NVS storage.
//
- Status = BootScript->Write(BootScript, EFI_BOOT_SCRIPT_INFORMATION_OPCODE,
- (UINT32) sizeof Info,
- (EFI_PHYSICAL_ADDRESS)(UINTN) &Info);
+ Status = BootScript->Write (
+ BootScript,
+ EFI_BOOT_SCRIPT_INFORMATION_OPCODE,
+ (UINT32)sizeof Info,
+ (EFI_PHYSICAL_ADDRESS)(UINTN)&Info
+ );
ASSERT_EFI_ERROR (Status);
}
-
/**
Do the platform specific action after the console is ready
@@ -1411,18 +1513,22 @@ PlatformBootManagerAfterConsole (
VOID
)
{
- EFI_BOOT_MODE BootMode;
+ EFI_BOOT_MODE BootMode;
DEBUG ((DEBUG_INFO, "PlatformBootManagerAfterConsole\n"));
if (PcdGetBool (PcdOvmfFlashVariablesEnable)) {
- DEBUG ((DEBUG_INFO, "PlatformBdsPolicyBehavior: not restoring NvVars "
- "from disk since flash variables appear to be supported.\n"));
+ DEBUG ((
+ DEBUG_INFO,
+ "PlatformBdsPolicyBehavior: not restoring NvVars "
+ "from disk since flash variables appear to be supported.\n"
+ ));
} else {
//
// Try to restore variables from the hard disk early so
// they can be used for the other BDS connect operations.
//
+
/* XXX Calling this causes Keyboard to be removed from ConIn which
results in unresponsive guest boot loaders in the GUI. Restore it
when we figure out what is needed to get NvVars storage done
@@ -1464,7 +1570,9 @@ PlatformBootManagerAfterConsole (
// Register UEFI Shell
//
PlatformRegisterFvBootOption (
- &gUefiShellFileGuid, L"EFI Internal Shell", LOAD_OPTION_ACTIVE
+ &gUefiShellFileGuid,
+ L"EFI Internal Shell",
+ LOAD_OPTION_ACTIVE
);
RemoveStaleFvFileOptions ();
@@ -1483,31 +1591,31 @@ PlatformBootManagerAfterConsole (
VOID
EFIAPI
NotifyDevPath (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- EFI_HANDLE Handle;
- EFI_STATUS Status;
- UINTN BufferSize;
- EFI_DEVICE_PATH_PROTOCOL *DevPathNode;
- ATAPI_DEVICE_PATH *Atapi;
+ EFI_HANDLE Handle;
+ EFI_STATUS Status;
+ UINTN BufferSize;
+ EFI_DEVICE_PATH_PROTOCOL *DevPathNode;
+ ATAPI_DEVICE_PATH *Atapi;
//
// Examine all new handles
//
- for (;;) {
+ for ( ; ;) {
//
// Get the next handle
//
BufferSize = sizeof (Handle);
- Status = gBS->LocateHandle (
- ByRegisterNotify,
- NULL,
- mEfiDevPathNotifyReg,
- &BufferSize,
- &Handle
- );
+ Status = gBS->LocateHandle (
+ ByRegisterNotify,
+ NULL,
+ mEfiDevPathNotifyReg,
+ &BufferSize,
+ &Handle
+ );
//
// If not found, we're done
@@ -1523,8 +1631,11 @@ NotifyDevPath (
//
// Get the DevicePath protocol on that handle
//
- Status = gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid,
- (VOID **)&DevPathNode);
+ Status = gBS->HandleProtocol (
+ Handle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID **)&DevPathNode
+ );
ASSERT_EFI_ERROR (Status);
while (!IsDevicePathEnd (DevPathNode)) {
@@ -1532,16 +1643,17 @@ NotifyDevPath (
// Find the handler to dump this device path node
//
if (
- (DevicePathType(DevPathNode) == MESSAGING_DEVICE_PATH) &&
- (DevicePathSubType(DevPathNode) == MSG_ATAPI_DP)
- ) {
- Atapi = (ATAPI_DEVICE_PATH*) DevPathNode;
+ (DevicePathType (DevPathNode) == MESSAGING_DEVICE_PATH) &&
+ (DevicePathSubType (DevPathNode) == MSG_ATAPI_DP)
+ )
+ {
+ Atapi = (ATAPI_DEVICE_PATH *)DevPathNode;
PciOr16 (
PCI_LIB_ADDRESS (
0,
1,
1,
- (Atapi->PrimarySecondary == 1) ? 0x42: 0x40
+ (Atapi->PrimarySecondary == 1) ? 0x42 : 0x40
),
BIT15
);
@@ -1557,7 +1669,6 @@ NotifyDevPath (
return;
}
-
VOID
InstallDevicePathCallback (
VOID
@@ -1565,12 +1676,12 @@ InstallDevicePathCallback (
{
DEBUG ((DEBUG_INFO, "Registered NotifyDevPath Event\n"));
mEfiDevPathEvent = EfiCreateProtocolNotifyEvent (
- &gEfiDevicePathProtocolGuid,
- TPL_CALLBACK,
- NotifyDevPath,
- NULL,
- &mEfiDevPathNotifyReg
- );
+ &gEfiDevicePathProtocolGuid,
+ TPL_CALLBACK,
+ NotifyDevPath,
+ NULL,
+ &mEfiDevPathNotifyReg
+ );
}
/**
@@ -1582,12 +1693,12 @@ InstallDevicePathCallback (
VOID
EFIAPI
PlatformBootManagerWaitCallback (
- UINT16 TimeoutRemain
+ UINT16 TimeoutRemain
)
{
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION White;
- UINT16 Timeout;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION White;
+ UINT16 Timeout;
Timeout = PcdGet16 (PcdPlatformBootTimeOut);
@@ -1617,10 +1728,10 @@ PlatformBootManagerUnableToBoot (
VOID
)
{
- EFI_STATUS Status;
- EFI_INPUT_KEY Key;
- EFI_BOOT_MANAGER_LOAD_OPTION BootManagerMenu;
- UINTN Index;
+ EFI_STATUS Status;
+ EFI_INPUT_KEY Key;
+ EFI_BOOT_MANAGER_LOAD_OPTION BootManagerMenu;
+ UINTN Index;
//
// BootManagerMenu doesn't contain the correct information when return status
@@ -1630,6 +1741,7 @@ PlatformBootManagerUnableToBoot (
if (EFI_ERROR (Status)) {
return;
}
+
//
// Normally BdsDxe does not print anything to the system console, but this is
// a last resort -- the end-user will likely not see any DEBUG messages
@@ -1659,7 +1771,7 @@ PlatformBootManagerUnableToBoot (
}
}
- for (;;) {
+ for ( ; ;) {
EfiBootManagerBoot (&BootManagerMenu);
}
}
diff --git a/OvmfPkg/Library/PlatformBootManagerLibBhyve/BdsPlatform.h b/OvmfPkg/Library/PlatformBootManagerLibBhyve/BdsPlatform.h
index 382fe191a9..9be184cb64 100644
--- a/OvmfPkg/Library/PlatformBootManagerLibBhyve/BdsPlatform.h
+++ b/OvmfPkg/Library/PlatformBootManagerLibBhyve/BdsPlatform.h
@@ -18,7 +18,6 @@ Abstract:
#ifndef _PLATFORM_SPECIFIC_BDS_PLATFORM_H_
#define _PLATFORM_SPECIFIC_BDS_PLATFORM_H_
-
#include <PiDxe.h>
#include <IndustryStandard/Pci.h>
@@ -65,11 +64,11 @@ Abstract:
#include <OvmfPlatforms.h>
-extern EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[];
-extern ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode;
-extern ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode;
-extern UART_DEVICE_PATH gUartDeviceNode;
-extern VENDOR_DEVICE_PATH gTerminalTypeDeviceNode;
+extern EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[];
+extern ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode;
+extern ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode;
+extern UART_DEVICE_PATH gUartDeviceNode;
+extern VENDOR_DEVICE_PATH gTerminalTypeDeviceNode;
#define PCI_DEVICE_PATH_NODE(Func, Dev) \
{ \
@@ -151,20 +150,20 @@ extern VENDOR_DEVICE_PATH gTerminalTypeDeviceNode;
} \
}
-#define PCI_CLASS_SCC 0x07
-#define PCI_SUBCLASS_SERIAL 0x00
-#define PCI_IF_16550 0x02
-#define IS_PCI_16550SERIAL(_p) IS_CLASS3 (_p, PCI_CLASS_SCC, PCI_SUBCLASS_SERIAL, PCI_IF_16550)
-#define IS_PCI_ISA_PDECODE(_p) IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_ISA_PDECODE, 0)
+#define PCI_CLASS_SCC 0x07
+#define PCI_SUBCLASS_SERIAL 0x00
+#define PCI_IF_16550 0x02
+#define IS_PCI_16550SERIAL(_p) IS_CLASS3 (_p, PCI_CLASS_SCC, PCI_SUBCLASS_SERIAL, PCI_IF_16550)
+#define IS_PCI_ISA_PDECODE(_p) IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_ISA_PDECODE, 0)
typedef struct {
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- UINTN ConnectType;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ UINTN ConnectType;
} PLATFORM_CONSOLE_CONNECT_ENTRY;
-#define CONSOLE_OUT BIT0
-#define CONSOLE_IN BIT1
-#define STD_ERROR BIT2
+#define CONSOLE_OUT BIT0
+#define CONSOLE_IN BIT1
+#define STD_ERROR BIT2
extern PLATFORM_CONSOLE_CONNECT_ENTRY gPlatformConsole[];
//
@@ -173,7 +172,7 @@ extern PLATFORM_CONSOLE_CONNECT_ENTRY gPlatformConsole[];
VOID
PlatformInitializeConsole (
- IN PLATFORM_CONSOLE_CONNECT_ENTRY *PlatformConsole
+ IN PLATFORM_CONSOLE_CONNECT_ENTRY *PlatformConsole
);
/**
diff --git a/OvmfPkg/Library/PlatformBootManagerLibBhyve/PlatformData.c b/OvmfPkg/Library/PlatformBootManagerLibBhyve/PlatformData.c
index 73674d536d..b57789b73d 100644
--- a/OvmfPkg/Library/PlatformBootManagerLibBhyve/PlatformData.c
+++ b/OvmfPkg/Library/PlatformBootManagerLibBhyve/PlatformData.c
@@ -16,10 +16,10 @@
//
#pragma pack(1)
typedef struct {
- VENDOR_DEVICE_PATH VendorHardware;
- UART_DEVICE_PATH Uart;
- VENDOR_DEVICE_PATH TerminalType;
- EFI_DEVICE_PATH_PROTOCOL End;
+ VENDOR_DEVICE_PATH VendorHardware;
+ UART_DEVICE_PATH Uart;
+ VENDOR_DEVICE_PATH TerminalType;
+ EFI_DEVICE_PATH_PROTOCOL End;
} VENDOR_UART_DEVICE_PATH;
#pragma pack()
@@ -28,8 +28,8 @@ typedef struct {
//
#pragma pack (1)
typedef struct {
- USB_CLASS_DEVICE_PATH Keyboard;
- EFI_DEVICE_PATH_PROTOCOL End;
+ USB_CLASS_DEVICE_PATH Keyboard;
+ EFI_DEVICE_PATH_PROTOCOL End;
} USB_KEYBOARD_DEVICE_PATH;
#pragma pack ()
@@ -38,33 +38,32 @@ typedef struct {
//
#pragma pack (1)
typedef struct {
- VENDOR_DEVICE_PATH Vendor;
- ACPI_ADR_DEVICE_PATH AcpiAdr;
- EFI_DEVICE_PATH_PROTOCOL End;
+ VENDOR_DEVICE_PATH Vendor;
+ ACPI_ADR_DEVICE_PATH AcpiAdr;
+ EFI_DEVICE_PATH_PROTOCOL End;
} VENDOR_RAMFB_DEVICE_PATH;
#pragma pack ()
-ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode = gPnpPs2Keyboard;
-ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode = gPnp16550ComPort;
-UART_DEVICE_PATH gUartDeviceNode = gUart;
-VENDOR_DEVICE_PATH gTerminalTypeDeviceNode = gPcAnsiTerminal;
+ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode = gPnpPs2Keyboard;
+ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode = gPnp16550ComPort;
+UART_DEVICE_PATH gUartDeviceNode = gUart;
+VENDOR_DEVICE_PATH gTerminalTypeDeviceNode = gPcAnsiTerminal;
//
// Platform specific keyboard device path
//
-
//
// Debug Agent UART Device Path
//
-VENDOR_UART_DEVICE_PATH gDebugAgentUartDevicePath = {
+VENDOR_UART_DEVICE_PATH gDebugAgentUartDevicePath = {
{
{
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{
- (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
- (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
+ (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}
},
EFI_DEBUG_AGENT_GUID,
@@ -74,8 +73,8 @@ VENDOR_UART_DEVICE_PATH gDebugAgentUartDevicePath = {
MESSAGING_DEVICE_PATH,
MSG_UART_DP,
{
- (UINT8) (sizeof (UART_DEVICE_PATH)),
- (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (UART_DEVICE_PATH)),
+ (UINT8)((sizeof (UART_DEVICE_PATH)) >> 8)
}
},
0, // Reserved
@@ -88,7 +87,7 @@ VENDOR_UART_DEVICE_PATH gDebugAgentUartDevicePath = {
gEndEntire
};
-STATIC USB_KEYBOARD_DEVICE_PATH gUsbKeyboardDevicePath = {
+STATIC USB_KEYBOARD_DEVICE_PATH gUsbKeyboardDevicePath = {
{
{
MESSAGING_DEVICE_PATH,
@@ -107,14 +106,14 @@ STATIC USB_KEYBOARD_DEVICE_PATH gUsbKeyboardDevicePath = {
gEndEntire
};
-STATIC VENDOR_RAMFB_DEVICE_PATH gQemuRamfbDevicePath = {
+STATIC VENDOR_RAMFB_DEVICE_PATH gQemuRamfbDevicePath = {
{
{
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{
- (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
- (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
+ (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}
},
QEMU_RAMFB_GUID,
@@ -124,8 +123,8 @@ STATIC VENDOR_RAMFB_DEVICE_PATH gQemuRamfbDevicePath = {
ACPI_DEVICE_PATH,
ACPI_ADR_DP,
{
- (UINT8) (sizeof (ACPI_ADR_DEVICE_PATH)),
- (UINT8) ((sizeof (ACPI_ADR_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (ACPI_ADR_DEVICE_PATH)),
+ (UINT8)((sizeof (ACPI_ADR_DEVICE_PATH)) >> 8)
}
},
ACPI_DISPLAY_ADR (
@@ -145,9 +144,9 @@ STATIC VENDOR_RAMFB_DEVICE_PATH gQemuRamfbDevicePath = {
//
// Predefined platform default console device path
//
-PLATFORM_CONSOLE_CONNECT_ENTRY gPlatformConsole[] = {
+PLATFORM_CONSOLE_CONNECT_ENTRY gPlatformConsole[] = {
{
- (EFI_DEVICE_PATH_PROTOCOL *) &gDebugAgentUartDevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gDebugAgentUartDevicePath,
(CONSOLE_OUT | CONSOLE_IN | STD_ERROR)
},
{
@@ -167,5 +166,4 @@ PLATFORM_CONSOLE_CONNECT_ENTRY gPlatformConsole[] = {
//
// Predefined platform connect sequence
//
-EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[] = { NULL };
-
+EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[] = { NULL };
diff --git a/OvmfPkg/Library/PlatformBootManagerLibGrub/BdsPlatform.c b/OvmfPkg/Library/PlatformBootManagerLibGrub/BdsPlatform.c
index e238af21f1..9c6848bbff 100644
--- a/OvmfPkg/Library/PlatformBootManagerLibGrub/BdsPlatform.c
+++ b/OvmfPkg/Library/PlatformBootManagerLibGrub/BdsPlatform.c
@@ -13,20 +13,19 @@
#include <Library/PlatformBmPrintScLib.h>
#include <Library/Tcg2PhysicalPresenceLib.h>
-
//
// Global data
//
-VOID *mEfiDevPathNotifyReg;
-EFI_EVENT mEfiDevPathEvent;
-UINT16 mHostBridgeDevId;
+VOID *mEfiDevPathNotifyReg;
+EFI_EVENT mEfiDevPathEvent;
+UINT16 mHostBridgeDevId;
//
// Table of host IRQs matching PCI IRQs A-D
// (for configuring PCI Interrupt Line register)
//
-CONST UINT8 PciHostIrqs[] = {
+CONST UINT8 PciHostIrqs[] = {
0x0a, 0x0a, 0x0b, 0x0b
};
@@ -55,7 +54,6 @@ EFI_STATUS
IN PCI_TYPE00 *Pci
);
-
//
// Function prototypes
//
@@ -69,7 +67,7 @@ VisitAllInstancesOfProtocol (
EFI_STATUS
VisitAllPciInstancesOfProtocol (
- IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction
+ IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction
);
VOID
@@ -79,24 +77,24 @@ InstallDevicePathCallback (
VOID
PlatformRegisterFvBootOption (
- EFI_GUID *FileGuid,
- CHAR16 *Description,
- UINT32 Attributes
+ EFI_GUID *FileGuid,
+ CHAR16 *Description,
+ UINT32 Attributes
)
{
- EFI_STATUS Status;
- INTN OptionIndex;
- EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
- EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
- UINTN BootOptionCount;
- MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
- EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_STATUS Status;
+ INTN OptionIndex;
+ EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
+ EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
+ UINTN BootOptionCount;
+ MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
Status = gBS->HandleProtocol (
gImageHandle,
&gEfiLoadedImageProtocolGuid,
- (VOID **) &LoadedImage
+ (VOID **)&LoadedImage
);
ASSERT_EFI_ERROR (Status);
@@ -105,7 +103,7 @@ PlatformRegisterFvBootOption (
ASSERT (DevicePath != NULL);
DevicePath = AppendDevicePathNode (
DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *) &FileNode
+ (EFI_DEVICE_PATH_PROTOCOL *)&FileNode
);
ASSERT (DevicePath != NULL);
@@ -123,17 +121,21 @@ PlatformRegisterFvBootOption (
FreePool (DevicePath);
BootOptions = EfiBootManagerGetLoadOptions (
- &BootOptionCount, LoadOptionTypeBoot
+ &BootOptionCount,
+ LoadOptionTypeBoot
);
OptionIndex = EfiBootManagerFindLoadOption (
- &NewOption, BootOptions, BootOptionCount
+ &NewOption,
+ BootOptions,
+ BootOptionCount
);
if (OptionIndex == -1) {
Status = EfiBootManagerAddLoadOptionVariable (&NewOption, MAX_UINTN);
ASSERT_EFI_ERROR (Status);
}
+
EfiBootManagerFreeLoadOption (&NewOption);
EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
}
@@ -160,29 +162,34 @@ RemoveStaleFvFileOptions (
VOID
)
{
- EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
- UINTN BootOptionCount;
- UINTN Index;
+ EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
+ UINTN BootOptionCount;
+ UINTN Index;
- BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount,
- LoadOptionTypeBoot);
+ BootOptions = EfiBootManagerGetLoadOptions (
+ &BootOptionCount,
+ LoadOptionTypeBoot
+ );
for (Index = 0; Index < BootOptionCount; ++Index) {
- EFI_DEVICE_PATH_PROTOCOL *Node1, *Node2, *SearchNode;
- EFI_STATUS Status;
- EFI_HANDLE FvHandle;
+ EFI_DEVICE_PATH_PROTOCOL *Node1, *Node2, *SearchNode;
+ EFI_STATUS Status;
+ EFI_HANDLE FvHandle;
//
// If the device path starts with neither MemoryMapped(...) nor Fv(...),
// then delete the boot option.
//
Node1 = BootOptions[Index].FilePath;
- if (!(DevicePathType (Node1) == HARDWARE_DEVICE_PATH &&
- DevicePathSubType (Node1) == HW_MEMMAP_DP) &&
- !(DevicePathType (Node1) == MEDIA_DEVICE_PATH &&
- DevicePathSubType (Node1) == MEDIA_PIWG_FW_VOL_DP)) {
+ if (!((DevicePathType (Node1) == HARDWARE_DEVICE_PATH) &&
+ (DevicePathSubType (Node1) == HW_MEMMAP_DP)) &&
+ !((DevicePathType (Node1) == MEDIA_DEVICE_PATH) &&
+ (DevicePathSubType (Node1) == MEDIA_PIWG_FW_VOL_DP)))
+ {
EfiBootManagerDeleteLoadOptionVariable (
- BootOptions[Index].OptionNumber, LoadOptionTypeBoot);
+ BootOptions[Index].OptionNumber,
+ LoadOptionTypeBoot
+ );
continue;
}
@@ -191,10 +198,13 @@ RemoveStaleFvFileOptions (
// option.
//
Node2 = NextDevicePathNode (Node1);
- if (DevicePathType (Node2) != MEDIA_DEVICE_PATH ||
- DevicePathSubType (Node2) != MEDIA_PIWG_FW_FILE_DP) {
+ if ((DevicePathType (Node2) != MEDIA_DEVICE_PATH) ||
+ (DevicePathSubType (Node2) != MEDIA_PIWG_FW_FILE_DP))
+ {
EfiBootManagerDeleteLoadOptionVariable (
- BootOptions[Index].OptionNumber, LoadOptionTypeBoot);
+ BootOptions[Index].OptionNumber,
+ LoadOptionTypeBoot
+ );
continue;
}
@@ -205,23 +215,29 @@ RemoveStaleFvFileOptions (
// boot option.
//
SearchNode = Node1;
- Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid,
- &SearchNode, &FvHandle);
+ Status = gBS->LocateDevicePath (
+ &gEfiFirmwareVolume2ProtocolGuid,
+ &SearchNode,
+ &FvHandle
+ );
if (!EFI_ERROR (Status)) {
//
// The firmware volume was found; now let's see if it contains the FvFile
// identified by GUID.
//
- EFI_FIRMWARE_VOLUME2_PROTOCOL *FvProtocol;
- MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFileNode;
- UINTN BufferSize;
- EFI_FV_FILETYPE FoundType;
- EFI_FV_FILE_ATTRIBUTES FileAttributes;
- UINT32 AuthenticationStatus;
-
- Status = gBS->HandleProtocol (FvHandle, &gEfiFirmwareVolume2ProtocolGuid,
- (VOID **)&FvProtocol);
+ EFI_FIRMWARE_VOLUME2_PROTOCOL *FvProtocol;
+ MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFileNode;
+ UINTN BufferSize;
+ EFI_FV_FILETYPE FoundType;
+ EFI_FV_FILE_ATTRIBUTES FileAttributes;
+ UINT32 AuthenticationStatus;
+
+ Status = gBS->HandleProtocol (
+ FvHandle,
+ &gEfiFirmwareVolume2ProtocolGuid,
+ (VOID **)&FvProtocol
+ );
ASSERT_EFI_ERROR (Status);
FvFileNode = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)Node2;
@@ -250,23 +266,29 @@ RemoveStaleFvFileOptions (
// Delete the boot option.
//
Status = EfiBootManagerDeleteLoadOptionVariable (
- BootOptions[Index].OptionNumber, LoadOptionTypeBoot);
+ BootOptions[Index].OptionNumber,
+ LoadOptionTypeBoot
+ );
DEBUG_CODE_BEGIN ();
- CHAR16 *DevicePathString;
+ CHAR16 *DevicePathString;
+
+ DevicePathString = ConvertDevicePathToText (
+ BootOptions[Index].FilePath,
+ FALSE,
+ FALSE
+ );
+ DEBUG ((
+ EFI_ERROR (Status) ? DEBUG_WARN : DEBUG_VERBOSE,
+ "%a: removing stale Boot#%04x %s: %r\n",
+ __FUNCTION__,
+ (UINT32)BootOptions[Index].OptionNumber,
+ DevicePathString == NULL ? L"<unavailable>" : DevicePathString,
+ Status
+ ));
+ if (DevicePathString != NULL) {
+ FreePool (DevicePathString);
+ }
- DevicePathString = ConvertDevicePathToText(BootOptions[Index].FilePath,
- FALSE, FALSE);
- DEBUG ((
- EFI_ERROR (Status) ? DEBUG_WARN : DEBUG_VERBOSE,
- "%a: removing stale Boot#%04x %s: %r\n",
- __FUNCTION__,
- (UINT32)BootOptions[Index].OptionNumber,
- DevicePathString == NULL ? L"<unavailable>" : DevicePathString,
- Status
- ));
- if (DevicePathString != NULL) {
- FreePool (DevicePathString);
- }
DEBUG_CODE_END ();
}
@@ -285,14 +307,15 @@ STATIC
EFI_STATUS
EFIAPI
ConnectVirtioPciRng (
- IN EFI_HANDLE Handle,
- IN VOID *Instance,
- IN VOID *Context
+ IN EFI_HANDLE Handle,
+ IN VOID *Instance,
+ IN VOID *Context
);
//
// BDS Platform Functions
//
+
/**
Do the platform init, can be customized by OEM/IBV
@@ -312,17 +335,20 @@ PlatformBootManagerBeforeConsole (
VOID
)
{
- EFI_HANDLE Handle;
- EFI_STATUS Status;
- UINT16 FrontPageTimeout;
+ EFI_HANDLE Handle;
+ EFI_STATUS Status;
+ UINT16 FrontPageTimeout;
FrontPageTimeout = 0;
DEBUG ((DEBUG_INFO, "PlatformBootManagerBeforeConsole\n"));
InstallDevicePathCallback ();
- VisitAllInstancesOfProtocol (&gEfiPciRootBridgeIoProtocolGuid,
- ConnectRootBridge, NULL);
+ VisitAllInstancesOfProtocol (
+ &gEfiPciRootBridgeIoProtocolGuid,
+ ConnectRootBridge,
+ NULL
+ );
//
// Signal the ACPI platform driver that it can download QEMU ACPI tables.
@@ -352,9 +378,12 @@ PlatformBootManagerBeforeConsole (
// Any TPM 2 Physical Presence Interface opcode must be handled before.
//
Handle = NULL;
- Status = gBS->InstallProtocolInterface (&Handle,
- &gEfiDxeSmmReadyToLockProtocolGuid, EFI_NATIVE_INTERFACE,
- NULL);
+ Status = gBS->InstallProtocolInterface (
+ &Handle,
+ &gEfiDxeSmmReadyToLockProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ NULL
+ );
ASSERT_EFI_ERROR (Status);
//
@@ -376,11 +405,13 @@ PlatformBootManagerBeforeConsole (
// Install both VIRTIO_DEVICE_PROTOCOL and (dependent) EFI_RNG_PROTOCOL
// instances on Virtio PCI RNG devices.
//
- VisitAllInstancesOfProtocol (&gEfiPciIoProtocolGuid, ConnectVirtioPciRng,
- NULL);
+ VisitAllInstancesOfProtocol (
+ &gEfiPciIoProtocolGuid,
+ ConnectVirtioPciRng,
+ NULL
+ );
}
-
EFI_STATUS
EFIAPI
ConnectRootBridge (
@@ -389,7 +420,7 @@ ConnectRootBridge (
IN VOID *Context
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Make the PCI bus driver connect the root bridge, non-recursively. This
@@ -405,34 +436,39 @@ ConnectRootBridge (
return Status;
}
-
STATIC
EFI_STATUS
EFIAPI
ConnectVirtioPciRng (
- IN EFI_HANDLE Handle,
- IN VOID *Instance,
- IN VOID *Context
+ IN EFI_HANDLE Handle,
+ IN VOID *Instance,
+ IN VOID *Context
)
{
- EFI_PCI_IO_PROTOCOL *PciIo;
- EFI_STATUS Status;
- UINT16 VendorId;
- UINT16 DeviceId;
- UINT8 RevisionId;
- BOOLEAN Virtio10;
- UINT16 SubsystemId;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ EFI_STATUS Status;
+ UINT16 VendorId;
+ UINT16 DeviceId;
+ UINT8 RevisionId;
+ BOOLEAN Virtio10;
+ UINT16 SubsystemId;
PciIo = Instance;
//
// Read and check VendorId.
//
- Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint16, PCI_VENDOR_ID_OFFSET,
- 1, &VendorId);
+ Status = PciIo->Pci.Read (
+ PciIo,
+ EfiPciIoWidthUint16,
+ PCI_VENDOR_ID_OFFSET,
+ 1,
+ &VendorId
+ );
if (EFI_ERROR (Status)) {
goto Error;
}
+
if (VendorId != VIRTIO_VENDOR_ID) {
return EFI_SUCCESS;
}
@@ -440,13 +476,24 @@ ConnectVirtioPciRng (
//
// Read DeviceId and RevisionId.
//
- Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint16, PCI_DEVICE_ID_OFFSET,
- 1, &DeviceId);
+ Status = PciIo->Pci.Read (
+ PciIo,
+ EfiPciIoWidthUint16,
+ PCI_DEVICE_ID_OFFSET,
+ 1,
+ &DeviceId
+ );
if (EFI_ERROR (Status)) {
goto Error;
}
- Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, PCI_REVISION_ID_OFFSET,
- 1, &RevisionId);
+
+ Status = PciIo->Pci.Read (
+ PciIo,
+ EfiPciIoWidthUint8,
+ PCI_REVISION_ID_OFFSET,
+ 1,
+ &RevisionId
+ );
if (EFI_ERROR (Status)) {
goto Error;
}
@@ -458,10 +505,11 @@ ConnectVirtioPciRng (
// SubsystemId will only play a sanity-check role. Otherwise, DeviceId can
// only be sanity-checked, and SubsystemId will decide.
//
- if (DeviceId == 0x1040 + VIRTIO_SUBSYSTEM_ENTROPY_SOURCE &&
- RevisionId >= 0x01) {
+ if ((DeviceId == 0x1040 + VIRTIO_SUBSYSTEM_ENTROPY_SOURCE) &&
+ (RevisionId >= 0x01))
+ {
Virtio10 = TRUE;
- } else if (DeviceId >= 0x1000 && DeviceId <= 0x103F && RevisionId == 0x00) {
+ } else if ((DeviceId >= 0x1000) && (DeviceId <= 0x103F) && (RevisionId == 0x00)) {
Virtio10 = FALSE;
} else {
return EFI_SUCCESS;
@@ -470,13 +518,20 @@ ConnectVirtioPciRng (
//
// Read and check SubsystemId as dictated by Virtio10.
//
- Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint16,
- PCI_SUBSYSTEM_ID_OFFSET, 1, &SubsystemId);
+ Status = PciIo->Pci.Read (
+ PciIo,
+ EfiPciIoWidthUint16,
+ PCI_SUBSYSTEM_ID_OFFSET,
+ 1,
+ &SubsystemId
+ );
if (EFI_ERROR (Status)) {
goto Error;
}
- if ((Virtio10 && SubsystemId >= 0x40) ||
- (!Virtio10 && SubsystemId == VIRTIO_SUBSYSTEM_ENTROPY_SOURCE)) {
+
+ if ((Virtio10 && (SubsystemId >= 0x40)) ||
+ (!Virtio10 && (SubsystemId == VIRTIO_SUBSYSTEM_ENTROPY_SOURCE)))
+ {
Status = gBS->ConnectController (
Handle, // ControllerHandle
NULL, // DriverImageHandle -- connect all drivers
@@ -487,6 +542,7 @@ ConnectVirtioPciRng (
goto Error;
}
}
+
return EFI_SUCCESS;
Error:
@@ -494,7 +550,6 @@ Error:
return Status;
}
-
/**
Add IsaKeyboard to ConIn; add IsaSerial to ConOut, ConIn, ErrOut.
@@ -508,7 +563,7 @@ Error:
**/
EFI_STATUS
PrepareLpcBridgeDevicePath (
- IN EFI_HANDLE DeviceHandle
+ IN EFI_HANDLE DeviceHandle
)
{
EFI_STATUS Status;
@@ -517,50 +572,59 @@ PrepareLpcBridgeDevicePath (
CHAR16 *DevPathStr;
DevicePath = NULL;
- Status = gBS->HandleProtocol (
- DeviceHandle,
- &gEfiDevicePathProtocolGuid,
- (VOID*)&DevicePath
- );
+ Status = gBS->HandleProtocol (
+ DeviceHandle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID *)&DevicePath
+ );
if (EFI_ERROR (Status)) {
return Status;
}
+
TempDevicePath = DevicePath;
//
// Register Keyboard
//
- DevicePath = AppendDevicePathNode (DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *)&gPnpPs2KeyboardDeviceNode);
+ DevicePath = AppendDevicePathNode (
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gPnpPs2KeyboardDeviceNode
+ );
EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);
//
// Register COM1
//
- DevicePath = TempDevicePath;
+ DevicePath = TempDevicePath;
gPnp16550ComPortDeviceNode.UID = 0;
- DevicePath = AppendDevicePathNode (DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode);
- DevicePath = AppendDevicePathNode (DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);
- DevicePath = AppendDevicePathNode (DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);
+ DevicePath = AppendDevicePathNode (
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode
+ );
+ DevicePath = AppendDevicePathNode (
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode
+ );
+ DevicePath = AppendDevicePathNode (
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode
+ );
//
// Print Device Path
//
DevPathStr = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
if (DevPathStr != NULL) {
- DEBUG((
+ DEBUG ((
DEBUG_INFO,
"BdsPlatform.c+%d: COM%d DevPath: %s\n",
DEBUG_LINE_NUMBER,
gPnp16550ComPortDeviceNode.UID + 1,
DevPathStr
));
- FreePool(DevPathStr);
+ FreePool (DevPathStr);
}
EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
@@ -570,29 +634,35 @@ PrepareLpcBridgeDevicePath (
//
// Register COM2
//
- DevicePath = TempDevicePath;
+ DevicePath = TempDevicePath;
gPnp16550ComPortDeviceNode.UID = 1;
- DevicePath = AppendDevicePathNode (DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode);
- DevicePath = AppendDevicePathNode (DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);
- DevicePath = AppendDevicePathNode (DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);
+ DevicePath = AppendDevicePathNode (
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode
+ );
+ DevicePath = AppendDevicePathNode (
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode
+ );
+ DevicePath = AppendDevicePathNode (
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode
+ );
//
// Print Device Path
//
DevPathStr = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
if (DevPathStr != NULL) {
- DEBUG((
+ DEBUG ((
DEBUG_INFO,
"BdsPlatform.c+%d: COM%d DevPath: %s\n",
DEBUG_LINE_NUMBER,
gPnp16550ComPortDeviceNode.UID + 1,
DevPathStr
));
- FreePool(DevPathStr);
+ FreePool (DevPathStr);
}
EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
@@ -604,19 +674,19 @@ PrepareLpcBridgeDevicePath (
EFI_STATUS
GetGopDevicePath (
- IN EFI_DEVICE_PATH_PROTOCOL *PciDevicePath,
- OUT EFI_DEVICE_PATH_PROTOCOL **GopDevicePath
- )
+ IN EFI_DEVICE_PATH_PROTOCOL *PciDevicePath,
+ OUT EFI_DEVICE_PATH_PROTOCOL **GopDevicePath
+ )
{
- UINTN Index;
- EFI_STATUS Status;
- EFI_HANDLE PciDeviceHandle;
- EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
- EFI_DEVICE_PATH_PROTOCOL *TempPciDevicePath;
- UINTN GopHandleCount;
- EFI_HANDLE *GopHandleBuffer;
-
- if (PciDevicePath == NULL || GopDevicePath == NULL) {
+ UINTN Index;
+ EFI_STATUS Status;
+ EFI_HANDLE PciDeviceHandle;
+ EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *TempPciDevicePath;
+ UINTN GopHandleCount;
+ EFI_HANDLE *GopHandleBuffer;
+
+ if ((PciDevicePath == NULL) || (GopDevicePath == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -655,16 +725,21 @@ GetGopDevicePath (
// Add all the child handles as possible Console Device
//
for (Index = 0; Index < GopHandleCount; Index++) {
- Status = gBS->HandleProtocol (GopHandleBuffer[Index],
- &gEfiDevicePathProtocolGuid, (VOID*)&TempDevicePath);
+ Status = gBS->HandleProtocol (
+ GopHandleBuffer[Index],
+ &gEfiDevicePathProtocolGuid,
+ (VOID *)&TempDevicePath
+ );
if (EFI_ERROR (Status)) {
continue;
}
+
if (CompareMem (
PciDevicePath,
TempDevicePath,
GetDevicePathSize (PciDevicePath) - END_DEVICE_PATH_LENGTH
- ) == 0) {
+ ) == 0)
+ {
//
// In current implementation, we only enable one of the child handles
// as console device, i.e. sotre one of the child handle's device
@@ -682,6 +757,7 @@ GetGopDevicePath (
EfiBootManagerUpdateConsoleVariable (ConOutDev, TempDevicePath, NULL);
}
}
+
gBS->FreePool (GopHandleBuffer);
}
@@ -700,7 +776,7 @@ GetGopDevicePath (
**/
EFI_STATUS
PreparePciDisplayDevicePath (
- IN EFI_HANDLE DeviceHandle
+ IN EFI_HANDLE DeviceHandle
)
{
EFI_STATUS Status;
@@ -709,11 +785,11 @@ PreparePciDisplayDevicePath (
DevicePath = NULL;
GopDevicePath = NULL;
- Status = gBS->HandleProtocol (
- DeviceHandle,
- &gEfiDevicePathProtocolGuid,
- (VOID*)&DevicePath
- );
+ Status = gBS->HandleProtocol (
+ DeviceHandle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID *)&DevicePath
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -739,26 +815,30 @@ PreparePciDisplayDevicePath (
**/
EFI_STATUS
PreparePciSerialDevicePath (
- IN EFI_HANDLE DeviceHandle
+ IN EFI_HANDLE DeviceHandle
)
{
EFI_STATUS Status;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
DevicePath = NULL;
- Status = gBS->HandleProtocol (
- DeviceHandle,
- &gEfiDevicePathProtocolGuid,
- (VOID*)&DevicePath
- );
+ Status = gBS->HandleProtocol (
+ DeviceHandle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID *)&DevicePath
+ );
if (EFI_ERROR (Status)) {
return Status;
}
- DevicePath = AppendDevicePathNode (DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);
- DevicePath = AppendDevicePathNode (DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);
+ DevicePath = AppendDevicePathNode (
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode
+ );
+ DevicePath = AppendDevicePathNode (
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode
+ );
EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);
@@ -774,24 +854,24 @@ VisitAllInstancesOfProtocol (
IN VOID *Context
)
{
- EFI_STATUS Status;
- UINTN HandleCount;
- EFI_HANDLE *HandleBuffer;
- UINTN Index;
- VOID *Instance;
+ EFI_STATUS Status;
+ UINTN HandleCount;
+ EFI_HANDLE *HandleBuffer;
+ UINTN Index;
+ VOID *Instance;
//
// Start to check all the PciIo to find all possible device
//
- HandleCount = 0;
+ HandleCount = 0;
HandleBuffer = NULL;
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- Id,
- NULL,
- &HandleCount,
- &HandleBuffer
- );
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ Id,
+ NULL,
+ &HandleCount,
+ &HandleBuffer
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -802,11 +882,11 @@ VisitAllInstancesOfProtocol (
continue;
}
- Status = (*CallBackFunction) (
- HandleBuffer[Index],
- Instance,
- Context
- );
+ Status = (*CallBackFunction)(
+ HandleBuffer[Index],
+ Instance,
+ Context
+ );
}
gBS->FreePool (HandleBuffer);
@@ -814,7 +894,6 @@ VisitAllInstancesOfProtocol (
return EFI_SUCCESS;
}
-
EFI_STATUS
EFIAPI
VisitingAPciInstance (
@@ -823,49 +902,45 @@ VisitingAPciInstance (
IN VOID *Context
)
{
- EFI_STATUS Status;
- EFI_PCI_IO_PROTOCOL *PciIo;
- PCI_TYPE00 Pci;
+ EFI_STATUS Status;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ PCI_TYPE00 Pci;
- PciIo = (EFI_PCI_IO_PROTOCOL*) Instance;
+ PciIo = (EFI_PCI_IO_PROTOCOL *)Instance;
//
// Check for all PCI device
//
Status = PciIo->Pci.Read (
- PciIo,
- EfiPciIoWidthUint32,
- 0,
- sizeof (Pci) / sizeof (UINT32),
- &Pci
- );
+ PciIo,
+ EfiPciIoWidthUint32,
+ 0,
+ sizeof (Pci) / sizeof (UINT32),
+ &Pci
+ );
if (EFI_ERROR (Status)) {
return Status;
}
- return (*(VISIT_PCI_INSTANCE_CALLBACK)(UINTN) Context) (
- Handle,
- PciIo,
- &Pci
- );
-
+ return (*(VISIT_PCI_INSTANCE_CALLBACK)(UINTN)Context)(
+ Handle,
+ PciIo,
+ &Pci
+ );
}
-
-
EFI_STATUS
VisitAllPciInstances (
- IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction
+ IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction
)
{
return VisitAllInstancesOfProtocol (
&gEfiPciIoProtocolGuid,
VisitingAPciInstance,
- (VOID*)(UINTN) CallBackFunction
+ (VOID *)(UINTN)CallBackFunction
);
}
-
/**
Do platform specific PCI Device check and add them to
ConOut, ConIn, ErrOut.
@@ -887,14 +962,14 @@ DetectAndPreparePlatformPciDevicePath (
IN PCI_TYPE00 *Pci
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = PciIo->Attributes (
- PciIo,
- EfiPciIoAttributeOperationEnable,
- EFI_PCI_DEVICE_ENABLE,
- NULL
- );
+ PciIo,
+ EfiPciIoAttributeOperationEnable,
+ EFI_PCI_DEVICE_ENABLE,
+ NULL
+ );
ASSERT_EFI_ERROR (Status);
//
@@ -905,7 +980,8 @@ DetectAndPreparePlatformPciDevicePath (
(Pci->Hdr.VendorId == 0x8086) &&
(Pci->Hdr.DeviceId == 0x7000)
)
- ) {
+ )
+ {
//
// Add IsaKeyboard to ConIn,
// add IsaSerial to ConOut, ConIn, ErrOut
@@ -914,6 +990,7 @@ DetectAndPreparePlatformPciDevicePath (
PrepareLpcBridgeDevicePath (Handle);
return EFI_SUCCESS;
}
+
//
// Here we decide which Serial device to enable in PCI bus
//
@@ -941,7 +1018,6 @@ DetectAndPreparePlatformPciDevicePath (
return Status;
}
-
/**
Connect the predefined platform default console device.
@@ -951,10 +1027,10 @@ DetectAndPreparePlatformPciDevicePath (
**/
VOID
PlatformInitializeConsole (
- IN PLATFORM_CONSOLE_CONNECT_ENTRY *PlatformConsole
+ IN PLATFORM_CONSOLE_CONNECT_ENTRY *PlatformConsole
)
{
- UINTN Index;
+ UINTN Index;
//
// Do platform specific PCI Device check and add them to ConOut, ConIn,
@@ -972,21 +1048,31 @@ PlatformInitializeConsole (
// Update the console variable with the connect type
//
if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {
- EfiBootManagerUpdateConsoleVariable (ConIn,
- PlatformConsole[Index].DevicePath, NULL);
+ EfiBootManagerUpdateConsoleVariable (
+ ConIn,
+ PlatformConsole[Index].DevicePath,
+ NULL
+ );
}
+
if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {
- EfiBootManagerUpdateConsoleVariable (ConOut,
- PlatformConsole[Index].DevicePath, NULL);
+ EfiBootManagerUpdateConsoleVariable (
+ ConOut,
+ PlatformConsole[Index].DevicePath,
+ NULL
+ );
}
+
if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {
- EfiBootManagerUpdateConsoleVariable (ErrOut,
- PlatformConsole[Index].DevicePath, NULL);
+ EfiBootManagerUpdateConsoleVariable (
+ ErrOut,
+ PlatformConsole[Index].DevicePath,
+ NULL
+ );
}
}
}
-
/**
Configure PCI Interrupt Line register for applicable devices
Ported from SeaBIOS, src/fw/pciinit.c, *_pci_slot_get_irq()
@@ -1017,15 +1103,15 @@ SetPciIntLine (
Status = EFI_SUCCESS;
if (PciHdr->Device.InterruptPin != 0) {
-
DevPathNode = DevicePathFromHandle (Handle);
ASSERT (DevPathNode != NULL);
DevPath = DevPathNode;
RootBusNumber = 0;
- if (DevicePathType (DevPathNode) == ACPI_DEVICE_PATH &&
- DevicePathSubType (DevPathNode) == ACPI_DP &&
- ((ACPI_HID_DEVICE_PATH *)DevPathNode)->HID == EISA_PNP_ID(0x0A03)) {
+ if ((DevicePathType (DevPathNode) == ACPI_DEVICE_PATH) &&
+ (DevicePathSubType (DevPathNode) == ACPI_DP) &&
+ (((ACPI_HID_DEVICE_PATH *)DevPathNode)->HID == EISA_PNP_ID (0x0A03)))
+ {
RootBusNumber = ((ACPI_HID_DEVICE_PATH *)DevPathNode)->UID;
}
@@ -1033,13 +1119,13 @@ SetPciIntLine (
// Compute index into PciHostIrqs[] table by walking
// the device path and adding up all device numbers
//
- Status = EFI_NOT_FOUND;
+ Status = EFI_NOT_FOUND;
RootSlot = 0;
- Idx = PciHdr->Device.InterruptPin - 1;
+ Idx = PciHdr->Device.InterruptPin - 1;
while (!IsDevicePathEnd (DevPathNode)) {
- if (DevicePathType (DevPathNode) == HARDWARE_DEVICE_PATH &&
- DevicePathSubType (DevPathNode) == HW_PCI_DP) {
-
+ if ((DevicePathType (DevPathNode) == HARDWARE_DEVICE_PATH) &&
+ (DevicePathSubType (DevPathNode) == HW_PCI_DP))
+ {
Idx += ((PCI_DEVICE_PATH *)DevPathNode)->Device;
//
@@ -1050,18 +1136,20 @@ SetPciIntLine (
// Q35 cases with more than 24 slots on the root bus.
//
if (Status != EFI_SUCCESS) {
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
RootSlot = ((PCI_DEVICE_PATH *)DevPathNode)->Device;
}
}
DevPathNode = NextDevicePathNode (DevPathNode);
}
+
if (EFI_ERROR (Status)) {
return Status;
}
- if (RootBusNumber == 0 && RootSlot == 0) {
- DEBUG((
+
+ if ((RootBusNumber == 0) && (RootSlot == 0)) {
+ DEBUG ((
DEBUG_ERROR,
"%a: PCI host bridge (00:00.0) should have no interrupts!\n",
__FUNCTION__
@@ -1093,29 +1181,39 @@ SetPciIntLine (
//
Idx -= RootSlot;
}
+
break;
default:
ASSERT (FALSE); // should never get here
}
- Idx %= ARRAY_SIZE (PciHostIrqs);
+
+ Idx %= ARRAY_SIZE (PciHostIrqs);
IrqLine = PciHostIrqs[Idx];
DEBUG_CODE_BEGIN ();
{
- CHAR16 *DevPathString;
- STATIC CHAR16 Fallback[] = L"<failed to convert>";
- UINTN Segment, Bus, Device, Function;
+ CHAR16 *DevPathString;
+ STATIC CHAR16 Fallback[] = L"<failed to convert>";
+ UINTN Segment, Bus, Device, Function;
DevPathString = ConvertDevicePathToText (DevPath, FALSE, FALSE);
if (DevPathString == NULL) {
DevPathString = Fallback;
}
+
Status = PciIo->GetLocation (PciIo, &Segment, &Bus, &Device, &Function);
ASSERT_EFI_ERROR (Status);
- DEBUG ((DEBUG_VERBOSE, "%a: [%02x:%02x.%x] %s -> 0x%02x\n", __FUNCTION__,
- (UINT32)Bus, (UINT32)Device, (UINT32)Function, DevPathString,
- IrqLine));
+ DEBUG ((
+ DEBUG_VERBOSE,
+ "%a: [%02x:%02x.%x] %s -> 0x%02x\n",
+ __FUNCTION__,
+ (UINT32)Bus,
+ (UINT32)Device,
+ (UINT32)Function,
+ DevPathString,
+ IrqLine
+ ));
if (DevPathString != Fallback) {
FreePool (DevPathString);
@@ -1127,18 +1225,17 @@ SetPciIntLine (
// Set PCI Interrupt Line register for this device to PciHostIrqs[Idx]
//
Status = PciIo->Pci.Write (
- PciIo,
- EfiPciIoWidthUint8,
- PCI_INT_LINE_OFFSET,
- 1,
- &IrqLine
- );
+ PciIo,
+ EfiPciIoWidthUint8,
+ PCI_INT_LINE_OFFSET,
+ 1,
+ &IrqLine
+ );
}
return Status;
}
-
VOID
PciAcpiInitialization (
)
@@ -1175,8 +1272,12 @@ PciAcpiInitialization (
PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x6b), 0x0b); // H
break;
default:
- DEBUG ((DEBUG_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n",
- __FUNCTION__, mHostBridgeDevId));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Unknown Host Bridge Device ID: 0x%04x\n",
+ __FUNCTION__,
+ mHostBridgeDevId
+ ));
ASSERT (FALSE);
return;
}
@@ -1209,11 +1310,11 @@ ConnectRecursivelyIfPciMassStorage (
//
if (IS_CLASS1 (PciHeader, PCI_CLASS_MASS_STORAGE)) {
DevicePath = NULL;
- Status = gBS->HandleProtocol (
- Handle,
- &gEfiDevicePathProtocolGuid,
- (VOID*)&DevicePath
- );
+ Status = gBS->HandleProtocol (
+ Handle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID *)&DevicePath
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -1223,25 +1324,23 @@ ConnectRecursivelyIfPciMassStorage (
//
DevPathStr = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
if (DevPathStr != NULL) {
- DEBUG((
+ DEBUG ((
DEBUG_INFO,
"Found Mass Storage device: %s\n",
DevPathStr
));
- FreePool(DevPathStr);
+ FreePool (DevPathStr);
}
Status = gBS->ConnectController (Handle, NULL, NULL, TRUE);
if (EFI_ERROR (Status)) {
return Status;
}
-
}
return EFI_SUCCESS;
}
-
/**
Connect with predefined platform connect sequence.
@@ -1252,7 +1351,7 @@ PlatformBdsConnectSequence (
VOID
)
{
- UINTN Index;
+ UINTN Index;
DEBUG ((DEBUG_INFO, "PlatformBdsConnectSequence\n"));
@@ -1270,6 +1369,7 @@ PlatformBdsConnectSequence (
EfiBootManagerConnectDevicePath (gPlatformConnectSequence[Index], NULL);
Index++;
}
+
EfiBootManagerConnectAll ();
}
@@ -1292,7 +1392,7 @@ PlatformBootManagerAfterConsole (
VOID
)
{
- EFI_BOOT_MODE BootMode;
+ EFI_BOOT_MODE BootMode;
DEBUG ((DEBUG_INFO, "PlatformBootManagerAfterConsole\n"));
@@ -1335,14 +1435,18 @@ PlatformBootManagerAfterConsole (
// which is the default)
//
PlatformRegisterFvBootOption (
- &gUefiShellFileGuid, L"EFI Internal Shell", LOAD_OPTION_ACTIVE
+ &gUefiShellFileGuid,
+ L"EFI Internal Shell",
+ LOAD_OPTION_ACTIVE
);
//
// Register Grub
//
PlatformRegisterFvBootOption (
- &gGrubFileGuid, L"Grub Bootloader", LOAD_OPTION_ACTIVE
+ &gGrubFileGuid,
+ L"Grub Bootloader",
+ LOAD_OPTION_ACTIVE
);
RemoveStaleFvFileOptions ();
@@ -1361,31 +1465,31 @@ PlatformBootManagerAfterConsole (
VOID
EFIAPI
NotifyDevPath (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- EFI_HANDLE Handle;
- EFI_STATUS Status;
- UINTN BufferSize;
- EFI_DEVICE_PATH_PROTOCOL *DevPathNode;
- ATAPI_DEVICE_PATH *Atapi;
+ EFI_HANDLE Handle;
+ EFI_STATUS Status;
+ UINTN BufferSize;
+ EFI_DEVICE_PATH_PROTOCOL *DevPathNode;
+ ATAPI_DEVICE_PATH *Atapi;
//
// Examine all new handles
//
- for (;;) {
+ for ( ; ;) {
//
// Get the next handle
//
BufferSize = sizeof (Handle);
- Status = gBS->LocateHandle (
- ByRegisterNotify,
- NULL,
- mEfiDevPathNotifyReg,
- &BufferSize,
- &Handle
- );
+ Status = gBS->LocateHandle (
+ ByRegisterNotify,
+ NULL,
+ mEfiDevPathNotifyReg,
+ &BufferSize,
+ &Handle
+ );
//
// If not found, we're done
@@ -1401,8 +1505,11 @@ NotifyDevPath (
//
// Get the DevicePath protocol on that handle
//
- Status = gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid,
- (VOID **)&DevPathNode);
+ Status = gBS->HandleProtocol (
+ Handle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID **)&DevPathNode
+ );
ASSERT_EFI_ERROR (Status);
while (!IsDevicePathEnd (DevPathNode)) {
@@ -1410,16 +1517,17 @@ NotifyDevPath (
// Find the handler to dump this device path node
//
if (
- (DevicePathType(DevPathNode) == MESSAGING_DEVICE_PATH) &&
- (DevicePathSubType(DevPathNode) == MSG_ATAPI_DP)
- ) {
- Atapi = (ATAPI_DEVICE_PATH*) DevPathNode;
+ (DevicePathType (DevPathNode) == MESSAGING_DEVICE_PATH) &&
+ (DevicePathSubType (DevPathNode) == MSG_ATAPI_DP)
+ )
+ {
+ Atapi = (ATAPI_DEVICE_PATH *)DevPathNode;
PciOr16 (
PCI_LIB_ADDRESS (
0,
1,
1,
- (Atapi->PrimarySecondary == 1) ? 0x42: 0x40
+ (Atapi->PrimarySecondary == 1) ? 0x42 : 0x40
),
BIT15
);
@@ -1435,7 +1543,6 @@ NotifyDevPath (
return;
}
-
VOID
InstallDevicePathCallback (
VOID
@@ -1443,12 +1550,12 @@ InstallDevicePathCallback (
{
DEBUG ((DEBUG_INFO, "Registered NotifyDevPath Event\n"));
mEfiDevPathEvent = EfiCreateProtocolNotifyEvent (
- &gEfiDevicePathProtocolGuid,
- TPL_CALLBACK,
- NotifyDevPath,
- NULL,
- &mEfiDevPathNotifyReg
- );
+ &gEfiDevicePathProtocolGuid,
+ TPL_CALLBACK,
+ NotifyDevPath,
+ NULL,
+ &mEfiDevPathNotifyReg
+ );
}
/**
@@ -1460,7 +1567,7 @@ InstallDevicePathCallback (
VOID
EFIAPI
PlatformBootManagerWaitCallback (
- UINT16 TimeoutRemain
+ UINT16 TimeoutRemain
)
{
//
diff --git a/OvmfPkg/Library/PlatformBootManagerLibGrub/BdsPlatform.h b/OvmfPkg/Library/PlatformBootManagerLibGrub/BdsPlatform.h
index f1d3a2906c..0593a51046 100644
--- a/OvmfPkg/Library/PlatformBootManagerLibGrub/BdsPlatform.h
+++ b/OvmfPkg/Library/PlatformBootManagerLibGrub/BdsPlatform.h
@@ -18,7 +18,6 @@ Abstract:
#ifndef _PLATFORM_SPECIFIC_BDS_PLATFORM_H_
#define _PLATFORM_SPECIFIC_BDS_PLATFORM_H_
-
#include <PiDxe.h>
#include <IndustryStandard/Pci.h>
@@ -60,11 +59,11 @@ Abstract:
#include <OvmfPlatforms.h>
-extern EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[];
-extern ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode;
-extern ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode;
-extern UART_DEVICE_PATH gUartDeviceNode;
-extern VENDOR_DEVICE_PATH gTerminalTypeDeviceNode;
+extern EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[];
+extern ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode;
+extern ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode;
+extern UART_DEVICE_PATH gUartDeviceNode;
+extern VENDOR_DEVICE_PATH gTerminalTypeDeviceNode;
#define PCI_DEVICE_PATH_NODE(Func, Dev) \
{ \
@@ -146,20 +145,20 @@ extern VENDOR_DEVICE_PATH gTerminalTypeDeviceNode;
} \
}
-#define PCI_CLASS_SCC 0x07
-#define PCI_SUBCLASS_SERIAL 0x00
-#define PCI_IF_16550 0x02
-#define IS_PCI_16550SERIAL(_p) IS_CLASS3 (_p, PCI_CLASS_SCC, PCI_SUBCLASS_SERIAL, PCI_IF_16550)
-#define IS_PCI_ISA_PDECODE(_p) IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_ISA_PDECODE, 0)
+#define PCI_CLASS_SCC 0x07
+#define PCI_SUBCLASS_SERIAL 0x00
+#define PCI_IF_16550 0x02
+#define IS_PCI_16550SERIAL(_p) IS_CLASS3 (_p, PCI_CLASS_SCC, PCI_SUBCLASS_SERIAL, PCI_IF_16550)
+#define IS_PCI_ISA_PDECODE(_p) IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_ISA_PDECODE, 0)
typedef struct {
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- UINTN ConnectType;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ UINTN ConnectType;
} PLATFORM_CONSOLE_CONNECT_ENTRY;
-#define CONSOLE_OUT BIT0
-#define CONSOLE_IN BIT1
-#define STD_ERROR BIT2
+#define CONSOLE_OUT BIT0
+#define CONSOLE_IN BIT1
+#define STD_ERROR BIT2
extern PLATFORM_CONSOLE_CONNECT_ENTRY gPlatformConsole[];
extern PLATFORM_CONSOLE_CONNECT_ENTRY gXenPlatformConsole[];
@@ -169,7 +168,7 @@ extern PLATFORM_CONSOLE_CONNECT_ENTRY gXenPlatformConsole[];
VOID
PlatformInitializeConsole (
- IN PLATFORM_CONSOLE_CONNECT_ENTRY *PlatformConsole
+ IN PLATFORM_CONSOLE_CONNECT_ENTRY *PlatformConsole
);
/**
diff --git a/OvmfPkg/Library/PlatformBootManagerLibGrub/PlatformData.c b/OvmfPkg/Library/PlatformBootManagerLibGrub/PlatformData.c
index e5945727f2..5e2b7510c5 100644
--- a/OvmfPkg/Library/PlatformBootManagerLibGrub/PlatformData.c
+++ b/OvmfPkg/Library/PlatformBootManagerLibGrub/PlatformData.c
@@ -17,10 +17,10 @@
//
#pragma pack (1)
typedef struct {
- VENDOR_DEVICE_PATH VendorHardware;
- UART_DEVICE_PATH Uart;
- VENDOR_DEVICE_PATH TerminalType;
- EFI_DEVICE_PATH_PROTOCOL End;
+ VENDOR_DEVICE_PATH VendorHardware;
+ UART_DEVICE_PATH Uart;
+ VENDOR_DEVICE_PATH TerminalType;
+ EFI_DEVICE_PATH_PROTOCOL End;
} VENDOR_UART_DEVICE_PATH;
#pragma pack ()
@@ -29,8 +29,8 @@ typedef struct {
//
#pragma pack (1)
typedef struct {
- USB_CLASS_DEVICE_PATH Keyboard;
- EFI_DEVICE_PATH_PROTOCOL End;
+ USB_CLASS_DEVICE_PATH Keyboard;
+ EFI_DEVICE_PATH_PROTOCOL End;
} USB_KEYBOARD_DEVICE_PATH;
#pragma pack ()
@@ -39,33 +39,32 @@ typedef struct {
//
#pragma pack (1)
typedef struct {
- VENDOR_DEVICE_PATH Vendor;
- ACPI_ADR_DEVICE_PATH AcpiAdr;
- EFI_DEVICE_PATH_PROTOCOL End;
+ VENDOR_DEVICE_PATH Vendor;
+ ACPI_ADR_DEVICE_PATH AcpiAdr;
+ EFI_DEVICE_PATH_PROTOCOL End;
} VENDOR_RAMFB_DEVICE_PATH;
#pragma pack ()
-ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode = gPnpPs2Keyboard;
-ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode = gPnp16550ComPort;
-UART_DEVICE_PATH gUartDeviceNode = gUart;
-VENDOR_DEVICE_PATH gTerminalTypeDeviceNode = gPcAnsiTerminal;
+ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode = gPnpPs2Keyboard;
+ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode = gPnp16550ComPort;
+UART_DEVICE_PATH gUartDeviceNode = gUart;
+VENDOR_DEVICE_PATH gTerminalTypeDeviceNode = gPcAnsiTerminal;
//
// Platform specific keyboard device path
//
-
//
// Debug Agent UART Device Path
//
-VENDOR_UART_DEVICE_PATH gDebugAgentUartDevicePath = {
+VENDOR_UART_DEVICE_PATH gDebugAgentUartDevicePath = {
{
{
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{
- (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
- (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
+ (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}
},
EFI_DEBUG_AGENT_GUID,
@@ -75,8 +74,8 @@ VENDOR_UART_DEVICE_PATH gDebugAgentUartDevicePath = {
MESSAGING_DEVICE_PATH,
MSG_UART_DP,
{
- (UINT8) (sizeof (UART_DEVICE_PATH)),
- (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (UART_DEVICE_PATH)),
+ (UINT8)((sizeof (UART_DEVICE_PATH)) >> 8)
}
},
0, // Reserved
@@ -89,7 +88,7 @@ VENDOR_UART_DEVICE_PATH gDebugAgentUartDevicePath = {
gEndEntire
};
-STATIC USB_KEYBOARD_DEVICE_PATH gUsbKeyboardDevicePath = {
+STATIC USB_KEYBOARD_DEVICE_PATH gUsbKeyboardDevicePath = {
{
{
MESSAGING_DEVICE_PATH,
@@ -108,14 +107,14 @@ STATIC USB_KEYBOARD_DEVICE_PATH gUsbKeyboardDevicePath = {
gEndEntire
};
-STATIC VENDOR_RAMFB_DEVICE_PATH gQemuRamfbDevicePath = {
+STATIC VENDOR_RAMFB_DEVICE_PATH gQemuRamfbDevicePath = {
{
{
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{
- (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
- (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
+ (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}
},
QEMU_RAMFB_GUID,
@@ -125,8 +124,8 @@ STATIC VENDOR_RAMFB_DEVICE_PATH gQemuRamfbDevicePath = {
ACPI_DEVICE_PATH,
ACPI_ADR_DP,
{
- (UINT8) (sizeof (ACPI_ADR_DEVICE_PATH)),
- (UINT8) ((sizeof (ACPI_ADR_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (ACPI_ADR_DEVICE_PATH)),
+ (UINT8)((sizeof (ACPI_ADR_DEVICE_PATH)) >> 8)
}
},
ACPI_DISPLAY_ADR (
@@ -143,14 +142,14 @@ STATIC VENDOR_RAMFB_DEVICE_PATH gQemuRamfbDevicePath = {
gEndEntire
};
-STATIC VENDOR_UART_DEVICE_PATH gXenConsoleDevicePath = {
+STATIC VENDOR_UART_DEVICE_PATH gXenConsoleDevicePath = {
{
{
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{
- (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
- (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
+ (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}
},
EDKII_SERIAL_PORT_LIB_VENDOR_GUID
@@ -160,8 +159,8 @@ STATIC VENDOR_UART_DEVICE_PATH gXenConsoleDevicePath = {
MESSAGING_DEVICE_PATH,
MSG_UART_DP,
{
- (UINT8) (sizeof (UART_DEVICE_PATH)),
- (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (UART_DEVICE_PATH)),
+ (UINT8)((sizeof (UART_DEVICE_PATH)) >> 8)
}
},
0,
@@ -177,9 +176,9 @@ STATIC VENDOR_UART_DEVICE_PATH gXenConsoleDevicePath = {
//
// Predefined platform default console device path
//
-PLATFORM_CONSOLE_CONNECT_ENTRY gPlatformConsole[] = {
+PLATFORM_CONSOLE_CONNECT_ENTRY gPlatformConsole[] = {
{
- (EFI_DEVICE_PATH_PROTOCOL *) &gDebugAgentUartDevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gDebugAgentUartDevicePath,
(CONSOLE_OUT | CONSOLE_IN | STD_ERROR)
},
{
@@ -196,7 +195,7 @@ PLATFORM_CONSOLE_CONNECT_ENTRY gPlatformConsole[] = {
}
};
-PLATFORM_CONSOLE_CONNECT_ENTRY gXenPlatformConsole[] = {
+PLATFORM_CONSOLE_CONNECT_ENTRY gXenPlatformConsole[] = {
{
(EFI_DEVICE_PATH_PROTOCOL *)&gXenConsoleDevicePath,
(CONSOLE_OUT | CONSOLE_IN | STD_ERROR)
@@ -210,5 +209,4 @@ PLATFORM_CONSOLE_CONNECT_ENTRY gXenPlatformConsole[] = {
//
// Predefined platform connect sequence
//
-EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[] = { NULL };
-
+EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[] = { NULL };
diff --git a/OvmfPkg/Library/PlatformBootManagerLibGrub/QemuKernel.c b/OvmfPkg/Library/PlatformBootManagerLibGrub/QemuKernel.c
index c625592177..1e66e3c452 100644
--- a/OvmfPkg/Library/PlatformBootManagerLibGrub/QemuKernel.c
+++ b/OvmfPkg/Library/PlatformBootManagerLibGrub/QemuKernel.c
@@ -13,14 +13,13 @@
#include <Library/ReportStatusCodeLib.h>
#include <Library/UefiLib.h>
-
EFI_STATUS
TryRunningQemuKernel (
VOID
)
{
- EFI_STATUS Status;
- EFI_HANDLE KernelImageHandle;
+ EFI_STATUS Status;
+ EFI_HANDLE KernelImageHandle;
Status = QemuLoadKernelImage (&KernelImageHandle);
if (EFI_ERROR (Status)) {
@@ -30,18 +29,24 @@ TryRunningQemuKernel (
//
// Signal the EVT_SIGNAL_READY_TO_BOOT event
//
- EfiSignalEventReadyToBoot();
+ EfiSignalEventReadyToBoot ();
- REPORT_STATUS_CODE (EFI_PROGRESS_CODE,
- (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT));
+ REPORT_STATUS_CODE (
+ EFI_PROGRESS_CODE,
+ (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT)
+ );
//
// Start the image.
//
Status = QemuStartKernelImage (&KernelImageHandle);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: QemuStartKernelImage(): %r\n", __FUNCTION__,
- Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: QemuStartKernelImage(): %r\n",
+ __FUNCTION__,
+ Status
+ ));
}
QemuUnloadKernelImage (KernelImageHandle);
diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugIoPortQemu.c b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugIoPortQemu.c
index bf9119807a..94013646b1 100644
--- a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugIoPortQemu.c
+++ b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugIoPortQemu.c
@@ -15,7 +15,7 @@
//
// The constant value that is read from the debug I/O port
//
-#define BOCHS_DEBUG_PORT_MAGIC 0xE9
+#define BOCHS_DEBUG_PORT_MAGIC 0xE9
/**
Return the result of detecting the debug I/O port device.
diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c
index dffb20822d..4e25f198aa 100644
--- a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c
+++ b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c
@@ -27,7 +27,7 @@
// VA_LIST can not initialize to NULL for all compiler, so we use this to
// indicate a null VA_LIST
//
-VA_LIST mVaListNull;
+VA_LIST mVaListNull;
/**
Prints a debug message to the debug output device if the specified error level is enabled.
@@ -52,14 +52,13 @@ DebugPrint (
...
)
{
- VA_LIST Marker;
+ VA_LIST Marker;
VA_START (Marker, Format);
DebugVPrint (ErrorLevel, Format, Marker);
VA_END (Marker);
}
-
/**
Prints a debug message to the debug output device if the specified
error level is enabled base on Null-terminated format string and a
@@ -79,14 +78,14 @@ DebugPrint (
**/
VOID
DebugPrintMarker (
- IN UINTN ErrorLevel,
- IN CONST CHAR8 *Format,
- IN VA_LIST VaListMarker,
- IN BASE_LIST BaseListMarker
+ IN UINTN ErrorLevel,
+ IN CONST CHAR8 *Format,
+ IN VA_LIST VaListMarker,
+ IN BASE_LIST BaseListMarker
)
{
- CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH];
- UINTN Length;
+ CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH];
+ UINTN Length;
//
// If Format is NULL, then ASSERT().
@@ -96,8 +95,9 @@ DebugPrintMarker (
//
// Check if the global mask disables this message or the device is inactive
//
- if ((ErrorLevel & GetDebugPrintErrorLevel ()) == 0 ||
- !PlatformDebugLibIoPortFound ()) {
+ if (((ErrorLevel & GetDebugPrintErrorLevel ()) == 0) ||
+ !PlatformDebugLibIoPortFound ())
+ {
return;
}
@@ -116,7 +116,6 @@ DebugPrintMarker (
IoWriteFifo8 (PcdGet16 (PcdDebugIoPort), Length, Buffer);
}
-
/**
Prints a debug message to the debug output device if the specified
error level is enabled.
@@ -135,15 +134,14 @@ DebugPrintMarker (
VOID
EFIAPI
DebugVPrint (
- IN UINTN ErrorLevel,
- IN CONST CHAR8 *Format,
- IN VA_LIST VaListMarker
+ IN UINTN ErrorLevel,
+ IN CONST CHAR8 *Format,
+ IN VA_LIST VaListMarker
)
{
DebugPrintMarker (ErrorLevel, Format, VaListMarker, NULL);
}
-
/**
Prints a debug message to the debug output device if the specified
error level is enabled.
@@ -164,15 +162,14 @@ DebugVPrint (
VOID
EFIAPI
DebugBPrint (
- IN UINTN ErrorLevel,
- IN CONST CHAR8 *Format,
- IN BASE_LIST BaseListMarker
+ IN UINTN ErrorLevel,
+ IN CONST CHAR8 *Format,
+ IN BASE_LIST BaseListMarker
)
{
DebugPrintMarker (ErrorLevel, Format, mVaListNull, BaseListMarker);
}
-
/**
Prints an assert message containing a filename, line number, and description.
This may be followed by a breakpoint or a dead loop.
@@ -208,8 +205,14 @@ DebugAssert (
//
// Generate the ASSERT() message in Ascii format
//
- Length = AsciiSPrint (Buffer, sizeof Buffer, "ASSERT %a(%Lu): %a\n",
- FileName, (UINT64)LineNumber, Description);
+ Length = AsciiSPrint (
+ Buffer,
+ sizeof Buffer,
+ "ASSERT %a(%Lu): %a\n",
+ FileName,
+ (UINT64)LineNumber,
+ Description
+ );
//
// Send the print string to the debug I/O port, if present
@@ -221,14 +224,13 @@ DebugAssert (
//
// Generate a Breakpoint, DeadLoop, or NOP based on PCD settings
//
- if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED) != 0) {
+ if ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED) != 0) {
CpuBreakpoint ();
- } else if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED) != 0) {
+ } else if ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED) != 0) {
CpuDeadLoop ();
}
}
-
/**
Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer.
@@ -259,10 +261,9 @@ DebugClearMemory (
//
// SetMem() checks for the the ASSERT() condition on Length and returns Buffer
//
- return SetMem (Buffer, Length, PcdGet8(PcdDebugClearMemoryValue));
+ return SetMem (Buffer, Length, PcdGet8 (PcdDebugClearMemoryValue));
}
-
/**
Returns TRUE if ASSERT() macros are enabled.
@@ -279,10 +280,9 @@ DebugAssertEnabled (
VOID
)
{
- return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
+ return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
}
-
/**
Returns TRUE if DEBUG() macros are enabled.
@@ -299,10 +299,9 @@ DebugPrintEnabled (
VOID
)
{
- return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);
+ return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);
}
-
/**
Returns TRUE if DEBUG_CODE() macros are enabled.
@@ -319,10 +318,9 @@ DebugCodeEnabled (
VOID
)
{
- return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);
+ return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);
}
-
/**
Returns TRUE if DEBUG_CLEAR_MEMORY() macro is enabled.
@@ -339,7 +337,7 @@ DebugClearMemoryEnabled (
VOID
)
{
- return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);
+ return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);
}
/**
@@ -354,8 +352,8 @@ DebugClearMemoryEnabled (
BOOLEAN
EFIAPI
DebugPrintLevelEnabled (
- IN CONST UINTN ErrorLevel
+ IN CONST UINTN ErrorLevel
)
{
- return (BOOLEAN) ((ErrorLevel & PcdGet32(PcdFixedDebugPrintErrorLevel)) != 0);
+ return (BOOLEAN)((ErrorLevel & PcdGet32 (PcdFixedDebugPrintErrorLevel)) != 0);
}
diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.c b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.c
index 8c466e64e0..45207faf5c 100644
--- a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.c
+++ b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.c
@@ -13,12 +13,12 @@
//
// Set to TRUE if the debug I/O port has been checked
//
-STATIC BOOLEAN mDebugIoPortChecked = FALSE;
+STATIC BOOLEAN mDebugIoPortChecked = FALSE;
//
// Set to TRUE if the debug I/O port is enabled
//
-STATIC BOOLEAN mDebugIoPortFound = FALSE;
+STATIC BOOLEAN mDebugIoPortFound = FALSE;
/**
This constructor function must not do anything.
@@ -58,8 +58,9 @@ PlatformDebugLibIoPortFound (
)
{
if (!mDebugIoPortChecked) {
- mDebugIoPortFound = PlatformDebugLibIoPortDetect ();
+ mDebugIoPortFound = PlatformDebugLibIoPortDetect ();
mDebugIoPortChecked = TRUE;
}
+
return mDebugIoPortFound;
}
diff --git a/OvmfPkg/Library/PlatformFvbLibNull/PlatformFvbLibNull.c b/OvmfPkg/Library/PlatformFvbLibNull/PlatformFvbLibNull.c
index 8ef7416d3e..89a50d79c3 100644
--- a/OvmfPkg/Library/PlatformFvbLibNull/PlatformFvbLibNull.c
+++ b/OvmfPkg/Library/PlatformFvbLibNull/PlatformFvbLibNull.c
@@ -9,7 +9,6 @@
#include "PiDxe.h"
#include <Library/PlatformFvbLib.h>
-
/**
This function will be called following a call to the
EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL Read function.
@@ -26,16 +25,15 @@
VOID
EFIAPI
PlatformFvbDataRead (
- IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,
- IN EFI_LBA Lba,
- IN UINTN Offset,
- IN UINTN NumBytes,
- IN UINT8 *Buffer
+ IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,
+ IN EFI_LBA Lba,
+ IN UINTN Offset,
+ IN UINTN NumBytes,
+ IN UINT8 *Buffer
)
{
}
-
/**
This function will be called following a call to the
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL Write function.
@@ -50,16 +48,15 @@ PlatformFvbDataRead (
VOID
EFIAPI
PlatformFvbDataWritten (
- IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,
- IN EFI_LBA Lba,
- IN UINTN Offset,
- IN UINTN NumBytes,
- IN UINT8 *Buffer
+ IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,
+ IN EFI_LBA Lba,
+ IN UINTN Offset,
+ IN UINTN NumBytes,
+ IN UINT8 *Buffer
)
{
}
-
/**
This function will be called following a call to the
EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL Erase function.
@@ -74,10 +71,8 @@ PlatformFvbDataWritten (
VOID
EFIAPI
PlatformFvbBlocksErased (
- IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,
- IN VA_LIST List
+ IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,
+ IN VA_LIST List
)
{
}
-
-
diff --git a/OvmfPkg/Library/PxeBcPcdProducerLib/PxeBcPcd.c b/OvmfPkg/Library/PxeBcPcdProducerLib/PxeBcPcd.c
index 7ce236326f..33cad38979 100644
--- a/OvmfPkg/Library/PxeBcPcdProducerLib/PxeBcPcd.c
+++ b/OvmfPkg/Library/PxeBcPcdProducerLib/PxeBcPcd.c
@@ -16,19 +16,29 @@ SetPxeBcPcds (
VOID
)
{
- BOOLEAN FwCfgBool;
- RETURN_STATUS PcdStatus;
+ BOOLEAN FwCfgBool;
+ RETURN_STATUS PcdStatus;
- if (!RETURN_ERROR (QemuFwCfgParseBool ("opt/org.tianocore/IPv4PXESupport",
- &FwCfgBool))) {
+ if (!RETURN_ERROR (
+ QemuFwCfgParseBool (
+ "opt/org.tianocore/IPv4PXESupport",
+ &FwCfgBool
+ )
+ ))
+ {
PcdStatus = PcdSet8S (PcdIPv4PXESupport, FwCfgBool);
if (RETURN_ERROR (PcdStatus)) {
return PcdStatus;
}
}
- if (!RETURN_ERROR (QemuFwCfgParseBool ("opt/org.tianocore/IPv6PXESupport",
- &FwCfgBool))) {
+ if (!RETURN_ERROR (
+ QemuFwCfgParseBool (
+ "opt/org.tianocore/IPv6PXESupport",
+ &FwCfgBool
+ )
+ ))
+ {
PcdStatus = PcdSet8S (PcdIPv6PXESupport, FwCfgBool);
if (RETURN_ERROR (PcdStatus)) {
return PcdStatus;
diff --git a/OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.c b/OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.c
index 25d5494047..37d488e01c 100644
--- a/OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.c
+++ b/OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.c
@@ -28,11 +28,10 @@
// BusNumbers is NULL.
//
struct EXTRA_ROOT_BUS_MAP_STRUCT {
- UINT32 *BusNumbers;
- UINTN Count;
+ UINT32 *BusNumbers;
+ UINTN Count;
};
-
/**
An ORDERED_COLLECTION_USER_COMPARE function that compares root bridge
protocol device paths based on UID.
@@ -51,12 +50,12 @@ STATIC
INTN
EFIAPI
RootBridgePathCompare (
- IN CONST VOID *UserStruct1,
- IN CONST VOID *UserStruct2
+ IN CONST VOID *UserStruct1,
+ IN CONST VOID *UserStruct2
)
{
- CONST ACPI_HID_DEVICE_PATH *Acpi1;
- CONST ACPI_HID_DEVICE_PATH *Acpi2;
+ CONST ACPI_HID_DEVICE_PATH *Acpi1;
+ CONST ACPI_HID_DEVICE_PATH *Acpi2;
Acpi1 = UserStruct1;
Acpi2 = UserStruct2;
@@ -66,7 +65,6 @@ RootBridgePathCompare (
0;
}
-
/**
An ORDERED_COLLECTION_KEY_COMPARE function that compares a root bridge
protocol device path against a UID.
@@ -86,12 +84,12 @@ STATIC
INTN
EFIAPI
RootBridgePathKeyCompare (
- IN CONST VOID *StandaloneKey,
- IN CONST VOID *UserStruct
+ IN CONST VOID *StandaloneKey,
+ IN CONST VOID *UserStruct
)
{
- CONST UINT32 *Uid;
- CONST ACPI_HID_DEVICE_PATH *Acpi;
+ CONST UINT32 *Uid;
+ CONST ACPI_HID_DEVICE_PATH *Acpi;
Uid = StandaloneKey;
Acpi = UserStruct;
@@ -101,7 +99,6 @@ RootBridgePathKeyCompare (
0;
}
-
/**
Create a structure that maps the relative positions of PCI root buses to bus
numbers.
@@ -129,31 +126,37 @@ RootBridgePathKeyCompare (
**/
EFI_STATUS
CreateExtraRootBusMap (
- OUT EXTRA_ROOT_BUS_MAP **ExtraRootBusMap
+ OUT EXTRA_ROOT_BUS_MAP **ExtraRootBusMap
)
{
- EFI_STATUS Status;
- UINTN NumHandles;
- EFI_HANDLE *Handles;
- ORDERED_COLLECTION *Collection;
- EXTRA_ROOT_BUS_MAP *Map;
- UINTN Idx;
- ORDERED_COLLECTION_ENTRY *Entry, *Entry2;
+ EFI_STATUS Status;
+ UINTN NumHandles;
+ EFI_HANDLE *Handles;
+ ORDERED_COLLECTION *Collection;
+ EXTRA_ROOT_BUS_MAP *Map;
+ UINTN Idx;
+ ORDERED_COLLECTION_ENTRY *Entry, *Entry2;
//
// Handles and Collection are temporary / helper variables, while in Map we
// build the return value.
//
- Status = gBS->LocateHandleBuffer (ByProtocol,
- &gEfiPciRootBridgeIoProtocolGuid, NULL /* SearchKey */,
- &NumHandles, &Handles);
- if (EFI_ERROR (Status)) {
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiPciRootBridgeIoProtocolGuid,
+ NULL /* SearchKey */,
+ &NumHandles,
+ &Handles
+ );
+ if (EFI_ERROR (Status)) {
return Status;
}
- Collection = OrderedCollectionInit (RootBridgePathCompare,
- RootBridgePathKeyCompare);
+ Collection = OrderedCollectionInit (
+ RootBridgePathCompare,
+ RootBridgePathKeyCompare
+ );
if (Collection == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto FreeHandles;
@@ -169,10 +172,13 @@ CreateExtraRootBusMap (
// Collect the ACPI device path protocols of the root bridges.
//
for (Idx = 0; Idx < NumHandles; ++Idx) {
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- Status = gBS->HandleProtocol (Handles[Idx], &gEfiDevicePathProtocolGuid,
- (VOID**)&DevicePath);
+ Status = gBS->HandleProtocol (
+ Handles[Idx],
+ &gEfiDevicePathProtocolGuid,
+ (VOID **)&DevicePath
+ );
if (EFI_ERROR (Status)) {
goto FreeMap;
}
@@ -182,14 +188,16 @@ CreateExtraRootBusMap (
// nonzero (ie. the root bridge that the bus number belongs to is "extra",
// not the main one). In that case, link the device path into Collection.
//
- if (DevicePathType (DevicePath) == ACPI_DEVICE_PATH &&
- DevicePathSubType (DevicePath) == ACPI_DP &&
- ((ACPI_HID_DEVICE_PATH *)DevicePath)->HID == EISA_PNP_ID(0x0A03) &&
- ((ACPI_HID_DEVICE_PATH *)DevicePath)->UID > 0) {
+ if ((DevicePathType (DevicePath) == ACPI_DEVICE_PATH) &&
+ (DevicePathSubType (DevicePath) == ACPI_DP) &&
+ (((ACPI_HID_DEVICE_PATH *)DevicePath)->HID == EISA_PNP_ID (0x0A03)) &&
+ (((ACPI_HID_DEVICE_PATH *)DevicePath)->UID > 0))
+ {
Status = OrderedCollectionInsert (Collection, NULL, DevicePath);
if (EFI_ERROR (Status)) {
goto FreeMap;
}
+
++Map->Count;
}
}
@@ -208,24 +216,29 @@ CreateExtraRootBusMap (
//
// Now collect the bus numbers of the extra PCI root buses into Map.
//
- Idx = 0;
+ Idx = 0;
Entry = OrderedCollectionMin (Collection);
while (Idx < Map->Count) {
- ACPI_HID_DEVICE_PATH *Acpi;
+ ACPI_HID_DEVICE_PATH *Acpi;
ASSERT (Entry != NULL);
- Acpi = OrderedCollectionUserStruct (Entry);
+ Acpi = OrderedCollectionUserStruct (Entry);
Map->BusNumbers[Idx] = Acpi->UID;
- DEBUG ((DEBUG_VERBOSE,
+ DEBUG ((
+ DEBUG_VERBOSE,
"%a: extra bus position 0x%Lx maps to bus number (UID) 0x%x\n",
- __FUNCTION__, (UINT64)(Idx + 1), Acpi->UID));
+ __FUNCTION__,
+ (UINT64)(Idx + 1),
+ Acpi->UID
+ ));
++Idx;
Entry = OrderedCollectionNext (Entry);
}
+
ASSERT (Entry == NULL);
*ExtraRootBusMap = Map;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
//
// Fall through in order to release temporaries.
@@ -236,15 +249,18 @@ FreeMap:
if (Map->BusNumbers != NULL) {
FreePool (Map->BusNumbers);
}
+
FreePool (Map);
}
FreeCollection:
for (Entry = OrderedCollectionMin (Collection); Entry != NULL;
- Entry = Entry2) {
+ Entry = Entry2)
+ {
Entry2 = OrderedCollectionNext (Entry);
OrderedCollectionDelete (Collection, Entry, NULL);
}
+
OrderedCollectionUninit (Collection);
FreeHandles:
@@ -253,7 +269,6 @@ FreeHandles:
return Status;
}
-
/**
Release a map created with CreateExtraRootBusMap().
@@ -261,12 +276,13 @@ FreeHandles:
*/
VOID
DestroyExtraRootBusMap (
- IN EXTRA_ROOT_BUS_MAP *ExtraRootBusMap
+ IN EXTRA_ROOT_BUS_MAP *ExtraRootBusMap
)
{
if (ExtraRootBusMap->BusNumbers != NULL) {
FreePool (ExtraRootBusMap->BusNumbers);
}
+
FreePool (ExtraRootBusMap);
}
@@ -291,17 +307,19 @@ DestroyExtraRootBusMap (
**/
EFI_STATUS
MapRootBusPosToBusNr (
- IN CONST EXTRA_ROOT_BUS_MAP *ExtraRootBusMap,
- IN UINT64 RootBusPos,
- OUT UINT32 *RootBusNr
+ IN CONST EXTRA_ROOT_BUS_MAP *ExtraRootBusMap,
+ IN UINT64 RootBusPos,
+ OUT UINT32 *RootBusNr
)
{
if (RootBusPos == 0) {
return EFI_INVALID_PARAMETER;
}
+
if (RootBusPos > ExtraRootBusMap->Count) {
return EFI_NOT_FOUND;
}
+
*RootBusNr = ExtraRootBusMap->BusNumbers[(UINTN)RootBusPos - 1];
return EFI_SUCCESS;
}
diff --git a/OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.h b/OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.h
index 3b79fbdc7f..7c4a338693 100644
--- a/OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.h
+++ b/OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.h
@@ -16,19 +16,19 @@ typedef struct EXTRA_ROOT_BUS_MAP_STRUCT EXTRA_ROOT_BUS_MAP;
EFI_STATUS
CreateExtraRootBusMap (
- OUT EXTRA_ROOT_BUS_MAP **ExtraRootBusMap
+ OUT EXTRA_ROOT_BUS_MAP **ExtraRootBusMap
);
VOID
DestroyExtraRootBusMap (
- IN EXTRA_ROOT_BUS_MAP *ExtraRootBusMap
+ IN EXTRA_ROOT_BUS_MAP *ExtraRootBusMap
);
EFI_STATUS
MapRootBusPosToBusNr (
- IN CONST EXTRA_ROOT_BUS_MAP *ExtraRootBusMap,
- IN UINT64 RootBusPos,
- OUT UINT32 *RootBusNr
+ IN CONST EXTRA_ROOT_BUS_MAP *ExtraRootBusMap,
+ IN UINT64 RootBusPos,
+ OUT UINT32 *RootBusNr
);
#endif
diff --git a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
index ceffb17fa6..b5768285d8 100644
--- a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
+++ b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
@@ -26,21 +26,20 @@
/**
OpenFirmware to UEFI device path translation output buffer size in CHAR16's.
**/
-#define TRANSLATION_OUTPUT_SIZE 0x100
+#define TRANSLATION_OUTPUT_SIZE 0x100
/**
Output buffer size for OpenFirmware to UEFI device path fragment translation,
in CHAR16's, for a sequence of PCI bridges.
**/
-#define BRIDGE_TRANSLATION_OUTPUT_SIZE 0x40
+#define BRIDGE_TRANSLATION_OUTPUT_SIZE 0x40
/**
Numbers of nodes in OpenFirmware device paths that are required and examined.
**/
-#define REQUIRED_PCI_OFW_NODES 2
-#define REQUIRED_MMIO_OFW_NODES 1
-#define EXAMINED_OFW_NODES 6
-
+#define REQUIRED_PCI_OFW_NODES 2
+#define REQUIRED_MMIO_OFW_NODES 1
+#define EXAMINED_OFW_NODES 6
/**
Simple character classification routines, corresponding to POSIX class names
@@ -49,7 +48,7 @@
STATIC
BOOLEAN
IsAlnum (
- IN CHAR8 Chr
+ IN CHAR8 Chr
)
{
return (('0' <= Chr && Chr <= '9') ||
@@ -58,11 +57,10 @@ IsAlnum (
);
}
-
STATIC
BOOLEAN
IsDriverNamePunct (
- IN CHAR8 Chr
+ IN CHAR8 Chr
)
{
return (Chr == ',' || Chr == '.' || Chr == '_' ||
@@ -70,27 +68,24 @@ IsDriverNamePunct (
);
}
-
STATIC
BOOLEAN
IsPrintNotDelim (
- IN CHAR8 Chr
+ IN CHAR8 Chr
)
{
return (32 <= Chr && Chr <= 126 &&
Chr != '/' && Chr != '@' && Chr != ':');
}
-
/**
Utility types and functions.
**/
typedef struct {
- CONST CHAR8 *Ptr; // not necessarily NUL-terminated
- UINTN Len; // number of non-NUL characters
+ CONST CHAR8 *Ptr; // not necessarily NUL-terminated
+ UINTN Len; // number of non-NUL characters
} SUBSTRING;
-
/**
Check if Substring and String have identical contents.
@@ -109,12 +104,12 @@ typedef struct {
STATIC
BOOLEAN
SubstringEq (
- IN SUBSTRING Substring,
- IN CONST CHAR8 *String
+ IN SUBSTRING Substring,
+ IN CONST CHAR8 *String
)
{
- UINTN Pos;
- CONST CHAR8 *Chr;
+ UINTN Pos;
+ CONST CHAR8 *Chr;
Pos = 0;
Chr = String;
@@ -127,7 +122,6 @@ SubstringEq (
return (BOOLEAN)(Pos == Substring.Len && *Chr == '\0');
}
-
/**
Parse a comma-separated list of hexadecimal integers into the elements of an
@@ -175,38 +169,41 @@ ParseUnitAddressHexList (
IN OUT UINTN *NumResults
)
{
- UINTN Entry; // number of entry currently being parsed
- UINT64 EntryVal; // value being constructed for current entry
- CHAR8 PrevChr; // UnitAddress character previously checked
- UINTN Pos; // current position within UnitAddress
- RETURN_STATUS Status;
+ UINTN Entry; // number of entry currently being parsed
+ UINT64 EntryVal; // value being constructed for current entry
+ CHAR8 PrevChr; // UnitAddress character previously checked
+ UINTN Pos; // current position within UnitAddress
+ RETURN_STATUS Status;
Entry = 0;
EntryVal = 0;
PrevChr = ',';
for (Pos = 0; Pos < UnitAddress.Len; ++Pos) {
- CHAR8 Chr;
- INT8 Val;
+ CHAR8 Chr;
+ INT8 Val;
Chr = UnitAddress.Ptr[Pos];
Val = ('a' <= Chr && Chr <= 'f') ? (Chr - 'a' + 10) :
('A' <= Chr && Chr <= 'F') ? (Chr - 'A' + 10) :
- ('0' <= Chr && Chr <= '9') ? (Chr - '0' ) :
+ ('0' <= Chr && Chr <= '9') ? (Chr - '0') :
-1;
if (Val >= 0) {
if (EntryVal > 0xFFFFFFFFFFFFFFFull) {
return RETURN_INVALID_PARAMETER;
}
+
EntryVal = LShiftU64 (EntryVal, 4) | Val;
} else if (Chr == ',') {
if (PrevChr == ',') {
return RETURN_INVALID_PARAMETER;
}
+
if (Entry < *NumResults) {
Result[Entry] = EntryVal;
}
+
++Entry;
EntryVal = 0;
} else {
@@ -219,41 +216,40 @@ ParseUnitAddressHexList (
if (PrevChr == ',') {
return RETURN_INVALID_PARAMETER;
}
+
if (Entry < *NumResults) {
Result[Entry] = EntryVal;
- Status = RETURN_SUCCESS;
+ Status = RETURN_SUCCESS;
} else {
Status = RETURN_BUFFER_TOO_SMALL;
}
+
++Entry;
*NumResults = Entry;
return Status;
}
-
/**
A simple array of Boot Option ID's.
**/
typedef struct {
- UINT16 *Data;
- UINTN Allocated;
- UINTN Produced;
+ UINT16 *Data;
+ UINTN Allocated;
+ UINTN Produced;
} BOOT_ORDER;
-
/**
Array element tracking an enumerated boot option that has the
LOAD_OPTION_ACTIVE attribute.
**/
typedef struct {
- CONST EFI_BOOT_MANAGER_LOAD_OPTION *BootOption; // reference only, no
- // ownership
- BOOLEAN Appended; // has been added to a
- // BOOT_ORDER?
+ CONST EFI_BOOT_MANAGER_LOAD_OPTION *BootOption; // reference only, no
+ // ownership
+ BOOLEAN Appended; // has been added to a
+ // BOOT_ORDER?
} ACTIVE_OPTION;
-
/**
Append an active boot option to BootOrder, reallocating the latter if needed.
@@ -273,35 +269,35 @@ typedef struct {
STATIC
RETURN_STATUS
BootOrderAppend (
- IN OUT BOOT_ORDER *BootOrder,
- IN OUT ACTIVE_OPTION *ActiveOption
+ IN OUT BOOT_ORDER *BootOrder,
+ IN OUT ACTIVE_OPTION *ActiveOption
)
{
if (BootOrder->Produced == BootOrder->Allocated) {
- UINTN AllocatedNew;
- UINT16 *DataNew;
+ UINTN AllocatedNew;
+ UINT16 *DataNew;
ASSERT (BootOrder->Allocated > 0);
AllocatedNew = BootOrder->Allocated * 2;
- DataNew = ReallocatePool (
- BootOrder->Allocated * sizeof (*BootOrder->Data),
- AllocatedNew * sizeof (*DataNew),
- BootOrder->Data
- );
+ DataNew = ReallocatePool (
+ BootOrder->Allocated * sizeof (*BootOrder->Data),
+ AllocatedNew * sizeof (*DataNew),
+ BootOrder->Data
+ );
if (DataNew == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
BootOrder->Allocated = AllocatedNew;
BootOrder->Data = DataNew;
}
BootOrder->Data[BootOrder->Produced++] =
- (UINT16) ActiveOption->BootOption->OptionNumber;
+ (UINT16)ActiveOption->BootOption->OptionNumber;
ActiveOption->Appended = TRUE;
return RETURN_SUCCESS;
}
-
/**
Create an array of ACTIVE_OPTION elements for a boot option array.
@@ -330,14 +326,14 @@ BootOrderAppend (
STATIC
RETURN_STATUS
CollectActiveOptions (
- IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions,
- IN UINTN BootOptionCount,
- OUT ACTIVE_OPTION **ActiveOption,
- OUT UINTN *Count
+ IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions,
+ IN UINTN BootOptionCount,
+ OUT ACTIVE_OPTION **ActiveOption,
+ OUT UINTN *Count
)
{
- UINTN Index;
- UINTN ScanMode;
+ UINTN Index;
+ UINTN ScanMode;
*ActiveOption = NULL;
@@ -354,6 +350,7 @@ CollectActiveOptions (
(*ActiveOption)[*Count].BootOption = &BootOptions[Index];
(*ActiveOption)[*Count].Appended = FALSE;
}
+
++*Count;
}
}
@@ -362,26 +359,26 @@ CollectActiveOptions (
if (*Count == 0) {
return RETURN_NOT_FOUND;
}
+
*ActiveOption = AllocatePool (*Count * sizeof **ActiveOption);
if (*ActiveOption == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
}
}
+
return RETURN_SUCCESS;
}
-
/**
OpenFirmware device path node
**/
typedef struct {
- SUBSTRING DriverName;
- SUBSTRING UnitAddress;
- SUBSTRING DeviceArguments;
+ SUBSTRING DriverName;
+ SUBSTRING UnitAddress;
+ SUBSTRING DeviceArguments;
} OFW_NODE;
-
/**
Parse an OpenFirmware device path node into the caller-allocated OFW_NODE
@@ -430,24 +427,24 @@ typedef struct {
STATIC
RETURN_STATUS
ParseOfwNode (
- IN OUT CONST CHAR8 **Ptr,
- OUT OFW_NODE *OfwNode,
- OUT BOOLEAN *IsFinal
+ IN OUT CONST CHAR8 **Ptr,
+ OUT OFW_NODE *OfwNode,
+ OUT BOOLEAN *IsFinal
)
{
//
// A leading slash is expected. End of string is tolerated.
//
switch (**Ptr) {
- case '\0':
- return RETURN_NOT_FOUND;
+ case '\0':
+ return RETURN_NOT_FOUND;
- case '/':
- ++*Ptr;
- break;
+ case '/':
+ ++*Ptr;
+ break;
- default:
- return RETURN_INVALID_PARAMETER;
+ default:
+ return RETURN_INVALID_PARAMETER;
}
//
@@ -457,22 +454,23 @@ ParseOfwNode (
OfwNode->DriverName.Len = 0;
while (OfwNode->DriverName.Len < 32 &&
(IsAlnum (**Ptr) || IsDriverNamePunct (**Ptr))
- ) {
+ )
+ {
++*Ptr;
++OfwNode->DriverName.Len;
}
- if (OfwNode->DriverName.Len == 0 || OfwNode->DriverName.Len == 32) {
+ if ((OfwNode->DriverName.Len == 0) || (OfwNode->DriverName.Len == 32)) {
return RETURN_INVALID_PARAMETER;
}
-
//
// unit-address
//
if (**Ptr != '@') {
return RETURN_INVALID_PARAMETER;
}
+
++*Ptr;
OfwNode->UnitAddress.Ptr = *Ptr;
@@ -486,7 +484,6 @@ ParseOfwNode (
return RETURN_INVALID_PARAMETER;
}
-
//
// device-arguments, may be omitted
//
@@ -503,43 +500,43 @@ ParseOfwNode (
if (OfwNode->DeviceArguments.Len == 0) {
return RETURN_INVALID_PARAMETER;
}
- }
- else {
+ } else {
OfwNode->DeviceArguments.Ptr = NULL;
}
switch (**Ptr) {
- case '\n':
- ++*Ptr;
+ case '\n':
+ ++*Ptr;
//
// fall through
//
- case '\0':
- *IsFinal = TRUE;
- break;
+ case '\0':
+ *IsFinal = TRUE;
+ break;
- case '/':
- *IsFinal = FALSE;
- break;
+ case '/':
+ *IsFinal = FALSE;
+ break;
- default:
- return RETURN_INVALID_PARAMETER;
+ default:
+ return RETURN_INVALID_PARAMETER;
}
DEBUG ((
DEBUG_VERBOSE,
"%a: DriverName=\"%.*a\" UnitAddress=\"%.*a\" DeviceArguments=\"%.*a\"\n",
__FUNCTION__,
- OfwNode->DriverName.Len, OfwNode->DriverName.Ptr,
- OfwNode->UnitAddress.Len, OfwNode->UnitAddress.Ptr,
+ OfwNode->DriverName.Len,
+ OfwNode->DriverName.Ptr,
+ OfwNode->UnitAddress.Len,
+ OfwNode->UnitAddress.Ptr,
OfwNode->DeviceArguments.Len,
OfwNode->DeviceArguments.Ptr == NULL ? "" : OfwNode->DeviceArguments.Ptr
));
return RETURN_SUCCESS;
}
-
/**
Translate a PCI-like array of OpenFirmware device nodes to a UEFI device path
@@ -584,21 +581,21 @@ ParseOfwNode (
STATIC
RETURN_STATUS
TranslatePciOfwNodes (
- IN CONST OFW_NODE *OfwNode,
- IN UINTN NumNodes,
- IN CONST EXTRA_ROOT_BUS_MAP *ExtraPciRoots,
- OUT CHAR16 *Translated,
- IN OUT UINTN *TranslatedSize
+ IN CONST OFW_NODE *OfwNode,
+ IN UINTN NumNodes,
+ IN CONST EXTRA_ROOT_BUS_MAP *ExtraPciRoots,
+ OUT CHAR16 *Translated,
+ IN OUT UINTN *TranslatedSize
)
{
- UINT32 PciRoot;
- CHAR8 *Comma;
- UINTN FirstNonBridge;
- CHAR16 Bridges[BRIDGE_TRANSLATION_OUTPUT_SIZE];
- UINTN BridgesLen;
- UINT64 PciDevFun[2];
- UINTN NumEntries;
- UINTN Written;
+ UINT32 PciRoot;
+ CHAR8 *Comma;
+ UINTN FirstNonBridge;
+ CHAR16 Bridges[BRIDGE_TRANSLATION_OUTPUT_SIZE];
+ UINTN BridgesLen;
+ UINT64 PciDevFun[2];
+ UINTN NumEntries;
+ UINTN Written;
//
// Resolve the PCI root bus number.
@@ -613,18 +610,22 @@ TranslatePciOfwNodes (
// ^
// root bus serial number (not PCI bus number)
//
- if (NumNodes < REQUIRED_PCI_OFW_NODES ||
+ if ((NumNodes < REQUIRED_PCI_OFW_NODES) ||
!SubstringEq (OfwNode[0].DriverName, "pci")
- ) {
+ )
+ {
return RETURN_UNSUPPORTED;
}
PciRoot = 0;
- Comma = ScanMem8 (OfwNode[0].UnitAddress.Ptr, OfwNode[0].UnitAddress.Len,
- ',');
+ Comma = ScanMem8 (
+ OfwNode[0].UnitAddress.Ptr,
+ OfwNode[0].UnitAddress.Len,
+ ','
+ );
if (Comma != NULL) {
- SUBSTRING PciRootSerialSubString;
- UINT64 PciRootSerial;
+ SUBSTRING PciRootSerialSubString;
+ UINT64 PciRootSerial;
//
// Parse the root bus serial number from the unit address after the comma.
@@ -634,16 +635,28 @@ TranslatePciOfwNodes (
(PciRootSerialSubString.Ptr -
OfwNode[0].UnitAddress.Ptr);
NumEntries = 1;
- if (RETURN_ERROR (ParseUnitAddressHexList (PciRootSerialSubString,
- &PciRootSerial, &NumEntries))) {
+ if (RETURN_ERROR (
+ ParseUnitAddressHexList (
+ PciRootSerialSubString,
+ &PciRootSerial,
+ &NumEntries
+ )
+ ))
+ {
return RETURN_UNSUPPORTED;
}
//
// Map the extra root bus's serial number to its actual bus number.
//
- if (EFI_ERROR (MapRootBusPosToBusNr (ExtraPciRoots, PciRootSerial,
- &PciRoot))) {
+ if (EFI_ERROR (
+ MapRootBusPosToBusNr (
+ ExtraPciRoots,
+ PciRootSerial,
+ &PciRoot
+ )
+ ))
+ {
return RETURN_PROTOCOL_ERROR;
}
}
@@ -660,26 +673,35 @@ TranslatePciOfwNodes (
// Pci(0x1E,0x0)
//
FirstNonBridge = 1;
- Bridges[0] = L'\0';
- BridgesLen = 0;
+ Bridges[0] = L'\0';
+ BridgesLen = 0;
do {
- UINT64 BridgeDevFun[2];
- UINTN BridgesFreeBytes;
+ UINT64 BridgeDevFun[2];
+ UINTN BridgesFreeBytes;
if (!SubstringEq (OfwNode[FirstNonBridge].DriverName, "pci-bridge")) {
break;
}
BridgeDevFun[1] = 0;
- NumEntries = sizeof BridgeDevFun / sizeof BridgeDevFun[0];
- if (ParseUnitAddressHexList (OfwNode[FirstNonBridge].UnitAddress,
- BridgeDevFun, &NumEntries) != RETURN_SUCCESS) {
+ NumEntries = sizeof BridgeDevFun / sizeof BridgeDevFun[0];
+ if (ParseUnitAddressHexList (
+ OfwNode[FirstNonBridge].UnitAddress,
+ BridgeDevFun,
+ &NumEntries
+ ) != RETURN_SUCCESS)
+ {
return RETURN_UNSUPPORTED;
}
BridgesFreeBytes = sizeof Bridges - BridgesLen * sizeof Bridges[0];
- Written = UnicodeSPrintAsciiFormat (Bridges + BridgesLen, BridgesFreeBytes,
- "/Pci(0x%Lx,0x%Lx)", BridgeDevFun[0], BridgeDevFun[1]);
+ Written = UnicodeSPrintAsciiFormat (
+ Bridges + BridgesLen,
+ BridgesFreeBytes,
+ "/Pci(0x%Lx,0x%Lx)",
+ BridgeDevFun[0],
+ BridgeDevFun[1]
+ );
BridgesLen += Written;
//
@@ -701,21 +723,23 @@ TranslatePciOfwNodes (
// Parse the OFW nodes starting with the first non-bridge node.
//
PciDevFun[1] = 0;
- NumEntries = ARRAY_SIZE (PciDevFun);
+ NumEntries = ARRAY_SIZE (PciDevFun);
if (ParseUnitAddressHexList (
OfwNode[FirstNonBridge].UnitAddress,
PciDevFun,
&NumEntries
) != RETURN_SUCCESS
- ) {
+ )
+ {
return RETURN_UNSUPPORTED;
}
- if (NumNodes >= FirstNonBridge + 3 &&
+ if ((NumNodes >= FirstNonBridge + 3) &&
SubstringEq (OfwNode[FirstNonBridge + 0].DriverName, "ide") &&
SubstringEq (OfwNode[FirstNonBridge + 1].DriverName, "drive") &&
SubstringEq (OfwNode[FirstNonBridge + 2].DriverName, "disk")
- ) {
+ )
+ {
//
// OpenFirmware device path (IDE disk, IDE CD-ROM):
//
@@ -732,42 +756,44 @@ TranslatePciOfwNodes (
// ^
// fixed LUN
//
- UINT64 Secondary;
- UINT64 Slave;
+ UINT64 Secondary;
+ UINT64 Slave;
NumEntries = 1;
- if (ParseUnitAddressHexList (
- OfwNode[FirstNonBridge + 1].UnitAddress,
- &Secondary,
- &NumEntries
- ) != RETURN_SUCCESS ||
- Secondary > 1 ||
- ParseUnitAddressHexList (
- OfwNode[FirstNonBridge + 2].UnitAddress,
- &Slave,
- &NumEntries // reuse after previous single-element call
- ) != RETURN_SUCCESS ||
- Slave > 1
- ) {
+ if ((ParseUnitAddressHexList (
+ OfwNode[FirstNonBridge + 1].UnitAddress,
+ &Secondary,
+ &NumEntries
+ ) != RETURN_SUCCESS) ||
+ (Secondary > 1) ||
+ (ParseUnitAddressHexList (
+ OfwNode[FirstNonBridge + 2].UnitAddress,
+ &Slave,
+ &NumEntries // reuse after previous single-element call
+ ) != RETURN_SUCCESS) ||
+ (Slave > 1)
+ )
+ {
return RETURN_UNSUPPORTED;
}
Written = UnicodeSPrintAsciiFormat (
- Translated,
- *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
- "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)/Ata(%a,%a,0x0)",
- PciRoot,
- Bridges,
- PciDevFun[0],
- PciDevFun[1],
- Secondary ? "Secondary" : "Primary",
- Slave ? "Slave" : "Master"
- );
- } else if (NumNodes >= FirstNonBridge + 3 &&
- SubstringEq (OfwNode[FirstNonBridge + 0].DriverName, "pci8086,2922") &&
- SubstringEq (OfwNode[FirstNonBridge + 1].DriverName, "drive") &&
- SubstringEq (OfwNode[FirstNonBridge + 2].DriverName, "disk")
- ) {
+ Translated,
+ *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
+ "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)/Ata(%a,%a,0x0)",
+ PciRoot,
+ Bridges,
+ PciDevFun[0],
+ PciDevFun[1],
+ Secondary ? "Secondary" : "Primary",
+ Slave ? "Slave" : "Master"
+ );
+ } else if ((NumNodes >= FirstNonBridge + 3) &&
+ SubstringEq (OfwNode[FirstNonBridge + 0].DriverName, "pci8086,2922") &&
+ SubstringEq (OfwNode[FirstNonBridge + 1].DriverName, "drive") &&
+ SubstringEq (OfwNode[FirstNonBridge + 2].DriverName, "disk")
+ )
+ {
//
// OpenFirmware device path (Q35 SATA disk and CD-ROM):
//
@@ -787,30 +813,36 @@ TranslatePciOfwNodes (
// | always 0xFFFF on Q35
// channel (port) number
//
- UINT64 Channel;
+ UINT64 Channel;
NumEntries = 1;
- if (RETURN_ERROR (ParseUnitAddressHexList (
- OfwNode[FirstNonBridge + 1].UnitAddress, &Channel,
- &NumEntries))) {
+ if (RETURN_ERROR (
+ ParseUnitAddressHexList (
+ OfwNode[FirstNonBridge + 1].UnitAddress,
+ &Channel,
+ &NumEntries
+ )
+ ))
+ {
return RETURN_UNSUPPORTED;
}
Written = UnicodeSPrintAsciiFormat (
- Translated,
- *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
- "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)/Sata(0x%Lx,0xFFFF,0x0)",
- PciRoot,
- Bridges,
- PciDevFun[0],
- PciDevFun[1],
- Channel
- );
- } else if (NumNodes >= FirstNonBridge + 3 &&
+ Translated,
+ *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
+ "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)/Sata(0x%Lx,0xFFFF,0x0)",
+ PciRoot,
+ Bridges,
+ PciDevFun[0],
+ PciDevFun[1],
+ Channel
+ );
+ } else if ((NumNodes >= FirstNonBridge + 3) &&
SubstringEq (OfwNode[FirstNonBridge + 0].DriverName, "isa") &&
SubstringEq (OfwNode[FirstNonBridge + 1].DriverName, "fdc") &&
SubstringEq (OfwNode[FirstNonBridge + 2].DriverName, "floppy")
- ) {
+ )
+ {
//
// OpenFirmware device path (floppy disk):
//
@@ -827,33 +859,35 @@ TranslatePciOfwNodes (
// ^
// ACPI UID
//
- UINT64 AcpiUid;
+ UINT64 AcpiUid;
NumEntries = 1;
- if (ParseUnitAddressHexList (
- OfwNode[FirstNonBridge + 2].UnitAddress,
- &AcpiUid,
- &NumEntries
- ) != RETURN_SUCCESS ||
- AcpiUid > 1
- ) {
+ if ((ParseUnitAddressHexList (
+ OfwNode[FirstNonBridge + 2].UnitAddress,
+ &AcpiUid,
+ &NumEntries
+ ) != RETURN_SUCCESS) ||
+ (AcpiUid > 1)
+ )
+ {
return RETURN_UNSUPPORTED;
}
Written = UnicodeSPrintAsciiFormat (
- Translated,
- *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
- "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)/Floppy(0x%Lx)",
- PciRoot,
- Bridges,
- PciDevFun[0],
- PciDevFun[1],
- AcpiUid
- );
- } else if (NumNodes >= FirstNonBridge + 2 &&
+ Translated,
+ *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
+ "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)/Floppy(0x%Lx)",
+ PciRoot,
+ Bridges,
+ PciDevFun[0],
+ PciDevFun[1],
+ AcpiUid
+ );
+ } else if ((NumNodes >= FirstNonBridge + 2) &&
SubstringEq (OfwNode[FirstNonBridge + 0].DriverName, "scsi") &&
SubstringEq (OfwNode[FirstNonBridge + 1].DriverName, "disk")
- ) {
+ )
+ {
//
// OpenFirmware device path (virtio-blk disk):
//
@@ -870,19 +904,20 @@ TranslatePciOfwNodes (
// PciRoot(0x0)/Pci(0x6,0x3) -- if PCI function is present and nonzero
//
Written = UnicodeSPrintAsciiFormat (
- Translated,
- *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
- "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)",
- PciRoot,
- Bridges,
- PciDevFun[0],
- PciDevFun[1]
- );
- } else if (NumNodes >= FirstNonBridge + 3 &&
+ Translated,
+ *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
+ "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)",
+ PciRoot,
+ Bridges,
+ PciDevFun[0],
+ PciDevFun[1]
+ );
+ } else if ((NumNodes >= FirstNonBridge + 3) &&
SubstringEq (OfwNode[FirstNonBridge + 0].DriverName, "scsi") &&
SubstringEq (OfwNode[FirstNonBridge + 1].DriverName, "channel") &&
SubstringEq (OfwNode[FirstNonBridge + 2].DriverName, "disk")
- ) {
+ )
+ {
//
// OpenFirmware device path (virtio-scsi disk):
//
@@ -901,34 +936,36 @@ TranslatePciOfwNodes (
// PciRoot(0x0)/Pci(0x7,0x3)/Scsi(0x2,0x3)
// -- if PCI function is present and nonzero
//
- UINT64 TargetLun[2];
+ UINT64 TargetLun[2];
TargetLun[1] = 0;
- NumEntries = ARRAY_SIZE (TargetLun);
+ NumEntries = ARRAY_SIZE (TargetLun);
if (ParseUnitAddressHexList (
OfwNode[FirstNonBridge + 2].UnitAddress,
TargetLun,
&NumEntries
) != RETURN_SUCCESS
- ) {
+ )
+ {
return RETURN_UNSUPPORTED;
}
Written = UnicodeSPrintAsciiFormat (
- Translated,
- *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
- "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)/Scsi(0x%Lx,0x%Lx)",
- PciRoot,
- Bridges,
- PciDevFun[0],
- PciDevFun[1],
- TargetLun[0],
- TargetLun[1]
- );
- } else if (NumNodes >= FirstNonBridge + 2 &&
- SubstringEq (OfwNode[FirstNonBridge + 0].DriverName, "pci8086,5845") &&
- SubstringEq (OfwNode[FirstNonBridge + 1].DriverName, "namespace")
- ) {
+ Translated,
+ *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
+ "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)/Scsi(0x%Lx,0x%Lx)",
+ PciRoot,
+ Bridges,
+ PciDevFun[0],
+ PciDevFun[1],
+ TargetLun[0],
+ TargetLun[1]
+ );
+ } else if ((NumNodes >= FirstNonBridge + 2) &&
+ SubstringEq (OfwNode[FirstNonBridge + 0].DriverName, "pci8086,5845") &&
+ SubstringEq (OfwNode[FirstNonBridge + 1].DriverName, "namespace")
+ )
+ {
//
// OpenFirmware device path (NVMe device):
//
@@ -948,41 +985,49 @@ TranslatePciOfwNodes (
// | in address order
// namespace ID
//
- UINT64 Namespace[2];
- UINTN RequiredEntries;
- UINT8 *Eui64;
+ UINT64 Namespace[2];
+ UINTN RequiredEntries;
+ UINT8 *Eui64;
RequiredEntries = ARRAY_SIZE (Namespace);
- NumEntries = RequiredEntries;
- if (ParseUnitAddressHexList (
- OfwNode[FirstNonBridge + 1].UnitAddress,
- Namespace,
- &NumEntries
- ) != RETURN_SUCCESS ||
- NumEntries != RequiredEntries ||
- Namespace[0] == 0 ||
- Namespace[0] >= MAX_UINT32
- ) {
+ NumEntries = RequiredEntries;
+ if ((ParseUnitAddressHexList (
+ OfwNode[FirstNonBridge + 1].UnitAddress,
+ Namespace,
+ &NumEntries
+ ) != RETURN_SUCCESS) ||
+ (NumEntries != RequiredEntries) ||
+ (Namespace[0] == 0) ||
+ (Namespace[0] >= MAX_UINT32)
+ )
+ {
return RETURN_UNSUPPORTED;
}
- Eui64 = (UINT8 *)&Namespace[1];
+ Eui64 = (UINT8 *)&Namespace[1];
Written = UnicodeSPrintAsciiFormat (
- Translated,
- *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
- "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)/"
- "NVMe(0x%Lx,%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x)",
- PciRoot,
- Bridges,
- PciDevFun[0],
- PciDevFun[1],
- Namespace[0],
- Eui64[7], Eui64[6], Eui64[5], Eui64[4],
- Eui64[3], Eui64[2], Eui64[1], Eui64[0]
- );
- } else if (NumNodes >= FirstNonBridge + 2 &&
+ Translated,
+ *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
+ "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)/"
+ "NVMe(0x%Lx,%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x)",
+ PciRoot,
+ Bridges,
+ PciDevFun[0],
+ PciDevFun[1],
+ Namespace[0],
+ Eui64[7],
+ Eui64[6],
+ Eui64[5],
+ Eui64[4],
+ Eui64[3],
+ Eui64[2],
+ Eui64[1],
+ Eui64[0]
+ );
+ } else if ((NumNodes >= FirstNonBridge + 2) &&
SubstringEq (OfwNode[FirstNonBridge + 0].DriverName, "usb") &&
- SubstringEq (OfwNode[FirstNonBridge + 1].DriverName, "storage")) {
+ SubstringEq (OfwNode[FirstNonBridge + 1].DriverName, "storage"))
+ {
//
// OpenFirmware device path (usb-storage device in XHCI port):
//
@@ -1001,16 +1046,16 @@ TranslatePciOfwNodes (
// | XHCI port number in 0-based notation
// 0x0 if PCI function is 0, or absent from OFW
//
- RETURN_STATUS ParseStatus;
- UINT64 OneBasedXhciPort;
+ RETURN_STATUS ParseStatus;
+ UINT64 OneBasedXhciPort;
- NumEntries = 1;
+ NumEntries = 1;
ParseStatus = ParseUnitAddressHexList (
OfwNode[FirstNonBridge + 1].UnitAddress,
&OneBasedXhciPort,
&NumEntries
);
- if (RETURN_ERROR (ParseStatus) || OneBasedXhciPort == 0) {
+ if (RETURN_ERROR (ParseStatus) || (OneBasedXhciPort == 0)) {
return RETURN_UNSUPPORTED;
}
@@ -1039,14 +1084,14 @@ TranslatePciOfwNodes (
// PciRoot(0x0)/Pci(0x3,0x2)
//
Written = UnicodeSPrintAsciiFormat (
- Translated,
- *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
- "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)",
- PciRoot,
- Bridges,
- PciDevFun[0],
- PciDevFun[1]
- );
+ Translated,
+ *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
+ "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)",
+ PciRoot,
+ Bridges,
+ PciDevFun[0],
+ PciDevFun[1]
+ );
}
//
@@ -1062,17 +1107,15 @@ TranslatePciOfwNodes (
return RETURN_BUFFER_TOO_SMALL;
}
-
//
// A type providing easy raw access to the base address of a virtio-mmio
// transport.
//
typedef union {
- UINT64 Uint64;
- UINT8 Raw[8];
+ UINT64 Uint64;
+ UINT8 Raw[8];
} VIRTIO_MMIO_BASE_ADDRESS;
-
/**
Translate an MMIO-like array of OpenFirmware device nodes to a UEFI device
@@ -1108,43 +1151,56 @@ typedef union {
STATIC
RETURN_STATUS
TranslateMmioOfwNodes (
- IN CONST OFW_NODE *OfwNode,
- IN UINTN NumNodes,
- OUT CHAR16 *Translated,
- IN OUT UINTN *TranslatedSize
+ IN CONST OFW_NODE *OfwNode,
+ IN UINTN NumNodes,
+ OUT CHAR16 *Translated,
+ IN OUT UINTN *TranslatedSize
)
{
- VIRTIO_MMIO_BASE_ADDRESS VirtioMmioBase;
- CHAR16 VenHwString[60 + 1];
- UINTN NumEntries;
- UINTN Written;
+ VIRTIO_MMIO_BASE_ADDRESS VirtioMmioBase;
+ CHAR16 VenHwString[60 + 1];
+ UINTN NumEntries;
+ UINTN Written;
//
// Get the base address of the virtio-mmio transport.
//
- if (NumNodes < REQUIRED_MMIO_OFW_NODES ||
+ if ((NumNodes < REQUIRED_MMIO_OFW_NODES) ||
!SubstringEq (OfwNode[0].DriverName, "virtio-mmio")
- ) {
+ )
+ {
return RETURN_UNSUPPORTED;
}
+
NumEntries = 1;
if (ParseUnitAddressHexList (
OfwNode[0].UnitAddress,
&VirtioMmioBase.Uint64,
&NumEntries
) != RETURN_SUCCESS
- ) {
+ )
+ {
return RETURN_UNSUPPORTED;
}
- UnicodeSPrintAsciiFormat (VenHwString, sizeof VenHwString,
- "VenHw(%g,%02X%02X%02X%02X%02X%02X%02X%02X)", &gVirtioMmioTransportGuid,
- VirtioMmioBase.Raw[0], VirtioMmioBase.Raw[1], VirtioMmioBase.Raw[2],
- VirtioMmioBase.Raw[3], VirtioMmioBase.Raw[4], VirtioMmioBase.Raw[5],
- VirtioMmioBase.Raw[6], VirtioMmioBase.Raw[7]);
-
- if (NumNodes >= 2 &&
- SubstringEq (OfwNode[1].DriverName, "disk")) {
+ UnicodeSPrintAsciiFormat (
+ VenHwString,
+ sizeof VenHwString,
+ "VenHw(%g,%02X%02X%02X%02X%02X%02X%02X%02X)",
+ &gVirtioMmioTransportGuid,
+ VirtioMmioBase.Raw[0],
+ VirtioMmioBase.Raw[1],
+ VirtioMmioBase.Raw[2],
+ VirtioMmioBase.Raw[3],
+ VirtioMmioBase.Raw[4],
+ VirtioMmioBase.Raw[5],
+ VirtioMmioBase.Raw[6],
+ VirtioMmioBase.Raw[7]
+ );
+
+ if ((NumNodes >= 2) &&
+ SubstringEq (OfwNode[1].DriverName, "disk"))
+ {
//
// OpenFirmware device path (virtio-blk disk):
//
@@ -1163,9 +1219,10 @@ TranslateMmioOfwNodes (
"%s",
VenHwString
);
- } else if (NumNodes >= 3 &&
+ } else if ((NumNodes >= 3) &&
SubstringEq (OfwNode[1].DriverName, "channel") &&
- SubstringEq (OfwNode[2].DriverName, "disk")) {
+ SubstringEq (OfwNode[2].DriverName, "disk"))
+ {
//
// OpenFirmware device path (virtio-scsi disk):
//
@@ -1180,16 +1237,17 @@ TranslateMmioOfwNodes (
//
// <VenHwString>/Scsi(0x2,0x3)
//
- UINT64 TargetLun[2];
+ UINT64 TargetLun[2];
TargetLun[1] = 0;
- NumEntries = ARRAY_SIZE (TargetLun);
+ NumEntries = ARRAY_SIZE (TargetLun);
if (ParseUnitAddressHexList (
OfwNode[2].UnitAddress,
TargetLun,
&NumEntries
) != RETURN_SUCCESS
- ) {
+ )
+ {
return RETURN_UNSUPPORTED;
}
@@ -1201,8 +1259,9 @@ TranslateMmioOfwNodes (
TargetLun[0],
TargetLun[1]
);
- } else if (NumNodes >= 2 &&
- SubstringEq (OfwNode[1].DriverName, "ethernet-phy")) {
+ } else if ((NumNodes >= 2) &&
+ SubstringEq (OfwNode[1].DriverName, "ethernet-phy"))
+ {
//
// OpenFirmware device path (virtio-net NIC):
//
@@ -1238,7 +1297,6 @@ TranslateMmioOfwNodes (
return RETURN_BUFFER_TOO_SMALL;
}
-
/**
Translate an array of OpenFirmware device nodes to a UEFI device path
@@ -1283,26 +1341,38 @@ TranslateMmioOfwNodes (
STATIC
RETURN_STATUS
TranslateOfwNodes (
- IN CONST OFW_NODE *OfwNode,
- IN UINTN NumNodes,
- IN CONST EXTRA_ROOT_BUS_MAP *ExtraPciRoots,
- OUT CHAR16 *Translated,
- IN OUT UINTN *TranslatedSize
+ IN CONST OFW_NODE *OfwNode,
+ IN UINTN NumNodes,
+ IN CONST EXTRA_ROOT_BUS_MAP *ExtraPciRoots,
+ OUT CHAR16 *Translated,
+ IN OUT UINTN *TranslatedSize
)
{
- RETURN_STATUS Status;
+ RETURN_STATUS Status;
Status = RETURN_UNSUPPORTED;
if (FeaturePcdGet (PcdQemuBootOrderPciTranslation)) {
- Status = TranslatePciOfwNodes (OfwNode, NumNodes, ExtraPciRoots,
- Translated, TranslatedSize);
+ Status = TranslatePciOfwNodes (
+ OfwNode,
+ NumNodes,
+ ExtraPciRoots,
+ Translated,
+ TranslatedSize
+ );
}
- if (Status == RETURN_UNSUPPORTED &&
- FeaturePcdGet (PcdQemuBootOrderMmioTranslation)) {
- Status = TranslateMmioOfwNodes (OfwNode, NumNodes, Translated,
- TranslatedSize);
+
+ if ((Status == RETURN_UNSUPPORTED) &&
+ FeaturePcdGet (PcdQemuBootOrderMmioTranslation))
+ {
+ Status = TranslateMmioOfwNodes (
+ OfwNode,
+ NumNodes,
+ Translated,
+ TranslatedSize
+ );
}
+
return Status;
}
@@ -1368,22 +1438,22 @@ TranslateOfwNodes (
STATIC
RETURN_STATUS
TranslateOfwPath (
- IN OUT CONST CHAR8 **Ptr,
- IN CONST EXTRA_ROOT_BUS_MAP *ExtraPciRoots,
- OUT CHAR16 *Translated,
- IN OUT UINTN *TranslatedSize
+ IN OUT CONST CHAR8 **Ptr,
+ IN CONST EXTRA_ROOT_BUS_MAP *ExtraPciRoots,
+ OUT CHAR16 *Translated,
+ IN OUT UINTN *TranslatedSize
)
{
- UINTN NumNodes;
- RETURN_STATUS Status;
- OFW_NODE Node[EXAMINED_OFW_NODES];
- BOOLEAN IsFinal;
- OFW_NODE Skip;
+ UINTN NumNodes;
+ RETURN_STATUS Status;
+ OFW_NODE Node[EXAMINED_OFW_NODES];
+ BOOLEAN IsFinal;
+ OFW_NODE Skip;
- IsFinal = FALSE;
+ IsFinal = FALSE;
NumNodes = 0;
if (AsciiStrCmp (*Ptr, "HALT") == 0) {
- *Ptr += 4;
+ *Ptr += 4;
Status = RETURN_NOT_FOUND;
} else {
Status = ParseOfwNode (Ptr, &Node[NumNodes], &IsFinal);
@@ -1404,16 +1474,16 @@ TranslateOfwPath (
}
switch (Status) {
- case RETURN_SUCCESS:
- ++NumNodes;
- break;
+ case RETURN_SUCCESS:
+ ++NumNodes;
+ break;
- case RETURN_INVALID_PARAMETER:
- DEBUG ((DEBUG_VERBOSE, "%a: parse error\n", __FUNCTION__));
- return RETURN_INVALID_PARAMETER;
+ case RETURN_INVALID_PARAMETER:
+ DEBUG ((DEBUG_VERBOSE, "%a: parse error\n", __FUNCTION__));
+ return RETURN_INVALID_PARAMETER;
- default:
- ASSERT (0);
+ default:
+ ASSERT (0);
}
Status = TranslateOfwNodes (
@@ -1421,32 +1491,36 @@ TranslateOfwPath (
NumNodes < EXAMINED_OFW_NODES ? NumNodes : EXAMINED_OFW_NODES,
ExtraPciRoots,
Translated,
- TranslatedSize);
+ TranslatedSize
+ );
switch (Status) {
- case RETURN_SUCCESS:
- DEBUG ((DEBUG_VERBOSE, "%a: success: \"%s\"\n", __FUNCTION__, Translated));
- break;
+ case RETURN_SUCCESS:
+ DEBUG ((DEBUG_VERBOSE, "%a: success: \"%s\"\n", __FUNCTION__, Translated));
+ break;
- case RETURN_BUFFER_TOO_SMALL:
- DEBUG ((DEBUG_VERBOSE, "%a: buffer too small\n", __FUNCTION__));
- break;
+ case RETURN_BUFFER_TOO_SMALL:
+ DEBUG ((DEBUG_VERBOSE, "%a: buffer too small\n", __FUNCTION__));
+ break;
- case RETURN_UNSUPPORTED:
- DEBUG ((DEBUG_VERBOSE, "%a: unsupported\n", __FUNCTION__));
- break;
+ case RETURN_UNSUPPORTED:
+ DEBUG ((DEBUG_VERBOSE, "%a: unsupported\n", __FUNCTION__));
+ break;
- case RETURN_PROTOCOL_ERROR:
- DEBUG ((DEBUG_VERBOSE, "%a: logic error / system state mismatch\n",
- __FUNCTION__));
- break;
+ case RETURN_PROTOCOL_ERROR:
+ DEBUG ((
+ DEBUG_VERBOSE,
+ "%a: logic error / system state mismatch\n",
+ __FUNCTION__
+ ));
+ break;
- default:
- ASSERT (0);
+ default:
+ ASSERT (0);
}
+
return Status;
}
-
/**
Connect devices based on the boot order retrieved from QEMU.
@@ -1481,16 +1555,16 @@ ConnectDevicesFromQemu (
VOID
)
{
- RETURN_STATUS Status;
- FIRMWARE_CONFIG_ITEM FwCfgItem;
- UINTN FwCfgSize;
- CHAR8 *FwCfg;
- EFI_STATUS EfiStatus;
- EXTRA_ROOT_BUS_MAP *ExtraPciRoots;
- CONST CHAR8 *FwCfgPtr;
- UINTN NumConnected;
- UINTN TranslatedSize;
- CHAR16 Translated[TRANSLATION_OUTPUT_SIZE];
+ RETURN_STATUS Status;
+ FIRMWARE_CONFIG_ITEM FwCfgItem;
+ UINTN FwCfgSize;
+ CHAR8 *FwCfg;
+ EFI_STATUS EfiStatus;
+ EXTRA_ROOT_BUS_MAP *ExtraPciRoots;
+ CONST CHAR8 *FwCfgPtr;
+ UINTN NumConnected;
+ UINTN TranslatedSize;
+ CHAR16 Translated[TRANSLATION_OUTPUT_SIZE];
Status = QemuFwCfgFindFile ("bootorder", &FwCfgItem, &FwCfgSize);
if (RETURN_ERROR (Status)) {
@@ -1512,6 +1586,7 @@ ConnectDevicesFromQemu (
Status = RETURN_INVALID_PARAMETER;
goto FreeFwCfg;
}
+
DEBUG ((DEBUG_VERBOSE, "%a: FwCfg:\n", __FUNCTION__));
DEBUG ((DEBUG_VERBOSE, "%a\n", FwCfg));
DEBUG ((DEBUG_VERBOSE, "%a: FwCfg: <end>\n", __FUNCTION__));
@@ -1529,14 +1604,18 @@ ConnectDevicesFromQemu (
//
// Translate each OpenFirmware path to a UEFI devpath prefix.
//
- FwCfgPtr = FwCfg;
- NumConnected = 0;
+ FwCfgPtr = FwCfg;
+ NumConnected = 0;
TranslatedSize = ARRAY_SIZE (Translated);
- Status = TranslateOfwPath (&FwCfgPtr, ExtraPciRoots, Translated,
- &TranslatedSize);
+ Status = TranslateOfwPath (
+ &FwCfgPtr,
+ ExtraPciRoots,
+ Translated,
+ &TranslatedSize
+ );
while (!RETURN_ERROR (Status)) {
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_HANDLE Controller;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_HANDLE Controller;
//
// Convert the UEFI devpath prefix to binary representation.
@@ -1547,6 +1626,7 @@ ConnectDevicesFromQemu (
Status = RETURN_OUT_OF_RESOURCES;
goto FreeExtraPciRoots;
}
+
//
// Advance along DevicePath, connecting the nodes individually, and asking
// drivers not to produce sibling nodes. Retrieve the controller handle
@@ -1559,6 +1639,7 @@ ConnectDevicesFromQemu (
Status = (RETURN_STATUS)EfiStatus;
goto FreeExtraPciRoots;
}
+
//
// Because QEMU's OFW devpaths have lesser expressive power than UEFI
// devpaths (i.e., DevicePath is considered a prefix), connect the tree
@@ -1566,22 +1647,31 @@ ConnectDevicesFromQemu (
// (EFI_NOT_FOUND), that's OK.
//
EfiStatus = gBS->ConnectController (Controller, NULL, NULL, TRUE);
- if (EFI_ERROR (EfiStatus) && EfiStatus != EFI_NOT_FOUND) {
+ if (EFI_ERROR (EfiStatus) && (EfiStatus != EFI_NOT_FOUND)) {
Status = (RETURN_STATUS)EfiStatus;
goto FreeExtraPciRoots;
}
+
++NumConnected;
//
// Move to the next OFW devpath.
//
TranslatedSize = ARRAY_SIZE (Translated);
- Status = TranslateOfwPath (&FwCfgPtr, ExtraPciRoots, Translated,
- &TranslatedSize);
+ Status = TranslateOfwPath (
+ &FwCfgPtr,
+ ExtraPciRoots,
+ Translated,
+ &TranslatedSize
+ );
}
- if (Status == RETURN_NOT_FOUND && NumConnected > 0) {
- DEBUG ((DEBUG_INFO, "%a: %Lu OpenFirmware device path(s) connected\n",
- __FUNCTION__, (UINT64)NumConnected));
+ if ((Status == RETURN_NOT_FOUND) && (NumConnected > 0)) {
+ DEBUG ((
+ DEBUG_INFO,
+ "%a: %Lu OpenFirmware device path(s) connected\n",
+ __FUNCTION__,
+ (UINT64)NumConnected
+ ));
Status = RETURN_SUCCESS;
}
@@ -1596,7 +1686,6 @@ FreeFwCfg:
return Status;
}
-
/**
Convert the UEFI DevicePath to full text representation with DevPathToText,
@@ -1623,19 +1712,19 @@ FreeFwCfg:
STATIC
BOOLEAN
Match (
- IN CONST CHAR16 *Translated,
- IN UINTN TranslatedLength,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ IN CONST CHAR16 *Translated,
+ IN UINTN TranslatedLength,
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
- CHAR16 *Converted;
- BOOLEAN Result;
- VOID *FileBuffer;
- UINTN FileSize;
- EFI_DEVICE_PATH_PROTOCOL *AbsDevicePath;
- CHAR16 *AbsConverted;
- BOOLEAN Shortform;
- EFI_DEVICE_PATH_PROTOCOL *Node;
+ CHAR16 *Converted;
+ BOOLEAN Result;
+ VOID *FileBuffer;
+ UINTN FileSize;
+ EFI_DEVICE_PATH_PROTOCOL *AbsDevicePath;
+ CHAR16 *AbsConverted;
+ BOOLEAN Shortform;
+ EFI_DEVICE_PATH_PROTOCOL *Node;
Converted = ConvertDevicePathToText (
DevicePath,
@@ -1646,37 +1735,42 @@ Match (
return FALSE;
}
- Result = FALSE;
+ Result = FALSE;
Shortform = FALSE;
//
// Expand the short-form device path to full device path
//
if ((DevicePathType (DevicePath) == MEDIA_DEVICE_PATH) &&
- (DevicePathSubType (DevicePath) == MEDIA_HARDDRIVE_DP)) {
+ (DevicePathSubType (DevicePath) == MEDIA_HARDDRIVE_DP))
+ {
//
// Harddrive shortform device path
//
Shortform = TRUE;
} else if ((DevicePathType (DevicePath) == MEDIA_DEVICE_PATH) &&
- (DevicePathSubType (DevicePath) == MEDIA_FILEPATH_DP)) {
+ (DevicePathSubType (DevicePath) == MEDIA_FILEPATH_DP))
+ {
//
// File-path shortform device path
//
Shortform = TRUE;
} else if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) &&
- (DevicePathSubType (DevicePath) == MSG_URI_DP)) {
+ (DevicePathSubType (DevicePath) == MSG_URI_DP))
+ {
//
// URI shortform device path
//
Shortform = TRUE;
} else {
for ( Node = DevicePath
- ; !IsDevicePathEnd (Node)
- ; Node = NextDevicePathNode (Node)
- ) {
+ ; !IsDevicePathEnd (Node)
+ ; Node = NextDevicePathNode (Node)
+ )
+ {
if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) &&
((DevicePathSubType (Node) == MSG_USB_CLASS_DP) ||
- (DevicePathSubType (Node) == MSG_USB_WWID_DP))) {
+ (DevicePathSubType (Node) == MSG_USB_WWID_DP)))
+ {
Shortform = TRUE;
break;
}
@@ -1689,20 +1783,27 @@ Match (
//
if (Shortform) {
FileBuffer = EfiBootManagerGetLoadOptionBuffer (
- DevicePath, &AbsDevicePath, &FileSize
+ DevicePath,
+ &AbsDevicePath,
+ &FileSize
);
if (FileBuffer == NULL) {
goto Exit;
}
+
FreePool (FileBuffer);
AbsConverted = ConvertDevicePathToText (AbsDevicePath, FALSE, FALSE);
FreePool (AbsDevicePath);
if (AbsConverted == NULL) {
goto Exit;
}
- DEBUG ((DEBUG_VERBOSE,
+
+ DEBUG ((
+ DEBUG_VERBOSE,
"%a: expanded relative device path \"%s\" for prefix matching\n",
- __FUNCTION__, Converted));
+ __FUNCTION__,
+ Converted
+ ));
FreePool (Converted);
Converted = AbsConverted;
}
@@ -1723,7 +1824,6 @@ Exit:
return Result;
}
-
/**
Append some of the unselected active boot options to the boot order.
@@ -1753,27 +1853,27 @@ Exit:
STATIC
RETURN_STATUS
BootOrderComplete (
- IN OUT BOOT_ORDER *BootOrder,
- IN OUT ACTIVE_OPTION *ActiveOption,
- IN UINTN ActiveCount
+ IN OUT BOOT_ORDER *BootOrder,
+ IN OUT ACTIVE_OPTION *ActiveOption,
+ IN UINTN ActiveCount
)
{
- RETURN_STATUS Status;
- UINTN Idx;
+ RETURN_STATUS Status;
+ UINTN Idx;
Status = RETURN_SUCCESS;
- Idx = 0;
+ Idx = 0;
while (!RETURN_ERROR (Status) && Idx < ActiveCount) {
if (!ActiveOption[Idx].Appended) {
- CONST EFI_BOOT_MANAGER_LOAD_OPTION *Current;
- CONST EFI_DEVICE_PATH_PROTOCOL *FirstNode;
+ CONST EFI_BOOT_MANAGER_LOAD_OPTION *Current;
+ CONST EFI_DEVICE_PATH_PROTOCOL *FirstNode;
- Current = ActiveOption[Idx].BootOption;
+ Current = ActiveOption[Idx].BootOption;
FirstNode = Current->FilePath;
if (FirstNode != NULL) {
- CHAR16 *Converted;
- STATIC CHAR16 ConvFallBack[] = L"<unable to convert>";
- BOOLEAN Keep;
+ CHAR16 *Converted;
+ STATIC CHAR16 ConvFallBack[] = L"<unable to convert>";
+ BOOLEAN Keep;
Converted = ConvertDevicePathToText (FirstNode, FALSE, FALSE);
if (Converted == NULL) {
@@ -1781,19 +1881,22 @@ BootOrderComplete (
}
Keep = TRUE;
- if (DevicePathType(FirstNode) == MEDIA_DEVICE_PATH &&
- DevicePathSubType(FirstNode) == MEDIA_HARDDRIVE_DP) {
+ if ((DevicePathType (FirstNode) == MEDIA_DEVICE_PATH) &&
+ (DevicePathSubType (FirstNode) == MEDIA_HARDDRIVE_DP))
+ {
//
// drop HD()
//
Keep = FALSE;
- } else if (DevicePathType(FirstNode) == ACPI_DEVICE_PATH &&
- DevicePathSubType(FirstNode) == ACPI_DP) {
- ACPI_HID_DEVICE_PATH *Acpi;
-
- Acpi = (ACPI_HID_DEVICE_PATH *) FirstNode;
- if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST &&
- EISA_ID_TO_NUM (Acpi->HID) == 0x0a03) {
+ } else if ((DevicePathType (FirstNode) == ACPI_DEVICE_PATH) &&
+ (DevicePathSubType (FirstNode) == ACPI_DP))
+ {
+ ACPI_HID_DEVICE_PATH *Acpi;
+
+ Acpi = (ACPI_HID_DEVICE_PATH *)FirstNode;
+ if (((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) &&
+ (EISA_ID_TO_NUM (Acpi->HID) == 0x0a03))
+ {
//
// drop PciRoot() if we enabled the user to select PCI-like boot
// options, by providing translation for such OFW device path
@@ -1801,9 +1904,10 @@ BootOrderComplete (
//
Keep = !FeaturePcdGet (PcdQemuBootOrderPciTranslation);
}
- } else if (DevicePathType(FirstNode) == HARDWARE_DEVICE_PATH &&
- DevicePathSubType(FirstNode) == HW_VENDOR_DP) {
- VENDOR_DEVICE_PATH *VenHw;
+ } else if ((DevicePathType (FirstNode) == HARDWARE_DEVICE_PATH) &&
+ (DevicePathSubType (FirstNode) == HW_VENDOR_DP))
+ {
+ VENDOR_DEVICE_PATH *VenHw;
VenHw = (VENDOR_DEVICE_PATH *)FirstNode;
if (CompareGuid (&VenHw->Guid, &gVirtioMmioTransportGuid)) {
@@ -1818,12 +1922,20 @@ BootOrderComplete (
if (Keep) {
Status = BootOrderAppend (BootOrder, &ActiveOption[Idx]);
if (!RETURN_ERROR (Status)) {
- DEBUG ((DEBUG_VERBOSE, "%a: keeping \"%s\"\n", __FUNCTION__,
- Converted));
+ DEBUG ((
+ DEBUG_VERBOSE,
+ "%a: keeping \"%s\"\n",
+ __FUNCTION__,
+ Converted
+ ));
}
} else {
- DEBUG ((DEBUG_VERBOSE, "%a: dropping \"%s\"\n", __FUNCTION__,
- Converted));
+ DEBUG ((
+ DEBUG_VERBOSE,
+ "%a: dropping \"%s\"\n",
+ __FUNCTION__,
+ Converted
+ ));
}
if (Converted != ConvFallBack) {
@@ -1831,12 +1943,13 @@ BootOrderComplete (
}
}
}
+
++Idx;
}
+
return Status;
}
-
/**
Delete Boot#### variables that stand for such active boot options that have
been dropped (ie. have not been selected by either matching or "survival
@@ -1851,24 +1964,30 @@ BootOrderComplete (
STATIC
VOID
PruneBootVariables (
- IN CONST ACTIVE_OPTION *ActiveOption,
- IN UINTN ActiveCount
+ IN CONST ACTIVE_OPTION *ActiveOption,
+ IN UINTN ActiveCount
)
{
- UINTN Idx;
+ UINTN Idx;
for (Idx = 0; Idx < ActiveCount; ++Idx) {
if (!ActiveOption[Idx].Appended) {
- CHAR16 VariableName[9];
+ CHAR16 VariableName[9];
- UnicodeSPrintAsciiFormat (VariableName, sizeof VariableName, "Boot%04x",
- ActiveOption[Idx].BootOption->OptionNumber);
+ UnicodeSPrintAsciiFormat (
+ VariableName,
+ sizeof VariableName,
+ "Boot%04x",
+ ActiveOption[Idx].BootOption->OptionNumber
+ );
//
// "The space consumed by the deleted variable may not be available until
// the next power cycle", but that's good enough.
//
- gRT->SetVariable (VariableName, &gEfiGlobalVariableGuid,
+ gRT->SetVariable (
+ VariableName,
+ &gEfiGlobalVariableGuid,
0, // Attributes, 0 means deletion
0, // DataSize, 0 means deletion
NULL // Data
@@ -1877,7 +1996,6 @@ PruneBootVariables (
}
}
-
/**
Set the boot order based on configuration retrieved from QEMU.
@@ -1912,22 +2030,22 @@ SetBootOrderFromQemu (
VOID
)
{
- RETURN_STATUS Status;
- FIRMWARE_CONFIG_ITEM FwCfgItem;
- UINTN FwCfgSize;
- CHAR8 *FwCfg;
- CONST CHAR8 *FwCfgPtr;
+ RETURN_STATUS Status;
+ FIRMWARE_CONFIG_ITEM FwCfgItem;
+ UINTN FwCfgSize;
+ CHAR8 *FwCfg;
+ CONST CHAR8 *FwCfgPtr;
- BOOT_ORDER BootOrder;
- ACTIVE_OPTION *ActiveOption;
- UINTN ActiveCount;
+ BOOT_ORDER BootOrder;
+ ACTIVE_OPTION *ActiveOption;
+ UINTN ActiveCount;
- EXTRA_ROOT_BUS_MAP *ExtraPciRoots;
+ EXTRA_ROOT_BUS_MAP *ExtraPciRoots;
- UINTN TranslatedSize;
- CHAR16 Translated[TRANSLATION_OUTPUT_SIZE];
- EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
- UINTN BootOptionCount;
+ UINTN TranslatedSize;
+ CHAR16 Translated[TRANSLATION_OUTPUT_SIZE];
+ EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
+ UINTN BootOptionCount;
Status = QemuFwCfgFindFile ("bootorder", &FwCfgItem, &FwCfgSize);
if (Status != RETURN_SUCCESS) {
@@ -1957,16 +2075,17 @@ SetBootOrderFromQemu (
BootOrder.Produced = 0;
BootOrder.Allocated = 1;
- BootOrder.Data = AllocatePool (
- BootOrder.Allocated * sizeof (*BootOrder.Data)
- );
+ BootOrder.Data = AllocatePool (
+ BootOrder.Allocated * sizeof (*BootOrder.Data)
+ );
if (BootOrder.Data == NULL) {
Status = RETURN_OUT_OF_RESOURCES;
goto ErrorFreeFwCfg;
}
BootOptions = EfiBootManagerGetLoadOptions (
- &BootOptionCount, LoadOptionTypeBoot
+ &BootOptionCount,
+ LoadOptionTypeBoot
);
if (BootOptions == NULL) {
Status = RETURN_NOT_FOUND;
@@ -1974,7 +2093,10 @@ SetBootOrderFromQemu (
}
Status = CollectActiveOptions (
- BootOptions, BootOptionCount, &ActiveOption, &ActiveCount
+ BootOptions,
+ BootOptionCount,
+ &ActiveOption,
+ &ActiveCount
);
if (RETURN_ERROR (Status)) {
goto ErrorFreeBootOptions;
@@ -1993,14 +2115,19 @@ SetBootOrderFromQemu (
// translate each OpenFirmware path
//
TranslatedSize = ARRAY_SIZE (Translated);
- Status = TranslateOfwPath (&FwCfgPtr, ExtraPciRoots, Translated,
- &TranslatedSize);
+ Status = TranslateOfwPath (
+ &FwCfgPtr,
+ ExtraPciRoots,
+ Translated,
+ &TranslatedSize
+ );
while (Status == RETURN_SUCCESS ||
Status == RETURN_UNSUPPORTED ||
Status == RETURN_PROTOCOL_ERROR ||
- Status == RETURN_BUFFER_TOO_SMALL) {
+ Status == RETURN_BUFFER_TOO_SMALL)
+ {
if (Status == RETURN_SUCCESS) {
- UINTN Idx;
+ UINTN Idx;
//
// match translated OpenFirmware path against all active boot options
@@ -2012,7 +2139,8 @@ SetBootOrderFromQemu (
TranslatedSize, // contains length, not size, in CHAR16's here
ActiveOption[Idx].BootOption->FilePath
)
- ) {
+ )
+ {
//
// match found, store ID and continue with next OpenFirmware path
//
@@ -2025,11 +2153,15 @@ SetBootOrderFromQemu (
} // translation successful
TranslatedSize = ARRAY_SIZE (Translated);
- Status = TranslateOfwPath (&FwCfgPtr, ExtraPciRoots, Translated,
- &TranslatedSize);
+ Status = TranslateOfwPath (
+ &FwCfgPtr,
+ ExtraPciRoots,
+ Translated,
+ &TranslatedSize
+ );
} // scanning of OpenFirmware paths done
- if (Status == RETURN_NOT_FOUND && BootOrder.Produced > 0) {
+ if ((Status == RETURN_NOT_FOUND) && (BootOrder.Produced > 0)) {
//
// No more OpenFirmware paths, some matches found: rewrite BootOrder NvVar.
// Some of the active boot options that have not been selected over fw_cfg
@@ -2048,14 +2180,18 @@ SetBootOrderFromQemu (
L"BootOrder",
&gEfiGlobalVariableGuid,
EFI_VARIABLE_NON_VOLATILE |
- EFI_VARIABLE_BOOTSERVICE_ACCESS |
- EFI_VARIABLE_RUNTIME_ACCESS,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS |
+ EFI_VARIABLE_RUNTIME_ACCESS,
BootOrder.Produced * sizeof (*BootOrder.Data),
BootOrder.Data
);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: setting BootOrder: %r\n", __FUNCTION__,
- Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: setting BootOrder: %r\n",
+ __FUNCTION__,
+ Status
+ ));
goto ErrorFreeExtraPciRoots;
}
@@ -2083,7 +2219,6 @@ ErrorFreeFwCfg:
return Status;
}
-
/**
Calculate the number of seconds we should be showing the FrontPage progress
bar for.
@@ -2096,8 +2231,8 @@ GetFrontPageTimeoutFromQemu (
VOID
)
{
- FIRMWARE_CONFIG_ITEM BootMenuWaitItem;
- UINTN BootMenuWaitSize;
+ FIRMWARE_CONFIG_ITEM BootMenuWaitItem;
+ UINTN BootMenuWaitSize;
QemuFwCfgSelectItem (QemuFwCfgItemBootMenu);
if (QemuFwCfgRead16 () == 0) {
@@ -2108,20 +2243,27 @@ GetFrontPageTimeoutFromQemu (
return PcdGet16 (PcdPlatformBootTimeOut);
}
- if (RETURN_ERROR (QemuFwCfgFindFile ("etc/boot-menu-wait", &BootMenuWaitItem,
- &BootMenuWaitSize)) ||
- BootMenuWaitSize != sizeof (UINT16)) {
+ if (RETURN_ERROR (
+ QemuFwCfgFindFile (
+ "etc/boot-menu-wait",
+ &BootMenuWaitItem,
+ &BootMenuWaitSize
+ )
+ ) ||
+ (BootMenuWaitSize != sizeof (UINT16)))
+ {
//
// "-boot menu=on" was specified without "splash-time=N". In this case,
// return three seconds if the platform default would cause us to skip the
// front page, and return the platform default otherwise.
//
- UINT16 Timeout;
+ UINT16 Timeout;
Timeout = PcdGet16 (PcdPlatformBootTimeOut);
if (Timeout == 0) {
Timeout = 3;
}
+
return Timeout;
}
diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c
index 0182c9235c..f5787cd24d 100644
--- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c
+++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c
@@ -23,10 +23,10 @@
#include "QemuFwCfgLibInternal.h"
-STATIC BOOLEAN mQemuFwCfgSupported = FALSE;
-STATIC BOOLEAN mQemuFwCfgDmaSupported;
+STATIC BOOLEAN mQemuFwCfgSupported = FALSE;
+STATIC BOOLEAN mQemuFwCfgDmaSupported;
-STATIC EDKII_IOMMU_PROTOCOL *mIoMmuProtocol;
+STATIC EDKII_IOMMU_PROTOCOL *mIoMmuProtocol;
/**
Returns a boolean indicating if the firmware configuration interface
@@ -47,21 +47,20 @@ QemuFwCfgIsAvailable (
return InternalQemuFwCfgIsAvailable ();
}
-
RETURN_STATUS
EFIAPI
QemuFwCfgInitialize (
VOID
)
{
- UINT32 Signature;
- UINT32 Revision;
+ UINT32 Signature;
+ UINT32 Revision;
//
// Enable the access routines while probing to see if it is supported.
// For probing we always use the IO Port (IoReadFifo8()) access method.
//
- mQemuFwCfgSupported = TRUE;
+ mQemuFwCfgSupported = TRUE;
mQemuFwCfgDmaSupported = FALSE;
QemuFwCfgSelectItem (QemuFwCfgItemSignature);
@@ -72,7 +71,8 @@ QemuFwCfgInitialize (
DEBUG ((DEBUG_INFO, "FW CFG Revision: 0x%x\n", Revision));
if ((Signature != SIGNATURE_32 ('Q', 'E', 'M', 'U')) ||
(Revision < 1)
- ) {
+ )
+ {
DEBUG ((DEBUG_INFO, "QemuFwCfg interface not supported.\n"));
mQemuFwCfgSupported = FALSE;
return RETURN_SUCCESS;
@@ -86,18 +86,24 @@ QemuFwCfgInitialize (
}
if (mQemuFwCfgDmaSupported && MemEncryptSevIsEnabled ()) {
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// IoMmuDxe driver must have installed the IOMMU protocol. If we are not
// able to locate the protocol then something must have gone wrong.
//
- Status = gBS->LocateProtocol (&gEdkiiIoMmuProtocolGuid, NULL,
- (VOID **)&mIoMmuProtocol);
+ Status = gBS->LocateProtocol (
+ &gEdkiiIoMmuProtocolGuid,
+ NULL,
+ (VOID **)&mIoMmuProtocol
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR,
+ DEBUG ((
+ DEBUG_ERROR,
"QemuFwCfgSevDma %a:%a Failed to locate IOMMU protocol.\n",
- gEfiCallerBaseName, __FUNCTION__));
+ gEfiCallerBaseName,
+ __FUNCTION__
+ ));
ASSERT (FALSE);
CpuDeadLoop ();
}
@@ -106,7 +112,6 @@ QemuFwCfgInitialize (
return RETURN_SUCCESS;
}
-
/**
Returns a boolean indicating if the firmware configuration interface is
available for library-internal purposes.
@@ -148,8 +153,8 @@ InternalQemuFwCfgDmaIsAvailable (
STATIC
VOID
AllocFwCfgDmaAccessBuffer (
- OUT VOID **Access,
- OUT VOID **MapInfo
+ OUT VOID **Access,
+ OUT VOID **MapInfo
)
{
UINTN Size;
@@ -159,7 +164,7 @@ AllocFwCfgDmaAccessBuffer (
EFI_PHYSICAL_ADDRESS DmaAddress;
VOID *Mapping;
- Size = sizeof (FW_CFG_DMA_ACCESS);
+ Size = sizeof (FW_CFG_DMA_ACCESS);
NumPages = EFI_SIZE_TO_PAGES (Size);
//
@@ -176,9 +181,12 @@ AllocFwCfgDmaAccessBuffer (
EDKII_IOMMU_ATTRIBUTE_DUAL_ADDRESS_CYCLE
);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR,
- "%a:%a failed to allocate FW_CFG_DMA_ACCESS\n", gEfiCallerBaseName,
- __FUNCTION__));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a:%a failed to allocate FW_CFG_DMA_ACCESS\n",
+ gEfiCallerBaseName,
+ __FUNCTION__
+ ));
ASSERT (FALSE);
CpuDeadLoop ();
}
@@ -202,9 +210,12 @@ AllocFwCfgDmaAccessBuffer (
);
if (EFI_ERROR (Status)) {
mIoMmuProtocol->FreeBuffer (mIoMmuProtocol, NumPages, HostAddress);
- DEBUG ((DEBUG_ERROR,
- "%a:%a failed to Map() FW_CFG_DMA_ACCESS\n", gEfiCallerBaseName,
- __FUNCTION__));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a:%a failed to Map() FW_CFG_DMA_ACCESS\n",
+ gEfiCallerBaseName,
+ __FUNCTION__
+ ));
ASSERT (FALSE);
CpuDeadLoop ();
}
@@ -212,14 +223,19 @@ AllocFwCfgDmaAccessBuffer (
if (Size < sizeof (FW_CFG_DMA_ACCESS)) {
mIoMmuProtocol->Unmap (mIoMmuProtocol, Mapping);
mIoMmuProtocol->FreeBuffer (mIoMmuProtocol, NumPages, HostAddress);
- DEBUG ((DEBUG_ERROR,
- "%a:%a failed to Map() - requested 0x%Lx got 0x%Lx\n", gEfiCallerBaseName,
- __FUNCTION__, (UINT64)sizeof (FW_CFG_DMA_ACCESS), (UINT64)Size));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a:%a failed to Map() - requested 0x%Lx got 0x%Lx\n",
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ (UINT64)sizeof (FW_CFG_DMA_ACCESS),
+ (UINT64)Size
+ ));
ASSERT (FALSE);
CpuDeadLoop ();
}
- *Access = HostAddress;
+ *Access = HostAddress;
*MapInfo = Mapping;
}
@@ -231,8 +247,8 @@ AllocFwCfgDmaAccessBuffer (
STATIC
VOID
FreeFwCfgDmaAccessBuffer (
- IN VOID *Access,
- IN VOID *Mapping
+ IN VOID *Access,
+ IN VOID *Mapping
)
{
UINTN NumPages;
@@ -242,18 +258,26 @@ FreeFwCfgDmaAccessBuffer (
Status = mIoMmuProtocol->Unmap (mIoMmuProtocol, Mapping);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR,
- "%a:%a failed to UnMap() Mapping 0x%Lx\n", gEfiCallerBaseName,
- __FUNCTION__, (UINT64)(UINTN)Mapping));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a:%a failed to UnMap() Mapping 0x%Lx\n",
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ (UINT64)(UINTN)Mapping
+ ));
ASSERT (FALSE);
CpuDeadLoop ();
}
Status = mIoMmuProtocol->FreeBuffer (mIoMmuProtocol, NumPages, Access);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR,
- "%a:%a failed to Free() 0x%Lx\n", gEfiCallerBaseName, __FUNCTION__,
- (UINT64)(UINTN)Access));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a:%a failed to Free() 0x%Lx\n",
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ (UINT64)(UINTN)Access
+ ));
ASSERT (FALSE);
CpuDeadLoop ();
}
@@ -274,41 +298,51 @@ MapFwCfgDmaDataBuffer (
OUT VOID **MapInfo
)
{
- EFI_STATUS Status;
- UINTN NumberOfBytes;
- VOID *Mapping;
- EFI_PHYSICAL_ADDRESS PhysicalAddress;
+ EFI_STATUS Status;
+ UINTN NumberOfBytes;
+ VOID *Mapping;
+ EFI_PHYSICAL_ADDRESS PhysicalAddress;
NumberOfBytes = Size;
- Status = mIoMmuProtocol->Map (
- mIoMmuProtocol,
- (IsWrite ?
- EdkiiIoMmuOperationBusMasterRead64 :
- EdkiiIoMmuOperationBusMasterWrite64),
- HostAddress,
- &NumberOfBytes,
- &PhysicalAddress,
- &Mapping
- );
+ Status = mIoMmuProtocol->Map (
+ mIoMmuProtocol,
+ (IsWrite ?
+ EdkiiIoMmuOperationBusMasterRead64 :
+ EdkiiIoMmuOperationBusMasterWrite64),
+ HostAddress,
+ &NumberOfBytes,
+ &PhysicalAddress,
+ &Mapping
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR,
- "%a:%a failed to Map() Address 0x%Lx Size 0x%Lx\n", gEfiCallerBaseName,
- __FUNCTION__, (UINT64)(UINTN)HostAddress, (UINT64)Size));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a:%a failed to Map() Address 0x%Lx Size 0x%Lx\n",
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ (UINT64)(UINTN)HostAddress,
+ (UINT64)Size
+ ));
ASSERT (FALSE);
CpuDeadLoop ();
}
if (NumberOfBytes < Size) {
mIoMmuProtocol->Unmap (mIoMmuProtocol, Mapping);
- DEBUG ((DEBUG_ERROR,
- "%a:%a failed to Map() - requested 0x%x got 0x%Lx\n", gEfiCallerBaseName,
- __FUNCTION__, Size, (UINT64)NumberOfBytes));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a:%a failed to Map() - requested 0x%x got 0x%Lx\n",
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ Size,
+ (UINT64)NumberOfBytes
+ ));
ASSERT (FALSE);
CpuDeadLoop ();
}
*DeviceAddress = PhysicalAddress;
- *MapInfo = Mapping;
+ *MapInfo = Mapping;
}
STATIC
@@ -321,9 +355,13 @@ UnmapFwCfgDmaDataBuffer (
Status = mIoMmuProtocol->Unmap (mIoMmuProtocol, Mapping);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR,
- "%a:%a failed to UnMap() Mapping 0x%Lx\n", gEfiCallerBaseName,
- __FUNCTION__, (UINT64)(UINTN)Mapping));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a:%a failed to UnMap() Mapping 0x%Lx\n",
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ (UINT64)(UINTN)Mapping
+ ));
ASSERT (FALSE);
CpuDeadLoop ();
}
@@ -346,29 +384,31 @@ UnmapFwCfgDmaDataBuffer (
**/
VOID
InternalQemuFwCfgDmaBytes (
- IN UINT32 Size,
- IN OUT VOID *Buffer OPTIONAL,
- IN UINT32 Control
+ IN UINT32 Size,
+ IN OUT VOID *Buffer OPTIONAL,
+ IN UINT32 Control
)
{
- volatile FW_CFG_DMA_ACCESS LocalAccess;
- volatile FW_CFG_DMA_ACCESS *Access;
- UINT32 AccessHigh, AccessLow;
- UINT32 Status;
- VOID *AccessMapping, *DataMapping;
- VOID *DataBuffer;
-
- ASSERT (Control == FW_CFG_DMA_CTL_WRITE || Control == FW_CFG_DMA_CTL_READ ||
- Control == FW_CFG_DMA_CTL_SKIP);
+ volatile FW_CFG_DMA_ACCESS LocalAccess;
+ volatile FW_CFG_DMA_ACCESS *Access;
+ UINT32 AccessHigh, AccessLow;
+ UINT32 Status;
+ VOID *AccessMapping, *DataMapping;
+ VOID *DataBuffer;
+
+ ASSERT (
+ Control == FW_CFG_DMA_CTL_WRITE || Control == FW_CFG_DMA_CTL_READ ||
+ Control == FW_CFG_DMA_CTL_SKIP
+ );
if (Size == 0) {
return;
}
- Access = &LocalAccess;
+ Access = &LocalAccess;
AccessMapping = NULL;
- DataMapping = NULL;
- DataBuffer = Buffer;
+ DataMapping = NULL;
+ DataBuffer = Buffer;
//
// When SEV is enabled, map Buffer to DMA address before issuing the DMA
@@ -397,7 +437,7 @@ InternalQemuFwCfgDmaBytes (
&DataMapping
);
- DataBuffer = (VOID *) (UINTN) DataBufferAddress;
+ DataBuffer = (VOID *)(UINTN)DataBufferAddress;
}
}
@@ -416,7 +456,7 @@ InternalQemuFwCfgDmaBytes (
//
AccessHigh = (UINT32)RShiftU64 ((UINTN)Access, 32);
AccessLow = (UINT32)(UINTN)Access;
- IoWrite32 (FW_CFG_IO_DMA_ADDRESS, SwapBytes32 (AccessHigh));
+ IoWrite32 (FW_CFG_IO_DMA_ADDRESS, SwapBytes32 (AccessHigh));
IoWrite32 (FW_CFG_IO_DMA_ADDRESS + 4, SwapBytes32 (AccessLow));
//
diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c
index 4ef78b7a8b..8e8f54ba3f 100644
--- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c
+++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c
@@ -19,7 +19,6 @@
#include "QemuFwCfgLibInternal.h"
-
/**
Selects a firmware configuration item for reading.
@@ -32,11 +31,11 @@
VOID
EFIAPI
QemuFwCfgSelectItem (
- IN FIRMWARE_CONFIG_ITEM QemuFwCfgItem
+ IN FIRMWARE_CONFIG_ITEM QemuFwCfgItem
)
{
- DEBUG ((DEBUG_INFO, "Select Item: 0x%x\n", (UINT16)(UINTN) QemuFwCfgItem));
- IoWrite16 (FW_CFG_IO_SELECTOR, (UINT16)(UINTN) QemuFwCfgItem);
+ DEBUG ((DEBUG_INFO, "Select Item: 0x%x\n", (UINT16)(UINTN)QemuFwCfgItem));
+ IoWrite16 (FW_CFG_IO_SELECTOR, (UINT16)(UINTN)QemuFwCfgItem);
}
/**
@@ -49,18 +48,18 @@ QemuFwCfgSelectItem (
VOID
EFIAPI
InternalQemuFwCfgReadBytes (
- IN UINTN Size,
- IN VOID *Buffer OPTIONAL
+ IN UINTN Size,
+ IN VOID *Buffer OPTIONAL
)
{
- if (InternalQemuFwCfgDmaIsAvailable () && Size <= MAX_UINT32) {
+ if (InternalQemuFwCfgDmaIsAvailable () && (Size <= MAX_UINT32)) {
InternalQemuFwCfgDmaBytes ((UINT32)Size, Buffer, FW_CFG_DMA_CTL_READ);
return;
}
+
IoReadFifo8 (FW_CFG_IO_DATA, Size, Buffer);
}
-
/**
Reads firmware configuration bytes into a buffer
@@ -75,8 +74,8 @@ InternalQemuFwCfgReadBytes (
VOID
EFIAPI
QemuFwCfgReadBytes (
- IN UINTN Size,
- IN VOID *Buffer
+ IN UINTN Size,
+ IN VOID *Buffer
)
{
if (InternalQemuFwCfgIsAvailable ()) {
@@ -100,20 +99,20 @@ QemuFwCfgReadBytes (
VOID
EFIAPI
QemuFwCfgWriteBytes (
- IN UINTN Size,
- IN VOID *Buffer
+ IN UINTN Size,
+ IN VOID *Buffer
)
{
if (InternalQemuFwCfgIsAvailable ()) {
- if (InternalQemuFwCfgDmaIsAvailable () && Size <= MAX_UINT32) {
+ if (InternalQemuFwCfgDmaIsAvailable () && (Size <= MAX_UINT32)) {
InternalQemuFwCfgDmaBytes ((UINT32)Size, Buffer, FW_CFG_DMA_CTL_WRITE);
return;
}
+
IoWriteFifo8 (FW_CFG_IO_DATA, Size, Buffer);
}
}
-
/**
Skip bytes in the firmware configuration item.
@@ -126,17 +125,17 @@ QemuFwCfgWriteBytes (
VOID
EFIAPI
QemuFwCfgSkipBytes (
- IN UINTN Size
+ IN UINTN Size
)
{
- UINTN ChunkSize;
- UINT8 SkipBuffer[256];
+ UINTN ChunkSize;
+ UINT8 SkipBuffer[256];
if (!InternalQemuFwCfgIsAvailable ()) {
return;
}
- if (InternalQemuFwCfgDmaIsAvailable () && Size <= MAX_UINT32) {
+ if (InternalQemuFwCfgDmaIsAvailable () && (Size <= MAX_UINT32)) {
InternalQemuFwCfgDmaBytes ((UINT32)Size, NULL, FW_CFG_DMA_CTL_SKIP);
return;
}
@@ -157,7 +156,6 @@ QemuFwCfgSkipBytes (
}
}
-
/**
Reads a UINT8 firmware configuration value
@@ -170,14 +168,13 @@ QemuFwCfgRead8 (
VOID
)
{
- UINT8 Result;
+ UINT8 Result;
QemuFwCfgReadBytes (sizeof (Result), &Result);
return Result;
}
-
/**
Reads a UINT16 firmware configuration value
@@ -190,14 +187,13 @@ QemuFwCfgRead16 (
VOID
)
{
- UINT16 Result;
+ UINT16 Result;
QemuFwCfgReadBytes (sizeof (Result), &Result);
return Result;
}
-
/**
Reads a UINT32 firmware configuration value
@@ -210,14 +206,13 @@ QemuFwCfgRead32 (
VOID
)
{
- UINT32 Result;
+ UINT32 Result;
QemuFwCfgReadBytes (sizeof (Result), &Result);
return Result;
}
-
/**
Reads a UINT64 firmware configuration value
@@ -230,14 +225,13 @@ QemuFwCfgRead64 (
VOID
)
{
- UINT64 Result;
+ UINT64 Result;
QemuFwCfgReadBytes (sizeof (Result), &Result);
return Result;
}
-
/**
Find the configuration item corresponding to the firmware configuration file.
@@ -259,8 +253,8 @@ QemuFwCfgFindFile (
OUT UINTN *Size
)
{
- UINT32 Count;
- UINT32 Idx;
+ UINT32 Count;
+ UINT32 Idx;
if (!InternalQemuFwCfgIsAvailable ()) {
return RETURN_UNSUPPORTED;
@@ -270,15 +264,15 @@ QemuFwCfgFindFile (
Count = SwapBytes32 (QemuFwCfgRead32 ());
for (Idx = 0; Idx < Count; ++Idx) {
- UINT32 FileSize;
- UINT16 FileSelect;
- UINT16 FileReserved;
- CHAR8 FName[QEMU_FW_CFG_FNAME_SIZE];
+ UINT32 FileSize;
+ UINT16 FileSelect;
+ UINT16 FileReserved;
+ CHAR8 FName[QEMU_FW_CFG_FNAME_SIZE];
FileSize = QemuFwCfgRead32 ();
FileSelect = QemuFwCfgRead16 ();
FileReserved = QemuFwCfgRead16 ();
- (VOID) FileReserved; /* Force a do-nothing reference. */
+ (VOID)FileReserved; /* Force a do-nothing reference. */
InternalQemuFwCfgReadBytes (sizeof (FName), FName);
if (AsciiStrCmp (Name, FName) == 0) {
diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h
index 1fa80686e0..0b77cad1c0 100644
--- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h
+++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h
@@ -25,7 +25,6 @@ InternalQemuFwCfgIsAvailable (
VOID
);
-
/**
Returns a boolean indicating whether QEMU provides the DMA-like access method
for fw_cfg.
@@ -55,9 +54,9 @@ InternalQemuFwCfgDmaIsAvailable (
**/
VOID
InternalQemuFwCfgDmaBytes (
- IN UINT32 Size,
- IN OUT VOID *Buffer OPTIONAL,
- IN UINT32 Control
+ IN UINT32 Size,
+ IN OUT VOID *Buffer OPTIONAL,
+ IN UINT32 Control
);
#endif
diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibMmio.c b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibMmio.c
index 457eba82fa..583d8a8e9f 100644
--- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibMmio.c
+++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibMmio.c
@@ -20,9 +20,9 @@
#include <Protocol/FdtClient.h>
-STATIC UINTN mFwCfgSelectorAddress;
-STATIC UINTN mFwCfgDataAddress;
-STATIC UINTN mFwCfgDmaAddress;
+STATIC UINTN mFwCfgSelectorAddress;
+STATIC UINTN mFwCfgDataAddress;
+STATIC UINTN mFwCfgDmaAddress;
/**
Reads firmware configuration bytes into a buffer
@@ -32,7 +32,7 @@ STATIC UINTN mFwCfgDmaAddress;
**/
typedef
-VOID (EFIAPI READ_BYTES_FUNCTION) (
+VOID(EFIAPI READ_BYTES_FUNCTION)(
IN UINTN Size,
IN VOID *Buffer OPTIONAL
);
@@ -45,7 +45,7 @@ VOID (EFIAPI READ_BYTES_FUNCTION) (
**/
typedef
-VOID (EFIAPI WRITE_BYTES_FUNCTION) (
+VOID(EFIAPI WRITE_BYTES_FUNCTION)(
IN UINTN Size,
IN VOID *Buffer OPTIONAL
);
@@ -57,27 +57,26 @@ VOID (EFIAPI WRITE_BYTES_FUNCTION) (
**/
typedef
-VOID (EFIAPI SKIP_BYTES_FUNCTION) (
+VOID(EFIAPI SKIP_BYTES_FUNCTION)(
IN UINTN Size
);
//
// Forward declaration of the two implementations we have.
//
-STATIC READ_BYTES_FUNCTION MmioReadBytes;
-STATIC WRITE_BYTES_FUNCTION MmioWriteBytes;
-STATIC SKIP_BYTES_FUNCTION MmioSkipBytes;
-STATIC READ_BYTES_FUNCTION DmaReadBytes;
-STATIC WRITE_BYTES_FUNCTION DmaWriteBytes;
-STATIC SKIP_BYTES_FUNCTION DmaSkipBytes;
+STATIC READ_BYTES_FUNCTION MmioReadBytes;
+STATIC WRITE_BYTES_FUNCTION MmioWriteBytes;
+STATIC SKIP_BYTES_FUNCTION MmioSkipBytes;
+STATIC READ_BYTES_FUNCTION DmaReadBytes;
+STATIC WRITE_BYTES_FUNCTION DmaWriteBytes;
+STATIC SKIP_BYTES_FUNCTION DmaSkipBytes;
//
// These correspond to the implementation we detect at runtime.
//
-STATIC READ_BYTES_FUNCTION *InternalQemuFwCfgReadBytes = MmioReadBytes;
-STATIC WRITE_BYTES_FUNCTION *InternalQemuFwCfgWriteBytes = MmioWriteBytes;
-STATIC SKIP_BYTES_FUNCTION *InternalQemuFwCfgSkipBytes = MmioSkipBytes;
-
+STATIC READ_BYTES_FUNCTION *InternalQemuFwCfgReadBytes = MmioReadBytes;
+STATIC WRITE_BYTES_FUNCTION *InternalQemuFwCfgWriteBytes = MmioWriteBytes;
+STATIC SKIP_BYTES_FUNCTION *InternalQemuFwCfgSkipBytes = MmioSkipBytes;
/**
Returns a boolean indicating if the firmware configuration interface
@@ -98,36 +97,46 @@ QemuFwCfgIsAvailable (
return (BOOLEAN)(mFwCfgSelectorAddress != 0 && mFwCfgDataAddress != 0);
}
-
RETURN_STATUS
EFIAPI
QemuFwCfgInitialize (
VOID
)
{
- EFI_STATUS Status;
- FDT_CLIENT_PROTOCOL *FdtClient;
- CONST UINT64 *Reg;
- UINT32 RegSize;
- UINTN AddressCells, SizeCells;
- UINT64 FwCfgSelectorAddress;
- UINT64 FwCfgSelectorSize;
- UINT64 FwCfgDataAddress;
- UINT64 FwCfgDataSize;
- UINT64 FwCfgDmaAddress;
- UINT64 FwCfgDmaSize;
-
- Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL,
- (VOID **)&FdtClient);
+ EFI_STATUS Status;
+ FDT_CLIENT_PROTOCOL *FdtClient;
+ CONST UINT64 *Reg;
+ UINT32 RegSize;
+ UINTN AddressCells, SizeCells;
+ UINT64 FwCfgSelectorAddress;
+ UINT64 FwCfgSelectorSize;
+ UINT64 FwCfgDataAddress;
+ UINT64 FwCfgDataSize;
+ UINT64 FwCfgDmaAddress;
+ UINT64 FwCfgDmaSize;
+
+ Status = gBS->LocateProtocol (
+ &gFdtClientProtocolGuid,
+ NULL,
+ (VOID **)&FdtClient
+ );
ASSERT_EFI_ERROR (Status);
- Status = FdtClient->FindCompatibleNodeReg (FdtClient, "qemu,fw-cfg-mmio",
- (CONST VOID **)&Reg, &AddressCells, &SizeCells,
- &RegSize);
+ Status = FdtClient->FindCompatibleNodeReg (
+ FdtClient,
+ "qemu,fw-cfg-mmio",
+ (CONST VOID **)&Reg,
+ &AddressCells,
+ &SizeCells,
+ &RegSize
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_WARN,
+ DEBUG ((
+ DEBUG_WARN,
"%a: No 'qemu,fw-cfg-mmio' compatible DT node found (Status == %r)\n",
- __FUNCTION__, Status));
+ __FUNCTION__,
+ Status
+ ));
return EFI_SUCCESS;
}
@@ -156,8 +165,12 @@ QemuFwCfgInitialize (
mFwCfgSelectorAddress = FwCfgSelectorAddress;
mFwCfgDataAddress = FwCfgDataAddress;
- DEBUG ((DEBUG_INFO, "Found FwCfg @ 0x%Lx/0x%Lx\n", FwCfgSelectorAddress,
- FwCfgDataAddress));
+ DEBUG ((
+ DEBUG_INFO,
+ "Found FwCfg @ 0x%Lx/0x%Lx\n",
+ FwCfgSelectorAddress,
+ FwCfgDataAddress
+ ));
if (SwapBytes64 (Reg[1]) >= 0x18) {
FwCfgDmaAddress = FwCfgDataAddress + 0x10;
@@ -174,7 +187,7 @@ QemuFwCfgInitialize (
}
if (QemuFwCfgIsAvailable ()) {
- UINT32 Signature;
+ UINT32 Signature;
QemuFwCfgSelectItem (QemuFwCfgItemSignature);
Signature = QemuFwCfgRead32 ();
@@ -184,15 +197,15 @@ QemuFwCfgInitialize (
// feature bitmap (which we read without DMA) to confirm the feature.
//
if (FwCfgDmaAddress != 0) {
- UINT32 Features;
+ UINT32 Features;
QemuFwCfgSelectItem (QemuFwCfgItemInterfaceVersion);
Features = QemuFwCfgRead32 ();
if ((Features & FW_CFG_F_DMA) != 0) {
- mFwCfgDmaAddress = FwCfgDmaAddress;
- InternalQemuFwCfgReadBytes = DmaReadBytes;
+ mFwCfgDmaAddress = FwCfgDmaAddress;
+ InternalQemuFwCfgReadBytes = DmaReadBytes;
InternalQemuFwCfgWriteBytes = DmaWriteBytes;
- InternalQemuFwCfgSkipBytes = DmaSkipBytes;
+ InternalQemuFwCfgSkipBytes = DmaSkipBytes;
}
}
} else {
@@ -200,10 +213,10 @@ QemuFwCfgInitialize (
mFwCfgDataAddress = 0;
}
}
+
return RETURN_SUCCESS;
}
-
/**
Selects a firmware configuration item for reading.
@@ -216,7 +229,7 @@ QemuFwCfgInitialize (
VOID
EFIAPI
QemuFwCfgSelectItem (
- IN FIRMWARE_CONFIG_ITEM QemuFwCfgItem
+ IN FIRMWARE_CONFIG_ITEM QemuFwCfgItem
)
{
if (QemuFwCfgIsAvailable ()) {
@@ -224,7 +237,6 @@ QemuFwCfgSelectItem (
}
}
-
/**
Slow READ_BYTES_FUNCTION.
**/
@@ -232,50 +244,53 @@ STATIC
VOID
EFIAPI
MmioReadBytes (
- IN UINTN Size,
- IN VOID *Buffer OPTIONAL
+ IN UINTN Size,
+ IN VOID *Buffer OPTIONAL
)
{
- UINTN Left;
- UINT8 *Ptr;
- UINT8 *End;
+ UINTN Left;
+ UINT8 *Ptr;
+ UINT8 *End;
-#if defined(MDE_CPU_AARCH64) || defined(MDE_CPU_RISCV64)
+ #if defined (MDE_CPU_AARCH64) || defined (MDE_CPU_RISCV64)
Left = Size & 7;
-#else
+ #else
Left = Size & 3;
-#endif
+ #endif
Size -= Left;
- Ptr = Buffer;
- End = Ptr + Size;
+ Ptr = Buffer;
+ End = Ptr + Size;
-#if defined(MDE_CPU_AARCH64) || defined(MDE_CPU_RISCV64)
+ #if defined (MDE_CPU_AARCH64) || defined (MDE_CPU_RISCV64)
while (Ptr < End) {
*(UINT64 *)Ptr = MmioRead64 (mFwCfgDataAddress);
- Ptr += 8;
+ Ptr += 8;
}
+
if (Left & 4) {
*(UINT32 *)Ptr = MmioRead32 (mFwCfgDataAddress);
- Ptr += 4;
+ Ptr += 4;
}
-#else
+
+ #else
while (Ptr < End) {
*(UINT32 *)Ptr = MmioRead32 (mFwCfgDataAddress);
- Ptr += 4;
+ Ptr += 4;
}
-#endif
+
+ #endif
if (Left & 2) {
*(UINT16 *)Ptr = MmioRead16 (mFwCfgDataAddress);
- Ptr += 2;
+ Ptr += 2;
}
+
if (Left & 1) {
*Ptr = MmioRead8 (mFwCfgDataAddress);
}
}
-
/**
Transfer an array of bytes, or skip a number of bytes, using the DMA
interface.
@@ -294,16 +309,18 @@ MmioReadBytes (
STATIC
VOID
DmaTransferBytes (
- IN UINTN Size,
- IN OUT VOID *Buffer OPTIONAL,
- IN UINT32 Control
+ IN UINTN Size,
+ IN OUT VOID *Buffer OPTIONAL,
+ IN UINT32 Control
)
{
- volatile FW_CFG_DMA_ACCESS Access;
- UINT32 Status;
+ volatile FW_CFG_DMA_ACCESS Access;
+ UINT32 Status;
- ASSERT (Control == FW_CFG_DMA_CTL_WRITE || Control == FW_CFG_DMA_CTL_READ ||
- Control == FW_CFG_DMA_CTL_SKIP);
+ ASSERT (
+ Control == FW_CFG_DMA_CTL_WRITE || Control == FW_CFG_DMA_CTL_READ ||
+ Control == FW_CFG_DMA_CTL_SKIP
+ );
if (Size == 0) {
return;
@@ -323,11 +340,11 @@ DmaTransferBytes (
//
// This will fire off the transfer.
//
-#if defined(MDE_CPU_AARCH64) || defined(MDE_CPU_RISCV64)
+ #if defined (MDE_CPU_AARCH64) || defined (MDE_CPU_RISCV64)
MmioWrite64 (mFwCfgDmaAddress, SwapBytes64 ((UINT64)&Access));
-#else
+ #else
MmioWrite32 ((UINT32)(mFwCfgDmaAddress + 4), SwapBytes32 ((UINT32)&Access));
-#endif
+ #endif
//
// We shouldn't look at Access.Control before starting the transfer.
@@ -345,7 +362,6 @@ DmaTransferBytes (
MemoryFence ();
}
-
/**
Fast READ_BYTES_FUNCTION.
**/
@@ -353,14 +369,13 @@ STATIC
VOID
EFIAPI
DmaReadBytes (
- IN UINTN Size,
- IN VOID *Buffer OPTIONAL
+ IN UINTN Size,
+ IN VOID *Buffer OPTIONAL
)
{
DmaTransferBytes (Size, Buffer, FW_CFG_DMA_CTL_READ);
}
-
/**
Reads firmware configuration bytes into a buffer
@@ -374,8 +389,8 @@ DmaReadBytes (
VOID
EFIAPI
QemuFwCfgReadBytes (
- IN UINTN Size,
- IN VOID *Buffer
+ IN UINTN Size,
+ IN VOID *Buffer
)
{
if (QemuFwCfgIsAvailable ()) {
@@ -385,7 +400,6 @@ QemuFwCfgReadBytes (
}
}
-
/**
Slow WRITE_BYTES_FUNCTION.
**/
@@ -393,18 +407,17 @@ STATIC
VOID
EFIAPI
MmioWriteBytes (
- IN UINTN Size,
- IN VOID *Buffer OPTIONAL
+ IN UINTN Size,
+ IN VOID *Buffer OPTIONAL
)
{
- UINTN Idx;
+ UINTN Idx;
for (Idx = 0; Idx < Size; ++Idx) {
MmioWrite8 (mFwCfgDataAddress, ((UINT8 *)Buffer)[Idx]);
}
}
-
/**
Fast WRITE_BYTES_FUNCTION.
**/
@@ -412,14 +425,13 @@ STATIC
VOID
EFIAPI
DmaWriteBytes (
- IN UINTN Size,
- IN VOID *Buffer OPTIONAL
+ IN UINTN Size,
+ IN VOID *Buffer OPTIONAL
)
{
DmaTransferBytes (Size, Buffer, FW_CFG_DMA_CTL_WRITE);
}
-
/**
Write firmware configuration bytes from a buffer
@@ -433,8 +445,8 @@ DmaWriteBytes (
VOID
EFIAPI
QemuFwCfgWriteBytes (
- IN UINTN Size,
- IN VOID *Buffer
+ IN UINTN Size,
+ IN VOID *Buffer
)
{
if (QemuFwCfgIsAvailable ()) {
@@ -442,7 +454,6 @@ QemuFwCfgWriteBytes (
}
}
-
/**
Slow SKIP_BYTES_FUNCTION.
**/
@@ -450,11 +461,11 @@ STATIC
VOID
EFIAPI
MmioSkipBytes (
- IN UINTN Size
+ IN UINTN Size
)
{
- UINTN ChunkSize;
- UINT8 SkipBuffer[256];
+ UINTN ChunkSize;
+ UINT8 SkipBuffer[256];
//
// Emulate the skip by reading data in chunks, and throwing it away. The
@@ -470,7 +481,6 @@ MmioSkipBytes (
}
}
-
/**
Fast SKIP_BYTES_FUNCTION.
**/
@@ -478,13 +488,12 @@ STATIC
VOID
EFIAPI
DmaSkipBytes (
- IN UINTN Size
+ IN UINTN Size
)
{
DmaTransferBytes (Size, NULL, FW_CFG_DMA_CTL_SKIP);
}
-
/**
Skip bytes in the firmware configuration item.
@@ -497,7 +506,7 @@ DmaSkipBytes (
VOID
EFIAPI
QemuFwCfgSkipBytes (
- IN UINTN Size
+ IN UINTN Size
)
{
if (QemuFwCfgIsAvailable ()) {
@@ -505,7 +514,6 @@ QemuFwCfgSkipBytes (
}
}
-
/**
Reads a UINT8 firmware configuration value
@@ -518,13 +526,12 @@ QemuFwCfgRead8 (
VOID
)
{
- UINT8 Result;
+ UINT8 Result;
QemuFwCfgReadBytes (sizeof Result, &Result);
return Result;
}
-
/**
Reads a UINT16 firmware configuration value
@@ -537,13 +544,12 @@ QemuFwCfgRead16 (
VOID
)
{
- UINT16 Result;
+ UINT16 Result;
QemuFwCfgReadBytes (sizeof Result, &Result);
return Result;
}
-
/**
Reads a UINT32 firmware configuration value
@@ -556,13 +562,12 @@ QemuFwCfgRead32 (
VOID
)
{
- UINT32 Result;
+ UINT32 Result;
QemuFwCfgReadBytes (sizeof Result, &Result);
return Result;
}
-
/**
Reads a UINT64 firmware configuration value
@@ -575,13 +580,12 @@ QemuFwCfgRead64 (
VOID
)
{
- UINT64 Result;
+ UINT64 Result;
QemuFwCfgReadBytes (sizeof Result, &Result);
return Result;
}
-
/**
Find the configuration item corresponding to the firmware configuration file.
@@ -603,8 +607,8 @@ QemuFwCfgFindFile (
OUT UINTN *Size
)
{
- UINT32 Count;
- UINT32 Idx;
+ UINT32 Count;
+ UINT32 Idx;
if (!QemuFwCfgIsAvailable ()) {
return RETURN_UNSUPPORTED;
@@ -614,9 +618,9 @@ QemuFwCfgFindFile (
Count = SwapBytes32 (QemuFwCfgRead32 ());
for (Idx = 0; Idx < Count; ++Idx) {
- UINT32 FileSize;
- UINT16 FileSelect;
- CHAR8 FName[QEMU_FW_CFG_FNAME_SIZE];
+ UINT32 FileSize;
+ UINT16 FileSelect;
+ CHAR8 FName[QEMU_FW_CFG_FNAME_SIZE];
FileSize = QemuFwCfgRead32 ();
FileSelect = QemuFwCfgRead16 ();
@@ -624,7 +628,7 @@ QemuFwCfgFindFile (
InternalQemuFwCfgReadBytes (sizeof (FName), FName);
if (AsciiStrCmp (Name, FName) == 0) {
- *Item = (FIRMWARE_CONFIG_ITEM) SwapBytes16 (FileSelect);
+ *Item = (FIRMWARE_CONFIG_ITEM)SwapBytes16 (FileSelect);
*Size = SwapBytes32 (FileSize);
return RETURN_SUCCESS;
}
diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgNull.c b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgNull.c
index edd97db49d..6a85ed65a0 100644
--- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgNull.c
+++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgNull.c
@@ -32,7 +32,6 @@ QemuFwCfgIsAvailable (
return FALSE;
}
-
/**
Selects a firmware configuration item for reading.
@@ -45,13 +44,12 @@ QemuFwCfgIsAvailable (
VOID
EFIAPI
QemuFwCfgSelectItem (
- IN FIRMWARE_CONFIG_ITEM QemuFwCfgItem
+ IN FIRMWARE_CONFIG_ITEM QemuFwCfgItem
)
{
ASSERT (FALSE);
}
-
/**
Reads firmware configuration bytes into a buffer
@@ -66,14 +64,13 @@ QemuFwCfgSelectItem (
VOID
EFIAPI
QemuFwCfgReadBytes (
- IN UINTN Size,
- IN VOID *Buffer OPTIONAL
+ IN UINTN Size,
+ IN VOID *Buffer OPTIONAL
)
{
ASSERT (FALSE);
}
-
/**
Writes firmware configuration bytes from a buffer
@@ -88,14 +85,13 @@ QemuFwCfgReadBytes (
VOID
EFIAPI
QemuFwCfgWriteBytes (
- IN UINTN Size,
- IN VOID *Buffer
+ IN UINTN Size,
+ IN VOID *Buffer
)
{
ASSERT (FALSE);
}
-
/**
Skip bytes in the firmware configuration item.
@@ -108,13 +104,12 @@ QemuFwCfgWriteBytes (
VOID
EFIAPI
QemuFwCfgSkipBytes (
- IN UINTN Size
+ IN UINTN Size
)
{
ASSERT (FALSE);
}
-
/**
Reads a UINT8 firmware configuration value
@@ -131,7 +126,6 @@ QemuFwCfgRead8 (
return 0;
}
-
/**
Reads a UINT16 firmware configuration value
@@ -148,7 +142,6 @@ QemuFwCfgRead16 (
return 0;
}
-
/**
Reads a UINT32 firmware configuration value
@@ -165,7 +158,6 @@ QemuFwCfgRead32 (
return 0;
}
-
/**
Reads a UINT64 firmware configuration value
@@ -182,7 +174,6 @@ QemuFwCfgRead64 (
return 0;
}
-
/**
Find the configuration item corresponding to the firmware configuration file.
@@ -206,4 +197,3 @@ QemuFwCfgFindFile (
{
return RETURN_UNSUPPORTED;
}
-
diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c
index ecabd88fab..f696fb7cac 100644
--- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c
+++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c
@@ -17,9 +17,8 @@
#include "QemuFwCfgLibInternal.h"
-STATIC BOOLEAN mQemuFwCfgSupported = FALSE;
-STATIC BOOLEAN mQemuFwCfgDmaSupported;
-
+STATIC BOOLEAN mQemuFwCfgSupported = FALSE;
+STATIC BOOLEAN mQemuFwCfgDmaSupported;
/**
Returns a boolean indicating if the firmware configuration interface
@@ -40,21 +39,20 @@ QemuFwCfgIsAvailable (
return InternalQemuFwCfgIsAvailable ();
}
-
RETURN_STATUS
EFIAPI
QemuFwCfgInitialize (
VOID
)
{
- UINT32 Signature;
- UINT32 Revision;
+ UINT32 Signature;
+ UINT32 Revision;
//
// Enable the access routines while probing to see if it is supported.
// For probing we always use the IO Port (IoReadFifo8()) access method.
//
- mQemuFwCfgSupported = TRUE;
+ mQemuFwCfgSupported = TRUE;
mQemuFwCfgDmaSupported = FALSE;
QemuFwCfgSelectItem (QemuFwCfgItemSignature);
@@ -65,7 +63,8 @@ QemuFwCfgInitialize (
DEBUG ((DEBUG_INFO, "FW CFG Revision: 0x%x\n", Revision));
if ((Signature != SIGNATURE_32 ('Q', 'E', 'M', 'U')) ||
(Revision < 1)
- ) {
+ )
+ {
DEBUG ((DEBUG_INFO, "QemuFwCfg interface not supported.\n"));
mQemuFwCfgSupported = FALSE;
return RETURN_SUCCESS;
@@ -87,10 +86,10 @@ QemuFwCfgInitialize (
DEBUG ((DEBUG_INFO, "QemuFwCfg interface (DMA) is supported.\n"));
}
}
+
return RETURN_SUCCESS;
}
-
/**
Returns a boolean indicating if the firmware configuration interface is
available for library-internal purposes.
@@ -140,17 +139,19 @@ InternalQemuFwCfgDmaIsAvailable (
**/
VOID
InternalQemuFwCfgDmaBytes (
- IN UINT32 Size,
- IN OUT VOID *Buffer OPTIONAL,
- IN UINT32 Control
+ IN UINT32 Size,
+ IN OUT VOID *Buffer OPTIONAL,
+ IN UINT32 Control
)
{
- volatile FW_CFG_DMA_ACCESS Access;
- UINT32 AccessHigh, AccessLow;
- UINT32 Status;
+ volatile FW_CFG_DMA_ACCESS Access;
+ UINT32 AccessHigh, AccessLow;
+ UINT32 Status;
- ASSERT (Control == FW_CFG_DMA_CTL_WRITE || Control == FW_CFG_DMA_CTL_READ ||
- Control == FW_CFG_DMA_CTL_SKIP);
+ ASSERT (
+ Control == FW_CFG_DMA_CTL_WRITE || Control == FW_CFG_DMA_CTL_READ ||
+ Control == FW_CFG_DMA_CTL_SKIP
+ );
if (Size == 0) {
return;
@@ -177,7 +178,7 @@ InternalQemuFwCfgDmaBytes (
//
AccessHigh = (UINT32)RShiftU64 ((UINTN)&Access, 32);
AccessLow = (UINT32)(UINTN)&Access;
- IoWrite32 (FW_CFG_IO_DMA_ADDRESS, SwapBytes32 (AccessHigh));
+ IoWrite32 (FW_CFG_IO_DMA_ADDRESS, SwapBytes32 (AccessHigh));
IoWrite32 (FW_CFG_IO_DMA_ADDRESS + 4, SwapBytes32 (AccessLow));
//
@@ -198,4 +199,3 @@ InternalQemuFwCfgDmaBytes (
//
MemoryFence ();
}
-
diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSec.c b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSec.c
index 94e8e92180..63cfee9347 100644
--- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSec.c
+++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSec.c
@@ -33,8 +33,8 @@ QemuFwCfgIsAvailable (
VOID
)
{
- UINT32 Signature;
- UINT32 Revision;
+ UINT32 Signature;
+ UINT32 Revision;
QemuFwCfgSelectItem (QemuFwCfgItemSignature);
Signature = QemuFwCfgRead32 ();
@@ -44,7 +44,8 @@ QemuFwCfgIsAvailable (
DEBUG ((DEBUG_INFO, "FW CFG Revision: 0x%x\n", Revision));
if ((Signature != SIGNATURE_32 ('Q', 'E', 'M', 'U')) ||
(Revision < 1)
- ) {
+ )
+ {
DEBUG ((DEBUG_INFO, "QemuFwCfg interface not supported.\n"));
return FALSE;
}
@@ -53,7 +54,6 @@ QemuFwCfgIsAvailable (
return TRUE;
}
-
/**
Returns a boolean indicating if the firmware configuration interface is
available for library-internal purposes.
@@ -108,9 +108,9 @@ InternalQemuFwCfgDmaIsAvailable (
**/
VOID
InternalQemuFwCfgDmaBytes (
- IN UINT32 Size,
- IN OUT VOID *Buffer OPTIONAL,
- IN UINT32 Control
+ IN UINT32 Size,
+ IN OUT VOID *Buffer OPTIONAL,
+ IN UINT32 Control
)
{
//
diff --git a/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3Base.c b/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3Base.c
index aad359d83d..b0356a2e25 100644
--- a/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3Base.c
+++ b/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3Base.c
@@ -33,7 +33,6 @@ QemuFwCfgS3Enabled (
return FALSE;
}
-
/**
Install the client module's FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION callback for
when the production of ACPI S3 Boot Script opcodes becomes possible.
@@ -91,13 +90,12 @@ QemuFwCfgS3Enabled (
@return Error codes from underlying functions.
**/
-
RETURN_STATUS
EFIAPI
QemuFwCfgS3CallWhenBootScriptReady (
- IN FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION *Callback,
- IN OUT VOID *Context OPTIONAL,
- IN UINTN ScratchBufferSize
+ IN FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION *Callback,
+ IN OUT VOID *Context OPTIONAL,
+ IN UINTN ScratchBufferSize
)
{
ASSERT (FALSE);
diff --git a/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3BasePei.c b/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3BasePei.c
index 3ec6209ba4..3c1b28ba2b 100644
--- a/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3BasePei.c
+++ b/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3BasePei.c
@@ -53,15 +53,14 @@
RETURN_STATUS
EFIAPI
QemuFwCfgS3ScriptWriteBytes (
- IN INT32 FirmwareConfigItem,
- IN UINTN NumberOfBytes
+ IN INT32 FirmwareConfigItem,
+ IN UINTN NumberOfBytes
)
{
ASSERT (FALSE);
return RETURN_UNSUPPORTED;
}
-
/**
Produce ACPI S3 Boot Script opcodes that (optionally) select an fw_cfg item,
and transfer data from it.
@@ -104,15 +103,14 @@ QemuFwCfgS3ScriptWriteBytes (
RETURN_STATUS
EFIAPI
QemuFwCfgS3ScriptReadBytes (
- IN INT32 FirmwareConfigItem,
- IN UINTN NumberOfBytes
+ IN INT32 FirmwareConfigItem,
+ IN UINTN NumberOfBytes
)
{
ASSERT (FALSE);
return RETURN_UNSUPPORTED;
}
-
/**
Produce ACPI S3 Boot Script opcodes that (optionally) select an fw_cfg item,
and increase its offset.
@@ -148,15 +146,14 @@ QemuFwCfgS3ScriptReadBytes (
RETURN_STATUS
EFIAPI
QemuFwCfgS3ScriptSkipBytes (
- IN INT32 FirmwareConfigItem,
- IN UINTN NumberOfBytes
+ IN INT32 FirmwareConfigItem,
+ IN UINTN NumberOfBytes
)
{
ASSERT (FALSE);
return RETURN_UNSUPPORTED;
}
-
/**
Produce ACPI S3 Boot Script opcodes that check a value in ScratchBuffer.
@@ -210,10 +207,10 @@ QemuFwCfgS3ScriptSkipBytes (
RETURN_STATUS
EFIAPI
QemuFwCfgS3ScriptCheckValue (
- IN VOID *ScratchData,
- IN UINT8 ValueSize,
- IN UINT64 ValueMask,
- IN UINT64 Value
+ IN VOID *ScratchData,
+ IN UINT8 ValueSize,
+ IN UINT64 ValueMask,
+ IN UINT64 Value
)
{
ASSERT (FALSE);
diff --git a/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3Dxe.c b/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3Dxe.c
index 4dcf4b1298..5706fa9be4 100644
--- a/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3Dxe.c
+++ b/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3Dxe.c
@@ -14,34 +14,32 @@
#include <Library/UefiBootServicesTableLib.h>
#include <Protocol/S3SaveState.h>
-
//
// Event to signal when the S3SaveState protocol interface is installed.
//
-STATIC EFI_EVENT mS3SaveStateInstalledEvent;
+STATIC EFI_EVENT mS3SaveStateInstalledEvent;
//
// Reference to the S3SaveState protocol interface, after it is installed.
//
-STATIC EFI_S3_SAVE_STATE_PROTOCOL *mS3SaveState;
+STATIC EFI_S3_SAVE_STATE_PROTOCOL *mS3SaveState;
//
// The control structure is allocated in reserved memory, aligned at 8 bytes.
// The client-requested ScratchBuffer will be allocated adjacently, also
// aligned at 8 bytes.
//
-#define RESERVED_MEM_ALIGNMENT 8
+#define RESERVED_MEM_ALIGNMENT 8
-STATIC FW_CFG_DMA_ACCESS *mDmaAccess;
-STATIC VOID *mScratchBuffer;
-STATIC UINTN mScratchBufferSize;
+STATIC FW_CFG_DMA_ACCESS *mDmaAccess;
+STATIC VOID *mScratchBuffer;
+STATIC UINTN mScratchBufferSize;
//
// Callback provided by the client, for appending ACPI S3 Boot Script opcodes.
// To be called from S3SaveStateInstalledNotify().
//
-STATIC FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION *mCallback;
-
+STATIC FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION *mCallback;
/**
Event notification function for mS3SaveStateInstalledEvent.
@@ -50,32 +48,40 @@ STATIC
VOID
EFIAPI
S3SaveStateInstalledNotify (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
ASSERT (Event == mS3SaveStateInstalledEvent);
- Status = gBS->LocateProtocol (&gEfiS3SaveStateProtocolGuid,
- NULL /* Registration */, (VOID **)&mS3SaveState);
+ Status = gBS->LocateProtocol (
+ &gEfiS3SaveStateProtocolGuid,
+ NULL /* Registration */,
+ (VOID **)&mS3SaveState
+ );
if (EFI_ERROR (Status)) {
return;
}
ASSERT (mCallback != NULL);
- DEBUG ((DEBUG_INFO, "%a: %a: DmaAccess@0x%Lx ScratchBuffer@[0x%Lx+0x%Lx]\n",
- gEfiCallerBaseName, __FUNCTION__, (UINT64)(UINTN)mDmaAccess,
- (UINT64)(UINTN)mScratchBuffer, (UINT64)mScratchBufferSize));
+ DEBUG ((
+ DEBUG_INFO,
+ "%a: %a: DmaAccess@0x%Lx ScratchBuffer@[0x%Lx+0x%Lx]\n",
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ (UINT64)(UINTN)mDmaAccess,
+ (UINT64)(UINTN)mScratchBuffer,
+ (UINT64)mScratchBufferSize
+ ));
mCallback (Context, mScratchBuffer);
gBS->CloseEvent (mS3SaveStateInstalledEvent);
mS3SaveStateInstalledEvent = NULL;
}
-
/**
Install the client module's FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION callback for
when the production of ACPI S3 Boot Script opcodes becomes possible.
@@ -136,13 +142,13 @@ S3SaveStateInstalledNotify (
RETURN_STATUS
EFIAPI
QemuFwCfgS3CallWhenBootScriptReady (
- IN FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION *Callback,
- IN OUT VOID *Context OPTIONAL,
- IN UINTN ScratchBufferSize
+ IN FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION *Callback,
+ IN OUT VOID *Context OPTIONAL,
+ IN UINTN ScratchBufferSize
)
{
- EFI_STATUS Status;
- VOID *Registration;
+ EFI_STATUS Status;
+ VOID *Registration;
//
// Basic fw_cfg is certainly available, as we can only be here after a
@@ -151,8 +157,12 @@ QemuFwCfgS3CallWhenBootScriptReady (
ASSERT (QemuFwCfgIsAvailable ());
QemuFwCfgSelectItem (QemuFwCfgItemInterfaceVersion);
if ((QemuFwCfgRead32 () & FW_CFG_F_DMA) == 0) {
- DEBUG ((DEBUG_ERROR, "%a: %a: fw_cfg DMA unavailable\n",
- gEfiCallerBaseName, __FUNCTION__));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: %a: fw_cfg DMA unavailable\n",
+ gEfiCallerBaseName,
+ __FUNCTION__
+ ));
return RETURN_NOT_FOUND;
}
@@ -161,37 +171,69 @@ QemuFwCfgS3CallWhenBootScriptReady (
// client data together.
//
if (ScratchBufferSize >
- MAX_UINT32 - (RESERVED_MEM_ALIGNMENT - 1) - sizeof *mDmaAccess) {
- DEBUG ((DEBUG_ERROR, "%a: %a: ScratchBufferSize too big: %Lu\n",
- gEfiCallerBaseName, __FUNCTION__, (UINT64)ScratchBufferSize));
+ MAX_UINT32 - (RESERVED_MEM_ALIGNMENT - 1) - sizeof *mDmaAccess)
+ {
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: %a: ScratchBufferSize too big: %Lu\n",
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ (UINT64)ScratchBufferSize
+ ));
return RETURN_BAD_BUFFER_SIZE;
}
- mDmaAccess = AllocateReservedPool ((RESERVED_MEM_ALIGNMENT - 1) +
- sizeof *mDmaAccess + ScratchBufferSize);
+
+ mDmaAccess = AllocateReservedPool (
+ (RESERVED_MEM_ALIGNMENT - 1) +
+ sizeof *mDmaAccess + ScratchBufferSize
+ );
if (mDmaAccess == NULL) {
- DEBUG ((DEBUG_ERROR, "%a: %a: AllocateReservedPool(): out of resources\n",
- gEfiCallerBaseName, __FUNCTION__));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: %a: AllocateReservedPool(): out of resources\n",
+ gEfiCallerBaseName,
+ __FUNCTION__
+ ));
return RETURN_OUT_OF_RESOURCES;
}
+
mDmaAccess = ALIGN_POINTER (mDmaAccess, RESERVED_MEM_ALIGNMENT);
//
// Set up a protocol notify for EFI_S3_SAVE_STATE_PROTOCOL. Forward the
// client's Context to the callback.
//
- Status = gBS->CreateEvent (EVT_NOTIFY_SIGNAL, TPL_CALLBACK,
- S3SaveStateInstalledNotify, Context,
- &mS3SaveStateInstalledEvent);
+ Status = gBS->CreateEvent (
+ EVT_NOTIFY_SIGNAL,
+ TPL_CALLBACK,
+ S3SaveStateInstalledNotify,
+ Context,
+ &mS3SaveStateInstalledEvent
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: %a: CreateEvent(): %r\n", gEfiCallerBaseName,
- __FUNCTION__, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: %a: CreateEvent(): %r\n",
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ Status
+ ));
goto FreeDmaAccess;
}
- Status = gBS->RegisterProtocolNotify (&gEfiS3SaveStateProtocolGuid,
- mS3SaveStateInstalledEvent, &Registration);
+
+ Status = gBS->RegisterProtocolNotify (
+ &gEfiS3SaveStateProtocolGuid,
+ mS3SaveStateInstalledEvent,
+ &Registration
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: %a: RegisterProtocolNotify(): %r\n",
- gEfiCallerBaseName, __FUNCTION__, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: %a: RegisterProtocolNotify(): %r\n",
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ Status
+ ));
goto CloseEvent;
}
@@ -201,26 +243,31 @@ QemuFwCfgS3CallWhenBootScriptReady (
// integral multiple of RESERVED_MEM_ALIGNMENT.
//
ASSERT (sizeof *mDmaAccess % RESERVED_MEM_ALIGNMENT == 0);
- mScratchBuffer = mDmaAccess + 1;
+ mScratchBuffer = mDmaAccess + 1;
mScratchBufferSize = ScratchBufferSize;
- mCallback = Callback;
+ mCallback = Callback;
//
// Kick the event; EFI_S3_SAVE_STATE_PROTOCOL could be available already.
//
Status = gBS->SignalEvent (mS3SaveStateInstalledEvent);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: %a: SignalEvent(): %r\n", gEfiCallerBaseName,
- __FUNCTION__, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: %a: SignalEvent(): %r\n",
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ Status
+ ));
goto NullGlobals;
}
return RETURN_SUCCESS;
NullGlobals:
- mScratchBuffer = NULL;
+ mScratchBuffer = NULL;
mScratchBufferSize = 0;
- mCallback = NULL;
+ mCallback = NULL;
CloseEvent:
gBS->CloseEvent (mS3SaveStateInstalledEvent);
@@ -233,7 +280,6 @@ FreeDmaAccess:
return (RETURN_STATUS)Status;
}
-
/**
Produce ACPI S3 Boot Script opcodes that (optionally) select an fw_cfg item,
and transfer data to it.
@@ -277,22 +323,23 @@ FreeDmaAccess:
RETURN_STATUS
EFIAPI
QemuFwCfgS3ScriptWriteBytes (
- IN INT32 FirmwareConfigItem,
- IN UINTN NumberOfBytes
+ IN INT32 FirmwareConfigItem,
+ IN UINTN NumberOfBytes
)
{
- UINTN Count;
- EFI_STATUS Status;
- UINT64 AccessAddress;
- UINT32 ControlPollData;
- UINT32 ControlPollMask;
+ UINTN Count;
+ EFI_STATUS Status;
+ UINT64 AccessAddress;
+ UINT32 ControlPollData;
+ UINT32 ControlPollMask;
ASSERT (mDmaAccess != NULL);
ASSERT (mS3SaveState != NULL);
- if (FirmwareConfigItem < -1 || FirmwareConfigItem > MAX_UINT16) {
+ if ((FirmwareConfigItem < -1) || (FirmwareConfigItem > MAX_UINT16)) {
return RETURN_INVALID_PARAMETER;
}
+
if (NumberOfBytes > mScratchBufferSize) {
return RETURN_BAD_BUFFER_SIZE;
}
@@ -305,6 +352,7 @@ QemuFwCfgS3ScriptWriteBytes (
mDmaAccess->Control |= FW_CFG_DMA_CTL_SELECT;
mDmaAccess->Control |= (UINT32)FirmwareConfigItem << 16;
}
+
mDmaAccess->Control = SwapBytes32 (mDmaAccess->Control);
//
@@ -321,7 +369,7 @@ QemuFwCfgS3ScriptWriteBytes (
// script. When executed at S3 resume, this opcode will restore all of them
// in-place.
//
- Count = (UINTN)mScratchBuffer + NumberOfBytes - (UINTN)mDmaAccess;
+ Count = (UINTN)mScratchBuffer + NumberOfBytes - (UINTN)mDmaAccess;
Status = mS3SaveState->Write (
mS3SaveState, // This
EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE, // OpCode
@@ -331,8 +379,13 @@ QemuFwCfgS3ScriptWriteBytes (
(VOID *)mDmaAccess // Buffer
);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: %a: EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE: %r\n",
- gEfiCallerBaseName, __FUNCTION__, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: %a: EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE: %r\n",
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ Status
+ ));
return (RETURN_STATUS)Status;
}
@@ -343,17 +396,22 @@ QemuFwCfgS3ScriptWriteBytes (
// transfer.
//
AccessAddress = SwapBytes64 ((UINTN)mDmaAccess);
- Status = mS3SaveState->Write (
- mS3SaveState, // This
- EFI_BOOT_SCRIPT_IO_WRITE_OPCODE, // OpCode
- EfiBootScriptWidthUint32, // Width
- (UINT64)FW_CFG_IO_DMA_ADDRESS, // Address
- (UINTN)2, // Count
- (VOID *)&AccessAddress // Buffer
- );
+ Status = mS3SaveState->Write (
+ mS3SaveState, // This
+ EFI_BOOT_SCRIPT_IO_WRITE_OPCODE, // OpCode
+ EfiBootScriptWidthUint32, // Width
+ (UINT64)FW_CFG_IO_DMA_ADDRESS, // Address
+ (UINTN)2, // Count
+ (VOID *)&AccessAddress // Buffer
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: %a: EFI_BOOT_SCRIPT_IO_WRITE_OPCODE: %r\n",
- gEfiCallerBaseName, __FUNCTION__, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: %a: EFI_BOOT_SCRIPT_IO_WRITE_OPCODE: %r\n",
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ Status
+ ));
return (RETURN_STATUS)Status;
}
@@ -364,25 +422,29 @@ QemuFwCfgS3ScriptWriteBytes (
//
ControlPollData = 0;
ControlPollMask = MAX_UINT32;
- Status = mS3SaveState->Write (
- mS3SaveState, // This
- EFI_BOOT_SCRIPT_MEM_POLL_OPCODE, // OpCode
- EfiBootScriptWidthUint32, // Width
- (UINT64)(UINTN)&mDmaAccess->Control, // Address
- (VOID *)&ControlPollData, // Data
- (VOID *)&ControlPollMask, // DataMask
- MAX_UINT64 // Delay
- );
+ Status = mS3SaveState->Write (
+ mS3SaveState, // This
+ EFI_BOOT_SCRIPT_MEM_POLL_OPCODE, // OpCode
+ EfiBootScriptWidthUint32, // Width
+ (UINT64)(UINTN)&mDmaAccess->Control, // Address
+ (VOID *)&ControlPollData, // Data
+ (VOID *)&ControlPollMask, // DataMask
+ MAX_UINT64 // Delay
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: %a: EFI_BOOT_SCRIPT_MEM_POLL_OPCODE: %r\n",
- gEfiCallerBaseName, __FUNCTION__, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: %a: EFI_BOOT_SCRIPT_MEM_POLL_OPCODE: %r\n",
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ Status
+ ));
return (RETURN_STATUS)Status;
}
return RETURN_SUCCESS;
}
-
/**
Produce ACPI S3 Boot Script opcodes that (optionally) select an fw_cfg item,
and transfer data from it.
@@ -425,21 +487,22 @@ QemuFwCfgS3ScriptWriteBytes (
RETURN_STATUS
EFIAPI
QemuFwCfgS3ScriptReadBytes (
- IN INT32 FirmwareConfigItem,
- IN UINTN NumberOfBytes
+ IN INT32 FirmwareConfigItem,
+ IN UINTN NumberOfBytes
)
{
- EFI_STATUS Status;
- UINT64 AccessAddress;
- UINT32 ControlPollData;
- UINT32 ControlPollMask;
+ EFI_STATUS Status;
+ UINT64 AccessAddress;
+ UINT32 ControlPollData;
+ UINT32 ControlPollMask;
ASSERT (mDmaAccess != NULL);
ASSERT (mS3SaveState != NULL);
- if (FirmwareConfigItem < -1 || FirmwareConfigItem > MAX_UINT16) {
+ if ((FirmwareConfigItem < -1) || (FirmwareConfigItem > MAX_UINT16)) {
return RETURN_INVALID_PARAMETER;
}
+
if (NumberOfBytes > mScratchBufferSize) {
return RETURN_BAD_BUFFER_SIZE;
}
@@ -452,6 +515,7 @@ QemuFwCfgS3ScriptReadBytes (
mDmaAccess->Control |= FW_CFG_DMA_CTL_SELECT;
mDmaAccess->Control |= (UINT32)FirmwareConfigItem << 16;
}
+
mDmaAccess->Control = SwapBytes32 (mDmaAccess->Control);
//
@@ -476,8 +540,13 @@ QemuFwCfgS3ScriptReadBytes (
(VOID *)mDmaAccess // Buffer
);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: %a: EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE: %r\n",
- gEfiCallerBaseName, __FUNCTION__, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: %a: EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE: %r\n",
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ Status
+ ));
return (RETURN_STATUS)Status;
}
@@ -488,17 +557,22 @@ QemuFwCfgS3ScriptReadBytes (
// transfer.
//
AccessAddress = SwapBytes64 ((UINTN)mDmaAccess);
- Status = mS3SaveState->Write (
- mS3SaveState, // This
- EFI_BOOT_SCRIPT_IO_WRITE_OPCODE, // OpCode
- EfiBootScriptWidthUint32, // Width
- (UINT64)FW_CFG_IO_DMA_ADDRESS, // Address
- (UINTN)2, // Count
- (VOID *)&AccessAddress // Buffer
- );
+ Status = mS3SaveState->Write (
+ mS3SaveState, // This
+ EFI_BOOT_SCRIPT_IO_WRITE_OPCODE, // OpCode
+ EfiBootScriptWidthUint32, // Width
+ (UINT64)FW_CFG_IO_DMA_ADDRESS, // Address
+ (UINTN)2, // Count
+ (VOID *)&AccessAddress // Buffer
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: %a: EFI_BOOT_SCRIPT_IO_WRITE_OPCODE: %r\n",
- gEfiCallerBaseName, __FUNCTION__, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: %a: EFI_BOOT_SCRIPT_IO_WRITE_OPCODE: %r\n",
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ Status
+ ));
return (RETURN_STATUS)Status;
}
@@ -509,25 +583,29 @@ QemuFwCfgS3ScriptReadBytes (
//
ControlPollData = 0;
ControlPollMask = MAX_UINT32;
- Status = mS3SaveState->Write (
- mS3SaveState, // This
- EFI_BOOT_SCRIPT_MEM_POLL_OPCODE, // OpCode
- EfiBootScriptWidthUint32, // Width
- (UINT64)(UINTN)&mDmaAccess->Control, // Address
- (VOID *)&ControlPollData, // Data
- (VOID *)&ControlPollMask, // DataMask
- MAX_UINT64 // Delay
- );
+ Status = mS3SaveState->Write (
+ mS3SaveState, // This
+ EFI_BOOT_SCRIPT_MEM_POLL_OPCODE, // OpCode
+ EfiBootScriptWidthUint32, // Width
+ (UINT64)(UINTN)&mDmaAccess->Control, // Address
+ (VOID *)&ControlPollData, // Data
+ (VOID *)&ControlPollMask, // DataMask
+ MAX_UINT64 // Delay
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: %a: EFI_BOOT_SCRIPT_MEM_POLL_OPCODE: %r\n",
- gEfiCallerBaseName, __FUNCTION__, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: %a: EFI_BOOT_SCRIPT_MEM_POLL_OPCODE: %r\n",
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ Status
+ ));
return (RETURN_STATUS)Status;
}
return RETURN_SUCCESS;
}
-
/**
Produce ACPI S3 Boot Script opcodes that (optionally) select an fw_cfg item,
and increase its offset.
@@ -563,21 +641,22 @@ QemuFwCfgS3ScriptReadBytes (
RETURN_STATUS
EFIAPI
QemuFwCfgS3ScriptSkipBytes (
- IN INT32 FirmwareConfigItem,
- IN UINTN NumberOfBytes
+ IN INT32 FirmwareConfigItem,
+ IN UINTN NumberOfBytes
)
{
- EFI_STATUS Status;
- UINT64 AccessAddress;
- UINT32 ControlPollData;
- UINT32 ControlPollMask;
+ EFI_STATUS Status;
+ UINT64 AccessAddress;
+ UINT32 ControlPollData;
+ UINT32 ControlPollMask;
ASSERT (mDmaAccess != NULL);
ASSERT (mS3SaveState != NULL);
- if (FirmwareConfigItem < -1 || FirmwareConfigItem > MAX_UINT16) {
+ if ((FirmwareConfigItem < -1) || (FirmwareConfigItem > MAX_UINT16)) {
return RETURN_INVALID_PARAMETER;
}
+
if (NumberOfBytes > MAX_UINT32) {
return RETURN_BAD_BUFFER_SIZE;
}
@@ -590,9 +669,10 @@ QemuFwCfgS3ScriptSkipBytes (
mDmaAccess->Control |= FW_CFG_DMA_CTL_SELECT;
mDmaAccess->Control |= (UINT32)FirmwareConfigItem << 16;
}
+
mDmaAccess->Control = SwapBytes32 (mDmaAccess->Control);
- mDmaAccess->Length = SwapBytes32 ((UINT32)NumberOfBytes);
+ mDmaAccess->Length = SwapBytes32 ((UINT32)NumberOfBytes);
mDmaAccess->Address = 0;
//
@@ -608,8 +688,13 @@ QemuFwCfgS3ScriptSkipBytes (
(VOID *)mDmaAccess // Buffer
);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: %a: EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE: %r\n",
- gEfiCallerBaseName, __FUNCTION__, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: %a: EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE: %r\n",
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ Status
+ ));
return (RETURN_STATUS)Status;
}
@@ -620,17 +705,22 @@ QemuFwCfgS3ScriptSkipBytes (
// transfer.
//
AccessAddress = SwapBytes64 ((UINTN)mDmaAccess);
- Status = mS3SaveState->Write (
- mS3SaveState, // This
- EFI_BOOT_SCRIPT_IO_WRITE_OPCODE, // OpCode
- EfiBootScriptWidthUint32, // Width
- (UINT64)FW_CFG_IO_DMA_ADDRESS, // Address
- (UINTN)2, // Count
- (VOID *)&AccessAddress // Buffer
- );
+ Status = mS3SaveState->Write (
+ mS3SaveState, // This
+ EFI_BOOT_SCRIPT_IO_WRITE_OPCODE, // OpCode
+ EfiBootScriptWidthUint32, // Width
+ (UINT64)FW_CFG_IO_DMA_ADDRESS, // Address
+ (UINTN)2, // Count
+ (VOID *)&AccessAddress // Buffer
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: %a: EFI_BOOT_SCRIPT_IO_WRITE_OPCODE: %r\n",
- gEfiCallerBaseName, __FUNCTION__, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: %a: EFI_BOOT_SCRIPT_IO_WRITE_OPCODE: %r\n",
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ Status
+ ));
return (RETURN_STATUS)Status;
}
@@ -641,25 +731,29 @@ QemuFwCfgS3ScriptSkipBytes (
//
ControlPollData = 0;
ControlPollMask = MAX_UINT32;
- Status = mS3SaveState->Write (
- mS3SaveState, // This
- EFI_BOOT_SCRIPT_MEM_POLL_OPCODE, // OpCode
- EfiBootScriptWidthUint32, // Width
- (UINT64)(UINTN)&mDmaAccess->Control, // Address
- (VOID *)&ControlPollData, // Data
- (VOID *)&ControlPollMask, // DataMask
- MAX_UINT64 // Delay
- );
+ Status = mS3SaveState->Write (
+ mS3SaveState, // This
+ EFI_BOOT_SCRIPT_MEM_POLL_OPCODE, // OpCode
+ EfiBootScriptWidthUint32, // Width
+ (UINT64)(UINTN)&mDmaAccess->Control, // Address
+ (VOID *)&ControlPollData, // Data
+ (VOID *)&ControlPollMask, // DataMask
+ MAX_UINT64 // Delay
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: %a: EFI_BOOT_SCRIPT_MEM_POLL_OPCODE: %r\n",
- gEfiCallerBaseName, __FUNCTION__, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: %a: EFI_BOOT_SCRIPT_MEM_POLL_OPCODE: %r\n",
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ Status
+ ));
return (RETURN_STATUS)Status;
}
return RETURN_SUCCESS;
}
-
/**
Produce ACPI S3 Boot Script opcodes that check a value in ScratchBuffer.
@@ -713,41 +807,42 @@ QemuFwCfgS3ScriptSkipBytes (
RETURN_STATUS
EFIAPI
QemuFwCfgS3ScriptCheckValue (
- IN VOID *ScratchData,
- IN UINT8 ValueSize,
- IN UINT64 ValueMask,
- IN UINT64 Value
+ IN VOID *ScratchData,
+ IN UINT8 ValueSize,
+ IN UINT64 ValueMask,
+ IN UINT64 Value
)
{
- EFI_BOOT_SCRIPT_WIDTH Width;
- EFI_STATUS Status;
+ EFI_BOOT_SCRIPT_WIDTH Width;
+ EFI_STATUS Status;
ASSERT (mS3SaveState != NULL);
switch (ValueSize) {
- case 1:
- Width = EfiBootScriptWidthUint8;
- break;
+ case 1:
+ Width = EfiBootScriptWidthUint8;
+ break;
- case 2:
- Width = EfiBootScriptWidthUint16;
- break;
+ case 2:
+ Width = EfiBootScriptWidthUint16;
+ break;
- case 4:
- Width = EfiBootScriptWidthUint32;
- break;
+ case 4:
+ Width = EfiBootScriptWidthUint32;
+ break;
- case 8:
- Width = EfiBootScriptWidthUint64;
- break;
+ case 8:
+ Width = EfiBootScriptWidthUint64;
+ break;
- default:
- return RETURN_INVALID_PARAMETER;
+ default:
+ return RETURN_INVALID_PARAMETER;
}
- if (ValueSize < 8 &&
- (RShiftU64 (ValueMask, ValueSize * 8) > 0 ||
- RShiftU64 (Value, ValueSize * 8) > 0)) {
+ if ((ValueSize < 8) &&
+ ((RShiftU64 (ValueMask, ValueSize * 8) > 0) ||
+ (RShiftU64 (Value, ValueSize * 8) > 0)))
+ {
return RETURN_INVALID_PARAMETER;
}
@@ -758,7 +853,8 @@ QemuFwCfgS3ScriptCheckValue (
if (((UINTN)ScratchData < (UINTN)mScratchBuffer) ||
((UINTN)ScratchData > MAX_UINTN - ValueSize) ||
((UINTN)ScratchData + ValueSize >
- (UINTN)mScratchBuffer + mScratchBufferSize)) {
+ (UINTN)mScratchBuffer + mScratchBufferSize))
+ {
return RETURN_BAD_BUFFER_SIZE;
}
@@ -777,8 +873,13 @@ QemuFwCfgS3ScriptCheckValue (
MAX_UINT64 // Delay
);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: %a: EFI_BOOT_SCRIPT_MEM_POLL_OPCODE: %r\n",
- gEfiCallerBaseName, __FUNCTION__, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: %a: EFI_BOOT_SCRIPT_MEM_POLL_OPCODE: %r\n",
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ Status
+ ));
return (RETURN_STATUS)Status;
}
diff --git a/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3Pei.c b/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3Pei.c
index bf1accd946..78a8f15442 100644
--- a/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3Pei.c
+++ b/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3Pei.c
@@ -71,9 +71,9 @@
RETURN_STATUS
EFIAPI
QemuFwCfgS3CallWhenBootScriptReady (
- IN FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION *Callback,
- IN OUT VOID *Context OPTIONAL,
- IN UINTN ScratchBufferSize
+ IN FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION *Callback,
+ IN OUT VOID *Context OPTIONAL,
+ IN UINTN ScratchBufferSize
)
{
return RETURN_UNSUPPORTED;
diff --git a/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3PeiDxe.c b/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3PeiDxe.c
index 5557c70aa3..270f050336 100644
--- a/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3PeiDxe.c
+++ b/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3PeiDxe.c
@@ -27,16 +27,17 @@ QemuFwCfgS3Enabled (
VOID
)
{
- RETURN_STATUS Status;
- FIRMWARE_CONFIG_ITEM FwCfgItem;
- UINTN FwCfgSize;
- UINT8 SystemStates[6];
+ RETURN_STATUS Status;
+ FIRMWARE_CONFIG_ITEM FwCfgItem;
+ UINTN FwCfgSize;
+ UINT8 SystemStates[6];
Status = QemuFwCfgFindFile ("etc/system-states", &FwCfgItem, &FwCfgSize);
- if (Status != RETURN_SUCCESS || FwCfgSize != sizeof SystemStates) {
+ if ((Status != RETURN_SUCCESS) || (FwCfgSize != sizeof SystemStates)) {
return FALSE;
}
+
QemuFwCfgSelectItem (FwCfgItem);
QemuFwCfgReadBytes (sizeof SystemStates, SystemStates);
- return (BOOLEAN) (SystemStates[3] & BIT7);
+ return (BOOLEAN)(SystemStates[3] & BIT7);
}
diff --git a/OvmfPkg/Library/QemuFwCfgSimpleParserLib/QemuFwCfgSimpleParser.c b/OvmfPkg/Library/QemuFwCfgSimpleParserLib/QemuFwCfgSimpleParser.c
index 5ca22fcf0d..c9e0091b82 100644
--- a/OvmfPkg/Library/QemuFwCfgSimpleParserLib/QemuFwCfgSimpleParser.c
+++ b/OvmfPkg/Library/QemuFwCfgSimpleParserLib/QemuFwCfgSimpleParser.c
@@ -20,20 +20,20 @@
// Size of the longest valid BOOL string (see the "mTrueString" and
// "mFalseString" arrays below), including the terminating NUL.
//
-#define BOOL_STRING_MAX_SIZE (sizeof "disabled")
+#define BOOL_STRING_MAX_SIZE (sizeof "disabled")
//
// Length of "\r\n", not including the terminating NUL.
//
-#define CRLF_LENGTH (sizeof "\r\n" - 1)
+#define CRLF_LENGTH (sizeof "\r\n" - 1)
//
// Words recognized as representing TRUE or FALSE.
//
-STATIC CONST CHAR8 * CONST mTrueString[] = {
+STATIC CONST CHAR8 *CONST mTrueString[] = {
"true", "yes", "y", "enable", "enabled", "1"
};
-STATIC CONST CHAR8 * CONST mFalseString[] = {
+STATIC CONST CHAR8 *CONST mFalseString[] = {
"false", "no", "n", "disable", "disabled", "0"
};
@@ -85,14 +85,14 @@ STATIC CONST CHAR8 * CONST mFalseString[] = {
STATIC
RETURN_STATUS
QemuFwCfgGetAsString (
- IN CONST CHAR8 *FileName,
- IN OUT UINTN *BufferSize,
- OUT CHAR8 *Buffer
+ IN CONST CHAR8 *FileName,
+ IN OUT UINTN *BufferSize,
+ OUT CHAR8 *Buffer
)
{
- RETURN_STATUS Status;
- FIRMWARE_CONFIG_ITEM FwCfgItem;
- UINTN FwCfgSize;
+ RETURN_STATUS Status;
+ FIRMWARE_CONFIG_ITEM FwCfgItem;
+ UINTN FwCfgSize;
if (!QemuFwCfgIsAvailable ()) {
return RETURN_UNSUPPORTED;
@@ -102,6 +102,7 @@ QemuFwCfgGetAsString (
if (RETURN_ERROR (Status)) {
return Status;
}
+
if (FwCfgSize > *BufferSize) {
return RETURN_PROTOCOL_ERROR;
}
@@ -112,18 +113,20 @@ QemuFwCfgGetAsString (
//
// If Buffer is already NUL-terminated due to fw_cfg contents, we're done.
//
- if (FwCfgSize > 0 && Buffer[FwCfgSize - 1] == '\0') {
+ if ((FwCfgSize > 0) && (Buffer[FwCfgSize - 1] == '\0')) {
*BufferSize = FwCfgSize;
return RETURN_SUCCESS;
}
+
//
// Otherwise, append a NUL byte to Buffer (if we have room for it).
//
if (FwCfgSize == *BufferSize) {
return RETURN_PROTOCOL_ERROR;
}
+
Buffer[FwCfgSize] = '\0';
- *BufferSize = FwCfgSize + 1;
+ *BufferSize = FwCfgSize + 1;
return RETURN_SUCCESS;
}
@@ -142,25 +145,26 @@ QemuFwCfgGetAsString (
STATIC
VOID
StripNewline (
- IN OUT UINTN *BufferSize,
- IN OUT CHAR8 *Buffer
+ IN OUT UINTN *BufferSize,
+ IN OUT CHAR8 *Buffer
)
{
- UINTN InSize, OutSize;
+ UINTN InSize, OutSize;
- InSize = *BufferSize;
+ InSize = *BufferSize;
OutSize = InSize;
- if (InSize >= 3 &&
- Buffer[InSize - 3] == '\r' && Buffer[InSize - 2] == '\n') {
+ if ((InSize >= 3) &&
+ (Buffer[InSize - 3] == '\r') && (Buffer[InSize - 2] == '\n'))
+ {
OutSize = InSize - 2;
- } else if (InSize >= 2 && Buffer[InSize - 2] == '\n') {
+ } else if ((InSize >= 2) && (Buffer[InSize - 2] == '\n')) {
OutSize = InSize - 1;
}
if (OutSize < InSize) {
Buffer[OutSize - 1] = '\0';
- *BufferSize = OutSize;
+ *BufferSize = OutSize;
}
}
@@ -203,20 +207,20 @@ StripNewline (
STATIC
RETURN_STATUS
QemuFwCfgParseUint64WithLimit (
- IN CONST CHAR8 *FileName,
- IN BOOLEAN ParseAsHex,
- IN UINT64 Limit,
- OUT UINT64 *Value
+ IN CONST CHAR8 *FileName,
+ IN BOOLEAN ParseAsHex,
+ IN UINT64 Limit,
+ OUT UINT64 *Value
)
{
- UINTN Uint64StringSize;
- CHAR8 Uint64String[UINT64_STRING_MAX_SIZE + CRLF_LENGTH];
- RETURN_STATUS Status;
- CHAR8 *EndPointer;
- UINT64 Uint64;
+ UINTN Uint64StringSize;
+ CHAR8 Uint64String[UINT64_STRING_MAX_SIZE + CRLF_LENGTH];
+ RETURN_STATUS Status;
+ CHAR8 *EndPointer;
+ UINT64 Uint64;
Uint64StringSize = sizeof Uint64String;
- Status = QemuFwCfgGetAsString (FileName, &Uint64StringSize, Uint64String);
+ Status = QemuFwCfgGetAsString (FileName, &Uint64StringSize, Uint64String);
if (RETURN_ERROR (Status)) {
return Status;
}
@@ -228,6 +232,7 @@ QemuFwCfgParseUint64WithLimit (
} else {
Status = AsciiStrDecimalToUint64S (Uint64String, &EndPointer, &Uint64);
}
+
if (RETURN_ERROR (Status)) {
return Status;
}
@@ -236,7 +241,7 @@ QemuFwCfgParseUint64WithLimit (
// Report a wire protocol error if the subject sequence is empty, or trailing
// garbage is present, or Limit is not honored.
//
- if (EndPointer == Uint64String || *EndPointer != '\0' || Uint64 > Limit) {
+ if ((EndPointer == Uint64String) || (*EndPointer != '\0') || (Uint64 > Limit)) {
return RETURN_PROTOCOL_ERROR;
}
@@ -263,17 +268,17 @@ QemuFwCfgSimpleParserInit (
RETURN_STATUS
EFIAPI
QemuFwCfgParseBool (
- IN CONST CHAR8 *FileName,
- OUT BOOLEAN *Value
+ IN CONST CHAR8 *FileName,
+ OUT BOOLEAN *Value
)
{
- UINTN BoolStringSize;
- CHAR8 BoolString[BOOL_STRING_MAX_SIZE + CRLF_LENGTH];
- RETURN_STATUS Status;
- UINTN Idx;
+ UINTN BoolStringSize;
+ CHAR8 BoolString[BOOL_STRING_MAX_SIZE + CRLF_LENGTH];
+ RETURN_STATUS Status;
+ UINTN Idx;
BoolStringSize = sizeof BoolString;
- Status = QemuFwCfgGetAsString (FileName, &BoolStringSize, BoolString);
+ Status = QemuFwCfgGetAsString (FileName, &BoolStringSize, BoolString);
if (RETURN_ERROR (Status)) {
return Status;
}
@@ -300,19 +305,24 @@ QemuFwCfgParseBool (
RETURN_STATUS
EFIAPI
QemuFwCfgParseUint8 (
- IN CONST CHAR8 *FileName,
- IN BOOLEAN ParseAsHex,
- OUT UINT8 *Value
+ IN CONST CHAR8 *FileName,
+ IN BOOLEAN ParseAsHex,
+ OUT UINT8 *Value
)
{
- RETURN_STATUS Status;
- UINT64 Uint64;
-
- Status = QemuFwCfgParseUint64WithLimit (FileName, ParseAsHex, MAX_UINT8,
- &Uint64);
+ RETURN_STATUS Status;
+ UINT64 Uint64;
+
+ Status = QemuFwCfgParseUint64WithLimit (
+ FileName,
+ ParseAsHex,
+ MAX_UINT8,
+ &Uint64
+ );
if (RETURN_ERROR (Status)) {
return Status;
}
+
*Value = (UINT8)Uint64;
return RETURN_SUCCESS;
}
@@ -320,19 +330,24 @@ QemuFwCfgParseUint8 (
RETURN_STATUS
EFIAPI
QemuFwCfgParseUint16 (
- IN CONST CHAR8 *FileName,
- IN BOOLEAN ParseAsHex,
- OUT UINT16 *Value
+ IN CONST CHAR8 *FileName,
+ IN BOOLEAN ParseAsHex,
+ OUT UINT16 *Value
)
{
- RETURN_STATUS Status;
- UINT64 Uint64;
-
- Status = QemuFwCfgParseUint64WithLimit (FileName, ParseAsHex, MAX_UINT16,
- &Uint64);
+ RETURN_STATUS Status;
+ UINT64 Uint64;
+
+ Status = QemuFwCfgParseUint64WithLimit (
+ FileName,
+ ParseAsHex,
+ MAX_UINT16,
+ &Uint64
+ );
if (RETURN_ERROR (Status)) {
return Status;
}
+
*Value = (UINT16)Uint64;
return RETURN_SUCCESS;
}
@@ -340,19 +355,24 @@ QemuFwCfgParseUint16 (
RETURN_STATUS
EFIAPI
QemuFwCfgParseUint32 (
- IN CONST CHAR8 *FileName,
- IN BOOLEAN ParseAsHex,
- OUT UINT32 *Value
+ IN CONST CHAR8 *FileName,
+ IN BOOLEAN ParseAsHex,
+ OUT UINT32 *Value
)
{
- RETURN_STATUS Status;
- UINT64 Uint64;
-
- Status = QemuFwCfgParseUint64WithLimit (FileName, ParseAsHex, MAX_UINT32,
- &Uint64);
+ RETURN_STATUS Status;
+ UINT64 Uint64;
+
+ Status = QemuFwCfgParseUint64WithLimit (
+ FileName,
+ ParseAsHex,
+ MAX_UINT32,
+ &Uint64
+ );
if (RETURN_ERROR (Status)) {
return Status;
}
+
*Value = (UINT32)Uint64;
return RETURN_SUCCESS;
}
@@ -360,19 +380,24 @@ QemuFwCfgParseUint32 (
RETURN_STATUS
EFIAPI
QemuFwCfgParseUint64 (
- IN CONST CHAR8 *FileName,
- IN BOOLEAN ParseAsHex,
- OUT UINT64 *Value
+ IN CONST CHAR8 *FileName,
+ IN BOOLEAN ParseAsHex,
+ OUT UINT64 *Value
)
{
- RETURN_STATUS Status;
- UINT64 Uint64;
-
- Status = QemuFwCfgParseUint64WithLimit (FileName, ParseAsHex, MAX_UINT64,
- &Uint64);
+ RETURN_STATUS Status;
+ UINT64 Uint64;
+
+ Status = QemuFwCfgParseUint64WithLimit (
+ FileName,
+ ParseAsHex,
+ MAX_UINT64,
+ &Uint64
+ );
if (RETURN_ERROR (Status)) {
return Status;
}
+
*Value = Uint64;
return RETURN_SUCCESS;
}
@@ -380,19 +405,24 @@ QemuFwCfgParseUint64 (
RETURN_STATUS
EFIAPI
QemuFwCfgParseUintn (
- IN CONST CHAR8 *FileName,
- IN BOOLEAN ParseAsHex,
- OUT UINTN *Value
+ IN CONST CHAR8 *FileName,
+ IN BOOLEAN ParseAsHex,
+ OUT UINTN *Value
)
{
- RETURN_STATUS Status;
- UINT64 Uint64;
-
- Status = QemuFwCfgParseUint64WithLimit (FileName, ParseAsHex, MAX_UINTN,
- &Uint64);
+ RETURN_STATUS Status;
+ UINT64 Uint64;
+
+ Status = QemuFwCfgParseUint64WithLimit (
+ FileName,
+ ParseAsHex,
+ MAX_UINTN,
+ &Uint64
+ );
if (RETURN_ERROR (Status)) {
return Status;
}
+
*Value = (UINTN)Uint64;
return RETURN_SUCCESS;
}
diff --git a/OvmfPkg/Library/ResetSystemLib/BaseResetShutdown.c b/OvmfPkg/Library/ResetSystemLib/BaseResetShutdown.c
index 21c80e4323..29abd57fa7 100644
--- a/OvmfPkg/Library/ResetSystemLib/BaseResetShutdown.c
+++ b/OvmfPkg/Library/ResetSystemLib/BaseResetShutdown.c
@@ -28,21 +28,21 @@ ResetShutdown (
VOID
)
{
- UINT16 AcpiPmBaseAddress;
- UINT16 HostBridgeDevId;
+ UINT16 AcpiPmBaseAddress;
+ UINT16 HostBridgeDevId;
AcpiPmBaseAddress = 0;
- HostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID);
+ HostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID);
switch (HostBridgeDevId) {
- case INTEL_82441_DEVICE_ID:
- AcpiPmBaseAddress = PIIX4_PMBA_VALUE;
- break;
- case INTEL_Q35_MCH_DEVICE_ID:
- AcpiPmBaseAddress = ICH9_PMBASE_VALUE;
- break;
- default:
- ASSERT (FALSE);
- CpuDeadLoop ();
+ case INTEL_82441_DEVICE_ID:
+ AcpiPmBaseAddress = PIIX4_PMBA_VALUE;
+ break;
+ case INTEL_Q35_MCH_DEVICE_ID:
+ AcpiPmBaseAddress = ICH9_PMBASE_VALUE;
+ break;
+ default:
+ ASSERT (FALSE);
+ CpuDeadLoop ();
}
IoBitFieldWrite16 (AcpiPmBaseAddress + 4, 10, 13, 0);
diff --git a/OvmfPkg/Library/ResetSystemLib/DxeResetShutdown.c b/OvmfPkg/Library/ResetSystemLib/DxeResetShutdown.c
index 5a75c32df3..a0db8b50bf 100644
--- a/OvmfPkg/Library/ResetSystemLib/DxeResetShutdown.c
+++ b/OvmfPkg/Library/ResetSystemLib/DxeResetShutdown.c
@@ -15,29 +15,29 @@
#include <Library/ResetSystemLib.h> // ResetShutdown()
#include <OvmfPlatforms.h> // PIIX4_PMBA_VALUE
-STATIC UINT16 mAcpiPmBaseAddress;
+STATIC UINT16 mAcpiPmBaseAddress;
EFI_STATUS
EFIAPI
DxeResetInit (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- UINT16 HostBridgeDevId;
+ UINT16 HostBridgeDevId;
HostBridgeDevId = PcdGet16 (PcdOvmfHostBridgePciDevId);
switch (HostBridgeDevId) {
- case INTEL_82441_DEVICE_ID:
- mAcpiPmBaseAddress = PIIX4_PMBA_VALUE;
- break;
- case INTEL_Q35_MCH_DEVICE_ID:
- mAcpiPmBaseAddress = ICH9_PMBASE_VALUE;
- break;
- default:
- ASSERT (FALSE);
- CpuDeadLoop ();
- return EFI_UNSUPPORTED;
+ case INTEL_82441_DEVICE_ID:
+ mAcpiPmBaseAddress = PIIX4_PMBA_VALUE;
+ break;
+ case INTEL_Q35_MCH_DEVICE_ID:
+ mAcpiPmBaseAddress = ICH9_PMBASE_VALUE;
+ break;
+ default:
+ ASSERT (FALSE);
+ CpuDeadLoop ();
+ return EFI_UNSUPPORTED;
}
return EFI_SUCCESS;
diff --git a/OvmfPkg/Library/ResetSystemLib/DxeResetSystemLibMicrovm.c b/OvmfPkg/Library/ResetSystemLib/DxeResetSystemLibMicrovm.c
index 0de8b39f54..a31fd0e7bb 100644
--- a/OvmfPkg/Library/ResetSystemLib/DxeResetSystemLibMicrovm.c
+++ b/OvmfPkg/Library/ResetSystemLib/DxeResetSystemLibMicrovm.c
@@ -37,8 +37,11 @@ DxeResetSystemLibMicrovmConstructor (
return RETURN_UNSUPPORTED;
}
- Status = gDS->SetMemorySpaceAttributes (Address, SIZE_4KB,
- Descriptor.Attributes | EFI_MEMORY_RUNTIME);
+ Status = gDS->SetMemorySpaceAttributes (
+ Address,
+ SIZE_4KB,
+ Descriptor.Attributes | EFI_MEMORY_RUNTIME
+ );
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "%a: SetMemorySpaceAttributes failed\n", __FUNCTION__));
return RETURN_UNSUPPORTED;
diff --git a/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c b/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c
index fe51f53d1d..9d1314d553 100644
--- a/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c
+++ b/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c
@@ -52,7 +52,6 @@ ResetWarm (
CpuDeadLoop ();
}
-
/**
This function causes a systemwide reset. The exact type of the reset is
defined by the EFI_GUID that follows the Null-terminated Unicode string
@@ -68,8 +67,8 @@ ResetWarm (
VOID
EFIAPI
ResetPlatformSpecific (
- IN UINTN DataSize,
- IN VOID *ResetData
+ IN UINTN DataSize,
+ IN VOID *ResetData
)
{
ResetCold ();
@@ -91,30 +90,30 @@ ResetPlatformSpecific (
VOID
EFIAPI
ResetSystem (
- IN EFI_RESET_TYPE ResetType,
- IN EFI_STATUS ResetStatus,
- IN UINTN DataSize,
- IN VOID *ResetData OPTIONAL
+ IN EFI_RESET_TYPE ResetType,
+ IN EFI_STATUS ResetStatus,
+ IN UINTN DataSize,
+ IN VOID *ResetData OPTIONAL
)
{
switch (ResetType) {
- case EfiResetWarm:
- ResetWarm ();
- break;
+ case EfiResetWarm:
+ ResetWarm ();
+ break;
- case EfiResetCold:
- ResetCold ();
- break;
+ case EfiResetCold:
+ ResetCold ();
+ break;
- case EfiResetShutdown:
- ResetShutdown ();
- break;
+ case EfiResetShutdown:
+ ResetShutdown ();
+ break;
- case EfiResetPlatformSpecific:
- ResetPlatformSpecific (DataSize, ResetData);
- break;
+ case EfiResetPlatformSpecific:
+ ResetPlatformSpecific (DataSize, ResetData);
+ break;
- default:
- break;
+ default:
+ break;
}
}
diff --git a/OvmfPkg/Library/ResetSystemLib/ResetSystemLibMicrovm.c b/OvmfPkg/Library/ResetSystemLib/ResetSystemLibMicrovm.c
index 94dc894ded..44fe929e93 100644
--- a/OvmfPkg/Library/ResetSystemLib/ResetSystemLibMicrovm.c
+++ b/OvmfPkg/Library/ResetSystemLib/ResetSystemLibMicrovm.c
@@ -16,9 +16,12 @@
#include <Library/UefiRuntimeLib.h> // EfiGoneVirtual()
#include <OvmfPlatforms.h> // PIIX4_PMBA_VALUE
-static UINTN MicrovmGedBase (VOID)
+static UINTN
+MicrovmGedBase (
+ VOID
+ )
{
- VOID *Address = (VOID*)(UINTN) MICROVM_GED_MMIO_BASE_REGS;
+ VOID *Address = (VOID *)(UINTN)MICROVM_GED_MMIO_BASE_REGS;
if (EfiGoneVirtual ()) {
EfiConvertPointer (0, &Address);
@@ -27,63 +30,82 @@ static UINTN MicrovmGedBase (VOID)
DEBUG ((DEBUG_INFO, "%a: physical -> 0x%x\n", __FUNCTION__, Address));
}
- return (UINTN) Address;
+ return (UINTN)Address;
}
-static VOID MicrovmReset (VOID)
+static VOID
+MicrovmReset (
+ VOID
+ )
{
- UINTN Address = MicrovmGedBase();
+ UINTN Address = MicrovmGedBase ();
DEBUG ((DEBUG_INFO, "%a: microvm reset via ged\n", __FUNCTION__));
- MmioWrite8 (Address + MICROVM_ACPI_GED_REG_RESET,
- MICROVM_ACPI_GED_RESET_VALUE);
+ MmioWrite8 (
+ Address + MICROVM_ACPI_GED_REG_RESET,
+ MICROVM_ACPI_GED_RESET_VALUE
+ );
CpuDeadLoop ();
}
-static VOID MicrovmShutdown (VOID)
+static VOID
+MicrovmShutdown (
+ VOID
+ )
{
- UINTN Address = MicrovmGedBase();
+ UINTN Address = MicrovmGedBase ();
DEBUG ((DEBUG_INFO, "%a: microvm poweroff via ged\n", __FUNCTION__));
- MmioWrite8 (Address + MICROVM_ACPI_GED_REG_SLEEP_CTL,
- (1 << 5) /* enable bit */ |
- (5 << 2) /* typ == S5 */);
+ MmioWrite8 (
+ Address + MICROVM_ACPI_GED_REG_SLEEP_CTL,
+ (1 << 5) /* enable bit */ |
+ (5 << 2) /* typ == S5 */
+ );
CpuDeadLoop ();
}
-VOID EFIAPI ResetCold (VOID)
+VOID EFIAPI
+ResetCold (
+ VOID
+ )
{
- MicrovmReset();
+ MicrovmReset ();
}
-VOID EFIAPI ResetWarm (VOID)
+VOID EFIAPI
+ResetWarm (
+ VOID
+ )
{
- MicrovmReset();
+ MicrovmReset ();
}
VOID
EFIAPI
ResetPlatformSpecific (
- IN UINTN DataSize,
- IN VOID *ResetData
+ IN UINTN DataSize,
+ IN VOID *ResetData
)
{
- MicrovmReset();
+ MicrovmReset ();
}
VOID
EFIAPI
ResetSystem (
- IN EFI_RESET_TYPE ResetType,
- IN EFI_STATUS ResetStatus,
- IN UINTN DataSize,
- IN VOID *ResetData OPTIONAL
+ IN EFI_RESET_TYPE ResetType,
+ IN EFI_STATUS ResetStatus,
+ IN UINTN DataSize,
+ IN VOID *ResetData OPTIONAL
)
{
- MicrovmReset();
+ MicrovmReset ();
}
-VOID EFIAPI ResetShutdown (VOID)
+VOID EFIAPI
+ResetShutdown (
+ VOID
+ )
{
- MicrovmShutdown();
+ MicrovmShutdown ();
}
diff --git a/OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.c b/OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.c
index 777b93f1a0..c70b4556b7 100644
--- a/OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.c
+++ b/OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.c
@@ -25,7 +25,6 @@
**/
-
/**
Unpacks the next variable from the buffer
@@ -49,55 +48,55 @@
STATIC
EFI_STATUS
UnpackVariableFromBuffer (
- IN VOID *Buffer,
- IN UINTN MaxSize,
- OUT CHAR16 **Name,
- OUT UINT32 *NameSize,
- OUT EFI_GUID **Guid,
- OUT UINT32 *Attributes,
- OUT UINT32 *DataSize,
- OUT VOID **Data,
- OUT UINTN *SizeUsed
+ IN VOID *Buffer,
+ IN UINTN MaxSize,
+ OUT CHAR16 **Name,
+ OUT UINT32 *NameSize,
+ OUT EFI_GUID **Guid,
+ OUT UINT32 *Attributes,
+ OUT UINT32 *DataSize,
+ OUT VOID **Data,
+ OUT UINTN *SizeUsed
)
{
UINT8 *BytePtr;
UINTN Offset;
- BytePtr = (UINT8*)Buffer;
- Offset = 0;
+ BytePtr = (UINT8 *)Buffer;
+ Offset = 0;
- *NameSize = *(UINT32*) (BytePtr + Offset);
- Offset = Offset + sizeof (UINT32);
+ *NameSize = *(UINT32 *)(BytePtr + Offset);
+ Offset = Offset + sizeof (UINT32);
if (Offset > MaxSize) {
return EFI_INVALID_PARAMETER;
}
- *Name = (CHAR16*) (BytePtr + Offset);
- Offset = Offset + *(UINT32*)BytePtr;
+ *Name = (CHAR16 *)(BytePtr + Offset);
+ Offset = Offset + *(UINT32 *)BytePtr;
if (Offset > MaxSize) {
return EFI_INVALID_PARAMETER;
}
- *Guid = (EFI_GUID*) (BytePtr + Offset);
+ *Guid = (EFI_GUID *)(BytePtr + Offset);
Offset = Offset + sizeof (EFI_GUID);
if (Offset > MaxSize) {
return EFI_INVALID_PARAMETER;
}
- *Attributes = *(UINT32*) (BytePtr + Offset);
- Offset = Offset + sizeof (UINT32);
+ *Attributes = *(UINT32 *)(BytePtr + Offset);
+ Offset = Offset + sizeof (UINT32);
if (Offset > MaxSize) {
return EFI_INVALID_PARAMETER;
}
- *DataSize = *(UINT32*) (BytePtr + Offset);
- Offset = Offset + sizeof (UINT32);
+ *DataSize = *(UINT32 *)(BytePtr + Offset);
+ Offset = Offset + sizeof (UINT32);
if (Offset > MaxSize) {
return EFI_INVALID_PARAMETER;
}
- *Data = (VOID*) (BytePtr + Offset);
+ *Data = (VOID *)(BytePtr + Offset);
Offset = Offset + *DataSize;
if (Offset > MaxSize) {
return EFI_INVALID_PARAMETER;
@@ -108,7 +107,6 @@ UnpackVariableFromBuffer (
return EFI_SUCCESS;
}
-
/**
Iterates through the variables in the buffer, and calls a callback
function for each variable found.
@@ -130,34 +128,35 @@ IterateVariablesInBuffer (
IN UINTN MaxSize
)
{
- RETURN_STATUS Status;
- UINTN TotalSizeUsed;
- UINTN SizeUsed;
-
- CHAR16 *Name;
- UINT32 NameSize;
- CHAR16 *AlignedName;
- UINT32 AlignedNameMaxSize;
- EFI_GUID *Guid;
- UINT32 Attributes;
- UINT32 DataSize;
- VOID *Data;
-
- SizeUsed = 0;
- AlignedName = NULL;
+ RETURN_STATUS Status;
+ UINTN TotalSizeUsed;
+ UINTN SizeUsed;
+
+ CHAR16 *Name;
+ UINT32 NameSize;
+ CHAR16 *AlignedName;
+ UINT32 AlignedNameMaxSize;
+ EFI_GUID *Guid;
+ UINT32 Attributes;
+ UINT32 DataSize;
+ VOID *Data;
+
+ SizeUsed = 0;
+ AlignedName = NULL;
AlignedNameMaxSize = 0;
- Name = NULL;
- Guid = NULL;
- Attributes = 0;
- DataSize = 0;
- Data = NULL;
+ Name = NULL;
+ Guid = NULL;
+ Attributes = 0;
+ DataSize = 0;
+ Data = NULL;
for (
- Status = EFI_SUCCESS, TotalSizeUsed = 0;
- !EFI_ERROR (Status) && (TotalSizeUsed < MaxSize);
- ) {
+ Status = EFI_SUCCESS, TotalSizeUsed = 0;
+ !EFI_ERROR (Status) && (TotalSizeUsed < MaxSize);
+ )
+ {
Status = UnpackVariableFromBuffer (
- (VOID*) ((UINT8*) Buffer + TotalSizeUsed),
+ (VOID *)((UINT8 *)Buffer + TotalSizeUsed),
(MaxSize - TotalSizeUsed),
&Name,
&NameSize,
@@ -179,11 +178,14 @@ IterateVariablesInBuffer (
if (AlignedName != NULL) {
FreePool (AlignedName);
}
+
AlignedName = AllocatePool (NameSize);
}
+
if (AlignedName == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
CopyMem (AlignedName, Name, NameSize);
TotalSizeUsed = TotalSizeUsed + SizeUsed;
@@ -191,15 +193,14 @@ IterateVariablesInBuffer (
//
// Run the callback function
//
- Status = (*CallbackFunction) (
- CallbackContext,
- AlignedName,
- Guid,
- Attributes,
- DataSize,
- Data
- );
-
+ Status = (*CallbackFunction)(
+ CallbackContext,
+ AlignedName,
+ Guid,
+ Attributes,
+ DataSize,
+ Data
+ );
}
if (AlignedName != NULL) {
@@ -222,38 +223,36 @@ IterateVariablesInBuffer (
return EFI_SUCCESS;
}
-
STATIC
RETURN_STATUS
EFIAPI
IterateVariablesCallbackNop (
- IN VOID *Context,
- IN CHAR16 *VariableName,
- IN EFI_GUID *VendorGuid,
- IN UINT32 Attributes,
- IN UINTN DataSize,
- IN VOID *Data
+ IN VOID *Context,
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ IN UINT32 Attributes,
+ IN UINTN DataSize,
+ IN VOID *Data
)
{
return RETURN_SUCCESS;
}
-
STATIC
RETURN_STATUS
EFIAPI
IterateVariablesCallbackSetInInstance (
- IN VOID *Context,
- IN CHAR16 *VariableName,
- IN EFI_GUID *VendorGuid,
- IN UINT32 Attributes,
- IN UINTN DataSize,
- IN VOID *Data
+ IN VOID *Context,
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ IN UINT32 Attributes,
+ IN UINTN DataSize,
+ IN VOID *Data
)
{
EFI_HANDLE Instance;
- Instance = (EFI_HANDLE) Context;
+ Instance = (EFI_HANDLE)Context;
return SerializeVariablesAddVariable (
Instance,
@@ -265,47 +264,54 @@ IterateVariablesCallbackSetInInstance (
);
}
-
STATIC
RETURN_STATUS
EFIAPI
IterateVariablesCallbackSetSystemVariable (
- IN VOID *Context,
- IN CHAR16 *VariableName,
- IN EFI_GUID *VendorGuid,
- IN UINT32 Attributes,
- IN UINTN DataSize,
- IN VOID *Data
+ IN VOID *Context,
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ IN UINT32 Attributes,
+ IN UINTN DataSize,
+ IN VOID *Data
)
{
- EFI_STATUS Status;
- STATIC CONST UINT32 AuthMask =
- EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS |
- EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS;
+ EFI_STATUS Status;
+ STATIC CONST UINT32 AuthMask =
+ EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS |
+ EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS;
Status = gRT->SetVariable (
- VariableName,
- VendorGuid,
- Attributes,
- DataSize,
- Data
- );
-
- if (Status == EFI_SECURITY_VIOLATION && (Attributes & AuthMask) != 0) {
- DEBUG ((DEBUG_WARN, "%a: setting authenticated variable \"%s\" "
- "failed with EFI_SECURITY_VIOLATION, ignoring\n", __FUNCTION__,
- VariableName));
+ VariableName,
+ VendorGuid,
+ Attributes,
+ DataSize,
+ Data
+ );
+
+ if ((Status == EFI_SECURITY_VIOLATION) && ((Attributes & AuthMask) != 0)) {
+ DEBUG ((
+ DEBUG_WARN,
+ "%a: setting authenticated variable \"%s\" "
+ "failed with EFI_SECURITY_VIOLATION, ignoring\n",
+ __FUNCTION__,
+ VariableName
+ ));
Status = EFI_SUCCESS;
} else if (Status == EFI_WRITE_PROTECTED) {
- DEBUG ((DEBUG_WARN, "%a: setting ReadOnly variable \"%s\" "
- "failed with EFI_WRITE_PROTECTED, ignoring\n", __FUNCTION__,
- VariableName));
+ DEBUG ((
+ DEBUG_WARN,
+ "%a: setting ReadOnly variable \"%s\" "
+ "failed with EFI_WRITE_PROTECTED, ignoring\n",
+ __FUNCTION__,
+ VariableName
+ ));
Status = EFI_SUCCESS;
}
+
return Status;
}
-
STATIC
RETURN_STATUS
EnsureExtraBufferSpace (
@@ -313,8 +319,8 @@ EnsureExtraBufferSpace (
IN UINTN Size
)
{
- VOID *NewBuffer;
- UINTN NewSize;
+ VOID *NewBuffer;
+ UINTN NewSize;
NewSize = Instance->DataSize + Size;
if (NewSize <= Instance->BufferSize) {
@@ -336,13 +342,12 @@ EnsureExtraBufferSpace (
FreePool (Instance->BufferPtr);
}
- Instance->BufferPtr = NewBuffer;
+ Instance->BufferPtr = NewBuffer;
Instance->BufferSize = NewSize;
return RETURN_SUCCESS;
}
-
STATIC
VOID
AppendToBuffer (
@@ -351,7 +356,7 @@ AppendToBuffer (
IN UINTN Size
)
{
- UINTN NewSize;
+ UINTN NewSize;
ASSERT (Instance != NULL);
ASSERT (Data != NULL);
@@ -360,7 +365,7 @@ AppendToBuffer (
ASSERT ((Instance->DataSize + Size) <= Instance->BufferSize);
CopyMem (
- (VOID*) (((UINT8*) (Instance->BufferPtr)) + Instance->DataSize),
+ (VOID *)(((UINT8 *)(Instance->BufferPtr)) + Instance->DataSize),
Data,
Size
);
@@ -368,7 +373,6 @@ AppendToBuffer (
Instance->DataSize = NewSize;
}
-
/**
Creates a new variable serialization instance
@@ -383,7 +387,7 @@ AppendToBuffer (
RETURN_STATUS
EFIAPI
SerializeVariablesNewInstance (
- OUT EFI_HANDLE *Handle
+ OUT EFI_HANDLE *Handle
)
{
SV_INSTANCE *New;
@@ -395,11 +399,10 @@ SerializeVariablesNewInstance (
New->Signature = SV_SIGNATURE;
- *Handle = (EFI_HANDLE) New;
+ *Handle = (EFI_HANDLE)New;
return RETURN_SUCCESS;
}
-
/**
Free memory associated with a variable serialization instance
@@ -414,10 +417,10 @@ SerializeVariablesNewInstance (
RETURN_STATUS
EFIAPI
SerializeVariablesFreeInstance (
- IN EFI_HANDLE Handle
+ IN EFI_HANDLE Handle
)
{
- SV_INSTANCE *Instance;
+ SV_INSTANCE *Instance;
Instance = SV_FROM_HANDLE (Handle);
@@ -436,7 +439,6 @@ SerializeVariablesFreeInstance (
return RETURN_SUCCESS;
}
-
/**
Creates a new variable serialization instance using the given
binary representation of the variables to fill the new instance
@@ -457,12 +459,12 @@ SerializeVariablesFreeInstance (
RETURN_STATUS
EFIAPI
SerializeVariablesNewInstanceFromBuffer (
- OUT EFI_HANDLE *Handle,
- IN VOID *Buffer,
- IN UINTN Size
+ OUT EFI_HANDLE *Handle,
+ IN VOID *Buffer,
+ IN UINTN Size
)
{
- RETURN_STATUS Status;
+ RETURN_STATUS Status;
Status = SerializeVariablesNewInstance (Handle);
if (RETURN_ERROR (Status)) {
@@ -482,7 +484,7 @@ SerializeVariablesNewInstanceFromBuffer (
Status = IterateVariablesInBuffer (
IterateVariablesCallbackSetInInstance,
- (VOID*) *Handle,
+ (VOID *)*Handle,
Buffer,
Size
);
@@ -494,7 +496,6 @@ SerializeVariablesNewInstanceFromBuffer (
return Status;
}
-
/**
Iterates all variables found with RuntimeServices GetNextVariableName
@@ -512,40 +513,40 @@ SerializeVariablesNewInstanceFromBuffer (
RETURN_STATUS
EFIAPI
SerializeVariablesIterateSystemVariables (
- IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK CallbackFunction,
- IN VOID *Context
+ IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK CallbackFunction,
+ IN VOID *Context
)
{
- RETURN_STATUS Status;
- UINTN VariableNameBufferSize;
- UINTN VariableNameSize;
- CHAR16 *VariableName;
- EFI_GUID VendorGuid;
- UINTN VariableDataBufferSize;
- UINTN VariableDataSize;
- VOID *VariableData;
- UINT32 VariableAttributes;
- VOID *NewBuffer;
+ RETURN_STATUS Status;
+ UINTN VariableNameBufferSize;
+ UINTN VariableNameSize;
+ CHAR16 *VariableName;
+ EFI_GUID VendorGuid;
+ UINTN VariableDataBufferSize;
+ UINTN VariableDataSize;
+ VOID *VariableData;
+ UINT32 VariableAttributes;
+ VOID *NewBuffer;
//
// Initialize the variable name and data buffer variables.
//
VariableNameBufferSize = sizeof (CHAR16);
- VariableName = AllocateZeroPool (VariableNameBufferSize);
+ VariableName = AllocateZeroPool (VariableNameBufferSize);
VariableDataBufferSize = 0;
- VariableData = NULL;
+ VariableData = NULL;
- for (;;) {
+ for ( ; ;) {
//
// Get the next variable name and guid
//
VariableNameSize = VariableNameBufferSize;
- Status = gRT->GetNextVariableName (
- &VariableNameSize,
- VariableName,
- &VendorGuid
- );
+ Status = gRT->GetNextVariableName (
+ &VariableNameSize,
+ VariableName,
+ &VendorGuid
+ );
if (Status == EFI_BUFFER_TOO_SMALL) {
//
// The currently allocated VariableName buffer is too small,
@@ -557,11 +558,13 @@ SerializeVariablesIterateSystemVariables (
Status = EFI_OUT_OF_RESOURCES;
break;
}
+
CopyMem (NewBuffer, VariableName, VariableNameBufferSize);
if (VariableName != NULL) {
FreePool (VariableName);
}
- VariableName = NewBuffer;
+
+ VariableName = NewBuffer;
VariableNameBufferSize = VariableNameSize;
//
@@ -578,6 +581,7 @@ SerializeVariablesIterateSystemVariables (
if (Status == EFI_NOT_FOUND) {
Status = EFI_SUCCESS;
}
+
break;
}
@@ -585,13 +589,13 @@ SerializeVariablesIterateSystemVariables (
// Get the variable data and attributes
//
VariableDataSize = VariableDataBufferSize;
- Status = gRT->GetVariable (
- VariableName,
- &VendorGuid,
- &VariableAttributes,
- &VariableDataSize,
- VariableData
- );
+ Status = gRT->GetVariable (
+ VariableName,
+ &VendorGuid,
+ &VariableAttributes,
+ &VariableDataSize,
+ VariableData
+ );
if (Status == EFI_BUFFER_TOO_SMALL) {
//
// The currently allocated VariableData buffer is too small,
@@ -599,14 +603,16 @@ SerializeVariablesIterateSystemVariables (
//
if (VariableDataBufferSize != 0) {
FreePool (VariableData);
- VariableData = NULL;
+ VariableData = NULL;
VariableDataBufferSize = 0;
}
+
VariableData = AllocatePool (VariableDataSize);
if (VariableData == NULL) {
Status = EFI_OUT_OF_RESOURCES;
break;
}
+
VariableDataBufferSize = VariableDataSize;
//
@@ -620,6 +626,7 @@ SerializeVariablesIterateSystemVariables (
VariableData
);
}
+
if (EFI_ERROR (Status)) {
break;
}
@@ -627,18 +634,17 @@ SerializeVariablesIterateSystemVariables (
//
// Run the callback function
//
- Status = (*CallbackFunction) (
- Context,
- VariableName,
- &VendorGuid,
- VariableAttributes,
- VariableDataSize,
- VariableData
- );
+ Status = (*CallbackFunction)(
+ Context,
+ VariableName,
+ &VendorGuid,
+ VariableAttributes,
+ VariableDataSize,
+ VariableData
+ );
if (EFI_ERROR (Status)) {
break;
}
-
}
if (VariableName != NULL) {
@@ -652,7 +658,6 @@ SerializeVariablesIterateSystemVariables (
return Status;
}
-
/**
Iterates all variables found in the variable serialization instance
@@ -671,12 +676,12 @@ SerializeVariablesIterateSystemVariables (
RETURN_STATUS
EFIAPI
SerializeVariablesIterateInstanceVariables (
- IN EFI_HANDLE Handle,
- IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK CallbackFunction,
- IN VOID *Context
+ IN EFI_HANDLE Handle,
+ IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK CallbackFunction,
+ IN VOID *Context
)
{
- SV_INSTANCE *Instance;
+ SV_INSTANCE *Instance;
Instance = SV_FROM_HANDLE (Handle);
@@ -692,7 +697,6 @@ SerializeVariablesIterateInstanceVariables (
}
}
-
/**
Sets all variables found in the variable serialization instance
@@ -708,7 +712,7 @@ SerializeVariablesIterateInstanceVariables (
RETURN_STATUS
EFIAPI
SerializeVariablesSetSerializedVariables (
- IN EFI_HANDLE Handle
+ IN EFI_HANDLE Handle
)
{
return SerializeVariablesIterateInstanceVariables (
@@ -718,7 +722,6 @@ SerializeVariablesSetSerializedVariables (
);
}
-
/**
Adds a variable to the variable serialization instance
@@ -740,12 +743,12 @@ SerializeVariablesSetSerializedVariables (
RETURN_STATUS
EFIAPI
SerializeVariablesAddVariable (
- IN EFI_HANDLE Handle,
- IN CHAR16 *VariableName,
- IN EFI_GUID *VendorGuid,
- IN UINT32 Attributes,
- IN UINTN DataSize,
- IN VOID *Data
+ IN EFI_HANDLE Handle,
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ IN UINT32 Attributes,
+ IN UINTN DataSize,
+ IN VOID *Data
)
{
RETURN_STATUS Status;
@@ -757,10 +760,11 @@ SerializeVariablesAddVariable (
Instance = SV_FROM_HANDLE (Handle);
if ((Instance->Signature != SV_SIGNATURE) ||
- (VariableName == NULL) || (VendorGuid == NULL) || (Data == NULL)) {
+ (VariableName == NULL) || (VendorGuid == NULL) || (Data == NULL))
+ {
}
- SerializedNameSize = (UINT32) StrSize (VariableName);
+ SerializedNameSize = (UINT32)StrSize (VariableName);
SerializedSize =
sizeof (SerializedNameSize) +
@@ -781,28 +785,28 @@ SerializeVariablesAddVariable (
//
// Add name size (UINT32)
//
- AppendToBuffer (Instance, (VOID*) &SerializedNameSize, sizeof (SerializedNameSize));
+ AppendToBuffer (Instance, (VOID *)&SerializedNameSize, sizeof (SerializedNameSize));
//
// Add variable unicode name string
//
- AppendToBuffer (Instance, (VOID*) VariableName, SerializedNameSize);
+ AppendToBuffer (Instance, (VOID *)VariableName, SerializedNameSize);
//
// Add variable GUID
//
- AppendToBuffer (Instance, (VOID*) VendorGuid, sizeof (*VendorGuid));
+ AppendToBuffer (Instance, (VOID *)VendorGuid, sizeof (*VendorGuid));
//
// Add variable attributes
//
- AppendToBuffer (Instance, (VOID*) &Attributes, sizeof (Attributes));
+ AppendToBuffer (Instance, (VOID *)&Attributes, sizeof (Attributes));
//
// Add variable data size (UINT32)
//
- SerializedDataSize = (UINT32) DataSize;
- AppendToBuffer (Instance, (VOID*) &SerializedDataSize, sizeof (SerializedDataSize));
+ SerializedDataSize = (UINT32)DataSize;
+ AppendToBuffer (Instance, (VOID *)&SerializedDataSize, sizeof (SerializedDataSize));
//
// Add variable data
@@ -812,7 +816,6 @@ SerializeVariablesAddVariable (
return RETURN_SUCCESS;
}
-
/**
Serializes the variables known to this instance into the
provided buffer.
@@ -839,12 +842,12 @@ SerializeVariablesAddVariable (
RETURN_STATUS
EFIAPI
SerializeVariablesToBuffer (
- IN EFI_HANDLE Handle,
- OUT VOID *Buffer,
- IN OUT UINTN *Size
+ IN EFI_HANDLE Handle,
+ OUT VOID *Buffer,
+ IN OUT UINTN *Size
)
{
- SV_INSTANCE *Instance;
+ SV_INSTANCE *Instance;
Instance = SV_FROM_HANDLE (Handle);
@@ -866,4 +869,3 @@ SerializeVariablesToBuffer (
return RETURN_SUCCESS;
}
-
diff --git a/OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.h b/OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.h
index 966fab77b2..7afa74ff6f 100644
--- a/OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.h
+++ b/OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.h
@@ -19,15 +19,14 @@
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
-#define SV_FROM_HANDLE(a) CR (a, SV_INSTANCE, Signature, SV_SIGNATURE)
-#define SV_SIGNATURE SIGNATURE_32 ('S', 'V', 'A', 'R')
+#define SV_FROM_HANDLE(a) CR (a, SV_INSTANCE, Signature, SV_SIGNATURE)
+#define SV_SIGNATURE SIGNATURE_32 ('S', 'V', 'A', 'R')
typedef struct {
- UINT32 Signature;
- VOID *BufferPtr;
- UINTN BufferSize;
- UINTN DataSize;
+ UINT32 Signature;
+ VOID *BufferPtr;
+ UINTN BufferSize;
+ UINTN DataSize;
} SV_INSTANCE;
#endif
-
diff --git a/OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.c b/OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.c
index 4d2c23cfb3..69c2d36400 100644
--- a/OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.c
+++ b/OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.c
@@ -20,8 +20,8 @@
#include <Library/QemuFwCfgLib.h>
typedef union {
- SMBIOS_TABLE_ENTRY_POINT V2;
- SMBIOS_TABLE_3_0_ENTRY_POINT V3;
+ SMBIOS_TABLE_ENTRY_POINT V2;
+ SMBIOS_TABLE_3_0_ENTRY_POINT V3;
} QEMU_SMBIOS_ANCHOR;
RETURN_STATUS
@@ -30,11 +30,11 @@ DetectSmbiosVersion (
VOID
)
{
- FIRMWARE_CONFIG_ITEM Anchor, Tables;
- UINTN AnchorSize, TablesSize;
- QEMU_SMBIOS_ANCHOR QemuAnchor;
- UINT16 SmbiosVersion;
- RETURN_STATUS PcdStatus;
+ FIRMWARE_CONFIG_ITEM Anchor, Tables;
+ UINTN AnchorSize, TablesSize;
+ QEMU_SMBIOS_ANCHOR QemuAnchor;
+ UINT16 SmbiosVersion;
+ RETURN_STATUS PcdStatus;
if (PcdGetBool (PcdQemuSmbiosValidated)) {
//
@@ -45,53 +45,76 @@ DetectSmbiosVersion (
return RETURN_SUCCESS;
}
- if (RETURN_ERROR (QemuFwCfgFindFile (
- "etc/smbios/smbios-anchor", &Anchor, &AnchorSize)) ||
- RETURN_ERROR (QemuFwCfgFindFile (
- "etc/smbios/smbios-tables", &Tables, &TablesSize)) ||
- TablesSize == 0) {
+ if (RETURN_ERROR (
+ QemuFwCfgFindFile (
+ "etc/smbios/smbios-anchor",
+ &Anchor,
+ &AnchorSize
+ )
+ ) ||
+ RETURN_ERROR (
+ QemuFwCfgFindFile (
+ "etc/smbios/smbios-tables",
+ &Tables,
+ &TablesSize
+ )
+ ) ||
+ (TablesSize == 0))
+ {
return RETURN_SUCCESS;
}
QemuFwCfgSelectItem (Anchor);
switch (AnchorSize) {
- case sizeof QemuAnchor.V2:
- QemuFwCfgReadBytes (AnchorSize, &QemuAnchor);
-
- if (QemuAnchor.V2.MajorVersion != 2 ||
- QemuAnchor.V2.TableLength != TablesSize ||
- CompareMem (QemuAnchor.V2.AnchorString, "_SM_", 4) != 0 ||
- CompareMem (QemuAnchor.V2.IntermediateAnchorString, "_DMI_", 5) != 0) {
- return RETURN_SUCCESS;
- }
- SmbiosVersion = (UINT16)(QemuAnchor.V2.MajorVersion << 8 |
- QemuAnchor.V2.MinorVersion);
- break;
-
- case sizeof QemuAnchor.V3:
- QemuFwCfgReadBytes (AnchorSize, &QemuAnchor);
-
- if (QemuAnchor.V3.MajorVersion != 3 ||
- QemuAnchor.V3.TableMaximumSize != TablesSize ||
- CompareMem (QemuAnchor.V3.AnchorString, "_SM3_", 5) != 0) {
+ case sizeof QemuAnchor.V2:
+ QemuFwCfgReadBytes (AnchorSize, &QemuAnchor);
+
+ if ((QemuAnchor.V2.MajorVersion != 2) ||
+ (QemuAnchor.V2.TableLength != TablesSize) ||
+ (CompareMem (QemuAnchor.V2.AnchorString, "_SM_", 4) != 0) ||
+ (CompareMem (QemuAnchor.V2.IntermediateAnchorString, "_DMI_", 5) != 0))
+ {
+ return RETURN_SUCCESS;
+ }
+
+ SmbiosVersion = (UINT16)(QemuAnchor.V2.MajorVersion << 8 |
+ QemuAnchor.V2.MinorVersion);
+ break;
+
+ case sizeof QemuAnchor.V3:
+ QemuFwCfgReadBytes (AnchorSize, &QemuAnchor);
+
+ if ((QemuAnchor.V3.MajorVersion != 3) ||
+ (QemuAnchor.V3.TableMaximumSize != TablesSize) ||
+ (CompareMem (QemuAnchor.V3.AnchorString, "_SM3_", 5) != 0))
+ {
+ return RETURN_SUCCESS;
+ }
+
+ SmbiosVersion = (UINT16)(QemuAnchor.V3.MajorVersion << 8 |
+ QemuAnchor.V3.MinorVersion);
+
+ DEBUG ((
+ DEBUG_INFO,
+ "%a: SMBIOS 3.x DocRev from QEMU: 0x%02x\n",
+ __FUNCTION__,
+ QemuAnchor.V3.DocRev
+ ));
+ PcdStatus = PcdSet8S (PcdSmbiosDocRev, QemuAnchor.V3.DocRev);
+ ASSERT_RETURN_ERROR (PcdStatus);
+ break;
+
+ default:
return RETURN_SUCCESS;
- }
- SmbiosVersion = (UINT16)(QemuAnchor.V3.MajorVersion << 8 |
- QemuAnchor.V3.MinorVersion);
-
- DEBUG ((DEBUG_INFO, "%a: SMBIOS 3.x DocRev from QEMU: 0x%02x\n",
- __FUNCTION__, QemuAnchor.V3.DocRev));
- PcdStatus = PcdSet8S (PcdSmbiosDocRev, QemuAnchor.V3.DocRev);
- ASSERT_RETURN_ERROR (PcdStatus);
- break;
-
- default:
- return RETURN_SUCCESS;
}
- DEBUG ((DEBUG_INFO, "%a: SMBIOS version from QEMU: 0x%04x\n", __FUNCTION__,
- SmbiosVersion));
+ DEBUG ((
+ DEBUG_INFO,
+ "%a: SMBIOS version from QEMU: 0x%04x\n",
+ __FUNCTION__,
+ SmbiosVersion
+ ));
PcdStatus = PcdSet16S (PcdSmbiosVersion, SmbiosVersion);
ASSERT_RETURN_ERROR (PcdStatus);
diff --git a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c
index c7cc5b0389..9297cc5fa9 100644
--- a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c
+++ b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c
@@ -25,7 +25,7 @@
//
// EFER register LMA bit
//
-#define LMA BIT10
+#define LMA BIT10
/**
The constructor function
@@ -88,9 +88,9 @@ SmmCpuFeaturesInitializeProcessor (
// Configure SMBASE.
//
CpuState = (QEMU_SMRAM_SAVE_STATE_MAP *)(UINTN)(
- SMM_DEFAULT_SMBASE +
- SMRAM_SAVE_STATE_MAP_OFFSET
- );
+ SMM_DEFAULT_SMBASE +
+ SMRAM_SAVE_STATE_MAP_OFFSET
+ );
if ((CpuState->x86.SMMRevId & 0xFFFF) == 0) {
CpuState->x86.SMBASE = (UINT32)CpuHotPlugData->SmBase[CpuIndex];
} else {
@@ -142,13 +142,13 @@ SmmCpuFeaturesHookReturnFromSmm (
IN UINT64 NewInstructionPointer
)
{
- UINT64 OriginalInstructionPointer;
- QEMU_SMRAM_SAVE_STATE_MAP *CpuSaveState;
+ UINT64 OriginalInstructionPointer;
+ QEMU_SMRAM_SAVE_STATE_MAP *CpuSaveState;
CpuSaveState = (QEMU_SMRAM_SAVE_STATE_MAP *)CpuState;
if ((CpuSaveState->x86.SMMRevId & 0xFFFF) == 0) {
OriginalInstructionPointer = (UINT64)CpuSaveState->x86._EIP;
- CpuSaveState->x86._EIP = (UINT32)NewInstructionPointer;
+ CpuSaveState->x86._EIP = (UINT32)NewInstructionPointer;
//
// Clear the auto HALT restart flag so the RSM instruction returns
// program control to the instruction following the HLT instruction.
@@ -163,6 +163,7 @@ SmmCpuFeaturesHookReturnFromSmm (
} else {
CpuSaveState->x64._RIP = (UINT32)NewInstructionPointer;
}
+
//
// Clear the auto HALT restart flag so the RSM instruction returns
// program control to the instruction following the HLT instruction.
@@ -171,10 +172,11 @@ SmmCpuFeaturesHookReturnFromSmm (
CpuSaveState->x64.AutoHALTRestart &= ~BIT0;
}
}
+
return OriginalInstructionPointer;
}
-STATIC CPU_HOT_EJECT_DATA *mCpuHotEjectData = NULL;
+STATIC CPU_HOT_EJECT_DATA *mCpuHotEjectData = NULL;
/**
Initialize mCpuHotEjectData if PcdCpuMaxLogicalProcessorNumber > 1.
@@ -208,7 +210,8 @@ InitCpuHotEjectData (
if (RETURN_ERROR (SafeUintnMult (MaxNumberOfCpus, sizeof (UINT64), &Size)) ||
RETURN_ERROR (SafeUintnAdd (Size, sizeof (*mCpuHotEjectData), &Size)) ||
- RETURN_ERROR (SafeUintnAdd (Size, sizeof (UINT64) - 1, &Size))) {
+ RETURN_ERROR (SafeUintnAdd (Size, sizeof (UINT64) - 1, &Size)))
+ {
DEBUG ((DEBUG_ERROR, "%a: invalid CPU_HOT_EJECT_DATA\n", __FUNCTION__));
goto Fatal;
}
@@ -219,11 +222,13 @@ InitCpuHotEjectData (
goto Fatal;
}
- mCpuHotEjectData->Handler = NULL;
+ mCpuHotEjectData->Handler = NULL;
mCpuHotEjectData->ArrayLength = MaxNumberOfCpus;
- mCpuHotEjectData->QemuSelectorMap = ALIGN_POINTER (mCpuHotEjectData + 1,
- sizeof (UINT64));
+ mCpuHotEjectData->QemuSelectorMap = ALIGN_POINTER (
+ mCpuHotEjectData + 1,
+ sizeof (UINT64)
+ );
//
// We use mCpuHotEjectData->QemuSelectorMap to map
// ProcessorNum -> QemuSelector. Initialize to invalid values.
@@ -235,8 +240,10 @@ InitCpuHotEjectData (
//
// Expose address of CPU Hot eject Data structure
//
- PcdStatus = PcdSet64S (PcdCpuHotEjectDataAddress,
- (UINTN)(VOID *)mCpuHotEjectData);
+ PcdStatus = PcdSet64S (
+ PcdCpuHotEjectDataAddress,
+ (UINTN)(VOID *)mCpuHotEjectData
+ );
ASSERT_RETURN_ERROR (PcdStatus);
return;
@@ -258,10 +265,9 @@ SmmCpuFeaturesSmmRelocationComplete (
VOID
)
{
- EFI_STATUS Status;
- UINTN MapPagesBase;
- UINTN MapPagesCount;
-
+ EFI_STATUS Status;
+ UINTN MapPagesBase;
+ UINTN MapPagesCount;
InitCpuHotEjectData ();
@@ -286,8 +292,12 @@ SmmCpuFeaturesSmmRelocationComplete (
MapPagesCount // NumPages
);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: MemEncryptSevSetPageEncMask(): %r\n",
- __FUNCTION__, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: MemEncryptSevSetPageEncMask(): %r\n",
+ __FUNCTION__,
+ Status
+ ));
ASSERT (FALSE);
CpuDeadLoop ();
}
@@ -458,7 +468,7 @@ SmmCpuFeaturesRendezvousExit (
//
if (mCpuHotEjectData != NULL) {
- CPU_HOT_EJECT_HANDLER Handler;
+ CPU_HOT_EJECT_HANDLER Handler;
//
// As the comment above mentions, mCpuHotEjectData->Handler might be
@@ -477,7 +487,7 @@ SmmCpuFeaturesRendezvousExit (
// ordered-after the AllCpusInSync loop by using a MemoryFence() with
// acquire semantics.
//
- MemoryFence();
+ MemoryFence ();
Handler = mCpuHotEjectData->Handler;
@@ -564,21 +574,21 @@ SmmCpuFeaturesSetSmmRegister (
/// Macro used to simplify the lookup table entries of type
/// CPU_SMM_SAVE_STATE_LOOKUP_ENTRY
///
-#define SMM_CPU_OFFSET(Field) OFFSET_OF (QEMU_SMRAM_SAVE_STATE_MAP, Field)
+#define SMM_CPU_OFFSET(Field) OFFSET_OF (QEMU_SMRAM_SAVE_STATE_MAP, Field)
///
/// Macro used to simplify the lookup table entries of type
/// CPU_SMM_SAVE_STATE_REGISTER_RANGE
///
-#define SMM_REGISTER_RANGE(Start, End) { Start, End, End - Start + 1 }
+#define SMM_REGISTER_RANGE(Start, End) { Start, End, End - Start + 1 }
///
/// Structure used to describe a range of registers
///
typedef struct {
- EFI_SMM_SAVE_STATE_REGISTER Start;
- EFI_SMM_SAVE_STATE_REGISTER End;
- UINTN Length;
+ EFI_SMM_SAVE_STATE_REGISTER Start;
+ EFI_SMM_SAVE_STATE_REGISTER End;
+ UINTN Length;
} CPU_SMM_SAVE_STATE_REGISTER_RANGE;
///
@@ -586,22 +596,22 @@ typedef struct {
/// associated with each supported EFI_SMM_SAVE_STATE_REGISTER value
///
-#define SMM_SAVE_STATE_REGISTER_FIRST_INDEX 1
+#define SMM_SAVE_STATE_REGISTER_FIRST_INDEX 1
typedef struct {
- UINT8 Width32;
- UINT8 Width64;
- UINT16 Offset32;
- UINT16 Offset64Lo;
- UINT16 Offset64Hi;
- BOOLEAN Writeable;
+ UINT8 Width32;
+ UINT8 Width64;
+ UINT16 Offset32;
+ UINT16 Offset64Lo;
+ UINT16 Offset64Hi;
+ BOOLEAN Writeable;
} CPU_SMM_SAVE_STATE_LOOKUP_ENTRY;
///
/// Table used by GetRegisterIndex() to convert an EFI_SMM_SAVE_STATE_REGISTER
/// value to an index into a table of type CPU_SMM_SAVE_STATE_LOOKUP_ENTRY
///
-STATIC CONST CPU_SMM_SAVE_STATE_REGISTER_RANGE mSmmCpuRegisterRanges[] = {
+STATIC CONST CPU_SMM_SAVE_STATE_REGISTER_RANGE mSmmCpuRegisterRanges[] = {
SMM_REGISTER_RANGE (
EFI_SMM_SAVE_STATE_REGISTER_GDTBASE,
EFI_SMM_SAVE_STATE_REGISTER_LDTINFO
@@ -614,14 +624,14 @@ STATIC CONST CPU_SMM_SAVE_STATE_REGISTER_RANGE mSmmCpuRegisterRanges[] = {
EFI_SMM_SAVE_STATE_REGISTER_RFLAGS,
EFI_SMM_SAVE_STATE_REGISTER_CR4
),
- { (EFI_SMM_SAVE_STATE_REGISTER)0, (EFI_SMM_SAVE_STATE_REGISTER)0, 0 }
+ { (EFI_SMM_SAVE_STATE_REGISTER)0, (EFI_SMM_SAVE_STATE_REGISTER)0,0 }
};
///
/// Lookup table used to retrieve the widths and offsets associated with each
/// supported EFI_SMM_SAVE_STATE_REGISTER value
///
-STATIC CONST CPU_SMM_SAVE_STATE_LOOKUP_ENTRY mSmmCpuWidthOffset[] = {
+STATIC CONST CPU_SMM_SAVE_STATE_LOOKUP_ENTRY mSmmCpuWidthOffset[] = {
{
0, // Width32
0, // Width64
@@ -1001,13 +1011,17 @@ GetRegisterIndex (
for (Index = 0, Offset = SMM_SAVE_STATE_REGISTER_FIRST_INDEX;
mSmmCpuRegisterRanges[Index].Length != 0;
- Index++) {
- if (Register >= mSmmCpuRegisterRanges[Index].Start &&
- Register <= mSmmCpuRegisterRanges[Index].End) {
+ Index++)
+ {
+ if ((Register >= mSmmCpuRegisterRanges[Index].Start) &&
+ (Register <= mSmmCpuRegisterRanges[Index].End))
+ {
return Register - mSmmCpuRegisterRanges[Index].Start + Offset;
}
+
Offset += mSmmCpuRegisterRanges[Index].Length;
}
+
return 0;
}
@@ -1037,10 +1051,10 @@ GetRegisterIndex (
STATIC
EFI_STATUS
ReadSaveStateRegisterByIndex (
- IN UINTN CpuIndex,
- IN UINTN RegisterIndex,
- IN UINTN Width,
- OUT VOID *Buffer
+ IN UINTN CpuIndex,
+ IN UINTN RegisterIndex,
+ IN UINTN Width,
+ OUT VOID *Buffer
)
{
QEMU_SMRAM_SAVE_STATE_MAP *CpuSaveState;
@@ -1067,7 +1081,7 @@ ReadSaveStateRegisterByIndex (
//
// Write return buffer
//
- ASSERT(CpuSaveState != NULL);
+ ASSERT (CpuSaveState != NULL);
CopyMem (
Buffer,
(UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset32,
@@ -1109,6 +1123,7 @@ ReadSaveStateRegisterByIndex (
);
}
}
+
return EFI_SUCCESS;
}
@@ -1139,7 +1154,7 @@ SmmCpuFeaturesReadSaveStateRegister (
OUT VOID *Buffer
)
{
- UINTN RegisterIndex;
+ UINTN RegisterIndex;
QEMU_SMRAM_SAVE_STATE_MAP *CpuSaveState;
//
@@ -1215,7 +1230,7 @@ SmmCpuFeaturesWriteSaveStateRegister (
IN CONST VOID *Buffer
)
{
- UINTN RegisterIndex;
+ UINTN RegisterIndex;
QEMU_SMRAM_SAVE_STATE_MAP *CpuSaveState;
//
@@ -1272,6 +1287,7 @@ SmmCpuFeaturesWriteSaveStateRegister (
if (Width > mSmmCpuWidthOffset[RegisterIndex].Width32) {
return EFI_INVALID_PARAMETER;
}
+
//
// Write SMM State register
//
@@ -1317,6 +1333,7 @@ SmmCpuFeaturesWriteSaveStateRegister (
);
}
}
+
return EFI_SUCCESS;
}
@@ -1357,9 +1374,8 @@ SmmCpuFeaturesCompleteSmmReadyToLock (
VOID *
EFIAPI
SmmCpuFeaturesAllocatePageTableMemory (
- IN UINTN Pages
+ IN UINTN Pages
)
{
return NULL;
}
-
diff --git a/OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQemu.c b/OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQemu.c
index c88a95c6de..4df057101e 100644
--- a/OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQemu.c
+++ b/OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQemu.c
@@ -75,13 +75,13 @@ ClearTopLevelSmiStatus (
EFI_STATUS
EFIAPI
PlatformSmmBspElection (
- OUT BOOLEAN *IsBsp
+ OUT BOOLEAN *IsBsp
)
{
- MSR_IA32_APIC_BASE_REGISTER ApicBaseMsr;
+ MSR_IA32_APIC_BASE_REGISTER ApicBaseMsr;
ApicBaseMsr.Uint64 = AsmReadMsr64 (MSR_IA32_APIC_BASE);
- *IsBsp = (BOOLEAN)(ApicBaseMsr.Bits.BSP == 1);
+ *IsBsp = (BOOLEAN)(ApicBaseMsr.Bits.BSP == 1);
return EFI_SUCCESS;
}
@@ -105,10 +105,10 @@ PlatformSmmBspElection (
EFI_STATUS
EFIAPI
GetPlatformPageTableAttribute (
- IN UINT64 Address,
- IN OUT SMM_PAGE_SIZE_TYPE *PageSize,
- IN OUT UINTN *NumOfPages,
- IN OUT UINTN *PageAttribute
+ IN UINT64 Address,
+ IN OUT SMM_PAGE_SIZE_TYPE *PageSize,
+ IN OUT UINTN *NumOfPages,
+ IN OUT UINTN *PageAttribute
)
{
return EFI_UNSUPPORTED;
diff --git a/OvmfPkg/Library/Tcg2PhysicalPresenceLibNull/DxeTcg2PhysicalPresenceLib.c b/OvmfPkg/Library/Tcg2PhysicalPresenceLibNull/DxeTcg2PhysicalPresenceLib.c
index 52455dd350..f664256c21 100644
--- a/OvmfPkg/Library/Tcg2PhysicalPresenceLibNull/DxeTcg2PhysicalPresenceLib.c
+++ b/OvmfPkg/Library/Tcg2PhysicalPresenceLibNull/DxeTcg2PhysicalPresenceLib.c
@@ -12,7 +12,7 @@
VOID
EFIAPI
Tcg2PhysicalPresenceLibProcessRequest (
- IN TPM2B_AUTH *PlatformAuth OPTIONAL
+ IN TPM2B_AUTH *PlatformAuth OPTIONAL
)
{
//
diff --git a/OvmfPkg/Library/Tcg2PhysicalPresenceLibQemu/DxeTcg2PhysicalPresenceLib.c b/OvmfPkg/Library/Tcg2PhysicalPresenceLibQemu/DxeTcg2PhysicalPresenceLib.c
index 80aad5a373..4038020251 100644
--- a/OvmfPkg/Library/Tcg2PhysicalPresenceLibQemu/DxeTcg2PhysicalPresenceLib.c
+++ b/OvmfPkg/Library/Tcg2PhysicalPresenceLibQemu/DxeTcg2PhysicalPresenceLib.c
@@ -36,14 +36,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/Tcg2PhysicalPresenceLib.h>
-#define CONFIRM_BUFFER_SIZE 4096
+#define CONFIRM_BUFFER_SIZE 4096
-EFI_HII_HANDLE mTcg2PpStringPackHandle;
+EFI_HII_HANDLE mTcg2PpStringPackHandle;
-#define TPM_PPI_FLAGS (QEMU_TPM_PPI_FUNC_ALLOWED_USR_REQ)
-
-STATIC volatile QEMU_TPM_PPI *mPpi;
+#define TPM_PPI_FLAGS (QEMU_TPM_PPI_FUNC_ALLOWED_USR_REQ)
+STATIC volatile QEMU_TPM_PPI *mPpi;
/**
Reads QEMU PPI config from fw_cfg.
@@ -56,12 +55,12 @@ STATIC volatile QEMU_TPM_PPI *mPpi;
STATIC
EFI_STATUS
QemuTpmReadConfig (
- OUT QEMU_FWCFG_TPM_CONFIG *Config
+ OUT QEMU_FWCFG_TPM_CONFIG *Config
)
{
- EFI_STATUS Status;
- FIRMWARE_CONFIG_ITEM FwCfgItem;
- UINTN FwCfgSize;
+ EFI_STATUS Status;
+ FIRMWARE_CONFIG_ITEM FwCfgItem;
+ UINTN FwCfgSize;
Status = QemuFwCfgFindFile ("etc/tpm/config", &FwCfgItem, &FwCfgSize);
if (EFI_ERROR (Status)) {
@@ -77,7 +76,6 @@ QemuTpmReadConfig (
return EFI_SUCCESS;
}
-
/**
Initializes QEMU PPI memory region.
@@ -90,11 +88,11 @@ QemuTpmInitPPI (
VOID
)
{
- EFI_STATUS Status;
- QEMU_FWCFG_TPM_CONFIG Config;
- EFI_PHYSICAL_ADDRESS PpiAddress64;
- EFI_GCD_MEMORY_SPACE_DESCRIPTOR Descriptor;
- UINTN Idx;
+ EFI_STATUS Status;
+ QEMU_FWCFG_TPM_CONFIG Config;
+ EFI_PHYSICAL_ADDRESS PpiAddress64;
+ EFI_GCD_MEMORY_SPACE_DESCRIPTOR Descriptor;
+ UINTN Idx;
if (mPpi != NULL) {
return EFI_SUCCESS;
@@ -114,19 +112,22 @@ QemuTpmInitPPI (
PpiAddress64 = (UINTN)mPpi;
if ((PpiAddress64 & ~(UINT64)EFI_PAGE_MASK) !=
- ((PpiAddress64 + sizeof *mPpi - 1) & ~(UINT64)EFI_PAGE_MASK)) {
+ ((PpiAddress64 + sizeof *mPpi - 1) & ~(UINT64)EFI_PAGE_MASK))
+ {
DEBUG ((DEBUG_ERROR, "[TPM2PP] mPpi crosses a page boundary\n"));
goto InvalidPpiAddress;
}
Status = gDS->GetMemorySpaceDescriptor (PpiAddress64, &Descriptor);
- if (EFI_ERROR (Status) && Status != EFI_NOT_FOUND) {
+ if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
ASSERT_EFI_ERROR (Status);
goto InvalidPpiAddress;
}
+
if (!EFI_ERROR (Status) &&
- (Descriptor.GcdMemoryType != EfiGcdMemoryTypeMemoryMappedIo &&
- Descriptor.GcdMemoryType != EfiGcdMemoryTypeNonExistent)) {
+ ((Descriptor.GcdMemoryType != EfiGcdMemoryTypeMemoryMappedIo) &&
+ (Descriptor.GcdMemoryType != EfiGcdMemoryTypeNonExistent)))
+ {
DEBUG ((DEBUG_ERROR, "[TPM2PP] mPpi has an invalid memory type\n"));
goto InvalidPpiAddress;
}
@@ -134,24 +135,25 @@ QemuTpmInitPPI (
for (Idx = 0; Idx < ARRAY_SIZE (mPpi->Func); Idx++) {
mPpi->Func[Idx] = 0;
}
+
if (Config.TpmVersion == QEMU_TPM_VERSION_2) {
- mPpi->Func[TCG2_PHYSICAL_PRESENCE_NO_ACTION] = TPM_PPI_FLAGS;
- mPpi->Func[TCG2_PHYSICAL_PRESENCE_CLEAR] = TPM_PPI_FLAGS;
- mPpi->Func[TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR] = TPM_PPI_FLAGS;
- mPpi->Func[TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR_2] = TPM_PPI_FLAGS;
- mPpi->Func[TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR_3] = TPM_PPI_FLAGS;
- mPpi->Func[TCG2_PHYSICAL_PRESENCE_SET_PCR_BANKS] = TPM_PPI_FLAGS;
- mPpi->Func[TCG2_PHYSICAL_PRESENCE_CHANGE_EPS] = TPM_PPI_FLAGS;
- mPpi->Func[TCG2_PHYSICAL_PRESENCE_LOG_ALL_DIGESTS] = TPM_PPI_FLAGS;
- mPpi->Func[TCG2_PHYSICAL_PRESENCE_ENABLE_BLOCK_SID] = TPM_PPI_FLAGS;
+ mPpi->Func[TCG2_PHYSICAL_PRESENCE_NO_ACTION] = TPM_PPI_FLAGS;
+ mPpi->Func[TCG2_PHYSICAL_PRESENCE_CLEAR] = TPM_PPI_FLAGS;
+ mPpi->Func[TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR] = TPM_PPI_FLAGS;
+ mPpi->Func[TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR_2] = TPM_PPI_FLAGS;
+ mPpi->Func[TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR_3] = TPM_PPI_FLAGS;
+ mPpi->Func[TCG2_PHYSICAL_PRESENCE_SET_PCR_BANKS] = TPM_PPI_FLAGS;
+ mPpi->Func[TCG2_PHYSICAL_PRESENCE_CHANGE_EPS] = TPM_PPI_FLAGS;
+ mPpi->Func[TCG2_PHYSICAL_PRESENCE_LOG_ALL_DIGESTS] = TPM_PPI_FLAGS;
+ mPpi->Func[TCG2_PHYSICAL_PRESENCE_ENABLE_BLOCK_SID] = TPM_PPI_FLAGS;
mPpi->Func[TCG2_PHYSICAL_PRESENCE_DISABLE_BLOCK_SID] = TPM_PPI_FLAGS;
}
if (mPpi->In == 0) {
- mPpi->In = 1;
- mPpi->Request = TCG2_PHYSICAL_PRESENCE_NO_ACTION;
+ mPpi->In = 1;
+ mPpi->Request = TCG2_PHYSICAL_PRESENCE_NO_ACTION;
mPpi->LastRequest = TCG2_PHYSICAL_PRESENCE_NO_ACTION;
- mPpi->NextStep = TCG2_PHYSICAL_PRESENCE_NO_ACTION;
+ mPpi->NextStep = TCG2_PHYSICAL_PRESENCE_NO_ACTION;
}
return EFI_SUCCESS;
@@ -161,7 +163,6 @@ InvalidPpiAddress:
return EFI_PROTOCOL_ERROR;
}
-
/**
Get string by string id from HII Interface.
@@ -174,13 +175,12 @@ InvalidPpiAddress:
STATIC
CHAR16 *
Tcg2PhysicalPresenceGetStringById (
- IN EFI_STRING_ID Id
+ IN EFI_STRING_ID Id
)
{
return HiiGetString (mTcg2PpStringPackHandle, Id, NULL);
}
-
/**
Send ClearControl and Clear command to TPM.
@@ -195,12 +195,12 @@ Tcg2PhysicalPresenceGetStringById (
EFI_STATUS
EFIAPI
Tpm2CommandClear (
- IN TPM2B_AUTH *PlatformAuth OPTIONAL
+ IN TPM2B_AUTH *PlatformAuth OPTIONAL
)
{
- EFI_STATUS Status;
- TPMS_AUTH_COMMAND *AuthSession;
- TPMS_AUTH_COMMAND LocalAuthSession;
+ EFI_STATUS Status;
+ TPMS_AUTH_COMMAND *AuthSession;
+ TPMS_AUTH_COMMAND LocalAuthSession;
if (PlatformAuth == NULL) {
AuthSession = NULL;
@@ -208,7 +208,7 @@ Tpm2CommandClear (
AuthSession = &LocalAuthSession;
ZeroMem (&LocalAuthSession, sizeof (LocalAuthSession));
LocalAuthSession.sessionHandle = TPM_RS_PW;
- LocalAuthSession.hmac.size = PlatformAuth->size;
+ LocalAuthSession.hmac.size = PlatformAuth->size;
CopyMem (LocalAuthSession.hmac.buffer, PlatformAuth->buffer, PlatformAuth->size);
}
@@ -218,6 +218,7 @@ Tpm2CommandClear (
if (EFI_ERROR (Status)) {
goto Done;
}
+
DEBUG ((DEBUG_INFO, "Tpm2Clear ... \n"));
Status = Tpm2Clear (TPM_RH_PLATFORM, AuthSession);
DEBUG ((DEBUG_INFO, "Tpm2Clear - %r\n", Status));
@@ -227,7 +228,6 @@ Done:
return Status;
}
-
/**
Change EPS.
@@ -238,12 +238,12 @@ Done:
STATIC
EFI_STATUS
Tpm2CommandChangeEps (
- IN TPM2B_AUTH *PlatformAuth OPTIONAL
+ IN TPM2B_AUTH *PlatformAuth OPTIONAL
)
{
- EFI_STATUS Status;
- TPMS_AUTH_COMMAND *AuthSession;
- TPMS_AUTH_COMMAND LocalAuthSession;
+ EFI_STATUS Status;
+ TPMS_AUTH_COMMAND *AuthSession;
+ TPMS_AUTH_COMMAND LocalAuthSession;
if (PlatformAuth == NULL) {
AuthSession = NULL;
@@ -251,18 +251,17 @@ Tpm2CommandChangeEps (
AuthSession = &LocalAuthSession;
ZeroMem (&LocalAuthSession, sizeof (LocalAuthSession));
LocalAuthSession.sessionHandle = TPM_RS_PW;
- LocalAuthSession.hmac.size = PlatformAuth->size;
+ LocalAuthSession.hmac.size = PlatformAuth->size;
CopyMem (LocalAuthSession.hmac.buffer, PlatformAuth->buffer, PlatformAuth->size);
}
Status = Tpm2ChangeEPS (TPM_RH_PLATFORM, AuthSession);
DEBUG ((DEBUG_INFO, "Tpm2ChangeEPS - %r\n", Status));
- ZeroMem (&LocalAuthSession.hmac, sizeof(LocalAuthSession.hmac));
+ ZeroMem (&LocalAuthSession.hmac, sizeof (LocalAuthSession.hmac));
return Status;
}
-
/**
Execute physical presence operation requested by the OS.
@@ -278,14 +277,14 @@ Tpm2CommandChangeEps (
STATIC
UINT32
Tcg2ExecutePhysicalPresence (
- IN TPM2B_AUTH *PlatformAuth OPTIONAL,
- IN UINT32 CommandCode,
- IN UINT32 CommandParameter
+ IN TPM2B_AUTH *PlatformAuth OPTIONAL,
+ IN UINT32 CommandCode,
+ IN UINT32 CommandParameter
)
{
- EFI_STATUS Status;
- EFI_TCG2_EVENT_ALGORITHM_BITMAP TpmHashAlgorithmBitmap;
- UINT32 ActivePcrBanks;
+ EFI_STATUS Status;
+ EFI_TCG2_EVENT_ALGORITHM_BITMAP TpmHashAlgorithmBitmap;
+ UINT32 ActivePcrBanks;
switch (CommandCode) {
case TCG2_PHYSICAL_PRESENCE_CLEAR:
@@ -309,8 +308,8 @@ Tcg2ExecutePhysicalPresence (
// Firmware has to ensure that at least one PCR banks is active.
// If not, an error is returned and no action is taken.
//
- if (CommandParameter == 0 || (CommandParameter & (~TpmHashAlgorithmBitmap)) != 0) {
- DEBUG((DEBUG_ERROR, "PCR banks %x to allocate are not supported by TPM. Skip operation\n", CommandParameter));
+ if ((CommandParameter == 0) || ((CommandParameter & (~TpmHashAlgorithmBitmap)) != 0)) {
+ DEBUG ((DEBUG_ERROR, "PCR banks %x to allocate are not supported by TPM. Skip operation\n", CommandParameter));
return TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE;
}
@@ -348,7 +347,6 @@ Tcg2ExecutePhysicalPresence (
}
}
-
/**
Read the specified key for user confirmation.
@@ -361,12 +359,12 @@ Tcg2ExecutePhysicalPresence (
STATIC
BOOLEAN
Tcg2ReadUserKey (
- IN BOOLEAN CautionKey
+ IN BOOLEAN CautionKey
)
{
- EFI_STATUS Status;
- EFI_INPUT_KEY Key;
- UINT16 InputKey;
+ EFI_STATUS Status;
+ EFI_INPUT_KEY Key;
+ UINT16 InputKey;
InputKey = 0;
do {
@@ -376,9 +374,11 @@ Tcg2ReadUserKey (
if (Key.ScanCode == SCAN_ESC) {
InputKey = Key.ScanCode;
}
+
if ((Key.ScanCode == SCAN_F10) && !CautionKey) {
InputKey = Key.ScanCode;
}
+
if ((Key.ScanCode == SCAN_F12) && CautionKey) {
InputKey = Key.ScanCode;
}
@@ -392,7 +392,6 @@ Tcg2ReadUserKey (
return FALSE;
}
-
/**
Fill Buffer With BootHashAlg.
@@ -414,35 +413,43 @@ Tcg2FillBufferWithBootHashAlg (
if (Buffer[0] != 0) {
StrnCatS (Buffer, BufferSize / sizeof (CHAR16), L", ", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);
}
+
StrnCatS (Buffer, BufferSize / sizeof (CHAR16), L"SHA1", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);
}
+
if ((BootHashAlg & EFI_TCG2_BOOT_HASH_ALG_SHA256) != 0) {
if (Buffer[0] != 0) {
StrnCatS (Buffer, BufferSize / sizeof (CHAR16), L", ", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);
}
+
StrnCatS (Buffer, BufferSize / sizeof (CHAR16), L"SHA256", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);
}
+
if ((BootHashAlg & EFI_TCG2_BOOT_HASH_ALG_SHA384) != 0) {
if (Buffer[0] != 0) {
StrnCatS (Buffer, BufferSize / sizeof (CHAR16), L", ", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);
}
+
StrnCatS (Buffer, BufferSize / sizeof (CHAR16), L"SHA384", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);
}
+
if ((BootHashAlg & EFI_TCG2_BOOT_HASH_ALG_SHA512) != 0) {
if (Buffer[0] != 0) {
StrnCatS (Buffer, BufferSize / sizeof (CHAR16), L", ", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);
}
+
StrnCatS (Buffer, BufferSize / sizeof (CHAR16), L"SHA512", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);
}
+
if ((BootHashAlg & EFI_TCG2_BOOT_HASH_ALG_SM3_256) != 0) {
if (Buffer[0] != 0) {
StrnCatS (Buffer, BufferSize / sizeof (CHAR16), L", ", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);
}
+
StrnCatS (Buffer, BufferSize / sizeof (CHAR16), L"SM3_256", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);
}
}
-
/**
Display the confirm text and get user confirmation.
@@ -455,8 +462,8 @@ Tcg2FillBufferWithBootHashAlg (
STATIC
BOOLEAN
Tcg2UserConfirm (
- IN UINT32 TpmPpCommand,
- IN UINT32 TpmPpCommandParameter
+ IN UINT32 TpmPpCommand,
+ IN UINT32 TpmPpCommandParameter
)
{
CHAR16 *ConfirmText;
@@ -485,13 +492,12 @@ Tcg2UserConfirm (
ASSERT (mTcg2PpStringPackHandle != NULL);
switch (TpmPpCommand) {
-
case TCG2_PHYSICAL_PRESENCE_CLEAR:
case TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR:
case TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR_2:
case TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR_3:
CautionKey = TRUE;
- TmpStr2 = Tcg2PhysicalPresenceGetStringById (STRING_TOKEN (TPM_CLEAR));
+ TmpStr2 = Tcg2PhysicalPresenceGetStringById (STRING_TOKEN (TPM_CLEAR));
TmpStr1 = Tcg2PhysicalPresenceGetStringById (STRING_TOKEN (TPM_HEAD_STR));
UnicodeSPrint (ConfirmText, BufSize, TmpStr1, TmpStr2);
@@ -505,14 +511,14 @@ Tcg2UserConfirm (
break;
case TCG2_PHYSICAL_PRESENCE_SET_PCR_BANKS:
- Status = gBS->LocateProtocol (&gEfiTcg2ProtocolGuid, NULL, (VOID **) &Tcg2Protocol);
+ Status = gBS->LocateProtocol (&gEfiTcg2ProtocolGuid, NULL, (VOID **)&Tcg2Protocol);
ASSERT_EFI_ERROR (Status);
- ProtocolCapability.Size = sizeof(ProtocolCapability);
- Status = Tcg2Protocol->GetCapability (
- Tcg2Protocol,
- &ProtocolCapability
- );
+ ProtocolCapability.Size = sizeof (ProtocolCapability);
+ Status = Tcg2Protocol->GetCapability (
+ Tcg2Protocol,
+ &ProtocolCapability
+ );
ASSERT_EFI_ERROR (Status);
Status = Tcg2Protocol->GetActivePcrBanks (
@@ -522,7 +528,7 @@ Tcg2UserConfirm (
ASSERT_EFI_ERROR (Status);
CautionKey = TRUE;
- TmpStr2 = Tcg2PhysicalPresenceGetStringById (STRING_TOKEN (TPM_SET_PCR_BANKS));
+ TmpStr2 = Tcg2PhysicalPresenceGetStringById (STRING_TOKEN (TPM_SET_PCR_BANKS));
TmpStr1 = Tcg2PhysicalPresenceGetStringById (STRING_TOKEN (TPM_HEAD_STR));
UnicodeSPrint (ConfirmText, BufSize, TmpStr1, TmpStr2);
@@ -536,8 +542,8 @@ Tcg2UserConfirm (
StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
FreePool (TmpStr1);
- Tcg2FillBufferWithBootHashAlg (TempBuffer, sizeof(TempBuffer), TpmPpCommandParameter);
- Tcg2FillBufferWithBootHashAlg (TempBuffer2, sizeof(TempBuffer2), CurrentPCRBanks);
+ Tcg2FillBufferWithBootHashAlg (TempBuffer, sizeof (TempBuffer), TpmPpCommandParameter);
+ Tcg2FillBufferWithBootHashAlg (TempBuffer2, sizeof (TempBuffer2), CurrentPCRBanks);
TmpStr1 = AllocateZeroPool (BufSize);
ASSERT (TmpStr1 != NULL);
@@ -551,7 +557,7 @@ Tcg2UserConfirm (
case TCG2_PHYSICAL_PRESENCE_CHANGE_EPS:
CautionKey = TRUE;
- TmpStr2 = Tcg2PhysicalPresenceGetStringById (STRING_TOKEN (TPM_CHANGE_EPS));
+ TmpStr2 = Tcg2PhysicalPresenceGetStringById (STRING_TOKEN (TPM_CHANGE_EPS));
TmpStr1 = Tcg2PhysicalPresenceGetStringById (STRING_TOKEN (TPM_HEAD_STR));
UnicodeSPrint (ConfirmText, BufSize, TmpStr1, TmpStr2);
@@ -602,6 +608,7 @@ Tcg2UserConfirm (
} else {
TmpStr1 = Tcg2PhysicalPresenceGetStringById (STRING_TOKEN (TPM_ACCEPT_KEY));
}
+
StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
FreePool (TmpStr1);
@@ -618,6 +625,7 @@ Tcg2UserConfirm (
} else {
TmpStr1 = Tcg2PhysicalPresenceGetStringById (STRING_TOKEN (TCG_STORAGE_ACCEPT_KEY));
}
+
StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen (ConfirmText) - 1);
FreePool (TmpStr1);
@@ -629,6 +637,7 @@ Tcg2UserConfirm (
TmpStr1 = Tcg2PhysicalPresenceGetStringById (STRING_TOKEN (TCG_STORAGE_REJECT_KEY));
}
+
BufSize -= StrSize (ConfirmText);
UnicodeSPrint (ConfirmText + StrLen (ConfirmText), BufSize, TmpStr1, TmpStr2);
@@ -650,7 +659,6 @@ Tcg2UserConfirm (
return FALSE;
}
-
/**
Check if there is a valid physical presence command request. Also updates parameter value
to whether the requested physical presence command already confirmed by user
@@ -667,11 +675,11 @@ Tcg2UserConfirm (
STATIC
BOOLEAN
Tcg2HaveValidTpmRequest (
- OUT BOOLEAN *RequestConfirmed
+ OUT BOOLEAN *RequestConfirmed
)
{
- EFI_TCG2_PROTOCOL *Tcg2Protocol;
- EFI_STATUS Status;
+ EFI_TCG2_PROTOCOL *Tcg2Protocol;
+ EFI_STATUS Status;
*RequestConfirmed = FALSE;
@@ -679,7 +687,7 @@ Tcg2HaveValidTpmRequest (
//
// Need TCG2 protocol.
//
- Status = gBS->LocateProtocol (&gEfiTcg2ProtocolGuid, NULL, (VOID **) &Tcg2Protocol);
+ Status = gBS->LocateProtocol (&gEfiTcg2ProtocolGuid, NULL, (VOID **)&Tcg2Protocol);
if (EFI_ERROR (Status)) {
return FALSE;
}
@@ -714,7 +722,6 @@ Tcg2HaveValidTpmRequest (
return TRUE;
}
-
/**
Check and execute the requested physical presence command.
@@ -723,10 +730,10 @@ Tcg2HaveValidTpmRequest (
STATIC
VOID
Tcg2ExecutePendingTpmRequest (
- IN TPM2B_AUTH *PlatformAuth OPTIONAL
+ IN TPM2B_AUTH *PlatformAuth OPTIONAL
)
{
- BOOLEAN RequestConfirmed;
+ BOOLEAN RequestConfirmed;
if (mPpi->Request == TCG2_PHYSICAL_PRESENCE_NO_ACTION) {
//
@@ -744,8 +751,9 @@ Tcg2ExecutePendingTpmRequest (
} else {
mPpi->Response = TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE;
}
- mPpi->LastRequest = mPpi->Request;
- mPpi->Request = TCG2_PHYSICAL_PRESENCE_NO_ACTION;
+
+ mPpi->LastRequest = mPpi->Request;
+ mPpi->Request = TCG2_PHYSICAL_PRESENCE_NO_ACTION;
mPpi->RequestParameter = 0;
return;
}
@@ -763,17 +771,17 @@ Tcg2ExecutePendingTpmRequest (
mPpi->Response = TCG_PP_OPERATION_RESPONSE_USER_ABORT;
if (RequestConfirmed) {
mPpi->Response = Tcg2ExecutePhysicalPresence (
- PlatformAuth,
- mPpi->Request,
- mPpi->RequestParameter
- );
+ PlatformAuth,
+ mPpi->Request,
+ mPpi->RequestParameter
+ );
}
//
// Clear request
//
- mPpi->LastRequest = mPpi->Request;
- mPpi->Request = TCG2_PHYSICAL_PRESENCE_NO_ACTION;
+ mPpi->LastRequest = mPpi->Request;
+ mPpi->Request = TCG2_PHYSICAL_PRESENCE_NO_ACTION;
mPpi->RequestParameter = 0;
if (mPpi->Response == TCG_PP_OPERATION_RESPONSE_USER_ABORT) {
@@ -784,24 +792,25 @@ Tcg2ExecutePendingTpmRequest (
// Reset system to make new TPM settings in effect
//
switch (mPpi->LastRequest) {
- case TCG2_PHYSICAL_PRESENCE_CLEAR:
- case TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR:
- case TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR_2:
- case TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR_3:
- case TCG2_PHYSICAL_PRESENCE_SET_PCR_BANKS:
- case TCG2_PHYSICAL_PRESENCE_CHANGE_EPS:
- case TCG2_PHYSICAL_PRESENCE_LOG_ALL_DIGESTS:
- break;
-
- case TCG2_PHYSICAL_PRESENCE_ENABLE_BLOCK_SID:
- case TCG2_PHYSICAL_PRESENCE_DISABLE_BLOCK_SID:
- break;
-
- default:
- if (mPpi->Request != TCG2_PHYSICAL_PRESENCE_NO_ACTION) {
+ case TCG2_PHYSICAL_PRESENCE_CLEAR:
+ case TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR:
+ case TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR_2:
+ case TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR_3:
+ case TCG2_PHYSICAL_PRESENCE_SET_PCR_BANKS:
+ case TCG2_PHYSICAL_PRESENCE_CHANGE_EPS:
+ case TCG2_PHYSICAL_PRESENCE_LOG_ALL_DIGESTS:
break;
- }
- return;
+
+ case TCG2_PHYSICAL_PRESENCE_ENABLE_BLOCK_SID:
+ case TCG2_PHYSICAL_PRESENCE_DISABLE_BLOCK_SID:
+ break;
+
+ default:
+ if (mPpi->Request != TCG2_PHYSICAL_PRESENCE_NO_ACTION) {
+ break;
+ }
+
+ return;
}
Print (L"Rebooting system to make TPM2 settings in effect\n");
@@ -809,7 +818,6 @@ Tcg2ExecutePendingTpmRequest (
ASSERT (FALSE);
}
-
/**
Check and execute the pending TPM request.
@@ -826,15 +834,15 @@ Tcg2ExecutePendingTpmRequest (
VOID
EFIAPI
Tcg2PhysicalPresenceLibProcessRequest (
- IN TPM2B_AUTH *PlatformAuth OPTIONAL
+ IN TPM2B_AUTH *PlatformAuth OPTIONAL
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = QemuTpmInitPPI ();
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "[TPM2PP] no PPI\n"));
- return ;
+ return;
}
//
@@ -842,14 +850,13 @@ Tcg2PhysicalPresenceLibProcessRequest (
//
if (GetBootModeHob () == BOOT_ON_S4_RESUME) {
DEBUG ((DEBUG_INFO, "S4 Resume, Skip TPM PP process!\n"));
- return ;
+ return;
}
DEBUG ((DEBUG_INFO, "[TPM2PP] PPRequest=%x (PPRequestParameter=%x)\n", mPpi->Request, mPpi->RequestParameter));
Tcg2ExecutePendingTpmRequest (PlatformAuth);
}
-
/**
The handler for TPM physical presence function:
Return TPM Operation Response to OS Environment.
@@ -862,11 +869,11 @@ Tcg2PhysicalPresenceLibProcessRequest (
UINT32
EFIAPI
Tcg2PhysicalPresenceLibReturnOperationResponseToOsFunction (
- OUT UINT32 *MostRecentRequest,
- OUT UINT32 *Response
+ OUT UINT32 *MostRecentRequest,
+ OUT UINT32 *Response
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
DEBUG ((DEBUG_INFO, "[TPM2PP] ReturnOperationResponseToOsFunction\n"));
@@ -884,7 +891,6 @@ Tcg2PhysicalPresenceLibReturnOperationResponseToOsFunction (
return TCG_PP_RETURN_TPM_OPERATION_RESPONSE_SUCCESS;
}
-
/**
The handler for TPM physical presence function:
Submit TPM Operation Request to Pre-OS Environment and
@@ -901,11 +907,11 @@ Tcg2PhysicalPresenceLibReturnOperationResponseToOsFunction (
UINT32
EFIAPI
Tcg2PhysicalPresenceLibSubmitRequestToPreOSFunction (
- IN UINT32 OperationRequest,
- IN UINT32 RequestParameter
+ IN UINT32 OperationRequest,
+ IN UINT32 RequestParameter
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
DEBUG ((DEBUG_INFO, "[TPM2PP] SubmitRequestToPreOSFunction, Request = %x, %x\n", OperationRequest, RequestParameter));
@@ -915,7 +921,7 @@ Tcg2PhysicalPresenceLibSubmitRequestToPreOSFunction (
return TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE;
}
- mPpi->Request = OperationRequest;
+ mPpi->Request = OperationRequest;
mPpi->RequestParameter = RequestParameter;
return TCG_PP_SUBMIT_REQUEST_TO_PREOS_SUCCESS;
diff --git a/OvmfPkg/Library/TlsAuthConfigLib/TlsAuthConfigLib.c b/OvmfPkg/Library/TlsAuthConfigLib/TlsAuthConfigLib.c
index 14b6a2a540..e22de4f5d4 100644
--- a/OvmfPkg/Library/TlsAuthConfigLib/TlsAuthConfigLib.c
+++ b/OvmfPkg/Library/TlsAuthConfigLib/TlsAuthConfigLib.c
@@ -36,16 +36,23 @@ SetCaCerts (
VOID
)
{
- EFI_STATUS Status;
- FIRMWARE_CONFIG_ITEM HttpsCaCertsItem;
- UINTN HttpsCaCertsSize;
- VOID *HttpsCaCerts;
+ EFI_STATUS Status;
+ FIRMWARE_CONFIG_ITEM HttpsCaCertsItem;
+ UINTN HttpsCaCertsSize;
+ VOID *HttpsCaCerts;
- Status = QemuFwCfgFindFile ("etc/edk2/https/cacerts", &HttpsCaCertsItem,
- &HttpsCaCertsSize);
+ Status = QemuFwCfgFindFile (
+ "etc/edk2/https/cacerts",
+ &HttpsCaCertsItem,
+ &HttpsCaCertsSize
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_VERBOSE, "%a:%a: not touching CA cert list\n",
- gEfiCallerBaseName, __FUNCTION__));
+ DEBUG ((
+ DEBUG_VERBOSE,
+ "%a:%a: not touching CA cert list\n",
+ gEfiCallerBaseName,
+ __FUNCTION__
+ ));
return;
}
@@ -72,23 +79,36 @@ SetCaCerts (
//
// This is fatal.
//
- DEBUG ((DEBUG_ERROR, "%a:%a: failed to delete %g:\"%s\"\n",
- gEfiCallerBaseName, __FUNCTION__, &gEfiTlsCaCertificateGuid,
- EFI_TLS_CA_CERTIFICATE_VARIABLE));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a:%a: failed to delete %g:\"%s\"\n",
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ &gEfiTlsCaCertificateGuid,
+ EFI_TLS_CA_CERTIFICATE_VARIABLE
+ ));
ASSERT_EFI_ERROR (Status);
CpuDeadLoop ();
}
if (HttpsCaCertsSize == 0) {
- DEBUG ((DEBUG_VERBOSE, "%a:%a: applied empty CA cert list\n",
- gEfiCallerBaseName, __FUNCTION__));
+ DEBUG ((
+ DEBUG_VERBOSE,
+ "%a:%a: applied empty CA cert list\n",
+ gEfiCallerBaseName,
+ __FUNCTION__
+ ));
return;
}
HttpsCaCerts = AllocatePool (HttpsCaCertsSize);
if (HttpsCaCerts == NULL) {
- DEBUG ((DEBUG_ERROR, "%a:%a: failed to allocate HttpsCaCerts\n",
- gEfiCallerBaseName, __FUNCTION__));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a:%a: failed to allocate HttpsCaCerts\n",
+ gEfiCallerBaseName,
+ __FUNCTION__
+ ));
return;
}
@@ -103,14 +123,25 @@ SetCaCerts (
HttpsCaCerts // Data
);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a:%a: failed to set %g:\"%s\": %r\n",
- gEfiCallerBaseName, __FUNCTION__, &gEfiTlsCaCertificateGuid,
- EFI_TLS_CA_CERTIFICATE_VARIABLE, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a:%a: failed to set %g:\"%s\": %r\n",
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ &gEfiTlsCaCertificateGuid,
+ EFI_TLS_CA_CERTIFICATE_VARIABLE,
+ Status
+ ));
goto FreeHttpsCaCerts;
}
- DEBUG ((DEBUG_VERBOSE, "%a:%a: stored CA cert list (%Lu byte(s))\n",
- gEfiCallerBaseName, __FUNCTION__, (UINT64)HttpsCaCertsSize));
+ DEBUG ((
+ DEBUG_VERBOSE,
+ "%a:%a: stored CA cert list (%Lu byte(s))\n",
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ (UINT64)HttpsCaCertsSize
+ ));
FreeHttpsCaCerts:
FreePool (HttpsCaCerts);
@@ -130,18 +161,26 @@ SetCipherSuites (
VOID
)
{
- EFI_STATUS Status;
- FIRMWARE_CONFIG_ITEM HttpsCiphersItem;
- UINTN HttpsCiphersSize;
- VOID *HttpsCiphers;
+ EFI_STATUS Status;
+ FIRMWARE_CONFIG_ITEM HttpsCiphersItem;
+ UINTN HttpsCiphersSize;
+ VOID *HttpsCiphers;
- Status = QemuFwCfgFindFile ("etc/edk2/https/ciphers", &HttpsCiphersItem,
- &HttpsCiphersSize);
+ Status = QemuFwCfgFindFile (
+ "etc/edk2/https/ciphers",
+ &HttpsCiphersItem,
+ &HttpsCiphersSize
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_VERBOSE, "%a:%a: not touching cipher suites\n",
- gEfiCallerBaseName, __FUNCTION__));
+ DEBUG ((
+ DEBUG_VERBOSE,
+ "%a:%a: not touching cipher suites\n",
+ gEfiCallerBaseName,
+ __FUNCTION__
+ ));
return;
}
+
//
// From this point on, any failure is fatal. An ordered cipher preference
// list is available from QEMU, thus we cannot let the firmware attempt HTTPS
@@ -161,23 +200,36 @@ SetCipherSuites (
NULL // Data
);
if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
- DEBUG ((DEBUG_ERROR, "%a:%a: failed to delete %g:\"%s\"\n",
- gEfiCallerBaseName, __FUNCTION__, &gEdkiiHttpTlsCipherListGuid,
- EDKII_HTTP_TLS_CIPHER_LIST_VARIABLE));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a:%a: failed to delete %g:\"%s\"\n",
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ &gEdkiiHttpTlsCipherListGuid,
+ EDKII_HTTP_TLS_CIPHER_LIST_VARIABLE
+ ));
goto Done;
}
if (HttpsCiphersSize == 0) {
- DEBUG ((DEBUG_ERROR, "%a:%a: list of cipher suites must not be empty\n",
- gEfiCallerBaseName, __FUNCTION__));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a:%a: list of cipher suites must not be empty\n",
+ gEfiCallerBaseName,
+ __FUNCTION__
+ ));
Status = EFI_INVALID_PARAMETER;
goto Done;
}
HttpsCiphers = AllocatePool (HttpsCiphersSize);
if (HttpsCiphers == NULL) {
- DEBUG ((DEBUG_ERROR, "%a:%a: failed to allocate HttpsCiphers\n",
- gEfiCallerBaseName, __FUNCTION__));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a:%a: failed to allocate HttpsCiphers\n",
+ gEfiCallerBaseName,
+ __FUNCTION__
+ ));
Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
@@ -193,14 +245,24 @@ SetCipherSuites (
HttpsCiphers // Data
);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a:%a: failed to set %g:\"%s\"\n",
- gEfiCallerBaseName, __FUNCTION__, &gEdkiiHttpTlsCipherListGuid,
- EDKII_HTTP_TLS_CIPHER_LIST_VARIABLE));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a:%a: failed to set %g:\"%s\"\n",
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ &gEdkiiHttpTlsCipherListGuid,
+ EDKII_HTTP_TLS_CIPHER_LIST_VARIABLE
+ ));
goto FreeHttpsCiphers;
}
- DEBUG ((DEBUG_VERBOSE, "%a:%a: stored list of cipher suites (%Lu byte(s))\n",
- gEfiCallerBaseName, __FUNCTION__, (UINT64)HttpsCiphersSize));
+ DEBUG ((
+ DEBUG_VERBOSE,
+ "%a:%a: stored list of cipher suites (%Lu byte(s))\n",
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ (UINT64)HttpsCiphersSize
+ ));
FreeHttpsCiphers:
FreePool (HttpsCiphers);
diff --git a/OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.c b/OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.c
index 2b6835626f..18bca6046c 100644
--- a/OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.c
+++ b/OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.c
@@ -10,7 +10,6 @@
#include "UefiPciCapPciIoLib.h"
-
/**
Transfer bytes between the config space of a given PCI device and a memory
buffer.
@@ -46,18 +45,18 @@
STATIC
EFI_STATUS
ProtoDevTransferConfig (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN EFI_PCI_IO_PROTOCOL_CONFIG TransferFunction,
- IN UINT16 ConfigOffset,
- IN OUT UINT8 *Buffer,
- IN UINT16 Size
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN EFI_PCI_IO_PROTOCOL_CONFIG TransferFunction,
+ IN UINT16 ConfigOffset,
+ IN OUT UINT8 *Buffer,
+ IN UINT16 Size
)
{
while (Size > 0) {
- EFI_PCI_IO_PROTOCOL_WIDTH Width;
- UINT16 Count;
- EFI_STATUS Status;
- UINT16 Progress;
+ EFI_PCI_IO_PROTOCOL_WIDTH Width;
+ UINT16 Count;
+ EFI_STATUS Status;
+ UINT16 Progress;
//
// Pick the largest access size that is allowed by the remaining transfer
@@ -67,29 +66,31 @@ ProtoDevTransferConfig (
// possible in one iteration of the loop. Otherwise, transfer only one
// unit, to improve the alignment.
//
- if (Size >= 4 && (ConfigOffset & 3) == 0) {
+ if ((Size >= 4) && ((ConfigOffset & 3) == 0)) {
Width = EfiPciIoWidthUint32;
Count = Size >> Width;
- } else if (Size >= 2 && (ConfigOffset & 1) == 0) {
+ } else if ((Size >= 2) && ((ConfigOffset & 1) == 0)) {
Width = EfiPciIoWidthUint16;
Count = 1;
} else {
Width = EfiPciIoWidthUint8;
Count = 1;
}
+
Status = TransferFunction (PciIo, Width, ConfigOffset, Count, Buffer);
if (EFI_ERROR (Status)) {
return Status;
}
+
Progress = Count << Width;
ConfigOffset += Progress;
Buffer += Progress;
Size -= Progress;
}
+
return EFI_SUCCESS;
}
-
/**
Read the config space of a given PCI device (both normal and extended).
@@ -121,20 +122,24 @@ STATIC
RETURN_STATUS
EFIAPI
ProtoDevReadConfig (
- IN PCI_CAP_DEV *PciDevice,
- IN UINT16 SourceOffset,
- OUT VOID *DestinationBuffer,
- IN UINT16 Size
+ IN PCI_CAP_DEV *PciDevice,
+ IN UINT16 SourceOffset,
+ OUT VOID *DestinationBuffer,
+ IN UINT16 Size
)
{
- PROTO_DEV *ProtoDev;
+ PROTO_DEV *ProtoDev;
ProtoDev = PROTO_DEV_FROM_PCI_CAP_DEV (PciDevice);
- return ProtoDevTransferConfig (ProtoDev->PciIo, ProtoDev->PciIo->Pci.Read,
- SourceOffset, DestinationBuffer, Size);
+ return ProtoDevTransferConfig (
+ ProtoDev->PciIo,
+ ProtoDev->PciIo->Pci.Read,
+ SourceOffset,
+ DestinationBuffer,
+ Size
+ );
}
-
/**
Write the config space of a given PCI device (both normal and extended).
@@ -166,20 +171,24 @@ STATIC
RETURN_STATUS
EFIAPI
ProtoDevWriteConfig (
- IN PCI_CAP_DEV *PciDevice,
- IN UINT16 DestinationOffset,
- IN VOID *SourceBuffer,
- IN UINT16 Size
+ IN PCI_CAP_DEV *PciDevice,
+ IN UINT16 DestinationOffset,
+ IN VOID *SourceBuffer,
+ IN UINT16 Size
)
{
- PROTO_DEV *ProtoDev;
+ PROTO_DEV *ProtoDev;
ProtoDev = PROTO_DEV_FROM_PCI_CAP_DEV (PciDevice);
- return ProtoDevTransferConfig (ProtoDev->PciIo, ProtoDev->PciIo->Pci.Write,
- DestinationOffset, SourceBuffer, Size);
+ return ProtoDevTransferConfig (
+ ProtoDev->PciIo,
+ ProtoDev->PciIo->Pci.Write,
+ DestinationOffset,
+ SourceBuffer,
+ Size
+ );
}
-
/**
Create a PCI_CAP_DEV object from an EFI_PCI_IO_PROTOCOL instance. The config
space accessors are based upon EFI_PCI_IO_PROTOCOL.Pci.Read() and
@@ -197,11 +206,11 @@ ProtoDevWriteConfig (
EFI_STATUS
EFIAPI
PciCapPciIoDeviceInit (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- OUT PCI_CAP_DEV **PciDevice
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ OUT PCI_CAP_DEV **PciDevice
)
{
- PROTO_DEV *ProtoDev;
+ PROTO_DEV *ProtoDev;
ProtoDev = AllocatePool (sizeof *ProtoDev);
if (ProtoDev == NULL) {
@@ -217,7 +226,6 @@ PciCapPciIoDeviceInit (
return EFI_SUCCESS;
}
-
/**
Free the resources used by PciDevice.
@@ -227,10 +235,10 @@ PciCapPciIoDeviceInit (
VOID
EFIAPI
PciCapPciIoDeviceUninit (
- IN PCI_CAP_DEV *PciDevice
+ IN PCI_CAP_DEV *PciDevice
)
{
- PROTO_DEV *ProtoDev;
+ PROTO_DEV *ProtoDev;
ProtoDev = PROTO_DEV_FROM_PCI_CAP_DEV (PciDevice);
FreePool (ProtoDev);
diff --git a/OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.h b/OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.h
index cfe29d1a29..3ff65966b2 100644
--- a/OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.h
+++ b/OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.h
@@ -14,22 +14,22 @@
#include <Library/PciCapPciIoLib.h>
-#define PROTO_DEV_SIG SIGNATURE_64 ('P', 'C', 'P', 'I', 'O', 'P', 'R', 'T')
+#define PROTO_DEV_SIG SIGNATURE_64 ('P', 'C', 'P', 'I', 'O', 'P', 'R', 'T')
typedef struct {
//
// Signature identifying the derived class.
//
- UINT64 Signature;
+ UINT64 Signature;
//
// Members added by the derived class, specific to the use of
// EFI_PCI_IO_PROTOCOL.
//
- EFI_PCI_IO_PROTOCOL *PciIo;
+ EFI_PCI_IO_PROTOCOL *PciIo;
//
// Base class.
//
- PCI_CAP_DEV BaseDevice;
+ PCI_CAP_DEV BaseDevice;
} PROTO_DEV;
#define PROTO_DEV_FROM_PCI_CAP_DEV(PciDevice) \
diff --git a/OvmfPkg/Library/VirtioLib/VirtioLib.c b/OvmfPkg/Library/VirtioLib/VirtioLib.c
index e09324813c..28041dbec5 100644
--- a/OvmfPkg/Library/VirtioLib/VirtioLib.c
+++ b/OvmfPkg/Library/VirtioLib/VirtioLib.c
@@ -17,7 +17,6 @@
#include <Library/VirtioLib.h>
-
/**
Configure a virtio ring.
@@ -48,14 +47,14 @@
EFI_STATUS
EFIAPI
VirtioRingInit (
- IN VIRTIO_DEVICE_PROTOCOL *VirtIo,
- IN UINT16 QueueSize,
- OUT VRING *Ring
+ IN VIRTIO_DEVICE_PROTOCOL *VirtIo,
+ IN UINT16 QueueSize,
+ OUT VRING *Ring
)
{
- EFI_STATUS Status;
- UINTN RingSize;
- volatile UINT8 *RingPagesPtr;
+ EFI_STATUS Status;
+ UINTN RingSize;
+ volatile UINT8 *RingPagesPtr;
RingSize = ALIGN_VALUE (
sizeof *Ring->Desc * QueueSize +
@@ -63,66 +62,70 @@ VirtioRingInit (
sizeof *Ring->Avail.Idx +
sizeof *Ring->Avail.Ring * QueueSize +
sizeof *Ring->Avail.UsedEvent,
- EFI_PAGE_SIZE);
+ EFI_PAGE_SIZE
+ );
RingSize += ALIGN_VALUE (
sizeof *Ring->Used.Flags +
sizeof *Ring->Used.Idx +
sizeof *Ring->Used.UsedElem * QueueSize +
sizeof *Ring->Used.AvailEvent,
- EFI_PAGE_SIZE);
+ EFI_PAGE_SIZE
+ );
//
// Allocate a shared ring buffer
//
Ring->NumPages = EFI_SIZE_TO_PAGES (RingSize);
- Status = VirtIo->AllocateSharedPages (
- VirtIo,
- Ring->NumPages,
- &Ring->Base
- );
+ Status = VirtIo->AllocateSharedPages (
+ VirtIo,
+ Ring->NumPages,
+ &Ring->Base
+ );
if (EFI_ERROR (Status)) {
return Status;
}
+
SetMem (Ring->Base, RingSize, 0x00);
RingPagesPtr = Ring->Base;
- Ring->Desc = (volatile VOID *) RingPagesPtr;
+ Ring->Desc = (volatile VOID *)RingPagesPtr;
RingPagesPtr += sizeof *Ring->Desc * QueueSize;
- Ring->Avail.Flags = (volatile VOID *) RingPagesPtr;
- RingPagesPtr += sizeof *Ring->Avail.Flags;
+ Ring->Avail.Flags = (volatile VOID *)RingPagesPtr;
+ RingPagesPtr += sizeof *Ring->Avail.Flags;
- Ring->Avail.Idx = (volatile VOID *) RingPagesPtr;
- RingPagesPtr += sizeof *Ring->Avail.Idx;
+ Ring->Avail.Idx = (volatile VOID *)RingPagesPtr;
+ RingPagesPtr += sizeof *Ring->Avail.Idx;
- Ring->Avail.Ring = (volatile VOID *) RingPagesPtr;
- RingPagesPtr += sizeof *Ring->Avail.Ring * QueueSize;
+ Ring->Avail.Ring = (volatile VOID *)RingPagesPtr;
+ RingPagesPtr += sizeof *Ring->Avail.Ring * QueueSize;
- Ring->Avail.UsedEvent = (volatile VOID *) RingPagesPtr;
- RingPagesPtr += sizeof *Ring->Avail.UsedEvent;
+ Ring->Avail.UsedEvent = (volatile VOID *)RingPagesPtr;
+ RingPagesPtr += sizeof *Ring->Avail.UsedEvent;
- RingPagesPtr = (volatile UINT8 *) Ring->Base +
- ALIGN_VALUE (RingPagesPtr - (volatile UINT8 *) Ring->Base,
- EFI_PAGE_SIZE);
+ RingPagesPtr = (volatile UINT8 *)Ring->Base +
+ ALIGN_VALUE (
+ RingPagesPtr - (volatile UINT8 *)Ring->Base,
+ EFI_PAGE_SIZE
+ );
- Ring->Used.Flags = (volatile VOID *) RingPagesPtr;
- RingPagesPtr += sizeof *Ring->Used.Flags;
+ Ring->Used.Flags = (volatile VOID *)RingPagesPtr;
+ RingPagesPtr += sizeof *Ring->Used.Flags;
- Ring->Used.Idx = (volatile VOID *) RingPagesPtr;
- RingPagesPtr += sizeof *Ring->Used.Idx;
+ Ring->Used.Idx = (volatile VOID *)RingPagesPtr;
+ RingPagesPtr += sizeof *Ring->Used.Idx;
- Ring->Used.UsedElem = (volatile VOID *) RingPagesPtr;
- RingPagesPtr += sizeof *Ring->Used.UsedElem * QueueSize;
+ Ring->Used.UsedElem = (volatile VOID *)RingPagesPtr;
+ RingPagesPtr += sizeof *Ring->Used.UsedElem * QueueSize;
- Ring->Used.AvailEvent = (volatile VOID *) RingPagesPtr;
- RingPagesPtr += sizeof *Ring->Used.AvailEvent;
+ Ring->Used.AvailEvent = (volatile VOID *)RingPagesPtr;
+ RingPagesPtr += sizeof *Ring->Used.AvailEvent;
Ring->QueueSize = QueueSize;
return EFI_SUCCESS;
}
-
/**
Tear down the internal resources of a configured virtio ring.
@@ -139,15 +142,14 @@ VirtioRingInit (
VOID
EFIAPI
VirtioRingUninit (
- IN VIRTIO_DEVICE_PROTOCOL *VirtIo,
- IN OUT VRING *Ring
+ IN VIRTIO_DEVICE_PROTOCOL *VirtIo,
+ IN OUT VRING *Ring
)
{
VirtIo->FreeSharedPages (VirtIo, Ring->NumPages, Ring->Base);
SetMem (Ring, sizeof *Ring, 0x00);
}
-
/**
Turn off interrupt notifications from the host, and prepare for appending
@@ -163,15 +165,15 @@ VirtioRingUninit (
VOID
EFIAPI
VirtioPrepare (
- IN OUT VRING *Ring,
- OUT DESC_INDICES *Indices
+ IN OUT VRING *Ring,
+ OUT DESC_INDICES *Indices
)
{
//
// Prepare for virtio-0.9.5, 2.4.2 Receiving Used Buffers From the Device.
// We're going to poll the answer, the host should not send an interrupt.
//
- *Ring->Avail.Flags = (UINT16) VRING_AVAIL_F_NO_INTERRUPT;
+ *Ring->Avail.Flags = (UINT16)VRING_AVAIL_F_NO_INTERRUPT;
//
// Prepare for virtio-0.9.5, 2.4.1 Supplying Buffers to the Device.
@@ -224,14 +226,14 @@ VirtioPrepare (
VOID
EFIAPI
VirtioAppendDesc (
- IN OUT VRING *Ring,
- IN UINT64 BufferDeviceAddress,
- IN UINT32 BufferSize,
- IN UINT16 Flags,
- IN OUT DESC_INDICES *Indices
+ IN OUT VRING *Ring,
+ IN UINT64 BufferDeviceAddress,
+ IN UINT32 BufferSize,
+ IN UINT16 Flags,
+ IN OUT DESC_INDICES *Indices
)
{
- volatile VRING_DESC *Desc;
+ volatile VRING_DESC *Desc;
Desc = &Ring->Desc[Indices->NextDescIdx++ % Ring->QueueSize];
Desc->Addr = BufferDeviceAddress;
@@ -240,7 +242,6 @@ VirtioAppendDesc (
Desc->Next = Indices->NextDescIdx % Ring->QueueSize;
}
-
/**
Notify the host about the descriptor chain just built, and wait until the
@@ -271,17 +272,17 @@ VirtioAppendDesc (
EFI_STATUS
EFIAPI
VirtioFlush (
- IN VIRTIO_DEVICE_PROTOCOL *VirtIo,
- IN UINT16 VirtQueueId,
- IN OUT VRING *Ring,
- IN DESC_INDICES *Indices,
- OUT UINT32 *UsedLen OPTIONAL
+ IN VIRTIO_DEVICE_PROTOCOL *VirtIo,
+ IN UINT16 VirtQueueId,
+ IN OUT VRING *Ring,
+ IN DESC_INDICES *Indices,
+ OUT UINT32 *UsedLen OPTIONAL
)
{
- UINT16 NextAvailIdx;
- UINT16 LastUsedIdx;
- EFI_STATUS Status;
- UINTN PollPeriodUsecs;
+ UINT16 NextAvailIdx;
+ UINT16 LastUsedIdx;
+ EFI_STATUS Status;
+ UINTN PollPeriodUsecs;
//
// virtio-0.9.5, 2.4.1.2 Updating the Available Ring
@@ -295,21 +296,21 @@ VirtioFlush (
// (Due to our lock-step progress, this is where the host will produce the
// used element with the head descriptor's index in it.)
//
- LastUsedIdx = NextAvailIdx;
+ LastUsedIdx = NextAvailIdx;
Ring->Avail.Ring[NextAvailIdx++ % Ring->QueueSize] =
Indices->HeadDescIdx % Ring->QueueSize;
//
// virtio-0.9.5, 2.4.1.3 Updating the Index Field
//
- MemoryFence();
+ MemoryFence ();
*Ring->Avail.Idx = NextAvailIdx;
//
// virtio-0.9.5, 2.4.1.4 Notifying the Device -- gratuitous notifications are
// OK.
//
- MemoryFence();
+ MemoryFence ();
Status = VirtIo->SetQueueNotify (VirtIo, VirtQueueId);
if (EFI_ERROR (Status)) {
return Status;
@@ -324,20 +325,21 @@ VirtioFlush (
// Keep slowing down until we reach a poll period of slightly above 1 ms.
//
PollPeriodUsecs = 1;
- MemoryFence();
+ MemoryFence ();
while (*Ring->Used.Idx != NextAvailIdx) {
gBS->Stall (PollPeriodUsecs); // calls AcpiTimerLib::MicroSecondDelay
if (PollPeriodUsecs < 1024) {
PollPeriodUsecs *= 2;
}
- MemoryFence();
+
+ MemoryFence ();
}
- MemoryFence();
+ MemoryFence ();
if (UsedLen != NULL) {
- volatile CONST VRING_USED_ELEM *UsedElem;
+ volatile CONST VRING_USED_ELEM *UsedElem;
UsedElem = &Ring->Used.UsedElem[LastUsedIdx % Ring->QueueSize];
ASSERT (UsedElem->Id == Indices->HeadDescIdx);
@@ -347,7 +349,6 @@ VirtioFlush (
return EFI_SUCCESS;
}
-
/**
Report the feature bits to the VirtIo 1.0 device that the VirtIo 1.0 driver
@@ -388,12 +389,12 @@ VirtioFlush (
EFI_STATUS
EFIAPI
Virtio10WriteFeatures (
- IN VIRTIO_DEVICE_PROTOCOL *VirtIo,
- IN UINT64 Features,
- IN OUT UINT8 *DeviceStatus
+ IN VIRTIO_DEVICE_PROTOCOL *VirtIo,
+ IN UINT64 Features,
+ IN OUT UINT8 *DeviceStatus
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
if (VirtIo->Revision < VIRTIO_SPEC_REVISION (1, 0, 0)) {
return EFI_UNSUPPORTED;
@@ -405,7 +406,7 @@ Virtio10WriteFeatures (
}
*DeviceStatus |= VSTAT_FEATURES_OK;
- Status = VirtIo->SetDeviceStatus (VirtIo, *DeviceStatus);
+ Status = VirtIo->SetDeviceStatus (VirtIo, *DeviceStatus);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -479,7 +480,7 @@ VirtioMapAllBytesInSharedBuffer (
UINTN Size;
EFI_PHYSICAL_ADDRESS PhysicalAddress;
- Size = NumberOfBytes;
+ Size = NumberOfBytes;
Status = VirtIo->MapSharedBuffer (
VirtIo,
Operation,
@@ -496,7 +497,7 @@ VirtioMapAllBytesInSharedBuffer (
goto Failed;
}
- *Mapping = MapInfo;
+ *Mapping = MapInfo;
*DeviceAddress = PhysicalAddress;
return EFI_SUCCESS;
@@ -526,10 +527,10 @@ Failed:
EFI_STATUS
EFIAPI
VirtioRingMap (
- IN VIRTIO_DEVICE_PROTOCOL *VirtIo,
- IN VRING *Ring,
- OUT UINT64 *RingBaseShift,
- OUT VOID **Mapping
+ IN VIRTIO_DEVICE_PROTOCOL *VirtIo,
+ IN VRING *Ring,
+ OUT UINT64 *RingBaseShift,
+ OUT VOID **Mapping
)
{
EFI_STATUS Status;
diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c
index a97ef9352d..831dc1736d 100644
--- a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c
+++ b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c
@@ -14,26 +14,26 @@
#include "VirtioMmioDevice.h"
-STATIC CONST VIRTIO_DEVICE_PROTOCOL mMmioDeviceProtocolTemplate = {
- 0, // Revision
- 0, // SubSystemDeviceId
- VirtioMmioGetDeviceFeatures, // GetDeviceFeatures
- VirtioMmioSetGuestFeatures, // SetGuestFeatures
- VirtioMmioSetQueueAddress, // SetQueueAddress
- VirtioMmioSetQueueSel, // SetQueueSel
- VirtioMmioSetQueueNotify, // SetQueueNotify
- VirtioMmioSetQueueAlignment, // SetQueueAlign
- VirtioMmioSetPageSize, // SetPageSize
- VirtioMmioGetQueueSize, // GetQueueNumMax
- VirtioMmioSetQueueSize, // SetQueueNum
- VirtioMmioGetDeviceStatus, // GetDeviceStatus
- VirtioMmioSetDeviceStatus, // SetDeviceStatus
- VirtioMmioDeviceWrite, // WriteDevice
- VirtioMmioDeviceRead, // ReadDevice
- VirtioMmioAllocateSharedPages, // AllocateSharedPages
- VirtioMmioFreeSharedPages, // FreeSharedPages
- VirtioMmioMapSharedBuffer, // MapSharedBuffer
- VirtioMmioUnmapSharedBuffer // UnmapSharedBuffer
+STATIC CONST VIRTIO_DEVICE_PROTOCOL mMmioDeviceProtocolTemplate = {
+ 0, // Revision
+ 0, // SubSystemDeviceId
+ VirtioMmioGetDeviceFeatures, // GetDeviceFeatures
+ VirtioMmioSetGuestFeatures, // SetGuestFeatures
+ VirtioMmioSetQueueAddress, // SetQueueAddress
+ VirtioMmioSetQueueSel, // SetQueueSel
+ VirtioMmioSetQueueNotify, // SetQueueNotify
+ VirtioMmioSetQueueAlignment, // SetQueueAlign
+ VirtioMmioSetPageSize, // SetPageSize
+ VirtioMmioGetQueueSize, // GetQueueNumMax
+ VirtioMmioSetQueueSize, // SetQueueNum
+ VirtioMmioGetDeviceStatus, // GetDeviceStatus
+ VirtioMmioSetDeviceStatus, // SetDeviceStatus
+ VirtioMmioDeviceWrite, // WriteDevice
+ VirtioMmioDeviceRead, // ReadDevice
+ VirtioMmioAllocateSharedPages, // AllocateSharedPages
+ VirtioMmioFreeSharedPages, // FreeSharedPages
+ VirtioMmioMapSharedBuffer, // MapSharedBuffer
+ VirtioMmioUnmapSharedBuffer // UnmapSharedBuffer
};
/**
@@ -54,19 +54,22 @@ EFI_STATUS
EFIAPI
VirtioMmioInit (
IN PHYSICAL_ADDRESS BaseAddress,
- IN OUT VIRTIO_MMIO_DEVICE *Device
+ IN OUT VIRTIO_MMIO_DEVICE *Device
)
{
- UINT32 MagicValue;
+ UINT32 MagicValue;
//
// Initialize VirtIo Mmio Device
//
- CopyMem (&Device->VirtioDevice, &mMmioDeviceProtocolTemplate,
- sizeof (VIRTIO_DEVICE_PROTOCOL));
- Device->BaseAddress = BaseAddress;
+ CopyMem (
+ &Device->VirtioDevice,
+ &mMmioDeviceProtocolTemplate,
+ sizeof (VIRTIO_DEVICE_PROTOCOL)
+ );
+ Device->BaseAddress = BaseAddress;
Device->VirtioDevice.SubSystemDeviceId =
- MmioRead32 (BaseAddress + VIRTIO_MMIO_OFFSET_DEVICE_ID);
+ MmioRead32 (BaseAddress + VIRTIO_MMIO_OFFSET_DEVICE_ID);
//
// Double-check MMIO-specific values
@@ -78,24 +81,31 @@ VirtioMmioInit (
Device->Version = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_VERSION);
switch (Device->Version) {
- case VIRTIO_MMIO_DEVICE_VERSION_0_95:
- DEBUG ((DEBUG_INFO, "%a virtio 0.9.5, id %d\n", __FUNCTION__,
- Device->VirtioDevice.SubSystemDeviceId));
- Device->VirtioDevice.Revision = VIRTIO_SPEC_REVISION (0, 9, 5);
- break;
- case VIRTIO_MMIO_DEVICE_VERSION_1_00:
- DEBUG ((DEBUG_INFO, "%a virtio 1.0, id %d\n", __FUNCTION__,
- Device->VirtioDevice.SubSystemDeviceId));
- Device->VirtioDevice.Revision = VIRTIO_SPEC_REVISION (1, 0, 0);
- break;
- default:
- return EFI_UNSUPPORTED;
+ case VIRTIO_MMIO_DEVICE_VERSION_0_95:
+ DEBUG ((
+ DEBUG_INFO,
+ "%a virtio 0.9.5, id %d\n",
+ __FUNCTION__,
+ Device->VirtioDevice.SubSystemDeviceId
+ ));
+ Device->VirtioDevice.Revision = VIRTIO_SPEC_REVISION (0, 9, 5);
+ break;
+ case VIRTIO_MMIO_DEVICE_VERSION_1_00:
+ DEBUG ((
+ DEBUG_INFO,
+ "%a virtio 1.0, id %d\n",
+ __FUNCTION__,
+ Device->VirtioDevice.SubSystemDeviceId
+ ));
+ Device->VirtioDevice.Revision = VIRTIO_SPEC_REVISION (1, 0, 0);
+ break;
+ default:
+ return EFI_UNSUPPORTED;
}
return EFI_SUCCESS;
}
-
/**
Uninitialize the internals of a virtio-mmio device that has been successfully
@@ -104,12 +114,11 @@ VirtioMmioInit (
@param[in, out] Device The device to clean up.
**/
-
STATIC
VOID
EFIAPI
VirtioMmioUninit (
- IN VIRTIO_MMIO_DEVICE *Device
+ IN VIRTIO_MMIO_DEVICE *Device
)
{
//
@@ -120,16 +129,17 @@ VirtioMmioUninit (
EFI_STATUS
VirtioMmioInstallDevice (
- IN PHYSICAL_ADDRESS BaseAddress,
- IN EFI_HANDLE Handle
+ IN PHYSICAL_ADDRESS BaseAddress,
+ IN EFI_HANDLE Handle
)
{
EFI_STATUS Status;
- VIRTIO_MMIO_DEVICE *VirtIo;
+ VIRTIO_MMIO_DEVICE *VirtIo;
if (!BaseAddress) {
return EFI_INVALID_PARAMETER;
}
+
if (Handle == NULL) {
return EFI_INVALID_PARAMETER;
}
@@ -152,9 +162,12 @@ VirtioMmioInstallDevice (
//
// Install VIRTIO_DEVICE_PROTOCOL to Handle
//
- Status = gBS->InstallProtocolInterface (&Handle,
- &gVirtioDeviceProtocolGuid, EFI_NATIVE_INTERFACE,
- &VirtIo->VirtioDevice);
+ Status = gBS->InstallProtocolInterface (
+ &Handle,
+ &gVirtioDeviceProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ &VirtIo->VirtioDevice
+ );
if (EFI_ERROR (Status)) {
goto UninitVirtio;
}
@@ -171,7 +184,7 @@ FreeVirtioMem:
EFI_STATUS
VirtioMmioUninstallDevice (
- IN EFI_HANDLE DeviceHandle
+ IN EFI_HANDLE DeviceHandle
)
{
VIRTIO_DEVICE_PROTOCOL *VirtioDevice;
@@ -198,9 +211,11 @@ VirtioMmioUninstallDevice (
//
// Uninstall the protocol interface
//
- Status = gBS->UninstallProtocolInterface (DeviceHandle,
- &gVirtioDeviceProtocolGuid, &MmioDevice->VirtioDevice
- );
+ Status = gBS->UninstallProtocolInterface (
+ DeviceHandle,
+ &gVirtioDeviceProtocolGuid,
+ &MmioDevice->VirtioDevice
+ );
if (EFI_ERROR (Status)) {
return Status;
}
diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h
index 5ad951f415..7298cf5821 100644
--- a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h
+++ b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h
@@ -22,17 +22,16 @@
#include <Library/VirtioMmioDeviceLib.h>
#include <Library/MemoryAllocationLib.h>
-#define VIRTIO_MMIO_DEVICE_SIGNATURE SIGNATURE_32 ('V', 'M', 'I', 'O')
+#define VIRTIO_MMIO_DEVICE_SIGNATURE SIGNATURE_32 ('V', 'M', 'I', 'O')
#define VIRTIO_MMIO_DEVICE_VERSION_0_95 1
#define VIRTIO_MMIO_DEVICE_VERSION_1_00 2
-
typedef struct {
- UINT32 Signature;
- UINT32 Version;
- UINT16 QueueNum;
- VIRTIO_DEVICE_PROTOCOL VirtioDevice;
- PHYSICAL_ADDRESS BaseAddress;
+ UINT32 Signature;
+ UINT32 Version;
+ UINT16 QueueNum;
+ VIRTIO_DEVICE_PROTOCOL VirtioDevice;
+ PHYSICAL_ADDRESS BaseAddress;
} VIRTIO_MMIO_DEVICE;
#define VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE(Device) \
@@ -46,27 +45,27 @@ typedef struct {
EFI_STATUS
EFIAPI
VirtioMmioDeviceRead (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- IN UINTN FieldOFfset,
- IN UINTN FieldSize,
- IN UINTN BufferSize,
- OUT VOID* Buffer
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN UINTN FieldOFfset,
+ IN UINTN FieldSize,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
);
EFI_STATUS
EFIAPI
VirtioMmioDeviceWrite (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- IN UINTN FieldOffset,
- IN UINTN FieldSize,
- IN UINT64 Value
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN UINTN FieldOffset,
+ IN UINTN FieldSize,
+ IN UINT64 Value
);
EFI_STATUS
EFIAPI
VirtioMmioGetDeviceFeatures (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- OUT UINT64 *DeviceFeatures
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ OUT UINT64 *DeviceFeatures
);
EFI_STATUS
@@ -86,28 +85,28 @@ VirtioMmioGetDeviceStatus (
EFI_STATUS
EFIAPI
VirtioMmioSetQueueSize (
- IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN VIRTIO_DEVICE_PROTOCOL *This,
IN UINT16 QueueSize
);
EFI_STATUS
EFIAPI
VirtioMmioSetDeviceStatus (
- IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN VIRTIO_DEVICE_PROTOCOL *This,
IN UINT8 DeviceStatus
);
EFI_STATUS
EFIAPI
VirtioMmioSetQueueNotify (
- IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN VIRTIO_DEVICE_PROTOCOL *This,
IN UINT16 QueueNotify
);
EFI_STATUS
EFIAPI
VirtioMmioSetQueueSel (
- IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN VIRTIO_DEVICE_PROTOCOL *This,
IN UINT16 Sel
);
@@ -122,56 +121,56 @@ VirtioMmioSetQueueAddress (
EFI_STATUS
EFIAPI
VirtioMmioSetQueueAlignment (
- IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN VIRTIO_DEVICE_PROTOCOL *This,
IN UINT32 Alignment
);
EFI_STATUS
EFIAPI
VirtioMmioSetPageSize (
- IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN VIRTIO_DEVICE_PROTOCOL *This,
IN UINT32 PageSize
);
EFI_STATUS
EFIAPI
VirtioMmioSetGuestFeatures (
- IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN VIRTIO_DEVICE_PROTOCOL *This,
IN UINT64 Features
);
EFI_STATUS
EFIAPI
VirtioMmioAllocateSharedPages (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- IN UINTN NumPages,
- OUT VOID **HostAddress
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN UINTN NumPages,
+ OUT VOID **HostAddress
);
VOID
EFIAPI
VirtioMmioFreeSharedPages (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- IN UINTN NumPages,
- IN VOID *HostAddress
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN UINTN NumPages,
+ IN VOID *HostAddress
);
EFI_STATUS
EFIAPI
VirtioMmioMapSharedBuffer (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- IN VIRTIO_MAP_OPERATION Operation,
- IN VOID *HostAddress,
- IN OUT UINTN *NumberOfBytes,
- OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
- OUT VOID **Mapping
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN VIRTIO_MAP_OPERATION Operation,
+ IN VOID *HostAddress,
+ IN OUT UINTN *NumberOfBytes,
+ OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
+ OUT VOID **Mapping
);
EFI_STATUS
EFIAPI
VirtioMmioUnmapSharedBuffer (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- IN VOID *Mapping
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN VOID *Mapping
);
#endif // _VIRTIO_MMIO_DEVICE_INTERNAL_H_
diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c
index b43850e69d..8bdf1e1fc3 100644
--- a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c
+++ b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c
@@ -15,12 +15,12 @@
EFI_STATUS
EFIAPI
VirtioMmioGetDeviceFeatures (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- OUT UINT64 *DeviceFeatures
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ OUT UINT64 *DeviceFeatures
)
{
- VIRTIO_MMIO_DEVICE *Device;
- UINT32 LowBits, HighBits;
+ VIRTIO_MMIO_DEVICE *Device;
+ UINT32 LowBits, HighBits;
if (DeviceFeatures == NULL) {
return EFI_INVALID_PARAMETER;
@@ -34,8 +34,8 @@ VirtioMmioGetDeviceFeatures (
VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_HOST_FEATURES_SEL, 0);
LowBits = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_HOST_FEATURES);
VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_HOST_FEATURES_SEL, 1);
- HighBits = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_HOST_FEATURES);
- *DeviceFeatures = LShiftU64(HighBits, 32) | LowBits;
+ HighBits = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_HOST_FEATURES);
+ *DeviceFeatures = LShiftU64 (HighBits, 32) | LowBits;
}
return EFI_SUCCESS;
@@ -48,7 +48,7 @@ VirtioMmioGetQueueSize (
OUT UINT16 *QueueNumMax
)
{
- VIRTIO_MMIO_DEVICE *Device;
+ VIRTIO_MMIO_DEVICE *Device;
if (QueueNumMax == NULL) {
return EFI_INVALID_PARAMETER;
@@ -68,7 +68,7 @@ VirtioMmioGetDeviceStatus (
OUT UINT8 *DeviceStatus
)
{
- VIRTIO_MMIO_DEVICE *Device;
+ VIRTIO_MMIO_DEVICE *Device;
if (DeviceStatus == NULL) {
return EFI_INVALID_PARAMETER;
@@ -84,11 +84,11 @@ VirtioMmioGetDeviceStatus (
EFI_STATUS
EFIAPI
VirtioMmioSetQueueSize (
- IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN VIRTIO_DEVICE_PROTOCOL *This,
IN UINT16 QueueSize
)
{
- VIRTIO_MMIO_DEVICE *Device;
+ VIRTIO_MMIO_DEVICE *Device;
Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
@@ -104,11 +104,11 @@ VirtioMmioSetQueueSize (
EFI_STATUS
EFIAPI
VirtioMmioSetDeviceStatus (
- IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN VIRTIO_DEVICE_PROTOCOL *This,
IN UINT8 DeviceStatus
)
{
- VIRTIO_MMIO_DEVICE *Device;
+ VIRTIO_MMIO_DEVICE *Device;
Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
@@ -120,11 +120,11 @@ VirtioMmioSetDeviceStatus (
EFI_STATUS
EFIAPI
VirtioMmioSetQueueNotify (
- IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN VIRTIO_DEVICE_PROTOCOL *This,
IN UINT16 QueueNotify
)
{
- VIRTIO_MMIO_DEVICE *Device;
+ VIRTIO_MMIO_DEVICE *Device;
Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
@@ -136,11 +136,11 @@ VirtioMmioSetQueueNotify (
EFI_STATUS
EFIAPI
VirtioMmioSetQueueAlignment (
- IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN VIRTIO_DEVICE_PROTOCOL *This,
IN UINT32 Alignment
)
{
- VIRTIO_MMIO_DEVICE *Device;
+ VIRTIO_MMIO_DEVICE *Device;
Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
@@ -152,11 +152,11 @@ VirtioMmioSetQueueAlignment (
EFI_STATUS
EFIAPI
VirtioMmioSetPageSize (
- IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN VIRTIO_DEVICE_PROTOCOL *This,
IN UINT32 PageSize
)
{
- VIRTIO_MMIO_DEVICE *Device;
+ VIRTIO_MMIO_DEVICE *Device;
if (PageSize != EFI_PAGE_SIZE) {
return EFI_UNSUPPORTED;
@@ -174,11 +174,11 @@ VirtioMmioSetPageSize (
EFI_STATUS
EFIAPI
VirtioMmioSetQueueSel (
- IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN VIRTIO_DEVICE_PROTOCOL *This,
IN UINT16 Sel
)
{
- VIRTIO_MMIO_DEVICE *Device;
+ VIRTIO_MMIO_DEVICE *Device;
Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
@@ -199,36 +199,57 @@ VirtioMmioSetQueueAddress (
IN UINT64 RingBaseShift
)
{
- VIRTIO_MMIO_DEVICE *Device;
- UINT64 Address;
+ VIRTIO_MMIO_DEVICE *Device;
+ UINT64 Address;
ASSERT (RingBaseShift == 0);
Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
if (Device->Version == VIRTIO_MMIO_DEVICE_VERSION_0_95) {
- VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_PFN,
- (UINT32)((UINTN)Ring->Base >> EFI_PAGE_SHIFT));
+ VIRTIO_CFG_WRITE (
+ Device,
+ VIRTIO_MMIO_OFFSET_QUEUE_PFN,
+ (UINT32)((UINTN)Ring->Base >> EFI_PAGE_SHIFT)
+ );
} else {
VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_NUM, Device->QueueNum);
Address = (UINTN)Ring->Base;
- VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_DESC_LO,
- (UINT32)Address);
- VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_DESC_HI,
- (UINT32)RShiftU64(Address, 32));
+ VIRTIO_CFG_WRITE (
+ Device,
+ VIRTIO_MMIO_OFFSET_QUEUE_DESC_LO,
+ (UINT32)Address
+ );
+ VIRTIO_CFG_WRITE (
+ Device,
+ VIRTIO_MMIO_OFFSET_QUEUE_DESC_HI,
+ (UINT32)RShiftU64 (Address, 32)
+ );
Address = (UINTN)Ring->Avail.Flags;
- VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_AVAIL_LO,
- (UINT32)Address);
- VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_AVAIL_HI,
- (UINT32)RShiftU64(Address, 32));
+ VIRTIO_CFG_WRITE (
+ Device,
+ VIRTIO_MMIO_OFFSET_QUEUE_AVAIL_LO,
+ (UINT32)Address
+ );
+ VIRTIO_CFG_WRITE (
+ Device,
+ VIRTIO_MMIO_OFFSET_QUEUE_AVAIL_HI,
+ (UINT32)RShiftU64 (Address, 32)
+ );
Address = (UINTN)Ring->Used.Flags;
- VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_USED_LO,
- (UINT32)Address);
- VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_USED_HI,
- (UINT32)RShiftU64(Address, 32));
+ VIRTIO_CFG_WRITE (
+ Device,
+ VIRTIO_MMIO_OFFSET_QUEUE_USED_LO,
+ (UINT32)Address
+ );
+ VIRTIO_CFG_WRITE (
+ Device,
+ VIRTIO_MMIO_OFFSET_QUEUE_USED_HI,
+ (UINT32)RShiftU64 (Address, 32)
+ );
VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_READY, 1);
}
@@ -239,11 +260,11 @@ VirtioMmioSetQueueAddress (
EFI_STATUS
EFIAPI
VirtioMmioSetGuestFeatures (
- IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN VIRTIO_DEVICE_PROTOCOL *This,
IN UINT64 Features
)
{
- VIRTIO_MMIO_DEVICE *Device;
+ VIRTIO_MMIO_DEVICE *Device;
Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
@@ -251,15 +272,25 @@ VirtioMmioSetGuestFeatures (
if (Features > MAX_UINT32) {
return EFI_UNSUPPORTED;
}
- VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_GUEST_FEATURES,
- (UINT32)Features);
+
+ VIRTIO_CFG_WRITE (
+ Device,
+ VIRTIO_MMIO_OFFSET_GUEST_FEATURES,
+ (UINT32)Features
+ );
} else {
VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_GUEST_FEATURES_SEL, 0);
- VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_GUEST_FEATURES,
- (UINT32)Features);
+ VIRTIO_CFG_WRITE (
+ Device,
+ VIRTIO_MMIO_OFFSET_GUEST_FEATURES,
+ (UINT32)Features
+ );
VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_GUEST_FEATURES_SEL, 1);
- VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_GUEST_FEATURES,
- (UINT32)RShiftU64(Features, 32));
+ VIRTIO_CFG_WRITE (
+ Device,
+ VIRTIO_MMIO_OFFSET_GUEST_FEATURES,
+ (UINT32)RShiftU64 (Features, 32)
+ );
}
return EFI_SUCCESS;
@@ -268,14 +299,14 @@ VirtioMmioSetGuestFeatures (
EFI_STATUS
EFIAPI
VirtioMmioDeviceWrite (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- IN UINTN FieldOffset,
- IN UINTN FieldSize,
- IN UINT64 Value
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN UINTN FieldOffset,
+ IN UINTN FieldSize,
+ IN UINT64 Value
)
{
- UINTN DstBaseAddress;
- VIRTIO_MMIO_DEVICE *Device;
+ UINTN DstBaseAddress;
+ VIRTIO_MMIO_DEVICE *Device;
Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
@@ -283,7 +314,8 @@ VirtioMmioDeviceWrite (
// Double-check fieldsize
//
if ((FieldSize != 1) && (FieldSize != 2) &&
- (FieldSize != 4) && (FieldSize != 8)) {
+ (FieldSize != 4) && (FieldSize != 8))
+ {
return EFI_INVALID_PARAMETER;
}
@@ -291,13 +323,13 @@ VirtioMmioDeviceWrite (
// Compute base address
//
DstBaseAddress = Device->BaseAddress +
- VIRTIO_DEVICE_SPECIFIC_CONFIGURATION_OFFSET_MMIO + FieldOffset;
+ VIRTIO_DEVICE_SPECIFIC_CONFIGURATION_OFFSET_MMIO + FieldOffset;
//
// The device-specific memory area of Virtio-MMIO can only be written in
// byte accesses. This is not currently in the Virtio spec.
//
- MmioWriteBuffer8 (DstBaseAddress, FieldSize, (UINT8*)&Value);
+ MmioWriteBuffer8 (DstBaseAddress, FieldSize, (UINT8 *)&Value);
return EFI_SUCCESS;
}
@@ -305,15 +337,15 @@ VirtioMmioDeviceWrite (
EFI_STATUS
EFIAPI
VirtioMmioDeviceRead (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- IN UINTN FieldOffset,
- IN UINTN FieldSize,
- IN UINTN BufferSize,
- OUT VOID *Buffer
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN UINTN FieldOffset,
+ IN UINTN FieldSize,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
)
{
- UINTN SrcBaseAddress;
- VIRTIO_MMIO_DEVICE *Device;
+ UINTN SrcBaseAddress;
+ VIRTIO_MMIO_DEVICE *Device;
Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
@@ -326,7 +358,8 @@ VirtioMmioDeviceRead (
// Double-check fieldsize
//
if ((FieldSize != 1) && (FieldSize != 2) &&
- (FieldSize != 4) && (FieldSize != 8)) {
+ (FieldSize != 4) && (FieldSize != 8))
+ {
return EFI_INVALID_PARAMETER;
}
@@ -334,7 +367,7 @@ VirtioMmioDeviceRead (
// Compute base address
//
SrcBaseAddress = Device->BaseAddress +
- VIRTIO_DEVICE_SPECIFIC_CONFIGURATION_OFFSET_MMIO + FieldOffset;
+ VIRTIO_DEVICE_SPECIFIC_CONFIGURATION_OFFSET_MMIO + FieldOffset;
//
// The device-specific memory area of Virtio-MMIO can only be read in
@@ -353,7 +386,7 @@ VirtioMmioAllocateSharedPages (
OUT VOID **HostAddress
)
{
- VOID *Buffer;
+ VOID *Buffer;
Buffer = AllocatePages (NumPages);
if (Buffer == NULL) {
@@ -386,8 +419,8 @@ VirtioMmioMapSharedBuffer (
OUT VOID **Mapping
)
{
- *DeviceAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) HostAddress;
- *Mapping = NULL;
+ *DeviceAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)HostAddress;
+ *Mapping = NULL;
return EFI_SUCCESS;
}
@@ -395,8 +428,8 @@ VirtioMmioMapSharedBuffer (
EFI_STATUS
EFIAPI
VirtioMmioUnmapSharedBuffer (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- IN VOID *Mapping
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN VOID *Mapping
)
{
return EFI_SUCCESS;
diff --git a/OvmfPkg/Library/VmgExitLib/PeiDxeVmgExitVcHandler.c b/OvmfPkg/Library/VmgExitLib/PeiDxeVmgExitVcHandler.c
index fb4942df37..e3d0715837 100644
--- a/OvmfPkg/Library/VmgExitLib/PeiDxeVmgExitVcHandler.c
+++ b/OvmfPkg/Library/VmgExitLib/PeiDxeVmgExitVcHandler.c
@@ -54,10 +54,10 @@ VmgExitHandleVc (
ASSERT (Msr.GhcbInfo.Function == 0);
ASSERT (Msr.Ghcb != 0);
- Ghcb = Msr.Ghcb;
+ Ghcb = Msr.Ghcb;
GhcbBackup = NULL;
- SevEsData = (SEV_ES_PER_CPU_DATA *) (Ghcb + 1);
+ SevEsData = (SEV_ES_PER_CPU_DATA *)(Ghcb + 1);
SevEsData->VcCount++;
//
@@ -78,7 +78,7 @@ VmgExitHandleVc (
// To access the correct backup page, increment the backup page pointer
// based on the current VcCount.
//
- GhcbBackup = (GHCB *) SevEsData->GhcbBackupPages;
+ GhcbBackup = (GHCB *)SevEsData->GhcbBackupPages;
GhcbBackup += (SevEsData->VcCount - 2);
CopyMem (GhcbBackup, Ghcb, sizeof (*Ghcb));
diff --git a/OvmfPkg/Library/VmgExitLib/SecVmgExitVcHandler.c b/OvmfPkg/Library/VmgExitLib/SecVmgExitVcHandler.c
index 85853d334b..fe8680f831 100644
--- a/OvmfPkg/Library/VmgExitLib/SecVmgExitVcHandler.c
+++ b/OvmfPkg/Library/VmgExitLib/SecVmgExitVcHandler.c
@@ -54,10 +54,10 @@ VmgExitHandleVc (
ASSERT (Msr.GhcbInfo.Function == 0);
ASSERT (Msr.Ghcb != 0);
- Ghcb = Msr.Ghcb;
+ Ghcb = Msr.Ghcb;
GhcbBackup = NULL;
- SevEsData = (SEV_ES_PER_CPU_DATA *) (Ghcb + 1);
+ SevEsData = (SEV_ES_PER_CPU_DATA *)(Ghcb + 1);
SevEsData->VcCount++;
//
@@ -84,7 +84,7 @@ VmgExitHandleVc (
// To access the correct backup page, increment the backup page pointer
// based on the current VcCount.
//
- GhcbBackup = (GHCB *) FixedPcdGet32 (PcdOvmfSecGhcbBackupBase);
+ GhcbBackup = (GHCB *)FixedPcdGet32 (PcdOvmfSecGhcbBackupBase);
GhcbBackup += (SevEsData->VcCount - 2);
CopyMem (GhcbBackup, Ghcb, sizeof (*Ghcb));
diff --git a/OvmfPkg/Library/VmgExitLib/VmgExitLib.c b/OvmfPkg/Library/VmgExitLib/VmgExitLib.c
index bc5cd61d75..c205521870 100644
--- a/OvmfPkg/Library/VmgExitLib/VmgExitLib.c
+++ b/OvmfPkg/Library/VmgExitLib/VmgExitLib.c
@@ -28,7 +28,7 @@
STATIC
UINT64
VmgExitErrorCheck (
- IN GHCB *Ghcb
+ IN GHCB *Ghcb
)
{
GHCB_EVENT_INJECTION Event;
@@ -36,8 +36,10 @@ VmgExitErrorCheck (
UINT64 Status;
ExitInfo.Uint64 = Ghcb->SaveArea.SwExitInfo1;
- ASSERT ((ExitInfo.Elements.Lower32Bits == 0) ||
- (ExitInfo.Elements.Lower32Bits == 1));
+ ASSERT (
+ (ExitInfo.Elements.Lower32Bits == 0) ||
+ (ExitInfo.Elements.Lower32Bits == 1)
+ );
Status = 0;
if (ExitInfo.Elements.Lower32Bits == 0) {
@@ -52,14 +54,15 @@ VmgExitErrorCheck (
//
Event.Uint64 = Ghcb->SaveArea.SwExitInfo2;
if (Event.Elements.Valid &&
- Event.Elements.Type == GHCB_EVENT_INJECTION_TYPE_EXCEPTION) {
+ (Event.Elements.Type == GHCB_EVENT_INJECTION_TYPE_EXCEPTION))
+ {
switch (Event.Elements.Vector) {
- case GP_EXCEPTION:
- case UD_EXCEPTION:
- //
- // Use returned event as return code
- //
- Status = Event.Uint64;
+ case GP_EXCEPTION:
+ case UD_EXCEPTION:
+ //
+ // Use returned event as return code
+ //
+ Status = Event.Uint64;
}
}
}
@@ -67,7 +70,7 @@ VmgExitErrorCheck (
if (Status == 0) {
GHCB_EVENT_INJECTION GpEvent;
- GpEvent.Uint64 = 0;
+ GpEvent.Uint64 = 0;
GpEvent.Elements.Vector = GP_EXCEPTION;
GpEvent.Elements.Type = GHCB_EVENT_INJECTION_TYPE_EXCEPTION;
GpEvent.Elements.Valid = 1;
@@ -100,13 +103,13 @@ VmgExitErrorCheck (
UINT64
EFIAPI
VmgExit (
- IN OUT GHCB *Ghcb,
- IN UINT64 ExitCode,
- IN UINT64 ExitInfo1,
- IN UINT64 ExitInfo2
+ IN OUT GHCB *Ghcb,
+ IN UINT64 ExitCode,
+ IN UINT64 ExitInfo1,
+ IN UINT64 ExitInfo2
)
{
- Ghcb->SaveArea.SwExitCode = ExitCode;
+ Ghcb->SaveArea.SwExitCode = ExitCode;
Ghcb->SaveArea.SwExitInfo1 = ExitInfo1;
Ghcb->SaveArea.SwExitInfo2 = ExitInfo2;
@@ -140,8 +143,8 @@ VmgExit (
VOID
EFIAPI
VmgInit (
- IN OUT GHCB *Ghcb,
- IN OUT BOOLEAN *InterruptState
+ IN OUT GHCB *Ghcb,
+ IN OUT BOOLEAN *InterruptState
)
{
//
@@ -170,8 +173,8 @@ VmgInit (
VOID
EFIAPI
VmgDone (
- IN OUT GHCB *Ghcb,
- IN BOOLEAN InterruptState
+ IN OUT GHCB *Ghcb,
+ IN BOOLEAN InterruptState
)
{
if (InterruptState) {
@@ -192,8 +195,8 @@ VmgDone (
VOID
EFIAPI
VmgSetOffsetValid (
- IN OUT GHCB *Ghcb,
- IN GHCB_REGISTER Offset
+ IN OUT GHCB *Ghcb,
+ IN GHCB_REGISTER Offset
)
{
UINT32 OffsetIndex;
@@ -221,8 +224,8 @@ VmgSetOffsetValid (
BOOLEAN
EFIAPI
VmgIsOffsetValid (
- IN GHCB *Ghcb,
- IN GHCB_REGISTER Offset
+ IN GHCB *Ghcb,
+ IN GHCB_REGISTER Offset
)
{
UINT32 OffsetIndex;
diff --git a/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c b/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c
index 41b0c8cc53..81a93968c8 100644
--- a/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c
+++ b/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c
@@ -22,7 +22,7 @@
// Instruction execution mode definition
//
typedef enum {
- LongMode64Bit = 0,
+ LongMode64Bit = 0,
LongModeCompat32Bit,
LongModeCompat16Bit,
} SEV_ES_INSTRUCTION_MODE;
@@ -31,7 +31,7 @@ typedef enum {
// Instruction size definition (for operand and address)
//
typedef enum {
- Size8Bits = 0,
+ Size8Bits = 0,
Size16Bits,
Size32Bits,
Size64Bits,
@@ -41,7 +41,7 @@ typedef enum {
// Intruction segment definition
//
typedef enum {
- SegmentEs = 0,
+ SegmentEs = 0,
SegmentCs,
SegmentSs,
SegmentDs,
@@ -53,70 +53,70 @@ typedef enum {
// Instruction rep function definition
//
typedef enum {
- RepNone = 0,
+ RepNone = 0,
RepZ,
RepNZ,
} SEV_ES_INSTRUCTION_REP;
typedef struct {
- UINT8 Rm;
- UINT8 Reg;
- UINT8 Mod;
+ UINT8 Rm;
+ UINT8 Reg;
+ UINT8 Mod;
} SEV_ES_INSTRUCTION_MODRM_EXT;
typedef struct {
- UINT8 Base;
- UINT8 Index;
- UINT8 Scale;
+ UINT8 Base;
+ UINT8 Index;
+ UINT8 Scale;
} SEV_ES_INSTRUCTION_SIB_EXT;
//
// Instruction opcode definition
//
typedef struct {
- SEV_ES_INSTRUCTION_MODRM_EXT ModRm;
+ SEV_ES_INSTRUCTION_MODRM_EXT ModRm;
- SEV_ES_INSTRUCTION_SIB_EXT Sib;
+ SEV_ES_INSTRUCTION_SIB_EXT Sib;
- UINTN RegData;
- UINTN RmData;
+ UINTN RegData;
+ UINTN RmData;
} SEV_ES_INSTRUCTION_OPCODE_EXT;
//
// Instruction parsing context definition
//
typedef struct {
- GHCB *Ghcb;
+ GHCB *Ghcb;
- SEV_ES_INSTRUCTION_MODE Mode;
- SEV_ES_INSTRUCTION_SIZE DataSize;
- SEV_ES_INSTRUCTION_SIZE AddrSize;
- BOOLEAN SegmentSpecified;
- SEV_ES_INSTRUCTION_SEGMENT Segment;
- SEV_ES_INSTRUCTION_REP RepMode;
+ SEV_ES_INSTRUCTION_MODE Mode;
+ SEV_ES_INSTRUCTION_SIZE DataSize;
+ SEV_ES_INSTRUCTION_SIZE AddrSize;
+ BOOLEAN SegmentSpecified;
+ SEV_ES_INSTRUCTION_SEGMENT Segment;
+ SEV_ES_INSTRUCTION_REP RepMode;
- UINT8 *Begin;
- UINT8 *End;
+ UINT8 *Begin;
+ UINT8 *End;
- UINT8 *Prefixes;
- UINT8 *OpCodes;
- UINT8 *Displacement;
- UINT8 *Immediate;
+ UINT8 *Prefixes;
+ UINT8 *OpCodes;
+ UINT8 *Displacement;
+ UINT8 *Immediate;
- INSTRUCTION_REX_PREFIX RexPrefix;
+ INSTRUCTION_REX_PREFIX RexPrefix;
- BOOLEAN ModRmPresent;
- INSTRUCTION_MODRM ModRm;
+ BOOLEAN ModRmPresent;
+ INSTRUCTION_MODRM ModRm;
- BOOLEAN SibPresent;
- INSTRUCTION_SIB Sib;
+ BOOLEAN SibPresent;
+ INSTRUCTION_SIB Sib;
- UINTN PrefixSize;
- UINTN OpCodeSize;
- UINTN DisplacementSize;
- UINTN ImmediateSize;
+ UINTN PrefixSize;
+ UINTN OpCodeSize;
+ UINTN DisplacementSize;
+ UINTN ImmediateSize;
- SEV_ES_INSTRUCTION_OPCODE_EXT Ext;
+ SEV_ES_INSTRUCTION_OPCODE_EXT Ext;
} SEV_ES_INSTRUCTION_DATA;
//
@@ -145,64 +145,65 @@ UINT64
STATIC
UINT64 *
GetRegisterPointer (
- IN EFI_SYSTEM_CONTEXT_X64 *Regs,
- IN UINT8 Register
+ IN EFI_SYSTEM_CONTEXT_X64 *Regs,
+ IN UINT8 Register
)
{
- UINT64 *Reg;
+ UINT64 *Reg;
switch (Register) {
- case 0:
- Reg = &Regs->Rax;
- break;
- case 1:
- Reg = &Regs->Rcx;
- break;
- case 2:
- Reg = &Regs->Rdx;
- break;
- case 3:
- Reg = &Regs->Rbx;
- break;
- case 4:
- Reg = &Regs->Rsp;
- break;
- case 5:
- Reg = &Regs->Rbp;
- break;
- case 6:
- Reg = &Regs->Rsi;
- break;
- case 7:
- Reg = &Regs->Rdi;
- break;
- case 8:
- Reg = &Regs->R8;
- break;
- case 9:
- Reg = &Regs->R9;
- break;
- case 10:
- Reg = &Regs->R10;
- break;
- case 11:
- Reg = &Regs->R11;
- break;
- case 12:
- Reg = &Regs->R12;
- break;
- case 13:
- Reg = &Regs->R13;
- break;
- case 14:
- Reg = &Regs->R14;
- break;
- case 15:
- Reg = &Regs->R15;
- break;
- default:
- Reg = NULL;
+ case 0:
+ Reg = &Regs->Rax;
+ break;
+ case 1:
+ Reg = &Regs->Rcx;
+ break;
+ case 2:
+ Reg = &Regs->Rdx;
+ break;
+ case 3:
+ Reg = &Regs->Rbx;
+ break;
+ case 4:
+ Reg = &Regs->Rsp;
+ break;
+ case 5:
+ Reg = &Regs->Rbp;
+ break;
+ case 6:
+ Reg = &Regs->Rsi;
+ break;
+ case 7:
+ Reg = &Regs->Rdi;
+ break;
+ case 8:
+ Reg = &Regs->R8;
+ break;
+ case 9:
+ Reg = &Regs->R9;
+ break;
+ case 10:
+ Reg = &Regs->R10;
+ break;
+ case 11:
+ Reg = &Regs->R11;
+ break;
+ case 12:
+ Reg = &Regs->R12;
+ break;
+ case 13:
+ Reg = &Regs->R13;
+ break;
+ case 14:
+ Reg = &Regs->R14;
+ break;
+ case 15:
+ Reg = &Regs->R15;
+ break;
+ default:
+ Reg = NULL;
}
+
ASSERT (Reg != NULL);
return Reg;
@@ -223,8 +224,8 @@ UpdateForDisplacement (
)
{
InstructionData->DisplacementSize = Size;
- InstructionData->Immediate += Size;
- InstructionData->End += Size;
+ InstructionData->Immediate += Size;
+ InstructionData->End += Size;
}
/**
@@ -277,42 +278,43 @@ GetEffectiveMemoryAddress (
SEV_ES_INSTRUCTION_OPCODE_EXT *Ext;
UINT64 EffectiveAddress;
- Ext = &InstructionData->Ext;
+ Ext = &InstructionData->Ext;
EffectiveAddress = 0;
if (IsRipRelative (InstructionData)) {
//
// RIP-relative displacement is a 32-bit signed value
//
- INT32 RipRelative;
+ INT32 RipRelative;
- RipRelative = *(INT32 *) InstructionData->Displacement;
+ RipRelative = *(INT32 *)InstructionData->Displacement;
UpdateForDisplacement (InstructionData, 4);
//
// Negative displacement is handled by standard UINT64 wrap-around.
//
- return Regs->Rip + (UINT64) RipRelative;
+ return Regs->Rip + (UINT64)RipRelative;
}
switch (Ext->ModRm.Mod) {
- case 1:
- UpdateForDisplacement (InstructionData, 1);
- EffectiveAddress += (UINT64) (*(INT8 *) (InstructionData->Displacement));
- break;
- case 2:
- switch (InstructionData->AddrSize) {
- case Size16Bits:
- UpdateForDisplacement (InstructionData, 2);
- EffectiveAddress += (UINT64) (*(INT16 *) (InstructionData->Displacement));
+ case 1:
+ UpdateForDisplacement (InstructionData, 1);
+ EffectiveAddress += (UINT64)(*(INT8 *)(InstructionData->Displacement));
break;
- default:
- UpdateForDisplacement (InstructionData, 4);
- EffectiveAddress += (UINT64) (*(INT32 *) (InstructionData->Displacement));
+ case 2:
+ switch (InstructionData->AddrSize) {
+ case Size16Bits:
+ UpdateForDisplacement (InstructionData, 2);
+ EffectiveAddress += (UINT64)(*(INT16 *)(InstructionData->Displacement));
+ break;
+ default:
+ UpdateForDisplacement (InstructionData, 4);
+ EffectiveAddress += (UINT64)(*(INT32 *)(InstructionData->Displacement));
+ break;
+ }
+
break;
- }
- break;
}
if (InstructionData->SibPresent) {
@@ -329,14 +331,14 @@ GetEffectiveMemoryAddress (
//
// Negative displacement is handled by standard UINT64 wrap-around.
//
- EffectiveAddress += (UINT64) Displacement;
+ EffectiveAddress += (UINT64)Displacement;
}
if ((Ext->Sib.Base != 5) || Ext->ModRm.Mod) {
EffectiveAddress += *GetRegisterPointer (Regs, Ext->Sib.Base);
} else {
UpdateForDisplacement (InstructionData, 4);
- EffectiveAddress += (UINT64) (*(INT32 *) (InstructionData->Displacement));
+ EffectiveAddress += (UINT64)(*(INT32 *)(InstructionData->Displacement));
}
} else {
EffectiveAddress += *GetRegisterPointer (Regs, Ext->ModRm.Rm);
@@ -368,12 +370,12 @@ DecodeModRm (
INSTRUCTION_SIB *Sib;
RexPrefix = &InstructionData->RexPrefix;
- Ext = &InstructionData->Ext;
- ModRm = &InstructionData->ModRm;
- Sib = &InstructionData->Sib;
+ Ext = &InstructionData->Ext;
+ ModRm = &InstructionData->ModRm;
+ Sib = &InstructionData->Sib;
InstructionData->ModRmPresent = TRUE;
- ModRm->Uint8 = *(InstructionData->End);
+ ModRm->Uint8 = *(InstructionData->End);
InstructionData->Displacement++;
InstructionData->Immediate++;
@@ -390,7 +392,7 @@ DecodeModRm (
} else {
if (ModRm->Bits.Rm == 4) {
InstructionData->SibPresent = TRUE;
- Sib->Uint8 = *(InstructionData->End);
+ Sib->Uint8 = *(InstructionData->End);
InstructionData->Displacement++;
InstructionData->Immediate++;
@@ -430,11 +432,11 @@ DecodePrefixes (
//
// Always in 64-bit mode
//
- Mode = LongMode64Bit;
+ Mode = LongMode64Bit;
ModeDataSize = Size32Bits;
ModeAddrSize = Size64Bits;
- InstructionData->Mode = Mode;
+ InstructionData->Mode = Mode;
InstructionData->DataSize = ModeDataSize;
InstructionData->AddrSize = ModeAddrSize;
@@ -452,61 +454,64 @@ DecodePrefixes (
if ((*Byte & REX_64BIT_OPERAND_SIZE_MASK) != 0) {
InstructionData->DataSize = Size64Bits;
}
+
continue;
}
switch (*Byte) {
- case OVERRIDE_SEGMENT_CS:
- case OVERRIDE_SEGMENT_DS:
- case OVERRIDE_SEGMENT_ES:
- case OVERRIDE_SEGMENT_SS:
- if (Mode != LongMode64Bit) {
+ case OVERRIDE_SEGMENT_CS:
+ case OVERRIDE_SEGMENT_DS:
+ case OVERRIDE_SEGMENT_ES:
+ case OVERRIDE_SEGMENT_SS:
+ if (Mode != LongMode64Bit) {
+ InstructionData->SegmentSpecified = TRUE;
+ InstructionData->Segment = (*Byte >> 3) & 3;
+ }
+
+ break;
+
+ case OVERRIDE_SEGMENT_FS:
+ case OVERRIDE_SEGMENT_GS:
InstructionData->SegmentSpecified = TRUE;
- InstructionData->Segment = (*Byte >> 3) & 3;
- }
- break;
-
- case OVERRIDE_SEGMENT_FS:
- case OVERRIDE_SEGMENT_GS:
- InstructionData->SegmentSpecified = TRUE;
- InstructionData->Segment = *Byte & 7;
- break;
-
- case OVERRIDE_OPERAND_SIZE:
- if (InstructionData->RexPrefix.Uint8 == 0) {
- InstructionData->DataSize =
- (Mode == LongMode64Bit) ? Size16Bits :
+ InstructionData->Segment = *Byte & 7;
+ break;
+
+ case OVERRIDE_OPERAND_SIZE:
+ if (InstructionData->RexPrefix.Uint8 == 0) {
+ InstructionData->DataSize =
+ (Mode == LongMode64Bit) ? Size16Bits :
+ (Mode == LongModeCompat32Bit) ? Size16Bits :
+ (Mode == LongModeCompat16Bit) ? Size32Bits : 0;
+ }
+
+ break;
+
+ case OVERRIDE_ADDRESS_SIZE:
+ InstructionData->AddrSize =
+ (Mode == LongMode64Bit) ? Size32Bits :
(Mode == LongModeCompat32Bit) ? Size16Bits :
(Mode == LongModeCompat16Bit) ? Size32Bits : 0;
- }
- break;
-
- case OVERRIDE_ADDRESS_SIZE:
- InstructionData->AddrSize =
- (Mode == LongMode64Bit) ? Size32Bits :
- (Mode == LongModeCompat32Bit) ? Size16Bits :
- (Mode == LongModeCompat16Bit) ? Size32Bits : 0;
- break;
+ break;
- case LOCK_PREFIX:
- break;
+ case LOCK_PREFIX:
+ break;
- case REPZ_PREFIX:
- InstructionData->RepMode = RepZ;
- break;
+ case REPZ_PREFIX:
+ InstructionData->RepMode = RepZ;
+ break;
- case REPNZ_PREFIX:
- InstructionData->RepMode = RepNZ;
- break;
+ case REPNZ_PREFIX:
+ InstructionData->RepMode = RepNZ;
+ break;
- default:
- InstructionData->OpCodes = Byte;
- InstructionData->OpCodeSize = (*Byte == TWO_BYTE_OPCODE_ESCAPE) ? 2 : 1;
+ default:
+ InstructionData->OpCodes = Byte;
+ InstructionData->OpCodeSize = (*Byte == TWO_BYTE_OPCODE_ESCAPE) ? 2 : 1;
- InstructionData->End = Byte + InstructionData->OpCodeSize;
- InstructionData->Displacement = InstructionData->End;
- InstructionData->Immediate = InstructionData->End;
- return;
+ InstructionData->End = Byte + InstructionData->OpCodeSize;
+ InstructionData->Displacement = InstructionData->End;
+ InstructionData->Immediate = InstructionData->End;
+ return;
}
}
}
@@ -527,7 +532,7 @@ InstructionLength (
IN SEV_ES_INSTRUCTION_DATA *InstructionData
)
{
- return (UINT64) (InstructionData->End - InstructionData->Begin);
+ return (UINT64)(InstructionData->End - InstructionData->Begin);
}
/**
@@ -551,9 +556,9 @@ InitInstructionData (
)
{
SetMem (InstructionData, sizeof (*InstructionData), 0);
- InstructionData->Ghcb = Ghcb;
- InstructionData->Begin = (UINT8 *) Regs->Rip;
- InstructionData->End = (UINT8 *) Regs->Rip;
+ InstructionData->Ghcb = Ghcb;
+ InstructionData->Begin = (UINT8 *)Regs->Rip;
+ InstructionData->End = (UINT8 *)Regs->Rip;
DecodePrefixes (Regs, InstructionData);
}
@@ -585,7 +590,7 @@ UnsupportedExit (
if (Status == 0) {
GHCB_EVENT_INJECTION Event;
- Event.Uint64 = 0;
+ Event.Uint64 = 0;
Event.Elements.Vector = GP_EXCEPTION;
Event.Elements.Type = GHCB_EVENT_INJECTION_TYPE_EXCEPTION;
Event.Elements.Valid = 1;
@@ -643,10 +648,12 @@ ValidateMmioMemory (
//
// Any state other than unencrypted is an error, issue a #GP.
//
- DEBUG ((DEBUG_ERROR,
+ DEBUG ((
+ DEBUG_ERROR,
"MMIO using encrypted memory: %lx\n",
- (UINT64) MemoryAddress));
- GpEvent.Uint64 = 0;
+ (UINT64)MemoryAddress
+ ));
+ GpEvent.Uint64 = 0;
GpEvent.Elements.Vector = GP_EXCEPTION;
GpEvent.Elements.Type = GHCB_EVENT_INJECTION_TYPE_EXCEPTION;
GpEvent.Elements.Valid = 1;
@@ -690,317 +697,322 @@ MmioExit (
}
switch (OpCode) {
- //
- // MMIO write (MOV reg/memX, regX)
- //
- case 0x88:
- Bytes = 1;
+ //
+ // MMIO write (MOV reg/memX, regX)
+ //
+ case 0x88:
+ Bytes = 1;
//
// fall through
//
- case 0x89:
- DecodeModRm (Regs, InstructionData);
- Bytes = ((Bytes != 0) ? Bytes :
- (InstructionData->DataSize == Size16Bits) ? 2 :
- (InstructionData->DataSize == Size32Bits) ? 4 :
- (InstructionData->DataSize == Size64Bits) ? 8 :
- 0);
-
- if (InstructionData->Ext.ModRm.Mod == 3) {
- //
- // NPF on two register operands???
- //
- return UnsupportedExit (Ghcb, Regs, InstructionData);
- }
+ case 0x89:
+ DecodeModRm (Regs, InstructionData);
+ Bytes = ((Bytes != 0) ? Bytes :
+ (InstructionData->DataSize == Size16Bits) ? 2 :
+ (InstructionData->DataSize == Size32Bits) ? 4 :
+ (InstructionData->DataSize == Size64Bits) ? 8 :
+ 0);
+
+ if (InstructionData->Ext.ModRm.Mod == 3) {
+ //
+ // NPF on two register operands???
+ //
+ return UnsupportedExit (Ghcb, Regs, InstructionData);
+ }
- Status = ValidateMmioMemory (Ghcb, InstructionData->Ext.RmData, Bytes);
- if (Status != 0) {
- return Status;
- }
+ Status = ValidateMmioMemory (Ghcb, InstructionData->Ext.RmData, Bytes);
+ if (Status != 0) {
+ return Status;
+ }
- ExitInfo1 = InstructionData->Ext.RmData;
- ExitInfo2 = Bytes;
- CopyMem (Ghcb->SharedBuffer, &InstructionData->Ext.RegData, Bytes);
+ ExitInfo1 = InstructionData->Ext.RmData;
+ ExitInfo2 = Bytes;
+ CopyMem (Ghcb->SharedBuffer, &InstructionData->Ext.RegData, Bytes);
- Ghcb->SaveArea.SwScratch = (UINT64) Ghcb->SharedBuffer;
- VmgSetOffsetValid (Ghcb, GhcbSwScratch);
- Status = VmgExit (Ghcb, SVM_EXIT_MMIO_WRITE, ExitInfo1, ExitInfo2);
- if (Status != 0) {
- return Status;
- }
- break;
+ Ghcb->SaveArea.SwScratch = (UINT64)Ghcb->SharedBuffer;
+ VmgSetOffsetValid (Ghcb, GhcbSwScratch);
+ Status = VmgExit (Ghcb, SVM_EXIT_MMIO_WRITE, ExitInfo1, ExitInfo2);
+ if (Status != 0) {
+ return Status;
+ }
- //
- // MMIO write (MOV moffsetX, aX)
- //
- case 0xA2:
- Bytes = 1;
+ break;
+
+ //
+ // MMIO write (MOV moffsetX, aX)
+ //
+ case 0xA2:
+ Bytes = 1;
//
// fall through
//
- case 0xA3:
- Bytes = ((Bytes != 0) ? Bytes :
- (InstructionData->DataSize == Size16Bits) ? 2 :
- (InstructionData->DataSize == Size32Bits) ? 4 :
- (InstructionData->DataSize == Size64Bits) ? 8 :
- 0);
+ case 0xA3:
+ Bytes = ((Bytes != 0) ? Bytes :
+ (InstructionData->DataSize == Size16Bits) ? 2 :
+ (InstructionData->DataSize == Size32Bits) ? 4 :
+ (InstructionData->DataSize == Size64Bits) ? 8 :
+ 0);
- InstructionData->ImmediateSize = (UINTN) (1 << InstructionData->AddrSize);
- InstructionData->End += InstructionData->ImmediateSize;
+ InstructionData->ImmediateSize = (UINTN)(1 << InstructionData->AddrSize);
+ InstructionData->End += InstructionData->ImmediateSize;
- //
- // This code is X64 only, so a possible 8-byte copy to a UINTN is ok.
- // Use a STATIC_ASSERT to be certain the code is being built as X64.
- //
- STATIC_ASSERT (
- sizeof (UINTN) == sizeof (UINT64),
- "sizeof (UINTN) != sizeof (UINT64), this file must be built as X64"
- );
-
- Address = 0;
- CopyMem (
- &Address,
- InstructionData->Immediate,
- InstructionData->ImmediateSize
- );
-
- Status = ValidateMmioMemory (Ghcb, Address, Bytes);
- if (Status != 0) {
- return Status;
- }
+ //
+ // This code is X64 only, so a possible 8-byte copy to a UINTN is ok.
+ // Use a STATIC_ASSERT to be certain the code is being built as X64.
+ //
+ STATIC_ASSERT (
+ sizeof (UINTN) == sizeof (UINT64),
+ "sizeof (UINTN) != sizeof (UINT64), this file must be built as X64"
+ );
- ExitInfo1 = Address;
- ExitInfo2 = Bytes;
- CopyMem (Ghcb->SharedBuffer, &Regs->Rax, Bytes);
+ Address = 0;
+ CopyMem (
+ &Address,
+ InstructionData->Immediate,
+ InstructionData->ImmediateSize
+ );
- Ghcb->SaveArea.SwScratch = (UINT64) Ghcb->SharedBuffer;
- VmgSetOffsetValid (Ghcb, GhcbSwScratch);
- Status = VmgExit (Ghcb, SVM_EXIT_MMIO_WRITE, ExitInfo1, ExitInfo2);
- if (Status != 0) {
- return Status;
- }
- break;
+ Status = ValidateMmioMemory (Ghcb, Address, Bytes);
+ if (Status != 0) {
+ return Status;
+ }
- //
- // MMIO write (MOV reg/memX, immX)
- //
- case 0xC6:
- Bytes = 1;
+ ExitInfo1 = Address;
+ ExitInfo2 = Bytes;
+ CopyMem (Ghcb->SharedBuffer, &Regs->Rax, Bytes);
+
+ Ghcb->SaveArea.SwScratch = (UINT64)Ghcb->SharedBuffer;
+ VmgSetOffsetValid (Ghcb, GhcbSwScratch);
+ Status = VmgExit (Ghcb, SVM_EXIT_MMIO_WRITE, ExitInfo1, ExitInfo2);
+ if (Status != 0) {
+ return Status;
+ }
+
+ break;
+
+ //
+ // MMIO write (MOV reg/memX, immX)
+ //
+ case 0xC6:
+ Bytes = 1;
//
// fall through
//
- case 0xC7:
- DecodeModRm (Regs, InstructionData);
- Bytes = ((Bytes != 0) ? Bytes :
- (InstructionData->DataSize == Size16Bits) ? 2 :
- (InstructionData->DataSize == Size32Bits) ? 4 :
- 0);
+ case 0xC7:
+ DecodeModRm (Regs, InstructionData);
+ Bytes = ((Bytes != 0) ? Bytes :
+ (InstructionData->DataSize == Size16Bits) ? 2 :
+ (InstructionData->DataSize == Size32Bits) ? 4 :
+ 0);
- InstructionData->ImmediateSize = Bytes;
- InstructionData->End += Bytes;
+ InstructionData->ImmediateSize = Bytes;
+ InstructionData->End += Bytes;
- Status = ValidateMmioMemory (Ghcb, InstructionData->Ext.RmData, Bytes);
- if (Status != 0) {
- return Status;
- }
+ Status = ValidateMmioMemory (Ghcb, InstructionData->Ext.RmData, Bytes);
+ if (Status != 0) {
+ return Status;
+ }
- ExitInfo1 = InstructionData->Ext.RmData;
- ExitInfo2 = Bytes;
- CopyMem (Ghcb->SharedBuffer, InstructionData->Immediate, Bytes);
+ ExitInfo1 = InstructionData->Ext.RmData;
+ ExitInfo2 = Bytes;
+ CopyMem (Ghcb->SharedBuffer, InstructionData->Immediate, Bytes);
- Ghcb->SaveArea.SwScratch = (UINT64) Ghcb->SharedBuffer;
- VmgSetOffsetValid (Ghcb, GhcbSwScratch);
- Status = VmgExit (Ghcb, SVM_EXIT_MMIO_WRITE, ExitInfo1, ExitInfo2);
- if (Status != 0) {
- return Status;
- }
- break;
+ Ghcb->SaveArea.SwScratch = (UINT64)Ghcb->SharedBuffer;
+ VmgSetOffsetValid (Ghcb, GhcbSwScratch);
+ Status = VmgExit (Ghcb, SVM_EXIT_MMIO_WRITE, ExitInfo1, ExitInfo2);
+ if (Status != 0) {
+ return Status;
+ }
- //
- // MMIO read (MOV regX, reg/memX)
- //
- case 0x8A:
- Bytes = 1;
+ break;
+
+ //
+ // MMIO read (MOV regX, reg/memX)
+ //
+ case 0x8A:
+ Bytes = 1;
//
// fall through
//
- case 0x8B:
- DecodeModRm (Regs, InstructionData);
- Bytes = ((Bytes != 0) ? Bytes :
- (InstructionData->DataSize == Size16Bits) ? 2 :
- (InstructionData->DataSize == Size32Bits) ? 4 :
- (InstructionData->DataSize == Size64Bits) ? 8 :
- 0);
- if (InstructionData->Ext.ModRm.Mod == 3) {
- //
- // NPF on two register operands???
- //
- return UnsupportedExit (Ghcb, Regs, InstructionData);
- }
+ case 0x8B:
+ DecodeModRm (Regs, InstructionData);
+ Bytes = ((Bytes != 0) ? Bytes :
+ (InstructionData->DataSize == Size16Bits) ? 2 :
+ (InstructionData->DataSize == Size32Bits) ? 4 :
+ (InstructionData->DataSize == Size64Bits) ? 8 :
+ 0);
+ if (InstructionData->Ext.ModRm.Mod == 3) {
+ //
+ // NPF on two register operands???
+ //
+ return UnsupportedExit (Ghcb, Regs, InstructionData);
+ }
- Status = ValidateMmioMemory (Ghcb, InstructionData->Ext.RmData, Bytes);
- if (Status != 0) {
- return Status;
- }
+ Status = ValidateMmioMemory (Ghcb, InstructionData->Ext.RmData, Bytes);
+ if (Status != 0) {
+ return Status;
+ }
- ExitInfo1 = InstructionData->Ext.RmData;
- ExitInfo2 = Bytes;
+ ExitInfo1 = InstructionData->Ext.RmData;
+ ExitInfo2 = Bytes;
- Ghcb->SaveArea.SwScratch = (UINT64) Ghcb->SharedBuffer;
- VmgSetOffsetValid (Ghcb, GhcbSwScratch);
- Status = VmgExit (Ghcb, SVM_EXIT_MMIO_READ, ExitInfo1, ExitInfo2);
- if (Status != 0) {
- return Status;
- }
+ Ghcb->SaveArea.SwScratch = (UINT64)Ghcb->SharedBuffer;
+ VmgSetOffsetValid (Ghcb, GhcbSwScratch);
+ Status = VmgExit (Ghcb, SVM_EXIT_MMIO_READ, ExitInfo1, ExitInfo2);
+ if (Status != 0) {
+ return Status;
+ }
- Register = GetRegisterPointer (Regs, InstructionData->Ext.ModRm.Reg);
- if (Bytes == 4) {
- //
- // Zero-extend for 32-bit operation
- //
- *Register = 0;
- }
- CopyMem (Register, Ghcb->SharedBuffer, Bytes);
- break;
+ Register = GetRegisterPointer (Regs, InstructionData->Ext.ModRm.Reg);
+ if (Bytes == 4) {
+ //
+ // Zero-extend for 32-bit operation
+ //
+ *Register = 0;
+ }
+
+ CopyMem (Register, Ghcb->SharedBuffer, Bytes);
+ break;
- //
- // MMIO read (MOV aX, moffsetX)
- //
- case 0xA0:
- Bytes = 1;
//
- // fall through
+ // MMIO read (MOV aX, moffsetX)
//
- case 0xA1:
- Bytes = ((Bytes != 0) ? Bytes :
- (InstructionData->DataSize == Size16Bits) ? 2 :
- (InstructionData->DataSize == Size32Bits) ? 4 :
- (InstructionData->DataSize == Size64Bits) ? 8 :
- 0);
-
- InstructionData->ImmediateSize = (UINTN) (1 << InstructionData->AddrSize);
- InstructionData->End += InstructionData->ImmediateSize;
-
+ case 0xA0:
+ Bytes = 1;
//
- // This code is X64 only, so a possible 8-byte copy to a UINTN is ok.
- // Use a STATIC_ASSERT to be certain the code is being built as X64.
+ // fall through
//
- STATIC_ASSERT (
- sizeof (UINTN) == sizeof (UINT64),
- "sizeof (UINTN) != sizeof (UINT64), this file must be built as X64"
- );
-
- Address = 0;
- CopyMem (
- &Address,
- InstructionData->Immediate,
- InstructionData->ImmediateSize
- );
-
- Status = ValidateMmioMemory (Ghcb, Address, Bytes);
- if (Status != 0) {
- return Status;
- }
-
- ExitInfo1 = Address;
- ExitInfo2 = Bytes;
+ case 0xA1:
+ Bytes = ((Bytes != 0) ? Bytes :
+ (InstructionData->DataSize == Size16Bits) ? 2 :
+ (InstructionData->DataSize == Size32Bits) ? 4 :
+ (InstructionData->DataSize == Size64Bits) ? 8 :
+ 0);
- Ghcb->SaveArea.SwScratch = (UINT64) Ghcb->SharedBuffer;
- VmgSetOffsetValid (Ghcb, GhcbSwScratch);
- Status = VmgExit (Ghcb, SVM_EXIT_MMIO_READ, ExitInfo1, ExitInfo2);
- if (Status != 0) {
- return Status;
- }
+ InstructionData->ImmediateSize = (UINTN)(1 << InstructionData->AddrSize);
+ InstructionData->End += InstructionData->ImmediateSize;
- if (Bytes == 4) {
//
- // Zero-extend for 32-bit operation
+ // This code is X64 only, so a possible 8-byte copy to a UINTN is ok.
+ // Use a STATIC_ASSERT to be certain the code is being built as X64.
//
- Regs->Rax = 0;
- }
- CopyMem (&Regs->Rax, Ghcb->SharedBuffer, Bytes);
- break;
+ STATIC_ASSERT (
+ sizeof (UINTN) == sizeof (UINT64),
+ "sizeof (UINTN) != sizeof (UINT64), this file must be built as X64"
+ );
- //
- // MMIO read w/ zero-extension ((MOVZX regX, reg/memX)
- //
- case 0xB6:
- Bytes = 1;
+ Address = 0;
+ CopyMem (
+ &Address,
+ InstructionData->Immediate,
+ InstructionData->ImmediateSize
+ );
+
+ Status = ValidateMmioMemory (Ghcb, Address, Bytes);
+ if (Status != 0) {
+ return Status;
+ }
+
+ ExitInfo1 = Address;
+ ExitInfo2 = Bytes;
+
+ Ghcb->SaveArea.SwScratch = (UINT64)Ghcb->SharedBuffer;
+ VmgSetOffsetValid (Ghcb, GhcbSwScratch);
+ Status = VmgExit (Ghcb, SVM_EXIT_MMIO_READ, ExitInfo1, ExitInfo2);
+ if (Status != 0) {
+ return Status;
+ }
+
+ if (Bytes == 4) {
+ //
+ // Zero-extend for 32-bit operation
+ //
+ Regs->Rax = 0;
+ }
+
+ CopyMem (&Regs->Rax, Ghcb->SharedBuffer, Bytes);
+ break;
+
+ //
+ // MMIO read w/ zero-extension ((MOVZX regX, reg/memX)
+ //
+ case 0xB6:
+ Bytes = 1;
//
// fall through
//
- case 0xB7:
- DecodeModRm (Regs, InstructionData);
- Bytes = (Bytes != 0) ? Bytes : 2;
+ case 0xB7:
+ DecodeModRm (Regs, InstructionData);
+ Bytes = (Bytes != 0) ? Bytes : 2;
- Status = ValidateMmioMemory (Ghcb, InstructionData->Ext.RmData, Bytes);
- if (Status != 0) {
- return Status;
- }
+ Status = ValidateMmioMemory (Ghcb, InstructionData->Ext.RmData, Bytes);
+ if (Status != 0) {
+ return Status;
+ }
- ExitInfo1 = InstructionData->Ext.RmData;
- ExitInfo2 = Bytes;
+ ExitInfo1 = InstructionData->Ext.RmData;
+ ExitInfo2 = Bytes;
- Ghcb->SaveArea.SwScratch = (UINT64) Ghcb->SharedBuffer;
- VmgSetOffsetValid (Ghcb, GhcbSwScratch);
- Status = VmgExit (Ghcb, SVM_EXIT_MMIO_READ, ExitInfo1, ExitInfo2);
- if (Status != 0) {
- return Status;
- }
+ Ghcb->SaveArea.SwScratch = (UINT64)Ghcb->SharedBuffer;
+ VmgSetOffsetValid (Ghcb, GhcbSwScratch);
+ Status = VmgExit (Ghcb, SVM_EXIT_MMIO_READ, ExitInfo1, ExitInfo2);
+ if (Status != 0) {
+ return Status;
+ }
- Register = GetRegisterPointer (Regs, InstructionData->Ext.ModRm.Reg);
- SetMem (Register, (UINTN) (1 << InstructionData->DataSize), 0);
- CopyMem (Register, Ghcb->SharedBuffer, Bytes);
- break;
+ Register = GetRegisterPointer (Regs, InstructionData->Ext.ModRm.Reg);
+ SetMem (Register, (UINTN)(1 << InstructionData->DataSize), 0);
+ CopyMem (Register, Ghcb->SharedBuffer, Bytes);
+ break;
- //
- // MMIO read w/ sign-extension (MOVSX regX, reg/memX)
- //
- case 0xBE:
- Bytes = 1;
+ //
+ // MMIO read w/ sign-extension (MOVSX regX, reg/memX)
+ //
+ case 0xBE:
+ Bytes = 1;
//
// fall through
//
- case 0xBF:
- DecodeModRm (Regs, InstructionData);
- Bytes = (Bytes != 0) ? Bytes : 2;
+ case 0xBF:
+ DecodeModRm (Regs, InstructionData);
+ Bytes = (Bytes != 0) ? Bytes : 2;
- Status = ValidateMmioMemory (Ghcb, InstructionData->Ext.RmData, Bytes);
- if (Status != 0) {
- return Status;
- }
+ Status = ValidateMmioMemory (Ghcb, InstructionData->Ext.RmData, Bytes);
+ if (Status != 0) {
+ return Status;
+ }
- ExitInfo1 = InstructionData->Ext.RmData;
- ExitInfo2 = Bytes;
+ ExitInfo1 = InstructionData->Ext.RmData;
+ ExitInfo2 = Bytes;
- Ghcb->SaveArea.SwScratch = (UINT64) Ghcb->SharedBuffer;
- VmgSetOffsetValid (Ghcb, GhcbSwScratch);
- Status = VmgExit (Ghcb, SVM_EXIT_MMIO_READ, ExitInfo1, ExitInfo2);
- if (Status != 0) {
- return Status;
- }
+ Ghcb->SaveArea.SwScratch = (UINT64)Ghcb->SharedBuffer;
+ VmgSetOffsetValid (Ghcb, GhcbSwScratch);
+ Status = VmgExit (Ghcb, SVM_EXIT_MMIO_READ, ExitInfo1, ExitInfo2);
+ if (Status != 0) {
+ return Status;
+ }
- if (Bytes == 1) {
- UINT8 *Data;
+ if (Bytes == 1) {
+ UINT8 *Data;
- Data = (UINT8 *) Ghcb->SharedBuffer;
- SignByte = ((*Data & BIT7) != 0) ? 0xFF : 0x00;
- } else {
- UINT16 *Data;
+ Data = (UINT8 *)Ghcb->SharedBuffer;
+ SignByte = ((*Data & BIT7) != 0) ? 0xFF : 0x00;
+ } else {
+ UINT16 *Data;
- Data = (UINT16 *) Ghcb->SharedBuffer;
- SignByte = ((*Data & BIT15) != 0) ? 0xFF : 0x00;
- }
+ Data = (UINT16 *)Ghcb->SharedBuffer;
+ SignByte = ((*Data & BIT15) != 0) ? 0xFF : 0x00;
+ }
- Register = GetRegisterPointer (Regs, InstructionData->Ext.ModRm.Reg);
- SetMem (Register, (UINTN) (1 << InstructionData->DataSize), SignByte);
- CopyMem (Register, Ghcb->SharedBuffer, Bytes);
- break;
+ Register = GetRegisterPointer (Regs, InstructionData->Ext.ModRm.Reg);
+ SetMem (Register, (UINTN)(1 << InstructionData->DataSize), SignByte);
+ CopyMem (Register, Ghcb->SharedBuffer, Bytes);
+ break;
- default:
- DEBUG ((DEBUG_ERROR, "Invalid MMIO opcode (%x)\n", OpCode));
- Status = GP_EXCEPTION;
- ASSERT (FALSE);
+ default:
+ DEBUG ((DEBUG_ERROR, "Invalid MMIO opcode (%x)\n", OpCode));
+ Status = GP_EXCEPTION;
+ ASSERT (FALSE);
}
return Status;
@@ -1130,9 +1142,11 @@ RdtscpExit (
if (!VmgIsOffsetValid (Ghcb, GhcbRax) ||
!VmgIsOffsetValid (Ghcb, GhcbRcx) ||
- !VmgIsOffsetValid (Ghcb, GhcbRdx)) {
+ !VmgIsOffsetValid (Ghcb, GhcbRdx))
+ {
return UnsupportedExit (Ghcb, Regs, InstructionData);
}
+
Regs->Rax = Ghcb->SaveArea.Rax;
Regs->Rcx = Ghcb->SaveArea.Rcx;
Regs->Rdx = Ghcb->SaveArea.Rdx;
@@ -1168,7 +1182,7 @@ VmmCallExit (
Ghcb->SaveArea.Rax = Regs->Rax;
VmgSetOffsetValid (Ghcb, GhcbRax);
- Ghcb->SaveArea.Cpl = (UINT8) (Regs->Cs & 0x3);
+ Ghcb->SaveArea.Cpl = (UINT8)(Regs->Cs & 0x3);
VmgSetOffsetValid (Ghcb, GhcbCpl);
Status = VmgExit (Ghcb, SVM_EXIT_VMMCALL, 0, 0);
@@ -1179,6 +1193,7 @@ VmmCallExit (
if (!VmgIsOffsetValid (Ghcb, GhcbRax)) {
return UnsupportedExit (Ghcb, Regs, InstructionData);
}
+
Regs->Rax = Ghcb->SaveArea.Rax;
return 0;
@@ -1211,21 +1226,21 @@ MsrExit (
ExitInfo1 = 0;
switch (*(InstructionData->OpCodes + 1)) {
- case 0x30: // WRMSR
- ExitInfo1 = 1;
- Ghcb->SaveArea.Rax = Regs->Rax;
- VmgSetOffsetValid (Ghcb, GhcbRax);
- Ghcb->SaveArea.Rdx = Regs->Rdx;
- VmgSetOffsetValid (Ghcb, GhcbRdx);
+ case 0x30: // WRMSR
+ ExitInfo1 = 1;
+ Ghcb->SaveArea.Rax = Regs->Rax;
+ VmgSetOffsetValid (Ghcb, GhcbRax);
+ Ghcb->SaveArea.Rdx = Regs->Rdx;
+ VmgSetOffsetValid (Ghcb, GhcbRdx);
//
// fall through
//
- case 0x32: // RDMSR
- Ghcb->SaveArea.Rcx = Regs->Rcx;
- VmgSetOffsetValid (Ghcb, GhcbRcx);
- break;
- default:
- return UnsupportedExit (Ghcb, Regs, InstructionData);
+ case 0x32: // RDMSR
+ Ghcb->SaveArea.Rcx = Regs->Rcx;
+ VmgSetOffsetValid (Ghcb, GhcbRcx);
+ break;
+ default:
+ return UnsupportedExit (Ghcb, Regs, InstructionData);
}
Status = VmgExit (Ghcb, SVM_EXIT_MSR, ExitInfo1, 0);
@@ -1235,9 +1250,11 @@ MsrExit (
if (ExitInfo1 == 0) {
if (!VmgIsOffsetValid (Ghcb, GhcbRax) ||
- !VmgIsOffsetValid (Ghcb, GhcbRdx)) {
+ !VmgIsOffsetValid (Ghcb, GhcbRdx))
+ {
return UnsupportedExit (Ghcb, Regs, InstructionData);
}
+
Regs->Rax = Ghcb->SaveArea.Rax;
Regs->Rdx = Ghcb->SaveArea.Rdx;
}
@@ -1269,106 +1286,106 @@ IoioExitInfo (
ExitInfo = 0;
switch (*(InstructionData->OpCodes)) {
- //
- // INS opcodes
- //
- case 0x6C:
- case 0x6D:
- ExitInfo |= IOIO_TYPE_INS;
- ExitInfo |= IOIO_SEG_ES;
- ExitInfo |= ((Regs->Rdx & 0xffff) << 16);
- break;
+ //
+ // INS opcodes
+ //
+ case 0x6C:
+ case 0x6D:
+ ExitInfo |= IOIO_TYPE_INS;
+ ExitInfo |= IOIO_SEG_ES;
+ ExitInfo |= ((Regs->Rdx & 0xffff) << 16);
+ break;
- //
- // OUTS opcodes
- //
- case 0x6E:
- case 0x6F:
- ExitInfo |= IOIO_TYPE_OUTS;
- ExitInfo |= IOIO_SEG_DS;
- ExitInfo |= ((Regs->Rdx & 0xffff) << 16);
- break;
+ //
+ // OUTS opcodes
+ //
+ case 0x6E:
+ case 0x6F:
+ ExitInfo |= IOIO_TYPE_OUTS;
+ ExitInfo |= IOIO_SEG_DS;
+ ExitInfo |= ((Regs->Rdx & 0xffff) << 16);
+ break;
- //
- // IN immediate opcodes
- //
- case 0xE4:
- case 0xE5:
- InstructionData->ImmediateSize = 1;
- InstructionData->End++;
- ExitInfo |= IOIO_TYPE_IN;
- ExitInfo |= ((*(InstructionData->OpCodes + 1)) << 16);
- break;
+ //
+ // IN immediate opcodes
+ //
+ case 0xE4:
+ case 0xE5:
+ InstructionData->ImmediateSize = 1;
+ InstructionData->End++;
+ ExitInfo |= IOIO_TYPE_IN;
+ ExitInfo |= ((*(InstructionData->OpCodes + 1)) << 16);
+ break;
- //
- // OUT immediate opcodes
- //
- case 0xE6:
- case 0xE7:
- InstructionData->ImmediateSize = 1;
- InstructionData->End++;
- ExitInfo |= IOIO_TYPE_OUT;
- ExitInfo |= ((*(InstructionData->OpCodes + 1)) << 16) | IOIO_TYPE_OUT;
- break;
+ //
+ // OUT immediate opcodes
+ //
+ case 0xE6:
+ case 0xE7:
+ InstructionData->ImmediateSize = 1;
+ InstructionData->End++;
+ ExitInfo |= IOIO_TYPE_OUT;
+ ExitInfo |= ((*(InstructionData->OpCodes + 1)) << 16) | IOIO_TYPE_OUT;
+ break;
- //
- // IN register opcodes
- //
- case 0xEC:
- case 0xED:
- ExitInfo |= IOIO_TYPE_IN;
- ExitInfo |= ((Regs->Rdx & 0xffff) << 16);
- break;
+ //
+ // IN register opcodes
+ //
+ case 0xEC:
+ case 0xED:
+ ExitInfo |= IOIO_TYPE_IN;
+ ExitInfo |= ((Regs->Rdx & 0xffff) << 16);
+ break;
- //
- // OUT register opcodes
- //
- case 0xEE:
- case 0xEF:
- ExitInfo |= IOIO_TYPE_OUT;
- ExitInfo |= ((Regs->Rdx & 0xffff) << 16);
- break;
+ //
+ // OUT register opcodes
+ //
+ case 0xEE:
+ case 0xEF:
+ ExitInfo |= IOIO_TYPE_OUT;
+ ExitInfo |= ((Regs->Rdx & 0xffff) << 16);
+ break;
- default:
- return 0;
+ default:
+ return 0;
}
switch (*(InstructionData->OpCodes)) {
- //
- // Single-byte opcodes
- //
- case 0x6C:
- case 0x6E:
- case 0xE4:
- case 0xE6:
- case 0xEC:
- case 0xEE:
- ExitInfo |= IOIO_DATA_8;
- break;
+ //
+ // Single-byte opcodes
+ //
+ case 0x6C:
+ case 0x6E:
+ case 0xE4:
+ case 0xE6:
+ case 0xEC:
+ case 0xEE:
+ ExitInfo |= IOIO_DATA_8;
+ break;
- //
- // Length determined by instruction parsing
- //
- default:
- ExitInfo |= (InstructionData->DataSize == Size16Bits) ? IOIO_DATA_16
+ //
+ // Length determined by instruction parsing
+ //
+ default:
+ ExitInfo |= (InstructionData->DataSize == Size16Bits) ? IOIO_DATA_16
: IOIO_DATA_32;
}
switch (InstructionData->AddrSize) {
- case Size16Bits:
- ExitInfo |= IOIO_ADDR_16;
- break;
+ case Size16Bits:
+ ExitInfo |= IOIO_ADDR_16;
+ break;
- case Size32Bits:
- ExitInfo |= IOIO_ADDR_32;
- break;
+ case Size32Bits:
+ ExitInfo |= IOIO_ADDR_32;
+ break;
- case Size64Bits:
- ExitInfo |= IOIO_ADDR_64;
- break;
+ case Size64Bits:
+ ExitInfo |= IOIO_ADDR_64;
+ break;
- default:
- break;
+ default:
+ break;
}
if (InstructionData->RepMode != 0) {
@@ -1415,20 +1432,20 @@ IoioExit (
Status = 0;
- IoBytes = IOIO_DATA_BYTES (ExitInfo1);
+ IoBytes = IOIO_DATA_BYTES (ExitInfo1);
GhcbCount = sizeof (Ghcb->SharedBuffer) / IoBytes;
OpCount = ((ExitInfo1 & IOIO_REP) != 0) ? Regs->Rcx : 1;
while (OpCount != 0) {
- ExitInfo2 = MIN (OpCount, GhcbCount);
+ ExitInfo2 = MIN (OpCount, GhcbCount);
VmgExitBytes = ExitInfo2 * IoBytes;
if ((ExitInfo1 & IOIO_TYPE_IN) == 0) {
- CopyMem (Ghcb->SharedBuffer, (VOID *) Regs->Rsi, VmgExitBytes);
+ CopyMem (Ghcb->SharedBuffer, (VOID *)Regs->Rsi, VmgExitBytes);
Regs->Rsi += VmgExitBytes;
}
- Ghcb->SaveArea.SwScratch = (UINT64) Ghcb->SharedBuffer;
+ Ghcb->SaveArea.SwScratch = (UINT64)Ghcb->SharedBuffer;
VmgSetOffsetValid (Ghcb, GhcbSwScratch);
Status = VmgExit (Ghcb, SVM_EXIT_IOIO_PROT, ExitInfo1, ExitInfo2);
if (Status != 0) {
@@ -1436,7 +1453,7 @@ IoioExit (
}
if ((ExitInfo1 & IOIO_TYPE_IN) != 0) {
- CopyMem ((VOID *) Regs->Rdi, Ghcb->SharedBuffer, VmgExitBytes);
+ CopyMem ((VOID *)Regs->Rdi, Ghcb->SharedBuffer, VmgExitBytes);
Regs->Rdi += VmgExitBytes;
}
@@ -1452,6 +1469,7 @@ IoioExit (
} else {
CopyMem (&Ghcb->SaveArea.Rax, &Regs->Rax, IOIO_DATA_BYTES (ExitInfo1));
}
+
VmgSetOffsetValid (Ghcb, GhcbRax);
Status = VmgExit (Ghcb, SVM_EXIT_IOIO_PROT, ExitInfo1, 0);
@@ -1463,6 +1481,7 @@ IoioExit (
if (!VmgIsOffsetValid (Ghcb, GhcbRax)) {
return UnsupportedExit (Ghcb, Regs, InstructionData);
}
+
CopyMem (&Regs->Rax, &Ghcb->SaveArea.Rax, IOIO_DATA_BYTES (ExitInfo1));
}
}
@@ -1526,7 +1545,7 @@ CpuidExit (
if (Regs->Rax == CPUID_EXTENDED_STATE) {
IA32_CR4 Cr4;
- Cr4.UintN = AsmReadCr4 ();
+ Cr4.UintN = AsmReadCr4 ();
Ghcb->SaveArea.XCr0 = (Cr4.Bits.OSXSAVE == 1) ? AsmXGetBv (0) : 1;
VmgSetOffsetValid (Ghcb, GhcbXCr0);
}
@@ -1539,9 +1558,11 @@ CpuidExit (
if (!VmgIsOffsetValid (Ghcb, GhcbRax) ||
!VmgIsOffsetValid (Ghcb, GhcbRbx) ||
!VmgIsOffsetValid (Ghcb, GhcbRcx) ||
- !VmgIsOffsetValid (Ghcb, GhcbRdx)) {
+ !VmgIsOffsetValid (Ghcb, GhcbRdx))
+ {
return UnsupportedExit (Ghcb, Regs, InstructionData);
}
+
Regs->Rax = Ghcb->SaveArea.Rax;
Regs->Rbx = Ghcb->SaveArea.Rbx;
Regs->Rcx = Ghcb->SaveArea.Rcx;
@@ -1583,9 +1604,11 @@ RdpmcExit (
}
if (!VmgIsOffsetValid (Ghcb, GhcbRax) ||
- !VmgIsOffsetValid (Ghcb, GhcbRdx)) {
+ !VmgIsOffsetValid (Ghcb, GhcbRdx))
+ {
return UnsupportedExit (Ghcb, Regs, InstructionData);
}
+
Regs->Rax = Ghcb->SaveArea.Rax;
Regs->Rdx = Ghcb->SaveArea.Rdx;
@@ -1622,9 +1645,11 @@ RdtscExit (
}
if (!VmgIsOffsetValid (Ghcb, GhcbRax) ||
- !VmgIsOffsetValid (Ghcb, GhcbRdx)) {
+ !VmgIsOffsetValid (Ghcb, GhcbRdx))
+ {
return UnsupportedExit (Ghcb, Regs, InstructionData);
}
+
Regs->Rax = Ghcb->SaveArea.Rax;
Regs->Rdx = Ghcb->SaveArea.Rdx;
@@ -1658,8 +1683,8 @@ Dr7WriteExit (
UINT64 *Register;
UINT64 Status;
- Ext = &InstructionData->Ext;
- SevEsData = (SEV_ES_PER_CPU_DATA *) (Ghcb + 1);
+ Ext = &InstructionData->Ext;
+ SevEsData = (SEV_ES_PER_CPU_DATA *)(Ghcb + 1);
DecodeModRm (Regs, InstructionData);
@@ -1679,7 +1704,7 @@ Dr7WriteExit (
return Status;
}
- SevEsData->Dr7 = *Register;
+ SevEsData->Dr7 = *Register;
SevEsData->Dr7Cached = 1;
return 0;
@@ -1710,8 +1735,8 @@ Dr7ReadExit (
SEV_ES_PER_CPU_DATA *SevEsData;
UINT64 *Register;
- Ext = &InstructionData->Ext;
- SevEsData = (SEV_ES_PER_CPU_DATA *) (Ghcb + 1);
+ Ext = &InstructionData->Ext;
+ SevEsData = (SEV_ES_PER_CPU_DATA *)(Ghcb + 1);
DecodeModRm (Regs, InstructionData);
@@ -1754,12 +1779,12 @@ InternalVmgExitHandleVc (
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
- EFI_SYSTEM_CONTEXT_X64 *Regs;
- NAE_EXIT NaeExit;
- SEV_ES_INSTRUCTION_DATA InstructionData;
- UINT64 ExitCode, Status;
- EFI_STATUS VcRet;
- BOOLEAN InterruptState;
+ EFI_SYSTEM_CONTEXT_X64 *Regs;
+ NAE_EXIT NaeExit;
+ SEV_ES_INSTRUCTION_DATA InstructionData;
+ UINT64 ExitCode, Status;
+ EFI_STATUS VcRet;
+ BOOLEAN InterruptState;
VcRet = EFI_SUCCESS;
@@ -1769,64 +1794,64 @@ InternalVmgExitHandleVc (
ExitCode = Regs->ExceptionData;
switch (ExitCode) {
- case SVM_EXIT_DR7_READ:
- NaeExit = Dr7ReadExit;
- break;
+ case SVM_EXIT_DR7_READ:
+ NaeExit = Dr7ReadExit;
+ break;
- case SVM_EXIT_DR7_WRITE:
- NaeExit = Dr7WriteExit;
- break;
+ case SVM_EXIT_DR7_WRITE:
+ NaeExit = Dr7WriteExit;
+ break;
- case SVM_EXIT_RDTSC:
- NaeExit = RdtscExit;
- break;
+ case SVM_EXIT_RDTSC:
+ NaeExit = RdtscExit;
+ break;
- case SVM_EXIT_RDPMC:
- NaeExit = RdpmcExit;
- break;
+ case SVM_EXIT_RDPMC:
+ NaeExit = RdpmcExit;
+ break;
- case SVM_EXIT_CPUID:
- NaeExit = CpuidExit;
- break;
+ case SVM_EXIT_CPUID:
+ NaeExit = CpuidExit;
+ break;
- case SVM_EXIT_INVD:
- NaeExit = InvdExit;
- break;
+ case SVM_EXIT_INVD:
+ NaeExit = InvdExit;
+ break;
- case SVM_EXIT_IOIO_PROT:
- NaeExit = IoioExit;
- break;
+ case SVM_EXIT_IOIO_PROT:
+ NaeExit = IoioExit;
+ break;
- case SVM_EXIT_MSR:
- NaeExit = MsrExit;
- break;
+ case SVM_EXIT_MSR:
+ NaeExit = MsrExit;
+ break;
- case SVM_EXIT_VMMCALL:
- NaeExit = VmmCallExit;
- break;
+ case SVM_EXIT_VMMCALL:
+ NaeExit = VmmCallExit;
+ break;
- case SVM_EXIT_RDTSCP:
- NaeExit = RdtscpExit;
- break;
+ case SVM_EXIT_RDTSCP:
+ NaeExit = RdtscpExit;
+ break;
- case SVM_EXIT_WBINVD:
- NaeExit = WbinvdExit;
- break;
+ case SVM_EXIT_WBINVD:
+ NaeExit = WbinvdExit;
+ break;
- case SVM_EXIT_MONITOR:
- NaeExit = MonitorExit;
- break;
+ case SVM_EXIT_MONITOR:
+ NaeExit = MonitorExit;
+ break;
- case SVM_EXIT_MWAIT:
- NaeExit = MwaitExit;
- break;
+ case SVM_EXIT_MWAIT:
+ NaeExit = MwaitExit;
+ break;
- case SVM_EXIT_NPF:
- NaeExit = MmioExit;
- break;
+ case SVM_EXIT_NPF:
+ NaeExit = MmioExit;
+ break;
- default:
- NaeExit = UnsupportedExit;
+ default:
+ NaeExit = UnsupportedExit;
}
InitInstructionData (&InstructionData, Ghcb, Regs);
diff --git a/OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c b/OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c
index 9f30df2973..248a03e8db 100644
--- a/OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c
+++ b/OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c
@@ -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));
+ 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;
+
+ 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);
diff --git a/OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.c b/OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.c
index 895dfc02f9..b29ed3e58e 100644
--- a/OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.c
+++ b/OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.c
@@ -36,8 +36,8 @@
// in general, it is actually fine for the Xen domU (guest) environment that
// this module is intended for, as UEFI always executes from DRAM in that case.
//
-STATIC evtchn_send_t mXenConsoleEventChain;
-STATIC struct xencons_interface *mXenConsoleInterface;
+STATIC evtchn_send_t mXenConsoleEventChain;
+STATIC struct xencons_interface *mXenConsoleInterface;
/**
Initialize the serial device hardware.
@@ -56,19 +56,20 @@ SerialPortInitialize (
VOID
)
{
- if (! XenHypercallIsAvailable ()) {
+ if (!XenHypercallIsAvailable ()) {
return RETURN_DEVICE_ERROR;
}
if (!mXenConsoleInterface) {
mXenConsoleEventChain.port = (UINT32)XenHypercallHvmGetParam (HVM_PARAM_CONSOLE_EVTCHN);
- mXenConsoleInterface = (struct xencons_interface *)(UINTN)
- (XenHypercallHvmGetParam (HVM_PARAM_CONSOLE_PFN) << EFI_PAGE_SHIFT);
+ mXenConsoleInterface = (struct xencons_interface *)(UINTN)
+ (XenHypercallHvmGetParam (HVM_PARAM_CONSOLE_PFN) << EFI_PAGE_SHIFT);
//
// No point in ASSERT'ing here as we won't be seeing the output
//
}
+
return RETURN_SUCCESS;
}
@@ -92,8 +93,8 @@ SerialPortInitialize (
UINTN
EFIAPI
SerialPortWrite (
- IN UINT8 *Buffer,
- IN UINTN NumberOfBytes
+ IN UINT8 *Buffer,
+ IN UINTN NumberOfBytes
)
{
XENCONS_RING_IDX Consumer, Producer;
@@ -116,15 +117,15 @@ SerialPortWrite (
MemoryFence ();
- while (Sent < NumberOfBytes && ((Producer - Consumer) < sizeof (mXenConsoleInterface->out)))
- mXenConsoleInterface->out[MASK_XENCONS_IDX(Producer++, mXenConsoleInterface->out)] = Buffer[Sent++];
+ while (Sent < NumberOfBytes && ((Producer - Consumer) < sizeof (mXenConsoleInterface->out))) {
+ mXenConsoleInterface->out[MASK_XENCONS_IDX (Producer++, mXenConsoleInterface->out)] = Buffer[Sent++];
+ }
MemoryFence ();
mXenConsoleInterface->out_prod = Producer;
XenHypercallEventChannelOp (EVTCHNOP_send, &mXenConsoleEventChain);
-
} while (Sent < NumberOfBytes);
return Sent;
@@ -148,9 +149,9 @@ SerialPortWrite (
UINTN
EFIAPI
SerialPortRead (
- OUT UINT8 *Buffer,
- IN UINTN NumberOfBytes
-)
+ OUT UINT8 *Buffer,
+ IN UINTN NumberOfBytes
+ )
{
XENCONS_RING_IDX Consumer, Producer;
UINTN Received;
@@ -171,8 +172,9 @@ SerialPortRead (
MemoryFence ();
Received = 0;
- while (Received < NumberOfBytes && Consumer < Producer)
- Buffer[Received++] = mXenConsoleInterface->in[MASK_XENCONS_IDX(Consumer++, mXenConsoleInterface->in)];
+ while (Received < NumberOfBytes && Consumer < Producer) {
+ Buffer[Received++] = mXenConsoleInterface->in[MASK_XENCONS_IDX (Consumer++, mXenConsoleInterface->in)];
+ }
MemoryFence ();
@@ -197,7 +199,7 @@ SerialPortPoll (
)
{
return mXenConsoleInterface &&
- mXenConsoleInterface->in_cons != mXenConsoleInterface->in_prod;
+ mXenConsoleInterface->in_cons != mXenConsoleInterface->in_prod;
}
/**
@@ -213,7 +215,7 @@ SerialPortPoll (
RETURN_STATUS
EFIAPI
SerialPortSetControl (
- IN UINT32 Control
+ IN UINT32 Control
)
{
return RETURN_UNSUPPORTED;
@@ -232,7 +234,7 @@ SerialPortSetControl (
RETURN_STATUS
EFIAPI
SerialPortGetControl (
- OUT UINT32 *Control
+ OUT UINT32 *Control
)
{
if (!mXenConsoleInterface) {
@@ -243,6 +245,7 @@ SerialPortGetControl (
if (!SerialPortPoll ()) {
*Control = EFI_SERIAL_INPUT_BUFFER_EMPTY;
}
+
return RETURN_SUCCESS;
}
@@ -282,14 +285,13 @@ SerialPortGetControl (
RETURN_STATUS
EFIAPI
SerialPortSetAttributes (
- IN OUT UINT64 *BaudRate,
- IN OUT UINT32 *ReceiveFifoDepth,
- IN OUT UINT32 *Timeout,
- IN OUT EFI_PARITY_TYPE *Parity,
- IN OUT UINT8 *DataBits,
- IN OUT EFI_STOP_BITS_TYPE *StopBits
+ IN OUT UINT64 *BaudRate,
+ IN OUT UINT32 *ReceiveFifoDepth,
+ IN OUT UINT32 *Timeout,
+ IN OUT EFI_PARITY_TYPE *Parity,
+ IN OUT UINT8 *DataBits,
+ IN OUT EFI_STOP_BITS_TYPE *StopBits
)
{
return RETURN_UNSUPPORTED;
}
-
diff --git a/OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c b/OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c
index f779e46470..dcc6575250 100644
--- a/OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c
+++ b/OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c
@@ -11,7 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/DebugLib.h>
#include <Guid/XenInfo.h>
-STATIC VOID *HyperPage;
+STATIC VOID *HyperPage;
/**
Check if the Xen Hypercall library is able to make calls to the Xen
@@ -38,30 +38,30 @@ XenHypercallIsAvailable (
INTN
EFIAPI
__XenHypercall2 (
- IN VOID *HypercallAddr,
- IN OUT INTN Arg1,
- IN OUT INTN Arg2
+ IN VOID *HypercallAddr,
+ IN OUT INTN Arg1,
+ IN OUT INTN Arg2
);
/**
Library constructor: retrieves the Hyperpage address
from the gEfiXenInfoGuid HOB
**/
-
RETURN_STATUS
EFIAPI
XenHypercallLibInit (
VOID
)
{
- EFI_HOB_GUID_TYPE *GuidHob;
- EFI_XEN_INFO *XenInfo;
+ EFI_HOB_GUID_TYPE *GuidHob;
+ EFI_XEN_INFO *XenInfo;
GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid);
if (GuidHob == NULL) {
return RETURN_NOT_FOUND;
}
- XenInfo = (EFI_XEN_INFO *) GET_GUID_HOB_DATA (GuidHob);
+
+ XenInfo = (EFI_XEN_INFO *)GET_GUID_HOB_DATA (GuidHob);
HyperPage = XenInfo->HyperPages;
return RETURN_SUCCESS;
}
@@ -86,5 +86,5 @@ XenHypercall2 (
{
ASSERT (HyperPage != NULL);
- return __XenHypercall2 ((UINT8*)HyperPage + HypercallID * 32, Arg1, Arg2);
+ return __XenHypercall2 ((UINT8 *)HyperPage + HypercallID * 32, Arg1, Arg2);
}
diff --git a/OvmfPkg/Library/XenHypercallLib/XenHypercall.c b/OvmfPkg/Library/XenHypercallLib/XenHypercall.c
index 265aa766d0..65b14a11f4 100644
--- a/OvmfPkg/Library/XenHypercallLib/XenHypercall.c
+++ b/OvmfPkg/Library/XenHypercallLib/XenHypercall.c
@@ -34,43 +34,56 @@ XenHypercallLibConstruct (
UINT64
EFIAPI
XenHypercallHvmGetParam (
- IN UINT32 Index
+ IN UINT32 Index
)
{
- xen_hvm_param_t Parameter;
- INTN Error;
+ xen_hvm_param_t Parameter;
+ INTN Error;
Parameter.domid = DOMID_SELF;
Parameter.index = Index;
- Error = XenHypercall2 (__HYPERVISOR_hvm_op,
- HVMOP_get_param, (INTN) &Parameter);
+ Error = XenHypercall2 (
+ __HYPERVISOR_hvm_op,
+ HVMOP_get_param,
+ (INTN)&Parameter
+ );
if (Error != 0) {
- DEBUG ((DEBUG_ERROR,
- "XenHypercall: Error %Ld trying to get HVM parameter %d\n",
- (INT64)Error, Index));
+ DEBUG ((
+ DEBUG_ERROR,
+ "XenHypercall: Error %Ld trying to get HVM parameter %d\n",
+ (INT64)Error,
+ Index
+ ));
return 0;
}
+
return Parameter.value;
}
INTN
EFIAPI
XenHypercallMemoryOp (
- IN UINTN Operation,
- IN OUT VOID *Arguments
+ IN UINTN Operation,
+ IN OUT VOID *Arguments
)
{
- return XenHypercall2 (__HYPERVISOR_memory_op,
- Operation, (INTN) Arguments);
+ return XenHypercall2 (
+ __HYPERVISOR_memory_op,
+ Operation,
+ (INTN)Arguments
+ );
}
INTN
EFIAPI
XenHypercallEventChannelOp (
- IN INTN Operation,
- IN OUT VOID *Arguments
+ IN INTN Operation,
+ IN OUT VOID *Arguments
)
{
- return XenHypercall2 (__HYPERVISOR_event_channel_op,
- Operation, (INTN) Arguments);
+ return XenHypercall2 (
+ __HYPERVISOR_event_channel_op,
+ Operation,
+ (INTN)Arguments
+ );
}
diff --git a/OvmfPkg/Library/XenIoMmioLib/XenIoMmioLib.c b/OvmfPkg/Library/XenIoMmioLib/XenIoMmioLib.c
index ae4ea0309a..caf4a28e1f 100644
--- a/OvmfPkg/Library/XenIoMmioLib/XenIoMmioLib.c
+++ b/OvmfPkg/Library/XenIoMmioLib/XenIoMmioLib.c
@@ -21,13 +21,13 @@
#pragma pack (1)
typedef struct {
- VENDOR_DEVICE_PATH Vendor;
- EFI_PHYSICAL_ADDRESS GrantTableAddress;
- EFI_DEVICE_PATH_PROTOCOL End;
+ VENDOR_DEVICE_PATH Vendor;
+ EFI_PHYSICAL_ADDRESS GrantTableAddress;
+ EFI_DEVICE_PATH_PROTOCOL End;
} XENBUS_ROOT_DEVICE_PATH;
#pragma pack ()
-STATIC CONST XENBUS_ROOT_DEVICE_PATH mXenBusRootDevicePathTemplate = {
+STATIC CONST XENBUS_ROOT_DEVICE_PATH mXenBusRootDevicePathTemplate = {
{
{
HARDWARE_DEVICE_PATH,
@@ -40,7 +40,7 @@ STATIC CONST XENBUS_ROOT_DEVICE_PATH mXenBusRootDevicePathTemplate = {
{
END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
- { sizeof (EFI_DEVICE_PATH_PROTOCOL), 0 }
+ { sizeof (EFI_DEVICE_PATH_PROTOCOL), 0 }
}
};
@@ -66,14 +66,14 @@ STATIC CONST XENBUS_ROOT_DEVICE_PATH mXenBusRootDevicePathTemplate = {
**/
EFI_STATUS
XenIoMmioInstall (
- IN OUT EFI_HANDLE *Handle,
- IN EFI_PHYSICAL_ADDRESS GrantTableAddress
+ IN OUT EFI_HANDLE *Handle,
+ IN EFI_PHYSICAL_ADDRESS GrantTableAddress
)
{
- EFI_STATUS Status;
- XENIO_PROTOCOL *XenIo;
- XENBUS_ROOT_DEVICE_PATH *XenBusDevicePath;
- EFI_HANDLE OutHandle;
+ EFI_STATUS Status;
+ XENIO_PROTOCOL *XenIo;
+ XENBUS_ROOT_DEVICE_PATH *XenBusDevicePath;
+ EFI_HANDLE OutHandle;
ASSERT (Handle != NULL);
@@ -83,29 +83,42 @@ XenIoMmioInstall (
if (!XenIo) {
return EFI_OUT_OF_RESOURCES;
}
+
XenIo->GrantTableAddress = GrantTableAddress;
- XenBusDevicePath = AllocateCopyPool (sizeof *XenBusDevicePath,
- &mXenBusRootDevicePathTemplate);
+ XenBusDevicePath = AllocateCopyPool (
+ sizeof *XenBusDevicePath,
+ &mXenBusRootDevicePathTemplate
+ );
if (!XenBusDevicePath) {
DEBUG ((DEBUG_ERROR, "%a: Out of memory\n", __FUNCTION__));
Status = EFI_OUT_OF_RESOURCES;
goto FreeXenIo;
}
+
XenBusDevicePath->GrantTableAddress = GrantTableAddress;
- Status = gBS->InstallMultipleProtocolInterfaces (&OutHandle,
- &gEfiDevicePathProtocolGuid, XenBusDevicePath,
- &gXenIoProtocolGuid, XenIo,
- NULL);
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &OutHandle,
+ &gEfiDevicePathProtocolGuid,
+ XenBusDevicePath,
+ &gXenIoProtocolGuid,
+ XenIo,
+ NULL
+ );
if (!EFI_ERROR (Status)) {
*Handle = OutHandle;
return EFI_SUCCESS;
}
- DEBUG ((DEBUG_ERROR, "%a: Failed to install the EFI_DEVICE_PATH and "
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Failed to install the EFI_DEVICE_PATH and "
"XENIO_PROTOCOL protocols on handle %p (Status == %r)\n",
- __FUNCTION__, OutHandle, Status));
+ __FUNCTION__,
+ OutHandle,
+ Status
+ ));
FreePool (XenBusDevicePath);
@@ -129,25 +142,41 @@ FreeXenIo:
**/
EFI_STATUS
XenIoMmioUninstall (
- IN EFI_HANDLE Handle
+ IN EFI_HANDLE Handle
)
{
- EFI_STATUS Status;
- VOID *XenIo;
- VOID *XenBusDevicePath;
+ EFI_STATUS Status;
+ VOID *XenIo;
+ VOID *XenBusDevicePath;
XenBusDevicePath = NULL;
- gBS->OpenProtocol (Handle, &gEfiDevicePathProtocolGuid, &XenBusDevicePath,
- NULL, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+ gBS->OpenProtocol (
+ Handle,
+ &gEfiDevicePathProtocolGuid,
+ &XenBusDevicePath,
+ NULL,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
XenIo = NULL;
- gBS->OpenProtocol (Handle, &gXenIoProtocolGuid, &XenIo,
- NULL, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
-
- Status = gBS->UninstallMultipleProtocolInterfaces (Handle,
- &gEfiDevicePathProtocolGuid, XenBusDevicePath,
- &gXenIoProtocolGuid, XenIo,
- NULL);
+ gBS->OpenProtocol (
+ Handle,
+ &gXenIoProtocolGuid,
+ &XenIo,
+ NULL,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ Handle,
+ &gEfiDevicePathProtocolGuid,
+ XenBusDevicePath,
+ &gXenIoProtocolGuid,
+ XenIo,
+ NULL
+ );
if (EFI_ERROR (Status)) {
return Status;
diff --git a/OvmfPkg/Library/XenPlatformLib/XenPlatformLib.c b/OvmfPkg/Library/XenPlatformLib/XenPlatformLib.c
index 8f20ae2d45..f6b3e5ca70 100644
--- a/OvmfPkg/Library/XenPlatformLib/XenPlatformLib.c
+++ b/OvmfPkg/Library/XenPlatformLib/XenPlatformLib.c
@@ -25,9 +25,9 @@ XenGetInfoHOB (
VOID
)
{
- EFI_HOB_GUID_TYPE *GuidHob;
- STATIC BOOLEAN Cached = FALSE;
- STATIC EFI_XEN_INFO *XenInfo;
+ EFI_HOB_GUID_TYPE *GuidHob;
+ STATIC BOOLEAN Cached = FALSE;
+ STATIC EFI_XEN_INFO *XenInfo;
//
// Return the cached result for the benefit of XenDetected that can be
@@ -41,8 +41,9 @@ XenGetInfoHOB (
if (GuidHob == NULL) {
XenInfo = NULL;
} else {
- XenInfo = (EFI_XEN_INFO *) GET_GUID_HOB_DATA (GuidHob);
+ XenInfo = (EFI_XEN_INFO *)GET_GUID_HOB_DATA (GuidHob);
}
+
Cached = TRUE;
return XenInfo;
}
@@ -74,7 +75,7 @@ XenPvhDetected (
VOID
)
{
- EFI_XEN_INFO *XenInfo;
+ EFI_XEN_INFO *XenInfo;
XenInfo = XenGetInfoHOB ();
return (XenInfo != NULL && XenInfo->RsdpPvh != NULL);
diff --git a/OvmfPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.c b/OvmfPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.c
index 72e0aaa879..7f37710b96 100644
--- a/OvmfPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.c
+++ b/OvmfPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.c
@@ -22,22 +22,22 @@ EpochToEfiTime (
OUT EFI_TIME *Time
)
{
- UINTN a;
- UINTN b;
- UINTN c;
- UINTN d;
- UINTN g;
- UINTN j;
- UINTN m;
- UINTN y;
- UINTN da;
- UINTN db;
- UINTN dc;
- UINTN dg;
- UINTN hh;
- UINTN mm;
- UINTN ss;
- UINTN J;
+ UINTN a;
+ UINTN b;
+ UINTN c;
+ UINTN d;
+ UINTN g;
+ UINTN j;
+ UINTN m;
+ UINTN y;
+ UINTN da;
+ UINTN db;
+ UINTN dc;
+ UINTN dg;
+ UINTN hh;
+ UINTN mm;
+ UINTN ss;
+ UINTN J;
J = (EpochSeconds / 86400) + 2440588;
j = J + 32044;
@@ -60,14 +60,13 @@ EpochToEfiTime (
ss = EpochSeconds % 60;
a = (EpochSeconds - ss) / 60;
mm = a % 60;
- b = (a - mm) / 60;
+ b = (a - mm) / 60;
hh = b % 24;
- Time->Hour = (UINT8)hh;
- Time->Minute = (UINT8)mm;
- Time->Second = (UINT8)ss;
- Time->Nanosecond = 0;
-
+ Time->Hour = (UINT8)hh;
+ Time->Minute = (UINT8)mm;
+ Time->Second = (UINT8)ss;
+ Time->Nanosecond = 0;
}
/**
@@ -97,7 +96,7 @@ LibGetTime (
// as Xen's timekeeping uses a shared info page which cannot be shared
// between UEFI and the OS
//
- EpochToEfiTime(1421770011, Time);
+ EpochToEfiTime (1421770011, Time);
return EFI_SUCCESS;
}
@@ -115,13 +114,12 @@ LibGetTime (
EFI_STATUS
EFIAPI
LibSetTime (
- IN EFI_TIME *Time
+ IN EFI_TIME *Time
)
{
return EFI_DEVICE_ERROR;
}
-
/**
Returns the current wakeup alarm clock setting.
@@ -138,9 +136,9 @@ LibSetTime (
EFI_STATUS
EFIAPI
LibGetWakeupTime (
- OUT BOOLEAN *Enabled,
- OUT BOOLEAN *Pending,
- OUT EFI_TIME *Time
+ OUT BOOLEAN *Enabled,
+ OUT BOOLEAN *Pending,
+ OUT EFI_TIME *Time
)
{
return EFI_UNSUPPORTED;
@@ -162,8 +160,8 @@ LibGetWakeupTime (
EFI_STATUS
EFIAPI
LibSetWakeupTime (
- IN BOOLEAN Enabled,
- OUT EFI_TIME *Time
+ IN BOOLEAN Enabled,
+ OUT EFI_TIME *Time
)
{
return EFI_UNSUPPORTED;
@@ -182,8 +180,8 @@ LibSetWakeupTime (
EFI_STATUS
EFIAPI
LibRtcInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
return EFI_SUCCESS;