summaryrefslogtreecommitdiffstats
path: root/EmulatorPkg
diff options
context:
space:
mode:
authorMichael Kubacki <michael.kubacki@microsoft.com>2021-12-05 14:53:57 -0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2021-12-07 17:24:28 +0000
commita550d468a6ca577d9e9c57a0eafcf2fc9fbb8c97 (patch)
tree16ea0a059e01bb8af07f41dcea5996424c309a95 /EmulatorPkg
parente7108d0e9655b1795c94ac372b0449f28dd907df (diff)
downloadedk2-a550d468a6ca577d9e9c57a0eafcf2fc9fbb8c97.tar.gz
edk2-a550d468a6ca577d9e9c57a0eafcf2fc9fbb8c97.tar.bz2
edk2-a550d468a6ca577d9e9c57a0eafcf2fc9fbb8c97.zip
EmulatorPkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the EmulatorPkg 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: Ray Ni <ray.ni@intel.com>
Diffstat (limited to 'EmulatorPkg')
-rw-r--r--EmulatorPkg/Application/RedfishPlatformConfig/RedfishPlatformConfig.c62
-rw-r--r--EmulatorPkg/AutoScanPei/AutoScanPei.c33
-rw-r--r--EmulatorPkg/BootModePei/BootModePei.c17
-rw-r--r--EmulatorPkg/CpuRuntimeDxe/Cpu.c108
-rw-r--r--EmulatorPkg/CpuRuntimeDxe/CpuDriver.h119
-rw-r--r--EmulatorPkg/CpuRuntimeDxe/CpuIo.c77
-rw-r--r--EmulatorPkg/CpuRuntimeDxe/MpService.c280
-rw-r--r--EmulatorPkg/EmuBlockIoDxe/ComponentName.c57
-rw-r--r--EmulatorPkg/EmuBlockIoDxe/DriverConfiguration.c104
-rw-r--r--EmulatorPkg/EmuBlockIoDxe/DriverDiagnostics.c97
-rw-r--r--EmulatorPkg/EmuBlockIoDxe/EmuBlockIo.c196
-rw-r--r--EmulatorPkg/EmuBlockIoDxe/EmuBlockIo.h5
-rw-r--r--EmulatorPkg/EmuBusDriverDxe/ComponentName.c54
-rw-r--r--EmulatorPkg/EmuBusDriverDxe/EmuBusDriverDxe.c200
-rw-r--r--EmulatorPkg/EmuBusDriverDxe/EmuBusDriverDxe.h45
-rw-r--r--EmulatorPkg/EmuGopDxe/ComponentName.c36
-rw-r--r--EmulatorPkg/EmuGopDxe/Gop.h115
-rw-r--r--EmulatorPkg/EmuGopDxe/GopDriver.c123
-rw-r--r--EmulatorPkg/EmuGopDxe/GopInput.c181
-rw-r--r--EmulatorPkg/EmuGopDxe/GopScreen.c176
-rw-r--r--EmulatorPkg/EmuSimpleFileSystemDxe/ComponentName.c56
-rw-r--r--EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c246
-rw-r--r--EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.h33
-rw-r--r--EmulatorPkg/EmuSnpDxe/ComponentName.c32
-rw-r--r--EmulatorPkg/EmuSnpDxe/EmuSnpDxe.c310
-rw-r--r--EmulatorPkg/EmuSnpDxe/EmuSnpDxe.h166
-rw-r--r--EmulatorPkg/EmuThunkDxe/EmuThunk.c18
-rw-r--r--EmulatorPkg/FirmwareVolumePei/FirmwareVolumePei.c31
-rw-r--r--EmulatorPkg/FlashMapPei/FlashMapPei.c16
-rw-r--r--EmulatorPkg/FvbServicesRuntimeDxe/FWBlockService.c382
-rw-r--r--EmulatorPkg/FvbServicesRuntimeDxe/FvbInfo.c35
-rw-r--r--EmulatorPkg/FvbServicesRuntimeDxe/FwBlockService.h155
-rw-r--r--EmulatorPkg/Include/Guid/EmuPhysicalDisk.h2
-rw-r--r--EmulatorPkg/Include/Guid/EmuSystemConfig.h8
-rw-r--r--EmulatorPkg/Include/Guid/EmuVirtualDisk.h2
-rw-r--r--EmulatorPkg/Include/Library/EmuMagicPageLib.h8
-rw-r--r--EmulatorPkg/Include/Library/EmuThunkLib.h5
-rw-r--r--EmulatorPkg/Include/Library/KeyMapLib.h5
-rw-r--r--EmulatorPkg/Include/Library/PpiListLib.h2
-rw-r--r--EmulatorPkg/Include/Library/SmbiosLib.h38
-rw-r--r--EmulatorPkg/Include/Library/ThunkPpiList.h4
-rw-r--r--EmulatorPkg/Include/Library/ThunkProtocolList.h13
-rw-r--r--EmulatorPkg/Include/Ppi/EmuThunk.h23
-rw-r--r--EmulatorPkg/Include/Protocol/EmuBlockIo.h31
-rw-r--r--EmulatorPkg/Include/Protocol/EmuFileSystem.h45
-rw-r--r--EmulatorPkg/Include/Protocol/EmuGraphicsWindow.h45
-rw-r--r--EmulatorPkg/Include/Protocol/EmuIoThunk.h25
-rw-r--r--EmulatorPkg/Include/Protocol/EmuSnp.h36
-rw-r--r--EmulatorPkg/Include/Protocol/EmuThread.h49
-rw-r--r--EmulatorPkg/Include/Protocol/EmuThunk.h116
-rw-r--r--EmulatorPkg/Library/DevicePathTextLib/DevicePathTextLib.c51
-rw-r--r--EmulatorPkg/Library/DxeCoreTimerLib/DxeCoreTimerLib.c20
-rw-r--r--EmulatorPkg/Library/DxeEmuLib/DxeEmuLib.c10
-rw-r--r--EmulatorPkg/Library/DxeEmuPeCoffExtraActionLib/DxeEmuPeCoffExtraActionLib.c7
-rw-r--r--EmulatorPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.c31
-rw-r--r--EmulatorPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.c15
-rw-r--r--EmulatorPkg/Library/DxeTimerLib/DxeTimerLib.c41
-rw-r--r--EmulatorPkg/Library/GuardUefiMemoryAllocationLib/MemoryAllocationLib.c51
-rw-r--r--EmulatorPkg/Library/KeyMapLibNull/KeyMapLibNull.c5
-rw-r--r--EmulatorPkg/Library/PeiCoreServicesTablePointerLib/PeiServicesTablePointer.c8
-rw-r--r--EmulatorPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.c30
-rw-r--r--EmulatorPkg/Library/PeiEmuPeCoffGetEntryPointLib/PeiEmuPeCoffGetEntryPointLib.c135
-rw-r--r--EmulatorPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.c29
-rw-r--r--EmulatorPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c22
-rw-r--r--EmulatorPkg/Library/PeiServicesTablePointerLibMagicPage/PeiServicesTablePointer.c11
-rw-r--r--EmulatorPkg/Library/PeiTimerLib/PeiTimerLib.c67
-rw-r--r--EmulatorPkg/Library/PlatformBmLib/PlatformBm.c155
-rw-r--r--EmulatorPkg/Library/PlatformBmLib/PlatformBm.h23
-rw-r--r--EmulatorPkg/Library/PlatformBmLib/PlatformBmData.c29
-rw-r--r--EmulatorPkg/Library/PlatformBmLib/PlatformBmMemoryTest.c15
-rw-r--r--EmulatorPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCredentialLib.c46
-rw-r--r--EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c168
-rw-r--r--EmulatorPkg/Library/SecPeiServicesLib/FwVol.c157
-rw-r--r--EmulatorPkg/Library/SecPeiServicesLib/PeiServicesLib.c107
-rw-r--r--EmulatorPkg/Library/SecPpiListLib/PpiListLib.c1
-rw-r--r--EmulatorPkg/Library/SmbiosLib/SmbiosLib.c95
-rw-r--r--EmulatorPkg/Library/ThunkPpiList/ThunkPpiList.c21
-rw-r--r--EmulatorPkg/Library/ThunkProtocolList/ThunkProtocolList.c47
-rw-r--r--EmulatorPkg/PlatformSmbiosDxe/PlatformSmbiosDxe.c36
-rw-r--r--EmulatorPkg/PlatformSmbiosDxe/SmbiosTable.c226
-rw-r--r--EmulatorPkg/RealTimeClockRuntimeDxe/RealTimeClock.c75
-rw-r--r--EmulatorPkg/ResetRuntimeDxe/Reset.c14
-rw-r--r--EmulatorPkg/Sec/Ia32/TempRam.c21
-rw-r--r--EmulatorPkg/Sec/Sec.c25
-rw-r--r--EmulatorPkg/Sec/Sec.h12
-rw-r--r--EmulatorPkg/ThunkPpiToProtocolPei/ThunkPpiToProtocolPei.c17
-rw-r--r--EmulatorPkg/TimerDxe/Timer.c42
-rw-r--r--EmulatorPkg/TimerDxe/Timer.h13
-rw-r--r--EmulatorPkg/Unix/Host/BerkeleyPacketFilter.c261
-rw-r--r--EmulatorPkg/Unix/Host/BlockIo.c262
-rw-r--r--EmulatorPkg/Unix/Host/EmuThunk.c183
-rw-r--r--EmulatorPkg/Unix/Host/Gasket.h288
-rw-r--r--EmulatorPkg/Unix/Host/Host.c400
-rw-r--r--EmulatorPkg/Unix/Host/Host.h160
-rw-r--r--EmulatorPkg/Unix/Host/Ia32/SwitchStack.c12
-rw-r--r--EmulatorPkg/Unix/Host/LinuxPacketFilter.c142
-rw-r--r--EmulatorPkg/Unix/Host/MemoryAllocationLib.c14
-rw-r--r--EmulatorPkg/Unix/Host/PosixFileSystem.c637
-rw-r--r--EmulatorPkg/Unix/Host/Pthreads.c66
-rw-r--r--EmulatorPkg/Unix/Host/X11GraphicsWindow.c1076
-rw-r--r--EmulatorPkg/Win/Host/WinBlockIo.c224
-rw-r--r--EmulatorPkg/Win/Host/WinFileSystem.c983
-rw-r--r--EmulatorPkg/Win/Host/WinGop.h121
-rw-r--r--EmulatorPkg/Win/Host/WinGopInput.c132
-rw-r--r--EmulatorPkg/Win/Host/WinGopScreen.c705
-rw-r--r--EmulatorPkg/Win/Host/WinHost.c347
-rw-r--r--EmulatorPkg/Win/Host/WinHost.h64
-rw-r--r--EmulatorPkg/Win/Host/WinInclude.h13
-rw-r--r--EmulatorPkg/Win/Host/WinMemoryAllocationLib.c15
-rw-r--r--EmulatorPkg/Win/Host/WinPacketFilter.c349
-rw-r--r--EmulatorPkg/Win/Host/WinThunk.c245
111 files changed, 6212 insertions, 6387 deletions
diff --git a/EmulatorPkg/Application/RedfishPlatformConfig/RedfishPlatformConfig.c b/EmulatorPkg/Application/RedfishPlatformConfig/RedfishPlatformConfig.c
index 89d4c760a7..9253b2245f 100644
--- a/EmulatorPkg/Application/RedfishPlatformConfig/RedfishPlatformConfig.c
+++ b/EmulatorPkg/Application/RedfishPlatformConfig/RedfishPlatformConfig.c
@@ -17,8 +17,8 @@
#include <Library/UefiLib.h>
#include <Protocol/ShellParameters.h>
-UINTN Argc;
-CHAR16 **Argv;
+UINTN Argc;
+CHAR16 **Argv;
/**
@@ -31,15 +31,15 @@ GetArg (
VOID
)
{
- EFI_STATUS Status;
- EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters;
+ EFI_STATUS Status;
+ EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters;
Status = gBS->HandleProtocol (
gImageHandle,
&gEfiShellParametersProtocolGuid,
- (VOID**)&ShellParameters
+ (VOID **)&ShellParameters
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
return Status;
}
@@ -84,8 +84,8 @@ UefiMain (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
- RETURN_STATUS ReturnStatus;
+ EFI_STATUS Status;
+ RETURN_STATUS ReturnStatus;
UINT8 HostIpAssignmentType;
EFI_IPv4_ADDRESS HostIpAddress;
@@ -94,8 +94,8 @@ UefiMain (
EFI_IPv4_ADDRESS RedfishServiceIpMask;
UINTN RedfishServiceIpPort;
- Status = GetArg();
- if (EFI_ERROR(Status)) {
+ Status = GetArg ();
+ if (EFI_ERROR (Status)) {
return Status;
}
@@ -104,39 +104,41 @@ UefiMain (
// RedfishPlatformConfig.efi -s HostIpAddress HostIpMask RedfishServiceIpAddress RedfishServiceIpMask RedfishServiceIpPort
// RedfishPlatformConfig.efi -a RedfishServiceIpAddress RedfishServiceIpMask RedfishServiceIpPort
//
- if (Argc != 7 && Argc != 5) {
-
- PrintHelp();
+ if ((Argc != 7) && (Argc != 5)) {
+ PrintHelp ();
return EFI_UNSUPPORTED;
}
- if (StrCmp(Argv[1], L"-s") == 0) {
-
+ if (StrCmp (Argv[1], L"-s") == 0) {
HostIpAssignmentType = 1;
Status = NetLibStrToIp4 (Argv[2], &HostIpAddress);
if (EFI_ERROR (Status)) {
- PrintHelp();
+ PrintHelp ();
return Status;
}
+
Status = NetLibStrToIp4 (Argv[3], &HostIpMask);
if (EFI_ERROR (Status)) {
- PrintHelp();
+ PrintHelp ();
return Status;
}
+
Status = NetLibStrToIp4 (Argv[4], &RedfishServiceIpAddress);
if (EFI_ERROR (Status)) {
- PrintHelp();
+ PrintHelp ();
return Status;
}
+
Status = NetLibStrToIp4 (Argv[5], &RedfishServiceIpMask);
if (EFI_ERROR (Status)) {
- PrintHelp();
+ PrintHelp ();
return Status;
}
+
ReturnStatus = StrDecimalToUintnS (Argv[6], NULL, &RedfishServiceIpPort);
if (RETURN_ERROR (ReturnStatus)) {
- PrintHelp();
+ PrintHelp ();
return Status;
}
@@ -214,24 +216,24 @@ UefiMain (
Print (L"RedfishServiceIpMask: %s has been set Successfully!\n", Argv[5]);
Print (L"RedfishServiceIpPort: %s has been set Successfully!\n", Argv[6]);
Print (L"Please Restart!\n");
-
- } else if (StrCmp(Argv[1], L"-a") == 0) {
-
+ } else if (StrCmp (Argv[1], L"-a") == 0) {
HostIpAssignmentType = 3;
Status = NetLibStrToIp4 (Argv[2], &RedfishServiceIpAddress);
if (EFI_ERROR (Status)) {
- PrintHelp();
+ PrintHelp ();
return Status;
}
+
Status = NetLibStrToIp4 (Argv[3], &RedfishServiceIpMask);
if (EFI_ERROR (Status)) {
- PrintHelp();
+ PrintHelp ();
return Status;
}
+
ReturnStatus = StrDecimalToUintnS (Argv[4], NULL, &RedfishServiceIpPort);
if (RETURN_ERROR (ReturnStatus)) {
- PrintHelp();
+ PrintHelp ();
return Status;
}
@@ -285,12 +287,10 @@ UefiMain (
Print (L"RedfishServiceIpMask: %s has been set Successfully!\n", Argv[3]);
Print (L"RedfishServiceIpPort: %s has been set Successfully!\n", Argv[4]);
Print (L"Please Restart!\n");
- } else if (StrCmp(Argv[1], L"-h") == 0 || StrCmp(Argv[1], L"-help") == 0) {
-
- PrintHelp();
+ } else if ((StrCmp (Argv[1], L"-h") == 0) || (StrCmp (Argv[1], L"-help") == 0)) {
+ PrintHelp ();
} else {
-
- PrintHelp();
+ PrintHelp ();
return EFI_UNSUPPORTED;
}
diff --git a/EmulatorPkg/AutoScanPei/AutoScanPei.c b/EmulatorPkg/AutoScanPei/AutoScanPei.c
index eec04fc88d..b7085b2d07 100644
--- a/EmulatorPkg/AutoScanPei/AutoScanPei.c
+++ b/EmulatorPkg/AutoScanPei/AutoScanPei.c
@@ -21,9 +21,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
EFI_STATUS
EFIAPI
PeimInitializeAutoScanPei (
- IN EFI_PEI_FILE_HANDLE FileHandle,
- IN CONST EFI_PEI_SERVICES **PeiServices
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ IN CONST EFI_PEI_SERVICES **PeiServices
)
+
/*++
Routine Description:
@@ -38,14 +39,13 @@ Returns:
**/
{
- EFI_STATUS Status;
- EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;
- EMU_THUNK_PPI *Thunk;
- UINT64 MemorySize;
- EFI_PHYSICAL_ADDRESS MemoryBase;
- UINTN Index;
- EFI_RESOURCE_ATTRIBUTE_TYPE Attributes;
-
+ EFI_STATUS Status;
+ EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;
+ EMU_THUNK_PPI *Thunk;
+ UINT64 MemorySize;
+ EFI_PHYSICAL_ADDRESS MemoryBase;
+ UINTN Index;
+ EFI_RESOURCE_ATTRIBUTE_TYPE Attributes;
DEBUG ((DEBUG_ERROR, "Emu Autoscan PEIM Loaded\n"));
@@ -66,12 +66,12 @@ Returns:
if (!EFI_ERROR (Status)) {
Attributes =
(
- EFI_RESOURCE_ATTRIBUTE_PRESENT |
- EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
- EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
- EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
- EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
- EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE
+ EFI_RESOURCE_ATTRIBUTE_PRESENT |
+ EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
+ EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
+ EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
+ EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
+ EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE
);
if (Index == 0) {
@@ -91,6 +91,7 @@ Returns:
MemorySize
);
}
+
Index++;
} while (!EFI_ERROR (Status));
diff --git a/EmulatorPkg/BootModePei/BootModePei.c b/EmulatorPkg/BootModePei/BootModePei.c
index d523a5f873..4f6a3d1869 100644
--- a/EmulatorPkg/BootModePei/BootModePei.c
+++ b/EmulatorPkg/BootModePei/BootModePei.c
@@ -6,8 +6,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-
-
//
// The package level header files this module uses
//
@@ -16,7 +14,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/PcdLib.h>
#include <Library/PeiServicesLib.h>
-
//
// The protocols, PPI and GUID defintions for this module
//
@@ -28,7 +25,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/DebugLib.h>
#include <Library/PeimEntryPoint.h>
-
//
// Module globals
//
@@ -47,9 +43,10 @@ EFI_PEI_PPI_DESCRIPTOR mPpiListRecoveryBootMode = {
EFI_STATUS
EFIAPI
InitializeBootMode (
- IN EFI_PEI_FILE_HANDLE FileHandle,
- IN CONST EFI_PEI_SERVICES **PeiServices
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ IN CONST EFI_PEI_SERVICES **PeiServices
)
+
/*++
Routine Description:
@@ -66,14 +63,14 @@ Returns:
**/
{
- EFI_STATUS Status;
- EFI_BOOT_MODE BootMode;
+ EFI_STATUS Status;
+ EFI_BOOT_MODE BootMode;
DEBUG ((DEBUG_ERROR, "Emu Boot Mode PEIM Loaded\n"));
- BootMode = FixedPcdGet32 (PcdEmuBootMode);
+ BootMode = FixedPcdGet32 (PcdEmuBootMode);
- Status = PeiServicesSetBootMode (BootMode);
+ Status = PeiServicesSetBootMode (BootMode);
ASSERT_EFI_ERROR (Status);
Status = PeiServicesInstallPpi (&mPpiListBootMode);
diff --git a/EmulatorPkg/CpuRuntimeDxe/Cpu.c b/EmulatorPkg/CpuRuntimeDxe/Cpu.c
index 00e93016af..e00f6cf35f 100644
--- a/EmulatorPkg/CpuRuntimeDxe/Cpu.c
+++ b/EmulatorPkg/CpuRuntimeDxe/Cpu.c
@@ -11,7 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
UINT64 mTimerPeriod;
-CPU_ARCH_PROTOCOL_PRIVATE mCpuTemplate = {
+CPU_ARCH_PROTOCOL_PRIVATE mCpuTemplate = {
CPU_ARCH_PROT_PRIVATE_SIGNATURE,
NULL,
{
@@ -39,16 +39,16 @@ CPU_ARCH_PROTOCOL_PRIVATE mCpuTemplate = {
TRUE
};
-#define EFI_CPU_DATA_MAXIMUM_LENGTH 0x100
+#define EFI_CPU_DATA_MAXIMUM_LENGTH 0x100
-SMBIOS_TABLE_TYPE4 mCpuSmbiosType4 = {
- { EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION, sizeof (SMBIOS_TABLE_TYPE4), 0},
+SMBIOS_TABLE_TYPE4 mCpuSmbiosType4 = {
+ { EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION, sizeof (SMBIOS_TABLE_TYPE4), 0 },
1, // Socket String
ProcessorOther, // ProcessorType; ///< The enumeration value from PROCESSOR_TYPE_DATA.
ProcessorFamilyOther, // ProcessorFamily; ///< The enumeration value from PROCESSOR_FAMILY_DATA.
2, // ProcessorManufacture String;
{ // ProcessorId;
- { // PROCESSOR_SIGNATURE
+ { // PROCESSOR_SIGNATURE
0, // ProcessorSteppingId:4;
0, // ProcessorModel: 4;
0, // ProcessorFamily: 4;
@@ -58,7 +58,7 @@ SMBIOS_TABLE_TYPE4 mCpuSmbiosType4 = {
0, // ProcessorXFamily: 8;
0, // ProcessorReserved2: 4;
},
- { // PROCESSOR_FEATURE_FLAGS
+ { // PROCESSOR_FEATURE_FLAGS
0, // ProcessorFpu :1;
0, // ProcessorVme :1;
0, // ProcessorDe :1;
@@ -93,7 +93,7 @@ SMBIOS_TABLE_TYPE4 mCpuSmbiosType4 = {
}
},
3, // ProcessorVersion String;
- { // Voltage;
+ { // Voltage;
1, // ProcessorVoltageCapability5V :1;
1, // ProcessorVoltageCapability3_3V :1;
1, // ProcessorVoltageCapability2_9V :1;
@@ -119,7 +119,7 @@ SMBIOS_TABLE_TYPE4 mCpuSmbiosType4 = {
0, // ProcessorFamily2;
};
-CHAR8 *mCpuSmbiosType4Strings[] = {
+CHAR8 *mCpuSmbiosType4Strings[] = {
"Socket",
"http://www.tianocore.org/edk2/",
"Emulated Processor",
@@ -129,7 +129,6 @@ CHAR8 *mCpuSmbiosType4Strings[] = {
NULL
};
-
/**
Create SMBIOS record.
@@ -159,18 +158,18 @@ CHAR8 *mCpuSmbiosType4Strings[] = {
**/
EFI_STATUS
LogSmbiosData (
- IN EFI_SMBIOS_TABLE_HEADER *Template,
- IN CHAR8 **StringPack
+ IN EFI_SMBIOS_TABLE_HEADER *Template,
+ IN CHAR8 **StringPack
)
{
- EFI_STATUS Status;
- EFI_SMBIOS_PROTOCOL *Smbios;
- EFI_SMBIOS_HANDLE SmbiosHandle;
- EFI_SMBIOS_TABLE_HEADER *Record;
- UINTN Index;
- UINTN StringSize;
- UINTN Size;
- CHAR8 *Str;
+ EFI_STATUS Status;
+ EFI_SMBIOS_PROTOCOL *Smbios;
+ EFI_SMBIOS_HANDLE SmbiosHandle;
+ EFI_SMBIOS_TABLE_HEADER *Record;
+ UINTN Index;
+ UINTN StringSize;
+ UINTN Size;
+ CHAR8 *Str;
//
// Locate Smbios protocol.
@@ -188,12 +187,14 @@ LogSmbiosData (
} else {
for (Index = 0; StringPack[Index] != NULL; Index++) {
StringSize = AsciiStrSize (StringPack[Index]);
- Size += StringSize;
+ Size += StringSize;
}
+
if (StringPack[0] == NULL) {
// At least a double null is required
Size += 1;
}
+
// Don't forget the terminating double null
Size += 1;
}
@@ -203,6 +204,7 @@ LogSmbiosData (
if (Record == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
CopyMem (Record, Template, Template->Length);
// Append string pack
@@ -212,32 +214,30 @@ LogSmbiosData (
CopyMem (Str, StringPack[Index], StringSize);
Str += StringSize;
}
+
*Str = 0;
SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
- Status = Smbios->Add (
- Smbios,
- gImageHandle,
- &SmbiosHandle,
- Record
- );
+ Status = Smbios->Add (
+ Smbios,
+ gImageHandle,
+ &SmbiosHandle,
+ Record
+ );
ASSERT_EFI_ERROR (Status);
FreePool (Record);
return Status;
}
-
-
-
VOID
CpuUpdateSmbios (
IN UINTN MaxCpus
)
{
- mCpuSmbiosType4.CoreCount = (UINT8) MaxCpus;
- mCpuSmbiosType4.EnabledCoreCount = (UINT8) MaxCpus;
- mCpuSmbiosType4.ThreadCount = (UINT8) MaxCpus;
+ mCpuSmbiosType4.CoreCount = (UINT8)MaxCpus;
+ mCpuSmbiosType4.EnabledCoreCount = (UINT8)MaxCpus;
+ mCpuSmbiosType4.ThreadCount = (UINT8)MaxCpus;
//
// The value of 1234 is fake value for CPU frequency
//
@@ -245,7 +245,6 @@ CpuUpdateSmbios (
LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER *)&mCpuSmbiosType4, mCpuSmbiosType4Strings);
}
-
//
// Service routines for the driver
//
@@ -265,6 +264,7 @@ EmuFlushCpuDataCache (
//
return EFI_SUCCESS;
}
+
//
// Other flush types are not supported by Emu emulator
//
@@ -277,7 +277,7 @@ EmuEnableInterrupt (
IN EFI_CPU_ARCH_PROTOCOL *This
)
{
- CPU_ARCH_PROTOCOL_PRIVATE *Private;
+ CPU_ARCH_PROTOCOL_PRIVATE *Private;
Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);
Private->InterruptState = TRUE;
@@ -291,7 +291,7 @@ EmuDisableInterrupt (
IN EFI_CPU_ARCH_PROTOCOL *This
)
{
- CPU_ARCH_PROTOCOL_PRIVATE *Private;
+ CPU_ARCH_PROTOCOL_PRIVATE *Private;
Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);
Private->InterruptState = FALSE;
@@ -306,7 +306,7 @@ EmuGetInterruptState (
OUT BOOLEAN *State
)
{
- CPU_ARCH_PROTOCOL_PRIVATE *Private;
+ CPU_ARCH_PROTOCOL_PRIVATE *Private;
if (State == NULL) {
return EFI_INVALID_PARAMETER;
@@ -338,9 +338,10 @@ EmuRegisterInterruptHandler (
//
// Do parameter checking for EFI spec conformance
//
- if (InterruptType < 0 || InterruptType > 0xff) {
+ if ((InterruptType < 0) || (InterruptType > 0xff)) {
return EFI_UNSUPPORTED;
}
+
//
// Do nothing for Emu emulation
//
@@ -350,10 +351,10 @@ EmuRegisterInterruptHandler (
EFI_STATUS
EFIAPI
EmuGetTimerValue (
- IN EFI_CPU_ARCH_PROTOCOL *This,
- IN UINT32 TimerIndex,
- OUT UINT64 *TimerValue,
- OUT UINT64 *TimerPeriod OPTIONAL
+ IN EFI_CPU_ARCH_PROTOCOL *This,
+ IN UINT32 TimerIndex,
+ OUT UINT64 *TimerValue,
+ OUT UINT64 *TimerPeriod OPTIONAL
)
{
if (TimerValue == NULL) {
@@ -373,7 +374,6 @@ EmuGetTimerValue (
return EFI_SUCCESS;
}
-
EFI_STATUS
EFIAPI
EmuSetMemoryAttributes (
@@ -396,9 +396,6 @@ EmuSetMemoryAttributes (
return EFI_UNSUPPORTED;
}
-
-
-
/**
Callback function for idle events.
@@ -410,14 +407,13 @@ EmuSetMemoryAttributes (
VOID
EFIAPI
IdleLoopEventCallback (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
gEmuThunk->CpuSleep ();
}
-
EFI_STATUS
EFIAPI
InitializeCpu (
@@ -425,10 +421,10 @@ InitializeCpu (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
- UINT64 Frequency;
- EFI_EVENT IdleLoopEvent;
- UINTN MaxCpu;
+ EFI_STATUS Status;
+ UINT64 Frequency;
+ EFI_EVENT IdleLoopEvent;
+ UINTN MaxCpu;
//
// Retrieve the frequency of the performance counter in Hz.
@@ -444,7 +440,6 @@ InitializeCpu (
CpuUpdateSmbios (MaxCpu);
-
Status = gBS->CreateEventEx (
EVT_NOTIFY_SIGNAL,
TPL_NOTIFY,
@@ -455,11 +450,12 @@ InitializeCpu (
);
ASSERT_EFI_ERROR (Status);
-
Status = gBS->InstallMultipleProtocolInterfaces (
&mCpuTemplate.Handle,
- &gEfiCpuArchProtocolGuid, &mCpuTemplate.Cpu,
- &gEfiCpuIo2ProtocolGuid, &mCpuTemplate.CpuIo,
+ &gEfiCpuArchProtocolGuid,
+ &mCpuTemplate.Cpu,
+ &gEfiCpuIo2ProtocolGuid,
+ &mCpuTemplate.CpuIo,
NULL
);
ASSERT_EFI_ERROR (Status);
diff --git a/EmulatorPkg/CpuRuntimeDxe/CpuDriver.h b/EmulatorPkg/CpuRuntimeDxe/CpuDriver.h
index b191cbd048..cec82a1b6f 100644
--- a/EmulatorPkg/CpuRuntimeDxe/CpuDriver.h
+++ b/EmulatorPkg/CpuRuntimeDxe/CpuDriver.h
@@ -10,7 +10,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _CPU_ARCHITECTURAL_PROTOCOL_DRIVER_H_
#define _CPU_ARCHITECTURAL_PROTOCOL_DRIVER_H_
-
#include <PiDxe.h>
#include <IndustryStandard/SmBios.h>
@@ -32,25 +31,22 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/UefiLib.h>
#include <Library/PcdLib.h>
-
-
//
// Internal Data Structures
//
-#define CPU_ARCH_PROT_PRIVATE_SIGNATURE SIGNATURE_32 ('c', 'a', 'p', 'd')
+#define CPU_ARCH_PROT_PRIVATE_SIGNATURE SIGNATURE_32 ('c', 'a', 'p', 'd')
typedef struct {
- UINTN Signature;
- EFI_HANDLE Handle;
+ UINTN Signature;
+ EFI_HANDLE Handle;
- EFI_CPU_ARCH_PROTOCOL Cpu;
- EFI_CPU_IO2_PROTOCOL CpuIo;
+ EFI_CPU_ARCH_PROTOCOL Cpu;
+ EFI_CPU_IO2_PROTOCOL CpuIo;
//
// Local Data for CPU interface goes here
//
- BOOLEAN InterruptState;
-
+ BOOLEAN InterruptState;
} CPU_ARCH_PROTOCOL_PRIVATE;
#define CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS(a) \
@@ -60,8 +56,6 @@ typedef struct {
CPU_ARCH_PROT_PRIVATE_SIGNATURE \
)
-
-
typedef enum {
CPU_STATE_IDLE,
CPU_STATE_BLOCKED,
@@ -70,84 +64,78 @@ typedef enum {
CPU_STATE_FINISHED
} PROCESSOR_STATE;
-
//
// Define Individual Processor Data block.
//
typedef struct {
- EFI_PROCESSOR_INFORMATION Info;
- EFI_AP_PROCEDURE Procedure;
- VOID *Parameter;
- VOID *StateLock;
- VOID *ProcedureLock;
- PROCESSOR_STATE State;
- EFI_EVENT CheckThisAPEvent;
+ EFI_PROCESSOR_INFORMATION Info;
+ EFI_AP_PROCEDURE Procedure;
+ VOID *Parameter;
+ VOID *StateLock;
+ VOID *ProcedureLock;
+ PROCESSOR_STATE State;
+ EFI_EVENT CheckThisAPEvent;
} PROCESSOR_DATA_BLOCK;
-
//
// Define MP data block which consumes individual processor block.
//
typedef struct {
- UINTN NumberOfProcessors;
- UINTN NumberOfEnabledProcessors;
- EFI_EVENT CheckAllAPsEvent;
- EFI_EVENT WaitEvent;
- UINTN FinishCount;
- UINTN StartCount;
- EFI_AP_PROCEDURE Procedure;
- VOID *ProcedureArgument;
- BOOLEAN SingleThread;
- UINTN StartedNumber;
- PROCESSOR_DATA_BLOCK *ProcessorData;
- UINTN Timeout;
- UINTN *FailedList;
- UINTN FailedListIndex;
- BOOLEAN TimeoutActive;
+ UINTN NumberOfProcessors;
+ UINTN NumberOfEnabledProcessors;
+ EFI_EVENT CheckAllAPsEvent;
+ EFI_EVENT WaitEvent;
+ UINTN FinishCount;
+ UINTN StartCount;
+ EFI_AP_PROCEDURE Procedure;
+ VOID *ProcedureArgument;
+ BOOLEAN SingleThread;
+ UINTN StartedNumber;
+ PROCESSOR_DATA_BLOCK *ProcessorData;
+ UINTN Timeout;
+ UINTN *FailedList;
+ UINTN FailedListIndex;
+ BOOLEAN TimeoutActive;
} MP_SYSTEM_DATA;
-
-
-
-
EFI_STATUS
EFIAPI
CpuMemoryServiceRead (
- IN EFI_CPU_IO2_PROTOCOL *This,
- IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- IN OUT VOID *Buffer
+ IN EFI_CPU_IO2_PROTOCOL *This,
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
);
EFI_STATUS
EFIAPI
CpuMemoryServiceWrite (
- IN EFI_CPU_IO2_PROTOCOL *This,
- IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- IN OUT VOID *Buffer
+ IN EFI_CPU_IO2_PROTOCOL *This,
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
);
EFI_STATUS
EFIAPI
CpuIoServiceRead (
- IN EFI_CPU_IO2_PROTOCOL *This,
- IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
- IN UINT64 UserAddress,
- IN UINTN Count,
- IN OUT VOID *UserBuffer
+ IN EFI_CPU_IO2_PROTOCOL *This,
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 UserAddress,
+ IN UINTN Count,
+ IN OUT VOID *UserBuffer
);
EFI_STATUS
EFIAPI
CpuIoServiceWrite (
- IN EFI_CPU_IO2_PROTOCOL *This,
- IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
- IN UINT64 UserAddress,
- IN UINTN Count,
- IN OUT VOID *UserBuffer
+ IN EFI_CPU_IO2_PROTOCOL *This,
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 UserAddress,
+ IN UINTN Count,
+ IN OUT VOID *UserBuffer
);
EFI_STATUS
@@ -203,10 +191,10 @@ EmuRegisterInterruptHandler (
EFI_STATUS
EFIAPI
EmuGetTimerValue (
- IN EFI_CPU_ARCH_PROTOCOL *This,
- IN UINT32 TimerIndex,
- OUT UINT64 *TimerValue,
- OUT UINT64 *TimerPeriod OPTIONAL
+ IN EFI_CPU_ARCH_PROTOCOL *This,
+ IN UINT32 TimerIndex,
+ OUT UINT64 *TimerValue,
+ OUT UINT64 *TimerPeriod OPTIONAL
);
EFI_STATUS
@@ -220,7 +208,7 @@ EmuSetMemoryAttributes (
EFI_STATUS
CpuMpServicesInit (
- OUT UINTN *MaxCores
+ OUT UINTN *MaxCores
);
EFI_STATUS
@@ -232,5 +220,4 @@ CpuMpServicesWhoAmI (
extern EFI_MP_SERVICES_PROTOCOL mMpServicesTemplate;
-
#endif
diff --git a/EmulatorPkg/CpuRuntimeDxe/CpuIo.c b/EmulatorPkg/CpuRuntimeDxe/CpuIo.c
index 152c260451..417b225b7e 100644
--- a/EmulatorPkg/CpuRuntimeDxe/CpuIo.c
+++ b/EmulatorPkg/CpuRuntimeDxe/CpuIo.c
@@ -31,22 +31,23 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
EFI_STATUS
CpuIoCheckAddressRange (
- IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- IN VOID *Buffer,
- IN UINT64 Limit
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN VOID *Buffer,
+ IN UINT64 Limit
);
EFI_STATUS
EFIAPI
CpuMemoryServiceRead (
- IN EFI_CPU_IO2_PROTOCOL *This,
- IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- IN OUT VOID *Buffer
+ IN EFI_CPU_IO2_PROTOCOL *This,
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
)
+
/*++
Routine Description:
@@ -95,12 +96,13 @@ Returns:
EFI_STATUS
EFIAPI
CpuMemoryServiceWrite (
- IN EFI_CPU_IO2_PROTOCOL *This,
- IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- IN OUT VOID *Buffer
+ IN EFI_CPU_IO2_PROTOCOL *This,
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
)
+
/*++
Routine Description:
@@ -148,12 +150,13 @@ Returns:
EFI_STATUS
EFIAPI
CpuIoServiceRead (
- IN EFI_CPU_IO2_PROTOCOL *This,
- IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
- IN UINT64 UserAddress,
- IN UINTN Count,
- IN OUT VOID *UserBuffer
+ IN EFI_CPU_IO2_PROTOCOL *This,
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 UserAddress,
+ IN UINTN Count,
+ IN OUT VOID *UserBuffer
)
+
/*++
Routine Description:
@@ -186,7 +189,7 @@ Returns:
return EFI_INVALID_PARAMETER;
}
- Address = (UINTN) UserAddress;
+ Address = (UINTN)UserAddress;
if (Width >= EfiCpuIoWidthMaximum) {
return EFI_INVALID_PARAMETER;
@@ -206,12 +209,13 @@ Returns:
EFI_STATUS
EFIAPI
CpuIoServiceWrite (
- IN EFI_CPU_IO2_PROTOCOL *This,
- IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
- IN UINT64 UserAddress,
- IN UINTN Count,
- IN OUT VOID *UserBuffer
+ IN EFI_CPU_IO2_PROTOCOL *This,
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 UserAddress,
+ IN UINTN Count,
+ IN OUT VOID *UserBuffer
)
+
/*++
Routine Description:
@@ -248,7 +252,7 @@ Returns:
return EFI_INVALID_PARAMETER;
}
- Address = (UINTN) UserAddress;
+ Address = (UINTN)UserAddress;
if (Width >= EfiCpuIoWidthMaximum) {
return EFI_INVALID_PARAMETER;
@@ -265,7 +269,6 @@ Returns:
return EFI_SUCCESS;
}
-
/*++
Routine Description:
@@ -288,14 +291,14 @@ Returns:
**/
EFI_STATUS
CpuIoCheckAddressRange (
- IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- IN VOID *Buffer,
- IN UINT64 Limit
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN VOID *Buffer,
+ IN UINT64 Limit
)
{
- UINTN AlignMask;
+ UINTN AlignMask;
if (Address > Limit) {
return EFI_UNSUPPORTED;
@@ -304,7 +307,7 @@ CpuIoCheckAddressRange (
//
// For FiFo type, the target address won't increase during the access, so treat count as 1
//
- if (Width >= EfiCpuIoWidthFifoUint8 && Width <= EfiCpuIoWidthFifoUint64) {
+ if ((Width >= EfiCpuIoWidthFifoUint8) && (Width <= EfiCpuIoWidthFifoUint64)) {
Count = 1;
}
@@ -314,11 +317,9 @@ CpuIoCheckAddressRange (
}
AlignMask = (1 << Width) - 1;
- if ((UINTN) Buffer & AlignMask) {
+ if ((UINTN)Buffer & AlignMask) {
return EFI_UNSUPPORTED;
}
return EFI_SUCCESS;
}
-
-
diff --git a/EmulatorPkg/CpuRuntimeDxe/MpService.c b/EmulatorPkg/CpuRuntimeDxe/MpService.c
index 42f94ada27..122019f04e 100644
--- a/EmulatorPkg/CpuRuntimeDxe/MpService.c
+++ b/EmulatorPkg/CpuRuntimeDxe/MpService.c
@@ -37,13 +37,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "CpuDriver.h"
-
-MP_SYSTEM_DATA gMPSystem;
-EMU_THREAD_THUNK_PROTOCOL *gThread = NULL;
-EFI_EVENT gReadToBootEvent;
-BOOLEAN gReadToBoot = FALSE;
-UINTN gPollInterval;
-
+MP_SYSTEM_DATA gMPSystem;
+EMU_THREAD_THUNK_PROTOCOL *gThread = NULL;
+EFI_EVENT gReadToBootEvent;
+BOOLEAN gReadToBoot = FALSE;
+UINTN gPollInterval;
BOOLEAN
IsBSP (
@@ -61,7 +59,6 @@ IsBSP (
return (gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag & PROCESSOR_AS_BSP_BIT) != 0;
}
-
VOID
SetApProcedure (
IN PROCESSOR_DATA_BLOCK *Processor,
@@ -70,15 +67,14 @@ SetApProcedure (
)
{
gThread->MutexLock (Processor->ProcedureLock);
- Processor->Parameter = ProcedureArgument;
- Processor->Procedure = Procedure;
+ Processor->Parameter = ProcedureArgument;
+ Processor->Procedure = Procedure;
gThread->MutexUnlock (Processor->ProcedureLock);
}
-
EFI_STATUS
GetNextBlockedNumber (
- OUT UINTN *NextNumber
+ OUT UINTN *NextNumber
)
{
UINTN Number;
@@ -116,16 +112,17 @@ GetNextBlockedNumber (
**/
UINTN
CalculateAndStallInterval (
- IN UINTN Timeout
+ IN UINTN Timeout
)
{
- UINTN StallTime;
+ UINTN StallTime;
- if (Timeout < gPollInterval && Timeout != 0) {
+ if ((Timeout < gPollInterval) && (Timeout != 0)) {
StallTime = Timeout;
} else {
StallTime = gPollInterval;
}
+
gBS->Stall (StallTime);
return StallTime;
@@ -188,8 +185,6 @@ CpuMpServicesGetNumberOfProcessors (
return EFI_SUCCESS;
}
-
-
/**
Gets detailed MP-related information on the requested processor at the
instant this call is made. This service may only be called from the BSP.
@@ -240,7 +235,6 @@ CpuMpServicesGetProcessorInfo (
return EFI_SUCCESS;
}
-
/**
This service executes a caller provided function on all enabled APs. APs can
run either simultaneously or one at a time in sequence. This service supports
@@ -397,7 +391,6 @@ CpuMpServicesStartupAllAps (
PROCESSOR_STATE ProcessorState;
UINTN Timeout;
-
if (!IsBSP ()) {
return EFI_DEVICE_ERROR;
}
@@ -425,12 +418,14 @@ CpuMpServicesStartupAllAps (
// Skip Disabled processors
continue;
}
- gThread->MutexLock(ProcessorData->StateLock);
+
+ gThread->MutexLock (ProcessorData->StateLock);
if (ProcessorData->State != CPU_STATE_IDLE) {
gThread->MutexUnlock (ProcessorData->StateLock);
return EFI_NOT_READY;
}
- gThread->MutexUnlock(ProcessorData->StateLock);
+
+ gThread->MutexUnlock (ProcessorData->StateLock);
}
if (FailedCpuList != NULL) {
@@ -438,19 +433,20 @@ CpuMpServicesStartupAllAps (
if (gMPSystem.FailedList == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
SetMemN (gMPSystem.FailedList, (gMPSystem.NumberOfProcessors + 1) * sizeof (UINTN), END_OF_CPU_LIST);
gMPSystem.FailedListIndex = 0;
- *FailedCpuList = gMPSystem.FailedList;
+ *FailedCpuList = gMPSystem.FailedList;
}
Timeout = TimeoutInMicroseconds;
- ProcessorData = NULL;
+ ProcessorData = NULL;
- gMPSystem.FinishCount = 0;
- gMPSystem.StartCount = 0;
- gMPSystem.SingleThread = SingleThread;
- APInitialState = CPU_STATE_READY;
+ gMPSystem.FinishCount = 0;
+ gMPSystem.StartCount = 0;
+ gMPSystem.SingleThread = SingleThread;
+ APInitialState = CPU_STATE_READY;
for (Number = 0; Number < gMPSystem.NumberOfProcessors; Number++) {
ProcessorData = &gMPSystem.ProcessorData[Number];
@@ -472,7 +468,7 @@ CpuMpServicesStartupAllAps (
// state 1 by 1, until the previous 1 finished its task
// if not "SingleThread", all APs are put to ready state from the beginning
//
- gThread->MutexLock(ProcessorData->StateLock);
+ gThread->MutexLock (ProcessorData->StateLock);
ASSERT (ProcessorData->State == CPU_STATE_IDLE);
ProcessorData->State = APInitialState;
gThread->MutexUnlock (ProcessorData->StateLock);
@@ -487,7 +483,7 @@ CpuMpServicesStartupAllAps (
for (Number = 0; Number < gMPSystem.NumberOfProcessors; Number++) {
ProcessorData = &gMPSystem.ProcessorData[Number];
if ((ProcessorData->Info.StatusFlag & PROCESSOR_AS_BSP_BIT) == PROCESSOR_AS_BSP_BIT) {
- // Skip BSP
+ // Skip BSP
continue;
}
@@ -513,20 +509,19 @@ CpuMpServicesStartupAllAps (
gMPSystem.WaitEvent = WaitEvent;
gMPSystem.Timeout = TimeoutInMicroseconds;
gMPSystem.TimeoutActive = (BOOLEAN)(TimeoutInMicroseconds != 0);
- Status = gBS->SetTimer (
- gMPSystem.CheckAllAPsEvent,
- TimerPeriodic,
- gPollInterval
- );
+ Status = gBS->SetTimer (
+ gMPSystem.CheckAllAPsEvent,
+ TimerPeriodic,
+ gPollInterval
+ );
return Status;
-
}
while (TRUE) {
for (Number = 0; Number < gMPSystem.NumberOfProcessors; Number++) {
ProcessorData = &gMPSystem.ProcessorData[Number];
if ((ProcessorData->Info.StatusFlag & PROCESSOR_AS_BSP_BIT) == PROCESSOR_AS_BSP_BIT) {
- // Skip BSP
+ // Skip BSP
continue;
}
@@ -540,29 +535,29 @@ CpuMpServicesStartupAllAps (
gThread->MutexUnlock (ProcessorData->StateLock);
switch (ProcessorState) {
- case CPU_STATE_READY:
- SetApProcedure (ProcessorData, Procedure, ProcedureArgument);
- break;
-
- case CPU_STATE_FINISHED:
- gMPSystem.FinishCount++;
- if (SingleThread) {
- Status = GetNextBlockedNumber (&NextNumber);
- if (!EFI_ERROR (Status)) {
- gThread->MutexLock (gMPSystem.ProcessorData[NextNumber].StateLock);
- gMPSystem.ProcessorData[NextNumber].State = CPU_STATE_READY;
- gThread->MutexUnlock (gMPSystem.ProcessorData[NextNumber].StateLock);
+ case CPU_STATE_READY:
+ SetApProcedure (ProcessorData, Procedure, ProcedureArgument);
+ break;
+
+ case CPU_STATE_FINISHED:
+ gMPSystem.FinishCount++;
+ if (SingleThread) {
+ Status = GetNextBlockedNumber (&NextNumber);
+ if (!EFI_ERROR (Status)) {
+ gThread->MutexLock (gMPSystem.ProcessorData[NextNumber].StateLock);
+ gMPSystem.ProcessorData[NextNumber].State = CPU_STATE_READY;
+ gThread->MutexUnlock (gMPSystem.ProcessorData[NextNumber].StateLock);
+ }
}
- }
- gThread->MutexLock (ProcessorData->StateLock);
- ProcessorData->State = CPU_STATE_IDLE;
- gThread->MutexUnlock (ProcessorData->StateLock);
+ gThread->MutexLock (ProcessorData->StateLock);
+ ProcessorData->State = CPU_STATE_IDLE;
+ gThread->MutexUnlock (ProcessorData->StateLock);
- break;
+ break;
- default:
- break;
+ default:
+ break;
}
}
@@ -590,7 +585,6 @@ Done:
return EFI_SUCCESS;
}
-
/**
This service lets the caller get one enabled AP to execute a caller-provided
function. The caller can request the BSP to either wait for the completion
@@ -689,7 +683,7 @@ CpuMpServicesStartupThisAP (
OUT BOOLEAN *Finished OPTIONAL
)
{
- UINTN Timeout;
+ UINTN Timeout;
if (!IsBSP ()) {
return EFI_DEVICE_ERROR;
@@ -711,12 +705,13 @@ CpuMpServicesStartupThisAP (
return EFI_INVALID_PARAMETER;
}
- gThread->MutexLock(gMPSystem.ProcessorData[ProcessorNumber].StateLock);
+ gThread->MutexLock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);
if (gMPSystem.ProcessorData[ProcessorNumber].State != CPU_STATE_IDLE) {
- gThread->MutexUnlock(gMPSystem.ProcessorData[ProcessorNumber].StateLock);
+ gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);
return EFI_NOT_READY;
}
- gThread->MutexUnlock(gMPSystem.ProcessorData[ProcessorNumber].StateLock);
+
+ gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);
if ((WaitEvent != NULL) && gReadToBoot) {
return EFI_UNSUPPORTED;
@@ -724,8 +719,8 @@ CpuMpServicesStartupThisAP (
Timeout = TimeoutInMicroseconds;
- gMPSystem.StartCount = 1;
- gMPSystem.FinishCount = 0;
+ gMPSystem.StartCount = 1;
+ gMPSystem.FinishCount = 0;
SetApProcedure (&gMPSystem.ProcessorData[ProcessorNumber], Procedure, ProcedureArgument);
@@ -759,10 +754,8 @@ CpuMpServicesStartupThisAP (
}
return EFI_SUCCESS;
-
}
-
/**
This service switches the requested AP to be the BSP from that point onward.
This service changes the BSP for all purposes. This call can only be performed
@@ -806,7 +799,7 @@ CpuMpServicesSwitchBSP (
IN BOOLEAN EnableOldBSP
)
{
- UINTN Index;
+ UINTN Index;
if (!IsBSP ()) {
return EFI_DEVICE_ERROR;
@@ -829,6 +822,7 @@ CpuMpServicesSwitchBSP (
break;
}
}
+
ASSERT (Index != gMPSystem.NumberOfProcessors);
gThread->MutexLock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);
@@ -836,6 +830,7 @@ CpuMpServicesSwitchBSP (
gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);
return EFI_NOT_READY;
}
+
gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);
// Skip for now as we need switch a bunch of stack stuff around and it's complex
@@ -843,7 +838,6 @@ CpuMpServicesSwitchBSP (
return EFI_NOT_READY;
}
-
/**
This service lets the caller enable or disable an AP from this point onward.
This service may only be called from the BSP.
@@ -911,17 +905,20 @@ CpuMpServicesEnableDisableAP (
gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);
return EFI_UNSUPPORTED;
}
+
gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);
if (EnableAP) {
if ((gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag & PROCESSOR_ENABLED_BIT) == 0 ) {
gMPSystem.NumberOfEnabledProcessors++;
}
+
gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag |= PROCESSOR_ENABLED_BIT;
} else {
if ((gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag & PROCESSOR_ENABLED_BIT) == PROCESSOR_ENABLED_BIT ) {
gMPSystem.NumberOfEnabledProcessors--;
}
+
gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag &= ~PROCESSOR_ENABLED_BIT;
}
@@ -933,7 +930,6 @@ CpuMpServicesEnableDisableAP (
return EFI_SUCCESS;
}
-
/**
This return the handle number for the calling processor. This service may be
called from the BSP and APs.
@@ -983,8 +979,6 @@ CpuMpServicesWhoAmI (
return EFI_SUCCESS;
}
-
-
EFI_MP_SERVICES_PROTOCOL mMpServicesTemplate = {
CpuMpServicesGetNumberOfProcessors,
CpuMpServicesGetProcessorInfo,
@@ -995,8 +989,6 @@ EFI_MP_SERVICES_PROTOCOL mMpServicesTemplate = {
CpuMpServicesWhoAmI
};
-
-
/*++
If timeout occurs in StartupAllAps(), a timer is set, which invokes this
procedure periodically to check whether all APs have finished.
@@ -1006,8 +998,8 @@ EFI_MP_SERVICES_PROTOCOL mMpServicesTemplate = {
VOID
EFIAPI
CpuCheckAllAPsStatus (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
UINTN ProcessorNumber;
@@ -1026,7 +1018,7 @@ CpuCheckAllAPsStatus (
for (ProcessorNumber = 0; ProcessorNumber < gMPSystem.NumberOfProcessors; ProcessorNumber++) {
ProcessorData = &gMPSystem.ProcessorData[ProcessorNumber];
if ((ProcessorData->Info.StatusFlag & PROCESSOR_AS_BSP_BIT) == PROCESSOR_AS_BSP_BIT) {
- // Skip BSP
+ // Skip BSP
continue;
}
@@ -1041,39 +1033,40 @@ CpuCheckAllAPsStatus (
// So, try lock it. If we can get it, cool, do our thing.
// otherwise, just dump out & try again on the next iteration.
Status = gThread->MutexTryLock (ProcessorData->StateLock);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
return;
}
+
ProcessorState = ProcessorData->State;
gThread->MutexUnlock (ProcessorData->StateLock);
switch (ProcessorState) {
- case CPU_STATE_FINISHED:
- if (gMPSystem.SingleThread) {
- Status = GetNextBlockedNumber (&NextNumber);
- if (!EFI_ERROR (Status)) {
- NextData = &gMPSystem.ProcessorData[NextNumber];
+ case CPU_STATE_FINISHED:
+ if (gMPSystem.SingleThread) {
+ Status = GetNextBlockedNumber (&NextNumber);
+ if (!EFI_ERROR (Status)) {
+ NextData = &gMPSystem.ProcessorData[NextNumber];
- gThread->MutexLock (NextData->StateLock);
- NextData->State = CPU_STATE_READY;
- gThread->MutexUnlock (NextData->StateLock);
+ gThread->MutexLock (NextData->StateLock);
+ NextData->State = CPU_STATE_READY;
+ gThread->MutexUnlock (NextData->StateLock);
- SetApProcedure (NextData, gMPSystem.Procedure, gMPSystem.ProcedureArgument);
+ SetApProcedure (NextData, gMPSystem.Procedure, gMPSystem.ProcedureArgument);
+ }
}
- }
- gThread->MutexLock (ProcessorData->StateLock);
- ProcessorData->State = CPU_STATE_IDLE;
- gThread->MutexUnlock (ProcessorData->StateLock);
- gMPSystem.FinishCount++;
- break;
+ gThread->MutexLock (ProcessorData->StateLock);
+ ProcessorData->State = CPU_STATE_IDLE;
+ gThread->MutexUnlock (ProcessorData->StateLock);
+ gMPSystem.FinishCount++;
+ break;
- default:
- break;
+ default:
+ break;
}
}
- if (gMPSystem.TimeoutActive && gMPSystem.Timeout == 0) {
+ if (gMPSystem.TimeoutActive && (gMPSystem.Timeout == 0)) {
//
// Timeout
//
@@ -1081,7 +1074,7 @@ CpuCheckAllAPsStatus (
for (ProcessorNumber = 0; ProcessorNumber < gMPSystem.NumberOfProcessors; ProcessorNumber++) {
ProcessorData = &gMPSystem.ProcessorData[ProcessorNumber];
if ((ProcessorData->Info.StatusFlag & PROCESSOR_AS_BSP_BIT) == PROCESSOR_AS_BSP_BIT) {
- // Skip BSP
+ // Skip BSP
continue;
}
@@ -1092,9 +1085,10 @@ CpuCheckAllAPsStatus (
// Mark the
Status = gThread->MutexTryLock (ProcessorData->StateLock);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
return;
}
+
ProcessorState = ProcessorData->State;
gThread->MutexUnlock (ProcessorData->StateLock);
@@ -1104,17 +1098,20 @@ CpuCheckAllAPsStatus (
if (gMPSystem.FailedList[Cpu] == END_OF_CPU_LIST) {
break;
}
+
if (gMPSystem.FailedList[ProcessorNumber] == Cpu) {
Found = TRUE;
break;
}
}
+
if (!Found) {
gMPSystem.FailedList[gMPSystem.FailedListIndex++] = Cpu;
}
}
}
}
+
// Force terminal exit
gMPSystem.FinishCount = gMPSystem.StartCount;
}
@@ -1138,21 +1135,21 @@ CpuCheckAllAPsStatus (
Status = gBS->SignalEvent (gMPSystem.WaitEvent);
- return ;
+ return;
}
VOID
EFIAPI
CpuCheckThisAPStatus (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
EFI_STATUS Status;
PROCESSOR_DATA_BLOCK *ProcessorData;
PROCESSOR_STATE ProcessorState;
- ProcessorData = (PROCESSOR_DATA_BLOCK *) Context;
+ ProcessorData = (PROCESSOR_DATA_BLOCK *)Context;
//
// This is an Interrupt Service routine.
@@ -1162,9 +1159,10 @@ CpuCheckThisAPStatus (
// otherwise, just dump out & try again on the next iteration.
//
Status = gThread->MutexTryLock (ProcessorData->StateLock);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
return;
}
+
ProcessorState = ProcessorData->State;
gThread->MutexUnlock (ProcessorData->StateLock);
@@ -1180,10 +1178,9 @@ CpuCheckThisAPStatus (
gThread->MutexUnlock (ProcessorData->StateLock);
}
- return ;
+ return;
}
-
/*++
This function is called by all processors (both BSP and AP) once and collects MP related data
@@ -1195,25 +1192,25 @@ CpuCheckThisAPStatus (
--*/
EFI_STATUS
FillInProcessorInformation (
- IN BOOLEAN BSP,
- IN UINTN ProcessorNumber
+ IN BOOLEAN BSP,
+ IN UINTN ProcessorNumber
)
{
- gMPSystem.ProcessorData[ProcessorNumber].Info.ProcessorId = gThread->Self ();
- gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag = PROCESSOR_ENABLED_BIT | PROCESSOR_HEALTH_STATUS_BIT;
+ gMPSystem.ProcessorData[ProcessorNumber].Info.ProcessorId = gThread->Self ();
+ gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag = PROCESSOR_ENABLED_BIT | PROCESSOR_HEALTH_STATUS_BIT;
if (BSP) {
gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag |= PROCESSOR_AS_BSP_BIT;
}
- gMPSystem.ProcessorData[ProcessorNumber].Info.Location.Package = (UINT32) ProcessorNumber;
+ gMPSystem.ProcessorData[ProcessorNumber].Info.Location.Package = (UINT32)ProcessorNumber;
gMPSystem.ProcessorData[ProcessorNumber].Info.Location.Core = 0;
gMPSystem.ProcessorData[ProcessorNumber].Info.Location.Thread = 0;
- gMPSystem.ProcessorData[ProcessorNumber].State = BSP ? CPU_STATE_BUSY : CPU_STATE_IDLE;
+ gMPSystem.ProcessorData[ProcessorNumber].State = BSP ? CPU_STATE_BUSY : CPU_STATE_IDLE;
- gMPSystem.ProcessorData[ProcessorNumber].Procedure = NULL;
- gMPSystem.ProcessorData[ProcessorNumber].Parameter = NULL;
- gMPSystem.ProcessorData[ProcessorNumber].StateLock = gThread->MutexInit ();
- gMPSystem.ProcessorData[ProcessorNumber].ProcedureLock = gThread->MutexInit ();
+ gMPSystem.ProcessorData[ProcessorNumber].Procedure = NULL;
+ gMPSystem.ProcessorData[ProcessorNumber].Parameter = NULL;
+ gMPSystem.ProcessorData[ProcessorNumber].StateLock = gThread->MutexInit ();
+ gMPSystem.ProcessorData[ProcessorNumber].ProcedureLock = gThread->MutexInit ();
return EFI_SUCCESS;
}
@@ -1230,7 +1227,7 @@ CpuDriverApIdolLoop (
PROCESSOR_DATA_BLOCK *ProcessorData;
ProcessorNumber = (UINTN)Context;
- ProcessorData = &gMPSystem.ProcessorData[ProcessorNumber];
+ ProcessorData = &gMPSystem.ProcessorData[ProcessorNumber];
ProcessorData->Info.ProcessorId = gThread->Self ();
@@ -1267,15 +1264,13 @@ CpuDriverApIdolLoop (
return 0;
}
-
EFI_STATUS
InitializeMpSystemData (
- IN UINTN NumberOfProcessors
+ IN UINTN NumberOfProcessors
)
{
- EFI_STATUS Status;
- UINTN Index;
-
+ EFI_STATUS Status;
+ UINTN Index;
//
// Clear the data structure area first.
@@ -1285,8 +1280,8 @@ InitializeMpSystemData (
//
// First BSP fills and inits all known values, including it's own records.
//
- gMPSystem.NumberOfProcessors = NumberOfProcessors;
- gMPSystem.NumberOfEnabledProcessors = NumberOfProcessors;
+ gMPSystem.NumberOfProcessors = NumberOfProcessors;
+ gMPSystem.NumberOfEnabledProcessors = NumberOfProcessors;
gMPSystem.ProcessorData = AllocateZeroPool (gMPSystem.NumberOfProcessors * sizeof (PROCESSOR_DATA_BLOCK));
ASSERT (gMPSystem.ProcessorData != NULL);
@@ -1302,10 +1297,9 @@ InitializeMpSystemData (
);
ASSERT_EFI_ERROR (Status);
-
for (Index = 0; Index < gMPSystem.NumberOfProcessors; Index++) {
if ((gMPSystem.ProcessorData[Index].Info.StatusFlag & PROCESSOR_AS_BSP_BIT) == PROCESSOR_AS_BSP_BIT) {
- // Skip BSP
+ // Skip BSP
continue;
}
@@ -1318,21 +1312,18 @@ InitializeMpSystemData (
(VOID *)Index
);
-
Status = gBS->CreateEvent (
- EVT_TIMER | EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- CpuCheckThisAPStatus,
- (VOID *) &gMPSystem.ProcessorData[Index],
- &gMPSystem.ProcessorData[Index].CheckThisAPEvent
- );
+ EVT_TIMER | EVT_NOTIFY_SIGNAL,
+ TPL_CALLBACK,
+ CpuCheckThisAPStatus,
+ (VOID *)&gMPSystem.ProcessorData[Index],
+ &gMPSystem.ProcessorData[Index].CheckThisAPEvent
+ );
}
return EFI_SUCCESS;
}
-
-
/**
Invoke a notification event
@@ -1344,32 +1335,30 @@ InitializeMpSystemData (
VOID
EFIAPI
CpuReadToBootFunction (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
gReadToBoot = TRUE;
}
-
-
EFI_STATUS
CpuMpServicesInit (
- OUT UINTN *MaxCpus
+ OUT UINTN *MaxCpus
)
{
- EFI_STATUS Status;
- EFI_HANDLE Handle;
- EMU_IO_THUNK_PROTOCOL *IoThunk;
+ EFI_STATUS Status;
+ EFI_HANDLE Handle;
+ EMU_IO_THUNK_PROTOCOL *IoThunk;
*MaxCpus = 1; // BSP
- IoThunk = GetIoThunkInstance (&gEmuThreadThunkProtocolGuid, 0);
+ IoThunk = GetIoThunkInstance (&gEmuThreadThunkProtocolGuid, 0);
if (IoThunk != NULL) {
Status = IoThunk->Open (IoThunk);
if (!EFI_ERROR (Status)) {
if (IoThunk->ConfigString != NULL) {
*MaxCpus += StrDecimalToUintn (IoThunk->ConfigString);
- gThread = IoThunk->Interface;
+ gThread = IoThunk->Interface;
}
}
}
@@ -1379,9 +1368,9 @@ CpuMpServicesInit (
return EFI_SUCCESS;
}
- gPollInterval = (UINTN) PcdGet64 (PcdEmuMpServicesPollingInterval);
+ gPollInterval = (UINTN)PcdGet64 (PcdEmuMpServicesPollingInterval);
- Status = InitializeMpSystemData (*MaxCpus);
+ Status = InitializeMpSystemData (*MaxCpus);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -1395,10 +1384,9 @@ CpuMpServicesInit (
Handle = NULL;
Status = gBS->InstallMultipleProtocolInterfaces (
&Handle,
- &gEfiMpServiceProtocolGuid, &mMpServicesTemplate,
+ &gEfiMpServiceProtocolGuid,
+ &mMpServicesTemplate,
NULL
);
return Status;
}
-
-
diff --git a/EmulatorPkg/EmuBlockIoDxe/ComponentName.c b/EmulatorPkg/EmuBlockIoDxe/ComponentName.c
index 7c61fdfd78..76533e1fbb 100644
--- a/EmulatorPkg/EmuBlockIoDxe/ComponentName.c
+++ b/EmulatorPkg/EmuBlockIoDxe/ComponentName.c
@@ -16,6 +16,7 @@ Abstract:
//
// EFI Component Name Functions
//
+
/**
Retrieves a Unicode string that is the user readable name of the driver.
@@ -63,7 +64,6 @@ EmuBlockIoComponentNameGetDriverName (
OUT CHAR16 **DriverName
);
-
/**
Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver.
@@ -135,17 +135,17 @@ EmuBlockIoComponentNameGetDriverName (
EFI_STATUS
EFIAPI
EmuBlockIoComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
);
//
// EFI Component Name Protocol
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gEmuBlockIoComponentName = {
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gEmuBlockIoComponentName = {
EmuBlockIoComponentNameGetDriverName,
EmuBlockIoComponentNameGetControllerName,
"eng"
@@ -154,16 +154,15 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gEmuBlockIoCompon
//
// EFI Component Name 2 Protocol
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuBlockIoComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) EmuBlockIoComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) EmuBlockIoComponentNameGetControllerName,
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuBlockIoComponentName2 = {
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)EmuBlockIoComponentNameGetDriverName,
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)EmuBlockIoComponentNameGetControllerName,
"en"
};
-
-EFI_UNICODE_STRING_TABLE mEmuBlockIoDriverNameTable[] = {
+EFI_UNICODE_STRING_TABLE mEmuBlockIoDriverNameTable[] = {
{ "eng;en", L"Emu Block I/O Driver" },
- { NULL , NULL }
+ { NULL, NULL }
};
/**
@@ -214,12 +213,12 @@ EmuBlockIoComponentNameGetDriverName (
)
{
return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- mEmuBlockIoDriverNameTable,
- DriverName,
+ Language,
+ This->SupportedLanguages,
+ mEmuBlockIoDriverNameTable,
+ DriverName,
(BOOLEAN)(This == &gEmuBlockIoComponentName)
- );
+ );
}
/**
@@ -293,16 +292,16 @@ EmuBlockIoComponentNameGetDriverName (
EFI_STATUS
EFIAPI
EmuBlockIoComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
)
{
- EFI_STATUS Status;
- EFI_BLOCK_IO_PROTOCOL *BlockIo;
- EMU_BLOCK_IO_PRIVATE *Private;
+ EFI_STATUS Status;
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;
+ EMU_BLOCK_IO_PRIVATE *Private;
//
// This is a device driver, so ChildHandle must be NULL.
@@ -310,6 +309,7 @@ EmuBlockIoComponentNameGetControllerName (
if (ChildHandle != NULL) {
return EFI_UNSUPPORTED;
}
+
//
// Make sure this driver is currently managing ControllerHandle
//
@@ -321,6 +321,7 @@ EmuBlockIoComponentNameGetControllerName (
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
+
//
// Get our context back
//
@@ -339,10 +340,10 @@ EmuBlockIoComponentNameGetControllerName (
Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (BlockIo);
return LookupUnicodeString2 (
- Language,
+ Language,
This->SupportedLanguages,
Private->ControllerNameTable,
ControllerName,
(BOOLEAN)(This == &gEmuBlockIoComponentName)
- );
+ );
}
diff --git a/EmulatorPkg/EmuBlockIoDxe/DriverConfiguration.c b/EmulatorPkg/EmuBlockIoDxe/DriverConfiguration.c
index 86648dd445..a3ec1a5412 100644
--- a/EmulatorPkg/EmuBlockIoDxe/DriverConfiguration.c
+++ b/EmulatorPkg/EmuBlockIoDxe/DriverConfiguration.c
@@ -19,35 +19,35 @@ Abstract:
EFI_STATUS
EFIAPI
EmuBlockIoDriverConfigurationSetOptions (
- IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired
+ IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired
);
EFI_STATUS
EFIAPI
EmuBlockIoDriverConfigurationOptionsValid (
- IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL
+ IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL
);
EFI_STATUS
EFIAPI
EmuBlockIoDriverConfigurationForceDefaults (
- IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN UINT32 DefaultType,
- OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired
+ IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN UINT32 DefaultType,
+ OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired
);
//
// EFI Driver Configuration Protocol
//
-EFI_DRIVER_CONFIGURATION_PROTOCOL gEmuBlockIoDriverConfiguration = {
+EFI_DRIVER_CONFIGURATION_PROTOCOL gEmuBlockIoDriverConfiguration = {
EmuBlockIoDriverConfigurationSetOptions,
EmuBlockIoDriverConfigurationOptionsValid,
EmuBlockIoDriverConfigurationForceDefaults,
@@ -103,20 +103,20 @@ EFI_DRIVER_CONFIGURATION_PROTOCOL gEmuBlockIoDriverConfiguration = {
EFI_STATUS
EFIAPI
EmuBlockIoDriverConfigurationSetOptions (
- IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired
+ IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired
)
{
- EFI_STATUS Status;
- EFI_BLOCK_IO_PROTOCOL *BlockIo;
- CHAR8 *SupportedLanguage;
+ EFI_STATUS Status;
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;
+ CHAR8 *SupportedLanguage;
SupportedLanguage = This->SupportedLanguages;
- Status = EFI_UNSUPPORTED;
+ Status = EFI_UNSUPPORTED;
while (*SupportedLanguage != 0) {
if (AsciiStrnCmp (Language, SupportedLanguage, 3) == 0) {
Status = EFI_SUCCESS;
@@ -129,7 +129,7 @@ EmuBlockIoDriverConfigurationSetOptions (
return Status;
}
- if (ActionRequired == NULL || ControllerHandle == NULL) {
+ if ((ActionRequired == NULL) || (ControllerHandle == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -151,11 +151,11 @@ EmuBlockIoDriverConfigurationSetOptions (
if (!EFI_ERROR (Status)) {
gBS->CloseProtocol (
- ControllerHandle,
- &gEmuIoThunkProtocolGuid,
- gEmuBlockIoDriverBinding.DriverBindingHandle,
- ControllerHandle
- );
+ ControllerHandle,
+ &gEmuIoThunkProtocolGuid,
+ gEmuBlockIoDriverBinding.DriverBindingHandle,
+ ControllerHandle
+ );
return EFI_UNSUPPORTED;
}
@@ -206,13 +206,13 @@ EmuBlockIoDriverConfigurationSetOptions (
EFI_STATUS
EFIAPI
EmuBlockIoDriverConfigurationOptionsValid (
- IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL
+ IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL
)
{
- EFI_STATUS Status;
- EFI_BLOCK_IO_PROTOCOL *BlockIo;
+ EFI_STATUS Status;
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;
if (ChildHandle != NULL) {
return EFI_UNSUPPORTED;
@@ -236,11 +236,11 @@ EmuBlockIoDriverConfigurationOptionsValid (
if (!EFI_ERROR (Status)) {
gBS->CloseProtocol (
- ControllerHandle,
- &gEmuIoThunkProtocolGuid,
- gEmuBlockIoDriverBinding.DriverBindingHandle,
- ControllerHandle
- );
+ ControllerHandle,
+ &gEmuIoThunkProtocolGuid,
+ gEmuBlockIoDriverBinding.DriverBindingHandle,
+ ControllerHandle
+ );
return EFI_UNSUPPORTED;
}
@@ -280,21 +280,21 @@ EmuBlockIoDriverConfigurationOptionsValid (
EFI_STATUS
EFIAPI
EmuBlockIoDriverConfigurationForceDefaults (
- IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN UINT32 DefaultType,
- OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired
+ IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN UINT32 DefaultType,
+ OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired
)
{
- EFI_STATUS Status;
- EFI_BLOCK_IO_PROTOCOL *BlockIo;
+ EFI_STATUS Status;
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;
if (ChildHandle != NULL) {
return EFI_UNSUPPORTED;
}
- if (ActionRequired == NULL || ControllerHandle == NULL) {
+ if ((ActionRequired == NULL) || (ControllerHandle == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -312,11 +312,11 @@ EmuBlockIoDriverConfigurationForceDefaults (
if (!EFI_ERROR (Status)) {
gBS->CloseProtocol (
- ControllerHandle,
- &gEmuIoThunkProtocolGuid,
- gEmuBlockIoDriverBinding.DriverBindingHandle,
- ControllerHandle
- );
+ ControllerHandle,
+ &gEmuIoThunkProtocolGuid,
+ gEmuBlockIoDriverBinding.DriverBindingHandle,
+ ControllerHandle
+ );
return EFI_UNSUPPORTED;
}
diff --git a/EmulatorPkg/EmuBlockIoDxe/DriverDiagnostics.c b/EmulatorPkg/EmuBlockIoDxe/DriverDiagnostics.c
index 84e6b19329..b107dba37b 100644
--- a/EmulatorPkg/EmuBlockIoDxe/DriverDiagnostics.c
+++ b/EmulatorPkg/EmuBlockIoDxe/DriverDiagnostics.c
@@ -19,20 +19,20 @@ Abstract:
EFI_STATUS
EFIAPI
EmuBlockIoDriverDiagnosticsRunDiagnostics (
- IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN EFI_DRIVER_DIAGNOSTIC_TYPE DiagnosticType,
- IN CHAR8 *Language,
- OUT EFI_GUID **ErrorType,
- OUT UINTN *BufferSize,
- OUT CHAR16 **Buffer
+ IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN EFI_DRIVER_DIAGNOSTIC_TYPE DiagnosticType,
+ IN CHAR8 *Language,
+ OUT EFI_GUID **ErrorType,
+ OUT UINTN *BufferSize,
+ OUT CHAR16 **Buffer
);
//
// EFI Driver Diagnostics Protocol
//
-EFI_DRIVER_DIAGNOSTICS_PROTOCOL gEmuBlockIoDriverDiagnostics = {
+EFI_DRIVER_DIAGNOSTICS_PROTOCOL gEmuBlockIoDriverDiagnostics = {
EmuBlockIoDriverDiagnosticsRunDiagnostics,
"eng"
};
@@ -40,23 +40,24 @@ EFI_DRIVER_DIAGNOSTICS_PROTOCOL gEmuBlockIoDriverDiagnostics = {
//
// EFI Driver Diagnostics 2 Protocol
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_DRIVER_DIAGNOSTICS2_PROTOCOL gEmuBlockIoDriverDiagnostics2 = {
- (EFI_DRIVER_DIAGNOSTICS2_RUN_DIAGNOSTICS) EmuBlockIoDriverDiagnosticsRunDiagnostics,
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_DRIVER_DIAGNOSTICS2_PROTOCOL gEmuBlockIoDriverDiagnostics2 = {
+ (EFI_DRIVER_DIAGNOSTICS2_RUN_DIAGNOSTICS)EmuBlockIoDriverDiagnosticsRunDiagnostics,
"en"
};
EFI_STATUS
EFIAPI
EmuBlockIoDriverDiagnosticsRunDiagnostics (
- IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN EFI_DRIVER_DIAGNOSTIC_TYPE DiagnosticType,
- IN CHAR8 *Language,
- OUT EFI_GUID **ErrorType,
- OUT UINTN *BufferSize,
- OUT CHAR16 **Buffer
+ IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN EFI_DRIVER_DIAGNOSTIC_TYPE DiagnosticType,
+ IN CHAR8 *Language,
+ OUT EFI_GUID **ErrorType,
+ OUT UINTN *BufferSize,
+ OUT CHAR16 **Buffer
)
+
/*++
Routine Description:
@@ -117,24 +118,24 @@ EmuBlockIoDriverDiagnosticsRunDiagnostics (
--*/
{
- EFI_STATUS Status;
- EFI_BLOCK_IO_PROTOCOL *BlockIo;
- CHAR8 *SupportedLanguages;
- BOOLEAN Iso639Language;
- BOOLEAN Found;
- UINTN Index;
-
- if (Language == NULL ||
- ErrorType == NULL ||
- Buffer == NULL ||
- ControllerHandle == NULL ||
- BufferSize == NULL) {
-
+ EFI_STATUS Status;
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;
+ CHAR8 *SupportedLanguages;
+ BOOLEAN Iso639Language;
+ BOOLEAN Found;
+ UINTN Index;
+
+ if ((Language == NULL) ||
+ (ErrorType == NULL) ||
+ (Buffer == NULL) ||
+ (ControllerHandle == NULL) ||
+ (BufferSize == NULL))
+ {
return EFI_INVALID_PARAMETER;
}
SupportedLanguages = This->SupportedLanguages;
- Iso639Language = (BOOLEAN)(This == &gEmuBlockIoDriverDiagnostics);
+ Iso639Language = (BOOLEAN)(This == &gEmuBlockIoDriverDiagnostics);
//
// Make sure Language is in the set of Supported Languages
//
@@ -143,19 +144,25 @@ EmuBlockIoDriverDiagnosticsRunDiagnostics (
if (Iso639Language) {
if (CompareMem (Language, SupportedLanguages, 3) == 0) {
Found = TRUE;
- break;
- }
+ break;
+ }
+
SupportedLanguages += 3;
} else {
- for (Index = 0; SupportedLanguages[Index] != 0 && SupportedLanguages[Index] != ';'; Index++);
- if ((AsciiStrnCmp(SupportedLanguages, Language, Index) == 0) && (Language[Index] == 0)) {
+ for (Index = 0; SupportedLanguages[Index] != 0 && SupportedLanguages[Index] != ';'; Index++) {
+ }
+
+ if ((AsciiStrnCmp (SupportedLanguages, Language, Index) == 0) && (Language[Index] == 0)) {
Found = TRUE;
break;
- }
+ }
+
SupportedLanguages += Index;
- for (; *SupportedLanguages != 0 && *SupportedLanguages == ';'; SupportedLanguages++);
+ for ( ; *SupportedLanguages != 0 && *SupportedLanguages == ';'; SupportedLanguages++) {
+ }
}
}
+
//
// If Language is not a member of SupportedLanguages, then return EFI_UNSUPPORTED
//
@@ -168,7 +175,7 @@ EmuBlockIoDriverDiagnosticsRunDiagnostics (
if (DiagnosticType != EfiDriverDiagnosticTypeStandard) {
*ErrorType = &gEfiBlockIoProtocolGuid;
*BufferSize = 0x60;
- Buffer = AllocatePool ((UINTN) (*BufferSize));
+ Buffer = AllocatePool ((UINTN)(*BufferSize));
CopyMem (*Buffer, L"Windows Block I/O Driver Diagnostics Failed\n", *BufferSize);
return EFI_DEVICE_ERROR;
}
@@ -194,11 +201,11 @@ EmuBlockIoDriverDiagnosticsRunDiagnostics (
if (!EFI_ERROR (Status)) {
gBS->CloseProtocol (
- ControllerHandle,
- &gEmuIoThunkProtocolGuid,
- gEmuBlockIoDriverBinding.DriverBindingHandle,
- ControllerHandle
- );
+ ControllerHandle,
+ &gEmuIoThunkProtocolGuid,
+ gEmuBlockIoDriverBinding.DriverBindingHandle,
+ ControllerHandle
+ );
return EFI_UNSUPPORTED;
}
diff --git a/EmulatorPkg/EmuBlockIoDxe/EmuBlockIo.c b/EmulatorPkg/EmuBlockIoDxe/EmuBlockIo.c
index 96424a82ae..4e8caf2514 100644
--- a/EmulatorPkg/EmuBlockIoDxe/EmuBlockIo.c
+++ b/EmulatorPkg/EmuBlockIoDxe/EmuBlockIo.c
@@ -7,7 +7,6 @@ bbe
#include "EmuBlockIo.h"
-
/**
Reset the block device hardware.
@@ -28,9 +27,9 @@ EmuBlockIo2Reset (
IN BOOLEAN ExtendedVerification
)
{
- EFI_STATUS Status;
- EMU_BLOCK_IO_PRIVATE *Private;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ EMU_BLOCK_IO_PRIVATE *Private;
+ EFI_TPL OldTpl;
Private = EMU_BLOCK_IO2_PRIVATE_DATA_FROM_THIS (This);
@@ -78,17 +77,17 @@ EmuBlockIo2Reset (
EFI_STATUS
EFIAPI
EmuBlockIo2ReadBlocksEx (
- IN EFI_BLOCK_IO2_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA LBA,
- IN OUT EFI_BLOCK_IO2_TOKEN *Token,
- IN UINTN BufferSize,
- OUT VOID *Buffer
+ IN EFI_BLOCK_IO2_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN EFI_LBA LBA,
+ IN OUT EFI_BLOCK_IO2_TOKEN *Token,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
)
{
- EFI_STATUS Status;
- EMU_BLOCK_IO_PRIVATE *Private;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ EMU_BLOCK_IO_PRIVATE *Private;
+ EFI_TPL OldTpl;
Private = EMU_BLOCK_IO2_PRIVATE_DATA_FROM_THIS (This);
@@ -100,7 +99,6 @@ EmuBlockIo2ReadBlocksEx (
return Status;
}
-
/**
Write BufferSize bytes from Lba into Buffer.
@@ -136,16 +134,16 @@ EFI_STATUS
EFIAPI
EmuBlockIo2WriteBlocksEx (
IN EFI_BLOCK_IO2_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA LBA,
- IN OUT EFI_BLOCK_IO2_TOKEN *Token,
- IN UINTN BufferSize,
- IN VOID *Buffer
+ IN UINT32 MediaId,
+ IN EFI_LBA LBA,
+ IN OUT EFI_BLOCK_IO2_TOKEN *Token,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
)
{
- EFI_STATUS Status;
- EMU_BLOCK_IO_PRIVATE *Private;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ EMU_BLOCK_IO_PRIVATE *Private;
+ EFI_TPL OldTpl;
Private = EMU_BLOCK_IO2_PRIVATE_DATA_FROM_THIS (This);
@@ -157,8 +155,6 @@ EmuBlockIo2WriteBlocksEx (
return Status;
}
-
-
/**
Flush the Block Device.
@@ -184,13 +180,13 @@ EmuBlockIo2WriteBlocksEx (
EFI_STATUS
EFIAPI
EmuBlockIo2Flush (
- IN EFI_BLOCK_IO2_PROTOCOL *This,
- IN OUT EFI_BLOCK_IO2_TOKEN *Token
+ IN EFI_BLOCK_IO2_PROTOCOL *This,
+ IN OUT EFI_BLOCK_IO2_TOKEN *Token
)
{
- EFI_STATUS Status;
- EMU_BLOCK_IO_PRIVATE *Private;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ EMU_BLOCK_IO_PRIVATE *Private;
+ EFI_TPL OldTpl;
Private = EMU_BLOCK_IO2_PRIVATE_DATA_FROM_THIS (This);
@@ -202,8 +198,6 @@ EmuBlockIo2Flush (
return Status;
}
-
-
/**
Reset the Block Device.
@@ -218,13 +212,13 @@ EmuBlockIo2Flush (
EFI_STATUS
EFIAPI
EmuBlockIoReset (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
)
{
- EFI_STATUS Status;
- EMU_BLOCK_IO_PRIVATE *Private;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ EMU_BLOCK_IO_PRIVATE *Private;
+ EFI_TPL OldTpl;
Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);
@@ -236,7 +230,6 @@ EmuBlockIoReset (
return Status;
}
-
/**
Read BufferSize bytes from Lba into Buffer.
@@ -259,30 +252,29 @@ EmuBlockIoReset (
EFI_STATUS
EFIAPI
EmuBlockIoReadBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN EFI_LBA Lba,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
)
{
- EFI_STATUS Status;
- EMU_BLOCK_IO_PRIVATE *Private;
- EFI_TPL OldTpl;
- EFI_BLOCK_IO2_TOKEN Token;
+ EFI_STATUS Status;
+ EMU_BLOCK_IO_PRIVATE *Private;
+ EFI_TPL OldTpl;
+ EFI_BLOCK_IO2_TOKEN Token;
Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
Token.Event = NULL;
- Status = Private->Io->ReadBlocks (Private->Io, MediaId, Lba, &Token, BufferSize, Buffer);
+ Status = Private->Io->ReadBlocks (Private->Io, MediaId, Lba, &Token, BufferSize, Buffer);
gBS->RestoreTPL (OldTpl);
return Status;
}
-
/**
Write BufferSize bytes from Lba into Buffer.
@@ -306,24 +298,24 @@ EmuBlockIoReadBlocks (
EFI_STATUS
EFIAPI
EmuBlockIoWriteBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- IN VOID *Buffer
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN EFI_LBA Lba,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
)
{
- EFI_STATUS Status;
- EMU_BLOCK_IO_PRIVATE *Private;
- EFI_TPL OldTpl;
- EFI_BLOCK_IO2_TOKEN Token;
+ EFI_STATUS Status;
+ EMU_BLOCK_IO_PRIVATE *Private;
+ EFI_TPL OldTpl;
+ EFI_BLOCK_IO2_TOKEN Token;
Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
Token.Event = NULL;
- Status = Private->Io->WriteBlocks (Private->Io, MediaId, Lba, &Token, BufferSize, Buffer);
+ Status = Private->Io->WriteBlocks (Private->Io, MediaId, Lba, &Token, BufferSize, Buffer);
gBS->RestoreTPL (OldTpl);
return Status;
@@ -345,24 +337,22 @@ EmuBlockIoFlushBlocks (
IN EFI_BLOCK_IO_PROTOCOL *This
)
{
- EFI_STATUS Status;
- EMU_BLOCK_IO_PRIVATE *Private;
- EFI_TPL OldTpl;
- EFI_BLOCK_IO2_TOKEN Token;
+ EFI_STATUS Status;
+ EMU_BLOCK_IO_PRIVATE *Private;
+ EFI_TPL OldTpl;
+ EFI_BLOCK_IO2_TOKEN Token;
Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
Token.Event = NULL;
- Status = Private->Io->FlushBlocks (Private->Io, &Token);
+ Status = Private->Io->FlushBlocks (Private->Io, &Token);
gBS->RestoreTPL (OldTpl);
return Status;
}
-
-
/**
Tests to see if this driver supports a given controller. If a child device is provided,
it further tests to see if this driver supports creating a handle for the specified child device.
@@ -413,8 +403,8 @@ EmuBlockIoDriverBindingSupported (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- EFI_STATUS Status;
- EMU_IO_THUNK_PROTOCOL *EmuIoThunk;
+ EFI_STATUS Status;
+ EMU_IO_THUNK_PROTOCOL *EmuIoThunk;
//
// Open the IO Abstraction(s) needed to perform the supported test
@@ -443,15 +433,14 @@ EmuBlockIoDriverBindingSupported (
// Close the I/O Abstraction(s) used to perform the supported test
//
gBS->CloseProtocol (
- Handle,
- &gEmuIoThunkProtocolGuid,
- This->DriverBindingHandle,
- Handle
- );
+ Handle,
+ &gEmuIoThunkProtocolGuid,
+ This->DriverBindingHandle,
+ Handle
+ );
return Status;
}
-
/**
Starts a device controller or a bus controller.
@@ -490,14 +479,14 @@ EmuBlockIoDriverBindingSupported (
EFI_STATUS
EFIAPI
EmuBlockIoDriverBindingStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Handle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Handle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- EFI_STATUS Status;
- EMU_IO_THUNK_PROTOCOL *EmuIoThunk;
- EMU_BLOCK_IO_PRIVATE *Private = NULL;
+ EFI_STATUS Status;
+ EMU_IO_THUNK_PROTOCOL *EmuIoThunk;
+ EMU_BLOCK_IO_PRIVATE *Private = NULL;
//
// Grab the protocols we need
@@ -573,8 +562,10 @@ EmuBlockIoDriverBindingStart (
Status = gBS->InstallMultipleProtocolInterfaces (
&Handle,
- &gEfiBlockIoProtocolGuid, &Private->BlockIo,
- &gEfiBlockIo2ProtocolGuid, &Private->BlockIo2,
+ &gEfiBlockIoProtocolGuid,
+ &Private->BlockIo,
+ &gEfiBlockIo2ProtocolGuid,
+ &Private->BlockIo2,
NULL
);
@@ -586,21 +577,19 @@ Done:
}
gBS->FreePool (Private);
-
}
gBS->CloseProtocol (
- Handle,
- &gEmuIoThunkProtocolGuid,
- This->DriverBindingHandle,
- Handle
- );
+ Handle,
+ &gEmuIoThunkProtocolGuid,
+ This->DriverBindingHandle,
+ Handle
+ );
}
return Status;
}
-
/**
Stops a device controller or a bus controller.
@@ -636,9 +625,9 @@ EmuBlockIoDriverBindingStop (
IN EFI_HANDLE *ChildHandleBuffer
)
{
- EFI_BLOCK_IO_PROTOCOL *BlockIo;
- EFI_STATUS Status;
- EMU_BLOCK_IO_PRIVATE *Private;
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;
+ EFI_STATUS Status;
+ EMU_BLOCK_IO_PRIVATE *Private;
//
// Get our context back
@@ -659,8 +648,10 @@ EmuBlockIoDriverBindingStop (
Status = gBS->UninstallMultipleProtocolInterfaces (
Private->EfiHandle,
- &gEfiBlockIoProtocolGuid, &Private->BlockIo,
- &gEfiBlockIo2ProtocolGuid, &Private->BlockIo2,
+ &gEfiBlockIoProtocolGuid,
+ &Private->BlockIo,
+ &gEfiBlockIo2ProtocolGuid,
+ &Private->BlockIo2,
NULL
);
if (!EFI_ERROR (Status)) {
@@ -686,11 +677,7 @@ EmuBlockIoDriverBindingStop (
return Status;
}
-
-
-
-
-EFI_DRIVER_BINDING_PROTOCOL gEmuBlockIoDriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gEmuBlockIoDriverBinding = {
EmuBlockIoDriverBindingSupported,
EmuBlockIoDriverBindingStart,
EmuBlockIoDriverBindingStop,
@@ -699,9 +686,6 @@ EFI_DRIVER_BINDING_PROTOCOL gEmuBlockIoDriverBinding = {
NULL
};
-
-
-
/**
The user Entry Point for module EmuBlockIo . The user code starts with this function.
@@ -715,11 +699,11 @@ EFI_DRIVER_BINDING_PROTOCOL gEmuBlockIoDriverBinding = {
EFI_STATUS
EFIAPI
InitializeEmuBlockIo (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = EfiLibInstallAllDriverProtocols2 (
ImageHandle,
@@ -735,9 +719,5 @@ InitializeEmuBlockIo (
);
ASSERT_EFI_ERROR (Status);
-
return Status;
}
-
-
-
diff --git a/EmulatorPkg/EmuBlockIoDxe/EmuBlockIo.h b/EmulatorPkg/EmuBlockIoDxe/EmuBlockIo.h
index e1e859326b..ac7d8356fa 100644
--- a/EmulatorPkg/EmuBlockIoDxe/EmuBlockIo.h
+++ b/EmulatorPkg/EmuBlockIoDxe/EmuBlockIo.h
@@ -38,12 +38,11 @@ Abstract:
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
-
//
// Language supported for driverconfiguration protocol
//
-#define EMU_BLOCK_IO_PRIVATE_SIGNATURE SIGNATURE_32 ('E', 'M', 'b', 'k')
+#define EMU_BLOCK_IO_PRIVATE_SIGNATURE SIGNATURE_32 ('E', 'M', 'b', 'k')
typedef struct {
UINTN Signature;
EMU_IO_THUNK_PROTOCOL *IoThunk;
@@ -55,7 +54,6 @@ typedef struct {
EFI_BLOCK_IO_MEDIA Media;
EFI_UNICODE_STRING_TABLE *ControllerNameTable;
-
} EMU_BLOCK_IO_PRIVATE;
#define EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS(a) \
@@ -64,7 +62,6 @@ typedef struct {
#define EMU_BLOCK_IO2_PRIVATE_DATA_FROM_THIS(a) \
CR(a, EMU_BLOCK_IO_PRIVATE, BlockIo2, EMU_BLOCK_IO_PRIVATE_SIGNATURE)
-
//
// Block I/O Global Variables
//
diff --git a/EmulatorPkg/EmuBusDriverDxe/ComponentName.c b/EmulatorPkg/EmuBusDriverDxe/ComponentName.c
index f1b0fa5f22..a79b0946c1 100644
--- a/EmulatorPkg/EmuBusDriverDxe/ComponentName.c
+++ b/EmulatorPkg/EmuBusDriverDxe/ComponentName.c
@@ -21,17 +21,17 @@ EmuBusDriverComponentNameGetDriverName (
EFI_STATUS
EFIAPI
EmuBusDriverComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
);
//
// EFI Component Name Protocol
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gEmuBusDriverComponentName = {
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gEmuBusDriverComponentName = {
EmuBusDriverComponentNameGetDriverName,
EmuBusDriverComponentNameGetControllerName,
"eng"
@@ -40,15 +40,15 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gEmuBusDriverCompo
//
// EFI Component Name 2 Protocol
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuBusDriverComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) EmuBusDriverComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) EmuBusDriverComponentNameGetControllerName,
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuBusDriverComponentName2 = {
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)EmuBusDriverComponentNameGetDriverName,
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)EmuBusDriverComponentNameGetControllerName,
"en"
};
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mEmuBusDriverNameTable[] = {
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mEmuBusDriverNameTable[] = {
{ "eng", L"Emu Bus Driver" },
- { NULL , NULL }
+ { NULL, NULL }
};
/**
@@ -99,12 +99,12 @@ EmuBusDriverComponentNameGetDriverName (
)
{
return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- mEmuBusDriverNameTable,
- DriverName,
- (BOOLEAN)(This == &gEmuBusDriverComponentName)
- );
+ Language,
+ This->SupportedLanguages,
+ mEmuBusDriverNameTable,
+ DriverName,
+ (BOOLEAN)(This == &gEmuBusDriverComponentName)
+ );
}
/**
@@ -178,16 +178,16 @@ EmuBusDriverComponentNameGetDriverName (
EFI_STATUS
EFIAPI
EmuBusDriverComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
)
{
- EFI_STATUS Status;
- EMU_IO_THUNK_PROTOCOL *EmuIo;
- EMU_IO_DEVICE *Private;
+ EFI_STATUS Status;
+ EMU_IO_THUNK_PROTOCOL *EmuIo;
+ EMU_IO_DEVICE *Private;
//
// Make sure this driver is currently managing ControllHandle
@@ -223,7 +223,7 @@ EmuBusDriverComponentNameGetControllerName (
Status = gBS->OpenProtocol (
ChildHandle,
&gEmuIoThunkProtocolGuid,
- (VOID**)&EmuIo,
+ (VOID **)&EmuIo,
gEmuBusDriverBinding.DriverBindingHandle,
ChildHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -240,5 +240,5 @@ EmuBusDriverComponentNameGetControllerName (
Private->ControllerNameTable,
ControllerName,
(BOOLEAN)(This == &gEmuBusDriverComponentName)
- );
+ );
}
diff --git a/EmulatorPkg/EmuBusDriverDxe/EmuBusDriverDxe.c b/EmulatorPkg/EmuBusDriverDxe/EmuBusDriverDxe.c
index d8380f2be9..2feb158186 100644
--- a/EmulatorPkg/EmuBusDriverDxe/EmuBusDriverDxe.c
+++ b/EmulatorPkg/EmuBusDriverDxe/EmuBusDriverDxe.c
@@ -10,12 +10,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "EmuBusDriverDxe.h"
-
-
//
// DriverBinding protocol global
//
-EFI_DRIVER_BINDING_PROTOCOL gEmuBusDriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gEmuBusDriverBinding = {
EmuBusDriverBindingSupported,
EmuBusDriverBindingStart,
EmuBusDriverBindingStop,
@@ -24,8 +22,6 @@ EFI_DRIVER_BINDING_PROTOCOL gEmuBusDriverBinding = {
NULL
};
-
-
EFI_STATUS
EFIAPI
EmuBusDriverBindingSupported (
@@ -52,9 +48,10 @@ EmuBusDriverBindingSupported (
// If RemainingDevicePath isn't the End of Device Path Node,
// check its validation
//
- if (RemainingDevicePath->Type != HARDWARE_DEVICE_PATH ||
- RemainingDevicePath->SubType != HW_VENDOR_DP ||
- DevicePathNodeLength(RemainingDevicePath) != sizeof(EMU_VENDOR_DEVICE_PATH_NODE)) {
+ if ((RemainingDevicePath->Type != HARDWARE_DEVICE_PATH) ||
+ (RemainingDevicePath->SubType != HW_VENDOR_DP) ||
+ (DevicePathNodeLength (RemainingDevicePath) != sizeof (EMU_VENDOR_DEVICE_PATH_NODE)))
+ {
return EFI_UNSUPPORTED;
}
}
@@ -66,7 +63,7 @@ EmuBusDriverBindingSupported (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEmuThunkProtocolGuid,
- (VOID **)&EmuThunk ,
+ (VOID **)&EmuThunk,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -83,11 +80,11 @@ EmuBusDriverBindingSupported (
// Close the I/O Abstraction(s) used to perform the supported test
//
gBS->CloseProtocol (
- ControllerHandle,
- &gEmuThunkProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
+ ControllerHandle,
+ &gEmuThunkProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
//
// Open the EFI Device Path protocol needed to perform the supported test
@@ -108,21 +105,19 @@ EmuBusDriverBindingSupported (
return Status;
}
-
//
// Close protocol, don't use device path protocol in the Support() function
//
gBS->CloseProtocol (
- ControllerHandle,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
+ ControllerHandle,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
return Status;
}
-
EFI_STATUS
EFIAPI
EmuBusDriverBindingStart (
@@ -131,19 +126,19 @@ EmuBusDriverBindingStart (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- EFI_STATUS Status;
- EFI_STATUS InstallStatus;
- EMU_THUNK_PROTOCOL *EmuThunk;
- EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
- EMU_IO_DEVICE *EmuDevice;
- EMU_BUS_DEVICE *EmuBusDevice;
- EMU_IO_THUNK_PROTOCOL *EmuIoThunk;
- UINT16 ComponentName[512];
- EMU_VENDOR_DEVICE_PATH_NODE *Node;
- BOOLEAN CreateDevice;
+ EFI_STATUS Status;
+ EFI_STATUS InstallStatus;
+ EMU_THUNK_PROTOCOL *EmuThunk;
+ EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
+ EMU_IO_DEVICE *EmuDevice;
+ EMU_BUS_DEVICE *EmuBusDevice;
+ EMU_IO_THUNK_PROTOCOL *EmuIoThunk;
+ UINT16 ComponentName[512];
+ EMU_VENDOR_DEVICE_PATH_NODE *Node;
+ BOOLEAN CreateDevice;
InstallStatus = EFI_UNSUPPORTED;
- Status = EFI_UNSUPPORTED;
+ Status = EFI_UNSUPPORTED;
//
// Grab the protocols we need
@@ -156,7 +151,7 @@ EmuBusDriverBindingStart (
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
- if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {
+ if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
return Status;
}
@@ -168,7 +163,7 @@ EmuBusDriverBindingStart (
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
- if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {
+ if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
return Status;
}
@@ -196,10 +191,10 @@ EmuBusDriverBindingStart (
FALSE
);
-
Status = gBS->InstallMultipleProtocolInterfaces (
&ControllerHandle,
- &gEfiCallerIdGuid, EmuBusDevice,
+ &gEfiCallerIdGuid,
+ EmuBusDevice,
NULL
);
if (EFI_ERROR (Status)) {
@@ -209,7 +204,6 @@ EmuBusDriverBindingStart (
}
}
-
for (Status = EFI_SUCCESS, EmuIoThunk = NULL; !EFI_ERROR (Status); ) {
Status = EmuThunk->GetNextProtocol (TRUE, &EmuIoThunk);
if (EFI_ERROR (Status)) {
@@ -218,7 +212,7 @@ EmuBusDriverBindingStart (
CreateDevice = TRUE;
if (RemainingDevicePath != NULL) {
- CreateDevice = FALSE;
+ CreateDevice = FALSE;
//
// Check if RemainingDevicePath is the End of Device Path Node,
// if yes, don't create any child device
@@ -228,12 +222,13 @@ EmuBusDriverBindingStart (
// If RemainingDevicePath isn't the End of Device Path Node,
// check its validation
//
- Node = (EMU_VENDOR_DEVICE_PATH_NODE *) RemainingDevicePath;
- if (Node->VendorDevicePath.Header.Type == HARDWARE_DEVICE_PATH &&
- Node->VendorDevicePath.Header.SubType == HW_VENDOR_DP &&
- DevicePathNodeLength (&Node->VendorDevicePath.Header) == sizeof (EMU_VENDOR_DEVICE_PATH_NODE)
- ) {
- if (CompareGuid (&Node->VendorDevicePath.Guid, EmuIoThunk->Protocol) && Node->Instance == EmuIoThunk->Instance) {
+ Node = (EMU_VENDOR_DEVICE_PATH_NODE *)RemainingDevicePath;
+ if ((Node->VendorDevicePath.Header.Type == HARDWARE_DEVICE_PATH) &&
+ (Node->VendorDevicePath.Header.SubType == HW_VENDOR_DP) &&
+ (DevicePathNodeLength (&Node->VendorDevicePath.Header) == sizeof (EMU_VENDOR_DEVICE_PATH_NODE))
+ )
+ {
+ if (CompareGuid (&Node->VendorDevicePath.Guid, EmuIoThunk->Protocol) && (Node->Instance == EmuIoThunk->Instance)) {
CreateDevice = TRUE;
}
}
@@ -249,9 +244,9 @@ EmuBusDriverBindingStart (
return EFI_OUT_OF_RESOURCES;
}
- EmuDevice->Handle = NULL;
- EmuDevice->ControllerHandle = ControllerHandle;
- EmuDevice->ParentDevicePath = ParentDevicePath;
+ EmuDevice->Handle = NULL;
+ EmuDevice->ControllerHandle = ControllerHandle;
+ EmuDevice->ParentDevicePath = ParentDevicePath;
CopyMem (&EmuDevice->EmuIoThunk, EmuIoThunk, sizeof (EMU_IO_THUNK_PROTOCOL));
EmuDevice->ControllerNameTable = NULL;
@@ -264,10 +259,10 @@ EmuBusDriverBindingStart (
);
EmuDevice->DevicePath = EmuBusCreateDevicePath (
- ParentDevicePath,
- EmuIoThunk->Protocol,
- EmuIoThunk->Instance
- );
+ ParentDevicePath,
+ EmuIoThunk->Protocol,
+ EmuIoThunk->Instance
+ );
if (EmuDevice->DevicePath == NULL) {
gBS->FreePool (EmuDevice);
return EFI_OUT_OF_RESOURCES;
@@ -283,11 +278,13 @@ EmuBusDriverBindingStart (
EmuDevice->Signature = EMU_IO_DEVICE_SIGNATURE;
InstallStatus = gBS->InstallMultipleProtocolInterfaces (
- &EmuDevice->Handle,
- &gEfiDevicePathProtocolGuid, EmuDevice->DevicePath,
- &gEmuIoThunkProtocolGuid, &EmuDevice->EmuIoThunk,
- NULL
- );
+ &EmuDevice->Handle,
+ &gEfiDevicePathProtocolGuid,
+ EmuDevice->DevicePath,
+ &gEmuIoThunkProtocolGuid,
+ &EmuDevice->EmuIoThunk,
+ NULL
+ );
if (EFI_ERROR (InstallStatus)) {
FreeUnicodeStringTable (EmuDevice->ControllerNameTable);
gBS->FreePool (EmuDevice);
@@ -298,7 +295,7 @@ EmuBusDriverBindingStart (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEmuThunkProtocolGuid,
- (VOID **)&EmuThunk ,
+ (VOID **)&EmuThunk,
This->DriverBindingHandle,
EmuDevice->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@@ -313,7 +310,6 @@ EmuBusDriverBindingStart (
return InstallStatus;
}
-
EFI_STATUS
EFIAPI
EmuBusDriverBindingStop (
@@ -323,13 +319,13 @@ EmuBusDriverBindingStop (
IN EFI_HANDLE *ChildHandleBuffer
)
{
- EFI_STATUS Status;
- UINTN Index;
- BOOLEAN AllChildrenStopped;
- EMU_IO_THUNK_PROTOCOL *EmuIoThunk;
- EMU_BUS_DEVICE *EmuBusDevice;
- EMU_IO_DEVICE *EmuDevice;
- EMU_THUNK_PROTOCOL *EmuThunk;
+ EFI_STATUS Status;
+ UINTN Index;
+ BOOLEAN AllChildrenStopped;
+ EMU_IO_THUNK_PROTOCOL *EmuIoThunk;
+ EMU_BUS_DEVICE *EmuBusDevice;
+ EMU_IO_DEVICE *EmuDevice;
+ EMU_THUNK_PROTOCOL *EmuThunk;
//
// Complete all outstanding transactions to Controller.
@@ -353,35 +349,35 @@ EmuBusDriverBindingStop (
}
gBS->UninstallMultipleProtocolInterfaces (
- ControllerHandle,
- &gEfiCallerIdGuid, EmuBusDevice,
- NULL
- );
+ ControllerHandle,
+ &gEfiCallerIdGuid,
+ EmuBusDevice,
+ NULL
+ );
FreeUnicodeStringTable (EmuBusDevice->ControllerNameTable);
gBS->FreePool (EmuBusDevice);
gBS->CloseProtocol (
- ControllerHandle,
- &gEmuThunkProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
+ ControllerHandle,
+ &gEmuThunkProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
gBS->CloseProtocol (
- ControllerHandle,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
+ ControllerHandle,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
return EFI_SUCCESS;
}
AllChildrenStopped = TRUE;
for (Index = 0; Index < NumberOfChildren; Index++) {
-
Status = gBS->OpenProtocol (
ChildHandleBuffer[Index],
&gEmuIoThunkProtocolGuid,
@@ -402,20 +398,22 @@ EmuBusDriverBindingStop (
Status = gBS->UninstallMultipleProtocolInterfaces (
EmuDevice->Handle,
- &gEfiDevicePathProtocolGuid, EmuDevice->DevicePath,
- &gEmuIoThunkProtocolGuid, &EmuDevice->EmuIoThunk,
+ &gEfiDevicePathProtocolGuid,
+ EmuDevice->DevicePath,
+ &gEmuIoThunkProtocolGuid,
+ &EmuDevice->EmuIoThunk,
NULL
);
if (EFI_ERROR (Status)) {
gBS->OpenProtocol (
- ControllerHandle,
- &gEmuThunkProtocolGuid,
- (VOID **) &EmuThunk ,
- This->DriverBindingHandle,
- EmuDevice->Handle,
- EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
- );
+ ControllerHandle,
+ &gEmuThunkProtocolGuid,
+ (VOID **)&EmuThunk,
+ This->DriverBindingHandle,
+ EmuDevice->Handle,
+ EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
+ );
} else {
//
// Close the child handle
@@ -437,7 +435,6 @@ EmuBusDriverBindingStop (
return EFI_SUCCESS;
}
-
/*++
Routine Description:
@@ -466,8 +463,8 @@ EmuBusCreateDevicePath (
{
EMU_VENDOR_DEVICE_PATH_NODE DevicePath;
- DevicePath.VendorDevicePath.Header.Type = HARDWARE_DEVICE_PATH;
- DevicePath.VendorDevicePath.Header.SubType = HW_VENDOR_DP;
+ DevicePath.VendorDevicePath.Header.Type = HARDWARE_DEVICE_PATH;
+ DevicePath.VendorDevicePath.Header.SubType = HW_VENDOR_DP;
SetDevicePathNodeLength (&DevicePath.VendorDevicePath.Header, sizeof (EMU_VENDOR_DEVICE_PATH_NODE));
//
@@ -482,13 +479,11 @@ EmuBusCreateDevicePath (
DevicePath.Instance = InstanceNumber;
return AppendDevicePathNode (
- RootDevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *) &DevicePath
- );
+ RootDevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&DevicePath
+ );
}
-
-
/**
The user Entry Point for module EmuBusDriver. The user code starts with this function.
@@ -502,11 +497,11 @@ EmuBusCreateDevicePath (
EFI_STATUS
EFIAPI
InitializeEmuBusDriver (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = EfiLibInstallAllDriverProtocols (
ImageHandle,
@@ -519,10 +514,5 @@ InitializeEmuBusDriver (
);
ASSERT_EFI_ERROR (Status);
-
return Status;
}
-
-
-
-
diff --git a/EmulatorPkg/EmuBusDriverDxe/EmuBusDriverDxe.h b/EmulatorPkg/EmuBusDriverDxe/EmuBusDriverDxe.h
index 632d706606..b9617a0bfa 100644
--- a/EmulatorPkg/EmuBusDriverDxe/EmuBusDriverDxe.h
+++ b/EmulatorPkg/EmuBusDriverDxe/EmuBusDriverDxe.h
@@ -25,19 +25,18 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/UefiBootServicesTableLib.h>
#include <Library/DevicePathLib.h>
-extern EFI_DRIVER_BINDING_PROTOCOL gEmuBusDriverBinding;
-extern EFI_COMPONENT_NAME_PROTOCOL gEmuBusDriverComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gEmuBusDriverComponentName2;
-
+extern EFI_DRIVER_BINDING_PROTOCOL gEmuBusDriverBinding;
+extern EFI_COMPONENT_NAME_PROTOCOL gEmuBusDriverComponentName;
+extern EFI_COMPONENT_NAME2_PROTOCOL gEmuBusDriverComponentName2;
//
// Unix Bus Controller Structure
//
-#define EMU_BUS_DEVICE_SIGNATURE SIGNATURE_32 ('L', 'X', 'B', 'D')
+#define EMU_BUS_DEVICE_SIGNATURE SIGNATURE_32 ('L', 'X', 'B', 'D')
typedef struct {
- UINT64 Signature;
- EFI_UNICODE_STRING_TABLE *ControllerNameTable;
+ UINT64 Signature;
+ EFI_UNICODE_STRING_TABLE *ControllerNameTable;
} EMU_BUS_DEVICE;
//
@@ -46,47 +45,42 @@ typedef struct {
#define EMU_IO_DEVICE_SIGNATURE SIGNATURE_32 ('L', 'X', 'V', 'D')
typedef struct {
- UINT64 Signature;
- EFI_HANDLE Handle;
- EMU_IO_THUNK_PROTOCOL EmuIoThunk;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ UINT64 Signature;
+ EFI_HANDLE Handle;
+ EMU_IO_THUNK_PROTOCOL EmuIoThunk;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
//
// Private data about the parent
//
- EFI_HANDLE ControllerHandle;
- EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
-
- EFI_UNICODE_STRING_TABLE *ControllerNameTable;
+ EFI_HANDLE ControllerHandle;
+ EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
+ EFI_UNICODE_STRING_TABLE *ControllerNameTable;
} EMU_IO_DEVICE;
#define EMU_IO_DEVICE_FROM_THIS(a) \
CR(a, EMU_IO_DEVICE, EmuIoThunk, EMU_IO_DEVICE_SIGNATURE)
-
-
//
// Driver Binding Protocol function prototypes
//
EFI_STATUS
EFIAPI
EmuBusDriverBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Handle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Handle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
);
-
EFI_STATUS
EFIAPI
EmuBusDriverBindingStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ParentHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ParentHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
);
-
EFI_STATUS
EFIAPI
EmuBusDriverBindingStop (
@@ -106,5 +100,4 @@ EmuBusCreateDevicePath (
IN UINT16 InstanceNumber
);
-
#endif
diff --git a/EmulatorPkg/EmuGopDxe/ComponentName.c b/EmulatorPkg/EmuGopDxe/ComponentName.c
index d096a2405f..b288c26a5b 100644
--- a/EmulatorPkg/EmuGopDxe/ComponentName.c
+++ b/EmulatorPkg/EmuGopDxe/ComponentName.c
@@ -28,17 +28,17 @@ EmuGopComponentNameGetDriverName (
EFI_STATUS
EFIAPI
EmuGopComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
);
//
// EFI Component Name Protocol
//
-EFI_COMPONENT_NAME_PROTOCOL gEmuGopComponentName = {
+EFI_COMPONENT_NAME_PROTOCOL gEmuGopComponentName = {
EmuGopComponentNameGetDriverName,
EmuGopComponentNameGetControllerName,
"eng"
@@ -47,19 +47,17 @@ EFI_COMPONENT_NAME_PROTOCOL gEmuGopComponentName = {
//
// EFI Component Name 2 Protocol
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuGopComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) EmuGopComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) EmuGopComponentNameGetControllerName,
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuGopComponentName2 = {
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)EmuGopComponentNameGetDriverName,
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)EmuGopComponentNameGetControllerName,
"en"
};
-
-EFI_UNICODE_STRING_TABLE mEmuGopDriverNameTable[] = {
+EFI_UNICODE_STRING_TABLE mEmuGopDriverNameTable[] = {
{ "eng", L"Emulator GOP Driver" },
- { NULL , NULL }
+ { NULL, NULL }
};
-
/**
Retrieves a Unicode string that is the user readable name of the driver.
@@ -116,7 +114,6 @@ EmuGopComponentNameGetDriverName (
);
}
-
/**
Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver.
@@ -188,11 +185,11 @@ EmuGopComponentNameGetDriverName (
EFI_STATUS
EFIAPI
EmuGopComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
)
{
EFI_STATUS Status;
@@ -217,6 +214,7 @@ EmuGopComponentNameGetControllerName (
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
+
//
// Get our context back
//
diff --git a/EmulatorPkg/EmuGopDxe/Gop.h b/EmulatorPkg/EmuGopDxe/Gop.h
index 3896663276..7f7dc4e8eb 100644
--- a/EmulatorPkg/EmuGopDxe/Gop.h
+++ b/EmulatorPkg/EmuGopDxe/Gop.h
@@ -29,78 +29,73 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/UefiBootServicesTableLib.h>
#include <Library/KeyMapLib.h>
-
-#define MAX_Q 256
+#define MAX_Q 256
typedef struct {
- UINTN Front;
- UINTN Rear;
- UINTN Count;
- EFI_INPUT_KEY Q[MAX_Q];
+ UINTN Front;
+ UINTN Rear;
+ UINTN Count;
+ EFI_INPUT_KEY Q[MAX_Q];
} GOP_QUEUE_FIXED;
-#define EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('U', 'g', 'S', 'n')
+#define EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('U', 'g', 'S', 'n')
typedef struct _EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY {
- UINTN Signature;
- EFI_HANDLE NotifyHandle;
- EFI_KEY_DATA KeyData;
- EFI_KEY_NOTIFY_FUNCTION KeyNotificationFn;
- EFI_EVENT Event;
- LIST_ENTRY NotifyEntry;
+ UINTN Signature;
+ EFI_HANDLE NotifyHandle;
+ EFI_KEY_DATA KeyData;
+ EFI_KEY_NOTIFY_FUNCTION KeyNotificationFn;
+ EFI_EVENT Event;
+ LIST_ENTRY NotifyEntry;
} EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY;
-#define GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER 0xffff
+#define GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER 0xffff
typedef struct {
- UINT32 HorizontalResolution;
- UINT32 VerticalResolution;
- UINT32 ColorDepth;
- UINT32 RefreshRate;
+ UINT32 HorizontalResolution;
+ UINT32 VerticalResolution;
+ UINT32 ColorDepth;
+ UINT32 RefreshRate;
} GOP_MODE_DATA;
+extern EFI_DRIVER_BINDING_PROTOCOL gEmuGopDriverBinding;
+extern EFI_COMPONENT_NAME_PROTOCOL gEmuGopComponentName;
-
-extern EFI_DRIVER_BINDING_PROTOCOL gEmuGopDriverBinding;
-extern EFI_COMPONENT_NAME_PROTOCOL gEmuGopComponentName;
-
-#define EMU_UGA_CLASS_NAME L"EmuGopWindow"
+#define EMU_UGA_CLASS_NAME L"EmuGopWindow"
#define GOP_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('G', 'o', 'p', 'N')
typedef struct {
- UINT64 Signature;
+ UINT64 Signature;
- EFI_HANDLE Handle;
- EFI_GRAPHICS_OUTPUT_PROTOCOL GraphicsOutput;
- EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleTextIn;
- EFI_SIMPLE_POINTER_PROTOCOL SimplePointer;
+ EFI_HANDLE Handle;
+ EFI_GRAPHICS_OUTPUT_PROTOCOL GraphicsOutput;
+ EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleTextIn;
+ EFI_SIMPLE_POINTER_PROTOCOL SimplePointer;
- EMU_IO_THUNK_PROTOCOL *EmuIoThunk;
- EMU_GRAPHICS_WINDOW_PROTOCOL *EmuGraphicsWindow;
+ EMU_IO_THUNK_PROTOCOL *EmuIoThunk;
+ EMU_GRAPHICS_WINDOW_PROTOCOL *EmuGraphicsWindow;
- EFI_UNICODE_STRING_TABLE *ControllerNameTable;
+ EFI_UNICODE_STRING_TABLE *ControllerNameTable;
- EFI_SIMPLE_POINTER_MODE PointerMode;
+ EFI_SIMPLE_POINTER_MODE PointerMode;
//
// GOP Private Data for QueryMode ()
//
- GOP_MODE_DATA *ModeData;
-
+ GOP_MODE_DATA *ModeData;
//
// UGA Private Data knowing when to start hardware
//
- BOOLEAN HardwareNeedsStarting;
+ BOOLEAN HardwareNeedsStarting;
- CHAR16 *WindowName;
+ CHAR16 *WindowName;
- GOP_QUEUE_FIXED Queue;
+ GOP_QUEUE_FIXED Queue;
- EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleTextInEx;
- EFI_KEY_STATE KeyState;
- LIST_ENTRY NotifyList;
+ EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleTextInEx;
+ EFI_KEY_STATE KeyState;
+ LIST_ENTRY NotifyList;
} GOP_PRIVATE_DATA;
-
#define GOP_PRIVATE_DATA_FROM_THIS(a) \
CR(a, GOP_PRIVATE_DATA, GraphicsOutput, GOP_PRIVATE_DATA_SIGNATURE)
@@ -113,13 +108,12 @@ typedef struct {
#define GOP_PRIVATE_DATA_FROM_POINTER_MODE_THIS(a) \
CR(a, GOP_PRIVATE_DATA, SimplePointer, GOP_PRIVATE_DATA_SIGNATURE)
-
//
// Global Protocol Variables
//
-extern EFI_DRIVER_BINDING_PROTOCOL gEmuGopDriverBinding;
-extern EFI_COMPONENT_NAME_PROTOCOL gEmuGopComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gEmuGopComponentName2;
+extern EFI_DRIVER_BINDING_PROTOCOL gEmuGopDriverBinding;
+extern EFI_COMPONENT_NAME_PROTOCOL gEmuGopComponentName;
+extern EFI_COMPONENT_NAME2_PROTOCOL gEmuGopComponentName2;
//
// Gop Hardware abstraction internal worker functions
@@ -131,38 +125,37 @@ EmuGopSupported (
EFI_STATUS
EmuGopConstructor (
- IN GOP_PRIVATE_DATA *Private
+ IN GOP_PRIVATE_DATA *Private
);
EFI_STATUS
EmuGopDestructor (
- IN GOP_PRIVATE_DATA *Private
+ IN GOP_PRIVATE_DATA *Private
);
-
EFI_STATUS
GopPrivateAddQ (
- IN GOP_PRIVATE_DATA *Private,
- IN EFI_INPUT_KEY Key
+ IN GOP_PRIVATE_DATA *Private,
+ IN EFI_INPUT_KEY Key
);
EFI_STATUS
EmuGopInitializeSimpleTextInForWindow (
- IN GOP_PRIVATE_DATA *Private
+ IN GOP_PRIVATE_DATA *Private
);
EFI_STATUS
EmuGopInitializeSimplePointerForWindow (
- IN GOP_PRIVATE_DATA *Private
+ IN GOP_PRIVATE_DATA *Private
);
EFI_STATUS
EmuGopStartWindow (
- IN GOP_PRIVATE_DATA *Private,
- IN UINT32 HorizontalResolution,
- IN UINT32 VerticalResolution,
- IN UINT32 ColorDepth,
- IN UINT32 RefreshRate
+ IN GOP_PRIVATE_DATA *Private,
+ IN UINT32 HorizontalResolution,
+ IN UINT32 VerticalResolution,
+ IN UINT32 ColorDepth,
+ IN UINT32 RefreshRate
);
VOID
@@ -175,15 +168,15 @@ ShutdownGopEvent (
VOID
EFIAPI
GopPrivateMakeCallbackFunction (
- IN VOID *Context,
- IN EFI_KEY_DATA *KeyData
+ IN VOID *Context,
+ IN EFI_KEY_DATA *KeyData
);
VOID
EFIAPI
GopPrivateBreakCallbackFunction (
- IN VOID *Context,
- IN EFI_KEY_DATA *KeyData
+ IN VOID *Context,
+ IN EFI_KEY_DATA *KeyData
);
#endif
diff --git a/EmulatorPkg/EmuGopDxe/GopDriver.c b/EmulatorPkg/EmuGopDxe/GopDriver.c
index d0215c33e7..4b716e35e1 100644
--- a/EmulatorPkg/EmuGopDxe/GopDriver.c
+++ b/EmulatorPkg/EmuGopDxe/GopDriver.c
@@ -9,11 +9,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "Gop.h"
-
EFI_STATUS
FreeNotifyList (
- IN OUT LIST_ENTRY *ListHead
+ IN OUT LIST_ENTRY *ListHead
)
+
/*++
Routine Description:
@@ -29,11 +29,12 @@ Returns:
**/
{
- EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *NotifyNode;
+ EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *NotifyNode;
if (ListHead == NULL) {
return EFI_INVALID_PARAMETER;
}
+
while (!IsListEmpty (ListHead)) {
NotifyNode = CR (
ListHead->ForwardLink,
@@ -48,7 +49,6 @@ Returns:
return EFI_SUCCESS;
}
-
/**
Tests to see if this driver supports a given controller. If a child device is provided,
it further tests to see if this driver supports creating a handle for the specified child device.
@@ -94,13 +94,13 @@ Returns:
EFI_STATUS
EFIAPI
EmuGopDriverBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Handle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Handle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- EFI_STATUS Status;
- EMU_IO_THUNK_PROTOCOL *EmuIoThunk;
+ EFI_STATUS Status;
+ EMU_IO_THUNK_PROTOCOL *EmuIoThunk;
//
// Open the IO Abstraction(s) needed to perform the supported test
@@ -123,16 +123,15 @@ EmuGopDriverBindingSupported (
// Close the I/O Abstraction(s) used to perform the supported test
//
gBS->CloseProtocol (
- Handle,
- &gEmuIoThunkProtocolGuid,
- This->DriverBindingHandle,
- Handle
- );
+ Handle,
+ &gEmuIoThunkProtocolGuid,
+ This->DriverBindingHandle,
+ Handle
+ );
return Status;
}
-
/**
Starts a device controller or a bus controller.
@@ -171,14 +170,14 @@ EmuGopDriverBindingSupported (
EFI_STATUS
EFIAPI
EmuGopDriverBindingStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Handle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Handle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- EMU_IO_THUNK_PROTOCOL *EmuIoThunk;
- EFI_STATUS Status;
- GOP_PRIVATE_DATA *Private;
+ EMU_IO_THUNK_PROTOCOL *EmuIoThunk;
+ EFI_STATUS Status;
+ GOP_PRIVATE_DATA *Private;
//
// Grab the protocols we need
@@ -199,14 +198,15 @@ EmuGopDriverBindingStart (
// Allocate Private context data for SGO inteface.
//
Private = NULL;
- Status = gBS->AllocatePool (
- EfiBootServicesData,
- sizeof (GOP_PRIVATE_DATA),
- (VOID **)&Private
- );
+ Status = gBS->AllocatePool (
+ EfiBootServicesData,
+ sizeof (GOP_PRIVATE_DATA),
+ (VOID **)&Private
+ );
if (EFI_ERROR (Status)) {
goto Done;
}
+
//
// Set up context record
//
@@ -234,27 +234,31 @@ EmuGopDriverBindingStart (
if (EFI_ERROR (Status)) {
goto Done;
}
+
//
// Publish the Gop interface to the world
//
Status = gBS->InstallMultipleProtocolInterfaces (
&Private->Handle,
- &gEfiGraphicsOutputProtocolGuid, &Private->GraphicsOutput,
- &gEfiSimpleTextInProtocolGuid, &Private->SimpleTextIn,
- &gEfiSimplePointerProtocolGuid, &Private->SimplePointer,
- &gEfiSimpleTextInputExProtocolGuid, &Private->SimpleTextInEx,
+ &gEfiGraphicsOutputProtocolGuid,
+ &Private->GraphicsOutput,
+ &gEfiSimpleTextInProtocolGuid,
+ &Private->SimpleTextIn,
+ &gEfiSimplePointerProtocolGuid,
+ &Private->SimplePointer,
+ &gEfiSimpleTextInputExProtocolGuid,
+ &Private->SimpleTextInEx,
NULL
);
Done:
if (EFI_ERROR (Status)) {
-
gBS->CloseProtocol (
- Handle,
- &gEmuIoThunkProtocolGuid,
- This->DriverBindingHandle,
- Handle
- );
+ Handle,
+ &gEmuIoThunkProtocolGuid,
+ This->DriverBindingHandle,
+ Handle
+ );
if (Private != NULL) {
//
@@ -263,12 +267,15 @@ Done:
if (Private->ControllerNameTable != NULL) {
FreeUnicodeStringTable (Private->ControllerNameTable);
}
+
if (Private->SimpleTextIn.WaitForKey != NULL) {
gBS->CloseEvent (Private->SimpleTextIn.WaitForKey);
}
+
if (Private->SimpleTextInEx.WaitForKeyEx != NULL) {
gBS->CloseEvent (Private->SimpleTextInEx.WaitForKeyEx);
}
+
FreeNotifyList (&Private->NotifyList);
gBS->FreePool (Private);
@@ -278,8 +285,6 @@ Done:
return Status;
}
-
-
/**
Stops a device controller or a bus controller.
@@ -315,9 +320,9 @@ EmuGopDriverBindingStop (
IN EFI_HANDLE *ChildHandleBuffer
)
{
- EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
- EFI_STATUS Status;
- GOP_PRIVATE_DATA *Private;
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
+ EFI_STATUS Status;
+ GOP_PRIVATE_DATA *Private;
Status = gBS->OpenProtocol (
Handle,
@@ -344,10 +349,14 @@ EmuGopDriverBindingStop (
//
Status = gBS->UninstallMultipleProtocolInterfaces (
Private->Handle,
- &gEfiGraphicsOutputProtocolGuid, &Private->GraphicsOutput,
- &gEfiSimpleTextInProtocolGuid, &Private->SimpleTextIn,
- &gEfiSimplePointerProtocolGuid, &Private->SimplePointer,
- &gEfiSimpleTextInputExProtocolGuid, &Private->SimpleTextInEx,
+ &gEfiGraphicsOutputProtocolGuid,
+ &Private->GraphicsOutput,
+ &gEfiSimpleTextInProtocolGuid,
+ &Private->SimpleTextIn,
+ &gEfiSimplePointerProtocolGuid,
+ &Private->SimplePointer,
+ &gEfiSimpleTextInputExProtocolGuid,
+ &Private->SimpleTextInEx,
NULL
);
if (!EFI_ERROR (Status)) {
@@ -360,11 +369,11 @@ EmuGopDriverBindingStop (
}
gBS->CloseProtocol (
- Handle,
- &gEmuIoThunkProtocolGuid,
- This->DriverBindingHandle,
- Handle
- );
+ Handle,
+ &gEmuIoThunkProtocolGuid,
+ This->DriverBindingHandle,
+ Handle
+ );
//
// Free our instance data
@@ -380,18 +389,16 @@ EmuGopDriverBindingStop (
FreeNotifyList (&Private->NotifyList);
gBS->FreePool (Private);
-
}
return Status;
}
-
///
/// This protocol provides the services required to determine if a driver supports a given controller.
/// If a controller is supported, then it also provides routines to start and stop the controller.
///
-EFI_DRIVER_BINDING_PROTOCOL gEmuGopDriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gEmuGopDriverBinding = {
EmuGopDriverBindingSupported,
EmuGopDriverBindingStart,
EmuGopDriverBindingStop,
@@ -400,8 +407,6 @@ EFI_DRIVER_BINDING_PROTOCOL gEmuGopDriverBinding = {
NULL
};
-
-
/**
The user Entry Point for module EmuGop. The user code starts with this function.
@@ -415,11 +420,11 @@ EFI_DRIVER_BINDING_PROTOCOL gEmuGopDriverBinding = {
EFI_STATUS
EFIAPI
InitializeEmuGop (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = EfiLibInstallDriverBindingComponentName2 (
ImageHandle,
@@ -431,7 +436,5 @@ InitializeEmuGop (
);
ASSERT_EFI_ERROR (Status);
-
return Status;
}
-
diff --git a/EmulatorPkg/EmuGopDxe/GopInput.c b/EmulatorPkg/EmuGopDxe/GopInput.c
index 2a23564a21..a48293912d 100644
--- a/EmulatorPkg/EmuGopDxe/GopInput.c
+++ b/EmulatorPkg/EmuGopDxe/GopInput.c
@@ -9,12 +9,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "Gop.h"
-
BOOLEAN
GopPrivateIsKeyRegistered (
IN EFI_KEY_DATA *RegsiteredData,
IN EFI_KEY_DATA *InputData
)
+
/*++
Routine Description:
@@ -35,37 +35,39 @@ Returns:
ASSERT (RegsiteredData != NULL && InputData != NULL);
if ((RegsiteredData->Key.ScanCode != InputData->Key.ScanCode) ||
- (RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar)) {
+ (RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar))
+ {
return FALSE;
}
//
// Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.
//
- if (RegsiteredData->KeyState.KeyShiftState != 0 &&
- RegsiteredData->KeyState.KeyShiftState != InputData->KeyState.KeyShiftState) {
+ if ((RegsiteredData->KeyState.KeyShiftState != 0) &&
+ (RegsiteredData->KeyState.KeyShiftState != InputData->KeyState.KeyShiftState))
+ {
return FALSE;
}
- if (RegsiteredData->KeyState.KeyToggleState != 0 &&
- RegsiteredData->KeyState.KeyToggleState != InputData->KeyState.KeyToggleState) {
+
+ if ((RegsiteredData->KeyState.KeyToggleState != 0) &&
+ (RegsiteredData->KeyState.KeyToggleState != InputData->KeyState.KeyToggleState))
+ {
return FALSE;
}
return TRUE;
-
}
-
VOID
EFIAPI
GopPrivateMakeCallbackFunction (
- IN VOID *Context,
- IN EFI_KEY_DATA *KeyData
+ IN VOID *Context,
+ IN EFI_KEY_DATA *KeyData
)
{
- LIST_ENTRY *Link;
+ LIST_ENTRY *Link;
EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *CurrentNotify;
- GOP_PRIVATE_DATA *Private = (GOP_PRIVATE_DATA *)Context;
+ GOP_PRIVATE_DATA *Private = (GOP_PRIVATE_DATA *)Context;
KeyMapMake (KeyData);
@@ -84,19 +86,16 @@ GopPrivateMakeCallbackFunction (
}
}
-
VOID
EFIAPI
GopPrivateBreakCallbackFunction (
- IN VOID *Context,
- IN EFI_KEY_DATA *KeyData
+ IN VOID *Context,
+ IN EFI_KEY_DATA *KeyData
)
{
KeyMapBreak (KeyData);
}
-
-
//
// Simple Text In implementation.
//
@@ -114,8 +113,8 @@ GopPrivateBreakCallbackFunction (
EFI_STATUS
EFIAPI
EmuGopSimpleTextInReset (
- IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
)
{
GOP_PRIVATE_DATA *Private;
@@ -135,8 +134,8 @@ EmuGopSimpleTextInReset (
//
// A reset is draining the Queue
//
- while (Private->EmuGraphicsWindow->GetKey (Private->EmuGraphicsWindow, &KeyData) == EFI_SUCCESS)
- ;
+ while (Private->EmuGraphicsWindow->GetKey (Private->EmuGraphicsWindow, &KeyData) == EFI_SUCCESS) {
+ }
//
// Leave critical section and return
@@ -145,7 +144,6 @@ EmuGopSimpleTextInReset (
return EFI_SUCCESS;
}
-
/**
Reads the next keystroke from the input device. The WaitForKey Event can
be used to test for existence of a keystroke via WaitForEvent () call.
@@ -163,8 +161,8 @@ EmuGopSimpleTextInReset (
EFI_STATUS
EFIAPI
EmuGopSimpleTextInReadKeyStroke (
- IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
- OUT EFI_INPUT_KEY *Key
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
+ OUT EFI_INPUT_KEY *Key
)
{
GOP_PRIVATE_DATA *Private;
@@ -180,9 +178,9 @@ EmuGopSimpleTextInReadKeyStroke (
//
// Enter critical section
//
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
+ OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
- Status = Private->EmuGraphicsWindow->GetKey (Private->EmuGraphicsWindow, &KeyData);
+ Status = Private->EmuGraphicsWindow->GetKey (Private->EmuGraphicsWindow, &KeyData);
if (!EFI_ERROR (Status)) {
if ((KeyData.Key.ScanCode == 0) && (KeyData.Key.UnicodeChar == 0)) {
// Modifier key was pressed
@@ -200,8 +198,6 @@ EmuGopSimpleTextInReadKeyStroke (
return Status;
}
-
-
/**
SimpleTextIn and SimpleTextInEx Notify Wait Event
@@ -212,15 +208,15 @@ EmuGopSimpleTextInReadKeyStroke (
VOID
EFIAPI
EmuGopSimpleTextInWaitForKey (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
GOP_PRIVATE_DATA *Private;
EFI_STATUS Status;
EFI_TPL OldTpl;
- Private = (GOP_PRIVATE_DATA *) Context;
+ Private = (GOP_PRIVATE_DATA *)Context;
if (Private->EmuGraphicsWindow == NULL) {
return;
}
@@ -228,27 +224,26 @@ EmuGopSimpleTextInWaitForKey (
//
// Enter critical section
//
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
+ OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
- Status = Private->EmuGraphicsWindow->CheckKey (Private->EmuGraphicsWindow);
+ Status = Private->EmuGraphicsWindow->CheckKey (Private->EmuGraphicsWindow);
if (!EFI_ERROR (Status)) {
//
// If a there is a key in the queue signal our event.
//
gBS->SignalEvent (Event);
}
+
//
// Leave critical section and return
//
gBS->RestoreTPL (OldTpl);
}
-
//
// Simple Text Input Ex protocol functions
//
-
/**
The Reset() function resets the input device hardware. As part
of initialization process, the firmware/device will make a quick
@@ -280,6 +275,7 @@ EmuGopSimpleTextInExResetEx (
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
IN BOOLEAN ExtendedVerification
)
+
/*++
Routine Description:
@@ -297,8 +293,6 @@ EmuGopSimpleTextInExResetEx (
return EFI_SUCCESS;
}
-
-
/**
The function reads the next keystroke from the input device. If
there is no pending keystroke the function returns
@@ -351,9 +345,10 @@ EmuGopSimpleTextInExResetEx (
EFI_STATUS
EFIAPI
EmuGopSimpleTextInExReadKeyStrokeEx (
- IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
- OUT EFI_KEY_DATA *KeyData
+ IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
+ OUT EFI_KEY_DATA *KeyData
)
+
/*++
Routine Description:
@@ -378,7 +373,6 @@ EmuGopSimpleTextInExReadKeyStrokeEx (
GOP_PRIVATE_DATA *Private;
EFI_TPL OldTpl;
-
if (KeyData == NULL) {
return EFI_INVALID_PARAMETER;
}
@@ -391,9 +385,9 @@ EmuGopSimpleTextInExReadKeyStrokeEx (
//
// Enter critical section
//
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
+ OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
- Status = Private->EmuGraphicsWindow->GetKey(Private->EmuGraphicsWindow, KeyData);
+ Status = Private->EmuGraphicsWindow->GetKey (Private->EmuGraphicsWindow, KeyData);
//
// Leave critical section and return
@@ -403,8 +397,6 @@ EmuGopSimpleTextInExReadKeyStrokeEx (
return Status;
}
-
-
/**
The SetState() function allows the input device hardware to
have state settings adjusted.
@@ -446,16 +438,17 @@ EmuGopSimpleTextInExSetState (
}
if (((Private->KeyState.KeyToggleState & EFI_TOGGLE_STATE_VALID) != EFI_TOGGLE_STATE_VALID) ||
- ((*KeyToggleState & EFI_TOGGLE_STATE_VALID) != EFI_TOGGLE_STATE_VALID)) {
+ ((*KeyToggleState & EFI_TOGGLE_STATE_VALID) != EFI_TOGGLE_STATE_VALID))
+ {
return EFI_UNSUPPORTED;
}
//
// Enter critical section
//
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
+ OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
- Status = Private->EmuGraphicsWindow->KeySetState (Private->EmuGraphicsWindow, KeyToggleState);
+ Status = Private->EmuGraphicsWindow->KeySetState (Private->EmuGraphicsWindow, KeyToggleState);
//
// Leave critical section and return
//
@@ -464,7 +457,6 @@ EmuGopSimpleTextInExSetState (
return Status;
}
-
/**
SimpleTextIn and SimpleTextInEx Notify Wait Event
@@ -475,17 +467,15 @@ EmuGopSimpleTextInExSetState (
VOID
EFIAPI
EmuGopRegisterKeyCallback (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *ExNotify = (EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *)Context;
+ EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *ExNotify = (EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *)Context;
ExNotify->KeyNotificationFn (&ExNotify->KeyData);
}
-
-
/**
The RegisterKeystrokeNotify() function registers a function
which will be called when a specified keystroke will occur.
@@ -520,13 +510,13 @@ EmuGopSimpleTextInExRegisterKeyNotify (
OUT VOID **NotifyHandle
)
{
- EFI_STATUS Status;
- GOP_PRIVATE_DATA *Private;
- EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *CurrentNotify;
- LIST_ENTRY *Link;
- EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *NewNotify;
+ EFI_STATUS Status;
+ GOP_PRIVATE_DATA *Private;
+ EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *CurrentNotify;
+ LIST_ENTRY *Link;
+ EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *NewNotify;
- if (KeyData == NULL || KeyNotificationFunction == NULL || NotifyHandle == NULL) {
+ if ((KeyData == NULL) || (KeyNotificationFunction == NULL) || (NotifyHandle == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -553,14 +543,14 @@ EmuGopSimpleTextInExRegisterKeyNotify (
//
// Allocate resource to save the notification function
//
- NewNotify = (EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *) AllocateZeroPool (sizeof (EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY));
+ NewNotify = (EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *)AllocateZeroPool (sizeof (EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY));
if (NewNotify == NULL) {
return EFI_OUT_OF_RESOURCES;
}
NewNotify->Signature = EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE;
NewNotify->KeyNotificationFn = KeyNotificationFunction;
- NewNotify->NotifyHandle = (EFI_HANDLE) NewNotify;
+ NewNotify->NotifyHandle = (EFI_HANDLE)NewNotify;
CopyMem (&NewNotify->KeyData, KeyData, sizeof (KeyData));
InsertTailList (&Private->NotifyList, &NewNotify->NotifyEntry);
@@ -573,14 +563,11 @@ EmuGopSimpleTextInExRegisterKeyNotify (
);
ASSERT_EFI_ERROR (Status);
-
*NotifyHandle = NewNotify->NotifyHandle;
return EFI_SUCCESS;
-
}
-
/**
The UnregisterKeystrokeNotify() function removes the
notification which was previously registered.
@@ -602,6 +589,7 @@ EmuGopSimpleTextInExUnregisterKeyNotify (
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
IN VOID *NotificationHandle
)
+
/*++
Routine Description:
@@ -617,15 +605,15 @@ EmuGopSimpleTextInExUnregisterKeyNotify (
**/
{
- GOP_PRIVATE_DATA *Private;
- LIST_ENTRY *Link;
- EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *CurrentNotify;
+ GOP_PRIVATE_DATA *Private;
+ LIST_ENTRY *Link;
+ EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *CurrentNotify;
if (NotificationHandle == NULL) {
return EFI_INVALID_PARAMETER;
}
- if (((EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *) NotificationHandle)->Signature != EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE) {
+ if (((EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *)NotificationHandle)->Signature != EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE) {
return EFI_INVALID_PARAMETER;
}
@@ -657,8 +645,6 @@ EmuGopSimpleTextInExUnregisterKeyNotify (
return EFI_INVALID_PARAMETER;
}
-
-
/**
Initialize SimplelTextIn and SimpleTextInEx protocols in the Private
context structure.
@@ -670,7 +656,7 @@ EmuGopSimpleTextInExUnregisterKeyNotify (
**/
EFI_STATUS
EmuGopInitializeSimpleTextInForWindow (
- IN GOP_PRIVATE_DATA *Private
+ IN GOP_PRIVATE_DATA *Private
)
{
EFI_STATUS Status;
@@ -690,7 +676,6 @@ EmuGopInitializeSimpleTextInForWindow (
);
ASSERT_EFI_ERROR (Status);
-
//
// Initialize Simple Text In Ex
//
@@ -714,21 +699,13 @@ EmuGopInitializeSimpleTextInForWindow (
);
ASSERT_EFI_ERROR (Status);
-
return Status;
}
-
-
-
-
-
-
//
// Simple Pointer implementation.
//
-
/**
Resets the pointer device hardware.
@@ -744,13 +721,13 @@ EmuGopInitializeSimpleTextInForWindow (
EFI_STATUS
EFIAPI
EmuGopSimplePointerReset (
- IN EFI_SIMPLE_POINTER_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EFI_SIMPLE_POINTER_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
)
{
- GOP_PRIVATE_DATA *Private;
- EFI_SIMPLE_POINTER_STATE State;
- EFI_TPL OldTpl;
+ GOP_PRIVATE_DATA *Private;
+ EFI_SIMPLE_POINTER_STATE State;
+ EFI_TPL OldTpl;
Private = GOP_PRIVATE_DATA_FROM_POINTER_MODE_THIS (This);
if (Private->EmuGraphicsWindow == NULL) {
@@ -765,8 +742,8 @@ EmuGopSimplePointerReset (
//
// A reset is draining the Queue
//
- while (Private->EmuGraphicsWindow->GetPointerState (Private->EmuGraphicsWindow, &State) == EFI_SUCCESS)
- ;
+ while (Private->EmuGraphicsWindow->GetPointerState (Private->EmuGraphicsWindow, &State) == EFI_SUCCESS) {
+ }
//
// Leave critical section and return
@@ -775,7 +752,6 @@ EmuGopSimplePointerReset (
return EFI_SUCCESS;
}
-
/**
Retrieves the current state of a pointer device.
@@ -793,8 +769,8 @@ EmuGopSimplePointerReset (
EFI_STATUS
EFIAPI
EmuGopSimplePointerGetState (
- IN EFI_SIMPLE_POINTER_PROTOCOL *This,
- IN OUT EFI_SIMPLE_POINTER_STATE *State
+ IN EFI_SIMPLE_POINTER_PROTOCOL *This,
+ IN OUT EFI_SIMPLE_POINTER_STATE *State
)
{
GOP_PRIVATE_DATA *Private;
@@ -809,9 +785,9 @@ EmuGopSimplePointerGetState (
//
// Enter critical section
//
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
+ OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
- Status = Private->EmuGraphicsWindow->GetPointerState (Private->EmuGraphicsWindow, State);
+ Status = Private->EmuGraphicsWindow->GetPointerState (Private->EmuGraphicsWindow, State);
//
// Leave critical section and return
//
@@ -820,7 +796,6 @@ EmuGopSimplePointerGetState (
return Status;
}
-
/**
SimplePointer Notify Wait Event
@@ -831,15 +806,15 @@ EmuGopSimplePointerGetState (
VOID
EFIAPI
EmuGopSimplePointerWaitForInput (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
GOP_PRIVATE_DATA *Private;
EFI_STATUS Status;
EFI_TPL OldTpl;
- Private = (GOP_PRIVATE_DATA *) Context;
+ Private = (GOP_PRIVATE_DATA *)Context;
if (Private->EmuGraphicsWindow == NULL) {
return;
}
@@ -847,22 +822,22 @@ EmuGopSimplePointerWaitForInput (
//
// Enter critical section
//
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
+ OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
- Status = Private->EmuGraphicsWindow->CheckPointer (Private->EmuGraphicsWindow);
+ Status = Private->EmuGraphicsWindow->CheckPointer (Private->EmuGraphicsWindow);
if (!EFI_ERROR (Status)) {
//
// If the pointer state has changed, signal our event.
//
gBS->SignalEvent (Event);
}
+
//
// Leave critical section and return
//
gBS->RestoreTPL (OldTpl);
}
-
/**
SimplePointer constructor
@@ -873,7 +848,7 @@ EmuGopSimplePointerWaitForInput (
**/
EFI_STATUS
EmuGopInitializeSimplePointerForWindow (
- IN GOP_PRIVATE_DATA *Private
+ IN GOP_PRIVATE_DATA *Private
)
{
EFI_STATUS Status;
@@ -887,9 +862,9 @@ EmuGopInitializeSimplePointerForWindow (
Private->PointerMode.LeftButton = TRUE;
Private->PointerMode.RightButton = TRUE;
- Private->SimplePointer.Reset = EmuGopSimplePointerReset;
- Private->SimplePointer.GetState = EmuGopSimplePointerGetState;
- Private->SimplePointer.Mode = &Private->PointerMode;
+ Private->SimplePointer.Reset = EmuGopSimplePointerReset;
+ Private->SimplePointer.GetState = EmuGopSimplePointerGetState;
+ Private->SimplePointer.Mode = &Private->PointerMode;
Status = gBS->CreateEvent (
EVT_NOTIFY_WAIT,
diff --git a/EmulatorPkg/EmuGopDxe/GopScreen.c b/EmulatorPkg/EmuGopDxe/GopScreen.c
index 05fd236151..41f748bc64 100644
--- a/EmulatorPkg/EmuGopDxe/GopScreen.c
+++ b/EmulatorPkg/EmuGopDxe/GopScreen.c
@@ -18,17 +18,15 @@ Abstract:
#include "Gop.h"
+EFI_EVENT mGopScreenExitBootServicesEvent;
-EFI_EVENT mGopScreenExitBootServicesEvent;
-
-GOP_MODE_DATA mGopModeData[] = {
- { 800, 600, 0, 0 },
- { 640, 480, 0, 0 },
- { 720, 400, 0, 0 },
- {1024, 768, 0, 0 },
- {1280, 1024, 0, 0 }
- };
-
+GOP_MODE_DATA mGopModeData[] = {
+ { 800, 600, 0, 0 },
+ { 640, 480, 0, 0 },
+ { 720, 400, 0, 0 },
+ { 1024, 768, 0, 0 },
+ { 1280, 1024, 0, 0 }
+};
/**
Returns information for an available graphics mode that the graphics device
@@ -59,7 +57,7 @@ EmuGopQuerytMode (
Private = GOP_PRIVATE_DATA_FROM_THIS (This);
- if (Info == NULL || SizeOfInfo == NULL || (UINTN) ModeNumber >= This->Mode->MaxMode) {
+ if ((Info == NULL) || (SizeOfInfo == NULL) || ((UINTN)ModeNumber >= This->Mode->MaxMode)) {
return EFI_INVALID_PARAMETER;
}
@@ -70,17 +68,15 @@ EmuGopQuerytMode (
*SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
- (*Info)->Version = 0;
+ (*Info)->Version = 0;
(*Info)->HorizontalResolution = Private->ModeData[ModeNumber].HorizontalResolution;
(*Info)->VerticalResolution = Private->ModeData[ModeNumber].VerticalResolution;
- (*Info)->PixelFormat = PixelBltOnly;
- (*Info)->PixelsPerScanLine = (*Info)->HorizontalResolution;
+ (*Info)->PixelFormat = PixelBltOnly;
+ (*Info)->PixelsPerScanLine = (*Info)->HorizontalResolution;
return EFI_SUCCESS;
}
-
-
/**
Set the video device into the specified mode and clears the visible portions of
the output display to black.
@@ -100,10 +96,10 @@ EmuGopSetMode (
IN UINT32 ModeNumber
)
{
- EFI_STATUS Status;
- GOP_PRIVATE_DATA *Private;
- GOP_MODE_DATA *ModeData;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL Fill;
+ EFI_STATUS Status;
+ GOP_PRIVATE_DATA *Private;
+ GOP_MODE_DATA *ModeData;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL Fill;
Private = GOP_PRIVATE_DATA_FROM_THIS (This);
@@ -111,20 +107,20 @@ EmuGopSetMode (
return EFI_UNSUPPORTED;
}
- ModeData = &Private->ModeData[ModeNumber];
- This->Mode->Mode = ModeNumber;
+ ModeData = &Private->ModeData[ModeNumber];
+ This->Mode->Mode = ModeNumber;
Private->GraphicsOutput.Mode->Info->HorizontalResolution = ModeData->HorizontalResolution;
- Private->GraphicsOutput.Mode->Info->VerticalResolution = ModeData->VerticalResolution;
- Private->GraphicsOutput.Mode->Info->PixelsPerScanLine = ModeData->HorizontalResolution;
+ Private->GraphicsOutput.Mode->Info->VerticalResolution = ModeData->VerticalResolution;
+ Private->GraphicsOutput.Mode->Info->PixelsPerScanLine = ModeData->HorizontalResolution;
if (Private->HardwareNeedsStarting) {
Status = EmuGopStartWindow (
- Private,
- ModeData->HorizontalResolution,
- ModeData->VerticalResolution,
- ModeData->ColorDepth,
- ModeData->RefreshRate
- );
+ Private,
+ ModeData->HorizontalResolution,
+ ModeData->VerticalResolution,
+ ModeData->ColorDepth,
+ ModeData->RefreshRate
+ );
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
@@ -132,13 +128,11 @@ EmuGopSetMode (
Private->HardwareNeedsStarting = FALSE;
}
-
- Status = Private->EmuGraphicsWindow->Size(
- Private->EmuGraphicsWindow,
- ModeData->HorizontalResolution,
- ModeData->VerticalResolution
- );
-
+ Status = Private->EmuGraphicsWindow->Size (
+ Private->EmuGraphicsWindow,
+ ModeData->HorizontalResolution,
+ ModeData->VerticalResolution
+ );
Fill.Red = 0;
Fill.Green = 0;
@@ -158,8 +152,6 @@ EmuGopSetMode (
return EFI_SUCCESS;
}
-
-
/**
Blt a rectangle of pixels on the graphics screen. Blt stands for BLock Transfer.
@@ -183,22 +175,22 @@ EmuGopSetMode (
EFI_STATUS
EFIAPI
EmuGopBlt (
- IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
- IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer OPTIONAL,
- IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,
- IN UINTN SourceX,
- IN UINTN SourceY,
- IN UINTN DestinationX,
- IN UINTN DestinationY,
- IN UINTN Width,
- IN UINTN Height,
- IN UINTN Delta OPTIONAL
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer OPTIONAL,
+ IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,
+ IN UINTN SourceX,
+ IN UINTN SourceY,
+ IN UINTN DestinationX,
+ IN UINTN DestinationY,
+ IN UINTN Width,
+ IN UINTN Height,
+ IN UINTN Delta OPTIONAL
)
{
- GOP_PRIVATE_DATA *Private;
- EFI_TPL OriginalTPL;
- EFI_STATUS Status;
- EMU_GRAPHICS_WINDOWS__BLT_ARGS GopBltArgs;
+ GOP_PRIVATE_DATA *Private;
+ EFI_TPL OriginalTPL;
+ EFI_STATUS Status;
+ EMU_GRAPHICS_WINDOWS__BLT_ARGS GopBltArgs;
Private = GOP_PRIVATE_DATA_FROM_THIS (This);
@@ -206,9 +198,10 @@ EmuGopBlt (
return EFI_INVALID_PARAMETER;
}
- if (Width == 0 || Height == 0) {
+ if ((Width == 0) || (Height == 0)) {
return EFI_INVALID_PARAMETER;
}
+
//
// If Delta is zero, then the entire BltBuffer is being used, so Delta
// is the number of bytes in each row of BltBuffer. Since BltBuffer is Width pixels size,
@@ -236,19 +229,18 @@ EmuGopBlt (
GopBltArgs.SourceX = SourceX;
GopBltArgs.SourceY = SourceY;
GopBltArgs.Delta = Delta;
- Status = Private->EmuGraphicsWindow->Blt (
- Private->EmuGraphicsWindow,
- (EFI_UGA_PIXEL *)BltBuffer,
- (EFI_UGA_BLT_OPERATION)BltOperation,
- &GopBltArgs
- );
+ Status = Private->EmuGraphicsWindow->Blt (
+ Private->EmuGraphicsWindow,
+ (EFI_UGA_PIXEL *)BltBuffer,
+ (EFI_UGA_BLT_OPERATION)BltOperation,
+ &GopBltArgs
+ );
gBS->RestoreTPL (OriginalTPL);
return Status;
}
-
//
// Construction and Destruction functions
//
@@ -270,17 +262,16 @@ EmuGopSupported (
return EFI_SUCCESS;
}
-
EFI_STATUS
EmuGopStartWindow (
- IN GOP_PRIVATE_DATA *Private,
- IN UINT32 HorizontalResolution,
- IN UINT32 VerticalResolution,
- IN UINT32 ColorDepth,
- IN UINT32 RefreshRate
+ IN GOP_PRIVATE_DATA *Private,
+ IN UINT32 HorizontalResolution,
+ IN UINT32 VerticalResolution,
+ IN UINT32 ColorDepth,
+ IN UINT32 RefreshRate
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Register to be notified on exit boot services so we can destroy the window.
@@ -298,27 +289,28 @@ EmuGopStartWindow (
Private->EmuGraphicsWindow = Private->EmuIoThunk->Interface;
// Register callback to support RegisterKeyNotify()
- Status = Private->EmuGraphicsWindow->RegisterKeyNotify (
- Private->EmuGraphicsWindow,
- GopPrivateMakeCallbackFunction,
- GopPrivateBreakCallbackFunction,
- Private
- );
+ Status = Private->EmuGraphicsWindow->RegisterKeyNotify (
+ Private->EmuGraphicsWindow,
+ GopPrivateMakeCallbackFunction,
+ GopPrivateBreakCallbackFunction,
+ Private
+ );
ASSERT_EFI_ERROR (Status);
}
+
return Status;
}
EFI_STATUS
EmuGopConstructor (
- GOP_PRIVATE_DATA *Private
+ GOP_PRIVATE_DATA *Private
)
{
Private->ModeData = mGopModeData;
- Private->GraphicsOutput.QueryMode = EmuGopQuerytMode;
- Private->GraphicsOutput.SetMode = EmuGopSetMode;
- Private->GraphicsOutput.Blt = EmuGopBlt;
+ Private->GraphicsOutput.QueryMode = EmuGopQuerytMode;
+ Private->GraphicsOutput.SetMode = EmuGopSetMode;
+ Private->GraphicsOutput.Blt = EmuGopBlt;
//
// Allocate buffer for Graphics Output Protocol mode information
@@ -327,26 +319,27 @@ EmuGopConstructor (
if (Private->GraphicsOutput.Mode == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
Private->GraphicsOutput.Mode->Info = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));
if (Private->GraphicsOutput.Mode->Info == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- Private->GraphicsOutput.Mode->MaxMode = sizeof(mGopModeData) / sizeof(GOP_MODE_DATA);
+ Private->GraphicsOutput.Mode->MaxMode = sizeof (mGopModeData) / sizeof (GOP_MODE_DATA);
//
// Till now, we have no idea about the window size.
//
- Private->GraphicsOutput.Mode->Mode = GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER;
- Private->GraphicsOutput.Mode->Info->Version = 0;
+ Private->GraphicsOutput.Mode->Mode = GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER;
+ Private->GraphicsOutput.Mode->Info->Version = 0;
Private->GraphicsOutput.Mode->Info->HorizontalResolution = 0;
- Private->GraphicsOutput.Mode->Info->VerticalResolution = 0;
- Private->GraphicsOutput.Mode->Info->PixelFormat = PixelBltOnly;
- Private->GraphicsOutput.Mode->SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
- Private->GraphicsOutput.Mode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS) (UINTN) NULL;
- Private->GraphicsOutput.Mode->FrameBufferSize = 0;
+ Private->GraphicsOutput.Mode->Info->VerticalResolution = 0;
+ Private->GraphicsOutput.Mode->Info->PixelFormat = PixelBltOnly;
+ Private->GraphicsOutput.Mode->SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
+ Private->GraphicsOutput.Mode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS)(UINTN)NULL;
+ Private->GraphicsOutput.Mode->FrameBufferSize = 0;
- Private->HardwareNeedsStarting = TRUE;
- Private->EmuGraphicsWindow = NULL;
+ Private->HardwareNeedsStarting = TRUE;
+ Private->EmuGraphicsWindow = NULL;
EmuGopInitializeSimpleTextInForWindow (Private);
@@ -355,11 +348,9 @@ EmuGopConstructor (
return EFI_SUCCESS;
}
-
-
EFI_STATUS
EmuGopDestructor (
- GOP_PRIVATE_DATA *Private
+ GOP_PRIVATE_DATA *Private
)
{
if (!Private->HardwareNeedsStarting) {
@@ -374,19 +365,20 @@ EmuGopDestructor (
if (Private->GraphicsOutput.Mode->Info != NULL) {
FreePool (Private->GraphicsOutput.Mode->Info);
}
+
FreePool (Private->GraphicsOutput.Mode);
}
return EFI_SUCCESS;
}
-
VOID
EFIAPI
ShutdownGopEvent (
IN EFI_EVENT Event,
IN VOID *Context
)
+
/*++
Routine Description:
diff --git a/EmulatorPkg/EmuSimpleFileSystemDxe/ComponentName.c b/EmulatorPkg/EmuSimpleFileSystemDxe/ComponentName.c
index b8a3cd14b7..188ee8dd32 100644
--- a/EmulatorPkg/EmuSimpleFileSystemDxe/ComponentName.c
+++ b/EmulatorPkg/EmuSimpleFileSystemDxe/ComponentName.c
@@ -21,11 +21,11 @@ EmuSimpleFileSystemComponentNameGetDriverName (
EFI_STATUS
EFIAPI
EmuSimpleFileSystemComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
);
//
@@ -43,7 +43,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuSimpleFileSystem
"en"
};
-EFI_UNICODE_STRING_TABLE mEmuSimpleFileSystemDriverNameTable[] = {
+EFI_UNICODE_STRING_TABLE mEmuSimpleFileSystemDriverNameTable[] = {
{
"eng;en",
L"Emu Simple File System Driver"
@@ -102,15 +102,14 @@ EmuSimpleFileSystemComponentNameGetDriverName (
)
{
return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- mEmuSimpleFileSystemDriverNameTable,
- DriverName,
- (BOOLEAN)(This == &gEmuSimpleFileSystemComponentName)
- );
+ Language,
+ This->SupportedLanguages,
+ mEmuSimpleFileSystemDriverNameTable,
+ DriverName,
+ (BOOLEAN)(This == &gEmuSimpleFileSystemComponentName)
+ );
}
-
/**
Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver.
@@ -182,16 +181,16 @@ EmuSimpleFileSystemComponentNameGetDriverName (
EFI_STATUS
EFIAPI
EmuSimpleFileSystemComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
)
{
- EFI_STATUS Status;
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem;
- EMU_SIMPLE_FILE_SYSTEM_PRIVATE *Private;
+ EFI_STATUS Status;
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem;
+ EMU_SIMPLE_FILE_SYSTEM_PRIVATE *Private;
//
// This is a device driver, so ChildHandle must be NULL.
@@ -211,13 +210,14 @@ EmuSimpleFileSystemComponentNameGetControllerName (
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
+
//
// Get our context back
//
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiSimpleFileSystemProtocolGuid,
- (VOID**)&SimpleFileSystem,
+ (VOID **)&SimpleFileSystem,
gEmuSimpleFileSystemDriverBinding.DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -229,10 +229,10 @@ EmuSimpleFileSystemComponentNameGetControllerName (
Private = EMU_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (SimpleFileSystem);
return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- Private->ControllerNameTable,
- ControllerName,
- (BOOLEAN)(This == &gEmuSimpleFileSystemComponentName)
- );
+ Language,
+ This->SupportedLanguages,
+ Private->ControllerNameTable,
+ ControllerName,
+ (BOOLEAN)(This == &gEmuSimpleFileSystemComponentName)
+ );
}
diff --git a/EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c b/EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c
index 6cea25b140..42cd3fcf94 100644
--- a/EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c
+++ b/EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c
@@ -12,9 +12,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "EmuSimpleFileSystem.h"
-
-
-
/**
Opens a new file relative to the source file's location.
@@ -38,44 +35,44 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
EFI_STATUS
EFIAPI
EmuSimpleFileSystemOpen (
- IN EFI_FILE_PROTOCOL *This,
- OUT EFI_FILE_PROTOCOL **NewHandle,
- IN CHAR16 *FileName,
- IN UINT64 OpenMode,
- IN UINT64 Attributes
+ IN EFI_FILE_PROTOCOL *This,
+ OUT EFI_FILE_PROTOCOL **NewHandle,
+ IN CHAR16 *FileName,
+ IN UINT64 OpenMode,
+ IN UINT64 Attributes
)
{
- EFI_STATUS Status;
- EFI_TPL OldTpl;
- EMU_EFI_FILE_PRIVATE *PrivateFile;
- EMU_EFI_FILE_PRIVATE *NewPrivateFile;
+ EFI_STATUS Status;
+ EFI_TPL OldTpl;
+ EMU_EFI_FILE_PRIVATE *PrivateFile;
+ EMU_EFI_FILE_PRIVATE *NewPrivateFile;
//
// Check for obvious invalid parameters.
//
- if (This == NULL || NewHandle == NULL || FileName == NULL) {
+ if ((This == NULL) || (NewHandle == NULL) || (FileName == NULL)) {
return EFI_INVALID_PARAMETER;
}
switch (OpenMode) {
- case EFI_FILE_MODE_CREATE | EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE:
- if (Attributes &~EFI_FILE_VALID_ATTR) {
- return EFI_INVALID_PARAMETER;
- }
+ case EFI_FILE_MODE_CREATE | EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE:
+ if (Attributes &~EFI_FILE_VALID_ATTR) {
+ return EFI_INVALID_PARAMETER;
+ }
- if (Attributes & EFI_FILE_READ_ONLY) {
- return EFI_INVALID_PARAMETER;
- }
+ if (Attributes & EFI_FILE_READ_ONLY) {
+ return EFI_INVALID_PARAMETER;
+ }
- //
- // fall through
- //
- case EFI_FILE_MODE_READ:
- case EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE:
- break;
+ //
+ // fall through
+ //
+ case EFI_FILE_MODE_READ:
+ case EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE:
+ break;
- default:
- return EFI_INVALID_PARAMETER;
+ default:
+ return EFI_INVALID_PARAMETER;
}
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
@@ -88,7 +85,6 @@ EmuSimpleFileSystemOpen (
goto Done;
}
-
Status = PrivateFile->Io->Open (PrivateFile->Io, &NewPrivateFile->Io, FileName, OpenMode, Attributes);
if (!EFI_ERROR (Status)) {
*NewHandle = &NewPrivateFile->EfiFile;
@@ -103,8 +99,6 @@ Done:
return Status;
}
-
-
/**
Close the file handle
@@ -119,9 +113,9 @@ EmuSimpleFileSystemClose (
IN EFI_FILE_PROTOCOL *This
)
{
- EFI_STATUS Status;
- EMU_EFI_FILE_PRIVATE *PrivateFile;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ EMU_EFI_FILE_PRIVATE *PrivateFile;
+ EFI_TPL OldTpl;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
@@ -141,7 +135,6 @@ EmuSimpleFileSystemClose (
return Status;
}
-
/**
Close and delete the file handle.
@@ -157,9 +150,9 @@ EmuSimpleFileSystemDelete (
IN EFI_FILE_PROTOCOL *This
)
{
- EFI_STATUS Status;
- EMU_EFI_FILE_PRIVATE *PrivateFile;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ EMU_EFI_FILE_PRIVATE *PrivateFile;
+ EFI_TPL OldTpl;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
@@ -179,7 +172,6 @@ EmuSimpleFileSystemDelete (
return Status;
}
-
/**
Read data from the file.
@@ -202,11 +194,11 @@ EmuSimpleFileSystemRead (
OUT VOID *Buffer
)
{
- EFI_STATUS Status;
- EMU_EFI_FILE_PRIVATE *PrivateFile;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ EMU_EFI_FILE_PRIVATE *PrivateFile;
+ EFI_TPL OldTpl;
- if (This == NULL || BufferSize == NULL) {
+ if ((This == NULL) || (BufferSize == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -225,7 +217,6 @@ EmuSimpleFileSystemRead (
return Status;
}
-
/**
Write data to a file.
@@ -253,10 +244,10 @@ EmuSimpleFileSystemWrite (
)
{
EFI_STATUS Status;
- EMU_EFI_FILE_PRIVATE *PrivateFile;
+ EMU_EFI_FILE_PRIVATE *PrivateFile;
EFI_TPL OldTpl;
- if (This == NULL || BufferSize == NULL || Buffer == NULL) {
+ if ((This == NULL) || (BufferSize == NULL) || (Buffer == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -270,7 +261,6 @@ EmuSimpleFileSystemWrite (
return Status;
}
-
/**
Get a file's current position
@@ -284,21 +274,21 @@ EmuSimpleFileSystemWrite (
EFI_STATUS
EFIAPI
EmuSimpleFileSystemGetPosition (
- IN EFI_FILE_PROTOCOL *This,
- OUT UINT64 *Position
+ IN EFI_FILE_PROTOCOL *This,
+ OUT UINT64 *Position
)
{
EFI_STATUS Status;
- EMU_EFI_FILE_PRIVATE *PrivateFile;
+ EMU_EFI_FILE_PRIVATE *PrivateFile;
EFI_TPL OldTpl;
- if (This == NULL || Position == NULL) {
+ if ((This == NULL) || (Position == NULL)) {
return EFI_INVALID_PARAMETER;
}
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
- PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
+ PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
Status = PrivateFile->Io->GetPosition (PrivateFile->Io, Position);
@@ -306,8 +296,6 @@ EmuSimpleFileSystemGetPosition (
return Status;
}
-
-
/**
Set file's current position
@@ -325,9 +313,9 @@ EmuSimpleFileSystemSetPosition (
IN UINT64 Position
)
{
- EFI_STATUS Status;
- EMU_EFI_FILE_PRIVATE *PrivateFile;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ EMU_EFI_FILE_PRIVATE *PrivateFile;
+ EFI_TPL OldTpl;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
@@ -343,7 +331,6 @@ EmuSimpleFileSystemSetPosition (
return Status;
}
-
/**
Get information about a file.
@@ -371,11 +358,11 @@ EmuSimpleFileSystemGetInfo (
OUT VOID *Buffer
)
{
- EFI_STATUS Status;
- EMU_EFI_FILE_PRIVATE *PrivateFile;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ EMU_EFI_FILE_PRIVATE *PrivateFile;
+ EFI_TPL OldTpl;
- if (This == NULL || InformationType == NULL || BufferSize == NULL) {
+ if ((This == NULL) || (InformationType == NULL) || (BufferSize == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -389,7 +376,6 @@ EmuSimpleFileSystemGetInfo (
return Status;
}
-
/**
Set information about a file
@@ -410,26 +396,26 @@ EmuSimpleFileSystemGetInfo (
EFI_STATUS
EFIAPI
EmuSimpleFileSystemSetInfo (
- IN EFI_FILE_PROTOCOL*This,
- IN EFI_GUID *InformationType,
- IN UINTN BufferSize,
- IN VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN EFI_GUID *InformationType,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
)
{
- EFI_STATUS Status;
- EMU_EFI_FILE_PRIVATE *PrivateFile;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ EMU_EFI_FILE_PRIVATE *PrivateFile;
+ EFI_TPL OldTpl;
//
// Check for invalid parameters.
//
- if (This == NULL || InformationType == NULL || BufferSize == 0 || Buffer == NULL) {
+ if ((This == NULL) || (InformationType == NULL) || (BufferSize == 0) || (Buffer == NULL)) {
return EFI_INVALID_PARAMETER;
}
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
- PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
+ PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
Status = PrivateFile->Io->SetInfo (PrivateFile->Io, InformationType, BufferSize, Buffer);
@@ -437,7 +423,6 @@ EmuSimpleFileSystemSetInfo (
return Status;
}
-
/**
Flush data back for the file handle.
@@ -459,9 +444,9 @@ EmuSimpleFileSystemFlush (
IN EFI_FILE_PROTOCOL *This
)
{
- EFI_STATUS Status;
- EMU_EFI_FILE_PRIVATE *PrivateFile;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ EMU_EFI_FILE_PRIVATE *PrivateFile;
+ EFI_TPL OldTpl;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
@@ -477,8 +462,6 @@ EmuSimpleFileSystemFlush (
return Status;
}
-
-
/**
Open the root directory on a volume.
@@ -501,14 +484,14 @@ EmuSimpleFileSystemOpenVolume (
OUT EFI_FILE_PROTOCOL **Root
)
{
- EFI_STATUS Status;
- EMU_SIMPLE_FILE_SYSTEM_PRIVATE *Private;
- EMU_EFI_FILE_PRIVATE *PrivateFile;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ EMU_SIMPLE_FILE_SYSTEM_PRIVATE *Private;
+ EMU_EFI_FILE_PRIVATE *PrivateFile;
+ EFI_TPL OldTpl;
Status = EFI_UNSUPPORTED;
- if (This == NULL || Root == NULL) {
+ if ((This == NULL) || (Root == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -522,22 +505,22 @@ EmuSimpleFileSystemOpenVolume (
goto Done;
}
- PrivateFile->Signature = EMU_EFI_FILE_PRIVATE_SIGNATURE;
- PrivateFile->IoThunk = Private->IoThunk;
- PrivateFile->SimpleFileSystem = This;
+ PrivateFile->Signature = EMU_EFI_FILE_PRIVATE_SIGNATURE;
+ PrivateFile->IoThunk = Private->IoThunk;
+ PrivateFile->SimpleFileSystem = This;
ZeroMem (&PrivateFile->EfiFile, sizeof (PrivateFile->EfiFile));
- PrivateFile->EfiFile.Revision = EFI_FILE_PROTOCOL_REVISION;
- PrivateFile->EfiFile.Open = EmuSimpleFileSystemOpen;
- PrivateFile->EfiFile.Close = EmuSimpleFileSystemClose;
- PrivateFile->EfiFile.Delete = EmuSimpleFileSystemDelete;
- PrivateFile->EfiFile.Read = EmuSimpleFileSystemRead;
- PrivateFile->EfiFile.Write = EmuSimpleFileSystemWrite;
- PrivateFile->EfiFile.GetPosition = EmuSimpleFileSystemGetPosition;
- PrivateFile->EfiFile.SetPosition = EmuSimpleFileSystemSetPosition;
- PrivateFile->EfiFile.GetInfo = EmuSimpleFileSystemGetInfo;
- PrivateFile->EfiFile.SetInfo = EmuSimpleFileSystemSetInfo;
- PrivateFile->EfiFile.Flush = EmuSimpleFileSystemFlush;
+ PrivateFile->EfiFile.Revision = EFI_FILE_PROTOCOL_REVISION;
+ PrivateFile->EfiFile.Open = EmuSimpleFileSystemOpen;
+ PrivateFile->EfiFile.Close = EmuSimpleFileSystemClose;
+ PrivateFile->EfiFile.Delete = EmuSimpleFileSystemDelete;
+ PrivateFile->EfiFile.Read = EmuSimpleFileSystemRead;
+ PrivateFile->EfiFile.Write = EmuSimpleFileSystemWrite;
+ PrivateFile->EfiFile.GetPosition = EmuSimpleFileSystemGetPosition;
+ PrivateFile->EfiFile.SetPosition = EmuSimpleFileSystemSetPosition;
+ PrivateFile->EfiFile.GetInfo = EmuSimpleFileSystemGetInfo;
+ PrivateFile->EfiFile.SetInfo = EmuSimpleFileSystemSetInfo;
+ PrivateFile->EfiFile.Flush = EmuSimpleFileSystemFlush;
*Root = &PrivateFile->EfiFile;
@@ -562,7 +545,6 @@ EmuSimpleFileSystemOpenVolume (
FALSE
);
-
Done:
if (EFI_ERROR (Status)) {
if (PrivateFile) {
@@ -627,7 +609,7 @@ EmuSimpleFileSystemDriverBindingSupported (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
EMU_IO_THUNK_PROTOCOL *EmuIoThunk;
//
@@ -657,17 +639,15 @@ EmuSimpleFileSystemDriverBindingSupported (
// Close the I/O Abstraction(s) used to perform the supported test
//
gBS->CloseProtocol (
- ControllerHandle,
- &gEmuIoThunkProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
+ ControllerHandle,
+ &gEmuIoThunkProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
return Status;
}
-
-
/**
Starts a device controller or a bus controller.
@@ -706,14 +686,14 @@ EmuSimpleFileSystemDriverBindingSupported (
EFI_STATUS
EFIAPI
EmuSimpleFileSystemDriverBindingStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- EFI_STATUS Status;
- EMU_IO_THUNK_PROTOCOL *EmuIoThunk;
- EMU_SIMPLE_FILE_SYSTEM_PRIVATE *Private;
+ EFI_STATUS Status;
+ EMU_IO_THUNK_PROTOCOL *EmuIoThunk;
+ EMU_SIMPLE_FILE_SYSTEM_PRIVATE *Private;
Private = NULL;
@@ -755,8 +735,8 @@ EmuSimpleFileSystemDriverBindingStart (
Private->IoThunk = EmuIoThunk;
Private->Io = EmuIoThunk->Interface;
- Private->SimpleFileSystem.Revision = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION;
- Private->SimpleFileSystem.OpenVolume = EmuSimpleFileSystemOpenVolume;
+ Private->SimpleFileSystem.Revision = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION;
+ Private->SimpleFileSystem.OpenVolume = EmuSimpleFileSystemOpenVolume;
Private->ControllerNameTable = NULL;
@@ -778,7 +758,8 @@ EmuSimpleFileSystemDriverBindingStart (
Status = gBS->InstallMultipleProtocolInterfaces (
&ControllerHandle,
- &gEfiSimpleFileSystemProtocolGuid, &Private->SimpleFileSystem,
+ &gEfiSimpleFileSystemProtocolGuid,
+ &Private->SimpleFileSystem,
NULL
);
@@ -790,21 +771,19 @@ Done:
}
gBS->FreePool (Private);
-
}
gBS->CloseProtocol (
- ControllerHandle,
- &gEmuIoThunkProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
+ ControllerHandle,
+ &gEmuIoThunkProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
}
return Status;
}
-
/**
Stops a device controller or a bus controller.
@@ -840,9 +819,9 @@ EmuSimpleFileSystemDriverBindingStop (
IN EFI_HANDLE *ChildHandleBuffer
)
{
- EFI_STATUS Status;
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem;
- EMU_SIMPLE_FILE_SYSTEM_PRIVATE *Private;
+ EFI_STATUS Status;
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem;
+ EMU_SIMPLE_FILE_SYSTEM_PRIVATE *Private;
//
// Get our context back
@@ -866,7 +845,8 @@ EmuSimpleFileSystemDriverBindingStop (
//
Status = gBS->UninstallMultipleProtocolInterfaces (
ControllerHandle,
- &gEfiSimpleFileSystemProtocolGuid, &Private->SimpleFileSystem,
+ &gEfiSimpleFileSystemProtocolGuid,
+ &Private->SimpleFileSystem,
NULL
);
if (!EFI_ERROR (Status)) {
@@ -892,8 +872,7 @@ EmuSimpleFileSystemDriverBindingStop (
return Status;
}
-
-EFI_DRIVER_BINDING_PROTOCOL gEmuSimpleFileSystemDriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gEmuSimpleFileSystemDriverBinding = {
EmuSimpleFileSystemDriverBindingSupported,
EmuSimpleFileSystemDriverBindingStart,
EmuSimpleFileSystemDriverBindingStop,
@@ -902,9 +881,6 @@ EFI_DRIVER_BINDING_PROTOCOL gEmuSimpleFileSystemDriverBinding = {
NULL
};
-
-
-
/**
The user Entry Point for module EmuSimpleFileSystem. The user code starts with this function.
@@ -917,12 +893,12 @@ EFI_DRIVER_BINDING_PROTOCOL gEmuSimpleFileSystemDriverBinding = {
**/
EFI_STATUS
EFIAPI
-InitializeEmuSimpleFileSystem(
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+InitializeEmuSimpleFileSystem (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = EfiLibInstallDriverBindingComponentName2 (
ImageHandle,
diff --git a/EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.h b/EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.h
index c87ff653a2..61964137a4 100644
--- a/EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.h
+++ b/EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.h
@@ -30,19 +30,18 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
+extern EFI_DRIVER_BINDING_PROTOCOL gEmuSimpleFileSystemDriverBinding;
+extern EFI_COMPONENT_NAME_PROTOCOL gEmuSimpleFileSystemComponentName;
+extern EFI_COMPONENT_NAME2_PROTOCOL gEmuSimpleFileSystemComponentName2;
-extern EFI_DRIVER_BINDING_PROTOCOL gEmuSimpleFileSystemDriverBinding;
-extern EFI_COMPONENT_NAME_PROTOCOL gEmuSimpleFileSystemComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gEmuSimpleFileSystemComponentName2;
-
-#define EMU_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE SIGNATURE_32 ('E', 'M', 'f', 's')
+#define EMU_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE SIGNATURE_32 ('E', 'M', 'f', 's')
typedef struct {
- UINTN Signature;
- EMU_IO_THUNK_PROTOCOL *IoThunk;
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL SimpleFileSystem;
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Io;
- EFI_UNICODE_STRING_TABLE *ControllerNameTable;
+ UINTN Signature;
+ EMU_IO_THUNK_PROTOCOL *IoThunk;
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL SimpleFileSystem;
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Io;
+ EFI_UNICODE_STRING_TABLE *ControllerNameTable;
} EMU_SIMPLE_FILE_SYSTEM_PRIVATE;
#define EMU_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS(a) \
@@ -52,14 +51,14 @@ typedef struct {
EMU_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE \
)
-#define EMU_EFI_FILE_PRIVATE_SIGNATURE SIGNATURE_32 ('e', 'm', 'f', 's')
+#define EMU_EFI_FILE_PRIVATE_SIGNATURE SIGNATURE_32 ('e', 'm', 'f', 's')
typedef struct {
- UINTN Signature;
- EMU_IO_THUNK_PROTOCOL *IoThunk;
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem;
- EFI_FILE_PROTOCOL EfiFile;
- EFI_FILE_PROTOCOL *Io;
+ UINTN Signature;
+ EMU_IO_THUNK_PROTOCOL *IoThunk;
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem;
+ EFI_FILE_PROTOCOL EfiFile;
+ EFI_FILE_PROTOCOL *Io;
} EMU_EFI_FILE_PRIVATE;
#define EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS(a) \
@@ -69,6 +68,4 @@ typedef struct {
EMU_EFI_FILE_PRIVATE_SIGNATURE \
)
-
-
#endif
diff --git a/EmulatorPkg/EmuSnpDxe/ComponentName.c b/EmulatorPkg/EmuSnpDxe/ComponentName.c
index 19424bb34b..b6c04e02c6 100644
--- a/EmulatorPkg/EmuSnpDxe/ComponentName.c
+++ b/EmulatorPkg/EmuSnpDxe/ComponentName.c
@@ -17,6 +17,7 @@ Abstract:
//
// EFI Component Name Functions
//
+
/**
Retrieves a Unicode string that is the user readable name of the driver.
@@ -64,7 +65,6 @@ EmuSnpDriverComponentNameGetDriverName (
OUT CHAR16 **DriverName
);
-
/**
Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver.
@@ -136,14 +136,13 @@ EmuSnpDriverComponentNameGetDriverName (
EFI_STATUS
EFIAPI
EmuSnpDriverComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
);
-
//
// EFI Component Name Protocol
//
@@ -156,14 +155,13 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gEmuSnpDriverComponen
//
// EFI Component Name 2 Protocol
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuSnpDriverComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) EmuSnpDriverComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) EmuSnpDriverComponentNameGetControllerName,
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuSnpDriverComponentName2 = {
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)EmuSnpDriverComponentNameGetDriverName,
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)EmuSnpDriverComponentNameGetControllerName,
"en"
};
-
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mEmuSnpDriverNameTable[] = {
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mEmuSnpDriverNameTable[] = {
{
"eng;en",
L"Emu SNP Driver"
@@ -301,11 +299,11 @@ EmuSnpDriverComponentNameGetDriverName (
EFI_STATUS
EFIAPI
EmuSnpDriverComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
)
{
return EFI_UNSUPPORTED;
diff --git a/EmulatorPkg/EmuSnpDxe/EmuSnpDxe.c b/EmulatorPkg/EmuSnpDxe/EmuSnpDxe.c
index 8e7c5331ff..5b98961c20 100644
--- a/EmulatorPkg/EmuSnpDxe/EmuSnpDxe.c
+++ b/EmulatorPkg/EmuSnpDxe/EmuSnpDxe.c
@@ -15,9 +15,7 @@ Abstract:
#include "EmuSnpDxe.h"
-
-
-EFI_SIMPLE_NETWORK_PROTOCOL gEmuSnpTemplate = {
+EFI_SIMPLE_NETWORK_PROTOCOL gEmuSnpTemplate = {
EFI_SIMPLE_NETWORK_PROTOCOL_REVISION,
EmuSnpStart,
EmuSnpStop,
@@ -34,9 +32,9 @@ EFI_SIMPLE_NETWORK_PROTOCOL gEmuSnpTemplate = {
EmuSnpReceive,
NULL, // WaitForPacket
NULL // Mode
- };
+};
-EFI_SIMPLE_NETWORK_MODE gEmuSnpModeTemplate = {
+EFI_SIMPLE_NETWORK_MODE gEmuSnpModeTemplate = {
EfiSimpleNetworkStopped, // State
NET_ETHER_ADDR_LEN, // HwAddressSize
NET_ETHER_HEADER_SIZE, // MediaHeaderSize
@@ -48,7 +46,9 @@ EFI_SIMPLE_NETWORK_MODE gEmuSnpModeTemplate = {
MAX_MCAST_FILTER_CNT, // MaxMCastFilterCount
0, // MCastFilterCount
{
- { { 0 } }
+ {
+ { 0 }
+ }
}, // MCastFilter
{
{ 0 }
@@ -66,7 +66,6 @@ EFI_SIMPLE_NETWORK_MODE gEmuSnpModeTemplate = {
TRUE // MediaPresent
};
-
/**
Changes the state of a network interface from "stopped" to "started".
@@ -77,12 +76,12 @@ EFI_SIMPLE_NETWORK_MODE gEmuSnpModeTemplate = {
**/
EFI_STATUS
EFIAPI
-EmuSnpStart(
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This
+EmuSnpStart (
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This
)
{
- EFI_STATUS Status;
- EMU_SNP_PRIVATE_DATA *Private;
+ EFI_STATUS Status;
+ EMU_SNP_PRIVATE_DATA *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);
@@ -90,7 +89,6 @@ EmuSnpStart(
return Status;
}
-
/**
Changes the state of a network interface from "started" to "stopped".
@@ -102,11 +100,11 @@ EmuSnpStart(
EFI_STATUS
EFIAPI
EmuSnpStop (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This
)
{
- EFI_STATUS Status;
- EMU_SNP_PRIVATE_DATA *Private;
+ EFI_STATUS Status;
+ EMU_SNP_PRIVATE_DATA *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);
@@ -114,7 +112,6 @@ EmuSnpStop (
return Status;
}
-
/**
Resets a network adapter and allocates the transmit and receive buffers
required by the network interface; optionally, also requests allocation
@@ -138,13 +135,13 @@ EmuSnpStop (
EFI_STATUS
EFIAPI
EmuSnpInitialize (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
- IN UINTN ExtraRxBufferSize OPTIONAL,
- IN UINTN ExtraTxBufferSize OPTIONAL
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ IN UINTN ExtraRxBufferSize OPTIONAL,
+ IN UINTN ExtraTxBufferSize OPTIONAL
)
{
- EFI_STATUS Status;
- EMU_SNP_PRIVATE_DATA *Private;
+ EFI_STATUS Status;
+ EMU_SNP_PRIVATE_DATA *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);
@@ -167,12 +164,12 @@ EmuSnpInitialize (
EFI_STATUS
EFIAPI
EmuSnpReset (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
)
{
- EFI_STATUS Status;
- EMU_SNP_PRIVATE_DATA *Private;
+ EFI_STATUS Status;
+ EMU_SNP_PRIVATE_DATA *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);
@@ -192,11 +189,11 @@ EmuSnpReset (
EFI_STATUS
EFIAPI
EmuSnpShutdown (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This
)
{
- EFI_STATUS Status;
- EMU_SNP_PRIVATE_DATA *Private;
+ EFI_STATUS Status;
+ EMU_SNP_PRIVATE_DATA *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);
@@ -228,16 +225,16 @@ EmuSnpShutdown (
EFI_STATUS
EFIAPI
EmuSnpReceiveFilters (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
- IN UINT32 EnableBits,
- IN UINT32 DisableBits,
- IN BOOLEAN ResetMcastFilter,
- IN UINTN McastFilterCount OPTIONAL,
- IN EFI_MAC_ADDRESS *McastFilter OPTIONAL
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ IN UINT32 EnableBits,
+ IN UINT32 DisableBits,
+ IN BOOLEAN ResetMcastFilter,
+ IN UINTN McastFilterCount OPTIONAL,
+ IN EFI_MAC_ADDRESS *McastFilter OPTIONAL
)
{
- EFI_STATUS Status;
- EMU_SNP_PRIVATE_DATA *Private;
+ EFI_STATUS Status;
+ EMU_SNP_PRIVATE_DATA *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);
@@ -266,13 +263,13 @@ EmuSnpReceiveFilters (
EFI_STATUS
EFIAPI
EmuSnpStationAddress (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
- IN BOOLEAN Reset,
- IN EFI_MAC_ADDRESS *NewMacAddr OPTIONAL
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ IN BOOLEAN Reset,
+ IN EFI_MAC_ADDRESS *NewMacAddr OPTIONAL
)
{
- EFI_STATUS Status;
- EMU_SNP_PRIVATE_DATA *Private;
+ EFI_STATUS Status;
+ EMU_SNP_PRIVATE_DATA *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);
@@ -302,14 +299,14 @@ EmuSnpStationAddress (
EFI_STATUS
EFIAPI
EmuSnpStatistics (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
- IN BOOLEAN Reset,
- IN OUT UINTN *StatisticsSize OPTIONAL,
- OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ IN BOOLEAN Reset,
+ IN OUT UINTN *StatisticsSize OPTIONAL,
+ OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL
)
{
- EFI_STATUS Status;
- EMU_SNP_PRIVATE_DATA *Private;
+ EFI_STATUS Status;
+ EMU_SNP_PRIVATE_DATA *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);
@@ -339,14 +336,14 @@ EmuSnpStatistics (
EFI_STATUS
EFIAPI
EmuSnpMcastIptoMac (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
- IN BOOLEAN Ipv6,
- IN EFI_IP_ADDRESS *Ip,
- OUT EFI_MAC_ADDRESS *Mac
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ IN BOOLEAN Ipv6,
+ IN EFI_IP_ADDRESS *Ip,
+ OUT EFI_MAC_ADDRESS *Mac
)
{
- EFI_STATUS Status;
- EMU_SNP_PRIVATE_DATA *Private;
+ EFI_STATUS Status;
+ EMU_SNP_PRIVATE_DATA *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);
@@ -354,7 +351,6 @@ EmuSnpMcastIptoMac (
return Status;
}
-
/**
Performs read and write operations on the NVRAM device attached to a
network interface.
@@ -374,15 +370,15 @@ EmuSnpMcastIptoMac (
EFI_STATUS
EFIAPI
EmuSnpNvdata (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
- IN BOOLEAN ReadOrWrite,
- IN UINTN Offset,
- IN UINTN BufferSize,
- IN OUT VOID *Buffer
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ IN BOOLEAN ReadOrWrite,
+ IN UINTN Offset,
+ IN UINTN BufferSize,
+ IN OUT VOID *Buffer
)
{
- EFI_STATUS Status;
- EMU_SNP_PRIVATE_DATA *Private;
+ EFI_STATUS Status;
+ EMU_SNP_PRIVATE_DATA *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);
@@ -390,7 +386,6 @@ EmuSnpNvdata (
return Status;
}
-
/**
Reads the current interrupt status and recycled transmit buffer status from
a network interface.
@@ -415,13 +410,13 @@ EmuSnpNvdata (
EFI_STATUS
EFIAPI
EmuSnpGetStatus (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
- OUT UINT32 *InterruptStatus,
- OUT VOID **TxBuffer
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ OUT UINT32 *InterruptStatus,
+ OUT VOID **TxBuffer
)
{
- EFI_STATUS Status;
- EMU_SNP_PRIVATE_DATA *Private;
+ EFI_STATUS Status;
+ EMU_SNP_PRIVATE_DATA *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);
@@ -429,7 +424,6 @@ EmuSnpGetStatus (
return Status;
}
-
/**
Places a packet in the transmit queue of a network interface.
@@ -463,17 +457,17 @@ EmuSnpGetStatus (
EFI_STATUS
EFIAPI
EmuSnpTransmit (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
- IN UINTN HeaderSize,
- IN UINTN BufferSize,
- IN VOID* Buffer,
- IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
- IN EFI_MAC_ADDRESS *DestAddr OPTIONAL,
- IN UINT16 *Protocol OPTIONAL
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ IN UINTN HeaderSize,
+ IN UINTN BufferSize,
+ IN VOID *Buffer,
+ IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
+ IN EFI_MAC_ADDRESS *DestAddr OPTIONAL,
+ IN UINT16 *Protocol OPTIONAL
)
{
- EFI_STATUS Status;
- EMU_SNP_PRIVATE_DATA *Private;
+ EFI_STATUS Status;
+ EMU_SNP_PRIVATE_DATA *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);
@@ -522,17 +516,17 @@ EmuSnpTransmit (
EFI_STATUS
EFIAPI
EmuSnpReceive (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
- OUT UINTN *HeaderSize OPTIONAL,
- IN OUT UINTN *BuffSize,
- OUT VOID *Buffer,
- OUT EFI_MAC_ADDRESS *SourceAddr OPTIONAL,
- OUT EFI_MAC_ADDRESS *DestinationAddr OPTIONAL,
- OUT UINT16 *Protocol OPTIONAL
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ OUT UINTN *HeaderSize OPTIONAL,
+ IN OUT UINTN *BuffSize,
+ OUT VOID *Buffer,
+ OUT EFI_MAC_ADDRESS *SourceAddr OPTIONAL,
+ OUT EFI_MAC_ADDRESS *DestinationAddr OPTIONAL,
+ OUT UINT16 *Protocol OPTIONAL
)
{
- EFI_STATUS Status;
- EMU_SNP_PRIVATE_DATA *Private;
+ EFI_STATUS Status;
+ EMU_SNP_PRIVATE_DATA *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);
@@ -548,8 +542,6 @@ EmuSnpReceive (
return Status;
}
-
-
/**
Test to see if this driver supports ControllerHandle. This service
is called by the EFI boot service ConnectController(). In
@@ -583,15 +575,15 @@ EmuSnpDriverBindingSupported (
if (RemainingDevicePath != NULL) {
if (!IsDevicePathEnd (RemainingDevicePath)) {
Node = (MAC_ADDR_DEVICE_PATH *)RemainingDevicePath;
- if (Node->Header.Type != MESSAGING_DEVICE_PATH ||
- Node->Header.SubType != MSG_MAC_ADDR_DP) {
+ if ((Node->Header.Type != MESSAGING_DEVICE_PATH) ||
+ (Node->Header.SubType != MSG_MAC_ADDR_DP))
+ {
// If the remaining device path does not match we don't support the request
return EFI_UNSUPPORTED;
}
}
}
-
//
// Open the IO Abstraction(s) needed to perform the supported test
//
@@ -611,12 +603,11 @@ EmuSnpDriverBindingSupported (
// Close the I/O Abstraction(s) used to perform the supported test
//
gBS->CloseProtocol (
- ControllerHandle,
- &gEmuIoThunkProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
-
+ ControllerHandle,
+ &gEmuIoThunkProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
//
// Open the EFI Device Path protocol needed to perform the supported test
@@ -624,7 +615,7 @@ EmuSnpDriverBindingSupported (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiDevicePathProtocolGuid,
- (VOID **) &ParentDevicePath,
+ (VOID **)&ParentDevicePath,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -649,16 +640,15 @@ EmuSnpDriverBindingSupported (
// Close protocol, don't use device path protocol in the Support() function
//
gBS->CloseProtocol (
- ControllerHandle,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
+ ControllerHandle,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
return Status;
}
-
/**
Start this driver on ControllerHandle. This service is called by the
EFI boot service ConnectController(). In order to make
@@ -683,21 +673,21 @@ EmuSnpDriverBindingStart (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
{
- EFI_STATUS Status;
- EMU_IO_THUNK_PROTOCOL *EmuIoThunk;
- EMU_SNP_PRIVATE_DATA *Private;
- MAC_ADDR_DEVICE_PATH Node;
- EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
+ EFI_STATUS Status;
+ EMU_IO_THUNK_PROTOCOL *EmuIoThunk;
+ EMU_SNP_PRIVATE_DATA *Private;
+ MAC_ADDR_DEVICE_PATH Node;
+ EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
Private = NULL;
//
// Grab the protocols we need
//
- Status = gBS->OpenProtocol(
+ Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiDevicePathProtocolGuid,
- ( VOID ** ) &ParentDevicePath,
+ (VOID **)&ParentDevicePath,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -739,15 +729,14 @@ EmuSnpDriverBindingStart (
CopyMem (&Private->Snp, &gEmuSnpTemplate, sizeof (EFI_SIMPLE_NETWORK_PROTOCOL));
CopyMem (&Private->Mode, &gEmuSnpModeTemplate, sizeof (EFI_SIMPLE_NETWORK_MODE));
- Private->Signature = EMU_SNP_PRIVATE_DATA_SIGNATURE;
- Private->IoThunk = EmuIoThunk;
- Private->Io = EmuIoThunk->Interface;
- Private->EfiHandle = ControllerHandle;
- Private->DeviceHandle = NULL;
- Private->Snp.Mode = &Private->Mode;
+ Private->Signature = EMU_SNP_PRIVATE_DATA_SIGNATURE;
+ Private->IoThunk = EmuIoThunk;
+ Private->Io = EmuIoThunk->Interface;
+ Private->EfiHandle = ControllerHandle;
+ Private->DeviceHandle = NULL;
+ Private->Snp.Mode = &Private->Mode;
Private->ControllerNameTable = NULL;
-
Status = Private->Io->CreateMapping (Private->Io, &Private->Mode);
if (EFI_ERROR (Status)) {
goto Done;
@@ -759,11 +748,11 @@ EmuSnpDriverBindingStart (
//
ZeroMem (&Node, sizeof (MAC_ADDR_DEVICE_PATH));
- Node.Header.Type = MESSAGING_DEVICE_PATH;
- Node.Header.SubType = MSG_MAC_ADDR_DP;
- Node.IfType = Private->Mode.IfType;
+ Node.Header.Type = MESSAGING_DEVICE_PATH;
+ Node.Header.SubType = MSG_MAC_ADDR_DP;
+ Node.IfType = Private->Mode.IfType;
- SetDevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL * )&Node, sizeof (MAC_ADDR_DEVICE_PATH));
+ SetDevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *)&Node, sizeof (MAC_ADDR_DEVICE_PATH));
CopyMem (&Node.MacAddress, &Private->Mode.CurrentAddress, sizeof (EFI_MAC_ADDRESS));
@@ -795,10 +784,12 @@ EmuSnpDriverBindingStart (
//
// Create Child Handle
//
- Status = gBS->InstallMultipleProtocolInterfaces(
+ Status = gBS->InstallMultipleProtocolInterfaces (
&Private->DeviceHandle,
- &gEfiSimpleNetworkProtocolGuid, &Private->Snp,
- &gEfiDevicePathProtocolGuid, Private->DevicePath,
+ &gEfiSimpleNetworkProtocolGuid,
+ &Private->Snp,
+ &gEfiDevicePathProtocolGuid,
+ Private->DevicePath,
NULL
);
if (EFI_ERROR (Status)) {
@@ -822,13 +813,14 @@ Done:
if (Private != NULL) {
FreePool (Private);
}
+
if (ParentDevicePath != NULL) {
- gBS->CloseProtocol(
- ControllerHandle,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
+ gBS->CloseProtocol (
+ ControllerHandle,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
}
}
@@ -855,16 +847,16 @@ Done:
EFI_STATUS
EFIAPI
EmuSnpDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
)
{
- EFI_STATUS Status;
- EMU_SNP_PRIVATE_DATA *Private = NULL;
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
- VOID *EmuIoThunk;
+ EFI_STATUS Status;
+ EMU_SNP_PRIVATE_DATA *Private = NULL;
+ EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
+ VOID *EmuIoThunk;
//
// Complete all outstanding transactions to Controller.
@@ -892,14 +884,13 @@ EmuSnpDriverBindingStop (
ASSERT (NumberOfChildren == 1);
-
//
// Get our context back.
//
- Status = gBS->OpenProtocol(
+ Status = gBS->OpenProtocol (
ChildHandleBuffer[0],
&gEfiSimpleNetworkProtocolGuid,
- ( VOID ** ) &Snp,
+ (VOID **)&Snp,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -912,7 +903,7 @@ EmuSnpDriverBindingStop (
ASSERT (Private->DeviceHandle == ChildHandleBuffer[0]);
ASSERT (Private->EfiHandle == ControllerHandle);
- Status = gBS->CloseProtocol(
+ Status = gBS->CloseProtocol (
ControllerHandle,
&gEmuIoThunkProtocolGuid,
This->DriverBindingHandle,
@@ -920,10 +911,12 @@ EmuSnpDriverBindingStop (
);
ASSERT_EFI_ERROR (Status);
- Status = gBS->UninstallMultipleProtocolInterfaces(
+ Status = gBS->UninstallMultipleProtocolInterfaces (
Private->DeviceHandle,
- &gEfiSimpleNetworkProtocolGuid, &Private->Snp,
- &gEfiDevicePathProtocolGuid, Private->DevicePath,
+ &gEfiSimpleNetworkProtocolGuid,
+ &Private->Snp,
+ &gEfiDevicePathProtocolGuid,
+ Private->DevicePath,
NULL
);
if (EFI_ERROR (Status)) {
@@ -947,8 +940,7 @@ EmuSnpDriverBindingStop (
return Status;
}
-
-EFI_DRIVER_BINDING_PROTOCOL gEmuSnpDriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gEmuSnpDriverBinding = {
EmuSnpDriverBindingSupported,
EmuSnpDriverBindingStart,
EmuSnpDriverBindingStop,
@@ -957,8 +949,6 @@ EFI_DRIVER_BINDING_PROTOCOL gEmuSnpDriverBinding = {
NULL
};
-
-
/**
This is the declaration of an EFI image entry point. This entry point is
the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
@@ -975,22 +965,22 @@ EFI_STATUS
EFIAPI
InitializeEmuSnpDriver (
IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Install the Driver Protocols
//
- Status = EfiLibInstallDriverBindingComponentName2(
- ImageHandle,
- SystemTable,
- &gEmuSnpDriverBinding,
- ImageHandle,
- &gEmuSnpDriverComponentName,
- &gEmuSnpDriverComponentName2
- );
+ Status = EfiLibInstallDriverBindingComponentName2 (
+ ImageHandle,
+ SystemTable,
+ &gEmuSnpDriverBinding,
+ ImageHandle,
+ &gEmuSnpDriverComponentName,
+ &gEmuSnpDriverComponentName2
+ );
return Status;
}
diff --git a/EmulatorPkg/EmuSnpDxe/EmuSnpDxe.h b/EmulatorPkg/EmuSnpDxe/EmuSnpDxe.h
index 6eb9a740b2..2d66eb748e 100644
--- a/EmulatorPkg/EmuSnpDxe/EmuSnpDxe.h
+++ b/EmulatorPkg/EmuSnpDxe/EmuSnpDxe.h
@@ -22,7 +22,6 @@ Abstract:
#include <Protocol/EmuIoThunk.h>
#include <Protocol/EmuSnp.h>
-
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
@@ -32,35 +31,34 @@ Abstract:
#include <Library/MemoryAllocationLib.h>
#include <Library/NetLib.h>
-#define NET_ETHER_HEADER_SIZE 14
+#define NET_ETHER_HEADER_SIZE 14
//
// Private data for driver.
//
-#define EMU_SNP_PRIVATE_DATA_SIGNATURE SIGNATURE_32( 'U', 'S', 'N', 'P' )
+#define EMU_SNP_PRIVATE_DATA_SIGNATURE SIGNATURE_32( 'U', 'S', 'N', 'P' )
typedef struct {
- UINTN Signature;
- EMU_IO_THUNK_PROTOCOL *IoThunk;
- EMU_SNP_PROTOCOL *Io;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
-
- EFI_HANDLE EfiHandle;
- EFI_HANDLE DeviceHandle;
+ UINTN Signature;
+ EMU_IO_THUNK_PROTOCOL *IoThunk;
+ EMU_SNP_PROTOCOL *Io;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_SIMPLE_NETWORK_PROTOCOL Snp;
- EFI_SIMPLE_NETWORK_MODE Mode;
+ EFI_HANDLE EfiHandle;
+ EFI_HANDLE DeviceHandle;
- EFI_UNICODE_STRING_TABLE *ControllerNameTable;
+ EFI_SIMPLE_NETWORK_PROTOCOL Snp;
+ EFI_SIMPLE_NETWORK_MODE Mode;
+ EFI_UNICODE_STRING_TABLE *ControllerNameTable;
} EMU_SNP_PRIVATE_DATA;
#define EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS(a) \
CR( a, EMU_SNP_PRIVATE_DATA, Snp, EMU_SNP_PRIVATE_DATA_SIGNATURE )
-extern EFI_DRIVER_BINDING_PROTOCOL gEmuSnpDriverBinding;
-extern EFI_COMPONENT_NAME_PROTOCOL gEmuSnpDriverComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gEmuSnpDriverComponentName2;
+extern EFI_DRIVER_BINDING_PROTOCOL gEmuSnpDriverBinding;
+extern EFI_COMPONENT_NAME_PROTOCOL gEmuSnpDriverComponentName;
+extern EFI_COMPONENT_NAME2_PROTOCOL gEmuSnpDriverComponentName2;
/**
Test to see if this driver supports ControllerHandle. This service
@@ -82,9 +80,9 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gEmuSnpDriverComponentName2;
EFI_STATUS
EFIAPI
EmuSnpDriverBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL * This,
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
);
/**
@@ -106,9 +104,9 @@ EmuSnpDriverBindingSupported (
EFI_STATUS
EFIAPI
EmuSnpDriverBindingStart (
- IN EFI_DRIVER_BINDING_PROTOCOL * This,
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
);
/**
@@ -147,8 +145,8 @@ EmuSnpDriverBindingStop (
**/
EFI_STATUS
EFIAPI
-EmuSnpStart(
- IN EFI_SIMPLE_NETWORK_PROTOCOL* This
+EmuSnpStart (
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This
);
/**
@@ -161,8 +159,8 @@ EmuSnpStart(
**/
EFI_STATUS
EFIAPI
-EmuSnpStop(
- IN EFI_SIMPLE_NETWORK_PROTOCOL* This
+EmuSnpStop (
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This
);
/**
@@ -187,10 +185,10 @@ EmuSnpStop(
**/
EFI_STATUS
EFIAPI
-EmuSnpInitialize(
- IN EFI_SIMPLE_NETWORK_PROTOCOL* This,
- IN UINTN ExtraRxBufferSize OPTIONAL,
- IN UINTN ExtraTxBufferSize OPTIONAL
+EmuSnpInitialize (
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ IN UINTN ExtraRxBufferSize OPTIONAL,
+ IN UINTN ExtraTxBufferSize OPTIONAL
);
/**
@@ -207,9 +205,9 @@ EmuSnpInitialize(
**/
EFI_STATUS
EFIAPI
-EmuSnpReset(
- IN EFI_SIMPLE_NETWORK_PROTOCOL* This,
- IN BOOLEAN ExtendedVerification
+EmuSnpReset (
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
);
/**
@@ -223,8 +221,8 @@ EmuSnpReset(
**/
EFI_STATUS
EFIAPI
-EmuSnpShutdown(
- IN EFI_SIMPLE_NETWORK_PROTOCOL* This
+EmuSnpShutdown (
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This
);
/**
@@ -250,13 +248,13 @@ EmuSnpShutdown(
**/
EFI_STATUS
EFIAPI
-EmuSnpReceiveFilters(
- IN EFI_SIMPLE_NETWORK_PROTOCOL* This,
- IN UINT32 EnableBits,
- IN UINT32 DisableBits,
- IN BOOLEAN ResetMcastFilter,
- IN UINTN McastFilterCount OPTIONAL,
- IN EFI_MAC_ADDRESS* McastFilter OPTIONAL
+EmuSnpReceiveFilters (
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ IN UINT32 EnableBits,
+ IN UINT32 DisableBits,
+ IN BOOLEAN ResetMcastFilter,
+ IN UINTN McastFilterCount OPTIONAL,
+ IN EFI_MAC_ADDRESS *McastFilter OPTIONAL
);
/**
@@ -272,10 +270,10 @@ EmuSnpReceiveFilters(
**/
EFI_STATUS
EFIAPI
-EmuSnpStationAddress(
- IN EFI_SIMPLE_NETWORK_PROTOCOL* This,
- IN BOOLEAN Reset,
- IN EFI_MAC_ADDRESS* NewMacAddr OPTIONAL
+EmuSnpStationAddress (
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ IN BOOLEAN Reset,
+ IN EFI_MAC_ADDRESS *NewMacAddr OPTIONAL
);
/**
@@ -299,11 +297,11 @@ EmuSnpStationAddress(
**/
EFI_STATUS
EFIAPI
-EmuSnpStatistics(
- IN EFI_SIMPLE_NETWORK_PROTOCOL* This,
- IN BOOLEAN Reset,
- IN OUT UINTN* StatisticsSize OPTIONAL,
- OUT EFI_NETWORK_STATISTICS* StatisticsTable OPTIONAL
+EmuSnpStatistics (
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ IN BOOLEAN Reset,
+ IN OUT UINTN *StatisticsSize OPTIONAL,
+ OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL
);
/**
@@ -327,11 +325,11 @@ EmuSnpStatistics(
**/
EFI_STATUS
EFIAPI
-EmuSnpMcastIptoMac(
- IN EFI_SIMPLE_NETWORK_PROTOCOL* This,
- IN BOOLEAN Ipv6,
- IN EFI_IP_ADDRESS* Ip,
- OUT EFI_MAC_ADDRESS* Mac
+EmuSnpMcastIptoMac (
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ IN BOOLEAN Ipv6,
+ IN EFI_IP_ADDRESS *Ip,
+ OUT EFI_MAC_ADDRESS *Mac
);
/**
@@ -352,12 +350,12 @@ EmuSnpMcastIptoMac(
**/
EFI_STATUS
EFIAPI
-EmuSnpNvdata(
- IN EFI_SIMPLE_NETWORK_PROTOCOL* This,
- IN BOOLEAN ReadOrWrite,
- IN UINTN Offset,
- IN UINTN BufferSize,
- IN OUT VOID* Buffer
+EmuSnpNvdata (
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ IN BOOLEAN ReadOrWrite,
+ IN UINTN Offset,
+ IN UINTN BufferSize,
+ IN OUT VOID *Buffer
);
/**
@@ -383,10 +381,10 @@ EmuSnpNvdata(
**/
EFI_STATUS
EFIAPI
-EmuSnpGetStatus(
- IN EFI_SIMPLE_NETWORK_PROTOCOL* This,
- OUT UINT32* InterruptStatus,
- OUT VOID** TxBuffer
+EmuSnpGetStatus (
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ OUT UINT32 *InterruptStatus,
+ OUT VOID **TxBuffer
);
/**
@@ -420,14 +418,14 @@ EmuSnpGetStatus(
**/
EFI_STATUS
EFIAPI
-EmuSnpTransmit(
- IN EFI_SIMPLE_NETWORK_PROTOCOL* This,
- IN UINTN HeaderSize,
- IN UINTN BufferSize,
- IN VOID* Buffer,
- IN EFI_MAC_ADDRESS* SrcAddr OPTIONAL,
- IN EFI_MAC_ADDRESS* DestAddr OPTIONAL,
- IN UINT16* Protocol OPTIONAL
+EmuSnpTransmit (
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ IN UINTN HeaderSize,
+ IN UINTN BufferSize,
+ IN VOID *Buffer,
+ IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
+ IN EFI_MAC_ADDRESS *DestAddr OPTIONAL,
+ IN UINT16 *Protocol OPTIONAL
);
/**
@@ -462,21 +460,21 @@ EmuSnpTransmit(
**/
EFI_STATUS
EFIAPI
-EmuSnpReceive(
- IN EFI_SIMPLE_NETWORK_PROTOCOL* This,
- OUT UINTN* HeaderSize OPTIONAL,
- IN OUT UINTN* BuffSize,
- OUT VOID* Buffer,
- OUT EFI_MAC_ADDRESS* SourceAddr OPTIONAL,
- OUT EFI_MAC_ADDRESS* DestinationAddr OPTIONAL,
- OUT UINT16* Protocol OPTIONAL
+EmuSnpReceive (
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ OUT UINTN *HeaderSize OPTIONAL,
+ IN OUT UINTN *BuffSize,
+ OUT VOID *Buffer,
+ OUT EFI_MAC_ADDRESS *SourceAddr OPTIONAL,
+ OUT EFI_MAC_ADDRESS *DestinationAddr OPTIONAL,
+ OUT UINT16 *Protocol OPTIONAL
);
VOID
EFIAPI
-EmuSnpWaitForPacketNotify(
- IN EFI_EVENT Event,
- IN VOID* Private
+EmuSnpWaitForPacketNotify (
+ IN EFI_EVENT Event,
+ IN VOID *Private
);
-#endif // _EMU_SNP_H_
+#endif // _EMU_SNP_H_
diff --git a/EmulatorPkg/EmuThunkDxe/EmuThunk.c b/EmulatorPkg/EmuThunkDxe/EmuThunk.c
index d26d52ae36..97cdf16975 100644
--- a/EmulatorPkg/EmuThunkDxe/EmuThunk.c
+++ b/EmulatorPkg/EmuThunkDxe/EmuThunk.c
@@ -22,15 +22,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//
// EmuThunk Device Path Protocol Instance
//
-EMU_THUNK_DEVICE_PATH mEmuThunkDevicePath = {
+EMU_THUNK_DEVICE_PATH mEmuThunkDevicePath = {
{
{
{
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{
- (UINT8) (sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),
- (UINT8) ((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)
+ (UINT8)(sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),
+ (UINT8)((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)
}
},
EMU_THUNK_PROTOCOL_GUID
@@ -47,13 +47,13 @@ EMU_THUNK_DEVICE_PATH mEmuThunkDevicePath = {
}
};
-
EFI_STATUS
EFIAPI
InitializeEmuThunk (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
+
/*++
Routine Description:
@@ -74,8 +74,10 @@ Returns:
Handle = NULL;
Status = gBS->InstallMultipleProtocolInterfaces (
&Handle,
- &gEmuThunkProtocolGuid, gEmuThunk,
- &gEfiDevicePathProtocolGuid, &mEmuThunkDevicePath,
+ &gEmuThunkProtocolGuid,
+ gEmuThunk,
+ &gEfiDevicePathProtocolGuid,
+ &mEmuThunkDevicePath,
NULL
);
diff --git a/EmulatorPkg/FirmwareVolumePei/FirmwareVolumePei.c b/EmulatorPkg/FirmwareVolumePei/FirmwareVolumePei.c
index 4a3bfb226c..12b223e321 100644
--- a/EmulatorPkg/FirmwareVolumePei/FirmwareVolumePei.c
+++ b/EmulatorPkg/FirmwareVolumePei/FirmwareVolumePei.c
@@ -18,9 +18,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
EFI_STATUS
EFIAPI
PeimInitializeFirmwareVolumePei (
- IN EFI_PEI_FILE_HANDLE FileHandle,
- IN CONST EFI_PEI_SERVICES **PeiServices
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ IN CONST EFI_PEI_SERVICES **PeiServices
)
+
/*++
Routine Description:
@@ -50,11 +51,11 @@ Returns:
// Get the Fwh Information PPI
//
Status = PeiServicesLocatePpi (
- &gEmuThunkPpiGuid, // GUID
- 0, // INSTANCE
- &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR
- (VOID **)&Thunk // PPI
- );
+ &gEmuThunkPpiGuid, // GUID
+ 0, // INSTANCE
+ &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR
+ (VOID **)&Thunk // PPI
+ );
ASSERT_EFI_ERROR (Status);
Index = 0;
@@ -67,7 +68,7 @@ Returns:
//
// Assume the FD starts with an FV header
//
- FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) FdBase;
+ FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)FdBase;
//
// Make an FV Hob for the first FV in the FD
@@ -85,19 +86,19 @@ Returns:
(EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE),
FdBase,
(
- FvHeader->FvLength +
- PcdGet32 (PcdFlashNvStorageVariableSize) +
- PcdGet32 (PcdFlashNvStorageFtwWorkingSize) +
- PcdGet32 (PcdFlashNvStorageFtwSpareSize) +
- PcdGet32 (PcdEmuFlashNvStorageEventLogSize)
+ FvHeader->FvLength +
+ PcdGet32 (PcdFlashNvStorageVariableSize) +
+ PcdGet32 (PcdFlashNvStorageFtwWorkingSize) +
+ PcdGet32 (PcdFlashNvStorageFtwSpareSize) +
+ PcdGet32 (PcdEmuFlashNvStorageEventLogSize)
)
- );
+ );
//
// Hard code the address of the spare block and variable services.
// Assume it's a hard coded offset from FV0 in FD0.
//
- FdSize =
+ FdSize =
PcdGet32 (PcdFlashNvStorageVariableSize) +
PcdGet32 (PcdFlashNvStorageFtwWorkingSize) +
PcdGet32 (PcdFlashNvStorageFtwSpareSize) +
diff --git a/EmulatorPkg/FlashMapPei/FlashMapPei.c b/EmulatorPkg/FlashMapPei/FlashMapPei.c
index 2be0627fd9..65674d1787 100644
--- a/EmulatorPkg/FlashMapPei/FlashMapPei.c
+++ b/EmulatorPkg/FlashMapPei/FlashMapPei.c
@@ -7,7 +7,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-
#include "PiPei.h"
#include <Guid/SystemNvDataGuid.h>
@@ -24,9 +23,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
EFI_STATUS
EFIAPI
PeimInitializeFlashMap (
- IN EFI_PEI_FILE_HANDLE FileHandle,
- IN CONST EFI_PEI_SERVICES **PeiServices
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ IN CONST EFI_PEI_SERVICES **PeiServices
)
+
/*++
Routine Description:
@@ -54,11 +54,11 @@ Returns:
// Get the Fwh Information PPI
//
Status = PeiServicesLocatePpi (
- &gEmuThunkPpiGuid, // GUID
- 0, // INSTANCE
- &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR
- (VOID **)&Thunk // PPI
- );
+ &gEmuThunkPpiGuid, // GUID
+ 0, // INSTANCE
+ &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR
+ (VOID **)&Thunk // PPI
+ );
ASSERT_EFI_ERROR (Status);
//
diff --git a/EmulatorPkg/FvbServicesRuntimeDxe/FWBlockService.c b/EmulatorPkg/FvbServicesRuntimeDxe/FWBlockService.c
index db028c9e92..1c4d8120c1 100644
--- a/EmulatorPkg/FvbServicesRuntimeDxe/FWBlockService.c
+++ b/EmulatorPkg/FvbServicesRuntimeDxe/FWBlockService.c
@@ -25,11 +25,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "FwBlockService.h"
-ESAL_FWB_GLOBAL *mFvbModuleGlobal;
+ESAL_FWB_GLOBAL *mFvbModuleGlobal;
-#define EFI_FVB2_STATUS (EFI_FVB2_READ_STATUS | EFI_FVB2_WRITE_STATUS | EFI_FVB2_LOCK_STATUS)
+#define EFI_FVB2_STATUS (EFI_FVB2_READ_STATUS | EFI_FVB2_WRITE_STATUS | EFI_FVB2_LOCK_STATUS)
-EFI_FW_VOL_BLOCK_DEVICE mFvbDeviceTemplate = {
+EFI_FW_VOL_BLOCK_DEVICE mFvbDeviceTemplate = {
FVB_DEVICE_SIGNATURE,
{
{
@@ -67,14 +67,13 @@ EFI_FW_VOL_BLOCK_DEVICE mFvbDeviceTemplate = {
}
};
-
-
VOID
EFIAPI
FvbVirtualddressChangeEvent (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
+
/*++
Routine Description:
@@ -97,10 +96,10 @@ Returns:
**/
{
- EFI_FW_VOL_INSTANCE *FwhInstance;
- UINTN Index;
+ EFI_FW_VOL_INSTANCE *FwhInstance;
+ UINTN Index;
- EfiConvertPointer (0x0, (VOID **) &mFvbModuleGlobal->FvInstance[FVB_VIRTUAL]);
+ EfiConvertPointer (0x0, (VOID **)&mFvbModuleGlobal->FvInstance[FVB_VIRTUAL]);
//
// Convert the base address of all the instances
@@ -108,25 +107,26 @@ Returns:
Index = 0;
FwhInstance = mFvbModuleGlobal->FvInstance[FVB_PHYSICAL];
while (Index < mFvbModuleGlobal->NumFv) {
- EfiConvertPointer (0x0, (VOID **) &FwhInstance->FvBase[FVB_VIRTUAL]);
+ EfiConvertPointer (0x0, (VOID **)&FwhInstance->FvBase[FVB_VIRTUAL]);
FwhInstance = (EFI_FW_VOL_INSTANCE *)
- (
- (UINTN) ((UINT8 *) FwhInstance) + FwhInstance->VolumeHeader.HeaderLength +
- (sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER))
- );
+ (
+ (UINTN)((UINT8 *)FwhInstance) + FwhInstance->VolumeHeader.HeaderLength +
+ (sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER))
+ );
Index++;
}
- EfiConvertPointer (0x0, (VOID **) &mFvbModuleGlobal);
+ EfiConvertPointer (0x0, (VOID **)&mFvbModuleGlobal);
}
EFI_STATUS
GetFvbInstance (
- IN UINTN Instance,
- IN ESAL_FWB_GLOBAL *Global,
- OUT EFI_FW_VOL_INSTANCE **FwhInstance,
- IN BOOLEAN Virtual
+ IN UINTN Instance,
+ IN ESAL_FWB_GLOBAL *Global,
+ OUT EFI_FW_VOL_INSTANCE **FwhInstance,
+ IN BOOLEAN Virtual
)
+
/*++
Routine Description:
@@ -146,21 +146,22 @@ Returns:
**/
{
- EFI_FW_VOL_INSTANCE *FwhRecord;
+ EFI_FW_VOL_INSTANCE *FwhRecord;
if (Instance >= Global->NumFv) {
return EFI_INVALID_PARAMETER;
}
+
//
// Find the right instance of the FVB private data
//
FwhRecord = Global->FvInstance[Virtual];
while (Instance > 0) {
FwhRecord = (EFI_FW_VOL_INSTANCE *)
- (
- (UINTN) ((UINT8 *) FwhRecord) + FwhRecord->VolumeHeader.HeaderLength +
- (sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER))
- );
+ (
+ (UINTN)((UINT8 *)FwhRecord) + FwhRecord->VolumeHeader.HeaderLength +
+ (sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER))
+ );
Instance--;
}
@@ -171,11 +172,12 @@ Returns:
EFI_STATUS
FvbGetPhysicalAddress (
- IN UINTN Instance,
- OUT EFI_PHYSICAL_ADDRESS *Address,
- IN ESAL_FWB_GLOBAL *Global,
- IN BOOLEAN Virtual
+ IN UINTN Instance,
+ OUT EFI_PHYSICAL_ADDRESS *Address,
+ IN ESAL_FWB_GLOBAL *Global,
+ IN BOOLEAN Virtual
)
+
/*++
Routine Description:
@@ -197,8 +199,8 @@ Returns:
**/
{
- EFI_FW_VOL_INSTANCE *FwhInstance = NULL;
- EFI_STATUS Status;
+ EFI_FW_VOL_INSTANCE *FwhInstance = NULL;
+ EFI_STATUS Status;
//
// Find the right instance of the FVB private data
@@ -212,11 +214,12 @@ Returns:
EFI_STATUS
FvbGetVolumeAttributes (
- IN UINTN Instance,
- OUT EFI_FVB_ATTRIBUTES_2 *Attributes,
- IN ESAL_FWB_GLOBAL *Global,
- IN BOOLEAN Virtual
+ IN UINTN Instance,
+ OUT EFI_FVB_ATTRIBUTES_2 *Attributes,
+ IN ESAL_FWB_GLOBAL *Global,
+ IN BOOLEAN Virtual
)
+
/*++
Routine Description:
@@ -237,8 +240,8 @@ Returns:
**/
{
- EFI_FW_VOL_INSTANCE *FwhInstance = NULL;
- EFI_STATUS Status;
+ EFI_FW_VOL_INSTANCE *FwhInstance = NULL;
+ EFI_STATUS Status;
//
// Find the right instance of the FVB private data
@@ -252,14 +255,15 @@ Returns:
EFI_STATUS
FvbGetLbaAddress (
- IN UINTN Instance,
- IN EFI_LBA Lba,
- OUT UINTN *LbaAddress,
- OUT UINTN *LbaLength,
- OUT UINTN *NumOfBlocks,
- IN ESAL_FWB_GLOBAL *Global,
- IN BOOLEAN Virtual
+ IN UINTN Instance,
+ IN EFI_LBA Lba,
+ OUT UINTN *LbaAddress,
+ OUT UINTN *LbaLength,
+ OUT UINTN *NumOfBlocks,
+ IN ESAL_FWB_GLOBAL *Global,
+ IN BOOLEAN Virtual
)
+
/*++
Routine Description:
@@ -300,9 +304,9 @@ Returns:
Status = GetFvbInstance (Instance, Global, &FwhInstance, Virtual);
ASSERT_EFI_ERROR (Status);
- StartLba = 0;
- Offset = 0;
- BlockMap = &(FwhInstance->VolumeHeader.BlockMap[0]);
+ StartLba = 0;
+ Offset = 0;
+ BlockMap = &(FwhInstance->VolumeHeader.BlockMap[0]);
//
// Parse the blockmap of the FV to find which map entry the Lba belongs to
@@ -311,7 +315,7 @@ Returns:
NumBlocks = BlockMap->NumBlocks;
BlockLength = BlockMap->Length;
- if (NumBlocks == 0 || BlockLength == 0) {
+ if ((NumBlocks == 0) || (BlockLength == 0)) {
return EFI_INVALID_PARAMETER;
}
@@ -320,8 +324,8 @@ Returns:
//
// The map entry found
//
- if (Lba >= StartLba && Lba < NextLba) {
- Offset = Offset + (UINTN) MultU64x32 ((Lba - StartLba), BlockLength);
+ if ((Lba >= StartLba) && (Lba < NextLba)) {
+ Offset = Offset + (UINTN)MultU64x32 ((Lba - StartLba), BlockLength);
if (LbaAddress != NULL) {
*LbaAddress = FwhInstance->FvBase[Virtual] + Offset;
}
@@ -331,28 +335,29 @@ Returns:
}
if (NumOfBlocks != NULL) {
- *NumOfBlocks = (UINTN) (NextLba - Lba);
+ *NumOfBlocks = (UINTN)(NextLba - Lba);
}
return EFI_SUCCESS;
}
- StartLba = NextLba;
- Offset = Offset + NumBlocks * BlockLength;
+ StartLba = NextLba;
+ Offset = Offset + NumBlocks * BlockLength;
BlockMap++;
}
}
EFI_STATUS
FvbReadBlock (
- IN UINTN Instance,
- IN EFI_LBA Lba,
- IN UINTN BlockOffset,
- IN OUT UINTN *NumBytes,
- IN UINT8 *Buffer,
- IN ESAL_FWB_GLOBAL *Global,
- IN BOOLEAN Virtual
+ IN UINTN Instance,
+ IN EFI_LBA Lba,
+ IN UINTN BlockOffset,
+ IN OUT UINTN *NumBytes,
+ IN UINT8 *Buffer,
+ IN ESAL_FWB_GLOBAL *Global,
+ IN BOOLEAN Virtual
)
+
/*++
Routine Description:
@@ -385,9 +390,9 @@ Returns:
**/
{
EFI_FVB_ATTRIBUTES_2 Attributes;
- UINTN LbaAddress;
- UINTN LbaLength;
- EFI_STATUS Status;
+ UINTN LbaAddress;
+ UINTN LbaLength;
+ EFI_STATUS Status;
//
// Check for invalid conditions
@@ -404,6 +409,7 @@ Returns:
if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Check if the FV is read enabled
//
@@ -412,6 +418,7 @@ Returns:
if ((Attributes & EFI_FVB2_READ_STATUS) == 0) {
return EFI_ACCESS_DENIED;
}
+
//
// Perform boundary checks and adjust NumBytes
//
@@ -420,25 +427,26 @@ Returns:
}
if (LbaLength < (*NumBytes + BlockOffset)) {
- *NumBytes = (UINT32) (LbaLength - BlockOffset);
+ *NumBytes = (UINT32)(LbaLength - BlockOffset);
Status = EFI_BAD_BUFFER_SIZE;
}
- CopyMem (Buffer, (UINT8 *) (LbaAddress + BlockOffset), (UINTN) (*NumBytes));
+ CopyMem (Buffer, (UINT8 *)(LbaAddress + BlockOffset), (UINTN)(*NumBytes));
return Status;
}
EFI_STATUS
FvbWriteBlock (
- IN UINTN Instance,
- IN EFI_LBA Lba,
- IN UINTN BlockOffset,
- IN OUT UINTN *NumBytes,
- IN UINT8 *Buffer,
- IN ESAL_FWB_GLOBAL *Global,
- IN BOOLEAN Virtual
+ IN UINTN Instance,
+ IN EFI_LBA Lba,
+ IN UINTN BlockOffset,
+ IN OUT UINTN *NumBytes,
+ IN UINT8 *Buffer,
+ IN ESAL_FWB_GLOBAL *Global,
+ IN BOOLEAN Virtual
)
+
/*++
Routine Description:
@@ -470,9 +478,9 @@ Returns:
**/
{
EFI_FVB_ATTRIBUTES_2 Attributes;
- UINTN LbaAddress;
- UINTN LbaLength;
- EFI_STATUS Status;
+ UINTN LbaAddress;
+ UINTN LbaLength;
+ EFI_STATUS Status;
//
// Check for invalid conditions
@@ -489,6 +497,7 @@ Returns:
if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Check if the FV is write enabled
//
@@ -497,6 +506,7 @@ Returns:
if ((Attributes & EFI_FVB2_WRITE_STATUS) == 0) {
return EFI_ACCESS_DENIED;
}
+
//
// Perform boundary checks and adjust NumBytes
//
@@ -505,24 +515,26 @@ Returns:
}
if (LbaLength < (*NumBytes + BlockOffset)) {
- *NumBytes = (UINT32) (LbaLength - BlockOffset);
+ *NumBytes = (UINT32)(LbaLength - BlockOffset);
Status = EFI_BAD_BUFFER_SIZE;
}
+
//
// Write data
//
- CopyMem ((UINT8 *) (LbaAddress + BlockOffset), Buffer, (UINTN) (*NumBytes));
+ CopyMem ((UINT8 *)(LbaAddress + BlockOffset), Buffer, (UINTN)(*NumBytes));
return Status;
}
EFI_STATUS
FvbEraseBlock (
- IN UINTN Instance,
- IN EFI_LBA Lba,
- IN ESAL_FWB_GLOBAL *Global,
- IN BOOLEAN Virtual
+ IN UINTN Instance,
+ IN EFI_LBA Lba,
+ IN ESAL_FWB_GLOBAL *Global,
+ IN BOOLEAN Virtual
)
+
/*++
Routine Description:
@@ -545,7 +557,6 @@ Returns:
**/
{
-
EFI_FVB_ATTRIBUTES_2 Attributes;
UINTN LbaAddress;
UINTN LbaLength;
@@ -560,6 +571,7 @@ Returns:
if ((Attributes & EFI_FVB2_WRITE_STATUS) == 0) {
return EFI_ACCESS_DENIED;
}
+
//
// Get the starting address of the block for erase.
//
@@ -575,18 +587,19 @@ Returns:
Data = 0x0;
}
- SetMem ((UINT8 *) LbaAddress, LbaLength, Data);
+ SetMem ((UINT8 *)LbaAddress, LbaLength, Data);
return EFI_SUCCESS;
}
EFI_STATUS
FvbSetVolumeAttributes (
- IN UINTN Instance,
- IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes,
- IN ESAL_FWB_GLOBAL *Global,
- IN BOOLEAN Virtual
+ IN UINTN Instance,
+ IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes,
+ IN ESAL_FWB_GLOBAL *Global,
+ IN BOOLEAN Virtual
)
+
/*++
Routine Description:
@@ -622,14 +635,13 @@ Returns:
EFI_STATUS Status;
EFI_FVB_ATTRIBUTES_2 UnchangedAttributes;
-
//
// Find the right instance of the FVB private data
//
Status = GetFvbInstance (Instance, Global, &FwhInstance, Virtual);
ASSERT_EFI_ERROR (Status);
- AttribPtr = (EFI_FVB_ATTRIBUTES_2 *) &(FwhInstance->VolumeHeader.Attributes);
+ AttribPtr = (EFI_FVB_ATTRIBUTES_2 *)&(FwhInstance->VolumeHeader.Attributes);
OldAttributes = *AttribPtr;
Capabilities = OldAttributes & (EFI_FVB2_READ_DISABLED_CAP | \
EFI_FVB2_READ_ENABLED_CAP | \
@@ -638,8 +650,8 @@ Returns:
EFI_FVB2_LOCK_CAP \
);
- OldStatus = OldAttributes & EFI_FVB2_STATUS;
- NewStatus = *Attributes & EFI_FVB2_STATUS;
+ OldStatus = OldAttributes & EFI_FVB2_STATUS;
+ NewStatus = *Attributes & EFI_FVB2_STATUS;
UnchangedAttributes = EFI_FVB2_READ_DISABLED_CAP | \
EFI_FVB2_READ_ENABLED_CAP | \
EFI_FVB2_WRITE_DISABLED_CAP | \
@@ -667,6 +679,7 @@ Returns:
return EFI_ACCESS_DENIED;
}
}
+
//
// Test read disable
//
@@ -675,6 +688,7 @@ Returns:
return EFI_INVALID_PARAMETER;
}
}
+
//
// Test read enable
//
@@ -683,6 +697,7 @@ Returns:
return EFI_INVALID_PARAMETER;
}
}
+
//
// Test write disable
//
@@ -691,6 +706,7 @@ Returns:
return EFI_INVALID_PARAMETER;
}
}
+
//
// Test write enable
//
@@ -699,6 +715,7 @@ Returns:
return EFI_INVALID_PARAMETER;
}
}
+
//
// Test lock
//
@@ -714,15 +731,17 @@ Returns:
return EFI_SUCCESS;
}
+
//
// FVB protocol APIs
//
EFI_STATUS
EFIAPI
FvbProtocolGetPhysicalAddress (
- IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
- OUT EFI_PHYSICAL_ADDRESS *Address
+ IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
+ OUT EFI_PHYSICAL_ADDRESS *Address
)
+
/*++
Routine Description:
@@ -741,7 +760,7 @@ Returns:
**/
{
- EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
+ EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
FvbDevice = FVB_DEVICE_FROM_THIS (This);
@@ -751,11 +770,12 @@ Returns:
EFI_STATUS
EFIAPI
FvbProtocolGetBlockSize (
- IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
- IN EFI_LBA Lba,
- OUT UINTN *BlockSize,
- OUT UINTN *NumOfBlocks
+ IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
+ IN EFI_LBA Lba,
+ OUT UINTN *BlockSize,
+ OUT UINTN *NumOfBlocks
)
+
/*++
Routine Description:
@@ -777,27 +797,28 @@ Returns:
**/
{
- EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
+ EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
FvbDevice = FVB_DEVICE_FROM_THIS (This);
return FvbGetLbaAddress (
- FvbDevice->Instance,
- Lba,
- NULL,
- BlockSize,
- NumOfBlocks,
- mFvbModuleGlobal,
- EfiGoneVirtual ()
- );
+ FvbDevice->Instance,
+ Lba,
+ NULL,
+ BlockSize,
+ NumOfBlocks,
+ mFvbModuleGlobal,
+ EfiGoneVirtual ()
+ );
}
EFI_STATUS
EFIAPI
FvbProtocolGetAttributes (
- IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
- OUT EFI_FVB_ATTRIBUTES_2 *Attributes
+ IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
+ OUT EFI_FVB_ATTRIBUTES_2 *Attributes
)
+
/*++
Routine Description:
@@ -812,7 +833,7 @@ Returns:
**/
{
- EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
+ EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
FvbDevice = FVB_DEVICE_FROM_THIS (This);
@@ -822,9 +843,10 @@ Returns:
EFI_STATUS
EFIAPI
FvbProtocolSetAttributes (
- IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
- IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes
+ IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
+ IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes
)
+
/*++
Routine Description:
@@ -839,7 +861,7 @@ Returns:
**/
{
- EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
+ EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
FvbDevice = FVB_DEVICE_FROM_THIS (This);
@@ -849,9 +871,10 @@ Returns:
EFI_STATUS
EFIAPI
FvbProtocolEraseBlocks (
- IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
+ IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
...
)
+
/*++
Routine Description:
@@ -877,17 +900,17 @@ Returns:
**/
{
- EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
- EFI_FW_VOL_INSTANCE *FwhInstance = NULL;
- UINTN NumOfBlocks;
- VA_LIST args;
- EFI_LBA StartingLba;
- UINTN NumOfLba;
- EFI_STATUS Status;
+ EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
+ EFI_FW_VOL_INSTANCE *FwhInstance = NULL;
+ UINTN NumOfBlocks;
+ VA_LIST args;
+ EFI_LBA StartingLba;
+ UINTN NumOfLba;
+ EFI_STATUS Status;
FvbDevice = FVB_DEVICE_FROM_THIS (This);
- Status = GetFvbInstance (FvbDevice->Instance, mFvbModuleGlobal, &FwhInstance, EfiGoneVirtual ());
+ Status = GetFvbInstance (FvbDevice->Instance, mFvbModuleGlobal, &FwhInstance, EfiGoneVirtual ());
ASSERT_EFI_ERROR (Status);
NumOfBlocks = FwhInstance->NumOfBlocks;
@@ -905,7 +928,7 @@ Returns:
//
// Check input parameters
//
- if (NumOfLba == 0 || (StartingLba + NumOfLba) > NumOfBlocks) {
+ if ((NumOfLba == 0) || ((StartingLba + NumOfLba) > NumOfBlocks)) {
VA_END (args);
return EFI_INVALID_PARAMETER;
}
@@ -932,7 +955,6 @@ Returns:
StartingLba++;
NumOfLba--;
}
-
} while (1);
VA_END (args);
@@ -943,12 +965,13 @@ Returns:
EFI_STATUS
EFIAPI
FvbProtocolWrite (
- IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
- IN EFI_LBA Lba,
- IN UINTN Offset,
- IN OUT UINTN *NumBytes,
- IN UINT8 *Buffer
+ IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
+ IN EFI_LBA Lba,
+ IN UINTN Offset,
+ IN OUT UINTN *NumBytes,
+ IN UINT8 *Buffer
)
+
/*++
Routine Description:
@@ -980,8 +1003,7 @@ Returns:
**/
{
-
- EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
+ EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
FvbDevice = FVB_DEVICE_FROM_THIS (This);
@@ -991,12 +1013,13 @@ Returns:
EFI_STATUS
EFIAPI
FvbProtocolRead (
- IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
- IN EFI_LBA Lba,
- IN UINTN Offset,
- IN OUT UINTN *NumBytes,
- IN UINT8 *Buffer
+ IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
+ IN EFI_LBA Lba,
+ IN UINTN Offset,
+ IN OUT UINTN *NumBytes,
+ IN UINT8 *Buffer
)
+
/*++
Routine Description:
@@ -1029,17 +1052,18 @@ Returns:
**/
{
-
- EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
+ EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
FvbDevice = FVB_DEVICE_FROM_THIS (This);
return FvbReadBlock (FvbDevice->Instance, Lba, Offset, NumBytes, Buffer, mFvbModuleGlobal, EfiGoneVirtual ());
}
+
EFI_STATUS
ValidateFvHeader (
- EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader
+ EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader
)
+
/*++
Routine Description:
@@ -1065,17 +1089,19 @@ Returns:
//
if ((FwVolHeader->Revision != EFI_FVH_REVISION) ||
(FwVolHeader->Signature != EFI_FVH_SIGNATURE) ||
- (FwVolHeader->FvLength == ((UINTN) -1)) ||
+ (FwVolHeader->FvLength == ((UINTN)-1)) ||
((FwVolHeader->HeaderLength & 0x01) != 0)
- ) {
+ )
+ {
return EFI_NOT_FOUND;
}
+
//
// Verify the header checksum
//
- HeaderLength = (UINT16) (FwVolHeader->HeaderLength / 2);
- Ptr = (UINT16 *) FwVolHeader;
- Checksum = 0;
+ HeaderLength = (UINT16)(FwVolHeader->HeaderLength / 2);
+ Ptr = (UINT16 *)FwVolHeader;
+ Checksum = 0;
while (HeaderLength > 0) {
Checksum = Checksum + (*Ptr);
HeaderLength--;
@@ -1092,9 +1118,10 @@ Returns:
EFI_STATUS
EFIAPI
FvbInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
+
/*++
Routine Description:
@@ -1124,7 +1151,7 @@ Returns:
UINTN NumOfBlocks;
EFI_PEI_HOB_POINTERS FvHob;
- //
+ //
// Get the DXE services table
//
DxeServices = gDS;
@@ -1136,14 +1163,14 @@ Returns:
Status = gBS->AllocatePool (
EfiRuntimeServicesData,
sizeof (ESAL_FWB_GLOBAL),
- (VOID**) &mFvbModuleGlobal
+ (VOID **)&mFvbModuleGlobal
);
ASSERT_EFI_ERROR (Status);
//
// Calculate the total size for all firmware volume block instances
//
- BufferSize = 0;
+ BufferSize = 0;
FvHob.Raw = GetHobList ();
while ((FvHob.Raw = GetNextHob (EFI_HOB_TYPE_FV, FvHob.Raw)) != NULL) {
@@ -1165,7 +1192,7 @@ Returns:
continue;
}
- FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) BaseAddress;
+ FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)BaseAddress;
Status = ValidateFvHeader (FwVolHeader);
if (EFI_ERROR (Status)) {
//
@@ -1179,7 +1206,7 @@ Returns:
}
BufferSize += (sizeof (EFI_FW_VOL_INSTANCE) + FwVolHeader->HeaderLength - sizeof (EFI_FIRMWARE_VOLUME_HEADER));
- FvHob.Raw = GET_NEXT_HOB (FvHob);
+ FvHob.Raw = GET_NEXT_HOB (FvHob);
}
//
@@ -1190,18 +1217,18 @@ Returns:
Status = gBS->AllocatePool (
EfiRuntimeServicesData,
BufferSize,
- (VOID**) &mFvbModuleGlobal->FvInstance[FVB_PHYSICAL]
+ (VOID **)&mFvbModuleGlobal->FvInstance[FVB_PHYSICAL]
);
ASSERT_EFI_ERROR (Status);
//
// Make a virtual copy of the FvInstance pointer.
//
- FwhInstance = mFvbModuleGlobal->FvInstance[FVB_PHYSICAL];
+ FwhInstance = mFvbModuleGlobal->FvInstance[FVB_PHYSICAL];
mFvbModuleGlobal->FvInstance[FVB_VIRTUAL] = FwhInstance;
- mFvbModuleGlobal->NumFv = 0;
- MaxLbaSize = 0;
+ mFvbModuleGlobal->NumFv = 0;
+ MaxLbaSize = 0;
FvHob.Raw = GetHobList ();
while (NULL != (FvHob.Raw = GetNextHob (EFI_HOB_TYPE_FV, FvHob.Raw))) {
@@ -1223,7 +1250,7 @@ Returns:
continue;
}
- FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) BaseAddress;
+ FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)BaseAddress;
Status = ValidateFvHeader (FwVolHeader);
if (EFI_ERROR (Status)) {
//
@@ -1234,20 +1261,21 @@ Returns:
FvHob.Raw = GET_NEXT_HOB (FvHob);
continue;
}
+
//
// Write healthy FV header back.
//
CopyMem (
- (VOID *) (UINTN) BaseAddress,
- (VOID *) FwVolHeader,
+ (VOID *)(UINTN)BaseAddress,
+ (VOID *)FwVolHeader,
FwVolHeader->HeaderLength
);
}
- FwhInstance->FvBase[FVB_PHYSICAL] = (UINTN) BaseAddress;
- FwhInstance->FvBase[FVB_VIRTUAL] = (UINTN) BaseAddress;
+ FwhInstance->FvBase[FVB_PHYSICAL] = (UINTN)BaseAddress;
+ FwhInstance->FvBase[FVB_VIRTUAL] = (UINTN)BaseAddress;
- CopyMem ((UINTN *) &(FwhInstance->VolumeHeader), (UINTN *) FwVolHeader, FwVolHeader->HeaderLength);
+ CopyMem ((UINTN *)&(FwhInstance->VolumeHeader), (UINTN *)FwVolHeader, FwVolHeader->HeaderLength);
FwVolHeader = &(FwhInstance->VolumeHeader);
EfiInitializeLock (&(FwhInstance->FvbDevLock), TPL_HIGH_LEVEL);
@@ -1265,6 +1293,7 @@ Returns:
NumOfBlocks = NumOfBlocks + PtrBlockMapEntry->NumBlocks;
}
+
//
// The total number of blocks in the FV.
//
@@ -1276,7 +1305,7 @@ Returns:
Status = gBS->AllocatePool (
EfiRuntimeServicesData,
sizeof (EFI_FW_VOL_BLOCK_DEVICE),
- (VOID**) &FvbDevice
+ (VOID **)&FvbDevice
);
ASSERT_EFI_ERROR (Status);
@@ -1294,7 +1323,7 @@ Returns:
//
// Find a handle with a matching device path that has supports FW Block protocol
//
- TempFwbDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) &TempFvbDevicePathData;
+ TempFwbDevicePath = (EFI_DEVICE_PATH_PROTOCOL *)&TempFvbDevicePathData;
CopyMem (TempFwbDevicePath, &FvbDevice->DevicePath, sizeof (FV_DEVICE_PATH));
Status = gBS->LocateDevicePath (&gEfiFirmwareVolumeBlockProtocolGuid, &TempFwbDevicePath, &FwbHandle);
if (EFI_ERROR (Status)) {
@@ -1302,14 +1331,14 @@ Returns:
// LocateDevicePath fails so install a new interface and device path
//
FwbHandle = NULL;
- Status = gBS->InstallMultipleProtocolInterfaces (
- &FwbHandle,
- &gEfiFirmwareVolumeBlockProtocolGuid,
- &FvbDevice->FwVolBlockInstance,
- &gEfiDevicePathProtocolGuid,
- &FvbDevice->DevicePath,
- NULL
- );
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &FwbHandle,
+ &gEfiFirmwareVolumeBlockProtocolGuid,
+ &FvbDevice->FwVolBlockInstance,
+ &gEfiDevicePathProtocolGuid,
+ &FvbDevice->DevicePath,
+ NULL
+ );
ASSERT_EFI_ERROR (Status);
} else if (IsDevicePathEnd (TempFwbDevicePath)) {
//
@@ -1318,7 +1347,7 @@ Returns:
Status = gBS->HandleProtocol (
FwbHandle,
&gEfiFirmwareVolumeBlockProtocolGuid,
- (VOID**)&OldFwbInterface
+ (VOID **)&OldFwbInterface
);
ASSERT_EFI_ERROR (Status);
@@ -1329,7 +1358,6 @@ Returns:
&FvbDevice->FwVolBlockInstance
);
ASSERT_EFI_ERROR (Status);
-
} else {
//
// There was a FVB protocol on an End Device Path node
@@ -1338,10 +1366,10 @@ Returns:
}
FwhInstance = (EFI_FW_VOL_INSTANCE *)
- (
- (UINTN) ((UINT8 *) FwhInstance) + FwVolHeader->HeaderLength +
- (sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER))
- );
+ (
+ (UINTN)((UINT8 *)FwhInstance) + FwVolHeader->HeaderLength +
+ (sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER))
+ );
FvHob.Raw = GET_NEXT_HOB (FvHob);
}
diff --git a/EmulatorPkg/FvbServicesRuntimeDxe/FvbInfo.c b/EmulatorPkg/FvbServicesRuntimeDxe/FvbInfo.c
index af8f9a9831..bf2f0ac980 100644
--- a/EmulatorPkg/FvbServicesRuntimeDxe/FvbInfo.c
+++ b/EmulatorPkg/FvbServicesRuntimeDxe/FvbInfo.c
@@ -31,14 +31,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/PcdLib.h>
#include <Library/DevicePathLib.h>
-
typedef struct {
- UINT64 FvLength;
- EFI_FIRMWARE_VOLUME_HEADER FvbInfo;
+ UINT64 FvLength;
+ EFI_FIRMWARE_VOLUME_HEADER FvbInfo;
//
// EFI_FV_BLOCK_MAP_ENTRY ExtraBlockMap[n];//n=0
//
- EFI_FV_BLOCK_MAP_ENTRY End[1];
+ EFI_FV_BLOCK_MAP_ENTRY End[1];
} EFI_FVB_MEDIA_INFO;
EFI_FVB_MEDIA_INFO mPlatformFvbMediaInfo[] = {
@@ -55,10 +54,10 @@ EFI_FVB_MEDIA_INFO mPlatformFvbMediaInfo[] = {
FixedPcdGet32 (PcdEmuFlashFvRecoverySize),
EFI_FVH_SIGNATURE,
EFI_FVB2_READ_ENABLED_CAP |
- EFI_FVB2_READ_STATUS |
- EFI_FVB2_WRITE_ENABLED_CAP |
- EFI_FVB2_WRITE_STATUS |
- EFI_FVB2_ERASE_POLARITY,
+ EFI_FVB2_READ_STATUS |
+ EFI_FVB2_WRITE_ENABLED_CAP |
+ EFI_FVB2_WRITE_STATUS |
+ EFI_FVB2_ERASE_POLARITY,
sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),
0, // CheckSum
0, // ExtHeaderOffset
@@ -99,10 +98,10 @@ EFI_FVB_MEDIA_INFO mPlatformFvbMediaInfo[] = {
FixedPcdGet32 (PcdEmuFlashNvStorageEventLogSize),
EFI_FVH_SIGNATURE,
EFI_FVB2_READ_ENABLED_CAP |
- EFI_FVB2_READ_STATUS |
- EFI_FVB2_WRITE_ENABLED_CAP |
- EFI_FVB2_WRITE_STATUS |
- EFI_FVB2_ERASE_POLARITY,
+ EFI_FVB2_READ_STATUS |
+ EFI_FVB2_WRITE_ENABLED_CAP |
+ EFI_FVB2_WRITE_STATUS |
+ EFI_FVB2_ERASE_POLARITY,
sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),
0, // CheckSum
0, // ExtHeaderOffset
@@ -113,9 +112,9 @@ EFI_FVB_MEDIA_INFO mPlatformFvbMediaInfo[] = {
{
{
(FixedPcdGet32 (PcdFlashNvStorageVariableSize) + \
- FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + \
- FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + \
- FixedPcdGet32 (PcdEmuFlashNvStorageEventLogSize)) / FixedPcdGet32 (PcdEmuFirmwareBlockSize),
+ FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + \
+ FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + \
+ FixedPcdGet32 (PcdEmuFlashNvStorageEventLogSize)) / FixedPcdGet32 (PcdEmuFirmwareBlockSize),
FixedPcdGet32 (PcdEmuFirmwareBlockSize),
}
}
@@ -131,11 +130,11 @@ EFI_FVB_MEDIA_INFO mPlatformFvbMediaInfo[] = {
EFI_STATUS
GetFvbInfo (
- IN UINT64 FvLength,
- OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo
+ IN UINT64 FvLength,
+ OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo
)
{
- UINTN Index;
+ UINTN Index;
for (Index = 0; Index < sizeof (mPlatformFvbMediaInfo) / sizeof (EFI_FVB_MEDIA_INFO); Index += 1) {
if (mPlatformFvbMediaInfo[Index].FvLength == FvLength) {
diff --git a/EmulatorPkg/FvbServicesRuntimeDxe/FwBlockService.h b/EmulatorPkg/FvbServicesRuntimeDxe/FwBlockService.h
index 8808b01e05..4278210c1d 100644
--- a/EmulatorPkg/FvbServicesRuntimeDxe/FwBlockService.h
+++ b/EmulatorPkg/FvbServicesRuntimeDxe/FwBlockService.h
@@ -17,15 +17,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define FVB_VIRTUAL 1
typedef struct {
- EFI_LOCK FvbDevLock;
- UINTN FvBase[2];
- UINTN NumOfBlocks;
- EFI_FIRMWARE_VOLUME_HEADER VolumeHeader;
+ EFI_LOCK FvbDevLock;
+ UINTN FvBase[2];
+ UINTN NumOfBlocks;
+ EFI_FIRMWARE_VOLUME_HEADER VolumeHeader;
} EFI_FW_VOL_INSTANCE;
typedef struct {
- UINT32 NumFv;
- EFI_FW_VOL_INSTANCE *FvInstance[2];
+ UINT32 NumFv;
+ EFI_FW_VOL_INSTANCE *FvInstance[2];
} ESAL_FWB_GLOBAL;
//
@@ -33,113 +33,112 @@ typedef struct {
//
#define FVB_DEVICE_FROM_THIS(a) CR (a, EFI_FW_VOL_BLOCK_DEVICE, FwVolBlockInstance, FVB_DEVICE_SIGNATURE)
#define FVB_EXTEND_DEVICE_FROM_THIS(a) CR (a, EFI_FW_VOL_BLOCK_DEVICE, FvbExtension, FVB_DEVICE_SIGNATURE)
-#define FVB_DEVICE_SIGNATURE SIGNATURE_32 ('F', 'V', 'B', 'N')
+#define FVB_DEVICE_SIGNATURE SIGNATURE_32 ('F', 'V', 'B', 'N')
typedef struct {
- MEMMAP_DEVICE_PATH MemMapDevPath;
- EFI_DEVICE_PATH_PROTOCOL EndDevPath;
+ MEMMAP_DEVICE_PATH MemMapDevPath;
+ EFI_DEVICE_PATH_PROTOCOL EndDevPath;
} FV_DEVICE_PATH;
typedef struct {
- UINTN Signature;
- FV_DEVICE_PATH DevicePath;
- UINTN Instance;
- EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL FwVolBlockInstance;
+ UINTN Signature;
+ FV_DEVICE_PATH DevicePath;
+ UINTN Instance;
+ EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL FwVolBlockInstance;
} EFI_FW_VOL_BLOCK_DEVICE;
EFI_STATUS
GetFvbInfo (
- IN UINT64 FvLength,
- OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo
+ IN UINT64 FvLength,
+ OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo
)
;
EFI_STATUS
FvbReadBlock (
- IN UINTN Instance,
- IN EFI_LBA Lba,
- IN UINTN BlockOffset,
- IN OUT UINTN *NumBytes,
- IN UINT8 *Buffer,
- IN ESAL_FWB_GLOBAL *Global,
- IN BOOLEAN Virtual
+ IN UINTN Instance,
+ IN EFI_LBA Lba,
+ IN UINTN BlockOffset,
+ IN OUT UINTN *NumBytes,
+ IN UINT8 *Buffer,
+ IN ESAL_FWB_GLOBAL *Global,
+ IN BOOLEAN Virtual
)
;
EFI_STATUS
FvbWriteBlock (
- IN UINTN Instance,
- IN EFI_LBA Lba,
- IN UINTN BlockOffset,
- IN OUT UINTN *NumBytes,
- IN UINT8 *Buffer,
- IN ESAL_FWB_GLOBAL *Global,
- IN BOOLEAN Virtual
+ IN UINTN Instance,
+ IN EFI_LBA Lba,
+ IN UINTN BlockOffset,
+ IN OUT UINTN *NumBytes,
+ IN UINT8 *Buffer,
+ IN ESAL_FWB_GLOBAL *Global,
+ IN BOOLEAN Virtual
)
;
EFI_STATUS
FvbEraseBlock (
- IN UINTN Instance,
- IN EFI_LBA Lba,
- IN ESAL_FWB_GLOBAL *Global,
- IN BOOLEAN Virtual
+ IN UINTN Instance,
+ IN EFI_LBA Lba,
+ IN ESAL_FWB_GLOBAL *Global,
+ IN BOOLEAN Virtual
)
;
EFI_STATUS
FvbSetVolumeAttributes (
- IN UINTN Instance,
- IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes,
- IN ESAL_FWB_GLOBAL *Global,
- IN BOOLEAN Virtual
+ IN UINTN Instance,
+ IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes,
+ IN ESAL_FWB_GLOBAL *Global,
+ IN BOOLEAN Virtual
)
;
EFI_STATUS
FvbGetVolumeAttributes (
- IN UINTN Instance,
- OUT EFI_FVB_ATTRIBUTES_2 *Attributes,
- IN ESAL_FWB_GLOBAL *Global,
- IN BOOLEAN Virtual
+ IN UINTN Instance,
+ OUT EFI_FVB_ATTRIBUTES_2 *Attributes,
+ IN ESAL_FWB_GLOBAL *Global,
+ IN BOOLEAN Virtual
)
;
EFI_STATUS
FvbGetPhysicalAddress (
- IN UINTN Instance,
- OUT EFI_PHYSICAL_ADDRESS *Address,
- IN ESAL_FWB_GLOBAL *Global,
- IN BOOLEAN Virtual
+ IN UINTN Instance,
+ OUT EFI_PHYSICAL_ADDRESS *Address,
+ IN ESAL_FWB_GLOBAL *Global,
+ IN BOOLEAN Virtual
)
;
EFI_STATUS
EFIAPI
FvbInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
;
-
VOID
EFIAPI
FvbClassAddressChangeEvent (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
;
EFI_STATUS
FvbGetLbaAddress (
- IN UINTN Instance,
- IN EFI_LBA Lba,
- OUT UINTN *LbaAddress,
- OUT UINTN *LbaLength,
- OUT UINTN *NumOfBlocks,
- IN ESAL_FWB_GLOBAL *Global,
- IN BOOLEAN Virtual
+ IN UINTN Instance,
+ IN EFI_LBA Lba,
+ OUT UINTN *LbaAddress,
+ OUT UINTN *LbaLength,
+ OUT UINTN *NumOfBlocks,
+ IN ESAL_FWB_GLOBAL *Global,
+ IN BOOLEAN Virtual
)
;
@@ -149,63 +148,63 @@ FvbGetLbaAddress (
EFI_STATUS
EFIAPI
FvbProtocolGetAttributes (
- IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
- OUT EFI_FVB_ATTRIBUTES_2 *Attributes
+ IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
+ OUT EFI_FVB_ATTRIBUTES_2 *Attributes
)
;
EFI_STATUS
EFIAPI
FvbProtocolSetAttributes (
- IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
- IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes
+ IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
+ IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes
)
;
EFI_STATUS
EFIAPI
FvbProtocolGetPhysicalAddress (
- IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
- OUT EFI_PHYSICAL_ADDRESS *Address
+ IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
+ OUT EFI_PHYSICAL_ADDRESS *Address
)
;
EFI_STATUS
EFIAPI
FvbProtocolGetBlockSize (
- IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
- IN EFI_LBA Lba,
- OUT UINTN *BlockSize,
- OUT UINTN *NumOfBlocks
+ IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
+ IN EFI_LBA Lba,
+ OUT UINTN *BlockSize,
+ OUT UINTN *NumOfBlocks
)
;
EFI_STATUS
EFIAPI
FvbProtocolRead (
- IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
- IN EFI_LBA Lba,
- IN UINTN Offset,
- IN OUT UINTN *NumBytes,
- IN UINT8 *Buffer
+ IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
+ IN EFI_LBA Lba,
+ IN UINTN Offset,
+ IN OUT UINTN *NumBytes,
+ IN UINT8 *Buffer
)
;
EFI_STATUS
EFIAPI
FvbProtocolWrite (
- IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
- IN EFI_LBA Lba,
- IN UINTN Offset,
- IN OUT UINTN *NumBytes,
- IN UINT8 *Buffer
+ IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
+ IN EFI_LBA Lba,
+ IN UINTN Offset,
+ IN OUT UINTN *NumBytes,
+ IN UINT8 *Buffer
)
;
EFI_STATUS
EFIAPI
FvbProtocolEraseBlocks (
- IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
+ IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
...
)
;
diff --git a/EmulatorPkg/Include/Guid/EmuPhysicalDisk.h b/EmulatorPkg/Include/Guid/EmuPhysicalDisk.h
index 0886ea4f53..e1be4d200e 100644
--- a/EmulatorPkg/Include/Guid/EmuPhysicalDisk.h
+++ b/EmulatorPkg/Include/Guid/EmuPhysicalDisk.h
@@ -13,6 +13,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define EFI_EMU_PHYSICAL_DISK_GUID \
{ 0xf2ba331a, 0x8985, 0x11db, { 0xa4, 0x06, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } }
-extern EFI_GUID gEmuPhysicalDisksGuid;
+extern EFI_GUID gEmuPhysicalDisksGuid;
#endif
diff --git a/EmulatorPkg/Include/Guid/EmuSystemConfig.h b/EmulatorPkg/Include/Guid/EmuSystemConfig.h
index 7c51d7e40c..e448220740 100644
--- a/EmulatorPkg/Include/Guid/EmuSystemConfig.h
+++ b/EmulatorPkg/Include/Guid/EmuSystemConfig.h
@@ -13,18 +13,16 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define EFI_EMU_SYSTEM_CONFIG_GUID \
{ 0x9C4FB516, 0x3A1E, 0xD847, { 0xA1, 0xA1, 0x70, 0x58, 0xB6, 0x98, 0x67, 0x32 } }
-
#pragma pack(1)
typedef struct {
//
// Console output mode
//
- UINT32 ConOutColumn;
- UINT32 ConOutRow;
+ UINT32 ConOutColumn;
+ UINT32 ConOutRow;
} EMU_SYSTEM_CONFIGURATION;
#pragma pack()
-
-extern EFI_GUID gEmuSystemConfigGuid;
+extern EFI_GUID gEmuSystemConfigGuid;
#endif
diff --git a/EmulatorPkg/Include/Guid/EmuVirtualDisk.h b/EmulatorPkg/Include/Guid/EmuVirtualDisk.h
index 7e056887ed..66fc95f65f 100644
--- a/EmulatorPkg/Include/Guid/EmuVirtualDisk.h
+++ b/EmulatorPkg/Include/Guid/EmuVirtualDisk.h
@@ -13,6 +13,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define EFI_EMU_VIRTUAL_DISK_GUID \
{ 0xf2ba331a, 0x8985, 0x11db, { 0xa4, 0x06, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } }
-extern EFI_GUID gEmuVirtualDisksGuid;
+extern EFI_GUID gEmuVirtualDisksGuid;
#endif
diff --git a/EmulatorPkg/Include/Library/EmuMagicPageLib.h b/EmulatorPkg/Include/Library/EmuMagicPageLib.h
index fb4fcc1f2f..d102f1666a 100644
--- a/EmulatorPkg/Include/Library/EmuMagicPageLib.h
+++ b/EmulatorPkg/Include/Library/EmuMagicPageLib.h
@@ -18,15 +18,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
typedef struct {
// Used by PEI Core and PEIMs to store the PEI Services pointer.
// Privilege issues prevent using the PI mechanism in the emulator.
- CONST EFI_PEI_SERVICES **PeiServicesTablePointer;
+ CONST EFI_PEI_SERVICES **PeiServicesTablePointer;
// Used by SecPeiServicesLib
- EFI_PEI_PPI_DESCRIPTOR *PpiList;
+ EFI_PEI_PPI_DESCRIPTOR *PpiList;
// Needed by PEI PEI PeCoffLoaderExtraActionLib
- EMU_THUNK_PROTOCOL *Thunk;
+ EMU_THUNK_PROTOCOL *Thunk;
} EMU_MAGIC_PAGE_LAYOUT;
-#define EMU_MAGIC_PAGE() ((EMU_MAGIC_PAGE_LAYOUT *)((UINTN)PcdGet64 (PcdPeiServicesTablePage)))
+#define EMU_MAGIC_PAGE() ((EMU_MAGIC_PAGE_LAYOUT *)((UINTN)PcdGet64 (PcdPeiServicesTablePage)))
#endif
diff --git a/EmulatorPkg/Include/Library/EmuThunkLib.h b/EmulatorPkg/Include/Library/EmuThunkLib.h
index ddb3d59b00..54bd7e65cd 100644
--- a/EmulatorPkg/Include/Library/EmuThunkLib.h
+++ b/EmulatorPkg/Include/Library/EmuThunkLib.h
@@ -10,9 +10,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Protocol/EmuThunk.h>
-
-extern EMU_THUNK_PROTOCOL *gEmuThunk;
-
+extern EMU_THUNK_PROTOCOL *gEmuThunk;
/**
Serach the EMU IO Thunk database for a matching EMU IO Thunk
@@ -32,5 +30,4 @@ GetIoThunkInstance (
IN UINTN Instance
);
-
#endif
diff --git a/EmulatorPkg/Include/Library/KeyMapLib.h b/EmulatorPkg/Include/Library/KeyMapLib.h
index 41d9795ddf..9eb2a66efb 100644
--- a/EmulatorPkg/Include/Library/KeyMapLib.h
+++ b/EmulatorPkg/Include/Library/KeyMapLib.h
@@ -7,7 +7,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Protocol/SimpleTextInEx.h>
-
/**
KeyMapMake gets called on key presses.
@@ -19,7 +18,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
EFI_STATUS
EFIAPI
KeyMapMake (
- IN EFI_KEY_DATA *KeyData
+ IN EFI_KEY_DATA *KeyData
);
/**
@@ -33,5 +32,5 @@ KeyMapMake (
EFI_STATUS
EFIAPI
KeyMapBreak (
- IN EFI_KEY_DATA *KeyData
+ IN EFI_KEY_DATA *KeyData
);
diff --git a/EmulatorPkg/Include/Library/PpiListLib.h b/EmulatorPkg/Include/Library/PpiListLib.h
index a531328f97..a538cfde12 100644
--- a/EmulatorPkg/Include/Library/PpiListLib.h
+++ b/EmulatorPkg/Include/Library/PpiListLib.h
@@ -8,8 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef __PPI_LIST_LIB_H__
#define __PPI_LIST_LIB_H__
-
extern CONST EFI_PEI_PPI_DESCRIPTOR *gPpiList;
-
#endif
diff --git a/EmulatorPkg/Include/Library/SmbiosLib.h b/EmulatorPkg/Include/Library/SmbiosLib.h
index 1022b48c5e..aeba2f908e 100644
--- a/EmulatorPkg/Include/Library/SmbiosLib.h
+++ b/EmulatorPkg/Include/Library/SmbiosLib.h
@@ -15,12 +15,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <IndustryStandard/SmBios.h>
#include <Protocol/Smbios.h>
-
///
/// Cache copy of the SMBIOS Protocol pointer
///
-extern EFI_SMBIOS_PROTOCOL *gSmbios;
-
+extern EFI_SMBIOS_PROTOCOL *gSmbios;
///
/// Template for SMBIOS table initialization.
@@ -38,7 +36,6 @@ typedef struct {
CHAR8 **StringArray;
} SMBIOS_TEMPLATE_ENTRY;
-
/**
Create an initial SMBIOS Table from an array of SMBIOS_TEMPLATE_ENTRY
entries. SMBIOS_TEMPLATE_ENTRY.NULL indicates the end of the table.
@@ -51,11 +48,9 @@ typedef struct {
EFI_STATUS
EFIAPI
SmbiosLibInitializeFromTemplate (
- IN SMBIOS_TEMPLATE_ENTRY *Template
+ IN SMBIOS_TEMPLATE_ENTRY *Template
);
-
-
/**
Create SMBIOS record.
@@ -88,11 +83,10 @@ SmbiosLibInitializeFromTemplate (
EFI_STATUS
EFIAPI
SmbiosLibCreateEntry (
- IN SMBIOS_STRUCTURE *SmbiosEntry,
- IN CHAR8 **StringArray
+ IN SMBIOS_STRUCTURE *SmbiosEntry,
+ IN CHAR8 **StringArray
);
-
/**
Update the string associated with an existing SMBIOS record.
@@ -111,9 +105,9 @@ SmbiosLibCreateEntry (
EFI_STATUS
EFIAPI
SmbiosLibUpdateString (
- IN EFI_SMBIOS_HANDLE SmbiosHandle,
- IN SMBIOS_TABLE_STRING StringNumber,
- IN CHAR8 *String
+ IN EFI_SMBIOS_HANDLE SmbiosHandle,
+ IN SMBIOS_TABLE_STRING StringNumber,
+ IN CHAR8 *String
);
/**
@@ -134,9 +128,9 @@ SmbiosLibUpdateString (
EFI_STATUS
EFIAPI
SmbiosLibUpdateUnicodeString (
- IN EFI_SMBIOS_HANDLE SmbiosHandle,
- IN SMBIOS_TABLE_STRING StringNumber,
- IN CHAR16 *String
+ IN EFI_SMBIOS_HANDLE SmbiosHandle,
+ IN SMBIOS_TABLE_STRING StringNumber,
+ IN CHAR16 *String
);
/**
@@ -155,7 +149,6 @@ SmbiosLibReadString (
IN EFI_SMBIOS_STRING StringNumber
);
-
/**
Allow the caller to discover a specific SMBIOS entry, and patch it if necissary.
@@ -169,9 +162,9 @@ SmbiosLibReadString (
SMBIOS_STRUCTURE *
EFIAPI
SmbiosLibGetRecord (
- IN EFI_SMBIOS_TYPE Type,
- IN UINTN Instance,
- OUT EFI_SMBIOS_HANDLE *SmbiosHandle
+ IN EFI_SMBIOS_TYPE Type,
+ IN UINTN Instance,
+ OUT EFI_SMBIOS_HANDLE *SmbiosHandle
);
/**
@@ -187,10 +180,7 @@ SmbiosLibGetRecord (
EFI_STATUS
EFIAPI
SmbiosLibRemove (
- OUT EFI_SMBIOS_HANDLE SmbiosHandle
+ OUT EFI_SMBIOS_HANDLE SmbiosHandle
);
-
-
-
#endif
diff --git a/EmulatorPkg/Include/Library/ThunkPpiList.h b/EmulatorPkg/Include/Library/ThunkPpiList.h
index d33ae6db8c..011565850d 100644
--- a/EmulatorPkg/Include/Library/ThunkPpiList.h
+++ b/EmulatorPkg/Include/Library/ThunkPpiList.h
@@ -9,13 +9,11 @@
#include <PiPei.h>
-
EFI_PEI_PPI_DESCRIPTOR *
GetThunkPpiList (
VOID
);
-
EFI_STATUS
EFIAPI
AddThunkPpi (
@@ -23,5 +21,3 @@ AddThunkPpi (
IN EFI_GUID *Guid,
IN VOID *Ppi
);
-
-
diff --git a/EmulatorPkg/Include/Library/ThunkProtocolList.h b/EmulatorPkg/Include/Library/ThunkProtocolList.h
index 83f8fc93f6..c3b2756d9c 100644
--- a/EmulatorPkg/Include/Library/ThunkProtocolList.h
+++ b/EmulatorPkg/Include/Library/ThunkProtocolList.h
@@ -10,20 +10,17 @@
#include <Uefi.h>
#include <Protocol/EmuIoThunk.h>
-
EFI_STATUS
EFIAPI
AddThunkProtocol (
- IN EMU_IO_THUNK_PROTOCOL *ThunkIo,
- IN CHAR16 *ConfigString,
- IN BOOLEAN EmuBusDriver
+ IN EMU_IO_THUNK_PROTOCOL *ThunkIo,
+ IN CHAR16 *ConfigString,
+ IN BOOLEAN EmuBusDriver
);
EFI_STATUS
EFIAPI
GetNextThunkProtocol (
- IN BOOLEAN EmuBusDriver,
- OUT EMU_IO_THUNK_PROTOCOL **Instance
+ IN BOOLEAN EmuBusDriver,
+ OUT EMU_IO_THUNK_PROTOCOL **Instance
);
-
-
diff --git a/EmulatorPkg/Include/Ppi/EmuThunk.h b/EmulatorPkg/Include/Ppi/EmuThunk.h
index 9c7fa1b81d..c0e2bc6b98 100644
--- a/EmulatorPkg/Include/Ppi/EmuThunk.h
+++ b/EmulatorPkg/Include/Ppi/EmuThunk.h
@@ -13,8 +13,6 @@
#define EMU_THUNK_PPI_GUID \
{ 0xB958B78C, 0x1D3E, 0xEE40, { 0x8B, 0xF4, 0xF0, 0x63, 0x2D, 0x06, 0x39, 0x16 } }
-
-
/*++
Routine Description:
@@ -33,13 +31,12 @@ Returns:
**/
typedef
EFI_STATUS
-(EFIAPI *EMU_PEI_AUTOSCAN) (
+(EFIAPI *EMU_PEI_AUTOSCAN)(
IN UINTN Index,
OUT EFI_PHYSICAL_ADDRESS *MemoryBase,
OUT UINT64 *MemorySize
);
-
/*++
Routine Description:
@@ -59,14 +56,13 @@ Returns:
**/
typedef
EFI_STATUS
-(EFIAPI *EMU_PEI_FD_INFORMATION) (
+(EFIAPI *EMU_PEI_FD_INFORMATION)(
IN UINTN Index,
IN OUT EFI_PHYSICAL_ADDRESS *FdBase,
IN OUT UINT64 *FdSize,
IN OUT EFI_PHYSICAL_ADDRESS *FixUp
);
-
/*++
Routine Description:
@@ -78,12 +74,10 @@ Returns:
**/
typedef
VOID *
-(EFIAPI *EMU_PEI_THUNK_INTERFACE) (
+(EFIAPI *EMU_PEI_THUNK_INTERFACE)(
VOID
);
-
-
/*++
Routine Description:
@@ -102,20 +96,19 @@ Returns:
**/
typedef
EFI_STATUS
-(EFIAPI *EMU_PEI_LOAD_FILE) (
+(EFIAPI *EMU_PEI_LOAD_FILE)(
VOID *Pe32Data,
EFI_PHYSICAL_ADDRESS *ImageAddress,
UINT64 *ImageSize,
EFI_PHYSICAL_ADDRESS *EntryPoint
);
-
typedef struct {
- EMU_PEI_AUTOSCAN MemoryAutoScan;
- EMU_PEI_FD_INFORMATION FirmwareDevices;
- EMU_PEI_THUNK_INTERFACE Thunk;
+ EMU_PEI_AUTOSCAN MemoryAutoScan;
+ EMU_PEI_FD_INFORMATION FirmwareDevices;
+ EMU_PEI_THUNK_INTERFACE Thunk;
} EMU_THUNK_PPI;
-extern EFI_GUID gEmuThunkPpiGuid;
+extern EFI_GUID gEmuThunkPpiGuid;
#endif
diff --git a/EmulatorPkg/Include/Protocol/EmuBlockIo.h b/EmulatorPkg/Include/Protocol/EmuBlockIo.h
index a17cefa83d..494e100e74 100644
--- a/EmulatorPkg/Include/Protocol/EmuBlockIo.h
+++ b/EmulatorPkg/Include/Protocol/EmuBlockIo.h
@@ -19,9 +19,7 @@
#define EMU_BLOCK_IO_PROTOCOL_GUID \
{ 0x6888A4AE, 0xAFCE, 0xE84B, { 0x91, 0x02, 0xF7, 0xB9, 0xDA, 0xE6, 0xA0, 0x30 } }
-typedef struct _EMU_BLOCK_IO_PROTOCOL EMU_BLOCK_IO_PROTOCOL;
-
-
+typedef struct _EMU_BLOCK_IO_PROTOCOL EMU_BLOCK_IO_PROTOCOL;
/**
Reset the block device hardware.
@@ -38,7 +36,7 @@ typedef struct _EMU_BLOCK_IO_PROTOCOL EMU_BLOCK_IO_PROTOCOL;
**/
typedef
EFI_STATUS
-(EFIAPI *EMU_BLOCK_RESET) (
+(EFIAPI *EMU_BLOCK_RESET)(
IN EMU_BLOCK_IO_PROTOCOL *This,
IN BOOLEAN ExtendedVerification
);
@@ -78,13 +76,13 @@ EFI_STATUS
**/
typedef
EFI_STATUS
-(EFIAPI *EMU_BLOCK_READ) (
+(EFIAPI *EMU_BLOCK_READ)(
IN EMU_BLOCK_IO_PROTOCOL *This,
IN UINT32 MediaId,
IN EFI_LBA LBA,
IN OUT EFI_BLOCK_IO2_TOKEN *Token,
IN UINTN BufferSize,
- OUT VOID *Buffer
+ OUT VOID *Buffer
);
/**
@@ -120,7 +118,7 @@ EFI_STATUS
**/
typedef
EFI_STATUS
-(EFIAPI *EMU_BLOCK_WRITE) (
+(EFIAPI *EMU_BLOCK_WRITE)(
IN EMU_BLOCK_IO_PROTOCOL *This,
IN UINT32 MediaId,
IN EFI_LBA LBA,
@@ -153,34 +151,31 @@ EFI_STATUS
**/
typedef
EFI_STATUS
-(EFIAPI *EMU_BLOCK_FLUSH) (
+(EFIAPI *EMU_BLOCK_FLUSH)(
IN EMU_BLOCK_IO_PROTOCOL *This,
IN OUT EFI_BLOCK_IO2_TOKEN *Token
);
-
typedef
EFI_STATUS
-(EFIAPI *EMU_BLOCK_CREATE_MAPPING) (
+(EFIAPI *EMU_BLOCK_CREATE_MAPPING)(
IN EMU_BLOCK_IO_PROTOCOL *This,
IN EFI_BLOCK_IO_MEDIA *Media
);
-
///
/// The Block I/O2 protocol defines an extension to the Block I/O protocol which
/// enables the ability to read and write data at a block level in a non-blocking
// manner.
///
struct _EMU_BLOCK_IO_PROTOCOL {
- EMU_BLOCK_RESET Reset;
- EMU_BLOCK_READ ReadBlocks;
- EMU_BLOCK_WRITE WriteBlocks;
- EMU_BLOCK_FLUSH FlushBlocks;
- EMU_BLOCK_CREATE_MAPPING CreateMapping;
+ EMU_BLOCK_RESET Reset;
+ EMU_BLOCK_READ ReadBlocks;
+ EMU_BLOCK_WRITE WriteBlocks;
+ EMU_BLOCK_FLUSH FlushBlocks;
+ EMU_BLOCK_CREATE_MAPPING CreateMapping;
};
-extern EFI_GUID gEmuBlockIoProtocolGuid;
+extern EFI_GUID gEmuBlockIoProtocolGuid;
#endif
-
diff --git a/EmulatorPkg/Include/Protocol/EmuFileSystem.h b/EmulatorPkg/Include/Protocol/EmuFileSystem.h
index 8ac9d9ba5d..15de43ac02 100644
--- a/EmulatorPkg/Include/Protocol/EmuFileSystem.h
+++ b/EmulatorPkg/Include/Protocol/EmuFileSystem.h
@@ -55,36 +55,34 @@ EFI_STATUS
typedef
EFI_STATUS
-(EFIAPI *EMU_GRAPHICS_WINDOWS_KEY_SET_STATE) (
+(EFIAPI *EMU_GRAPHICS_WINDOWS_KEY_SET_STATE)(
IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows,
IN EFI_KEY_TOGGLE_STATE *KeyToggleState
);
-
typedef
VOID
-(EFIAPI *EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK) (
+(EFIAPI *EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK)(
IN VOID *Context,
IN EFI_KEY_DATA *KeyData
);
typedef
EFI_STATUS
-(EFIAPI *EMU_GRAPHICS_WINDOWS_REGISTER_KEY_NOTIFY) (
+(EFIAPI *EMU_GRAPHICS_WINDOWS_REGISTER_KEY_NOTIFY)(
IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows,
IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK CallBack,
IN VOID *Context
);
-
typedef struct {
- UINTN SourceX;
- UINTN SourceY;
- UINTN DestinationX;
- UINTN DestinationY;
- UINTN Width;
- UINTN Height;
- UINTN Delta;
+ UINTN SourceX;
+ UINTN SourceY;
+ UINTN DestinationX;
+ UINTN DestinationY;
+ UINTN Width;
+ UINTN Height;
+ UINTN Delta;
} EMU_GRAPHICS_WINDOWS__BLT_ARGS;
typedef
@@ -98,7 +96,7 @@ EFI_STATUS
typedef
BOOLEAN
-(EFIAPI *EMU_GRAPHICS_WINDOWS_IS_KEY_PRESSED) (
+(EFIAPI *EMU_GRAPHICS_WINDOWS_IS_KEY_PRESSED)(
IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows,
IN EFI_KEY_DATA *KeyData
);
@@ -117,18 +115,17 @@ EFI_STATUS
);
struct _EMU_GRAPHICS_WINDOW_PROTOCOL {
- EMU_GRAPHICS_WINDOWS_SIZE Size;
- EMU_GRAPHICS_WINDOWS_CHECK_KEY CheckKey;
- EMU_GRAPHICS_WINDOWS_KEY_SET_STATE KeySetState;
- EMU_GRAPHICS_WINDOWS_GET_KEY GetKey;
- EMU_GRAPHICS_WINDOWS_REGISTER_KEY_NOTIFY RegisterKeyNotify;
- EMU_GRAPHICS_WINDOWS_BLT Blt;
- EMU_GRAPHICS_WINDOWS_IS_KEY_PRESSED IsKeyPressed;
- EMU_GRAPHICS_WINDOWS_CHECK_POINTER CheckPointer;
- EMU_GRAPHICS_WINDOWS_GET_POINTER_STATE GetPointerState;
+ EMU_GRAPHICS_WINDOWS_SIZE Size;
+ EMU_GRAPHICS_WINDOWS_CHECK_KEY CheckKey;
+ EMU_GRAPHICS_WINDOWS_KEY_SET_STATE KeySetState;
+ EMU_GRAPHICS_WINDOWS_GET_KEY GetKey;
+ EMU_GRAPHICS_WINDOWS_REGISTER_KEY_NOTIFY RegisterKeyNotify;
+ EMU_GRAPHICS_WINDOWS_BLT Blt;
+ EMU_GRAPHICS_WINDOWS_IS_KEY_PRESSED IsKeyPressed;
+ EMU_GRAPHICS_WINDOWS_CHECK_POINTER CheckPointer;
+ EMU_GRAPHICS_WINDOWS_GET_POINTER_STATE GetPointerState;
};
-
-extern EFI_GUID gEmuGraphicsWindowProtocolGuid;
+extern EFI_GUID gEmuGraphicsWindowProtocolGuid;
#endif
diff --git a/EmulatorPkg/Include/Protocol/EmuGraphicsWindow.h b/EmulatorPkg/Include/Protocol/EmuGraphicsWindow.h
index 07d4070b35..7c495b25eb 100644
--- a/EmulatorPkg/Include/Protocol/EmuGraphicsWindow.h
+++ b/EmulatorPkg/Include/Protocol/EmuGraphicsWindow.h
@@ -48,37 +48,35 @@ EFI_STATUS
typedef
EFI_STATUS
-(EFIAPI *EMU_GRAPHICS_WINDOWS_KEY_SET_STATE) (
+(EFIAPI *EMU_GRAPHICS_WINDOWS_KEY_SET_STATE)(
IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows,
IN EFI_KEY_TOGGLE_STATE *KeyToggleState
);
-
typedef
VOID
-(EFIAPI *EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK) (
+(EFIAPI *EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK)(
IN VOID *Context,
IN EFI_KEY_DATA *KeyData
);
typedef
EFI_STATUS
-(EFIAPI *EMU_GRAPHICS_WINDOWS_REGISTER_KEY_NOTIFY) (
+(EFIAPI *EMU_GRAPHICS_WINDOWS_REGISTER_KEY_NOTIFY)(
IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows,
IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK MakeCallBack,
IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK BreakCallBack,
IN VOID *Context
);
-
typedef struct {
- UINTN SourceX;
- UINTN SourceY;
- UINTN DestinationX;
- UINTN DestinationY;
- UINTN Width;
- UINTN Height;
- UINTN Delta;
+ UINTN SourceX;
+ UINTN SourceY;
+ UINTN DestinationX;
+ UINTN DestinationY;
+ UINTN Width;
+ UINTN Height;
+ UINTN Delta;
} EMU_GRAPHICS_WINDOWS__BLT_ARGS;
typedef
@@ -92,7 +90,7 @@ EFI_STATUS
typedef
BOOLEAN
-(EFIAPI *EMU_GRAPHICS_WINDOWS_IS_KEY_PRESSED) (
+(EFIAPI *EMU_GRAPHICS_WINDOWS_IS_KEY_PRESSED)(
IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows,
IN EFI_KEY_DATA *KeyData
);
@@ -111,18 +109,17 @@ EFI_STATUS
);
struct _EMU_GRAPHICS_WINDOW_PROTOCOL {
- EMU_GRAPHICS_WINDOWS_SIZE Size;
- EMU_GRAPHICS_WINDOWS_CHECK_KEY CheckKey;
- EMU_GRAPHICS_WINDOWS_KEY_SET_STATE KeySetState;
- EMU_GRAPHICS_WINDOWS_GET_KEY GetKey;
- EMU_GRAPHICS_WINDOWS_REGISTER_KEY_NOTIFY RegisterKeyNotify;
- EMU_GRAPHICS_WINDOWS_BLT Blt;
- EMU_GRAPHICS_WINDOWS_IS_KEY_PRESSED IsKeyPressed;
- EMU_GRAPHICS_WINDOWS_CHECK_POINTER CheckPointer;
- EMU_GRAPHICS_WINDOWS_GET_POINTER_STATE GetPointerState;
+ EMU_GRAPHICS_WINDOWS_SIZE Size;
+ EMU_GRAPHICS_WINDOWS_CHECK_KEY CheckKey;
+ EMU_GRAPHICS_WINDOWS_KEY_SET_STATE KeySetState;
+ EMU_GRAPHICS_WINDOWS_GET_KEY GetKey;
+ EMU_GRAPHICS_WINDOWS_REGISTER_KEY_NOTIFY RegisterKeyNotify;
+ EMU_GRAPHICS_WINDOWS_BLT Blt;
+ EMU_GRAPHICS_WINDOWS_IS_KEY_PRESSED IsKeyPressed;
+ EMU_GRAPHICS_WINDOWS_CHECK_POINTER CheckPointer;
+ EMU_GRAPHICS_WINDOWS_GET_POINTER_STATE GetPointerState;
};
-
-extern EFI_GUID gEmuGraphicsWindowProtocolGuid;
+extern EFI_GUID gEmuGraphicsWindowProtocolGuid;
#endif
diff --git a/EmulatorPkg/Include/Protocol/EmuIoThunk.h b/EmulatorPkg/Include/Protocol/EmuIoThunk.h
index 6e4c2f8efc..b6da635177 100644
--- a/EmulatorPkg/Include/Protocol/EmuIoThunk.h
+++ b/EmulatorPkg/Include/Protocol/EmuIoThunk.h
@@ -10,36 +10,33 @@
#ifndef __EMU_IO_THUNK__
#define __EMU_IO_THUNK__
-
#define EMU_IO_THUNK_PROTOCO_GUID \
{ 0x453368F6, 0x7C85, 0x434A, { 0xA9, 0x8A, 0x72, 0xD1, 0xB7, 0xFF, 0xA9, 0x26 } }
-
-typedef struct _EMU_IO_THUNK_PROTOCOL EMU_IO_THUNK_PROTOCOL;
-
+typedef struct _EMU_IO_THUNK_PROTOCOL EMU_IO_THUNK_PROTOCOL;
typedef
EFI_STATUS
-(EFIAPI *EMU_IO_THUNK_PROTOCOL_CLOSE_OPEN) (
+(EFIAPI *EMU_IO_THUNK_PROTOCOL_CLOSE_OPEN)(
IN EMU_IO_THUNK_PROTOCOL *This
);
typedef
EFI_STATUS
-(EFIAPI *EMU_IO_THUNK_PROTOCOL_CLOSE_CLOSE) (
+(EFIAPI *EMU_IO_THUNK_PROTOCOL_CLOSE_CLOSE)(
IN EMU_IO_THUNK_PROTOCOL *This
);
struct _EMU_IO_THUNK_PROTOCOL {
- EFI_GUID *Protocol;
- VOID *Interface; /// Only be valid after Open() is called
- CHAR16 *ConfigString;
- UINT16 Instance;
- EMU_IO_THUNK_PROTOCOL_CLOSE_OPEN Open;
- EMU_IO_THUNK_PROTOCOL_CLOSE_CLOSE Close;
- VOID *Private; /// Used by implementation
+ EFI_GUID *Protocol;
+ VOID *Interface; /// Only be valid after Open() is called
+ CHAR16 *ConfigString;
+ UINT16 Instance;
+ EMU_IO_THUNK_PROTOCOL_CLOSE_OPEN Open;
+ EMU_IO_THUNK_PROTOCOL_CLOSE_CLOSE Close;
+ VOID *Private; /// Used by implementation
};
-extern EFI_GUID gEmuIoThunkProtocolGuid;
+extern EFI_GUID gEmuIoThunkProtocolGuid;
#endif
diff --git a/EmulatorPkg/Include/Protocol/EmuSnp.h b/EmulatorPkg/Include/Protocol/EmuSnp.h
index c58808fdd3..b461a1cb38 100644
--- a/EmulatorPkg/Include/Protocol/EmuSnp.h
+++ b/EmulatorPkg/Include/Protocol/EmuSnp.h
@@ -17,8 +17,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define EMU_SNP_PROTOCOL_GUID \
{ 0xFD5FBE54, 0x8C35, 0xB345, { 0x8A, 0x0F, 0x7A, 0xC8, 0xA5, 0xFD, 0x05, 0x21 } }
-typedef struct _EMU_SNP_PROTOCOL EMU_SNP_PROTOCOL;
-
+typedef struct _EMU_SNP_PROTOCOL EMU_SNP_PROTOCOL;
/**
Register storage for SNP Mode.
@@ -37,7 +36,6 @@ EFI_STATUS
IN EFI_SIMPLE_NETWORK_MODE *Mode
);
-
/**
Changes the state of a network interface from "stopped" to "started".
@@ -425,29 +423,29 @@ EFI_STATUS
//
// Revision defined in EFI1.1
//
-#define EMU_SNP_INTERFACE_REVISION EMU_SNP_PROTOCOL_REVISION
+#define EMU_SNP_INTERFACE_REVISION EMU_SNP_PROTOCOL_REVISION
///
/// The EMU_SNP_PROTOCOL protocol abstracts OS network sercices
/// from the EFI driver that produces EFI Simple Network Protocol.
///
struct _EMU_SNP_PROTOCOL {
- EMU_SNP_CREATE_MAPPING CreateMapping;
- EMU_SNP_START Start;
- EMU_SNP_STOP Stop;
- EMU_SNP_INITIALIZE Initialize;
- EMU_SNP_RESET Reset;
- EMU_SNP_SHUTDOWN Shutdown;
- EMU_SNP_RECEIVE_FILTERS ReceiveFilters;
- EMU_SNP_STATION_ADDRESS StationAddress;
- EMU_SNP_STATISTICS Statistics;
- EMU_SNP_MCAST_IP_TO_MAC MCastIpToMac;
- EMU_SNP_NVDATA NvData;
- EMU_SNP_GET_STATUS GetStatus;
- EMU_SNP_TRANSMIT Transmit;
- EMU_SNP_RECEIVE Receive;
+ EMU_SNP_CREATE_MAPPING CreateMapping;
+ EMU_SNP_START Start;
+ EMU_SNP_STOP Stop;
+ EMU_SNP_INITIALIZE Initialize;
+ EMU_SNP_RESET Reset;
+ EMU_SNP_SHUTDOWN Shutdown;
+ EMU_SNP_RECEIVE_FILTERS ReceiveFilters;
+ EMU_SNP_STATION_ADDRESS StationAddress;
+ EMU_SNP_STATISTICS Statistics;
+ EMU_SNP_MCAST_IP_TO_MAC MCastIpToMac;
+ EMU_SNP_NVDATA NvData;
+ EMU_SNP_GET_STATUS GetStatus;
+ EMU_SNP_TRANSMIT Transmit;
+ EMU_SNP_RECEIVE Receive;
};
-extern EFI_GUID gEmuSnpProtocolGuid;
+extern EFI_GUID gEmuSnpProtocolGuid;
#endif
diff --git a/EmulatorPkg/Include/Protocol/EmuThread.h b/EmulatorPkg/Include/Protocol/EmuThread.h
index 89e562d7af..fbde40bb4c 100644
--- a/EmulatorPkg/Include/Protocol/EmuThread.h
+++ b/EmulatorPkg/Include/Protocol/EmuThread.h
@@ -11,55 +11,47 @@
#ifndef __EMU_THREAD_THUNK__
#define __EMU_THREAD_THUNK__
-
-typedef struct _EMU_THREAD_THUNK_PROTOCOL EMU_THREAD_THUNK_PROTOCOL;
-
+typedef struct _EMU_THREAD_THUNK_PROTOCOL EMU_THREAD_THUNK_PROTOCOL;
typedef
UINTN
-(EFIAPI *THREAD_THUNK_MUTEX_LOCK) (
+(EFIAPI *THREAD_THUNK_MUTEX_LOCK)(
IN VOID *Mutex
);
-
typedef
UINTN
-(EFIAPI *THREAD_THUNK_MUTEX_UNLOCK) (
+(EFIAPI *THREAD_THUNK_MUTEX_UNLOCK)(
IN VOID *Mutex
);
-
typedef
UINTN
-(EFIAPI *THREAD_THUNK_MUTEX_TRY_LOCK) (
+(EFIAPI *THREAD_THUNK_MUTEX_TRY_LOCK)(
IN VOID *Mutex
);
-
typedef
VOID *
-(EFIAPI *THREAD_THUNK_MUTEX_INIT) (
+(EFIAPI *THREAD_THUNK_MUTEX_INIT)(
IN VOID
);
-
typedef
UINTN
-(EFIAPI *THREAD_THUNK_MUTEX_DISTROY) (
+(EFIAPI *THREAD_THUNK_MUTEX_DISTROY)(
IN VOID *Mutex
);
-
-
typedef
VOID *
-(EFIAPI *THREAD_THUNK_THREAD_ENTRY) (
+(EFIAPI *THREAD_THUNK_THREAD_ENTRY)(
IN VOID *Context
);
typedef
UINTN
-(EFIAPI *THREAD_THUNK_CREATE_THREAD) (
+(EFIAPI *THREAD_THUNK_CREATE_THREAD)(
IN VOID *Thread,
IN VOID *Attribute,
IN THREAD_THUNK_THREAD_ENTRY Start,
@@ -68,30 +60,27 @@ UINTN
typedef
VOID
-(EFIAPI *THREAD_THUNK_EXIT_THREAD) (
+(EFIAPI *THREAD_THUNK_EXIT_THREAD)(
IN VOID *ValuePtr
);
-
typedef
UINTN
-(EFIAPI *THREAD_THUNK_SELF) (
+(EFIAPI *THREAD_THUNK_SELF)(
VOID
);
-
struct _EMU_THREAD_THUNK_PROTOCOL {
- THREAD_THUNK_MUTEX_LOCK MutexLock;
- THREAD_THUNK_MUTEX_UNLOCK MutexUnlock;
- THREAD_THUNK_MUTEX_TRY_LOCK MutexTryLock;
- THREAD_THUNK_MUTEX_INIT MutexInit;
- THREAD_THUNK_MUTEX_DISTROY MutexDistroy;
- THREAD_THUNK_CREATE_THREAD CreateThread;
- THREAD_THUNK_EXIT_THREAD ExitThread;
- THREAD_THUNK_SELF Self;
+ THREAD_THUNK_MUTEX_LOCK MutexLock;
+ THREAD_THUNK_MUTEX_UNLOCK MutexUnlock;
+ THREAD_THUNK_MUTEX_TRY_LOCK MutexTryLock;
+ THREAD_THUNK_MUTEX_INIT MutexInit;
+ THREAD_THUNK_MUTEX_DISTROY MutexDistroy;
+ THREAD_THUNK_CREATE_THREAD CreateThread;
+ THREAD_THUNK_EXIT_THREAD ExitThread;
+ THREAD_THUNK_SELF Self;
};
-extern EFI_GUID gEmuThreadThunkProtocolGuid;
+extern EFI_GUID gEmuThreadThunkProtocolGuid;
#endif
-
diff --git a/EmulatorPkg/Include/Protocol/EmuThunk.h b/EmulatorPkg/Include/Protocol/EmuThunk.h
index 0bb20651e5..b720023ac9 100644
--- a/EmulatorPkg/Include/Protocol/EmuThunk.h
+++ b/EmulatorPkg/Include/Protocol/EmuThunk.h
@@ -21,166 +21,156 @@
#include <Protocol/EmuIoThunk.h>
#include <Protocol/DevicePath.h>
-
typedef struct {
- VENDOR_DEVICE_PATH VendorDevicePath;
- UINT32 Instance;
+ VENDOR_DEVICE_PATH VendorDevicePath;
+ UINT32 Instance;
} EMU_VENDOR_DEVICE_PATH_NODE;
typedef struct {
- EMU_VENDOR_DEVICE_PATH_NODE Vendor;
- EFI_DEVICE_PATH_PROTOCOL EndDevicePath;
+ EMU_VENDOR_DEVICE_PATH_NODE Vendor;
+ EFI_DEVICE_PATH_PROTOCOL EndDevicePath;
} EMU_THUNK_DEVICE_PATH;
-
-
-typedef struct _EMU_THUNK_PROTOCOL EMU_THUNK_PROTOCOL;
-
-
+typedef struct _EMU_THUNK_PROTOCOL EMU_THUNK_PROTOCOL;
typedef
UINTN
-(EFIAPI *EMU_WRITE_STD_ERROR) (
+(EFIAPI *EMU_WRITE_STD_ERROR)(
IN UINT8 *Buffer,
IN UINTN NumberOfBytes
);
typedef
EFI_STATUS
-(EFIAPI *EMU_CONFIG_STD_IN) (
+(EFIAPI *EMU_CONFIG_STD_IN)(
VOID
);
typedef
UINTN
-(EFIAPI *EMU_WRITE_STD_OUT) (
+(EFIAPI *EMU_WRITE_STD_OUT)(
IN UINT8 *Buffer,
IN UINTN NumberOfBytes
);
typedef
UINTN
-(EFIAPI *EMU_READ_STD_IN) (
+(EFIAPI *EMU_READ_STD_IN)(
OUT UINT8 *Buffer,
IN UINTN NumberOfBytes
);
typedef
BOOLEAN
-(EFIAPI *EMU_POLL_STD_IN) (
+(EFIAPI *EMU_POLL_STD_IN)(
VOID
);
-
typedef
VOID *
-(EFIAPI *EMU_OS_MALLOC) (
+(EFIAPI *EMU_OS_MALLOC)(
IN UINTN Size
);
typedef
VOID *
-(EFIAPI *EMU_OS_VMALLOC) (
+(EFIAPI *EMU_OS_VMALLOC)(
IN UINTN Size
);
typedef
BOOLEAN
-(EFIAPI *EMU_OS_FREE) (
+(EFIAPI *EMU_OS_FREE)(
IN VOID *Ptr
);
-
typedef
EFI_STATUS
-(EFIAPI *EMU_PE_COFF_GET_ENTRY_POINT) (
+(EFIAPI *EMU_PE_COFF_GET_ENTRY_POINT)(
IN VOID *Pe32Data,
IN OUT VOID **EntryPoint
);
typedef
VOID
-(EFIAPI *EMU_PE_COFF_RELOCATE_EXTRA_ACTION) (
+(EFIAPI *EMU_PE_COFF_RELOCATE_EXTRA_ACTION)(
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
);
typedef
VOID
-(EFIAPI *EMU_PE_COFF_UNLOAD_EXTRA_ACTION) (
+(EFIAPI *EMU_PE_COFF_UNLOAD_EXTRA_ACTION)(
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
);
typedef
VOID
-(EFIAPI *EMU_ENABLE_INERRUPTS) (
+(EFIAPI *EMU_ENABLE_INERRUPTS)(
VOID
);
typedef
VOID
-(EFIAPI *EMU_DISABLE_INERRUPTS) (
+(EFIAPI *EMU_DISABLE_INERRUPTS)(
VOID
);
typedef
UINT64
-(EFIAPI *EMU_QUERY_PERFORMANCE_FREQENCY) (
+(EFIAPI *EMU_QUERY_PERFORMANCE_FREQENCY)(
VOID
);
typedef
UINT64
-(EFIAPI *EMU_QUERY_PERFORMANCE_COUNTER) (
+(EFIAPI *EMU_QUERY_PERFORMANCE_COUNTER)(
VOID
);
typedef
VOID
-(EFIAPI *EMU_SLEEP) (
+(EFIAPI *EMU_SLEEP)(
IN UINT64 Milliseconds
);
typedef
VOID
-(EFIAPI *EMU_CPU_SLEEP) (
+(EFIAPI *EMU_CPU_SLEEP)(
VOID
);
typedef
VOID
-(EFIAPI *EMU_EXIT) (
+(EFIAPI *EMU_EXIT)(
IN UINTN Status
);
typedef
VOID
-(EFIAPI *EMU_GET_TIME) (
+(EFIAPI *EMU_GET_TIME)(
OUT EFI_TIME *Time,
OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL
);
typedef
VOID
-(EFIAPI *EMU_SET_TIME) (
+(EFIAPI *EMU_SET_TIME)(
IN EFI_TIME *Time
);
-
typedef
VOID
-(EFIAPI EMU_SET_TIMER_CALLBACK) (
+(EFIAPI EMU_SET_TIMER_CALLBACK)(
IN UINT64 DeltaMs
);
typedef
VOID
-(EFIAPI *EMU_SET_TIMER) (
+(EFIAPI *EMU_SET_TIMER)(
IN UINT64 PeriodMs,
IN EMU_SET_TIMER_CALLBACK CallBack
);
-
-
/**
Enumerates the current set of protocol instances that abstract OS services from EFI.
@@ -203,56 +193,54 @@ VOID
**/
typedef
EFI_STATUS
-(EFIAPI *EMU_GET_NEXT_PROTOCOL) (
+(EFIAPI *EMU_GET_NEXT_PROTOCOL)(
IN BOOLEAN EmuBusDriver,
OUT EMU_IO_THUNK_PROTOCOL **Instance OPTIONAL
);
-
struct _EMU_THUNK_PROTOCOL {
// Used for early debug printing
- EMU_WRITE_STD_ERROR WriteStdErr;
- EMU_CONFIG_STD_IN ConfigStdIn;
- EMU_WRITE_STD_OUT WriteStdOut;
- EMU_READ_STD_IN ReadStdIn;
- EMU_POLL_STD_IN PollStdIn;
+ EMU_WRITE_STD_ERROR WriteStdErr;
+ EMU_CONFIG_STD_IN ConfigStdIn;
+ EMU_WRITE_STD_OUT WriteStdOut;
+ EMU_READ_STD_IN ReadStdIn;
+ EMU_POLL_STD_IN PollStdIn;
//
// Map OS malloc/free so we can use OS based guard malloc
//
- EMU_OS_MALLOC Malloc;
- EMU_OS_VMALLOC Valloc;
- EMU_OS_FREE Free;
-
+ EMU_OS_MALLOC Malloc;
+ EMU_OS_VMALLOC Valloc;
+ EMU_OS_FREE Free;
///
/// PE/COFF loader hooks to get symbols loaded
///
- EMU_PE_COFF_GET_ENTRY_POINT PeCoffGetEntryPoint;
- EMU_PE_COFF_RELOCATE_EXTRA_ACTION PeCoffRelocateImageExtraAction;
- EMU_PE_COFF_UNLOAD_EXTRA_ACTION PeCoffUnloadImageExtraAction;
+ EMU_PE_COFF_GET_ENTRY_POINT PeCoffGetEntryPoint;
+ EMU_PE_COFF_RELOCATE_EXTRA_ACTION PeCoffRelocateImageExtraAction;
+ EMU_PE_COFF_UNLOAD_EXTRA_ACTION PeCoffUnloadImageExtraAction;
///
/// DXE Architecture Protocol Services
///
- EMU_ENABLE_INERRUPTS EnableInterrupt;
- EMU_DISABLE_INERRUPTS DisableInterrupt;
- EMU_QUERY_PERFORMANCE_FREQENCY QueryPerformanceFrequency;
- EMU_QUERY_PERFORMANCE_COUNTER QueryPerformanceCounter;
-
- EMU_SLEEP Sleep;
- EMU_CPU_SLEEP CpuSleep;
- EMU_EXIT Exit;
- EMU_GET_TIME GetTime;
- EMU_SET_TIME SetTime;
- EMU_SET_TIMER SetTimer;
+ EMU_ENABLE_INERRUPTS EnableInterrupt;
+ EMU_DISABLE_INERRUPTS DisableInterrupt;
+ EMU_QUERY_PERFORMANCE_FREQENCY QueryPerformanceFrequency;
+ EMU_QUERY_PERFORMANCE_COUNTER QueryPerformanceCounter;
+
+ EMU_SLEEP Sleep;
+ EMU_CPU_SLEEP CpuSleep;
+ EMU_EXIT Exit;
+ EMU_GET_TIME GetTime;
+ EMU_SET_TIME SetTime;
+ EMU_SET_TIMER SetTimer;
///
/// Generic System Services
///
- EMU_GET_NEXT_PROTOCOL GetNextProtocol;
+ EMU_GET_NEXT_PROTOCOL GetNextProtocol;
};
-extern EFI_GUID gEmuThunkProtocolGuid;
+extern EFI_GUID gEmuThunkProtocolGuid;
#endif
diff --git a/EmulatorPkg/Library/DevicePathTextLib/DevicePathTextLib.c b/EmulatorPkg/Library/DevicePathTextLib/DevicePathTextLib.c
index e636207a0c..01cc961299 100644
--- a/EmulatorPkg/Library/DevicePathTextLib/DevicePathTextLib.c
+++ b/EmulatorPkg/Library/DevicePathTextLib/DevicePathTextLib.c
@@ -19,7 +19,6 @@
#include <Library/BaseMemoryLib.h>
#include <Library/DevicePathLib.h>
-
/**
Converts a Vendor device path structure to its string representative.
@@ -52,18 +51,22 @@ DevPathToTextVendorLib (
CatPrint (Str, L"EmuThunk()");
return EFI_SUCCESS;
}
+
if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuGraphicsWindowProtocolGuid)) {
CatPrint (Str, L"EmuGraphics(%d)", Vendor->Instance);
return EFI_SUCCESS;
}
+
if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEfiSimpleFileSystemProtocolGuid)) {
CatPrint (Str, L"EmuFs(%d)", Vendor->Instance);
return EFI_SUCCESS;
}
+
if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuBlockIoProtocolGuid)) {
CatPrint (Str, L"EmuBlk(%d)", Vendor->Instance);
return EFI_SUCCESS;
}
+
if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuThreadThunkProtocolGuid)) {
CatPrint (Str, L"EmuThread()");
return EFI_SUCCESS;
@@ -82,20 +85,20 @@ DevPathToTextVendorLib (
**/
EFI_DEVICE_PATH_PROTOCOL *
DevPathFromTextEmuThunk (
- IN CHAR16 *TextDeviceNode
+ IN CHAR16 *TextDeviceNode
)
{
CHAR16 *Str;
VENDOR_DEVICE_PATH *Vendor;
Str = GetNextParamStr (&TextDeviceNode);
- Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (
- HARDWARE_DEVICE_PATH,
- HW_VENDOR_DP,
- (UINT16) sizeof (VENDOR_DEVICE_PATH)
- );
+ Vendor = (VENDOR_DEVICE_PATH *)CreateDeviceNode (
+ HARDWARE_DEVICE_PATH,
+ HW_VENDOR_DP,
+ (UINT16)sizeof (VENDOR_DEVICE_PATH)
+ );
CopyGuid (&Vendor->Guid, &gEmuThunkProtocolGuid);
- return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;
+ return (EFI_DEVICE_PATH_PROTOCOL *)Vendor;
}
/**
@@ -108,20 +111,20 @@ DevPathFromTextEmuThunk (
**/
EFI_DEVICE_PATH_PROTOCOL *
DevPathFromTextEmuThread (
- IN CHAR16 *TextDeviceNode
+ IN CHAR16 *TextDeviceNode
)
{
CHAR16 *Str;
VENDOR_DEVICE_PATH *Vendor;
Str = GetNextParamStr (&TextDeviceNode);
- Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (
- HARDWARE_DEVICE_PATH,
- HW_VENDOR_DP,
- (UINT16) sizeof (VENDOR_DEVICE_PATH)
- );
+ Vendor = (VENDOR_DEVICE_PATH *)CreateDeviceNode (
+ HARDWARE_DEVICE_PATH,
+ HW_VENDOR_DP,
+ (UINT16)sizeof (VENDOR_DEVICE_PATH)
+ );
CopyGuid (&Vendor->Guid, &gEmuThreadThunkProtocolGuid);
- return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;
+ return (EFI_DEVICE_PATH_PROTOCOL *)Vendor;
}
/**
@@ -134,22 +137,22 @@ DevPathFromTextEmuThread (
**/
EFI_DEVICE_PATH_PROTOCOL *
DevPathFromTextEmuFs (
- IN CHAR16 *TextDeviceNode
+ IN CHAR16 *TextDeviceNode
)
{
CHAR16 *Str;
EMU_VENDOR_DEVICE_PATH_NODE *Vendor;
- Str = GetNextParamStr (&TextDeviceNode);
- Vendor = (EMU_VENDOR_DEVICE_PATH_NODE *) CreateDeviceNode (
- HARDWARE_DEVICE_PATH,
- HW_VENDOR_DP,
- (UINT16) sizeof (EMU_VENDOR_DEVICE_PATH_NODE)
- );
+ Str = GetNextParamStr (&TextDeviceNode);
+ Vendor = (EMU_VENDOR_DEVICE_PATH_NODE *)CreateDeviceNode (
+ HARDWARE_DEVICE_PATH,
+ HW_VENDOR_DP,
+ (UINT16)sizeof (EMU_VENDOR_DEVICE_PATH_NODE)
+ );
CopyGuid (&Vendor->VendorDevicePath.Guid, &gEfiSimpleFileSystemProtocolGuid);
- Vendor->Instance = (UINT32) StrDecimalToUintn (Str);
+ Vendor->Instance = (UINT32)StrDecimalToUintn (Str);
- return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;
+ return (EFI_DEVICE_PATH_PROTOCOL *)Vendor;
}
/**
diff --git a/EmulatorPkg/Library/DxeCoreTimerLib/DxeCoreTimerLib.c b/EmulatorPkg/Library/DxeCoreTimerLib/DxeCoreTimerLib.c
index 513a5aaa7c..d14a2011b0 100644
--- a/EmulatorPkg/Library/DxeCoreTimerLib/DxeCoreTimerLib.c
+++ b/EmulatorPkg/Library/DxeCoreTimerLib/DxeCoreTimerLib.c
@@ -16,8 +16,6 @@
#include <Protocol/Timer.h>
-
-
/**
Stalls the CPU for at least the given number of microseconds.
@@ -31,13 +29,12 @@
UINTN
EFIAPI
MicroSecondDelay (
- IN UINTN MicroSeconds
+ IN UINTN MicroSeconds
)
{
return NanoSecondDelay (MicroSeconds * 1000);
}
-
/**
Stalls the CPU for at least the given number of nanoseconds.
@@ -51,14 +48,13 @@ MicroSecondDelay (
UINTN
EFIAPI
NanoSecondDelay (
- IN UINTN NanoSeconds
+ IN UINTN NanoSeconds
)
{
gEmuThunk->Sleep (NanoSeconds);
return NanoSeconds;
}
-
/**
Retrieves the current value of a 64-bit free running performance counter.
@@ -105,14 +101,14 @@ GetPerformanceCounter (
UINT64
EFIAPI
GetPerformanceCounterProperties (
- OUT UINT64 *StartValue OPTIONAL,
- OUT UINT64 *EndValue OPTIONAL
+ OUT UINT64 *StartValue OPTIONAL,
+ OUT UINT64 *EndValue OPTIONAL
)
{
-
if (StartValue != NULL) {
*StartValue = 0ULL;
}
+
if (EndValue != NULL) {
*EndValue = (UINT64)-1LL;
}
@@ -156,9 +152,9 @@ GetTimeInNanoSecond (
// Since 2^29 < 1,000,000,000 = 0x3B9ACA00 < 2^30, Remainder should < 2^(64-30) = 2^34,
// i.e. highest bit set in Remainder should <= 33.
//
- Shift = MAX (0, HighBitSet64 (Remainder) - 33);
- Remainder = RShiftU64 (Remainder, (UINTN) Shift);
- Frequency = RShiftU64 (Frequency, (UINTN) Shift);
+ Shift = MAX (0, HighBitSet64 (Remainder) - 33);
+ Remainder = RShiftU64 (Remainder, (UINTN)Shift);
+ Frequency = RShiftU64 (Frequency, (UINTN)Shift);
NanoSeconds += DivU64x64Remainder (MultU64x32 (Remainder, 1000000000u), Frequency, NULL);
return NanoSeconds;
diff --git a/EmulatorPkg/Library/DxeEmuLib/DxeEmuLib.c b/EmulatorPkg/Library/DxeEmuLib/DxeEmuLib.c
index 3247114d09..291897eff2 100644
--- a/EmulatorPkg/Library/DxeEmuLib/DxeEmuLib.c
+++ b/EmulatorPkg/Library/DxeEmuLib/DxeEmuLib.c
@@ -13,8 +13,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/EmuThunkLib.h>
#include <Library/BaseMemoryLib.h>
-EMU_THUNK_PROTOCOL *gEmuThunk = NULL;
-
+EMU_THUNK_PROTOCOL *gEmuThunk = NULL;
/**
The constructor function caches the pointer of EMU Thunk protocol.
@@ -32,7 +31,7 @@ DxeEmuLibConstructor (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_HOB_GUID_TYPE *GuidHob;
+ EFI_HOB_GUID_TYPE *GuidHob;
GuidHob = GetFirstGuidHob (&gEmuThunkProtocolGuid);
ASSERT (GuidHob != NULL);
@@ -43,7 +42,6 @@ DxeEmuLibConstructor (
return EFI_SUCCESS;
}
-
/**
Serach the EMU IO Thunk database for a matching EMU IO Thunk
Protocol instance.
@@ -62,8 +60,8 @@ GetIoThunkInstance (
IN UINTN Instance
)
{
- EFI_STATUS Status;
- EMU_IO_THUNK_PROTOCOL *EmuIoThunk;
+ EFI_STATUS Status;
+ EMU_IO_THUNK_PROTOCOL *EmuIoThunk;
for (Status = EFI_SUCCESS, EmuIoThunk = NULL; !EFI_ERROR (Status); ) {
Status = gEmuThunk->GetNextProtocol (FALSE, &EmuIoThunk);
diff --git a/EmulatorPkg/Library/DxeEmuPeCoffExtraActionLib/DxeEmuPeCoffExtraActionLib.c b/EmulatorPkg/Library/DxeEmuPeCoffExtraActionLib/DxeEmuPeCoffExtraActionLib.c
index 44a42a3784..c3c5ae4246 100644
--- a/EmulatorPkg/Library/DxeEmuPeCoffExtraActionLib/DxeEmuPeCoffExtraActionLib.c
+++ b/EmulatorPkg/Library/DxeEmuPeCoffExtraActionLib/DxeEmuPeCoffExtraActionLib.c
@@ -23,8 +23,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//
// Cache of UnixThunk protocol
//
-EMU_THUNK_PROTOCOL *mThunk = NULL;
-
+EMU_THUNK_PROTOCOL *mThunk = NULL;
/**
The constructor function gets the pointer of the WinNT thunk functions
@@ -40,7 +39,7 @@ DxeEmuPeCoffLibExtraActionConstructor (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_HOB_GUID_TYPE *GuidHob;
+ EFI_HOB_GUID_TYPE *GuidHob;
//
// Retrieve EmuThunkProtocol from GUID'ed HOB
@@ -73,8 +72,6 @@ PeCoffLoaderRelocateImageExtraAction (
}
}
-
-
/**
Performs additional actions just before a PE/COFF image is unloaded. Any resources
that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.
diff --git a/EmulatorPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.c b/EmulatorPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.c
index 1f9ab86377..158ef69800 100644
--- a/EmulatorPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.c
+++ b/EmulatorPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.c
@@ -8,14 +8,10 @@
**/
-
#include <PiDxe.h>
#include <Library/SerialPortLib.h>
#include <Library/EmuThunkLib.h>
-
-
-
/**
Initialize the serial device hardware.
@@ -56,14 +52,13 @@ SerialPortInitialize (
UINTN
EFIAPI
SerialPortWrite (
- IN UINT8 *Buffer,
- IN UINTN NumberOfBytes
+ IN UINT8 *Buffer,
+ IN UINTN NumberOfBytes
)
{
return gEmuThunk->WriteStdOut (Buffer, NumberOfBytes);
}
-
/**
Read data from serial device and save the datas in buffer.
@@ -83,8 +78,8 @@ SerialPortWrite (
UINTN
EFIAPI
SerialPortRead (
- OUT UINT8 *Buffer,
- IN UINTN NumberOfBytes
+ OUT UINT8 *Buffer,
+ IN UINTN NumberOfBytes
)
{
return gEmuThunk->ReadStdIn (Buffer, NumberOfBytes);
@@ -123,7 +118,7 @@ SerialPortPoll (
RETURN_STATUS
EFIAPI
SerialPortSetControl (
- IN UINT32 Control
+ IN UINT32 Control
)
{
return RETURN_UNSUPPORTED;
@@ -142,13 +137,14 @@ SerialPortSetControl (
RETURN_STATUS
EFIAPI
SerialPortGetControl (
- OUT UINT32 *Control
+ OUT UINT32 *Control
)
{
*Control = 0;
if (!SerialPortPoll ()) {
*Control = EFI_SERIAL_INPUT_BUFFER_EMPTY;
}
+
return RETURN_SUCCESS;
}
@@ -188,14 +184,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/EmulatorPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.c b/EmulatorPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.c
index 0eefec0404..70e7140464 100644
--- a/EmulatorPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.c
+++ b/EmulatorPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.c
@@ -8,14 +8,10 @@
**/
-
#include <PiDxe.h>
#include <Library/SerialPortLib.h>
#include <Library/EmuThunkLib.h>
-
-
-
/**
Initialize the serial device hardware.
@@ -56,8 +52,8 @@ SerialPortInitialize (
UINTN
EFIAPI
SerialPortWrite (
- IN UINT8 *Buffer,
- IN UINTN NumberOfBytes
+ IN UINT8 *Buffer,
+ IN UINTN NumberOfBytes
)
{
if (gEmuThunk == NULL) {
@@ -67,7 +63,6 @@ SerialPortWrite (
return gEmuThunk->WriteStdErr (Buffer, NumberOfBytes);
}
-
/**
Read data from serial device and save the datas in buffer.
@@ -87,8 +82,8 @@ SerialPortWrite (
UINTN
EFIAPI
SerialPortRead (
- OUT UINT8 *Buffer,
- IN UINTN NumberOfBytes
+ OUT UINT8 *Buffer,
+ IN UINTN NumberOfBytes
)
{
return 0;
@@ -113,5 +108,3 @@ SerialPortPoll (
{
return FALSE;
}
-
-
diff --git a/EmulatorPkg/Library/DxeTimerLib/DxeTimerLib.c b/EmulatorPkg/Library/DxeTimerLib/DxeTimerLib.c
index 4244a5d65c..9113efc3a0 100644
--- a/EmulatorPkg/Library/DxeTimerLib/DxeTimerLib.c
+++ b/EmulatorPkg/Library/DxeTimerLib/DxeTimerLib.c
@@ -16,17 +16,16 @@
#include <Protocol/Timer.h>
-
-STATIC UINT64 gTimerPeriod = 0;
-STATIC EFI_TIMER_ARCH_PROTOCOL *gTimerAp = NULL;
-STATIC EFI_EVENT gTimerEvent = NULL;
-STATIC VOID *gRegistration = NULL;
+STATIC UINT64 gTimerPeriod = 0;
+STATIC EFI_TIMER_ARCH_PROTOCOL *gTimerAp = NULL;
+STATIC EFI_EVENT gTimerEvent = NULL;
+STATIC VOID *gRegistration = NULL;
VOID
EFIAPI
RegisterTimerArchProtocol (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
EFI_STATUS Status;
@@ -46,8 +45,6 @@ RegisterTimerArchProtocol (
}
}
-
-
/**
Stalls the CPU for at least the given number of microseconds.
@@ -61,13 +58,12 @@ RegisterTimerArchProtocol (
UINTN
EFIAPI
MicroSecondDelay (
- IN UINTN MicroSeconds
+ IN UINTN MicroSeconds
)
{
return NanoSecondDelay (MicroSeconds * 1000);
}
-
/**
Stalls the CPU for at least the given number of nanoseconds.
@@ -81,7 +77,7 @@ MicroSecondDelay (
UINTN
EFIAPI
NanoSecondDelay (
- IN UINTN NanoSeconds
+ IN UINTN NanoSeconds
)
{
EFI_STATUS Status;
@@ -90,25 +86,25 @@ NanoSecondDelay (
if ((gTimerPeriod != 0) &&
((UINT64)NanoSeconds > gTimerPeriod) &&
- (EfiGetCurrentTpl () == TPL_APPLICATION)) {
+ (EfiGetCurrentTpl () == TPL_APPLICATION))
+ {
//
// This stall is long, so use gBS->WaitForEvent () to yield CPU to DXE Core
//
HundredNanoseconds = DivU64x32 (NanoSeconds, 100);
- Status = gBS->SetTimer (gTimerEvent, TimerRelative, HundredNanoseconds);
+ Status = gBS->SetTimer (gTimerEvent, TimerRelative, HundredNanoseconds);
ASSERT_EFI_ERROR (Status);
Status = gBS->WaitForEvent (sizeof (gTimerEvent)/sizeof (EFI_EVENT), &gTimerEvent, &Index);
ASSERT_EFI_ERROR (Status);
-
} else {
gEmuThunk->Sleep (NanoSeconds);
}
+
return NanoSeconds;
}
-
/**
Retrieves the current value of a 64-bit free running performance counter.
@@ -155,14 +151,14 @@ GetPerformanceCounter (
UINT64
EFIAPI
GetPerformanceCounterProperties (
- OUT UINT64 *StartValue OPTIONAL,
- OUT UINT64 *EndValue OPTIONAL
+ OUT UINT64 *StartValue OPTIONAL,
+ OUT UINT64 *EndValue OPTIONAL
)
{
-
if (StartValue != NULL) {
*StartValue = 0ULL;
}
+
if (EndValue != NULL) {
*EndValue = (UINT64)-1LL;
}
@@ -170,7 +166,6 @@ GetPerformanceCounterProperties (
return gEmuThunk->QueryPerformanceFrequency ();
}
-
/**
Register for the Timer AP protocol.
@@ -234,9 +229,9 @@ GetTimeInNanoSecond (
// Since 2^29 < 1,000,000,000 = 0x3B9ACA00 < 2^30, Remainder should < 2^(64-30) = 2^34,
// i.e. highest bit set in Remainder should <= 33.
//
- Shift = MAX (0, HighBitSet64 (Remainder) - 33);
- Remainder = RShiftU64 (Remainder, (UINTN) Shift);
- Frequency = RShiftU64 (Frequency, (UINTN) Shift);
+ Shift = MAX (0, HighBitSet64 (Remainder) - 33);
+ Remainder = RShiftU64 (Remainder, (UINTN)Shift);
+ Frequency = RShiftU64 (Frequency, (UINTN)Shift);
NanoSeconds += DivU64x64Remainder (MultU64x32 (Remainder, 1000000000u), Frequency, NULL);
return NanoSeconds;
diff --git a/EmulatorPkg/Library/GuardUefiMemoryAllocationLib/MemoryAllocationLib.c b/EmulatorPkg/Library/GuardUefiMemoryAllocationLib/MemoryAllocationLib.c
index cd7336a017..515ef1a59b 100644
--- a/EmulatorPkg/Library/GuardUefiMemoryAllocationLib/MemoryAllocationLib.c
+++ b/EmulatorPkg/Library/GuardUefiMemoryAllocationLib/MemoryAllocationLib.c
@@ -15,10 +15,8 @@
**/
-
#include <Uefi.h>
-
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/BaseMemoryLib.h>
@@ -144,14 +142,14 @@ FreePages (
IN UINTN Pages
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
ASSERT (Pages != 0);
if (!gEmuThunk->Free (Buffer)) {
// The Free thunk will not free memory allocated in emulated EFI memory.
// The assmuption is this was allocated directly by EFI. We need this as some
// times protocols or EFI BootServices can return dynamically allocated buffers.
- Status = gBS->FreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);
+ Status = gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, Pages);
ASSERT_EFI_ERROR (Status);
}
}
@@ -180,12 +178,12 @@ InternalAllocateAlignedPages (
IN UINTN Alignment
)
{
- EFI_STATUS Status;
- VOID *Memory;
- UINTN AlignedMemory;
- UINTN AlignmentMask;
- UINTN UnalignedPages;
- UINTN RealPages;
+ EFI_STATUS Status;
+ VOID *Memory;
+ UINTN AlignedMemory;
+ UINTN AlignmentMask;
+ UINTN UnalignedPages;
+ UINTN RealPages;
//
// Alignment must be a power of two or zero.
@@ -195,12 +193,13 @@ InternalAllocateAlignedPages (
if (Pages == 0) {
return NULL;
}
+
if (Alignment > EFI_PAGE_SIZE) {
//
// Caculate the total number of pages since alignment is larger than page size.
//
- AlignmentMask = Alignment - 1;
- RealPages = Pages + EFI_SIZE_TO_PAGES (Alignment);
+ AlignmentMask = Alignment - 1;
+ RealPages = Pages + EFI_SIZE_TO_PAGES (Alignment);
//
// Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.
//
@@ -210,15 +209,17 @@ InternalAllocateAlignedPages (
if (Memory != NULL) {
return NULL;
}
- AlignedMemory = ((UINTN) Memory + AlignmentMask) & ~AlignmentMask;
- UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN) Memory);
+
+ AlignedMemory = ((UINTN)Memory + AlignmentMask) & ~AlignmentMask;
+ UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN)Memory);
if (UnalignedPages > 0) {
//
// Free first unaligned page(s).
//
FreePages (Memory, UnalignedPages);
}
- Memory = (VOID *) (AlignedMemory + EFI_PAGES_TO_SIZE (Pages));
+
+ Memory = (VOID *)(AlignedMemory + EFI_PAGES_TO_SIZE (Pages));
UnalignedPages = RealPages - Pages - UnalignedPages;
if (UnalignedPages > 0) {
//
@@ -234,9 +235,11 @@ InternalAllocateAlignedPages (
if (Memory != NULL) {
return NULL;
}
- AlignedMemory = (UINTN) Memory;
+
+ AlignedMemory = (UINTN)Memory;
}
- return (VOID *) AlignedMemory;
+
+ return (VOID *)AlignedMemory;
}
/**
@@ -458,6 +461,7 @@ InternalAllocateZeroPool (
if (Memory != NULL) {
Memory = ZeroMem (Memory, AllocationSize);
}
+
return Memory;
}
@@ -554,12 +558,13 @@ InternalAllocateCopyPool (
VOID *Memory;
ASSERT (Buffer != NULL);
- ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));
+ ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN)Buffer + 1));
Memory = InternalAllocatePool (PoolType, AllocationSize);
if (Memory != NULL) {
- Memory = CopyMem (Memory, Buffer, AllocationSize);
+ Memory = CopyMem (Memory, Buffer, AllocationSize);
}
+
return Memory;
}
@@ -677,10 +682,11 @@ InternalReallocatePool (
VOID *NewBuffer;
NewBuffer = InternalAllocateZeroPool (PoolType, NewSize);
- if (NewBuffer != NULL && OldBuffer != NULL) {
+ if ((NewBuffer != NULL) && (OldBuffer != NULL)) {
CopyMem (NewBuffer, OldBuffer, MIN (OldSize, NewSize));
FreePool (OldBuffer);
}
+
return NewBuffer;
}
@@ -797,10 +803,10 @@ ReallocateReservedPool (
VOID
EFIAPI
FreePool (
- IN VOID *Buffer
+ IN VOID *Buffer
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
if (!gEmuThunk->Free (Buffer)) {
// The Free thunk will not free memory allocated in emulated EFI memory.
@@ -810,4 +816,3 @@ FreePool (
ASSERT_EFI_ERROR (Status);
}
}
-
diff --git a/EmulatorPkg/Library/KeyMapLibNull/KeyMapLibNull.c b/EmulatorPkg/Library/KeyMapLibNull/KeyMapLibNull.c
index 2e25fa5ac3..9aa34f70bb 100644
--- a/EmulatorPkg/Library/KeyMapLibNull/KeyMapLibNull.c
+++ b/EmulatorPkg/Library/KeyMapLibNull/KeyMapLibNull.c
@@ -8,7 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Uefi.h>
#include <Protocol/SimpleTextInEx.h>
-
/**
KeyMapMake gets called on key presses.
@@ -20,7 +19,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
EFI_STATUS
EFIAPI
KeyMapMake (
- IN EFI_KEY_DATA *KeyData
+ IN EFI_KEY_DATA *KeyData
)
{
return EFI_SUCCESS;
@@ -37,7 +36,7 @@ KeyMapMake (
EFI_STATUS
EFIAPI
KeyMapBreak (
- IN EFI_KEY_DATA *KeyData
+ IN EFI_KEY_DATA *KeyData
)
{
return EFI_SUCCESS;
diff --git a/EmulatorPkg/Library/PeiCoreServicesTablePointerLib/PeiServicesTablePointer.c b/EmulatorPkg/Library/PeiCoreServicesTablePointerLib/PeiServicesTablePointer.c
index 2d3a78269c..4a6111d2a2 100644
--- a/EmulatorPkg/Library/PeiCoreServicesTablePointerLib/PeiServicesTablePointer.c
+++ b/EmulatorPkg/Library/PeiCoreServicesTablePointerLib/PeiServicesTablePointer.c
@@ -29,7 +29,7 @@ CONST EFI_PEI_SERVICES **gPeiServices;
VOID
EFIAPI
SetPeiServicesTablePointer (
- IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer
+ IN CONST EFI_PEI_SERVICES **PeiServicesTablePointer
)
{
ASSERT (PeiServicesTablePointer != NULL);
@@ -58,7 +58,6 @@ GetPeiServicesTablePointer (
return gPeiServices;
}
-
/**
The constructor function caches the pointer to PEI services.
@@ -74,8 +73,8 @@ GetPeiServicesTablePointer (
EFI_STATUS
EFIAPI
PeiServicesTablePointerLibConstructor (
- IN EFI_PEI_FILE_HANDLE FileHandle,
- IN CONST EFI_PEI_SERVICES **PeiServices
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ IN CONST EFI_PEI_SERVICES **PeiServices
)
{
gPeiServices = PeiServices;
@@ -108,4 +107,3 @@ MigratePeiServicesTablePointer (
//
return;
}
-
diff --git a/EmulatorPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.c b/EmulatorPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.c
index 55be3efbdb..9e1a8be607 100644
--- a/EmulatorPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.c
+++ b/EmulatorPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.c
@@ -22,7 +22,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//
// Cache of UnixThunk protocol
//
-EMU_THUNK_PROTOCOL *mThunk = NULL;
+EMU_THUNK_PROTOCOL *mThunk = NULL;
/**
The function caches the pointer of the Unix thunk functions
@@ -36,22 +36,21 @@ EFIAPI
EmuPeCoffGetThunkStucture (
)
{
- EMU_THUNK_PPI *ThunkPpi;
- EFI_STATUS Status;
-
+ EMU_THUNK_PPI *ThunkPpi;
+ EFI_STATUS Status;
//
// Locate Unix ThunkPpi for retrieving standard output handle
//
Status = PeiServicesLocatePpi (
- &gEmuThunkPpiGuid,
- 0,
- NULL,
- (VOID **) &ThunkPpi
- );
+ &gEmuThunkPpiGuid,
+ 0,
+ NULL,
+ (VOID **)&ThunkPpi
+ );
ASSERT_EFI_ERROR (Status);
- EMU_MAGIC_PAGE()->Thunk = (EMU_THUNK_PROTOCOL *) ThunkPpi->Thunk ();
+ EMU_MAGIC_PAGE ()->Thunk = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();
return EFI_SUCCESS;
}
@@ -71,12 +70,12 @@ PeCoffLoaderRelocateImageExtraAction (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
{
- if (EMU_MAGIC_PAGE()->Thunk == NULL) {
+ if (EMU_MAGIC_PAGE ()->Thunk == NULL) {
EmuPeCoffGetThunkStucture ();
}
- EMU_MAGIC_PAGE()->Thunk->PeCoffRelocateImageExtraAction (ImageContext);
- }
+ EMU_MAGIC_PAGE ()->Thunk->PeCoffRelocateImageExtraAction (ImageContext);
+}
/**
Performs additional actions just before a PE/COFF image is unloaded. Any resources
@@ -94,8 +93,9 @@ PeCoffLoaderUnloadImageExtraAction (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
{
- if (EMU_MAGIC_PAGE()->Thunk == NULL) {
+ if (EMU_MAGIC_PAGE ()->Thunk == NULL) {
EmuPeCoffGetThunkStucture ();
}
- EMU_MAGIC_PAGE()->Thunk->PeCoffUnloadImageExtraAction (ImageContext);
+
+ EMU_MAGIC_PAGE ()->Thunk->PeCoffUnloadImageExtraAction (ImageContext);
}
diff --git a/EmulatorPkg/Library/PeiEmuPeCoffGetEntryPointLib/PeiEmuPeCoffGetEntryPointLib.c b/EmulatorPkg/Library/PeiEmuPeCoffGetEntryPointLib/PeiEmuPeCoffGetEntryPointLib.c
index fd756b5594..a9d28f48cf 100644
--- a/EmulatorPkg/Library/PeiEmuPeCoffGetEntryPointLib/PeiEmuPeCoffGetEntryPointLib.c
+++ b/EmulatorPkg/Library/PeiEmuPeCoffGetEntryPointLib/PeiEmuPeCoffGetEntryPointLib.c
@@ -15,8 +15,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Ppi/EmuThunk.h>
#include <Protocol/EmuThunk.h>
-
-
/**
Retrieves and returns a pointer to the entry point to a PE/COFF image that has been loaded
into system memory with the PE/COFF Loader Library functions.
@@ -41,22 +39,22 @@ PeCoffLoaderGetEntryPoint (
IN OUT VOID **EntryPoint
)
{
- EMU_THUNK_PPI *ThunkPpi;
- EFI_STATUS Status;
- EMU_THUNK_PROTOCOL *Thunk;
+ EMU_THUNK_PPI *ThunkPpi;
+ EFI_STATUS Status;
+ EMU_THUNK_PROTOCOL *Thunk;
//
// Locate EmuThunkPpi for retrieving standard output handle
//
Status = PeiServicesLocatePpi (
- &gEmuThunkPpiGuid,
- 0,
- NULL,
- (VOID **) &ThunkPpi
+ &gEmuThunkPpiGuid,
+ 0,
+ NULL,
+ (VOID **)&ThunkPpi
);
ASSERT_EFI_ERROR (Status);
- Thunk = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();
+ Thunk = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();
return Thunk->PeCoffGetEntryPoint (Pe32Data, EntryPoint);
}
@@ -86,15 +84,14 @@ PeCoffLoaderGetMachineType (
DosHdr = (EFI_IMAGE_DOS_HEADER *)Pe32Data;
if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
- Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHdr->e_lfanew) & 0x0ffff));
-
+ Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN)Pe32Data + (UINTN)((DosHdr->e_lfanew) & 0x0ffff));
} else {
Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)(Pe32Data);
}
if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {
return Hdr.Te->Machine;
- } else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {
+ } else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {
return Hdr.Pe32->FileHeader.Machine;
}
@@ -126,15 +123,15 @@ PeCoffLoaderGetPdbPointer (
IN VOID *Pe32Data
)
{
- EFI_IMAGE_DOS_HEADER *DosHdr;
- EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;
- EFI_IMAGE_DATA_DIRECTORY *DirectoryEntry;
- EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *DebugEntry;
- UINTN DirCount;
- VOID *CodeViewEntryPointer;
- INTN TEImageAdjust;
- UINT32 NumberOfRvaAndSizes;
- UINT16 Magic;
+ EFI_IMAGE_DOS_HEADER *DosHdr;
+ EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;
+ EFI_IMAGE_DATA_DIRECTORY *DirectoryEntry;
+ EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *DebugEntry;
+ UINTN DirCount;
+ VOID *CodeViewEntryPointer;
+ INTN TEImageAdjust;
+ UINT32 NumberOfRvaAndSizes;
+ UINT16 Magic;
ASSERT (Pe32Data != NULL);
@@ -148,7 +145,7 @@ PeCoffLoaderGetPdbPointer (
//
// DOS image header is present, so read the PE header after the DOS image header.
//
- Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHdr->e_lfanew) & 0x0ffff));
+ Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN)Pe32Data + (UINTN)((DosHdr->e_lfanew) & 0x0ffff));
} else {
//
// DOS image header is not present, so PE header is at the image base.
@@ -158,11 +155,11 @@ PeCoffLoaderGetPdbPointer (
if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {
if (Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress != 0) {
- DirectoryEntry = &Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG];
- TEImageAdjust = sizeof (EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize;
- DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)((UINTN) Hdr.Te +
- Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress +
- TEImageAdjust);
+ DirectoryEntry = &Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG];
+ TEImageAdjust = sizeof (EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize;
+ DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)((UINTN)Hdr.Te +
+ Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress +
+ TEImageAdjust);
}
} else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {
//
@@ -171,24 +168,24 @@ PeCoffLoaderGetPdbPointer (
// generate PE32+ image with PE32 Magic.
//
switch (Hdr.Pe32->FileHeader.Machine) {
- case EFI_IMAGE_MACHINE_IA32:
- //
- // Assume PE32 image with IA32 Machine field.
- //
- Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;
- break;
- case EFI_IMAGE_MACHINE_X64:
- case EFI_IMAGE_MACHINE_IA64:
- //
- // Assume PE32+ image with X64 or IA64 Machine field
- //
- Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
- break;
- default:
- //
- // For unknow Machine field, use Magic in optional Header
- //
- Magic = Hdr.Pe32->OptionalHeader.Magic;
+ case EFI_IMAGE_MACHINE_IA32:
+ //
+ // Assume PE32 image with IA32 Machine field.
+ //
+ Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;
+ break;
+ case EFI_IMAGE_MACHINE_X64:
+ case EFI_IMAGE_MACHINE_IA64:
+ //
+ // Assume PE32+ image with X64 or IA64 Machine field
+ //
+ Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
+ break;
+ default:
+ //
+ // For unknow Machine field, use Magic in optional Header
+ //
+ Magic = Hdr.Pe32->OptionalHeader.Magic;
}
if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
@@ -196,42 +193,42 @@ PeCoffLoaderGetPdbPointer (
// Use PE32 offset get Debug Directory Entry
//
NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;
- DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
- DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) Pe32Data + DirectoryEntry->VirtualAddress);
+ DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
+ DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)((UINTN)Pe32Data + DirectoryEntry->VirtualAddress);
} else if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {
//
// Use PE32+ offset get Debug Directory Entry
//
NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;
- DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
- DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) Pe32Data + DirectoryEntry->VirtualAddress);
+ DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
+ DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)((UINTN)Pe32Data + DirectoryEntry->VirtualAddress);
}
if (NumberOfRvaAndSizes <= EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) {
DirectoryEntry = NULL;
- DebugEntry = NULL;
+ DebugEntry = NULL;
}
} else {
return NULL;
}
- if (DebugEntry == NULL || DirectoryEntry == NULL) {
+ if ((DebugEntry == NULL) || (DirectoryEntry == NULL)) {
return NULL;
}
for (DirCount = 0; DirCount < DirectoryEntry->Size; DirCount += sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY), DebugEntry++) {
if (DebugEntry->Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {
if (DebugEntry->SizeOfData > 0) {
- CodeViewEntryPointer = (VOID *) ((UINTN) DebugEntry->RVA + ((UINTN)Pe32Data) + (UINTN)TEImageAdjust);
- switch (* (UINT32 *) CodeViewEntryPointer) {
- case CODEVIEW_SIGNATURE_NB10:
- return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY));
- case CODEVIEW_SIGNATURE_RSDS:
- return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY));
- case CODEVIEW_SIGNATURE_MTOC:
- return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY));
- default:
- break;
+ CodeViewEntryPointer = (VOID *)((UINTN)DebugEntry->RVA + ((UINTN)Pe32Data) + (UINTN)TEImageAdjust);
+ switch (*(UINT32 *)CodeViewEntryPointer) {
+ case CODEVIEW_SIGNATURE_NB10:
+ return (VOID *)((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY));
+ case CODEVIEW_SIGNATURE_RSDS:
+ return (VOID *)((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY));
+ case CODEVIEW_SIGNATURE_MTOC:
+ return (VOID *)((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY));
+ default:
+ break;
}
}
}
@@ -240,7 +237,6 @@ PeCoffLoaderGetPdbPointer (
return NULL;
}
-
/**
Returns the size of the PE/COFF headers
@@ -256,12 +252,12 @@ PeCoffLoaderGetPdbPointer (
UINT32
EFIAPI
PeCoffGetSizeOfHeaders (
- IN VOID *Pe32Data
+ IN VOID *Pe32Data
)
{
- EFI_IMAGE_DOS_HEADER *DosHdr;
- EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;
- UINTN SizeOfHeaders;
+ EFI_IMAGE_DOS_HEADER *DosHdr;
+ EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;
+ UINTN SizeOfHeaders;
ASSERT (Pe32Data != NULL);
@@ -270,7 +266,7 @@ PeCoffGetSizeOfHeaders (
//
// DOS image header is present, so read the PE header after the DOS image header.
//
- Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHdr->e_lfanew) & 0x0ffff));
+ Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN)Pe32Data + (UINTN)((DosHdr->e_lfanew) & 0x0ffff));
} else {
//
// DOS image header is not present, so PE header is at the image base.
@@ -286,6 +282,5 @@ PeCoffGetSizeOfHeaders (
SizeOfHeaders = 0;
}
- return (UINT32) SizeOfHeaders;
+ return (UINT32)SizeOfHeaders;
}
-
diff --git a/EmulatorPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.c b/EmulatorPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.c
index cf727a638c..e037d82f1e 100644
--- a/EmulatorPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.c
+++ b/EmulatorPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.c
@@ -9,7 +9,6 @@
**/
-
#include <PiPei.h>
#include <Library/SerialPortLib.h>
#include <Library/PeiServicesLib.h>
@@ -17,8 +16,6 @@
#include <Ppi/EmuThunk.h>
#include <Protocol/EmuThunk.h>
-
-
/**
Initialize the serial device hardware.
@@ -59,32 +56,31 @@ SerialPortInitialize (
UINTN
EFIAPI
SerialPortWrite (
- IN UINT8 *Buffer,
- IN UINTN NumberOfBytes
+ IN UINT8 *Buffer,
+ IN UINTN NumberOfBytes
)
{
- EMU_THUNK_PPI *ThunkPpi;
- EFI_STATUS Status;
- EMU_THUNK_PROTOCOL *Thunk;
+ EMU_THUNK_PPI *ThunkPpi;
+ EFI_STATUS Status;
+ EMU_THUNK_PROTOCOL *Thunk;
//
// Locate EmuThunkPpi for retrieving standard output handle
//
Status = PeiServicesLocatePpi (
- &gEmuThunkPpiGuid,
- 0,
- NULL,
- (VOID **) &ThunkPpi
+ &gEmuThunkPpiGuid,
+ 0,
+ NULL,
+ (VOID **)&ThunkPpi
);
if (!EFI_ERROR (Status)) {
- Thunk = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();
+ Thunk = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();
return Thunk->WriteStdErr (Buffer, NumberOfBytes);
}
return 0;
}
-
/**
Read data from serial device and save the datas in buffer.
@@ -104,8 +100,8 @@ SerialPortWrite (
UINTN
EFIAPI
SerialPortRead (
- OUT UINT8 *Buffer,
- IN UINTN NumberOfBytes
+ OUT UINT8 *Buffer,
+ IN UINTN NumberOfBytes
)
{
return 0;
@@ -130,4 +126,3 @@ SerialPortPoll (
{
return FALSE;
}
-
diff --git a/EmulatorPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c b/EmulatorPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c
index d9d37bf8af..37f5a106f0 100644
--- a/EmulatorPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c
+++ b/EmulatorPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c
@@ -16,7 +16,6 @@
#include <Ppi/MemoryDiscovered.h>
-
CONST EFI_PEI_SERVICES **gPeiServices = NULL;
/**
@@ -33,7 +32,7 @@ CONST EFI_PEI_SERVICES **gPeiServices = NULL;
VOID
EFIAPI
SetPeiServicesTablePointer (
- IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer
+ IN CONST EFI_PEI_SERVICES **PeiServicesTablePointer
)
{
ASSERT (PeiServicesTablePointer != NULL);
@@ -64,8 +63,6 @@ GetPeiServicesTablePointer (
return gPeiServices;
}
-
-
/**
Notification service to be called when gEmuThunkPpiGuid is installed.
@@ -81,9 +78,9 @@ GetPeiServicesTablePointer (
EFI_STATUS
EFIAPI
PeiServicesTablePointerNotifyCallback (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
- IN VOID *Ppi
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
+ IN VOID *Ppi
)
{
gPeiServices = (CONST EFI_PEI_SERVICES **)PeiServices;
@@ -91,14 +88,12 @@ PeiServicesTablePointerNotifyCallback (
return EFI_SUCCESS;
}
-
-EFI_PEI_NOTIFY_DESCRIPTOR mNotifyOnThunkList = {
+EFI_PEI_NOTIFY_DESCRIPTOR mNotifyOnThunkList = {
(EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
&gEfiPeiMemoryDiscoveredPpiGuid,
PeiServicesTablePointerNotifyCallback
};
-
/**
Constructor register notification on when PPI updates. If PPI is
alreay installed registering the notify will cause the handle to
@@ -113,11 +108,11 @@ EFI_PEI_NOTIFY_DESCRIPTOR mNotifyOnThunkList = {
EFI_STATUS
EFIAPI
PeiServicesTablePointerLibConstructor (
- IN EFI_PEI_FILE_HANDLE FileHandle,
- IN CONST EFI_PEI_SERVICES **PeiServices
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ IN CONST EFI_PEI_SERVICES **PeiServices
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
gPeiServices = (CONST EFI_PEI_SERVICES **)PeiServices;
@@ -153,4 +148,3 @@ MigratePeiServicesTablePointer (
//
return;
}
-
diff --git a/EmulatorPkg/Library/PeiServicesTablePointerLibMagicPage/PeiServicesTablePointer.c b/EmulatorPkg/Library/PeiServicesTablePointerLibMagicPage/PeiServicesTablePointer.c
index 9d6e1dfd8a..4f43d6d1aa 100644
--- a/EmulatorPkg/Library/PeiServicesTablePointerLibMagicPage/PeiServicesTablePointer.c
+++ b/EmulatorPkg/Library/PeiServicesTablePointerLibMagicPage/PeiServicesTablePointer.c
@@ -16,7 +16,6 @@
#include <Library/DebugLib.h>
#include <Library/EmuMagicPageLib.h>
-
/**
Caches a pointer PEI Services Table.
@@ -31,12 +30,12 @@
VOID
EFIAPI
SetPeiServicesTablePointer (
- IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer
+ IN CONST EFI_PEI_SERVICES **PeiServicesTablePointer
)
{
ASSERT (PeiServicesTablePointer != NULL);
ASSERT (*PeiServicesTablePointer != NULL);
- EMU_MAGIC_PAGE()->PeiServicesTablePointer = PeiServicesTablePointer;
+ EMU_MAGIC_PAGE ()->PeiServicesTablePointer = PeiServicesTablePointer;
}
/**
@@ -57,9 +56,9 @@ GetPeiServicesTablePointer (
VOID
)
{
- CONST EFI_PEI_SERVICES **PeiServicesTablePointer;
+ CONST EFI_PEI_SERVICES **PeiServicesTablePointer;
- PeiServicesTablePointer = EMU_MAGIC_PAGE()->PeiServicesTablePointer;
+ PeiServicesTablePointer = EMU_MAGIC_PAGE ()->PeiServicesTablePointer;
ASSERT (PeiServicesTablePointer != NULL);
ASSERT (*PeiServicesTablePointer != NULL);
return PeiServicesTablePointer;
@@ -91,5 +90,3 @@ MigratePeiServicesTablePointer (
//
return;
}
-
-
diff --git a/EmulatorPkg/Library/PeiTimerLib/PeiTimerLib.c b/EmulatorPkg/Library/PeiTimerLib/PeiTimerLib.c
index c71b166853..8c4f20f42b 100644
--- a/EmulatorPkg/Library/PeiTimerLib/PeiTimerLib.c
+++ b/EmulatorPkg/Library/PeiTimerLib/PeiTimerLib.c
@@ -28,7 +28,7 @@
UINTN
EFIAPI
MicroSecondDelay (
- IN UINTN MicroSeconds
+ IN UINTN MicroSeconds
)
{
return NanoSecondDelay (MicroSeconds * 1000);
@@ -47,24 +47,24 @@ MicroSecondDelay (
UINTN
EFIAPI
NanoSecondDelay (
- IN UINTN NanoSeconds
+ IN UINTN NanoSeconds
)
{
- EMU_THUNK_PPI *ThunkPpi;
- EFI_STATUS Status;
- EMU_THUNK_PROTOCOL *Thunk;
+ EMU_THUNK_PPI *ThunkPpi;
+ EFI_STATUS Status;
+ EMU_THUNK_PROTOCOL *Thunk;
//
// Locate EmuThunkPpi for
//
Status = PeiServicesLocatePpi (
- &gEmuThunkPpiGuid,
- 0,
- NULL,
- (VOID **) &ThunkPpi
+ &gEmuThunkPpiGuid,
+ 0,
+ NULL,
+ (VOID **)&ThunkPpi
);
if (!EFI_ERROR (Status)) {
- Thunk = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();
+ Thunk = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();
Thunk->Sleep (NanoSeconds * 100);
return NanoSeconds;
}
@@ -89,22 +89,22 @@ GetPerformanceCounter (
VOID
)
{
- EMU_THUNK_PPI *ThunkPpi;
- EFI_STATUS Status;
- EMU_THUNK_PROTOCOL *Thunk;
+ EMU_THUNK_PPI *ThunkPpi;
+ EFI_STATUS Status;
+ EMU_THUNK_PROTOCOL *Thunk;
//
// Locate EmuThunkPpi for
//
Status = PeiServicesLocatePpi (
- &gEmuThunkPpiGuid,
- 0,
- NULL,
- (VOID **) &ThunkPpi
+ &gEmuThunkPpiGuid,
+ 0,
+ NULL,
+ (VOID **)&ThunkPpi
);
if (!EFI_ERROR (Status)) {
- Thunk = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();
- return Thunk->QueryPerformanceCounter ();
+ Thunk = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();
+ return Thunk->QueryPerformanceCounter ();
}
return 0;
@@ -136,33 +136,34 @@ GetPerformanceCounter (
UINT64
EFIAPI
GetPerformanceCounterProperties (
- OUT UINT64 *StartValue OPTIONAL,
- OUT UINT64 *EndValue OPTIONAL
+ OUT UINT64 *StartValue OPTIONAL,
+ OUT UINT64 *EndValue OPTIONAL
)
{
- EMU_THUNK_PPI *ThunkPpi;
- EFI_STATUS Status;
- EMU_THUNK_PROTOCOL *Thunk;
+ EMU_THUNK_PPI *ThunkPpi;
+ EFI_STATUS Status;
+ EMU_THUNK_PROTOCOL *Thunk;
//
// Locate EmuThunkPpi for
//
Status = PeiServicesLocatePpi (
- &gEmuThunkPpiGuid,
- 0,
- NULL,
- (VOID **) &ThunkPpi
+ &gEmuThunkPpiGuid,
+ 0,
+ NULL,
+ (VOID **)&ThunkPpi
);
if (!EFI_ERROR (Status)) {
if (StartValue != NULL) {
*StartValue = 0ULL;
}
+
if (EndValue != NULL) {
*EndValue = (UINT64)-1LL;
}
- Thunk = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();
- return Thunk->QueryPerformanceFrequency ();
+ Thunk = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();
+ return Thunk->QueryPerformanceFrequency ();
}
return 0;
@@ -204,9 +205,9 @@ GetTimeInNanoSecond (
// Since 2^29 < 1,000,000,000 = 0x3B9ACA00 < 2^30, Remainder should < 2^(64-30) = 2^34,
// i.e. highest bit set in Remainder should <= 33.
//
- Shift = MAX (0, HighBitSet64 (Remainder) - 33);
- Remainder = RShiftU64 (Remainder, (UINTN) Shift);
- Frequency = RShiftU64 (Frequency, (UINTN) Shift);
+ Shift = MAX (0, HighBitSet64 (Remainder) - 33);
+ Remainder = RShiftU64 (Remainder, (UINTN)Shift);
+ Frequency = RShiftU64 (Frequency, (UINTN)Shift);
NanoSeconds += DivU64x64Remainder (MultU64x32 (Remainder, 1000000000u), Frequency, NULL);
return NanoSeconds;
diff --git a/EmulatorPkg/Library/PlatformBmLib/PlatformBm.c b/EmulatorPkg/Library/PlatformBmLib/PlatformBm.c
index 03f6157ae8..755fc04cb0 100644
--- a/EmulatorPkg/Library/PlatformBmLib/PlatformBm.c
+++ b/EmulatorPkg/Library/PlatformBmLib/PlatformBm.c
@@ -8,7 +8,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "PlatformBm.h"
-EFI_GUID mBootMenuFile = {
+EFI_GUID mBootMenuFile = {
0xEEC25BDC, 0x67F2, 0x4D95, { 0xB1, 0xD5, 0xF8, 0x1B, 0x20, 0x39, 0xD1, 0x1D }
};
@@ -20,24 +20,24 @@ SetupVariableInit (
VOID
)
{
- EFI_STATUS Status;
- UINTN Size;
- EMU_SYSTEM_CONFIGURATION SystemConfigData;
+ EFI_STATUS Status;
+ UINTN Size;
+ EMU_SYSTEM_CONFIGURATION SystemConfigData;
- Size = sizeof (SystemConfigData);
+ Size = sizeof (SystemConfigData);
Status = gRT->GetVariable (
L"Setup",
&gEmuSystemConfigGuid,
NULL,
&Size,
- (VOID *) &SystemConfigData
+ (VOID *)&SystemConfigData
);
if (EFI_ERROR (Status)) {
//
// SetupVariable is corrupt
//
- SystemConfigData.ConOutRow = PcdGet32 (PcdConOutColumn);
+ SystemConfigData.ConOutRow = PcdGet32 (PcdConOutColumn);
SystemConfigData.ConOutColumn = PcdGet32 (PcdConOutRow);
Status = gRT->SetVariable (
@@ -45,7 +45,7 @@ SetupVariableInit (
&gEmuSystemConfigGuid,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
sizeof (SystemConfigData),
- (VOID *) &SystemConfigData
+ (VOID *)&SystemConfigData
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Failed to save Setup Variable to non-volatile storage, Status = %r\n", Status));
@@ -55,10 +55,9 @@ SetupVariableInit (
EFI_DEVICE_PATH *
FvFilePath (
- EFI_GUID *FileGuid
+ EFI_GUID *FileGuid
)
{
-
EFI_STATUS Status;
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
@@ -68,12 +67,12 @@ FvFilePath (
Status = gBS->HandleProtocol (
gImageHandle,
&gEfiLoadedImageProtocolGuid,
- (VOID **) &LoadedImage
+ (VOID **)&LoadedImage
);
ASSERT_EFI_ERROR (Status);
return AppendDevicePathNode (
DevicePathFromHandle (LoadedImage->DeviceHandle),
- (EFI_DEVICE_PATH_PROTOCOL *) &FileNode
+ (EFI_DEVICE_PATH_PROTOCOL *)&FileNode
);
}
@@ -91,28 +90,28 @@ FvFilePath (
**/
UINTN
RegisterBootManagerMenuAppBootOption (
- EFI_GUID *FileGuid,
- CHAR16 *Description,
- UINTN Position,
- BOOLEAN IsBootCategory
+ EFI_GUID *FileGuid,
+ CHAR16 *Description,
+ UINTN Position,
+ BOOLEAN IsBootCategory
)
{
- EFI_STATUS Status;
- EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- UINTN OptionNumber;
+ EFI_STATUS Status;
+ EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ UINTN OptionNumber;
DevicePath = FvFilePath (FileGuid);
- Status = EfiBootManagerInitializeLoadOption (
- &NewOption,
- LoadOptionNumberUnassigned,
- LoadOptionTypeBoot,
- IsBootCategory ? LOAD_OPTION_ACTIVE : LOAD_OPTION_CATEGORY_APP,
- Description,
- DevicePath,
- NULL,
- 0
- );
+ Status = EfiBootManagerInitializeLoadOption (
+ &NewOption,
+ LoadOptionNumberUnassigned,
+ LoadOptionTypeBoot,
+ IsBootCategory ? LOAD_OPTION_ACTIVE : LOAD_OPTION_CATEGORY_APP,
+ Description,
+ DevicePath,
+ NULL,
+ 0
+ );
ASSERT_EFI_ERROR (Status);
FreePool (DevicePath);
@@ -136,16 +135,16 @@ RegisterBootManagerMenuAppBootOption (
**/
BOOLEAN
IsBootManagerMenuAppFilePath (
- EFI_DEVICE_PATH_PROTOCOL *DevicePath
-)
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
{
- EFI_HANDLE FvHandle;
- VOID *NameGuid;
- EFI_STATUS Status;
+ EFI_HANDLE FvHandle;
+ VOID *NameGuid;
+ EFI_STATUS Status;
Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &DevicePath, &FvHandle);
if (!EFI_ERROR (Status)) {
- NameGuid = EfiGetNameGuidFromFwVolDevicePathNode ((CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) DevicePath);
+ NameGuid = EfiGetNameGuidFromFwVolDevicePathNode ((CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)DevicePath);
if (NameGuid != NULL) {
return CompareGuid (NameGuid, &mBootMenuFile);
}
@@ -167,10 +166,10 @@ GetBootManagerMenuAppOption (
VOID
)
{
- UINTN BootOptionCount;
- EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
- UINTN Index;
- UINTN OptionNumber;
+ UINTN BootOptionCount;
+ EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
+ UINTN Index;
+ UINTN OptionNumber;
OptionNumber = 0;
@@ -189,7 +188,7 @@ GetBootManagerMenuAppOption (
//
// If not found the BootManagerMenuApp, create it.
//
- OptionNumber = (UINT16) RegisterBootManagerMenuAppBootOption (&mBootMenuFile, L"UEFI BootManagerMenuApp", (UINTN) -1, FALSE);
+ OptionNumber = (UINT16)RegisterBootManagerMenuAppBootOption (&mBootMenuFile, L"UEFI BootManagerMenuApp", (UINTN)-1, FALSE);
}
return OptionNumber;
@@ -205,13 +204,13 @@ PlatformBootManagerBeforeConsole (
VOID
)
{
- UINTN Index;
+ UINTN Index;
SetupVariableInit ();
EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid);
- Index = 0;
+ Index = 0;
while (gPlatformConsole[Index].DevicePath != NULL) {
//
// Update the console variable with the connect type
@@ -256,8 +255,8 @@ PlatformBdsConnectSequence (
**/
VOID
PlatformBdsDiagnostics (
- IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,
- IN BOOLEAN QuietBoot
+ IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,
+ IN BOOLEAN QuietBoot
)
{
EFI_STATUS Status;
@@ -317,14 +316,14 @@ PlatformBdsRegisterStaticBootOptions (
F2.ScanCode = SCAN_F2;
F2.UnicodeChar = CHAR_NULL;
EfiBootManagerGetBootManagerMenu (&BootOption);
- EfiBootManagerAddKeyOptionVariable (NULL, (UINT16) BootOption.OptionNumber, 0, &F2, NULL);
+ EfiBootManagerAddKeyOptionVariable (NULL, (UINT16)BootOption.OptionNumber, 0, &F2, NULL);
//
// 3. Boot Device List menu
//
- F7.ScanCode = SCAN_F7;
- F7.UnicodeChar = CHAR_NULL;
- OptionNumber = GetBootManagerMenuAppOption ();
+ F7.ScanCode = SCAN_F7;
+ F7.UnicodeChar = CHAR_NULL;
+ OptionNumber = GetBootManagerMenuAppOption ();
EfiBootManagerAddKeyOptionVariable (NULL, (UINT16)OptionNumber, 0, &F7, NULL);
PrintXY (10, 10, &White, &Black, L"F2 to enter Setup. ");
@@ -339,7 +338,7 @@ PlatformBdsRegisterStaticBootOptions (
**/
UINTN
BootOptionPriority (
- CONST EFI_BOOT_MANAGER_LOAD_OPTION *BootOption
+ CONST EFI_BOOT_MANAGER_LOAD_OPTION *BootOption
)
{
//
@@ -348,6 +347,7 @@ BootOptionPriority (
if (StrCmp (BootOption->Description, L"UEFI Shell") == 0) {
return 0;
}
+
return 100;
}
@@ -377,37 +377,35 @@ PlatformBootManagerAfterConsole (
VOID
)
{
-
//
// Go the different platform policy with different boot mode
// Notes: this part code can be change with the table policy
//
switch (GetBootModeHob ()) {
+ case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:
+ case BOOT_WITH_MINIMAL_CONFIGURATION:
+ PlatformBdsDiagnostics (IGNORE, TRUE);
+
+ //
+ // Perform some platform specific connect sequence
+ //
+ PlatformBdsConnectSequence ();
+ break;
- case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:
- case BOOT_WITH_MINIMAL_CONFIGURATION:
- PlatformBdsDiagnostics (IGNORE, TRUE);
+ case BOOT_IN_RECOVERY_MODE:
+ PlatformBdsDiagnostics (EXTENSIVE, FALSE);
+ break;
- //
- // Perform some platform specific connect sequence
- //
- PlatformBdsConnectSequence ();
- break;
-
- case BOOT_IN_RECOVERY_MODE:
- PlatformBdsDiagnostics (EXTENSIVE, FALSE);
- break;
-
- case BOOT_WITH_FULL_CONFIGURATION:
- case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:
- case BOOT_WITH_DEFAULT_SETTINGS:
- default:
- PlatformBdsDiagnostics (IGNORE, TRUE);
- PlatformBdsRegisterStaticBootOptions ();
- PlatformBdsConnectSequence ();
- EfiBootManagerRefreshAllBootOption ();
- EfiBootManagerSortLoadOptionVariable (LoadOptionTypeBoot, (SORT_COMPARE)CompareBootOption);
- break;
+ case BOOT_WITH_FULL_CONFIGURATION:
+ case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:
+ case BOOT_WITH_DEFAULT_SETTINGS:
+ default:
+ PlatformBdsDiagnostics (IGNORE, TRUE);
+ PlatformBdsRegisterStaticBootOptions ();
+ PlatformBdsConnectSequence ();
+ EfiBootManagerRefreshAllBootOption ();
+ EfiBootManagerSortLoadOptionVariable (LoadOptionTypeBoot, (SORT_COMPARE)CompareBootOption);
+ break;
}
}
@@ -419,12 +417,12 @@ PlatformBootManagerAfterConsole (
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);
@@ -456,4 +454,3 @@ PlatformBootManagerUnableToBoot (
{
return;
}
-
diff --git a/EmulatorPkg/Library/PlatformBmLib/PlatformBm.h b/EmulatorPkg/Library/PlatformBmLib/PlatformBm.h
index ce508b6b58..b89ffd77e4 100644
--- a/EmulatorPkg/Library/PlatformBmLib/PlatformBm.h
+++ b/EmulatorPkg/Library/PlatformBmLib/PlatformBm.h
@@ -34,14 +34,14 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/HobLib.h>
#include <Library/HiiLib.h>
-#define CONSOLE_OUT 0x00000001
-#define STD_ERROR 0x00000002
-#define CONSOLE_IN 0x00000004
-#define CONSOLE_ALL (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)
+#define CONSOLE_OUT 0x00000001
+#define STD_ERROR 0x00000002
+#define CONSOLE_IN 0x00000004
+#define CONSOLE_ALL (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)
typedef struct {
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- UINTN ConnectType;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ UINTN ConnectType;
} BDS_CONSOLE_CONNECT_ENTRY;
extern BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole[];
@@ -56,14 +56,12 @@ extern BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole[];
}\
}
-
typedef struct {
- EMU_VENDOR_DEVICE_PATH_NODE EmuBus;
- EMU_VENDOR_DEVICE_PATH_NODE EmuGraphicsWindow;
- EFI_DEVICE_PATH_PROTOCOL End;
+ EMU_VENDOR_DEVICE_PATH_NODE EmuBus;
+ EMU_VENDOR_DEVICE_PATH_NODE EmuGraphicsWindow;
+ EFI_DEVICE_PATH_PROTOCOL End;
} EMU_PLATFORM_UGA_DEVICE_PATH;
-
//
// Platform BDS Functions
//
@@ -80,10 +78,9 @@ typedef struct {
**/
EFI_STATUS
PlatformBootManagerMemoryTest (
- IN EXTENDMEM_COVERAGE_LEVEL Level
+ IN EXTENDMEM_COVERAGE_LEVEL Level
);
-
VOID
PlatformBdsConnectSequence (
VOID
diff --git a/EmulatorPkg/Library/PlatformBmLib/PlatformBmData.c b/EmulatorPkg/Library/PlatformBmLib/PlatformBmData.c
index 1151021606..efb03def37 100644
--- a/EmulatorPkg/Library/PlatformBmLib/PlatformBmData.c
+++ b/EmulatorPkg/Library/PlatformBmLib/PlatformBmData.c
@@ -8,17 +8,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "PlatformBm.h"
-
-
-EMU_PLATFORM_UGA_DEVICE_PATH gGopDevicePath = {
+EMU_PLATFORM_UGA_DEVICE_PATH gGopDevicePath = {
{
{
{
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{
- (UINT8) (sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),
- (UINT8) ((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)
+ (UINT8)(sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),
+ (UINT8)((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)
}
},
EMU_THUNK_PROTOCOL_GUID
@@ -31,8 +29,8 @@ EMU_PLATFORM_UGA_DEVICE_PATH gGopDevicePath = {
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{
- (UINT8) (sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),
- (UINT8) ((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)
+ (UINT8)(sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),
+ (UINT8)((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)
},
},
EMU_GRAPHICS_WINDOW_PROTOCOL_GUID,
@@ -42,15 +40,15 @@ EMU_PLATFORM_UGA_DEVICE_PATH gGopDevicePath = {
gEndEntire
};
-EMU_PLATFORM_UGA_DEVICE_PATH gGopDevicePath2 = {
+EMU_PLATFORM_UGA_DEVICE_PATH gGopDevicePath2 = {
{
{
{
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{
- (UINT8) (sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),
- (UINT8) ((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)
+ (UINT8)(sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),
+ (UINT8)((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)
}
},
EMU_THUNK_PROTOCOL_GUID
@@ -63,8 +61,8 @@ EMU_PLATFORM_UGA_DEVICE_PATH gGopDevicePath2 = {
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{
- (UINT8) (sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),
- (UINT8) ((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)
+ (UINT8)(sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),
+ (UINT8)((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)
},
},
EMU_GRAPHICS_WINDOW_PROTOCOL_GUID,
@@ -77,13 +75,13 @@ EMU_PLATFORM_UGA_DEVICE_PATH gGopDevicePath2 = {
//
// Predefined platform default console device path
//
-BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole[] = {
+BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole[] = {
{
- (EFI_DEVICE_PATH_PROTOCOL *) &gGopDevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gGopDevicePath,
(CONSOLE_OUT | CONSOLE_IN)
},
{
- (EFI_DEVICE_PATH_PROTOCOL *) &gGopDevicePath2,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gGopDevicePath2,
(CONSOLE_OUT | CONSOLE_IN)
},
{
@@ -91,4 +89,3 @@ BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole[] = {
0
}
};
-
diff --git a/EmulatorPkg/Library/PlatformBmLib/PlatformBmMemoryTest.c b/EmulatorPkg/Library/PlatformBmLib/PlatformBmMemoryTest.c
index bda704cf94..db1b9d86ac 100644
--- a/EmulatorPkg/Library/PlatformBmLib/PlatformBmMemoryTest.c
+++ b/EmulatorPkg/Library/PlatformBmLib/PlatformBmMemoryTest.c
@@ -24,7 +24,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
EFI_STATUS
PlatformBootManagerMemoryTest (
- IN EXTENDMEM_COVERAGE_LEVEL Level
+ IN EXTENDMEM_COVERAGE_LEVEL Level
)
{
EFI_STATUS Status;
@@ -42,17 +42,17 @@ PlatformBootManagerMemoryTest (
ReturnStatus = EFI_SUCCESS;
ZeroMem (&Key, sizeof (EFI_INPUT_KEY));
- TestedMemorySize = 0;
- TotalMemorySize = 0;
- ErrorOut = FALSE;
- TestAbort = FALSE;
+ TestedMemorySize = 0;
+ TotalMemorySize = 0;
+ ErrorOut = FALSE;
+ TestAbort = FALSE;
RequireSoftECCInit = FALSE;
Status = gBS->LocateProtocol (
&gEfiGenericMemTestProtocolGuid,
NULL,
- (VOID **) &GenMemoryTest
+ (VOID **)&GenMemoryTest
);
if (EFI_ERROR (Status)) {
return EFI_SUCCESS;
@@ -88,11 +88,10 @@ PlatformBootManagerMemoryTest (
ASSERT (0);
}
-
DEBUG ((DEBUG_INFO, "Perform memory test (ESC to skip).\n"));
if (!PcdGetBool (PcdConInConnectOnDemand)) {
- KeyStatus = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
+ KeyStatus = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
if (!EFI_ERROR (KeyStatus) && (Key.ScanCode == SCAN_ESC)) {
if (!RequireSoftECCInit) {
Status = GenMemoryTest->Finished (GenMemoryTest);
diff --git a/EmulatorPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCredentialLib.c b/EmulatorPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCredentialLib.c
index 5428aa324e..eaf9c56450 100644
--- a/EmulatorPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCredentialLib.c
+++ b/EmulatorPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCredentialLib.c
@@ -18,15 +18,15 @@
#include <Guid/GlobalVariable.h>
#include <Guid/ImageAuthentication.h>
-BOOLEAN mSecureBootDisabled = FALSE;
-BOOLEAN mStopRedfishService = FALSE;
+BOOLEAN mSecureBootDisabled = FALSE;
+BOOLEAN mStopRedfishService = FALSE;
EFI_STATUS
EFIAPI
LibStopRedfishService (
- IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This,
- IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType
-);
+ IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This,
+ IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType
+ );
/**
Return the credential for accessing to Redfish servcice.
@@ -41,10 +41,10 @@ LibStopRedfishService (
**/
EFI_STATUS
GetRedfishCredential (
- OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod,
- OUT CHAR8 **UserId,
- OUT CHAR8 **Password
-)
+ OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod,
+ OUT CHAR8 **UserId,
+ OUT CHAR8 **Password
+ )
{
UINTN UserIdSize;
UINTN PasswordSize;
@@ -59,14 +59,16 @@ GetRedfishCredential (
//
UserIdSize = AsciiStrSize ((CHAR8 *)PcdGetPtr (PcdRedfishServieUserId));
PasswordSize = AsciiStrSize ((CHAR8 *)PcdGetPtr (PcdRedfishServiePassword));
- if (UserIdSize == 0 || PasswordSize == 0) {
+ if ((UserIdSize == 0) || (PasswordSize == 0)) {
DEBUG ((DEBUG_ERROR, "Incorrect string of UserID or Password for REdfish service.\n"));
return EFI_INVALID_PARAMETER;
}
+
*UserId = AllocateZeroPool (UserIdSize);
if (*UserId == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
CopyMem (*UserId, (CHAR8 *)PcdGetPtr (PcdRedfishServieUserId), UserIdSize);
*Password = AllocateZeroPool (PasswordSize);
@@ -110,11 +112,11 @@ LibCredentialGetAuthInfo (
OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod,
OUT CHAR8 **UserId,
OUT CHAR8 **Password
-)
+ )
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
- if (This == NULL || AuthMethod == NULL || UserId == NULL || Password == NULL) {
+ if ((This == NULL) || (AuthMethod == NULL) || (UserId == NULL) || (Password == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -124,7 +126,7 @@ LibCredentialGetAuthInfo (
if (mSecureBootDisabled) {
Status = LibStopRedfishService (This, ServiceStopTypeSecureBootDisabled);
- if (EFI_ERROR (Status) && Status != EFI_UNSUPPORTED) {
+ if (EFI_ERROR (Status) && (Status != EFI_UNSUPPORTED)) {
DEBUG ((DEBUG_ERROR, "SecureBoot has been disabled, but failed to stop RedfishService - %r\n", Status));
return Status;
}
@@ -159,9 +161,9 @@ LibCredentialGetAuthInfo (
EFI_STATUS
EFIAPI
LibStopRedfishService (
- IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This,
- IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType
-)
+ IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This,
+ IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType
+ )
{
if (ServiceStopType >= ServiceStopTypeMax) {
return EFI_INVALID_PARAMETER;
@@ -193,8 +195,10 @@ LibStopRedfishService (
mStopRedfishService = TRUE;
DEBUG ((DEBUG_INFO, "EFI Redfish service is stopped without Redfish service stop type!!\n"));
}
+
return EFI_SUCCESS;
}
+
/**
Notification of Exit Boot Service.
@@ -204,7 +208,7 @@ VOID
EFIAPI
LibCredentialExitBootServicesNotify (
IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This
-)
+ )
{
LibStopRedfishService (This, ServiceStopTypeExitBootService);
}
@@ -218,15 +222,15 @@ VOID
EFIAPI
LibCredentialEndOfDxeNotify (
IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This
-)
+ )
{
EFI_STATUS Status;
- UINT8 *SecureBootVar;
+ UINT8 *SecureBootVar;
//
// Check Secure Boot status and lock Redfish service if Secure Boot is disabled.
//
- Status = GetVariable2 (EFI_SECURE_BOOT_MODE_NAME, &gEfiGlobalVariableGuid, (VOID**)&SecureBootVar, NULL);
+ Status = GetVariable2 (EFI_SECURE_BOOT_MODE_NAME, &gEfiGlobalVariableGuid, (VOID **)&SecureBootVar, NULL);
if (EFI_ERROR (Status) || (*SecureBootVar != SECURE_BOOT_MODE_ENABLE)) {
//
// Secure Boot is disabled
diff --git a/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c b/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
index 4e7bb65c06..3f053307a6 100644
--- a/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
+++ b/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
@@ -26,7 +26,7 @@
#define VERBOSE_COLUME_SIZE (16)
REDFISH_OVER_IP_PROTOCOL_DATA *mRedfishOverIpProtocolData;
-UINT8 mRedfishProtocolDataSize;
+UINT8 mRedfishProtocolDataSize;
/**
Get the MAC address of NIC.
@@ -38,22 +38,23 @@ UINT8 mRedfishProtocolDataSize;
**/
EFI_STATUS
GetMacAddressInformation (
- OUT EFI_MAC_ADDRESS *MacAddress
+ OUT EFI_MAC_ADDRESS *MacAddress
)
{
- MAC_ADDR_DEVICE_PATH *Mac;
- REST_EX_SERVICE_DEVICE_PATH_DATA *RestExServiceDevicePathData;
- EFI_DEVICE_PATH_PROTOCOL *RestExServiceDevicePath;
- MAC_ADDR_DEVICE_PATH *MacAddressDevicePath;
-
- Mac = NULL;
- RestExServiceDevicePathData = NULL;
- RestExServiceDevicePath = NULL;
-
- RestExServiceDevicePathData = (REST_EX_SERVICE_DEVICE_PATH_DATA *)PcdGetPtr(PcdRedfishRestExServiceDevicePath);
- if (RestExServiceDevicePathData == NULL ||
- RestExServiceDevicePathData->DevicePathNum == 0 ||
- !IsDevicePathValid (RestExServiceDevicePathData->DevicePath, 0)) {
+ MAC_ADDR_DEVICE_PATH *Mac;
+ REST_EX_SERVICE_DEVICE_PATH_DATA *RestExServiceDevicePathData;
+ EFI_DEVICE_PATH_PROTOCOL *RestExServiceDevicePath;
+ MAC_ADDR_DEVICE_PATH *MacAddressDevicePath;
+
+ Mac = NULL;
+ RestExServiceDevicePathData = NULL;
+ RestExServiceDevicePath = NULL;
+
+ RestExServiceDevicePathData = (REST_EX_SERVICE_DEVICE_PATH_DATA *)PcdGetPtr (PcdRedfishRestExServiceDevicePath);
+ if ((RestExServiceDevicePathData == NULL) ||
+ (RestExServiceDevicePathData->DevicePathNum == 0) ||
+ !IsDevicePathValid (RestExServiceDevicePathData->DevicePath, 0))
+ {
return EFI_NOT_FOUND;
}
@@ -67,7 +68,8 @@ GetMacAddressInformation (
//
while (!IsDevicePathEnd (RestExServiceDevicePath) &&
((DevicePathType (RestExServiceDevicePath) != MESSAGING_DEVICE_PATH) ||
- (DevicePathSubType (RestExServiceDevicePath) != MSG_MAC_ADDR_DP))) {
+ (DevicePathSubType (RestExServiceDevicePath) != MSG_MAC_ADDR_DP)))
+ {
RestExServiceDevicePath = NextDevicePathNode (RestExServiceDevicePath);
}
@@ -76,6 +78,7 @@ GetMacAddressInformation (
CopyMem ((VOID *)MacAddress, (VOID *)&MacAddressDevicePath->MacAddress, sizeof (EFI_MAC_ADDRESS));
return EFI_SUCCESS;
}
+
return EFI_NOT_FOUND;
}
@@ -91,35 +94,38 @@ GetMacAddressInformation (
**/
EFI_STATUS
RedfishPlatformHostInterfaceDeviceDescriptor (
- OUT UINT8 *DeviceType,
+ OUT UINT8 *DeviceType,
OUT REDFISH_INTERFACE_DATA **DeviceDescriptor
-)
+ )
{
- EFI_STATUS Status;
- EFI_MAC_ADDRESS MacAddress;
- REDFISH_INTERFACE_DATA *RedfishInterfaceData;
- PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2 *ThisDeviceDescriptor;
+ EFI_STATUS Status;
+ EFI_MAC_ADDRESS MacAddress;
+ REDFISH_INTERFACE_DATA *RedfishInterfaceData;
+ PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2 *ThisDeviceDescriptor;
RedfishInterfaceData = AllocateZeroPool (sizeof (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1);
if (RedfishInterfaceData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
RedfishInterfaceData->DeviceType = REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2;
//
// Fill up device type information.
//
- ThisDeviceDescriptor = (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2 *)((UINT8 *)RedfishInterfaceData + 1);
+ ThisDeviceDescriptor = (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2 *)((UINT8 *)RedfishInterfaceData + 1);
ThisDeviceDescriptor->Length = sizeof (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1;
- Status = GetMacAddressInformation (&MacAddress);
+ Status = GetMacAddressInformation (&MacAddress);
if (EFI_ERROR (Status)) {
FreePool (RedfishInterfaceData);
return EFI_NOT_FOUND;
}
+
CopyMem ((VOID *)&ThisDeviceDescriptor->MacAddress, (VOID *)&MacAddress, sizeof (ThisDeviceDescriptor->MacAddress));
- *DeviceType = REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2;
+ *DeviceType = REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2;
*DeviceDescriptor = RedfishInterfaceData;
return EFI_SUCCESS;
}
+
/**
Get platform Redfish host interface protocol data.
Caller should pass NULL in ProtocolRecord to retrive the first protocol record.
@@ -136,29 +142,32 @@ RedfishPlatformHostInterfaceDeviceDescriptor (
**/
EFI_STATUS
RedfishPlatformHostInterfaceProtocolData (
- OUT MC_HOST_INTERFACE_PROTOCOL_RECORD **ProtocolRecord,
- IN UINT8 IndexOfProtocolData
-)
+ OUT MC_HOST_INTERFACE_PROTOCOL_RECORD **ProtocolRecord,
+ IN UINT8 IndexOfProtocolData
+ )
{
- MC_HOST_INTERFACE_PROTOCOL_RECORD *ThisProtocolRecord;
+ MC_HOST_INTERFACE_PROTOCOL_RECORD *ThisProtocolRecord;
if (mRedfishOverIpProtocolData == 0) {
return EFI_NOT_FOUND;
}
+
if (IndexOfProtocolData == 0) {
//
// Return the first Redfish protocol data to caller. We only have
// one protocol data in this case.
//
- ThisProtocolRecord = (MC_HOST_INTERFACE_PROTOCOL_RECORD *) AllocatePool (mRedfishProtocolDataSize + sizeof (MC_HOST_INTERFACE_PROTOCOL_RECORD) - 1);
- ThisProtocolRecord->ProtocolType = MCHostInterfaceProtocolTypeRedfishOverIP;
+ ThisProtocolRecord = (MC_HOST_INTERFACE_PROTOCOL_RECORD *)AllocatePool (mRedfishProtocolDataSize + sizeof (MC_HOST_INTERFACE_PROTOCOL_RECORD) - 1);
+ ThisProtocolRecord->ProtocolType = MCHostInterfaceProtocolTypeRedfishOverIP;
ThisProtocolRecord->ProtocolTypeDataLen = mRedfishProtocolDataSize;
CopyMem ((VOID *)&ThisProtocolRecord->ProtocolTypeData, (VOID *)mRedfishOverIpProtocolData, mRedfishProtocolDataSize);
*ProtocolRecord = ThisProtocolRecord;
return EFI_SUCCESS;
}
+
return EFI_NOT_FOUND;
}
+
/**
Dump IPv4 address.
@@ -166,10 +175,10 @@ RedfishPlatformHostInterfaceProtocolData (
**/
VOID
InternalDumpIp4Addr (
- IN EFI_IPv4_ADDRESS *Ip
+ IN EFI_IPv4_ADDRESS *Ip
)
{
- UINTN Index;
+ UINTN Index;
for (Index = 0; Index < 4; Index++) {
DEBUG ((DEBUG_VERBOSE, "%d", Ip->Addr[Index]));
@@ -180,6 +189,7 @@ InternalDumpIp4Addr (
DEBUG ((DEBUG_VERBOSE, "\n"));
}
+
/**
Dump IPv6 address.
@@ -187,15 +197,16 @@ InternalDumpIp4Addr (
**/
VOID
InternalDumpIp6Addr (
- IN EFI_IPv6_ADDRESS *Ip
+ IN EFI_IPv6_ADDRESS *Ip
)
{
- UINTN Index;
+ UINTN Index;
for (Index = 0; Index < 16; Index++) {
if (Ip->Addr[Index] != 0) {
DEBUG ((DEBUG_VERBOSE, "%x", Ip->Addr[Index]));
}
+
Index++;
if (Index > 15) {
@@ -205,14 +216,17 @@ InternalDumpIp6Addr (
if (((Ip->Addr[Index] & 0xf0) == 0) && (Ip->Addr[Index - 1] != 0)) {
DEBUG ((DEBUG_VERBOSE, "0"));
}
+
DEBUG ((DEBUG_VERBOSE, "%x", Ip->Addr[Index]));
if (Index < 15) {
DEBUG ((DEBUG_VERBOSE, ":"));
}
}
+
DEBUG ((DEBUG_VERBOSE, "\n"));
}
+
/**
Dump data
@@ -226,10 +240,12 @@ InternalDumpData (
)
{
UINTN Index;
+
for (Index = 0; Index < Size; Index++) {
DEBUG ((DEBUG_VERBOSE, "%02x ", (UINTN)Data[Index]));
}
}
+
/**
Dump hex data
@@ -242,9 +258,9 @@ InternalDumpHex (
IN UINTN Size
)
{
- UINTN Index;
- UINTN Count;
- UINTN Left;
+ UINTN Index;
+ UINTN Count;
+ UINTN Left;
Count = Size / VERBOSE_COLUME_SIZE;
Left = Size % VERBOSE_COLUME_SIZE;
@@ -260,6 +276,7 @@ InternalDumpHex (
DEBUG ((DEBUG_VERBOSE, "\n"));
}
+
/**
Dump Redfish over IP protocol data
@@ -268,14 +285,14 @@ InternalDumpHex (
**/
VOID
DumpRedfishIpProtocolData (
- IN REDFISH_OVER_IP_PROTOCOL_DATA *RedfishProtocolData,
- IN UINT8 RedfishProtocolDataSize
+ IN REDFISH_OVER_IP_PROTOCOL_DATA *RedfishProtocolData,
+ IN UINT8 RedfishProtocolDataSize
)
{
- CHAR16 Hostname[16];
+ CHAR16 Hostname[16];
DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData: \n"));
- InternalDumpHex ((UINT8 *) RedfishProtocolData, RedfishProtocolDataSize);
+ InternalDumpHex ((UINT8 *)RedfishProtocolData, RedfishProtocolDataSize);
DEBUG ((DEBUG_VERBOSE, "Parsing as below: \n"));
@@ -287,16 +304,16 @@ DumpRedfishIpProtocolData (
DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->HostIpAddress: \n"));
if (RedfishProtocolData->HostIpAddressFormat == 0x01) {
- InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *) (RedfishProtocolData->HostIpAddress));
+ InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *)(RedfishProtocolData->HostIpAddress));
} else {
- InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *) (RedfishProtocolData->HostIpAddress));
+ InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *)(RedfishProtocolData->HostIpAddress));
}
DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->HostIpMask: \n"));
if (RedfishProtocolData->HostIpAddressFormat == 0x01) {
- InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *) (RedfishProtocolData->HostIpMask));
+ InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *)(RedfishProtocolData->HostIpMask));
} else {
- InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *) (RedfishProtocolData->HostIpMask));
+ InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *)(RedfishProtocolData->HostIpMask));
}
DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpDiscoveryType - %d\n", RedfishProtocolData->RedfishServiceIpDiscoveryType));
@@ -305,16 +322,16 @@ DumpRedfishIpProtocolData (
DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpAddress: \n"));
if (RedfishProtocolData->RedfishServiceIpAddressFormat == 0x01) {
- InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *) (RedfishProtocolData->RedfishServiceIpAddress));
+ InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *)(RedfishProtocolData->RedfishServiceIpAddress));
} else {
- InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *) (RedfishProtocolData->RedfishServiceIpAddress));
+ InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *)(RedfishProtocolData->RedfishServiceIpAddress));
}
DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpMask: \n"));
if (RedfishProtocolData->RedfishServiceIpAddressFormat == 0x01) {
- InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *) (RedfishProtocolData->RedfishServiceIpMask));
+ InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *)(RedfishProtocolData->RedfishServiceIpMask));
} else {
- InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *) (RedfishProtocolData->RedfishServiceIpMask));
+ InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *)(RedfishProtocolData->RedfishServiceIpMask));
}
DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpPort - %d\n", RedfishProtocolData->RedfishServiceIpPort));
@@ -323,7 +340,7 @@ DumpRedfishIpProtocolData (
DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceHostnameLength - %d\n", RedfishProtocolData->RedfishServiceHostnameLength));
- AsciiStrToUnicodeStrS((CHAR8 *) RedfishProtocolData->RedfishServiceHostname, Hostname, sizeof (Hostname) / sizeof (Hostname[0]));
+ AsciiStrToUnicodeStrS ((CHAR8 *)RedfishProtocolData->RedfishServiceHostname, Hostname, sizeof (Hostname) / sizeof (Hostname[0]));
DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceHostname - %s\n", Hostname));
}
@@ -337,24 +354,24 @@ DumpRedfishIpProtocolData (
**/
EFI_STATUS
GetRedfishRecordFromVariable (
- OUT REDFISH_OVER_IP_PROTOCOL_DATA **RedfishProtocolData,
- OUT UINT8 *RedfishProtocolDataSize
+ OUT REDFISH_OVER_IP_PROTOCOL_DATA **RedfishProtocolData,
+ OUT UINT8 *RedfishProtocolDataSize
)
{
- EFI_STATUS Status;
- UINT8 HostIpAssignmentType;
- UINTN HostIpAssignmentTypeSize;
- EFI_IPv4_ADDRESS HostIpAddress;
- UINTN IPv4DataSize;
- EFI_IPv4_ADDRESS HostIpMask;
- EFI_IPv4_ADDRESS RedfishServiceIpAddress;
- EFI_IPv4_ADDRESS RedfishServiceIpMask;
- UINT16 RedfishServiceIpPort;
- UINTN IpPortDataSize;
- UINT8 HostNameSize;
- CHAR8 RedfishHostName[20];
-
- if (RedfishProtocolData == NULL || RedfishProtocolDataSize == NULL) {
+ EFI_STATUS Status;
+ UINT8 HostIpAssignmentType;
+ UINTN HostIpAssignmentTypeSize;
+ EFI_IPv4_ADDRESS HostIpAddress;
+ UINTN IPv4DataSize;
+ EFI_IPv4_ADDRESS HostIpMask;
+ EFI_IPv4_ADDRESS RedfishServiceIpAddress;
+ EFI_IPv4_ADDRESS RedfishServiceIpMask;
+ UINT16 RedfishServiceIpPort;
+ UINTN IpPortDataSize;
+ UINT8 HostNameSize;
+ CHAR8 RedfishHostName[20];
+
+ if ((RedfishProtocolData == NULL) || (RedfishProtocolDataSize == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -446,7 +463,7 @@ GetRedfishRecordFromVariable (
RedfishServiceIpAddress.Addr[3]
);
- HostNameSize = (UINT8) AsciiStrLen (RedfishHostName) + 1;
+ HostNameSize = (UINT8)AsciiStrLen (RedfishHostName) + 1;
//
// 2. Protocol Data Size.
@@ -456,7 +473,7 @@ GetRedfishRecordFromVariable (
//
// 3. Protocol Data.
//
- *RedfishProtocolData = (REDFISH_OVER_IP_PROTOCOL_DATA *) AllocateZeroPool (*RedfishProtocolDataSize);
+ *RedfishProtocolData = (REDFISH_OVER_IP_PROTOCOL_DATA *)AllocateZeroPool (*RedfishProtocolDataSize);
if (*RedfishProtocolData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -464,7 +481,7 @@ GetRedfishRecordFromVariable (
CopyGuid (&(*RedfishProtocolData)->ServiceUuid, &gEmuRedfishServiceGuid);
(*RedfishProtocolData)->HostIpAssignmentType = HostIpAssignmentType;
- (*RedfishProtocolData)->HostIpAddressFormat = 1; // Only support IPv4
+ (*RedfishProtocolData)->HostIpAddressFormat = 1; // Only support IPv4
if (HostIpAssignmentType == 1 ) {
(*RedfishProtocolData)->HostIpAddress[0] = HostIpAddress.Addr[0];
@@ -495,7 +512,7 @@ GetRedfishRecordFromVariable (
(*RedfishProtocolData)->RedfishServiceVlanId = 0xffffffff;
(*RedfishProtocolData)->RedfishServiceHostnameLength = HostNameSize;
- AsciiStrCpyS ((CHAR8 *) ((*RedfishProtocolData)->RedfishServiceHostname), HostNameSize, RedfishHostName);
+ AsciiStrCpyS ((CHAR8 *)((*RedfishProtocolData)->RedfishServiceHostname), HostNameSize, RedfishHostName);
return Status;
}
@@ -513,16 +530,17 @@ GetRedfishRecordFromVariable (
EFI_STATUS
EFIAPI
RedfishPlatformHostInterfaceConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
-)
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = GetRedfishRecordFromVariable (&mRedfishOverIpProtocolData, &mRedfishProtocolDataSize);
DEBUG ((DEBUG_INFO, "%a: GetRedfishRecordFromVariable() - %r\n", __FUNCTION__, Status));
if (!EFI_ERROR (Status)) {
DumpRedfishIpProtocolData (mRedfishOverIpProtocolData, mRedfishProtocolDataSize);
}
+
return EFI_SUCCESS;
}
diff --git a/EmulatorPkg/Library/SecPeiServicesLib/FwVol.c b/EmulatorPkg/Library/SecPeiServicesLib/FwVol.c
index aee3003a26..e1cc6c6a51 100644
--- a/EmulatorPkg/Library/SecPeiServicesLib/FwVol.c
+++ b/EmulatorPkg/Library/SecPeiServicesLib/FwVol.c
@@ -9,7 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <PiPei.h>
-
#define GET_OCCUPIED_SIZE(ActualSize, Alignment) \
(ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1))
@@ -18,6 +17,7 @@ GetFileState (
IN UINT8 ErasePolarity,
IN EFI_FFS_FILE_HEADER *FfsHeader
)
+
/*++
Routine Description:
@@ -39,7 +39,7 @@ Returns:
FileState = FfsHeader->State;
if (ErasePolarity != 0) {
- FileState = (EFI_FFS_FILE_STATE)~FileState;
+ FileState = (EFI_FFS_FILE_STATE) ~FileState;
}
HighestBit = 0x80;
@@ -54,6 +54,7 @@ UINT8
CalculateHeaderChecksum (
IN EFI_FFS_FILE_HEADER *FileHeader
)
+
/*++
Routine Description:
@@ -67,41 +68,43 @@ Returns:
**/
{
- UINT8 *ptr;
- UINTN Index;
- UINT8 Sum;
+ UINT8 *ptr;
+ UINTN Index;
+ UINT8 Sum;
Sum = 0;
- ptr = (UINT8 *) FileHeader;
+ ptr = (UINT8 *)FileHeader;
for (Index = 0; Index < sizeof (EFI_FFS_FILE_HEADER) - 3; Index += 4) {
- Sum = (UINT8) (Sum + ptr[Index]);
- Sum = (UINT8) (Sum + ptr[Index + 1]);
- Sum = (UINT8) (Sum + ptr[Index + 2]);
- Sum = (UINT8) (Sum + ptr[Index + 3]);
+ Sum = (UINT8)(Sum + ptr[Index]);
+ Sum = (UINT8)(Sum + ptr[Index + 1]);
+ Sum = (UINT8)(Sum + ptr[Index + 2]);
+ Sum = (UINT8)(Sum + ptr[Index + 3]);
}
- for (; Index < sizeof (EFI_FFS_FILE_HEADER); Index++) {
- Sum = (UINT8) (Sum + ptr[Index]);
+ for ( ; Index < sizeof (EFI_FFS_FILE_HEADER); Index++) {
+ Sum = (UINT8)(Sum + ptr[Index]);
}
+
//
// State field (since this indicates the different state of file).
//
- Sum = (UINT8) (Sum - FileHeader->State);
+ Sum = (UINT8)(Sum - FileHeader->State);
//
// Checksum field of the file is not part of the header checksum.
//
- Sum = (UINT8) (Sum - FileHeader->IntegrityCheck.Checksum.File);
+ Sum = (UINT8)(Sum - FileHeader->IntegrityCheck.Checksum.File);
return Sum;
}
EFI_STATUS
SecFfsFindNextFile (
- IN EFI_FV_FILETYPE SearchType,
- IN EFI_PEI_FV_HANDLE FvHandle,
- IN OUT EFI_PEI_FILE_HANDLE *FileHandle
+ IN EFI_FV_FILETYPE SearchType,
+ IN EFI_PEI_FV_HANDLE FvHandle,
+ IN OUT EFI_PEI_FILE_HANDLE *FileHandle
)
+
/*++
Routine Description:
@@ -124,20 +127,20 @@ Returns:
**/
{
- EFI_FFS_FILE_HEADER *FfsFileHeader;
- UINT32 FileLength;
- UINT32 FileOccupiedSize;
- UINT32 FileOffset;
- UINT64 FvLength;
- UINT8 ErasePolarity;
- UINT8 FileState;
+ EFI_FFS_FILE_HEADER *FfsFileHeader;
+ UINT32 FileLength;
+ UINT32 FileOccupiedSize;
+ UINT32 FileOffset;
+ UINT64 FvLength;
+ UINT8 ErasePolarity;
+ UINT8 FileState;
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
EFI_FFS_FILE_HEADER **FileHeader;
//
// Convert the handle of FV to FV header for memory-mapped firmware volume
//
- FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) FvHandle;
+ FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)FvHandle;
FileHeader = (EFI_FFS_FILE_HEADER **)FileHandle;
FvLength = FwVolHeader->FvLength;
@@ -146,23 +149,24 @@ Returns:
} else {
ErasePolarity = 0;
}
+
//
// If FileHeader is not specified (NULL) start with the first file in the
// firmware volume. Otherwise, start from the FileHeader.
//
if (*FileHeader == NULL) {
- FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FwVolHeader + FwVolHeader->HeaderLength);
+ FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FwVolHeader + FwVolHeader->HeaderLength);
} else {
//
// Length is 24 bits wide so mask upper 8 bits
// FileLength is adjusted to FileOccupiedSize as it is 8 byte aligned.
//
- FileLength = *(UINT32 *) (*FileHeader)->Size & 0x00FFFFFF;
- FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8);
- FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) *FileHeader + FileOccupiedSize);
+ FileLength = *(UINT32 *)(*FileHeader)->Size & 0x00FFFFFF;
+ FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8);
+ FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)*FileHeader + FileOccupiedSize);
}
- FileOffset = (UINT32) ((UINT8 *) FfsFileHeader - (UINT8 *) FwVolHeader);
+ FileOffset = (UINT32)((UINT8 *)FfsFileHeader - (UINT8 *)FwVolHeader);
while (FileOffset < (FvLength - sizeof (EFI_FFS_FILE_HEADER))) {
//
@@ -171,42 +175,40 @@ Returns:
FileState = GetFileState (ErasePolarity, FfsFileHeader);
switch (FileState) {
-
- case EFI_FILE_HEADER_INVALID:
- FileOffset += sizeof (EFI_FFS_FILE_HEADER);
- FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + sizeof (EFI_FFS_FILE_HEADER));
- break;
-
- case EFI_FILE_DATA_VALID:
- case EFI_FILE_MARKED_FOR_UPDATE:
- if (CalculateHeaderChecksum (FfsFileHeader) == 0) {
- FileLength = *(UINT32 *) (FfsFileHeader->Size) & 0x00FFFFFF;
- FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8);
-
- if ((SearchType == FfsFileHeader->Type) || (SearchType == EFI_FV_FILETYPE_ALL)) {
-
- *FileHeader = FfsFileHeader;
-
- return EFI_SUCCESS;
+ case EFI_FILE_HEADER_INVALID:
+ FileOffset += sizeof (EFI_FFS_FILE_HEADER);
+ FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + sizeof (EFI_FFS_FILE_HEADER));
+ break;
+
+ case EFI_FILE_DATA_VALID:
+ case EFI_FILE_MARKED_FOR_UPDATE:
+ if (CalculateHeaderChecksum (FfsFileHeader) == 0) {
+ FileLength = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;
+ FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8);
+
+ if ((SearchType == FfsFileHeader->Type) || (SearchType == EFI_FV_FILETYPE_ALL)) {
+ *FileHeader = FfsFileHeader;
+
+ return EFI_SUCCESS;
+ }
+
+ FileOffset += FileOccupiedSize;
+ FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + FileOccupiedSize);
+ } else {
+ return EFI_NOT_FOUND;
}
- FileOffset += FileOccupiedSize;
- FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + FileOccupiedSize);
- } else {
- return EFI_NOT_FOUND;
- }
- break;
-
- case EFI_FILE_DELETED:
- FileLength = *(UINT32 *) (FfsFileHeader->Size) & 0x00FFFFFF;
- FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8);
- FileOffset += FileOccupiedSize;
- FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + FileOccupiedSize);
- break;
+ break;
- default:
- return EFI_NOT_FOUND;
+ case EFI_FILE_DELETED:
+ FileLength = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;
+ FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8);
+ FileOffset += FileOccupiedSize;
+ FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + FileOccupiedSize);
+ break;
+ default:
+ return EFI_NOT_FOUND;
}
}
@@ -215,10 +217,11 @@ Returns:
EFI_STATUS
SecFfsFindSectionData (
- IN EFI_SECTION_TYPE SectionType,
- IN EFI_FFS_FILE_HEADER *FfsFileHeader,
- IN OUT VOID **SectionData
+ IN EFI_SECTION_TYPE SectionType,
+ IN EFI_FFS_FILE_HEADER *FfsFileHeader,
+ IN OUT VOID **SectionData
)
+
/*++
Routine Description:
@@ -237,39 +240,39 @@ Returns:
**/
{
- UINT32 FileSize;
- EFI_COMMON_SECTION_HEADER *Section;
- UINT32 SectionLength;
- UINT32 ParsedLength;
+ UINT32 FileSize;
+ EFI_COMMON_SECTION_HEADER *Section;
+ UINT32 SectionLength;
+ UINT32 ParsedLength;
//
// Size is 24 bits wide so mask upper 8 bits.
// Does not include FfsFileHeader header size
// FileSize is adjusted to FileOccupiedSize as it is 8 byte aligned.
//
- Section = (EFI_COMMON_SECTION_HEADER *) (FfsFileHeader + 1);
- FileSize = *(UINT32 *) (FfsFileHeader->Size) & 0x00FFFFFF;
+ Section = (EFI_COMMON_SECTION_HEADER *)(FfsFileHeader + 1);
+ FileSize = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;
FileSize -= sizeof (EFI_FFS_FILE_HEADER);
- *SectionData = NULL;
- ParsedLength = 0;
+ *SectionData = NULL;
+ ParsedLength = 0;
while (ParsedLength < FileSize) {
if (Section->Type == SectionType) {
- *SectionData = (VOID *) (Section + 1);
+ *SectionData = (VOID *)(Section + 1);
return EFI_SUCCESS;
}
+
//
// Size is 24 bits wide so mask upper 8 bits.
// SectionLength is adjusted it is 4 byte aligned.
// Go to the next section
//
- SectionLength = *(UINT32 *) Section->Size & 0x00FFFFFF;
+ SectionLength = *(UINT32 *)Section->Size & 0x00FFFFFF;
SectionLength = GET_OCCUPIED_SIZE (SectionLength, 4);
ParsedLength += SectionLength;
- Section = (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) Section + SectionLength);
+ Section = (EFI_COMMON_SECTION_HEADER *)((UINT8 *)Section + SectionLength);
}
return EFI_NOT_FOUND;
}
-
diff --git a/EmulatorPkg/Library/SecPeiServicesLib/PeiServicesLib.c b/EmulatorPkg/Library/SecPeiServicesLib/PeiServicesLib.c
index c1d10d7f68..9409cbdb66 100644
--- a/EmulatorPkg/Library/SecPeiServicesLib/PeiServicesLib.c
+++ b/EmulatorPkg/Library/SecPeiServicesLib/PeiServicesLib.c
@@ -6,30 +6,26 @@
**/
-
#include <PiPei.h>
#include <Library/EmuMagicPageLib.h>
#include <Library/PeiServicesLib.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
-
-
EFI_STATUS
SecFfsFindNextFile (
- IN EFI_FV_FILETYPE SearchType,
- IN EFI_PEI_FV_HANDLE VolumeHandle,
- IN OUT EFI_PEI_FILE_HANDLE *FileHandle
+ IN EFI_FV_FILETYPE SearchType,
+ IN EFI_PEI_FV_HANDLE VolumeHandle,
+ IN OUT EFI_PEI_FILE_HANDLE *FileHandle
);
EFI_STATUS
SecFfsFindSectionData (
- IN EFI_SECTION_TYPE SectionType,
- IN EFI_PEI_FILE_HANDLE FileHandle,
- OUT VOID **SectionData
+ IN EFI_SECTION_TYPE SectionType,
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ OUT VOID **SectionData
);
-
/**
This service enables a given PEIM to register an interface into the PEI Foundation.
@@ -45,7 +41,7 @@ SecFfsFindSectionData (
EFI_STATUS
EFIAPI
PeiServicesInstallPpi (
- IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList
+ IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList
)
{
ASSERT (FALSE);
@@ -70,8 +66,8 @@ PeiServicesInstallPpi (
EFI_STATUS
EFIAPI
PeiServicesReInstallPpi (
- IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi,
- IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi
+ IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi,
+ IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi
)
{
ASSERT (FALSE);
@@ -97,26 +93,28 @@ PeiServicesReInstallPpi (
EFI_STATUS
EFIAPI
PeiServicesLocatePpi (
- IN CONST EFI_GUID *Guid,
- IN UINTN Instance,
- IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,
- IN OUT VOID **Ppi
+ IN CONST EFI_GUID *Guid,
+ IN UINTN Instance,
+ IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,
+ IN OUT VOID **Ppi
)
{
- EFI_PEI_PPI_DESCRIPTOR *PpiList;
+ EFI_PEI_PPI_DESCRIPTOR *PpiList;
if (Instance != 0) {
return EFI_NOT_FOUND;
}
- for (PpiList = EMU_MAGIC_PAGE()->PpiList; ; PpiList++) {
+ for (PpiList = EMU_MAGIC_PAGE ()->PpiList; ; PpiList++) {
if (CompareGuid (PpiList->Guid, Guid)) {
if (PpiDescriptor != NULL) {
*PpiDescriptor = PpiList;
}
+
if (Ppi != NULL) {
*Ppi = PpiList->Ppi;
}
+
return EFI_SUCCESS;
}
@@ -125,7 +123,6 @@ PeiServicesLocatePpi (
}
}
-
return EFI_NOT_FOUND;
}
@@ -166,7 +163,7 @@ PeiServicesNotifyPpi (
EFI_STATUS
EFIAPI
PeiServicesGetBootMode (
- OUT EFI_BOOT_MODE *BootMode
+ OUT EFI_BOOT_MODE *BootMode
)
{
ASSERT (FALSE);
@@ -184,7 +181,7 @@ PeiServicesGetBootMode (
EFI_STATUS
EFIAPI
PeiServicesSetBootMode (
- IN EFI_BOOT_MODE BootMode
+ IN EFI_BOOT_MODE BootMode
)
{
ASSERT (FALSE);
@@ -204,7 +201,7 @@ PeiServicesSetBootMode (
EFI_STATUS
EFIAPI
PeiServicesGetHobList (
- OUT VOID **HobList
+ OUT VOID **HobList
)
{
ASSERT (FALSE);
@@ -226,9 +223,9 @@ PeiServicesGetHobList (
EFI_STATUS
EFIAPI
PeiServicesCreateHob (
- IN UINT16 Type,
- IN UINT16 Length,
- OUT VOID **Hob
+ IN UINT16 Type,
+ IN UINT16 Length,
+ OUT VOID **Hob
)
{
ASSERT (FALSE);
@@ -251,8 +248,8 @@ PeiServicesCreateHob (
EFI_STATUS
EFIAPI
PeiServicesFfsFindNextVolume (
- IN UINTN Instance,
- IN OUT EFI_PEI_FV_HANDLE *VolumeHandle
+ IN UINTN Instance,
+ IN OUT EFI_PEI_FV_HANDLE *VolumeHandle
)
{
ASSERT (FALSE);
@@ -276,9 +273,9 @@ PeiServicesFfsFindNextVolume (
EFI_STATUS
EFIAPI
PeiServicesFfsFindNextFile (
- IN EFI_FV_FILETYPE SearchType,
- IN EFI_PEI_FV_HANDLE VolumeHandle,
- IN OUT EFI_PEI_FILE_HANDLE *FileHandle
+ IN EFI_FV_FILETYPE SearchType,
+ IN EFI_PEI_FV_HANDLE VolumeHandle,
+ IN OUT EFI_PEI_FILE_HANDLE *FileHandle
)
{
return SecFfsFindNextFile (SearchType, VolumeHandle, FileHandle);
@@ -299,9 +296,9 @@ PeiServicesFfsFindNextFile (
EFI_STATUS
EFIAPI
PeiServicesFfsFindSectionData (
- IN EFI_SECTION_TYPE SectionType,
- IN EFI_PEI_FILE_HANDLE FileHandle,
- OUT VOID **SectionData
+ IN EFI_SECTION_TYPE SectionType,
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ OUT VOID **SectionData
)
{
return SecFfsFindSectionData (SectionType, FileHandle, SectionData);
@@ -322,8 +319,8 @@ PeiServicesFfsFindSectionData (
EFI_STATUS
EFIAPI
PeiServicesInstallPeiMemory (
- IN EFI_PHYSICAL_ADDRESS MemoryBegin,
- IN UINT64 MemoryLength
+ IN EFI_PHYSICAL_ADDRESS MemoryBegin,
+ IN UINT64 MemoryLength
)
{
ASSERT (FALSE);
@@ -347,9 +344,9 @@ PeiServicesInstallPeiMemory (
EFI_STATUS
EFIAPI
PeiServicesAllocatePages (
- IN EFI_MEMORY_TYPE MemoryType,
- IN UINTN Pages,
- OUT EFI_PHYSICAL_ADDRESS *Memory
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN Pages,
+ OUT EFI_PHYSICAL_ADDRESS *Memory
)
{
ASSERT (FALSE);
@@ -370,8 +367,8 @@ PeiServicesAllocatePages (
EFI_STATUS
EFIAPI
PeiServicesAllocatePool (
- IN UINTN Size,
- OUT VOID **Buffer
+ IN UINTN Size,
+ OUT VOID **Buffer
)
{
ASSERT (FALSE);
@@ -415,7 +412,7 @@ PeiServicesResetSystem (
EFI_STATUS
EFIAPI
PeiServicesRegisterForShadow (
- IN EFI_PEI_FILE_HANDLE FileHandle
+ IN EFI_PEI_FILE_HANDLE FileHandle
)
{
ASSERT (FALSE);
@@ -443,15 +440,14 @@ PeiServicesRegisterForShadow (
EFI_STATUS
EFIAPI
PeiServicesFfsGetFileInfo (
- IN CONST EFI_PEI_FILE_HANDLE FileHandle,
- OUT EFI_FV_FILE_INFO *FileInfo
+ IN CONST EFI_PEI_FILE_HANDLE FileHandle,
+ OUT EFI_FV_FILE_INFO *FileInfo
)
{
ASSERT (FALSE);
return EFI_OUT_OF_RESOURCES;
}
-
/**
This service is a wrapper for the PEI Service FfsFindByName(), except the pointer to the PEI Services
Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
@@ -476,16 +472,15 @@ PeiServicesFfsGetFileInfo (
EFI_STATUS
EFIAPI
PeiServicesFfsFindFileByName (
- IN CONST EFI_GUID *FileName,
- IN CONST EFI_PEI_FV_HANDLE VolumeHandle,
- OUT EFI_PEI_FILE_HANDLE *FileHandle
+ IN CONST EFI_GUID *FileName,
+ IN CONST EFI_PEI_FV_HANDLE VolumeHandle,
+ OUT EFI_PEI_FILE_HANDLE *FileHandle
)
{
ASSERT (FALSE);
return EFI_OUT_OF_RESOURCES;
}
-
/**
This service is a wrapper for the PEI Service FfsGetVolumeInfo(), except the pointer to the PEI Services
Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
@@ -507,8 +502,8 @@ PeiServicesFfsFindFileByName (
EFI_STATUS
EFIAPI
PeiServicesFfsGetVolumeInfo (
- IN EFI_PEI_FV_HANDLE VolumeHandle,
- OUT EFI_FV_INFO *VolumeInfo
+ IN EFI_PEI_FV_HANDLE VolumeHandle,
+ OUT EFI_FV_INFO *VolumeInfo
)
{
ASSERT (FALSE);
@@ -548,11 +543,11 @@ PeiServicesFfsGetVolumeInfo (
VOID
EFIAPI
PeiServicesInstallFvInfoPpi (
- IN CONST EFI_GUID *FvFormat OPTIONAL,
- IN CONST VOID *FvInfo,
- IN UINT32 FvInfoSize,
- IN CONST EFI_GUID *ParentFvName OPTIONAL,
- IN CONST EFI_GUID *ParentFileName OPTIONAL
+ IN CONST EFI_GUID *FvFormat OPTIONAL,
+ IN CONST VOID *FvInfo,
+ IN UINT32 FvInfoSize,
+ IN CONST EFI_GUID *ParentFvName OPTIONAL,
+ IN CONST EFI_GUID *ParentFileName OPTIONAL
)
{
ASSERT (FALSE);
diff --git a/EmulatorPkg/Library/SecPpiListLib/PpiListLib.c b/EmulatorPkg/Library/SecPpiListLib/PpiListLib.c
index 0ead1a6296..452b1ea37b 100644
--- a/EmulatorPkg/Library/SecPpiListLib/PpiListLib.c
+++ b/EmulatorPkg/Library/SecPpiListLib/PpiListLib.c
@@ -8,4 +8,3 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <PiPei.h>
CONST EFI_PEI_PPI_DESCRIPTOR *gPpiList = NULL;
-
diff --git a/EmulatorPkg/Library/SmbiosLib/SmbiosLib.c b/EmulatorPkg/Library/SmbiosLib/SmbiosLib.c
index 3acbb23644..c76d115d38 100644
--- a/EmulatorPkg/Library/SmbiosLib/SmbiosLib.c
+++ b/EmulatorPkg/Library/SmbiosLib/SmbiosLib.c
@@ -18,9 +18,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/UefiLib.h>
#include <Library/SmbiosLib.h>
-
-EFI_SMBIOS_PROTOCOL *gSmbios = NULL;
-
+EFI_SMBIOS_PROTOCOL *gSmbios = NULL;
/**
Create an initial SMBIOS Table from an array of SMBIOS_TEMPLATE_ENTRY
@@ -34,11 +32,11 @@ EFI_SMBIOS_PROTOCOL *gSmbios = NULL;
EFI_STATUS
EFIAPI
SmbiosLibInitializeFromTemplate (
- IN SMBIOS_TEMPLATE_ENTRY *Template
+ IN SMBIOS_TEMPLATE_ENTRY *Template
)
{
- EFI_STATUS Status;
- UINTN Index;
+ EFI_STATUS Status;
+ UINTN Index;
if (Template == NULL) {
return EFI_INVALID_PARAMETER;
@@ -53,8 +51,6 @@ SmbiosLibInitializeFromTemplate (
return Status;
}
-
-
/**
Create SMBIOS record.
@@ -85,17 +81,17 @@ SmbiosLibInitializeFromTemplate (
EFI_STATUS
EFIAPI
SmbiosLibCreateEntry (
- IN SMBIOS_STRUCTURE *SmbiosEntry,
- IN CHAR8 **StringArray
+ IN SMBIOS_STRUCTURE *SmbiosEntry,
+ IN CHAR8 **StringArray
)
{
- EFI_STATUS Status;
- EFI_SMBIOS_HANDLE SmbiosHandle;
- EFI_SMBIOS_TABLE_HEADER *Record;
- UINTN Index;
- UINTN StringSize;
- UINTN Size;
- CHAR8 *Str;
+ EFI_STATUS Status;
+ EFI_SMBIOS_HANDLE SmbiosHandle;
+ EFI_SMBIOS_TABLE_HEADER *Record;
+ UINTN Index;
+ UINTN StringSize;
+ UINTN Size;
+ CHAR8 *Str;
// Calculate the size of the fixed record and optional string pack
Size = SmbiosEntry->Length;
@@ -106,8 +102,9 @@ SmbiosLibCreateEntry (
} else {
for (Index = 0; StringArray[Index] != NULL; Index++) {
StringSize = AsciiStrSize (StringArray[Index]);
- Size += StringSize;
+ Size += StringSize;
}
+
// Don't forget the terminating double null
Size += 1;
}
@@ -117,6 +114,7 @@ SmbiosLibCreateEntry (
if (Record == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
CopyMem (Record, SmbiosEntry, SmbiosEntry->Length);
if (StringArray != NULL) {
@@ -127,23 +125,22 @@ SmbiosLibCreateEntry (
CopyMem (Str, StringArray[Index], StringSize);
Str += StringSize;
}
+
*Str = 0;
}
SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
- Status = gSmbios->Add (
- gSmbios,
- gImageHandle,
- &SmbiosHandle,
- Record
- );
+ Status = gSmbios->Add (
+ gSmbios,
+ gImageHandle,
+ &SmbiosHandle,
+ Record
+ );
FreePool (Record);
return Status;
}
-
-
/**
Update the string associated with an existing SMBIOS record.
@@ -162,12 +159,12 @@ SmbiosLibCreateEntry (
EFI_STATUS
EFIAPI
SmbiosLibUpdateString (
- IN EFI_SMBIOS_HANDLE SmbiosHandle,
- IN SMBIOS_TABLE_STRING StringNumber,
- IN CHAR8 *String
+ IN EFI_SMBIOS_HANDLE SmbiosHandle,
+ IN SMBIOS_TABLE_STRING StringNumber,
+ IN CHAR8 *String
)
{
- UINTN StringIndex;
+ UINTN StringIndex;
if (String == NULL) {
return EFI_INVALID_PARAMETER;
@@ -182,7 +179,6 @@ SmbiosLibUpdateString (
return gSmbios->UpdateString (gSmbios, &SmbiosHandle, &StringIndex, String);
}
-
/**
Update the string associated with an existing SMBIOS record.
@@ -201,9 +197,9 @@ SmbiosLibUpdateString (
EFI_STATUS
EFIAPI
SmbiosLibUpdateUnicodeString (
- IN EFI_SMBIOS_HANDLE SmbiosHandle,
- IN SMBIOS_TABLE_STRING StringNumber,
- IN CHAR16 *String
+ IN EFI_SMBIOS_HANDLE SmbiosHandle,
+ IN SMBIOS_TABLE_STRING StringNumber,
+ IN CHAR16 *String
)
{
EFI_STATUS Status;
@@ -223,16 +219,16 @@ SmbiosLibUpdateUnicodeString (
if (Ascii == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
UnicodeStrToAsciiStrS (String, Ascii, StrSize (String));
StringIndex = StringNumber;
- Status = gSmbios->UpdateString (gSmbios, &SmbiosHandle, &StringIndex, Ascii);
+ Status = gSmbios->UpdateString (gSmbios, &SmbiosHandle, &StringIndex, Ascii);
FreePool (Ascii);
return Status;
}
-
/**
Allow caller to read a specific SMBIOS string
@@ -249,14 +245,15 @@ SmbiosLibReadString (
IN EFI_SMBIOS_STRING StringNumber
)
{
- CHAR8 *Data;
- UINTN Match;
+ CHAR8 *Data;
+ UINTN Match;
Data = (CHAR8 *)Header + Header->Length;
- for (Match = 1;!(*Data == 0 && *(Data+1) == 0); ) {
+ for (Match = 1; !(*Data == 0 && *(Data+1) == 0); ) {
if (StringNumber == Match) {
return Data;
}
+
Data++;
if (*(Data - 1) == '\0') {
Match++;
@@ -266,7 +263,6 @@ SmbiosLibReadString (
return NULL;
}
-
/**
Allow the caller to discover a specific SMBIOS entry, and patch it if necissary.
@@ -280,14 +276,14 @@ SmbiosLibReadString (
SMBIOS_STRUCTURE *
EFIAPI
SmbiosLibGetRecord (
- IN EFI_SMBIOS_TYPE Type,
- IN UINTN Instance,
- OUT EFI_SMBIOS_HANDLE *SmbiosHandle
+ IN EFI_SMBIOS_TYPE Type,
+ IN UINTN Instance,
+ OUT EFI_SMBIOS_HANDLE *SmbiosHandle
)
{
- EFI_STATUS Status;
- EFI_SMBIOS_TABLE_HEADER *Record;
- UINTN Match;
+ EFI_STATUS Status;
+ EFI_SMBIOS_TABLE_HEADER *Record;
+ UINTN Match;
Match = 0;
*SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
@@ -297,6 +293,7 @@ SmbiosLibGetRecord (
if (Match == Instance) {
return (SMBIOS_STRUCTURE *)Record;
}
+
Match++;
}
} while (!EFI_ERROR (Status));
@@ -304,7 +301,6 @@ SmbiosLibGetRecord (
return NULL;
}
-
/**
Remove an SMBIOS record.
@@ -318,14 +314,12 @@ SmbiosLibGetRecord (
EFI_STATUS
EFIAPI
SmbiosLibRemove (
- OUT EFI_SMBIOS_HANDLE SmbiosHandle
+ OUT EFI_SMBIOS_HANDLE SmbiosHandle
)
{
return gSmbios->Remove (gSmbios, SmbiosHandle);
}
-
-
/**
@param ImageHandle ImageHandle of the loaded driver.
@@ -343,4 +337,3 @@ SmbiosLibConstructor (
{
return gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&gSmbios);
}
-
diff --git a/EmulatorPkg/Library/ThunkPpiList/ThunkPpiList.c b/EmulatorPkg/Library/ThunkPpiList/ThunkPpiList.c
index 59ed6cca2e..ab34ec7ed9 100644
--- a/EmulatorPkg/Library/ThunkPpiList/ThunkPpiList.c
+++ b/EmulatorPkg/Library/ThunkPpiList/ThunkPpiList.c
@@ -12,30 +12,26 @@
#include <Library/BaseLib.h>
#include <Library/MemoryAllocationLib.h>
-
UINTN gThunkPpiListSize = 0;
-EFI_PEI_PPI_DESCRIPTOR *gThunkPpiList = NULL;
-
-
+EFI_PEI_PPI_DESCRIPTOR *gThunkPpiList = NULL;
EFI_PEI_PPI_DESCRIPTOR *
GetThunkPpiList (
VOID
)
{
- UINTN Index;
+ UINTN Index;
if (gThunkPpiList == NULL) {
return NULL;
}
- Index = (gThunkPpiListSize/sizeof (EFI_PEI_PPI_DESCRIPTOR)) - 1;
+ Index = (gThunkPpiListSize/sizeof (EFI_PEI_PPI_DESCRIPTOR)) - 1;
gThunkPpiList[Index].Flags |= EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;
return gThunkPpiList;
}
-
EFI_STATUS
EFIAPI
AddThunkPpi (
@@ -44,7 +40,7 @@ AddThunkPpi (
IN VOID *Ppi
)
{
- UINTN Index;
+ UINTN Index;
gThunkPpiList = ReallocatePool (
gThunkPpiListSize,
@@ -55,16 +51,11 @@ AddThunkPpi (
return EFI_OUT_OF_RESOURCES;
}
- Index = (gThunkPpiListSize/sizeof (EFI_PEI_PPI_DESCRIPTOR));
+ Index = (gThunkPpiListSize/sizeof (EFI_PEI_PPI_DESCRIPTOR));
gThunkPpiList[Index].Flags = Flags;
gThunkPpiList[Index].Guid = Guid;
gThunkPpiList[Index].Ppi = Ppi;
- gThunkPpiListSize += sizeof (EFI_PEI_PPI_DESCRIPTOR);
+ gThunkPpiListSize += sizeof (EFI_PEI_PPI_DESCRIPTOR);
return EFI_SUCCESS;
}
-
-
-
-
-
diff --git a/EmulatorPkg/Library/ThunkProtocolList/ThunkProtocolList.c b/EmulatorPkg/Library/ThunkProtocolList/ThunkProtocolList.c
index 3a7b6d1ceb..09b22a5247 100644
--- a/EmulatorPkg/Library/ThunkProtocolList/ThunkProtocolList.c
+++ b/EmulatorPkg/Library/ThunkProtocolList/ThunkProtocolList.c
@@ -16,25 +16,23 @@
#include <Protocol/EmuIoThunk.h>
-
-#define EMU_IO_THUNK_PROTOCOL_DATA_SIGNATURE SIGNATURE_32('E','m','u','T')
+#define EMU_IO_THUNK_PROTOCOL_DATA_SIGNATURE SIGNATURE_32('E','m','u','T')
typedef struct {
- UINTN Signature;
- EMU_IO_THUNK_PROTOCOL Data;
- BOOLEAN EmuBusDriver;
- LIST_ENTRY Link;
+ UINTN Signature;
+ EMU_IO_THUNK_PROTOCOL Data;
+ BOOLEAN EmuBusDriver;
+ LIST_ENTRY Link;
} EMU_IO_THUNK_PROTOCOL_DATA;
LIST_ENTRY mThunkList = INITIALIZE_LIST_HEAD_VARIABLE (mThunkList);
-
EFI_STATUS
EFIAPI
AddThunkProtocol (
- IN EMU_IO_THUNK_PROTOCOL *ThunkIo,
- IN CHAR16 *ConfigString,
- IN BOOLEAN EmuBusDriver
+ IN EMU_IO_THUNK_PROTOCOL *ThunkIo,
+ IN CHAR16 *ConfigString,
+ IN BOOLEAN EmuBusDriver
)
{
UINTN Size;
@@ -47,15 +45,15 @@ AddThunkProtocol (
return EFI_INVALID_PARAMETER;
}
- Instance = 0;
- Size = StrSize (ConfigString);
+ Instance = 0;
+ Size = StrSize (ConfigString);
StartString = AllocatePool (Size);
if (StartString == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
StrCpyS (StartString, Size / sizeof (CHAR16), ConfigString);
while (*StartString != '\0') {
-
//
// Find the end of the sub string
//
@@ -77,12 +75,13 @@ AddThunkProtocol (
if (Private == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- Private->Signature = EMU_IO_THUNK_PROTOCOL_DATA_SIGNATURE;
- Private->EmuBusDriver = EmuBusDriver;
+
+ Private->Signature = EMU_IO_THUNK_PROTOCOL_DATA_SIGNATURE;
+ Private->EmuBusDriver = EmuBusDriver;
CopyMem (&Private->Data, ThunkIo, sizeof (EMU_IO_THUNK_PROTOCOL));
- Private->Data.Instance = (UINT16)Instance++;
- Private->Data.ConfigString = StartString;
+ Private->Data.Instance = (UINT16)Instance++;
+ Private->Data.ConfigString = StartString;
InsertTailList (&mThunkList, &Private->Link);
@@ -95,16 +94,15 @@ AddThunkProtocol (
return EFI_SUCCESS;
}
-
EFI_STATUS
EFIAPI
GetNextThunkProtocol (
- IN BOOLEAN EmuBusDriver,
- OUT EMU_IO_THUNK_PROTOCOL **Instance OPTIONAL
+ IN BOOLEAN EmuBusDriver,
+ OUT EMU_IO_THUNK_PROTOCOL **Instance OPTIONAL
)
{
- LIST_ENTRY *Link;
- EMU_IO_THUNK_PROTOCOL_DATA *Private;
+ LIST_ENTRY *Link;
+ EMU_IO_THUNK_PROTOCOL_DATA *Private;
if (mThunkList.ForwardLink == &mThunkList) {
// Skip parsing an empty list
@@ -125,13 +123,12 @@ GetNextThunkProtocol (
if (Link == &mThunkList) {
return EFI_NOT_FOUND;
}
- Private = CR (Link, EMU_IO_THUNK_PROTOCOL_DATA, Link, EMU_IO_THUNK_PROTOCOL_DATA_SIGNATURE);
+
+ Private = CR (Link, EMU_IO_THUNK_PROTOCOL_DATA, Link, EMU_IO_THUNK_PROTOCOL_DATA_SIGNATURE);
*Instance = &Private->Data;
return EFI_SUCCESS;
}
}
-
return EFI_NOT_FOUND;
}
-
diff --git a/EmulatorPkg/PlatformSmbiosDxe/PlatformSmbiosDxe.c b/EmulatorPkg/PlatformSmbiosDxe/PlatformSmbiosDxe.c
index 48a3bfb5e9..7100abeb91 100644
--- a/EmulatorPkg/PlatformSmbiosDxe/PlatformSmbiosDxe.c
+++ b/EmulatorPkg/PlatformSmbiosDxe/PlatformSmbiosDxe.c
@@ -17,11 +17,9 @@
#include <Library/SmbiosLib.h>
#include <Library/HobLib.h>
-extern SMBIOS_TEMPLATE_ENTRY gSmbiosTemplate[];
+extern SMBIOS_TEMPLATE_ENTRY gSmbiosTemplate[];
-
-
-SMBIOS_TABLE_TYPE19 gSmbiosType19Template = {
+SMBIOS_TABLE_TYPE19 gSmbiosType19Template = {
{ EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS, sizeof (SMBIOS_TABLE_TYPE19), 0 },
0xffffffff, // StartingAddress;
0xffffffff, // EndingAddress;
@@ -36,11 +34,11 @@ CreatePlatformSmbiosMemoryRecords (
VOID
)
{
- EFI_PEI_HOB_POINTERS HobPtr;
- SMBIOS_STRUCTURE_POINTER Smbios16;
- SMBIOS_STRUCTURE_POINTER Smbios17;
- EFI_SMBIOS_HANDLE PhyscialMemoryArrayHandle;
- EFI_SMBIOS_HANDLE SmbiosHandle;
+ EFI_PEI_HOB_POINTERS HobPtr;
+ SMBIOS_STRUCTURE_POINTER Smbios16;
+ SMBIOS_STRUCTURE_POINTER Smbios17;
+ EFI_SMBIOS_HANDLE PhyscialMemoryArrayHandle;
+ EFI_SMBIOS_HANDLE SmbiosHandle;
Smbios16.Hdr = SmbiosLibGetRecord (EFI_SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY, 0, &PhyscialMemoryArrayHandle);
if (Smbios16.Hdr == NULL) {
@@ -56,21 +54,21 @@ CreatePlatformSmbiosMemoryRecords (
// Generate Type16 records
gSmbiosType19Template.MemoryArrayHandle = PhyscialMemoryArrayHandle;
- HobPtr.Raw = GetHobList ();
+ HobPtr.Raw = GetHobList ();
while ((HobPtr.Raw = GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, HobPtr.Raw)) != NULL) {
if (HobPtr.ResourceDescriptor->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY) {
gSmbiosType19Template.ExtendedStartingAddress = HobPtr.ResourceDescriptor->PhysicalStart;
- gSmbiosType19Template.ExtendedEndingAddress =
+ gSmbiosType19Template.ExtendedEndingAddress =
HobPtr.ResourceDescriptor->PhysicalStart +
HobPtr.ResourceDescriptor->ResourceLength - 1;
SmbiosLibCreateEntry ((SMBIOS_STRUCTURE *)&gSmbiosType19Template, NULL);
}
+
HobPtr.Raw = GET_NEXT_HOB (HobPtr);
}
}
-
/**
Main entry for this driver.
@@ -83,13 +81,13 @@ CreatePlatformSmbiosMemoryRecords (
EFI_STATUS
EFIAPI
PlatformSmbiosDriverEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
- EFI_SMBIOS_HANDLE SmbiosHandle;
- SMBIOS_STRUCTURE_POINTER Smbios;
+ EFI_STATUS Status;
+ EFI_SMBIOS_HANDLE SmbiosHandle;
+ SMBIOS_STRUCTURE_POINTER Smbios;
// Phase 0 - Patch table to make SMBIOS 2.7 structures smaller to conform
// to an early version of the specification.
@@ -108,12 +106,12 @@ PlatformSmbiosDriverEntryPoint (
SmbiosLibUpdateUnicodeString (
SmbiosHandle,
Smbios.Type0->BiosVersion,
- (CHAR16 *) PcdGetPtr (PcdFirmwareVersionString)
+ (CHAR16 *)PcdGetPtr (PcdFirmwareVersionString)
);
SmbiosLibUpdateUnicodeString (
SmbiosHandle,
Smbios.Type0->BiosReleaseDate,
- (CHAR16 *) PcdGetPtr (PcdFirmwareReleaseDateString)
+ (CHAR16 *)PcdGetPtr (PcdFirmwareReleaseDateString)
);
}
diff --git a/EmulatorPkg/PlatformSmbiosDxe/SmbiosTable.c b/EmulatorPkg/PlatformSmbiosDxe/SmbiosTable.c
index 11c8e94504..0d88b59322 100644
--- a/EmulatorPkg/PlatformSmbiosDxe/SmbiosTable.c
+++ b/EmulatorPkg/PlatformSmbiosDxe/SmbiosTable.c
@@ -23,15 +23,14 @@
#include <Protocol/Smbios.h>
#include <Library/SmbiosLib.h>
-
-SMBIOS_TABLE_TYPE0 gSmbiosType0Template = {
+SMBIOS_TABLE_TYPE0 gSmbiosType0Template = {
{ EFI_SMBIOS_TYPE_BIOS_INFORMATION, sizeof (SMBIOS_TABLE_TYPE0), 0 },
1, // Vendor String
2, // BiosVersion String
0xE000, // BiosSegment
3, // BiosReleaseDate String
0x7F, // BiosSize
- { // BiosCharacteristics
+ { // BiosCharacteristics
0, // Reserved :2; ///< Bits 0-1.
0, // Unknown :1;
0, // BiosCharacteristicsNotSupported :1;
@@ -64,7 +63,7 @@ SMBIOS_TABLE_TYPE0 gSmbiosType0Template = {
0, // CgaMonoIsSupported :1;
0, // NecPc98 :1;
0 // ReservedForVendor :32; ///< Bits 32-63. Bits 32-47 reserved for BIOS vendor
- ///< and bits 48-63 reserved for System Vendor.
+ ///< and bits 48-63 reserved for System Vendor.
},
{ // BIOSCharacteristicsExtensionBytes[]
0x81, // AcpiIsSupported :1;
@@ -75,7 +74,7 @@ SMBIOS_TABLE_TYPE0 gSmbiosType0Template = {
// AtapiZipDriveBootIsSupported :1;
// Boot1394IsSupported :1;
// SmartBatteryIsSupported :1;
- // BIOSCharacteristicsExtensionBytes[1]
+ // BIOSCharacteristicsExtensionBytes[1]
0x0a, // BiosBootSpecIsSupported :1;
// FunctionKeyNetworkBootIsSupported :1;
// TargetContentDistributionEnabled :1;
@@ -88,25 +87,26 @@ SMBIOS_TABLE_TYPE0 gSmbiosType0Template = {
0xFF, // EmbeddedControllerFirmwareMajorRelease
0xFF, // EmbeddedControllerFirmwareMinorRelease
};
-CHAR8 *gSmbiosType0Strings[] = {
- "http://www.tianocore.org/edk2/", // Vendor String
- __TIME__, // BiosVersion String
- __DATE__, // BiosReleaseDate String
+CHAR8 *gSmbiosType0Strings[] = {
+ "http://www.tianocore.org/edk2/", // Vendor String
+ __TIME__, // BiosVersion String
+ __DATE__, // BiosReleaseDate String
NULL
};
-SMBIOS_TABLE_TYPE1 gSmbiosType1Template = {
- { EFI_SMBIOS_TYPE_SYSTEM_INFORMATION, sizeof (SMBIOS_TABLE_TYPE1), 0 },
+SMBIOS_TABLE_TYPE1 gSmbiosType1Template = {
+ { EFI_SMBIOS_TYPE_SYSTEM_INFORMATION, sizeof (SMBIOS_TABLE_TYPE1), 0 },
1, // Manufacturer String
2, // ProductName String
3, // Version String
4, // SerialNumber String
- { 0x25EF0280, 0xEC82, 0x42B0, { 0x8F, 0xB6, 0x10, 0xAD, 0xCC, 0xC6, 0x7C, 0x02 } },
+ { 0x25EF0280, 0xEC82, 0x42B0, { 0x8F, 0xB6, 0x10, 0xAD, 0xCC, 0xC6, 0x7C, 0x02}
+ },
SystemWakeupTypePowerSwitch,
5, // SKUNumber String
6, // Family String
};
-CHAR8 *gSmbiosType1Strings[] = {
+CHAR8 *gSmbiosType1Strings[] = {
"http://www.tianocore.org/edk2/",
"EmulatorPkg",
"1.0",
@@ -124,20 +124,20 @@ SMBIOS_TABLE_TYPE2 gSmbiosType2Template = {
4, // SerialNumber String
5, // AssetTag String
{ // FeatureFlag
- 1, // Motherboard :1;
- 0, // RequiresDaughterCard :1;
- 0, // Removable :1;
- 0, // Replaceable :1;
- 0, // HotSwappable :1;
- 0, // Reserved :3;
+ 1, // Motherboard :1;
+ 0, // RequiresDaughterCard :1;
+ 0, // Removable :1;
+ 0, // Replaceable :1;
+ 0, // HotSwappable :1;
+ 0, // Reserved :3;
},
- 6, // LocationInChassis String
+ 6, // LocationInChassis String
0, // ChassisHandle;
BaseBoardTypeMotherBoard, // BoardType;
0, // NumberOfContainedObjectHandles;
{ 0 } // ContainedObjectHandles[1];
};
-CHAR8 *gSmbiosType2Strings[] = {
+CHAR8 *gSmbiosType2Strings[] = {
"http://www.tianocore.org/edk2/",
"EmulatorPkg",
"1.0",
@@ -149,23 +149,25 @@ CHAR8 *gSmbiosType2Strings[] = {
SMBIOS_TABLE_TYPE3 gSmbiosType3Template = {
{ EFI_SMBIOS_TYPE_SYSTEM_ENCLOSURE, sizeof (SMBIOS_TABLE_TYPE3), 0 },
- 1, // Manufacturer String
- MiscChassisTypeLapTop, // Type;
- 2, // Version String
- 3, // SerialNumber String
- 4, // AssetTag String
- ChassisStateSafe, // BootupState;
- ChassisStateSafe, // PowerSupplyState;
- ChassisStateSafe, // ThermalState;
- ChassisSecurityStatusNone,// SecurityStatus;
- { 0, 0, 0, 0 }, // OemDefined[4];
- 0, // Height;
- 0, // NumberofPowerCords;
- 0, // ContainedElementCount;
- 0, // ContainedElementRecordLength;
- { { 0 } }, // ContainedElements[1];
-};
-CHAR8 *gSmbiosType3Strings[] = {
+ 1, // Manufacturer String
+ MiscChassisTypeLapTop, // Type;
+ 2, // Version String
+ 3, // SerialNumber String
+ 4, // AssetTag String
+ ChassisStateSafe, // BootupState;
+ ChassisStateSafe, // PowerSupplyState;
+ ChassisStateSafe, // ThermalState;
+ ChassisSecurityStatusNone, // SecurityStatus;
+ { 0, 0, 0, 0}, // OemDefined[4];
+ 0, // Height;
+ 0, // NumberofPowerCords;
+ 0, // ContainedElementCount;
+ 0, // ContainedElementRecordLength;
+ {
+ { 0 }
+ }, // ContainedElements[1];
+};
+CHAR8 *gSmbiosType3Strings[] = {
"http://www.tianocore.org/edk2/",
"EmulatorPkg",
"Chassis Board Serial#",
@@ -181,7 +183,7 @@ SMBIOS_TABLE_TYPE8 gSmbiosType8Template1 = {
PortConnectorTypeNone, // ExternalConnectorType; ///< The enumeration value from MISC_PORT_CONNECTOR_TYPE.
PortTypeOther, // PortType; ///< The enumeration value from MISC_PORT_TYPE.
};
-CHAR8 *gSmbiosType8Strings1[] = {
+CHAR8 *gSmbiosType8Strings1[] = {
"Mini DisplayPort",
NULL
};
@@ -194,12 +196,11 @@ SMBIOS_TABLE_TYPE8 gSmbiosType8Template2 = {
PortConnectorTypeNone, // ExternalConnectorType; ///< The enumeration value from MISC_PORT_CONNECTOR_TYPE.
PortTypeFireWire, // PortType; ///< The enumeration value from MISC_PORT_TYPE.
};
-CHAR8 *gSmbiosType8Strings2[] = {
+CHAR8 *gSmbiosType8Strings2[] = {
"FireWire 800",
NULL
};
-
SMBIOS_TABLE_TYPE8 gSmbiosType8Template3 = {
{ EFI_SMBIOS_TYPE_PORT_CONNECTOR_INFORMATION, sizeof (SMBIOS_TABLE_TYPE8), 0 },
0, // InternalReferenceDesignator String
@@ -208,7 +209,7 @@ SMBIOS_TABLE_TYPE8 gSmbiosType8Template3 = {
PortConnectorTypeRJ45, // ExternalConnectorType; ///< The enumeration value from MISC_PORT_CONNECTOR_TYPE.
PortTypeNetworkPort, // PortType; ///< The enumeration value from MISC_PORT_TYPE.
};
-CHAR8 *gSmbiosType8Strings3[] = {
+CHAR8 *gSmbiosType8Strings3[] = {
"Ethernet",
NULL
};
@@ -221,7 +222,7 @@ SMBIOS_TABLE_TYPE8 gSmbiosType8Template4 = {
PortConnectorTypeUsb, // ExternalConnectorType; ///< The enumeration value from MISC_PORT_CONNECTOR_TYPE.
PortTypeUsb, // PortType; ///< The enumeration value from MISC_PORT_TYPE.
};
-CHAR8 *gSmbiosType8Strings4[] = {
+CHAR8 *gSmbiosType8Strings4[] = {
"USB0",
NULL
};
@@ -234,7 +235,7 @@ SMBIOS_TABLE_TYPE8 gSmbiosType8Template5 = {
PortConnectorTypeUsb, // ExternalConnectorType; ///< The enumeration value from MISC_PORT_CONNECTOR_TYPE.
PortTypeUsb, // PortType; ///< The enumeration value from MISC_PORT_TYPE.
};
-CHAR8 *gSmbiosType8Strings5[] = {
+CHAR8 *gSmbiosType8Strings5[] = {
"USB1",
NULL
};
@@ -247,7 +248,7 @@ SMBIOS_TABLE_TYPE8 gSmbiosType8Template6 = {
PortConnectorTypeUsb, // ExternalConnectorType; ///< The enumeration value from MISC_PORT_CONNECTOR_TYPE.
PortTypeUsb, // PortType; ///< The enumeration value from MISC_PORT_TYPE.
};
-CHAR8 *gSmbiosType8Strings6[] = {
+CHAR8 *gSmbiosType8Strings6[] = {
"USB2",
NULL
};
@@ -260,54 +261,54 @@ SMBIOS_TABLE_TYPE8 gSmbiosType8Template7 = {
PortConnectorTypeUsb, // ExternalConnectorType; ///< The enumeration value from MISC_PORT_CONNECTOR_TYPE.
PortTypeUsb, // PortType; ///< The enumeration value from MISC_PORT_TYPE.
};
-CHAR8 *gSmbiosType8Strings7[] = {
+CHAR8 *gSmbiosType8Strings7[] = {
"USB3",
NULL
};
SMBIOS_TABLE_TYPE8 gSmbiosType8Template8 = {
{ EFI_SMBIOS_TYPE_PORT_CONNECTOR_INFORMATION, sizeof (SMBIOS_TABLE_TYPE8), 0 },
- 0, // InternalReferenceDesignator String
- PortConnectorTypeNone, // InternalConnectorType; ///< The enumeration value from MISC_PORT_CONNECTOR_TYPE.
- 1, // ExternalReferenceDesignator String
+ 0, // InternalReferenceDesignator String
+ PortConnectorTypeNone, // InternalConnectorType; ///< The enumeration value from MISC_PORT_CONNECTOR_TYPE.
+ 1, // ExternalReferenceDesignator String
PortConnectorTypeHeadPhoneMiniJack, // ExternalConnectorType; ///< The enumeration value from MISC_PORT_CONNECTOR_TYPE.
PortTypeAudioPort, // PortType; ///< The enumeration value from MISC_PORT_TYPE.
};
-CHAR8 *gSmbiosType8Strings8[] = {
+CHAR8 *gSmbiosType8Strings8[] = {
"Audio Line In",
NULL
};
SMBIOS_TABLE_TYPE8 gSmbiosType8Template9 = {
{ EFI_SMBIOS_TYPE_PORT_CONNECTOR_INFORMATION, sizeof (SMBIOS_TABLE_TYPE8), 0 },
- 0, // InternalReferenceDesignator String
- PortConnectorTypeNone, // InternalConnectorType; ///< The enumeration value from MISC_PORT_CONNECTOR_TYPE.
- 1, // ExternalReferenceDesignator String
+ 0, // InternalReferenceDesignator String
+ PortConnectorTypeNone, // InternalConnectorType; ///< The enumeration value from MISC_PORT_CONNECTOR_TYPE.
+ 1, // ExternalReferenceDesignator String
PortConnectorTypeHeadPhoneMiniJack, // ExternalConnectorType; ///< The enumeration value from MISC_PORT_CONNECTOR_TYPE.
PortTypeAudioPort, // PortType; ///< The enumeration value from MISC_PORT_TYPE.
};
-CHAR8 *gSmbiosType8Strings9[] = {
+CHAR8 *gSmbiosType8Strings9[] = {
"Audio Line Out",
NULL
};
SMBIOS_TABLE_TYPE9 gSmbiosType9Template = {
{ EFI_SMBIOS_TYPE_SYSTEM_SLOTS, sizeof (SMBIOS_TABLE_TYPE9), 0 },
- 1, // SlotDesignation String
- SlotTypeOther, // SlotType; ///< The enumeration value from MISC_SLOT_TYPE.
- SlotDataBusWidthOther, // SlotDataBusWidth; ///< The enumeration value from MISC_SLOT_DATA_BUS_WIDTH.
+ 1, // SlotDesignation String
+ SlotTypeOther, // SlotType; ///< The enumeration value from MISC_SLOT_TYPE.
+ SlotDataBusWidthOther, // SlotDataBusWidth; ///< The enumeration value from MISC_SLOT_DATA_BUS_WIDTH.
SlotUsageAvailable, // CurrentUsage; ///< The enumeration value from MISC_SLOT_USAGE.
- SlotLengthOther, // SlotLength; ///< The enumeration value from MISC_SLOT_LENGTH.
- 0, // SlotID;
+ SlotLengthOther, // SlotLength; ///< The enumeration value from MISC_SLOT_LENGTH.
+ 0, // SlotID;
{ // SlotCharacteristics1;
- 1, // CharacteristicsUnknown :1;
- 0, // Provides50Volts :1;
- 0, // Provides33Volts :1;
- 0, // SharedSlot :1;
- 0, // PcCard16Supported :1;
- 0, // CardBusSupported :1;
- 0, // ZoomVideoSupported :1;
- 0, // ModemRingResumeSupported:1;
+ 1, // CharacteristicsUnknown :1;
+ 0, // Provides50Volts :1;
+ 0, // Provides33Volts :1;
+ 0, // SharedSlot :1;
+ 0, // PcCard16Supported :1;
+ 0, // CardBusSupported :1;
+ 0, // ZoomVideoSupported :1;
+ 0, // ModemRingResumeSupported:1;
},
{ // SlotCharacteristics2;
0, // PmeSignalSupported :1;
@@ -319,31 +320,30 @@ SMBIOS_TABLE_TYPE9 gSmbiosType9Template = {
0, // BusNum;
0, // DevFuncNum;
};
-CHAR8 *gSmbiosType9Strings[] = {
+CHAR8 *gSmbiosType9Strings[] = {
"SD Card",
NULL
};
-SMBIOS_TABLE_TYPE11 gSmbiosType11Template = {
+SMBIOS_TABLE_TYPE11 gSmbiosType11Template = {
{ EFI_SMBIOS_TYPE_OEM_STRINGS, sizeof (SMBIOS_TABLE_TYPE11), 0 },
1 // StringCount
};
-CHAR8 *gSmbiosType11Strings[] = {
+CHAR8 *gSmbiosType11Strings[] = {
"https://svn.code.sf.net/p/edk2/code/trunk/edk2/EmulatorPkg/",
NULL
};
-
-SMBIOS_TABLE_TYPE12 gSmbiosType12Template = {
+SMBIOS_TABLE_TYPE12 gSmbiosType12Template = {
{ EFI_SMBIOS_TYPE_SYSTEM_CONFIGURATION_OPTIONS, sizeof (SMBIOS_TABLE_TYPE12), 0 },
1 // StringCount
};
-CHAR8 *gSmbiosType12Strings[] = {
+CHAR8 *gSmbiosType12Strings[] = {
"https://svn.code.sf.net/p/edk2/code/trunk/edk2/EmulatorPkg/EmulatorPkg.dsc",
NULL
};
-SMBIOS_TABLE_TYPE16 gSmbiosType16Template = {
+SMBIOS_TABLE_TYPE16 gSmbiosType16Template = {
{ EFI_SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY, sizeof (SMBIOS_TABLE_TYPE16), 0 },
MemoryArrayLocationSystemBoard, // Location; ///< The enumeration value from MEMORY_ARRAY_LOCATION.
MemoryArrayUseSystemMemory, // Use; ///< The enumeration value from MEMORY_ARRAY_USE.
@@ -354,19 +354,19 @@ SMBIOS_TABLE_TYPE16 gSmbiosType16Template = {
0x3fffffffffffffffULL, // ExtendedMaximumCapacity;
};
-SMBIOS_TABLE_TYPE17 gSmbiosType17Template = {
+SMBIOS_TABLE_TYPE17 gSmbiosType17Template = {
{ EFI_SMBIOS_TYPE_MEMORY_DEVICE, sizeof (SMBIOS_TABLE_TYPE17), 0 },
- 0, // MemoryArrayHandle;
- 0xFFFE, // MemoryErrorInformationHandle;
- 0xFFFF, // TotalWidth;
- 0xFFFF, // DataWidth;
- 0xFFFF, // Size;
+ 0, // MemoryArrayHandle;
+ 0xFFFE, // MemoryErrorInformationHandle;
+ 0xFFFF, // TotalWidth;
+ 0xFFFF, // DataWidth;
+ 0xFFFF, // Size;
MemoryFormFactorUnknown, // FormFactor; ///< The enumeration value from MEMORY_FORM_FACTOR.
- 0xff, // DeviceSet;
- 1, // DeviceLocator String
- 2, // BankLocator String
- MemoryTypeDram, // MemoryType; ///< The enumeration value from MEMORY_DEVICE_TYPE.
- { // TypeDetail;
+ 0xff, // DeviceSet;
+ 1, // DeviceLocator String
+ 2, // BankLocator String
+ MemoryTypeDram, // MemoryType; ///< The enumeration value from MEMORY_DEVICE_TYPE.
+ { // TypeDetail;
0, // Reserved :1;
0, // Other :1;
1, // Unknown :1;
@@ -393,14 +393,14 @@ SMBIOS_TABLE_TYPE17 gSmbiosType17Template = {
0, // ExtendedSize;
0, // ConfiguredMemoryClockSpeed;
};
-CHAR8 *gSmbiosType17Strings[] = {
+CHAR8 *gSmbiosType17Strings[] = {
"OS Virtual Memory",
"malloc",
"OSV",
NULL
};
-SMBIOS_TABLE_TYPE23 gSmbiosType23Template = {
+SMBIOS_TABLE_TYPE23 gSmbiosType23Template = {
{ EFI_SMBIOS_TYPE_SYSTEM_BOOT_INFORMATION, sizeof (SMBIOS_TABLE_TYPE23), 0 },
0, // Capabilities;
0, // ResetCount;
@@ -409,34 +409,32 @@ SMBIOS_TABLE_TYPE23 gSmbiosType23Template = {
0 // Timeout;
};
-SMBIOS_TABLE_TYPE32 gSmbiosType32Template = {
+SMBIOS_TABLE_TYPE32 gSmbiosType32Template = {
{ EFI_SMBIOS_TYPE_SYSTEM_BOOT_INFORMATION, sizeof (SMBIOS_TABLE_TYPE32), 0 },
- { 0, 0, 0, 0, 0, 0 }, // Reserved[6];
- BootInformationStatusNoError // BootStatus
+ { 0, 0, 0, 0, 0, 0}, // Reserved[6];
+ BootInformationStatusNoError // BootStatus
};
-
-
-SMBIOS_TEMPLATE_ENTRY gSmbiosTemplate[] = {
- { (SMBIOS_STRUCTURE *)&gSmbiosType0Template, gSmbiosType0Strings },
- { (SMBIOS_STRUCTURE *)&gSmbiosType1Template, gSmbiosType1Strings },
- { (SMBIOS_STRUCTURE *)&gSmbiosType2Template, gSmbiosType2Strings },
- { (SMBIOS_STRUCTURE *)&gSmbiosType3Template, gSmbiosType3Strings },
- { (SMBIOS_STRUCTURE *)&gSmbiosType8Template1, gSmbiosType8Strings1 },
- { (SMBIOS_STRUCTURE *)&gSmbiosType8Template2, gSmbiosType8Strings2 },
- { (SMBIOS_STRUCTURE *)&gSmbiosType8Template3, gSmbiosType8Strings3 },
- { (SMBIOS_STRUCTURE *)&gSmbiosType8Template4, gSmbiosType8Strings4 },
- { (SMBIOS_STRUCTURE *)&gSmbiosType8Template5, gSmbiosType8Strings5 },
- { (SMBIOS_STRUCTURE *)&gSmbiosType8Template6, gSmbiosType8Strings6 },
- { (SMBIOS_STRUCTURE *)&gSmbiosType8Template7, gSmbiosType8Strings7 },
- { (SMBIOS_STRUCTURE *)&gSmbiosType8Template8, gSmbiosType8Strings8 },
- { (SMBIOS_STRUCTURE *)&gSmbiosType8Template9, gSmbiosType8Strings9 },
- { (SMBIOS_STRUCTURE *)&gSmbiosType9Template, gSmbiosType9Strings },
- { (SMBIOS_STRUCTURE *)&gSmbiosType11Template, gSmbiosType11Strings },
- { (SMBIOS_STRUCTURE *)&gSmbiosType12Template, gSmbiosType12Strings },
- { (SMBIOS_STRUCTURE *)&gSmbiosType16Template, NULL },
- { (SMBIOS_STRUCTURE *)&gSmbiosType17Template, gSmbiosType17Strings },
- { (SMBIOS_STRUCTURE *)&gSmbiosType23Template, NULL },
- { (SMBIOS_STRUCTURE *)&gSmbiosType32Template, NULL },
- { NULL, NULL }
+SMBIOS_TEMPLATE_ENTRY gSmbiosTemplate[] = {
+ { (SMBIOS_STRUCTURE *)&gSmbiosType0Template, gSmbiosType0Strings },
+ { (SMBIOS_STRUCTURE *)&gSmbiosType1Template, gSmbiosType1Strings },
+ { (SMBIOS_STRUCTURE *)&gSmbiosType2Template, gSmbiosType2Strings },
+ { (SMBIOS_STRUCTURE *)&gSmbiosType3Template, gSmbiosType3Strings },
+ { (SMBIOS_STRUCTURE *)&gSmbiosType8Template1, gSmbiosType8Strings1 },
+ { (SMBIOS_STRUCTURE *)&gSmbiosType8Template2, gSmbiosType8Strings2 },
+ { (SMBIOS_STRUCTURE *)&gSmbiosType8Template3, gSmbiosType8Strings3 },
+ { (SMBIOS_STRUCTURE *)&gSmbiosType8Template4, gSmbiosType8Strings4 },
+ { (SMBIOS_STRUCTURE *)&gSmbiosType8Template5, gSmbiosType8Strings5 },
+ { (SMBIOS_STRUCTURE *)&gSmbiosType8Template6, gSmbiosType8Strings6 },
+ { (SMBIOS_STRUCTURE *)&gSmbiosType8Template7, gSmbiosType8Strings7 },
+ { (SMBIOS_STRUCTURE *)&gSmbiosType8Template8, gSmbiosType8Strings8 },
+ { (SMBIOS_STRUCTURE *)&gSmbiosType8Template9, gSmbiosType8Strings9 },
+ { (SMBIOS_STRUCTURE *)&gSmbiosType9Template, gSmbiosType9Strings },
+ { (SMBIOS_STRUCTURE *)&gSmbiosType11Template, gSmbiosType11Strings },
+ { (SMBIOS_STRUCTURE *)&gSmbiosType12Template, gSmbiosType12Strings },
+ { (SMBIOS_STRUCTURE *)&gSmbiosType16Template, NULL },
+ { (SMBIOS_STRUCTURE *)&gSmbiosType17Template, gSmbiosType17Strings },
+ { (SMBIOS_STRUCTURE *)&gSmbiosType23Template, NULL },
+ { (SMBIOS_STRUCTURE *)&gSmbiosType32Template, NULL },
+ { NULL, NULL }
};
diff --git a/EmulatorPkg/RealTimeClockRuntimeDxe/RealTimeClock.c b/EmulatorPkg/RealTimeClockRuntimeDxe/RealTimeClock.c
index c2f980ddc5..9437b2ae98 100644
--- a/EmulatorPkg/RealTimeClockRuntimeDxe/RealTimeClock.c
+++ b/EmulatorPkg/RealTimeClockRuntimeDxe/RealTimeClock.c
@@ -25,27 +25,28 @@ DayValid (
BOOLEAN
IsLeapYear (
- IN EFI_TIME *Time
+ IN EFI_TIME *Time
);
EFI_STATUS
RtcTimeFieldsValid (
- IN EFI_TIME *Time
+ IN EFI_TIME *Time
);
EFI_STATUS
EFIAPI
InitializeRealTimeClock (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
);
EFI_STATUS
EFIAPI
EmuGetTime (
- OUT EFI_TIME * Time,
- OUT EFI_TIME_CAPABILITIES * Capabilities OPTIONAL
+ OUT EFI_TIME *Time,
+ OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL
)
+
/*++
Routine Description:
@@ -67,13 +68,11 @@ Returns:
**/
{
-
//
// Check parameter for null pointer
//
if (Time == NULL) {
return EFI_INVALID_PARAMETER;
-
}
gEmuThunk->GetTime (Time, Capabilities);
@@ -84,8 +83,9 @@ Returns:
EFI_STATUS
EFIAPI
EmuSetTime (
- IN EFI_TIME *Time
+ IN EFI_TIME *Time
)
+
/*++
Routine Description:
@@ -106,11 +106,12 @@ Returns:
**/
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
if (Time == NULL) {
return EFI_INVALID_PARAMETER;
}
+
//
// Make sure that the time fields are valid
//
@@ -118,16 +119,18 @@ Returns:
if (EFI_ERROR (Status)) {
return Status;
}
+
return EFI_UNSUPPORTED;
}
EFI_STATUS
EFIAPI
EmuGetWakeupTime (
- OUT BOOLEAN *Enabled,
- OUT BOOLEAN *Pending,
- OUT EFI_TIME *Time
+ OUT BOOLEAN *Enabled,
+ OUT BOOLEAN *Pending,
+ OUT EFI_TIME *Time
)
+
/*++
Routine Description:
@@ -159,9 +162,10 @@ Returns:
EFI_STATUS
EFIAPI
EmuSetWakeupTime (
- IN BOOLEAN Enable,
- OUT EFI_TIME *Time
+ IN BOOLEAN Enable,
+ OUT EFI_TIME *Time
)
+
/*++
Routine Description:
@@ -193,9 +197,10 @@ Returns:
EFI_STATUS
EFIAPI
InitializeRealTimeClock (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
+
/*++
Routine Description:
@@ -231,8 +236,9 @@ Returns:
EFI_STATUS
RtcTimeFieldsValid (
- IN EFI_TIME *Time
+ IN EFI_TIME *Time
)
+
/*++
Routine Description:
@@ -242,18 +248,19 @@ Routine Description:
Returns:
**/
{
- if (Time->Year < 1998 ||
- Time->Year > 2099 ||
- Time->Month < 1 ||
- Time->Month > 12 ||
+ if ((Time->Year < 1998) ||
+ (Time->Year > 2099) ||
+ (Time->Month < 1) ||
+ (Time->Month > 12) ||
(!DayValid (Time)) ||
- Time->Hour > 23 ||
- Time->Minute > 59 ||
- Time->Second > 59 ||
- Time->Nanosecond > 999999999 ||
- (!(Time->TimeZone == EFI_UNSPECIFIED_TIMEZONE || (Time->TimeZone >= -1440 && Time->TimeZone <= 1440))) ||
+ (Time->Hour > 23) ||
+ (Time->Minute > 59) ||
+ (Time->Second > 59) ||
+ (Time->Nanosecond > 999999999) ||
+ (!((Time->TimeZone == EFI_UNSPECIFIED_TIMEZONE) || ((Time->TimeZone >= -1440) && (Time->TimeZone <= 1440)))) ||
(Time->Daylight & (~(EFI_TIME_ADJUST_DAYLIGHT | EFI_TIME_IN_DAYLIGHT)))
- ) {
+ )
+ {
return EFI_INVALID_PARAMETER;
}
@@ -265,13 +272,13 @@ DayValid (
IN EFI_TIME *Time
)
{
-
STATIC const INTN DayOfMonth[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
- if (Time->Day < 1 ||
- Time->Day > DayOfMonth[Time->Month - 1] ||
- (Time->Month == 2 && (!IsLeapYear (Time) && Time->Day > 28))
- ) {
+ if ((Time->Day < 1) ||
+ (Time->Day > DayOfMonth[Time->Month - 1]) ||
+ ((Time->Month == 2) && (!IsLeapYear (Time) && (Time->Day > 28)))
+ )
+ {
return FALSE;
}
@@ -280,7 +287,7 @@ DayValid (
BOOLEAN
IsLeapYear (
- IN EFI_TIME *Time
+ IN EFI_TIME *Time
)
{
if (Time->Year % 4 == 0) {
diff --git a/EmulatorPkg/ResetRuntimeDxe/Reset.c b/EmulatorPkg/ResetRuntimeDxe/Reset.c
index 19504825c9..07d4134cd4 100644
--- a/EmulatorPkg/ResetRuntimeDxe/Reset.c
+++ b/EmulatorPkg/ResetRuntimeDxe/Reset.c
@@ -19,14 +19,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Protocol/Reset.h>
-
VOID
EFIAPI
EmuResetSystem (
- 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
)
{
EFI_STATUS Status;
@@ -52,7 +51,6 @@ EmuResetSystem (
gBS->FreePool (HandleBuffer);
}
-
//
// Discard ResetType, always return 0 as exit code
//
@@ -66,14 +64,13 @@ EmuResetSystem (
return;
}
-
-
EFI_STATUS
EFIAPI
InitializeEmuReset (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
+
/*++
Routine Description:
@@ -105,4 +102,3 @@ Returns:
return Status;
}
-
diff --git a/EmulatorPkg/Sec/Ia32/TempRam.c b/EmulatorPkg/Sec/Ia32/TempRam.c
index e8b0d53bb1..13c32b9ca1 100644
--- a/EmulatorPkg/Sec/Ia32/TempRam.c
+++ b/EmulatorPkg/Sec/Ia32/TempRam.c
@@ -15,26 +15,25 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
VOID
EFIAPI
SecSwitchStack (
- UINT32 TemporaryMemoryBase,
- UINT32 PermenentMemoryBase
+ UINT32 TemporaryMemoryBase,
+ UINT32 PermenentMemoryBase
);
-
EFI_STATUS
EFIAPI
SecTemporaryRamSupport (
- IN CONST EFI_PEI_SERVICES **PeiServices,
- IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase,
- IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase,
- IN UINTN CopySize
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase,
+ IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase,
+ IN UINTN CopySize
)
{
//
// Migrate the whole temporary memory to permanent memory.
//
CopyMem (
- (VOID*)(UINTN)PermanentMemoryBase,
- (VOID*)(UINTN)TemporaryMemoryBase,
+ (VOID *)(UINTN)PermanentMemoryBase,
+ (VOID *)(UINTN)TemporaryMemoryBase,
CopySize
);
@@ -43,7 +42,7 @@ SecTemporaryRamSupport (
// immediately, also we need fixup the stack change caused by new call into
// permanent memory.
//
- SecSwitchStack ((UINT32) TemporaryMemoryBase, (UINT32) PermanentMemoryBase);
+ SecSwitchStack ((UINT32)TemporaryMemoryBase, (UINT32)PermanentMemoryBase);
//
// We need *not* fix the return address because currently,
@@ -53,7 +52,7 @@ SecTemporaryRamSupport (
//
// Simulate to invalid temporary memory, terminate temporary memory
//
- //ZeroMem ((VOID*)(UINTN)TemporaryMemoryBase, CopySize);
+ // ZeroMem ((VOID*)(UINTN)TemporaryMemoryBase, CopySize);
return EFI_SUCCESS;
}
diff --git a/EmulatorPkg/Sec/Sec.c b/EmulatorPkg/Sec/Sec.c
index e1bee4f6b4..3d792adc94 100644
--- a/EmulatorPkg/Sec/Sec.c
+++ b/EmulatorPkg/Sec/Sec.c
@@ -10,13 +10,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "Sec.h"
-
-
-EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI mSecTemporaryRamSupportPpi = {
+EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI mSecTemporaryRamSupportPpi = {
SecTemporaryRamSupport
};
-
EFI_PEI_PPI_DESCRIPTOR gPrivateDispatchTable[] = {
{
EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
@@ -25,8 +22,6 @@ EFI_PEI_PPI_DESCRIPTOR gPrivateDispatchTable[] = {
}
};
-
-
/**
The entry point of PE/COFF Image for the PEI Core, that has been hijacked by this
SEC that sits on top of an OS application. So the entry and exit of this module
@@ -62,8 +57,8 @@ EFI_PEI_PPI_DESCRIPTOR gPrivateDispatchTable[] = {
VOID
EFIAPI
_ModuleEntryPoint (
- IN EFI_SEC_PEI_HAND_OFF *SecCoreData,
- IN EFI_PEI_PPI_DESCRIPTOR *PpiList
+ IN EFI_SEC_PEI_HAND_OFF *SecCoreData,
+ IN EFI_PEI_PPI_DESCRIPTOR *PpiList
)
{
EFI_STATUS Status;
@@ -77,7 +72,7 @@ _ModuleEntryPoint (
UINTN Index;
EFI_PEI_PPI_DESCRIPTOR PpiArray[10];
- EMU_MAGIC_PAGE()->PpiList = PpiList;
+ EMU_MAGIC_PAGE ()->PpiList = PpiList;
ProcessLibraryConstructorList ();
DEBUG ((DEBUG_ERROR, "SEC Has Started\n"));
@@ -99,12 +94,12 @@ _ModuleEntryPoint (
// Keep everything on a good alignment
SecReseveredMemorySize = ALIGN_VALUE (SecReseveredMemorySize, CPU_STACK_ALIGNMENT);
-#if 0
+ #if 0
// Tell the PEI Core to not use our buffer in temp RAM
- SecPpiList = (EFI_PEI_PPI_DESCRIPTOR *)SecCoreData->PeiTemporaryRamBase;
- SecCoreData->PeiTemporaryRamBase = (VOID *)((UINTN)SecCoreData->PeiTemporaryRamBase + SecReseveredMemorySize);
+ SecPpiList = (EFI_PEI_PPI_DESCRIPTOR *)SecCoreData->PeiTemporaryRamBase;
+ SecCoreData->PeiTemporaryRamBase = (VOID *)((UINTN)SecCoreData->PeiTemporaryRamBase + SecReseveredMemorySize);
SecCoreData->PeiTemporaryRamSize -= SecReseveredMemorySize;
-#else
+ #else
//
// When I subtrack from SecCoreData->PeiTemporaryRamBase PEI Core crashes? Either there is a bug
// or I don't understand temp RAM correctly?
@@ -112,7 +107,7 @@ _ModuleEntryPoint (
SecPpiList = &PpiArray[0];
ASSERT (sizeof (PpiArray) >= SecReseveredMemorySize);
-#endif
+ #endif
// Copy existing list, and append our entries.
CopyMem (SecPpiList, PpiList, sizeof (EFI_PEI_PPI_DESCRIPTOR) * Index);
CopyMem (&SecPpiList[Index], gPrivateDispatchTable, sizeof (gPrivateDispatchTable));
@@ -120,7 +115,7 @@ _ModuleEntryPoint (
// Find PEI Core and transfer control
VolumeHandle = (EFI_PEI_FV_HANDLE)(UINTN)SecCoreData->BootFirmwareVolumeBase;
FileHandle = NULL;
- Status = PeiServicesFfsFindNextFile (EFI_FV_FILETYPE_PEI_CORE, VolumeHandle, &FileHandle);
+ Status = PeiServicesFfsFindNextFile (EFI_FV_FILETYPE_PEI_CORE, VolumeHandle, &FileHandle);
ASSERT_EFI_ERROR (Status);
Status = PeiServicesFfsFindSectionData (EFI_SECTION_PE32, FileHandle, &PeCoffImage);
diff --git a/EmulatorPkg/Sec/Sec.h b/EmulatorPkg/Sec/Sec.h
index 42554e05b5..29272a29ff 100644
--- a/EmulatorPkg/Sec/Sec.h
+++ b/EmulatorPkg/Sec/Sec.h
@@ -11,7 +11,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef __SEC_H___
#define __SEC_H___
-
#include <PiPei.h>
#include <Library/EmuMagicPageLib.h>
#include <Library/DebugLib.h>
@@ -21,7 +20,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Ppi/TemporaryRamSupport.h>
-
//
// I think this should be defined in a MdePkg include file?
//
@@ -34,12 +32,10 @@ ProcessLibraryConstructorList (
EFI_STATUS
EFIAPI
SecTemporaryRamSupport (
- IN CONST EFI_PEI_SERVICES **PeiServices,
- IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase,
- IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase,
- IN UINTN CopySize
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase,
+ IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase,
+ IN UINTN CopySize
);
-
#endif
-
diff --git a/EmulatorPkg/ThunkPpiToProtocolPei/ThunkPpiToProtocolPei.c b/EmulatorPkg/ThunkPpiToProtocolPei/ThunkPpiToProtocolPei.c
index 966da3b226..c228399b6c 100644
--- a/EmulatorPkg/ThunkPpiToProtocolPei/ThunkPpiToProtocolPei.c
+++ b/EmulatorPkg/ThunkPpiToProtocolPei/ThunkPpiToProtocolPei.c
@@ -18,14 +18,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Ppi/EmuThunk.h>
#include <Protocol/EmuThunk.h>
-
-
EFI_STATUS
EFIAPI
PeiInitialzeThunkPpiToProtocolPei (
- IN EFI_PEI_FILE_HANDLE FileHandle,
- IN CONST EFI_PEI_SERVICES **PeiServices
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ IN CONST EFI_PEI_SERVICES **PeiServices
)
+
/*++
Routine Description:
@@ -50,11 +49,11 @@ Returns:
DEBUG ((DEBUG_ERROR, "Emu Thunk PEIM Loaded\n"));
Status = PeiServicesLocatePpi (
- &gEmuThunkPpiGuid, // GUID
- 0, // INSTANCE
- &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR
- (VOID **)&Thunk // PPI
- );
+ &gEmuThunkPpiGuid, // GUID
+ 0, // INSTANCE
+ &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR
+ (VOID **)&Thunk // PPI
+ );
ASSERT_EFI_ERROR (Status);
Ptr = Thunk->Thunk ();
diff --git a/EmulatorPkg/TimerDxe/Timer.c b/EmulatorPkg/TimerDxe/Timer.c
index 8e2baaaa5b..4ec5c3ee28 100644
--- a/EmulatorPkg/TimerDxe/Timer.c
+++ b/EmulatorPkg/TimerDxe/Timer.c
@@ -27,12 +27,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//
// Pointer to the CPU Architectural Protocol instance
//
-EFI_CPU_ARCH_PROTOCOL *mCpu;
+EFI_CPU_ARCH_PROTOCOL *mCpu;
//
// The Timer Architectural Protocol that this driver produces
//
-EFI_TIMER_ARCH_PROTOCOL mTimer = {
+EFI_TIMER_ARCH_PROTOCOL mTimer = {
EmuTimerDriverRegisterHandler,
EmuTimerDriverSetTimerPeriod,
EmuTimerDriverGetTimerPeriod,
@@ -42,22 +42,22 @@ EFI_TIMER_ARCH_PROTOCOL mTimer = {
//
// The notification function to call on every timer interrupt
//
-EFI_TIMER_NOTIFY mTimerNotifyFunction = NULL;
+EFI_TIMER_NOTIFY mTimerNotifyFunction = NULL;
//
// The current period of the timer interrupt
//
-UINT64 mTimerPeriodMs;
-
+UINT64 mTimerPeriodMs;
VOID
EFIAPI
-TimerCallback (UINT64 DeltaMs)
+TimerCallback (
+ UINT64 DeltaMs
+ )
{
EFI_TPL OriginalTPL;
EFI_TIMER_NOTIFY CallbackFunction;
-
OriginalTPL = gBS->RaiseTPL (TPL_HIGH_LEVEL);
if (OriginalTPL < TPL_HIGH_LEVEL) {
@@ -73,15 +73,15 @@ TimerCallback (UINT64 DeltaMs)
}
gBS->RestoreTPL (OriginalTPL);
-
}
EFI_STATUS
EFIAPI
EmuTimerDriverRegisterHandler (
- IN EFI_TIMER_ARCH_PROTOCOL *This,
- IN EFI_TIMER_NOTIFY NotifyFunction
+ IN EFI_TIMER_ARCH_PROTOCOL *This,
+ IN EFI_TIMER_NOTIFY NotifyFunction
)
+
/*++
Routine Description:
@@ -127,11 +127,11 @@ Returns:
//
// Check for invalid parameters
//
- if (NotifyFunction == NULL && mTimerNotifyFunction == NULL) {
+ if ((NotifyFunction == NULL) && (mTimerNotifyFunction == NULL)) {
return EFI_INVALID_PARAMETER;
}
- if (NotifyFunction != NULL && mTimerNotifyFunction != NULL) {
+ if ((NotifyFunction != NULL) && (mTimerNotifyFunction != NULL)) {
return EFI_ALREADY_STARTED;
}
@@ -142,6 +142,7 @@ Returns:
/* Enable Timer. */
gEmuThunk->SetTimer (mTimerPeriodMs, TimerCallback);
}
+
mTimerNotifyFunction = NotifyFunction;
return EFI_SUCCESS;
@@ -153,6 +154,7 @@ EmuTimerDriverSetTimerPeriod (
IN EFI_TIMER_ARCH_PROTOCOL *This,
IN UINT64 TimerPeriod
)
+
/*++
Routine Description:
@@ -190,14 +192,14 @@ Returns:
**/
{
-
//
// If TimerPeriod is 0, then the timer thread should be canceled
// If the TimerPeriod is valid, then create and/or adjust the period of the timer thread
//
- if (TimerPeriod == 0
- || ((TimerPeriod > TIMER_MINIMUM_VALUE)
- && (TimerPeriod < TIMER_MAXIMUM_VALUE))) {
+ if ( (TimerPeriod == 0)
+ || ( (TimerPeriod > TIMER_MINIMUM_VALUE)
+ && (TimerPeriod < TIMER_MAXIMUM_VALUE)))
+ {
mTimerPeriodMs = DivU64x32 (TimerPeriod + 5000, 10000);
gEmuThunk->SetTimer (mTimerPeriodMs, TimerCallback);
@@ -209,9 +211,10 @@ Returns:
EFI_STATUS
EFIAPI
EmuTimerDriverGetTimerPeriod (
- IN EFI_TIMER_ARCH_PROTOCOL *This,
- OUT UINT64 *TimerPeriod
+ IN EFI_TIMER_ARCH_PROTOCOL *This,
+ OUT UINT64 *TimerPeriod
)
+
/*++
Routine Description:
@@ -250,6 +253,7 @@ EFIAPI
EmuTimerDriverGenerateSoftInterrupt (
IN EFI_TIMER_ARCH_PROTOCOL *This
)
+
/*++
Routine Description:
@@ -283,6 +287,7 @@ EmuTimerDriverInitialize (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
+
/*++
Routine Description:
@@ -341,6 +346,5 @@ Returns:
return Status;
}
-
return EFI_SUCCESS;
}
diff --git a/EmulatorPkg/TimerDxe/Timer.h b/EmulatorPkg/TimerDxe/Timer.h
index 861811f3a4..7a995e0d96 100644
--- a/EmulatorPkg/TimerDxe/Timer.h
+++ b/EmulatorPkg/TimerDxe/Timer.h
@@ -13,19 +13,16 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _TIMER_H_
#define _TIMER_H_
-
-
-
//
// Legal timer value range in 100 ns units
//
-#define TIMER_MINIMUM_VALUE 0
-#define TIMER_MAXIMUM_VALUE (0x100000000ULL - 1)
+#define TIMER_MINIMUM_VALUE 0
+#define TIMER_MAXIMUM_VALUE (0x100000000ULL - 1)
//
// Default timer value in 100 ns units (50 ms)
//
-#define DEFAULT_TIMER_TICK_DURATION 500000
+#define DEFAULT_TIMER_TICK_DURATION 500000
//
// Function Prototypes
@@ -54,8 +51,8 @@ EmuTimerDriverSetTimerPeriod (
EFI_STATUS
EFIAPI
EmuTimerDriverGetTimerPeriod (
- IN EFI_TIMER_ARCH_PROTOCOL *This,
- OUT UINT64 *TimerPeriod
+ IN EFI_TIMER_ARCH_PROTOCOL *This,
+ OUT UINT64 *TimerPeriod
);
EFI_STATUS
diff --git a/EmulatorPkg/Unix/Host/BerkeleyPacketFilter.c b/EmulatorPkg/Unix/Host/BerkeleyPacketFilter.c
index 441f1e8d0a..ecfdacc748 100644
--- a/EmulatorPkg/Unix/Host/BerkeleyPacketFilter.c
+++ b/EmulatorPkg/Unix/Host/BerkeleyPacketFilter.c
@@ -11,53 +11,48 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-
#include "Host.h"
#ifdef __APPLE__
+ #include <Library/NetLib.h>
-#include <Library/NetLib.h>
-
-
-#define EMU_SNP_PRIVATE_SIGNATURE SIGNATURE_32('E', 'M', 's', 'n')
+#define EMU_SNP_PRIVATE_SIGNATURE SIGNATURE_32('E', 'M', 's', 'n')
typedef struct {
- UINTN Signature;
+ UINTN Signature;
- EMU_IO_THUNK_PROTOCOL *Thunk;
- EMU_SNP_PROTOCOL EmuSnp;
- EFI_SIMPLE_NETWORK_MODE *Mode;
+ EMU_IO_THUNK_PROTOCOL *Thunk;
+ EMU_SNP_PROTOCOL EmuSnp;
+ EFI_SIMPLE_NETWORK_MODE *Mode;
- int BpfFd;
- char *InterfaceName;
- EFI_MAC_ADDRESS MacAddress;
- u_int ReadBufferSize;
- VOID *ReadBuffer;
+ int BpfFd;
+ char *InterfaceName;
+ EFI_MAC_ADDRESS MacAddress;
+ u_int ReadBufferSize;
+ VOID *ReadBuffer;
//
// Two walking pointers to manage the multiple packets that can be returned
// in a single read.
//
- VOID *CurrentReadPointer;
- VOID *EndReadPointer;
-
- UINT32 ReceivedPackets;
- UINT32 DroppedPackets;
+ VOID *CurrentReadPointer;
+ VOID *EndReadPointer;
+ UINT32 ReceivedPackets;
+ UINT32 DroppedPackets;
} EMU_SNP_PRIVATE;
#define EMU_SNP_PRIVATE_DATA_FROM_THIS(a) \
CR(a, EMU_SNP_PRIVATE, EmuSnp, EMU_SNP_PRIVATE_SIGNATURE)
-
//
// Strange, but there doesn't appear to be any structure for the Ethernet header in edk2...
//
typedef struct {
- UINT8 DstAddr[NET_ETHER_ADDR_LEN];
- UINT8 SrcAddr[NET_ETHER_ADDR_LEN];
- UINT16 Type;
+ UINT8 DstAddr[NET_ETHER_ADDR_LEN];
+ UINT8 SrcAddr[NET_ETHER_ADDR_LEN];
+ UINT16 Type;
} ETHERNET_HEADER;
/**
@@ -76,7 +71,7 @@ EmuSnpCreateMapping (
IN EFI_SIMPLE_NETWORK_MODE *Mode
)
{
- EMU_SNP_PRIVATE *Private;
+ EMU_SNP_PRIVATE *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -100,40 +95,38 @@ EmuSnpCreateMapping (
return EFI_SUCCESS;
}
-
-static struct bpf_insn mFilterInstructionTemplate[] = {
+static struct bpf_insn mFilterInstructionTemplate[] = {
// Load 4 bytes from the destination MAC address.
- BPF_STMT (BPF_LD + BPF_W + BPF_ABS, OFFSET_OF (ETHERNET_HEADER, DstAddr[0])),
+ BPF_STMT (BPF_LD + BPF_W + BPF_ABS, OFFSET_OF (ETHERNET_HEADER, DstAddr[0])),
// Compare to first 4 bytes of fake MAC address.
- BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, 0x12345678, 0, 3 ),
+ BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, 0x12345678, 0, 3),
// Load remaining 2 bytes from the destination MAC address.
- BPF_STMT (BPF_LD + BPF_H + BPF_ABS, OFFSET_OF( ETHERNET_HEADER, DstAddr[4])),
+ BPF_STMT (BPF_LD + BPF_H + BPF_ABS, OFFSET_OF (ETHERNET_HEADER, DstAddr[4])),
// Compare to remaining 2 bytes of fake MAC address.
- BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, 0x9ABC, 5, 0 ),
+ BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, 0x9ABC, 5, 0),
// Load 4 bytes from the destination MAC address.
- BPF_STMT (BPF_LD + BPF_W + BPF_ABS, OFFSET_OF (ETHERNET_HEADER, DstAddr[0])),
+ BPF_STMT (BPF_LD + BPF_W + BPF_ABS, OFFSET_OF (ETHERNET_HEADER, DstAddr[0])),
// Compare to first 4 bytes of broadcast MAC address.
- BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, 0xFFFFFFFF, 0, 2),
+ BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, 0xFFFFFFFF, 0, 2),
// Load remaining 2 bytes from the destination MAC address.
- BPF_STMT (BPF_LD + BPF_H + BPF_ABS, OFFSET_OF( ETHERNET_HEADER, DstAddr[4])),
+ BPF_STMT (BPF_LD + BPF_H + BPF_ABS, OFFSET_OF (ETHERNET_HEADER, DstAddr[4])),
// Compare to remaining 2 bytes of broadcast MAC address.
- BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, 0xFFFF, 1, 0),
+ BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, 0xFFFF, 1, 0),
// Reject packet.
- BPF_STMT (BPF_RET + BPF_K, 0),
+ BPF_STMT (BPF_RET + BPF_K, 0),
// Receive entire packet.
- BPF_STMT (BPF_RET + BPF_K, -1)
+ BPF_STMT (BPF_RET + BPF_K, -1)
};
-
EFI_STATUS
OpenBpfFileDescriptor (
IN EMU_SNP_PRIVATE *Private,
@@ -171,7 +164,6 @@ OpenBpfFileDescriptor (
return EFI_OUT_OF_RESOURCES;
}
-
/**
Changes the state of a network interface from "stopped" to "started".
@@ -189,15 +181,15 @@ EmuSnpStart (
IN EMU_SNP_PROTOCOL *This
)
{
- EFI_STATUS Status;
- EMU_SNP_PRIVATE *Private;
- struct ifreq BoundIf;
- struct bpf_program BpfProgram;
- struct bpf_insn *FilterProgram;
+ EFI_STATUS Status;
+ EMU_SNP_PRIVATE *Private;
+ struct ifreq BoundIf;
+ struct bpf_program BpfProgram;
+ struct bpf_insn *FilterProgram;
u_int Value;
u_int ReadBufferSize;
- UINT16 Temp16;
- UINT32 Temp32;
+ UINT16 Temp16;
+ UINT32 Temp32;
Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -215,7 +207,7 @@ EmuSnpStart (
break;
}
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
Private->ReadBuffer = NULL;
if (Private->BpfFd == 0) {
Status = OpenBpfFileDescriptor (Private, &Private->BpfFd);
@@ -282,7 +274,7 @@ EmuSnpStart (
// Allocate read buffer.
//
Private->ReadBufferSize = ReadBufferSize;
- Private->ReadBuffer = malloc (Private->ReadBufferSize);
+ Private->ReadBuffer = malloc (Private->ReadBufferSize);
if (Private->ReadBuffer == NULL) {
goto ErrorExit;
}
@@ -293,7 +285,7 @@ EmuSnpStart (
// Install our packet filter: successful reads should only produce broadcast or unicast
// packets directed to our fake MAC address.
//
- FilterProgram = malloc (sizeof (mFilterInstructionTemplate)) ;
+ FilterProgram = malloc (sizeof (mFilterInstructionTemplate));
if ( FilterProgram == NULL ) {
goto ErrorExit;
}
@@ -308,7 +300,7 @@ EmuSnpStart (
CopyMem (&Temp16, &Private->Mode->CurrentAddress.Addr[4], sizeof (UINT16));
FilterProgram[3].k = NTOHS (Temp16);
- BpfProgram.bf_len = sizeof (mFilterInstructionTemplate) / sizeof (struct bpf_insn);
+ BpfProgram.bf_len = sizeof (mFilterInstructionTemplate) / sizeof (struct bpf_insn);
BpfProgram.bf_insns = FilterProgram;
if (ioctl (Private->BpfFd, BIOCSETF, &BpfProgram) < 0) {
@@ -324,7 +316,6 @@ EmuSnpStart (
goto DeviceErrorExit;
}
-
Private->Mode->State = EfiSimpleNetworkStarted;
}
@@ -337,10 +328,10 @@ ErrorExit:
free (Private->ReadBuffer);
Private->ReadBuffer = NULL;
}
+
return Status;
}
-
/**
Changes the state of a network interface from "started" to "stopped".
@@ -358,7 +349,7 @@ EmuSnpStop (
IN EMU_SNP_PROTOCOL *This
)
{
- EMU_SNP_PRIVATE *Private;
+ EMU_SNP_PRIVATE *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -381,7 +372,7 @@ EmuSnpStop (
}
if (Private->ReadBuffer != NULL) {
- free (Private->ReadBuffer );
+ free (Private->ReadBuffer);
Private->CurrentReadPointer = Private->EndReadPointer = Private->ReadBuffer = NULL;
}
@@ -390,7 +381,6 @@ EmuSnpStop (
return EFI_SUCCESS;
}
-
/**
Resets a network adapter and allocates the transmit and receive buffers
required by the network interface; optionally, also requests allocation
@@ -419,12 +409,12 @@ EmuSnpStop (
**/
EFI_STATUS
EmuSnpInitialize (
- IN EMU_SNP_PROTOCOL *This,
- IN UINTN ExtraRxBufferSize OPTIONAL,
- IN UINTN ExtraTxBufferSize OPTIONAL
+ IN EMU_SNP_PROTOCOL *This,
+ IN UINTN ExtraRxBufferSize OPTIONAL,
+ IN UINTN ExtraTxBufferSize OPTIONAL
)
{
- EMU_SNP_PRIVATE *Private;
+ EMU_SNP_PRIVATE *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -441,7 +431,7 @@ EmuSnpInitialize (
break;
}
- Private->Mode->MCastFilterCount = 0;
+ Private->Mode->MCastFilterCount = 0;
Private->Mode->ReceiveFilterSetting = 0;
ZeroMem (Private->Mode->MCastFilter, sizeof (Private->Mode->MCastFilter));
@@ -450,7 +440,6 @@ EmuSnpInitialize (
return EFI_SUCCESS;
}
-
/**
Resets a network adapter and re-initializes it with the parameters that were
provided in the previous call to Initialize().
@@ -469,11 +458,11 @@ EmuSnpInitialize (
**/
EFI_STATUS
EmuSnpReset (
- IN EMU_SNP_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EMU_SNP_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
)
{
- EMU_SNP_PRIVATE *Private;
+ EMU_SNP_PRIVATE *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -493,7 +482,6 @@ EmuSnpReset (
return EFI_SUCCESS;
}
-
/**
Resets a network adapter and leaves it in a state that is safe for
another driver to initialize.
@@ -512,7 +500,7 @@ EmuSnpShutdown (
IN EMU_SNP_PROTOCOL *This
)
{
- EMU_SNP_PRIVATE *Private;
+ EMU_SNP_PRIVATE *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -532,7 +520,7 @@ EmuSnpShutdown (
Private->Mode->State = EfiSimpleNetworkStarted;
Private->Mode->ReceiveFilterSetting = 0;
- Private->Mode->MCastFilterCount = 0;
+ Private->Mode->MCastFilterCount = 0;
ZeroMem (Private->Mode->MCastFilter, sizeof (Private->Mode->MCastFilter));
if (Private->BpfFd != 0) {
@@ -574,15 +562,15 @@ EmuSnpShutdown (
**/
EFI_STATUS
EmuSnpReceiveFilters (
- IN EMU_SNP_PROTOCOL *This,
- IN UINT32 Enable,
- IN UINT32 Disable,
- IN BOOLEAN ResetMCastFilter,
- IN UINTN MCastFilterCnt OPTIONAL,
- IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL
+ IN EMU_SNP_PROTOCOL *This,
+ IN UINT32 Enable,
+ IN UINT32 Disable,
+ IN BOOLEAN ResetMCastFilter,
+ IN UINTN MCastFilterCnt OPTIONAL,
+ IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL
)
{
- EMU_SNP_PRIVATE *Private;
+ EMU_SNP_PRIVATE *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -590,7 +578,6 @@ EmuSnpReceiveFilters (
return EFI_SUCCESS;
}
-
/**
Modifies or resets the current station address, if supported.
@@ -608,19 +595,18 @@ EmuSnpReceiveFilters (
**/
EFI_STATUS
EmuSnpStationAddress (
- IN EMU_SNP_PROTOCOL *This,
- IN BOOLEAN Reset,
- IN EFI_MAC_ADDRESS *New OPTIONAL
+ IN EMU_SNP_PROTOCOL *This,
+ IN BOOLEAN Reset,
+ IN EFI_MAC_ADDRESS *New OPTIONAL
)
{
- EMU_SNP_PRIVATE *Private;
+ EMU_SNP_PRIVATE *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);
return EFI_UNSUPPORTED;
}
-
/**
Resets or collects the statistics on a network interface.
@@ -644,20 +630,19 @@ EmuSnpStationAddress (
**/
EFI_STATUS
EmuSnpStatistics (
- IN EMU_SNP_PROTOCOL *This,
- IN BOOLEAN Reset,
- IN OUT UINTN *StatisticsSize OPTIONAL,
- OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL
+ IN EMU_SNP_PROTOCOL *This,
+ IN BOOLEAN Reset,
+ IN OUT UINTN *StatisticsSize OPTIONAL,
+ OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL
)
{
- EMU_SNP_PRIVATE *Private;
+ EMU_SNP_PRIVATE *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);
return EFI_UNSUPPORTED;
}
-
/**
Converts a multicast IP address to a multicast HW MAC address.
@@ -681,20 +666,19 @@ EmuSnpStatistics (
**/
EFI_STATUS
EmuSnpMCastIpToMac (
- IN EMU_SNP_PROTOCOL *This,
- IN BOOLEAN IPv6,
- IN EFI_IP_ADDRESS *IP,
- OUT EFI_MAC_ADDRESS *MAC
+ IN EMU_SNP_PROTOCOL *This,
+ IN BOOLEAN IPv6,
+ IN EFI_IP_ADDRESS *IP,
+ OUT EFI_MAC_ADDRESS *MAC
)
{
- EMU_SNP_PRIVATE *Private;
+ EMU_SNP_PRIVATE *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);
return EFI_UNSUPPORTED;
}
-
/**
Performs read and write operations on the NVRAM device attached to a
network interface.
@@ -717,14 +701,14 @@ EmuSnpMCastIpToMac (
**/
EFI_STATUS
EmuSnpNvData (
- IN EMU_SNP_PROTOCOL *This,
- IN BOOLEAN ReadWrite,
- IN UINTN Offset,
- IN UINTN BufferSize,
- IN OUT VOID *Buffer
+ IN EMU_SNP_PROTOCOL *This,
+ IN BOOLEAN ReadWrite,
+ IN UINTN Offset,
+ IN UINTN BufferSize,
+ IN OUT VOID *Buffer
)
{
- EMU_SNP_PRIVATE *Private;
+ EMU_SNP_PRIVATE *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -758,12 +742,12 @@ EmuSnpNvData (
**/
EFI_STATUS
EmuSnpGetStatus (
- IN EMU_SNP_PROTOCOL *This,
- OUT UINT32 *InterruptStatus OPTIONAL,
- OUT VOID **TxBuf OPTIONAL
+ IN EMU_SNP_PROTOCOL *This,
+ OUT UINT32 *InterruptStatus OPTIONAL,
+ OUT VOID **TxBuf OPTIONAL
)
{
- EMU_SNP_PRIVATE *Private;
+ EMU_SNP_PRIVATE *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -774,7 +758,6 @@ EmuSnpGetStatus (
return EFI_SUCCESS;
}
-
/**
Places a packet in the transmit queue of a network interface.
@@ -810,17 +793,17 @@ EmuSnpGetStatus (
**/
EFI_STATUS
EmuSnpTransmit (
- IN EMU_SNP_PROTOCOL *This,
- IN UINTN HeaderSize,
- IN UINTN BufferSize,
- IN VOID *Buffer,
- IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
- IN EFI_MAC_ADDRESS *DestAddr OPTIONAL,
- IN UINT16 *Protocol OPTIONAL
+ IN EMU_SNP_PROTOCOL *This,
+ IN UINTN HeaderSize,
+ IN UINTN BufferSize,
+ IN VOID *Buffer,
+ IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
+ IN EFI_MAC_ADDRESS *DestAddr OPTIONAL,
+ IN UINT16 *Protocol OPTIONAL
)
{
- EMU_SNP_PRIVATE *Private;
- ETHERNET_HEADER *EnetHeader;
+ EMU_SNP_PRIVATE *Private;
+ ETHERNET_HEADER *EnetHeader;
Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -837,15 +820,15 @@ EmuSnpTransmit (
SrcAddr = &Private->Mode->CurrentAddress;
}
- EnetHeader = (ETHERNET_HEADER *) Buffer;
+ EnetHeader = (ETHERNET_HEADER *)Buffer;
CopyMem (EnetHeader->DstAddr, DestAddr, NET_ETHER_ADDR_LEN);
CopyMem (EnetHeader->SrcAddr, SrcAddr, NET_ETHER_ADDR_LEN);
- EnetHeader->Type = HTONS(*Protocol);
+ EnetHeader->Type = HTONS (*Protocol);
}
- if (write (Private->BpfFd, Buffer, BufferSize) < 0) {
+ if (write (Private->BpfFd, Buffer, BufferSize) < 0) {
return EFI_DEVICE_ERROR;
}
@@ -886,20 +869,20 @@ EmuSnpTransmit (
**/
EFI_STATUS
EmuSnpReceive (
- IN EMU_SNP_PROTOCOL *This,
- OUT UINTN *HeaderSize OPTIONAL,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer,
- OUT EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
- OUT EFI_MAC_ADDRESS *DestAddr OPTIONAL,
- OUT UINT16 *Protocol OPTIONAL
+ IN EMU_SNP_PROTOCOL *This,
+ OUT UINTN *HeaderSize OPTIONAL,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer,
+ OUT EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
+ OUT EFI_MAC_ADDRESS *DestAddr OPTIONAL,
+ OUT UINT16 *Protocol OPTIONAL
)
{
- EMU_SNP_PRIVATE *Private;
- struct bpf_hdr *BpfHeader;
- struct bpf_stat BpfStats;
- ETHERNET_HEADER *EnetHeader;
- ssize_t Result;
+ EMU_SNP_PRIVATE *Private;
+ struct bpf_hdr *BpfHeader;
+ struct bpf_stat BpfStats;
+ ETHERNET_HEADER *EnetHeader;
+ ssize_t Result;
Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -907,7 +890,7 @@ EmuSnpReceive (
return EFI_NOT_STARTED;
}
- ZeroMem (&BpfStats, sizeof( BpfStats));
+ ZeroMem (&BpfStats, sizeof (BpfStats));
if (ioctl (Private->BpfFd, BIOCGSTATS, &BpfStats) == 0) {
Private->ReceivedPackets += BpfStats.bs_recv;
@@ -936,10 +919,10 @@ EmuSnpReceive (
}
Private->CurrentReadPointer = Private->ReadBuffer;
- Private->EndReadPointer = Private->CurrentReadPointer + Result;
+ Private->EndReadPointer = Private->CurrentReadPointer + Result;
}
- BpfHeader = Private->CurrentReadPointer;
+ BpfHeader = Private->CurrentReadPointer;
EnetHeader = Private->CurrentReadPointer + BpfHeader->bh_hdrlen;
if (BpfHeader->bh_caplen > *BufferSize) {
@@ -972,8 +955,7 @@ EmuSnpReceive (
return EFI_SUCCESS;
}
-
-EMU_SNP_PROTOCOL gEmuSnpProtocol = {
+EMU_SNP_PROTOCOL gEmuSnpProtocol = {
GasketSnpCreateMapping,
GasketSnpStart,
GasketSnpStop,
@@ -992,7 +974,7 @@ EMU_SNP_PROTOCOL gEmuSnpProtocol = {
EFI_STATUS
GetInterfaceMacAddr (
- EMU_SNP_PRIVATE *Private
+ EMU_SNP_PRIVATE *Private
)
{
EFI_STATUS Status;
@@ -1020,12 +1002,12 @@ GetInterfaceMacAddr (
);
Status = EFI_NOT_FOUND;
- If = IfAddrs;
+ If = IfAddrs;
while (If != NULL) {
IfSdl = (struct sockaddr_dl *)If->ifa_addr;
if (IfSdl->sdl_family == AF_LINK) {
- if (!AsciiStrCmp( Private->InterfaceName, If->ifa_name)) {
+ if (!AsciiStrCmp (Private->InterfaceName, If->ifa_name)) {
CopyMem (&Private->MacAddress, LLADDR (IfSdl), NET_ETHER_ADDR_LEN);
Status = EFI_SUCCESS;
@@ -1041,10 +1023,9 @@ Exit:
return Status;
}
-
EFI_STATUS
EmuSnpThunkOpen (
- IN EMU_IO_THUNK_PROTOCOL *This
+ IN EMU_IO_THUNK_PROTOCOL *This
)
{
EMU_SNP_PRIVATE *Private;
@@ -1062,7 +1043,6 @@ EmuSnpThunkOpen (
return EFI_OUT_OF_RESOURCES;
}
-
Private->Signature = EMU_SNP_PRIVATE_SIGNATURE;
Private->Thunk = This;
CopyMem (&Private->EmuSnp, &gEmuSnpProtocol, sizeof (gEmuSnpProtocol));
@@ -1073,10 +1053,9 @@ EmuSnpThunkOpen (
return EFI_SUCCESS;
}
-
EFI_STATUS
EmuSnpThunkClose (
- IN EMU_IO_THUNK_PROTOCOL *This
+ IN EMU_IO_THUNK_PROTOCOL *This
)
{
EMU_SNP_PRIVATE *Private;
@@ -1091,9 +1070,7 @@ EmuSnpThunkClose (
return EFI_SUCCESS;
}
-
-
-EMU_IO_THUNK_PROTOCOL gSnpThunkIo = {
+EMU_IO_THUNK_PROTOCOL gSnpThunkIo = {
&gEmuSnpProtocolGuid,
NULL,
NULL,
diff --git a/EmulatorPkg/Unix/Host/BlockIo.c b/EmulatorPkg/Unix/Host/BlockIo.c
index e3d7c52a43..cf2d6b4cda 100644
--- a/EmulatorPkg/Unix/Host/BlockIo.c
+++ b/EmulatorPkg/Unix/Host/BlockIo.c
@@ -7,41 +7,37 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "Host.h"
-#define EMU_BLOCK_IO_PRIVATE_SIGNATURE SIGNATURE_32 ('E', 'M', 'b', 'k')
+#define EMU_BLOCK_IO_PRIVATE_SIGNATURE SIGNATURE_32 ('E', 'M', 'b', 'k')
typedef struct {
- UINTN Signature;
+ UINTN Signature;
- EMU_IO_THUNK_PROTOCOL *Thunk;
+ EMU_IO_THUNK_PROTOCOL *Thunk;
- char *Filename;
- UINTN ReadMode;
- UINTN Mode;
+ char *Filename;
+ UINTN ReadMode;
+ UINTN Mode;
- int fd;
+ int fd;
- BOOLEAN RemovableMedia;
- BOOLEAN WriteProtected;
+ BOOLEAN RemovableMedia;
+ BOOLEAN WriteProtected;
- UINT64 NumberOfBlocks;
- UINT32 BlockSize;
-
- EMU_BLOCK_IO_PROTOCOL EmuBlockIo;
- EFI_BLOCK_IO_MEDIA *Media;
+ UINT64 NumberOfBlocks;
+ UINT32 BlockSize;
+ EMU_BLOCK_IO_PROTOCOL EmuBlockIo;
+ EFI_BLOCK_IO_MEDIA *Media;
} EMU_BLOCK_IO_PRIVATE;
#define EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS(a) \
CR(a, EMU_BLOCK_IO_PRIVATE, EmuBlockIo, EMU_BLOCK_IO_PRIVATE_SIGNATURE)
-
-
EFI_STATUS
EmuBlockIoReset (
- IN EMU_BLOCK_IO_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EMU_BLOCK_IO_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
);
-
/*++
This function extends the capability of SetFilePointer to accept 64 bit parameters
@@ -49,18 +45,18 @@ This function extends the capability of SetFilePointer to accept 64 bit paramete
**/
EFI_STATUS
SetFilePointer64 (
- IN EMU_BLOCK_IO_PRIVATE *Private,
- IN INT64 DistanceToMove,
- OUT UINT64 *NewFilePointer,
- IN INT32 MoveMethod
+ IN EMU_BLOCK_IO_PRIVATE *Private,
+ IN INT64 DistanceToMove,
+ OUT UINT64 *NewFilePointer,
+ IN INT32 MoveMethod
)
{
- EFI_STATUS Status;
- off_t res;
- off_t offset = DistanceToMove;
+ EFI_STATUS Status;
+ off_t res;
+ off_t offset = DistanceToMove;
Status = EFI_SUCCESS;
- res = lseek (Private->fd, offset, (int)MoveMethod);
+ res = lseek (Private->fd, offset, (int)MoveMethod);
if (res == -1) {
Status = EFI_INVALID_PARAMETER;
}
@@ -72,16 +68,14 @@ SetFilePointer64 (
return Status;
}
-
EFI_STATUS
EmuBlockIoOpenDevice (
- IN EMU_BLOCK_IO_PRIVATE *Private
+ IN EMU_BLOCK_IO_PRIVATE *Private
)
{
- EFI_STATUS Status;
- UINT64 FileSize;
- struct statfs buf;
-
+ EFI_STATUS Status;
+ UINT64 FileSize;
+ struct statfs buf;
//
// If the device is already opened, close it
@@ -95,9 +89,9 @@ EmuBlockIoOpenDevice (
//
Private->fd = open (Private->Filename, Private->Mode, 0644);
if (Private->fd < 0) {
- printf ("EmuOpenBlock: Could not open %s: %s\n", Private->Filename, strerror(errno));
- Private->Media->MediaPresent = FALSE;
- Status = EFI_NO_MEDIA;
+ printf ("EmuOpenBlock: Could not open %s: %s\n", Private->Filename, strerror (errno));
+ Private->Media->MediaPresent = FALSE;
+ Status = EFI_NO_MEDIA;
goto Done;
}
@@ -120,13 +114,14 @@ EmuBlockIoOpenDevice (
if (FileSize == 0) {
// lseek fails on a real device. ioctl calls are OS specific
-#if __APPLE__
+ #if __APPLE__
{
- UINT32 BlockSize;
+ UINT32 BlockSize;
if (ioctl (Private->fd, DKIOCGETBLOCKSIZE, &BlockSize) == 0) {
Private->Media->BlockSize = BlockSize;
}
+
if (ioctl (Private->fd, DKIOCGETBLOCKCOUNT, &Private->NumberOfBlocks) == 0) {
if ((Private->NumberOfBlocks == 0) && (BlockSize == 0x800)) {
// A DVD is ~ 4.37 GB so make up a number
@@ -135,34 +130,35 @@ EmuBlockIoOpenDevice (
Private->Media->LastBlock = Private->NumberOfBlocks - 1;
}
}
+
ioctl (Private->fd, DKIOCGETMAXBLOCKCOUNTWRITE, &Private->Media->OptimalTransferLengthGranularity);
}
-#else
+ #else
{
- size_t BlockSize;
- UINT64 DiskSize;
+ size_t BlockSize;
+ UINT64 DiskSize;
if (ioctl (Private->fd, BLKSSZGET, &BlockSize) == 0) {
Private->Media->BlockSize = BlockSize;
}
+
if (ioctl (Private->fd, BLKGETSIZE64, &DiskSize) == 0) {
- Private->NumberOfBlocks = DivU64x32 (DiskSize, (UINT32)BlockSize);
+ Private->NumberOfBlocks = DivU64x32 (DiskSize, (UINT32)BlockSize);
Private->Media->LastBlock = Private->NumberOfBlocks - 1;
}
}
-#endif
-
+ #endif
} else {
Private->Media->BlockSize = Private->BlockSize;
- Private->NumberOfBlocks = DivU64x32 (FileSize, Private->Media->BlockSize);
+ Private->NumberOfBlocks = DivU64x32 (FileSize, Private->Media->BlockSize);
Private->Media->LastBlock = Private->NumberOfBlocks - 1;
if (fstatfs (Private->fd, &buf) == 0) {
-#if __APPLE__
+ #if __APPLE__
Private->Media->OptimalTransferLengthGranularity = buf.f_iosize/buf.f_bsize;
-#else
+ #else
Private->Media->OptimalTransferLengthGranularity = buf.f_bsize/buf.f_bsize;
-#endif
+ #endif
}
}
@@ -179,15 +175,14 @@ Done:
return Status;
}
-
EFI_STATUS
EmuBlockIoCreateMapping (
- IN EMU_BLOCK_IO_PROTOCOL *This,
- IN EFI_BLOCK_IO_MEDIA *Media
+ IN EMU_BLOCK_IO_PROTOCOL *This,
+ IN EFI_BLOCK_IO_MEDIA *Media
)
{
- EFI_STATUS Status;
- EMU_BLOCK_IO_PRIVATE *Private;
+ EFI_STATUS Status;
+ EMU_BLOCK_IO_PRIVATE *Private;
Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);
@@ -206,66 +201,61 @@ EmuBlockIoCreateMapping (
Media->LowestAlignedLba = 0;
Media->LogicalBlocksPerPhysicalBlock = 0;
-
// EFI_BLOCK_IO_PROTOCOL_REVISION3
Media->OptimalTransferLengthGranularity = 0;
Status = EmuBlockIoOpenDevice (Private);
-
return Status;
}
-
EFI_STATUS
EmuBlockIoError (
- IN EMU_BLOCK_IO_PRIVATE *Private
+ IN EMU_BLOCK_IO_PRIVATE *Private
)
{
- EFI_STATUS Status;
- BOOLEAN ReinstallBlockIoFlag;
-
+ EFI_STATUS Status;
+ BOOLEAN ReinstallBlockIoFlag;
switch (errno) {
-
- case EAGAIN:
- Status = EFI_NO_MEDIA;
- Private->Media->ReadOnly = FALSE;
- Private->Media->MediaPresent = FALSE;
- ReinstallBlockIoFlag = FALSE;
- break;
-
- case EACCES:
- Private->Media->ReadOnly = FALSE;
- Private->Media->MediaPresent = TRUE;
- Private->Media->MediaId += 1;
- ReinstallBlockIoFlag = TRUE;
- Status = EFI_MEDIA_CHANGED;
- break;
-
- case EROFS:
- Private->Media->ReadOnly = TRUE;
- ReinstallBlockIoFlag = FALSE;
- Status = EFI_WRITE_PROTECTED;
- break;
-
- default:
- ReinstallBlockIoFlag = FALSE;
- Status = EFI_DEVICE_ERROR;
- break;
+ case EAGAIN:
+ Status = EFI_NO_MEDIA;
+ Private->Media->ReadOnly = FALSE;
+ Private->Media->MediaPresent = FALSE;
+ ReinstallBlockIoFlag = FALSE;
+ break;
+
+ case EACCES:
+ Private->Media->ReadOnly = FALSE;
+ Private->Media->MediaPresent = TRUE;
+ Private->Media->MediaId += 1;
+ ReinstallBlockIoFlag = TRUE;
+ Status = EFI_MEDIA_CHANGED;
+ break;
+
+ case EROFS:
+ Private->Media->ReadOnly = TRUE;
+ ReinstallBlockIoFlag = FALSE;
+ Status = EFI_WRITE_PROTECTED;
+ break;
+
+ default:
+ ReinstallBlockIoFlag = FALSE;
+ Status = EFI_DEVICE_ERROR;
+ break;
}
+
return Status;
}
-
EFI_STATUS
EmuBlockIoReadWriteCommon (
- IN EMU_BLOCK_IO_PRIVATE *Private,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- IN VOID *Buffer,
- IN CHAR8 *CallerName
+ IN EMU_BLOCK_IO_PRIVATE *Private,
+ IN UINT32 MediaId,
+ IN EFI_LBA Lba,
+ IN UINTN BufferSize,
+ IN VOID *Buffer,
+ IN CHAR8 *CallerName
)
{
EFI_STATUS Status;
@@ -290,7 +280,7 @@ EmuBlockIoReadWriteCommon (
return EFI_MEDIA_CHANGED;
}
- if ((UINTN) Buffer % Private->Media->IoAlign != 0) {
+ if ((UINTN)Buffer % Private->Media->IoAlign != 0) {
return EFI_INVALID_PARAMETER;
}
@@ -313,11 +303,12 @@ EmuBlockIoReadWriteCommon (
DEBUG ((DEBUG_INIT, "ReadBlocks: Attempted to read off end of device\n"));
return EFI_INVALID_PARAMETER;
}
+
//
// Seek to End of File
//
DistanceToMove = MultU64x32 (Lba, BlockSize);
- Status = SetFilePointer64 (Private, DistanceToMove, &DistanceMoved, SEEK_SET);
+ Status = SetFilePointer64 (Private, DistanceToMove, &DistanceMoved, SEEK_SET);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INIT, "WriteBlocks: SetFilePointer failed\n"));
@@ -327,7 +318,6 @@ EmuBlockIoReadWriteCommon (
return EFI_SUCCESS;
}
-
/**
Read BufferSize bytes from Lba into Buffer.
@@ -368,16 +358,16 @@ EmuBlockIoReadBlocks (
IN EFI_LBA LBA,
IN OUT EFI_BLOCK_IO2_TOKEN *Token,
IN UINTN BufferSize,
- OUT VOID *Buffer
+ OUT VOID *Buffer
)
{
- EFI_STATUS Status;
- EMU_BLOCK_IO_PRIVATE *Private;
- ssize_t len;
+ EFI_STATUS Status;
+ EMU_BLOCK_IO_PRIVATE *Private;
+ ssize_t len;
Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);
- Status = EmuBlockIoReadWriteCommon (Private, MediaId, LBA, BufferSize, Buffer, "UnixReadBlocks");
+ Status = EmuBlockIoReadWriteCommon (Private, MediaId, LBA, BufferSize, Buffer, "UnixReadBlocks");
if (EFI_ERROR (Status)) {
goto Done;
}
@@ -393,7 +383,7 @@ EmuBlockIoReadBlocks (
// If we read then media is present.
//
Private->Media->MediaPresent = TRUE;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
Done:
if (Token != NULL) {
@@ -403,10 +393,10 @@ Done:
return EFI_SUCCESS;
}
}
+
return Status;
}
-
/**
Write BufferSize bytes from Lba into Buffer.
@@ -448,14 +438,13 @@ EmuBlockIoWriteBlocks (
IN VOID *Buffer
)
{
- EMU_BLOCK_IO_PRIVATE *Private;
- ssize_t len;
- EFI_STATUS Status;
-
+ EMU_BLOCK_IO_PRIVATE *Private;
+ ssize_t len;
+ EFI_STATUS Status;
Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);
- Status = EmuBlockIoReadWriteCommon (Private, MediaId, LBA, BufferSize, Buffer, "UnixWriteBlocks");
+ Status = EmuBlockIoReadWriteCommon (Private, MediaId, LBA, BufferSize, Buffer, "UnixWriteBlocks");
if (EFI_ERROR (Status)) {
goto Done;
}
@@ -472,7 +461,7 @@ EmuBlockIoWriteBlocks (
//
Private->Media->MediaPresent = TRUE;
Private->Media->ReadOnly = FALSE;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
Done:
if (Token != NULL) {
@@ -486,7 +475,6 @@ Done:
return Status;
}
-
/**
Flush the Block Device.
@@ -511,22 +499,21 @@ Done:
**/
EFI_STATUS
EmuBlockIoFlushBlocks (
- IN EMU_BLOCK_IO_PROTOCOL *This,
- IN OUT EFI_BLOCK_IO2_TOKEN *Token
+ IN EMU_BLOCK_IO_PROTOCOL *This,
+ IN OUT EFI_BLOCK_IO2_TOKEN *Token
)
{
- EMU_BLOCK_IO_PRIVATE *Private;
+ EMU_BLOCK_IO_PRIVATE *Private;
Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);
if (Private->fd >= 0) {
fsync (Private->fd);
-#if __APPLE__
+ #if __APPLE__
fcntl (Private->fd, F_FULLFSYNC);
-#endif
+ #endif
}
-
if (Token != NULL) {
if (Token->Event != NULL) {
// Caller is responsible for signaling EFI Event
@@ -538,7 +525,6 @@ EmuBlockIoFlushBlocks (
return EFI_SUCCESS;
}
-
/**
Reset the block device hardware.
@@ -554,11 +540,11 @@ EmuBlockIoFlushBlocks (
**/
EFI_STATUS
EmuBlockIoReset (
- IN EMU_BLOCK_IO_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EMU_BLOCK_IO_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
)
{
- EMU_BLOCK_IO_PRIVATE *Private;
+ EMU_BLOCK_IO_PRIVATE *Private;
Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);
@@ -570,17 +556,16 @@ EmuBlockIoReset (
return EFI_SUCCESS;
}
-
char *
StdDupUnicodeToAscii (
- IN CHAR16 *Str
+ IN CHAR16 *Str
)
{
- UINTN Size;
- char *Ascii;
- char *Ptr;
+ UINTN Size;
+ char *Ascii;
+ char *Ptr;
- Size = StrLen (Str) + 1;
+ Size = StrLen (Str) + 1;
Ascii = malloc (Size);
if (Ascii == NULL) {
return NULL;
@@ -589,13 +574,13 @@ StdDupUnicodeToAscii (
for (Ptr = Ascii; *Str != '\0'; Ptr++, Str++) {
*Ptr = *Str;
}
+
*Ptr = 0;
return Ascii;
}
-
-EMU_BLOCK_IO_PROTOCOL gEmuBlockIoProtocol = {
+EMU_BLOCK_IO_PROTOCOL gEmuBlockIoProtocol = {
GasketEmuBlockIoReset,
GasketEmuBlockIoReadBlocks,
GasketEmuBlockIoWriteBlocks,
@@ -605,7 +590,7 @@ EMU_BLOCK_IO_PROTOCOL gEmuBlockIoProtocol = {
EFI_STATUS
EmuBlockIoThunkOpen (
- IN EMU_IO_THUNK_PROTOCOL *This
+ IN EMU_IO_THUNK_PROTOCOL *This
)
{
EMU_BLOCK_IO_PRIVATE *Private;
@@ -624,7 +609,6 @@ EmuBlockIoThunkOpen (
return EFI_OUT_OF_RESOURCES;
}
-
Private->Signature = EMU_BLOCK_IO_PRIVATE_SIGNATURE;
Private->Thunk = This;
CopyMem (&Private->EmuBlockIo, &gEmuBlockIoProtocol, sizeof (gEmuBlockIoProtocol));
@@ -642,12 +626,14 @@ EmuBlockIoThunkOpen (
Private->WriteProtected = FALSE;
} else {
for (*Str++ = '\0'; *Str != 0; Str++) {
- if (*Str == 'R' || *Str == 'F') {
- Private->RemovableMedia = (BOOLEAN) (*Str == 'R');
+ if ((*Str == 'R') || (*Str == 'F')) {
+ Private->RemovableMedia = (BOOLEAN)(*Str == 'R');
}
- if (*Str == 'O' || *Str == 'W') {
- Private->WriteProtected = (BOOLEAN) (*Str == 'O');
+
+ if ((*Str == 'O') || (*Str == 'W')) {
+ Private->WriteProtected = (BOOLEAN)(*Str == 'O');
}
+
if (*Str == ':') {
Private->BlockSize = strtol (++Str, NULL, 0);
break;
@@ -662,10 +648,9 @@ EmuBlockIoThunkOpen (
return EFI_SUCCESS;
}
-
EFI_STATUS
EmuBlockIoThunkClose (
- IN EMU_IO_THUNK_PROTOCOL *This
+ IN EMU_IO_THUNK_PROTOCOL *This
)
{
EMU_BLOCK_IO_PRIVATE *Private;
@@ -680,6 +665,7 @@ EmuBlockIoThunkClose (
if (Private->Filename != NULL) {
free (Private->Filename);
}
+
free (This->Private);
This->Private = NULL;
}
@@ -687,9 +673,7 @@ EmuBlockIoThunkClose (
return EFI_SUCCESS;
}
-
-
-EMU_IO_THUNK_PROTOCOL gBlockIoThunkIo = {
+EMU_IO_THUNK_PROTOCOL gBlockIoThunkIo = {
&gEmuBlockIoProtocolGuid,
NULL,
NULL,
diff --git a/EmulatorPkg/Unix/Host/EmuThunk.c b/EmulatorPkg/Unix/Host/EmuThunk.c
index b8b0651c6a..6422f056a6 100644
--- a/EmulatorPkg/Unix/Host/EmuThunk.c
+++ b/EmulatorPkg/Unix/Host/EmuThunk.c
@@ -18,43 +18,41 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "Host.h"
#ifdef __APPLE__
-#define DebugAssert _Mangle__DebugAssert
+#define DebugAssert _Mangle__DebugAssert
-#include <assert.h>
-#include <CoreServices/CoreServices.h>
-#include <mach/mach.h>
-#include <mach/mach_time.h>
+ #include <assert.h>
+ #include <CoreServices/CoreServices.h>
+ #include <mach/mach.h>
+ #include <mach/mach_time.h>
-#undef DebugAssert
+ #undef DebugAssert
#endif
-int settimer_initialized;
-struct timeval settimer_timeval;
-UINTN settimer_callback = 0;
-
-BOOLEAN gEmulatorInterruptEnabled = FALSE;
+int settimer_initialized;
+struct timeval settimer_timeval;
+UINTN settimer_callback = 0;
+BOOLEAN gEmulatorInterruptEnabled = FALSE;
UINTN
SecWriteStdErr (
- IN UINT8 *Buffer,
- IN UINTN NumberOfBytes
+ IN UINT8 *Buffer,
+ IN UINTN NumberOfBytes
)
{
- ssize_t Return;
+ ssize_t Return;
Return = write (STDERR_FILENO, (const void *)Buffer, (size_t)NumberOfBytes);
return (Return == -1) ? 0 : Return;
}
-
EFI_STATUS
SecConfigStdIn (
VOID
)
{
- struct termios tty;
+ struct termios tty;
//
// Need to turn off line buffering, ECHO, and make it unbuffered.
@@ -63,7 +61,7 @@ SecConfigStdIn (
tty.c_lflag &= ~(ICANON | ECHO);
tcsetattr (STDIN_FILENO, TCSANOW, &tty);
-// setvbuf (STDIN_FILENO, NULL, _IONBF, 0);
+ // setvbuf (STDIN_FILENO, NULL, _IONBF, 0);
// now ioctl FIONREAD will do what we need
return EFI_SUCCESS;
@@ -71,11 +69,11 @@ SecConfigStdIn (
UINTN
SecWriteStdOut (
- IN UINT8 *Buffer,
- IN UINTN NumberOfBytes
+ IN UINT8 *Buffer,
+ IN UINTN NumberOfBytes
)
{
- ssize_t Return;
+ ssize_t Return;
Return = write (STDOUT_FILENO, (const void *)Buffer, (size_t)NumberOfBytes);
@@ -84,11 +82,11 @@ SecWriteStdOut (
UINTN
SecReadStdIn (
- IN UINT8 *Buffer,
- IN UINTN NumberOfBytes
+ IN UINT8 *Buffer,
+ IN UINTN NumberOfBytes
)
{
- ssize_t Return;
+ ssize_t Return;
Return = read (STDIN_FILENO, Buffer, (size_t)NumberOfBytes);
@@ -100,8 +98,8 @@ SecPollStdIn (
VOID
)
{
- int Result;
- int Bytes;
+ int Result;
+ int Bytes;
Result = ioctl (STDIN_FILENO, FIONREAD, &Bytes);
if (Result == -1) {
@@ -111,10 +109,9 @@ SecPollStdIn (
return (BOOLEAN)(Bytes > 0);
}
-
VOID *
SecMalloc (
- IN UINTN Size
+ IN UINTN Size
)
{
return malloc ((size_t)Size);
@@ -122,7 +119,7 @@ SecMalloc (
VOID *
SecValloc (
- IN UINTN Size
+ IN UINTN Size
)
{
return valloc ((size_t)Size);
@@ -130,7 +127,7 @@ SecValloc (
BOOLEAN
SecFree (
- IN VOID *Ptr
+ IN VOID *Ptr
)
{
if (EfiSystemMemoryRange (Ptr)) {
@@ -143,17 +140,18 @@ SecFree (
return TRUE;
}
-
void
-settimer_handler (int sig)
+settimer_handler (
+ int sig
+ )
{
- struct timeval timeval;
- UINT64 delta;
+ struct timeval timeval;
+ UINT64 delta;
gettimeofday (&timeval, NULL);
delta = ((UINT64)timeval.tv_sec * 1000) + (timeval.tv_usec / 1000)
- - ((UINT64)settimer_timeval.tv_sec * 1000)
- - (settimer_timeval.tv_usec / 1000);
+ - ((UINT64)settimer_timeval.tv_sec * 1000)
+ - (settimer_timeval.tv_usec / 1000);
settimer_timeval = timeval;
if (settimer_callback) {
@@ -167,37 +165,39 @@ SecSetTimer (
IN EMU_SET_TIMER_CALLBACK CallBack
)
{
- struct itimerval timerval;
- UINT32 remainder;
+ struct itimerval timerval;
+ UINT32 remainder;
if (!settimer_initialized) {
- struct sigaction act;
+ struct sigaction act;
settimer_initialized = 1;
- act.sa_handler = settimer_handler;
- act.sa_flags = 0;
+ act.sa_handler = settimer_handler;
+ act.sa_flags = 0;
sigemptyset (&act.sa_mask);
gEmulatorInterruptEnabled = TRUE;
if (sigaction (SIGALRM, &act, NULL) != 0) {
printf ("SetTimer: sigaction error %s\n", strerror (errno));
}
+
if (gettimeofday (&settimer_timeval, NULL) != 0) {
printf ("SetTimer: gettimeofday error %s\n", strerror (errno));
}
}
- timerval.it_value.tv_sec = DivU64x32(PeriodMs, 1000);
- DivU64x32Remainder(PeriodMs, 1000, &remainder);
+
+ timerval.it_value.tv_sec = DivU64x32 (PeriodMs, 1000);
+ DivU64x32Remainder (PeriodMs, 1000, &remainder);
timerval.it_value.tv_usec = remainder * 1000;
- timerval.it_value.tv_sec = DivU64x32(PeriodMs, 1000);
- timerval.it_interval = timerval.it_value;
+ timerval.it_value.tv_sec = DivU64x32 (PeriodMs, 1000);
+ timerval.it_interval = timerval.it_value;
if (setitimer (ITIMER_REAL, &timerval, NULL) != 0) {
printf ("SetTimer: setitimer error %s\n", strerror (errno));
}
+
settimer_callback = (UINTN)CallBack;
}
-
VOID
SecEnableInterrupt (
VOID
@@ -213,7 +213,6 @@ SecEnableInterrupt (
pthread_sigmask (SIG_UNBLOCK, &sigset, NULL);
}
-
VOID
SecDisableInterrupt (
VOID
@@ -229,14 +228,14 @@ SecDisableInterrupt (
gEmulatorInterruptEnabled = FALSE;
}
-
BOOLEAN
-SecInterruptEanbled (void)
+SecInterruptEanbled (
+ void
+ )
{
return gEmulatorInterruptEnabled;
}
-
UINT64
QueryPerformanceFrequency (
VOID
@@ -251,10 +250,9 @@ QueryPerformanceCounter (
VOID
)
{
-#if __APPLE__
- UINT64 Start;
- static mach_timebase_info_data_t sTimebaseInfo;
-
+ #if __APPLE__
+ UINT64 Start;
+ static mach_timebase_info_data_t sTimebaseInfo;
Start = mach_absolute_time ();
@@ -266,29 +264,27 @@ QueryPerformanceCounter (
// denominator is a fraction.
if ( sTimebaseInfo.denom == 0 ) {
- (void) mach_timebase_info(&sTimebaseInfo);
+ (void)mach_timebase_info (&sTimebaseInfo);
}
// Do the maths. We hope that the multiplication doesn't
// overflow; the price you pay for working in fixed point.
return (Start * sTimebaseInfo.numer) / sTimebaseInfo.denom;
-#else
+ #else
// Need to figure out what to do for Linux?
return 0;
-#endif
+ #endif
}
-
-
VOID
SecSleep (
- IN UINT64 Nanoseconds
+ IN UINT64 Nanoseconds
)
{
- struct timespec rq, rm;
- struct timeval start, end;
- unsigned long MicroSec;
+ struct timespec rq, rm;
+ struct timeval start, end;
+ unsigned long MicroSec;
rq.tv_sec = DivU64x32 (Nanoseconds, 1000000000);
rq.tv_nsec = ModU64x32 (Nanoseconds, 1000000000);
@@ -299,7 +295,7 @@ SecSleep (
//
gettimeofday (&start, NULL);
end.tv_sec = start.tv_sec + rq.tv_sec;
- MicroSec = (start.tv_usec + rq.tv_nsec/1000);
+ MicroSec = (start.tv_usec + rq.tv_nsec/1000);
end.tv_usec = MicroSec % 1000000;
if (MicroSec > 1000000) {
end.tv_sec++;
@@ -309,23 +305,26 @@ SecSleep (
if (errno != EINTR) {
break;
}
+
gettimeofday (&start, NULL);
if (start.tv_sec > end.tv_sec) {
break;
- } if ((start.tv_sec == end.tv_sec) && (start.tv_usec > end.tv_usec)) {
+ }
+
+ if ((start.tv_sec == end.tv_sec) && (start.tv_usec > end.tv_usec)) {
break;
}
+
rq = rm;
}
}
-
VOID
SecCpuSleep (
VOID
)
{
- struct timespec rq, rm;
+ struct timespec rq, rm;
// nanosleep gets interrupted by the timer tic
rq.tv_sec = 1;
@@ -334,51 +333,47 @@ SecCpuSleep (
nanosleep (&rq, &rm);
}
-
VOID
SecExit (
- UINTN Status
+ UINTN Status
)
{
exit (Status);
}
-
VOID
SecGetTime (
- OUT EFI_TIME *Time,
- OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL
+ OUT EFI_TIME *Time,
+ OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL
)
{
- struct tm *tm;
- time_t t;
+ struct tm *tm;
+ time_t t;
- t = time (NULL);
+ t = time (NULL);
tm = localtime (&t);
- Time->Year = 1900 + tm->tm_year;
- Time->Month = tm->tm_mon + 1;
- Time->Day = tm->tm_mday;
- Time->Hour = tm->tm_hour;
- Time->Minute = tm->tm_min;
- Time->Second = tm->tm_sec;
+ Time->Year = 1900 + tm->tm_year;
+ Time->Month = tm->tm_mon + 1;
+ Time->Day = tm->tm_mday;
+ Time->Hour = tm->tm_hour;
+ Time->Minute = tm->tm_min;
+ Time->Second = tm->tm_sec;
Time->Nanosecond = 0;
- Time->TimeZone = timezone / 60;
- Time->Daylight = (daylight ? EFI_TIME_ADJUST_DAYLIGHT : 0)
- | (tm->tm_isdst > 0 ? EFI_TIME_IN_DAYLIGHT : 0);
+ Time->TimeZone = timezone / 60;
+ Time->Daylight = (daylight ? EFI_TIME_ADJUST_DAYLIGHT : 0)
+ | (tm->tm_isdst > 0 ? EFI_TIME_IN_DAYLIGHT : 0);
if (Capabilities != NULL) {
- Capabilities->Resolution = 1;
- Capabilities->Accuracy = 50000000;
- Capabilities->SetsToZero = FALSE;
+ Capabilities->Resolution = 1;
+ Capabilities->Accuracy = 50000000;
+ Capabilities->SetsToZero = FALSE;
}
}
-
-
VOID
SecSetTime (
- IN EFI_TIME *Time
+ IN EFI_TIME *Time
)
{
// Don't change the time on the system
@@ -386,18 +381,16 @@ SecSetTime (
return;
}
-
EFI_STATUS
SecGetNextProtocol (
- IN BOOLEAN EmuBusDriver,
- OUT EMU_IO_THUNK_PROTOCOL **Instance OPTIONAL
+ IN BOOLEAN EmuBusDriver,
+ OUT EMU_IO_THUNK_PROTOCOL **Instance OPTIONAL
)
{
return GetNextThunkProtocol (EmuBusDriver, Instance);
}
-
-EMU_THUNK_PROTOCOL gEmuThunkProtocol = {
+EMU_THUNK_PROTOCOL gEmuThunkProtocol = {
GasketSecWriteStdErr,
GasketSecConfigStdIn,
GasketSecWriteStdOut,
@@ -422,7 +415,6 @@ EMU_THUNK_PROTOCOL gEmuThunkProtocol = {
GasketSecGetNextProtocol
};
-
VOID
SecInitThunkProtocol (
VOID
@@ -431,4 +423,3 @@ SecInitThunkProtocol (
// timezone and daylight lib globals depend on tzset be called 1st.
tzset ();
}
-
diff --git a/EmulatorPkg/Unix/Host/Gasket.h b/EmulatorPkg/Unix/Host/Gasket.h
index e082397d23..6dafc903cf 100644
--- a/EmulatorPkg/Unix/Host/Gasket.h
+++ b/EmulatorPkg/Unix/Host/Gasket.h
@@ -17,8 +17,8 @@
UINTN
EFIAPI
GasketSecWriteStdErr (
- IN UINT8 *Buffer,
- IN UINTN NumberOfBytes
+ IN UINT8 *Buffer,
+ IN UINTN NumberOfBytes
);
EFI_STATUS
@@ -30,15 +30,15 @@ GasketSecConfigStdIn (
UINTN
EFIAPI
GasketSecWriteStdOut (
- IN UINT8 *Buffer,
- IN UINTN NumberOfBytes
+ IN UINT8 *Buffer,
+ IN UINTN NumberOfBytes
);
UINTN
EFIAPI
GasketSecReadStdIn (
- IN UINT8 *Buffer,
- IN UINTN NumberOfBytes
+ IN UINT8 *Buffer,
+ IN UINTN NumberOfBytes
);
BOOLEAN
@@ -50,22 +50,21 @@ GasketSecPollStdIn (
VOID *
EFIAPI
GasketSecMalloc (
- IN UINTN Size
+ IN UINTN Size
);
VOID *
EFIAPI
GasketSecValloc (
- IN UINTN Size
+ IN UINTN Size
);
BOOLEAN
EFIAPI
GasketSecFree (
- IN VOID *Ptr
+ IN VOID *Ptr
);
-
RETURN_STATUS
EFIAPI
GasketSecPeCoffGetEntryPoint (
@@ -116,11 +115,10 @@ GasketQueryPerformanceCounter (
VOID
);
-
VOID
EFIAPI
GasketSecSleep (
- IN UINT64 Nanoseconds
+ IN UINT64 Nanoseconds
);
VOID
@@ -132,33 +130,31 @@ GasketSecCpuSleep (
VOID
EFIAPI
GasketSecExit (
- UINTN Status
+ UINTN Status
);
VOID
EFIAPI
GasketSecGetTime (
- OUT EFI_TIME *Time,
- OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL
+ OUT EFI_TIME *Time,
+ OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL
);
VOID
EFIAPI
GasketSecSetTime (
- IN EFI_TIME *Time
+ IN EFI_TIME *Time
);
EFI_STATUS
EFIAPI
GasketSecGetNextProtocol (
- IN BOOLEAN EmuBusDriver,
- OUT EMU_IO_THUNK_PROTOCOL **Instance OPTIONAL
+ IN BOOLEAN EmuBusDriver,
+ OUT EMU_IO_THUNK_PROTOCOL **Instance OPTIONAL
);
-
// PPIs produced by SEC
-
EFI_STATUS
EFIAPI
GasketSecUnixPeiAutoScan (
@@ -173,7 +169,6 @@ GasketSecEmuThunkAddress (
VOID
);
-
EFI_STATUS
EFIAPI
GasketSecUnixUnixFwhAddress (
@@ -181,55 +176,52 @@ GasketSecUnixUnixFwhAddress (
IN OUT EFI_PHYSICAL_ADDRESS *FwhBase
);
-
-
//
// Reverse (UNIX to EFIAPI) gaskets
//
typedef
void
-(EFIAPI *CALL_BACK) (
+(EFIAPI *CALL_BACK)(
UINT64 Delta
);
UINTN
ReverseGasketUint64 (
- UINTN CallBack,
- UINT64 a
+ UINTN CallBack,
+ UINT64 a
);
UINTN
ReverseGasketUint64Uint64 (
- VOID *CallBack,
- VOID *Context,
- VOID *Key
+ VOID *CallBack,
+ VOID *Context,
+ VOID *Key
);
//
// Gasket functions for EFI_EMU_UGA_IO_PROTOCOL
//
-
EFI_STATUS
EFIAPI
GasketX11Size (
- EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindowsIo,
- UINT32 Width,
- UINT32 Height
+ EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindowsIo,
+ UINT32 Width,
+ UINT32 Height
);
EFI_STATUS
EFIAPI
GasketX11CheckKey (
- EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindowsIo
+ EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindowsIo
);
EFI_STATUS
EFIAPI
GasketX11GetKey (
- EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindowsIo,
- EFI_KEY_DATA *key
+ EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindowsIo,
+ EFI_KEY_DATA *key
);
EFI_STATUS
@@ -242,45 +234,44 @@ GasketX11KeySetState (
EFI_STATUS
EFIAPI
GasketX11RegisterKeyNotify (
- IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindowsIo,
- IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK MakeCallBack,
- IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK BreakCallBack,
- IN VOID *Context
+ IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindowsIo,
+ IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK MakeCallBack,
+ IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK BreakCallBack,
+ IN VOID *Context
);
-
EFI_STATUS
EFIAPI
GasketX11Blt (
- IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows,
- IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,
- IN EFI_UGA_BLT_OPERATION BltOperation,
- IN EMU_GRAPHICS_WINDOWS__BLT_ARGS *Args
+ IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows,
+ IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,
+ IN EFI_UGA_BLT_OPERATION BltOperation,
+ IN EMU_GRAPHICS_WINDOWS__BLT_ARGS *Args
);
EFI_STATUS
EFIAPI
GasketX11CheckPointer (
- EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindowsIo
+ EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindowsIo
);
EFI_STATUS
EFIAPI
GasketX11GetPointerState (
- EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindowsIo,
- EFI_SIMPLE_POINTER_STATE *state
+ EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindowsIo,
+ EFI_SIMPLE_POINTER_STATE *state
);
EFI_STATUS
EFIAPI
GasketX11GraphicsWindowOpen (
- IN EMU_IO_THUNK_PROTOCOL *This
+ IN EMU_IO_THUNK_PROTOCOL *This
);
EFI_STATUS
EFIAPI
GasketX11GraphicsWindowClose (
- IN EMU_IO_THUNK_PROTOCOL *This
+ IN EMU_IO_THUNK_PROTOCOL *This
);
// Pthreads
@@ -288,55 +279,48 @@ GasketX11GraphicsWindowClose (
UINTN
EFIAPI
GasketPthreadMutexLock (
- IN VOID *Mutex
+ IN VOID *Mutex
);
-
-
UINTN
EFIAPI
GasketPthreadMutexUnLock (
- IN VOID *Mutex
+ IN VOID *Mutex
);
-
UINTN
EFIAPI
GasketPthreadMutexTryLock (
- IN VOID *Mutex
+ IN VOID *Mutex
);
-
VOID *
EFIAPI
GasketPthreadMutexInit (
IN VOID
);
-
UINTN
EFIAPI
GasketPthreadMutexDestroy (
- IN VOID *Mutex
+ IN VOID *Mutex
);
-
UINTN
EFIAPI
GasketPthreadCreate (
- IN VOID *Thread,
- IN VOID *Attribute,
- IN THREAD_THUNK_THREAD_ENTRY Start,
- IN VOID *Context
+ IN VOID *Thread,
+ IN VOID *Attribute,
+ IN THREAD_THUNK_THREAD_ENTRY Start,
+ IN VOID *Context
);
VOID
EFIAPI
GasketPthreadExit (
- IN VOID *ValuePtr
+ IN VOID *ValuePtr
);
-
UINTN
EFIAPI
GasketPthreadSelf (
@@ -346,33 +330,32 @@ GasketPthreadSelf (
EFI_STATUS
EFIAPI
GasketPthreadOpen (
- IN EMU_IO_THUNK_PROTOCOL *This
+ IN EMU_IO_THUNK_PROTOCOL *This
);
EFI_STATUS
EFIAPI
GasketPthreadClose (
- IN EMU_IO_THUNK_PROTOCOL *This
+ IN EMU_IO_THUNK_PROTOCOL *This
);
-
// PosixFileSystem
EFI_STATUS
EFIAPI
GasketPosixOpenVolume (
- IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,
- OUT EFI_FILE_PROTOCOL **Root
+ IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,
+ OUT EFI_FILE_PROTOCOL **Root
);
EFI_STATUS
EFIAPI
GasketPosixFileOpen (
- IN EFI_FILE_PROTOCOL *This,
- OUT EFI_FILE_PROTOCOL **NewHandle,
- IN CHAR16 *FileName,
- IN UINT64 OpenMode,
- IN UINT64 Attributes
+ IN EFI_FILE_PROTOCOL *This,
+ OUT EFI_FILE_PROTOCOL **NewHandle,
+ IN CHAR16 *FileName,
+ IN UINT64 OpenMode,
+ IN UINT64 Attributes
);
EFI_STATUS
@@ -390,49 +373,49 @@ GasketPosixFileDelete (
EFI_STATUS
EFIAPI
GasketPosixFileRead (
- IN EFI_FILE_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
);
EFI_STATUS
EFIAPI
GasketPosixFileWrite (
- IN EFI_FILE_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- IN VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN OUT UINTN *BufferSize,
+ IN VOID *Buffer
);
EFI_STATUS
EFIAPI
GasketPosixFileSetPossition (
- IN EFI_FILE_PROTOCOL *This,
- IN UINT64 Position
+ IN EFI_FILE_PROTOCOL *This,
+ IN UINT64 Position
);
EFI_STATUS
EFIAPI
GasketPosixFileGetPossition (
- IN EFI_FILE_PROTOCOL *This,
- OUT UINT64 *Position
+ IN EFI_FILE_PROTOCOL *This,
+ OUT UINT64 *Position
);
EFI_STATUS
EFIAPI
GasketPosixFileGetInfo (
- IN EFI_FILE_PROTOCOL *This,
- IN EFI_GUID *InformationType,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN EFI_GUID *InformationType,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
);
EFI_STATUS
EFIAPI
GasketPosixFileSetInfo (
- IN EFI_FILE_PROTOCOL *This,
- IN EFI_GUID *InformationType,
- IN UINTN BufferSize,
- IN VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN EFI_GUID *InformationType,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
);
EFI_STATUS
@@ -444,20 +427,20 @@ GasketPosixFileFlush (
EFI_STATUS
EFIAPI
GasketPosixFileSystmeThunkOpen (
- IN EMU_IO_THUNK_PROTOCOL *This
+ IN EMU_IO_THUNK_PROTOCOL *This
);
EFI_STATUS
EFIAPI
GasketPosixFileSystmeThunkClose (
- IN EMU_IO_THUNK_PROTOCOL *This
+ IN EMU_IO_THUNK_PROTOCOL *This
);
EFI_STATUS
EFIAPI
GasketEmuBlockIoReset (
- IN EMU_BLOCK_IO_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EMU_BLOCK_IO_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
);
EFI_STATUS
@@ -468,7 +451,7 @@ GasketEmuBlockIoReadBlocks (
IN EFI_LBA LBA,
IN OUT EFI_BLOCK_IO2_TOKEN *Token,
IN UINTN BufferSize,
- OUT VOID *Buffer
+ OUT VOID *Buffer
);
EFI_STATUS
@@ -485,39 +468,39 @@ GasketEmuBlockIoWriteBlocks (
EFI_STATUS
EFIAPI
GasketEmuBlockIoFlushBlocks (
- IN EMU_BLOCK_IO_PROTOCOL *This,
- IN OUT EFI_BLOCK_IO2_TOKEN *Token
+ IN EMU_BLOCK_IO_PROTOCOL *This,
+ IN OUT EFI_BLOCK_IO2_TOKEN *Token
);
EFI_STATUS
EFIAPI
GasketEmuBlockIoCreateMapping (
- IN EMU_BLOCK_IO_PROTOCOL *This,
- IN EFI_BLOCK_IO_MEDIA *Media
+ IN EMU_BLOCK_IO_PROTOCOL *This,
+ IN EFI_BLOCK_IO_MEDIA *Media
);
EFI_STATUS
EFIAPI
GasketBlockIoThunkOpen (
- IN EMU_IO_THUNK_PROTOCOL *This
+ IN EMU_IO_THUNK_PROTOCOL *This
);
EFI_STATUS
EFIAPI
GasketBlockIoThunkClose (
- IN EMU_IO_THUNK_PROTOCOL *This
+ IN EMU_IO_THUNK_PROTOCOL *This
);
EFI_STATUS
EFIAPI
GasketSnpThunkOpen (
- IN EMU_IO_THUNK_PROTOCOL *This
+ IN EMU_IO_THUNK_PROTOCOL *This
);
EFI_STATUS
EFIAPI
GasketSnpThunkClose (
- IN EMU_IO_THUNK_PROTOCOL *This
+ IN EMU_IO_THUNK_PROTOCOL *This
);
EFI_STATUS
@@ -542,16 +525,16 @@ GasketSnpStop (
EFI_STATUS
EFIAPI
GasketSnpInitialize (
- IN EMU_SNP_PROTOCOL *This,
- IN UINTN ExtraRxBufferSize OPTIONAL,
- IN UINTN ExtraTxBufferSize OPTIONAL
+ IN EMU_SNP_PROTOCOL *This,
+ IN UINTN ExtraRxBufferSize OPTIONAL,
+ IN UINTN ExtraTxBufferSize OPTIONAL
);
EFI_STATUS
EFIAPI
GasketSnpReset (
- IN EMU_SNP_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EMU_SNP_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
);
EFI_STATUS
@@ -563,83 +546,80 @@ GasketSnpShutdown (
EFI_STATUS
EFIAPI
GasketSnpReceiveFilters (
- IN EMU_SNP_PROTOCOL *This,
- IN UINT32 Enable,
- IN UINT32 Disable,
- IN BOOLEAN ResetMCastFilter,
- IN UINTN MCastFilterCnt OPTIONAL,
- IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL
+ IN EMU_SNP_PROTOCOL *This,
+ IN UINT32 Enable,
+ IN UINT32 Disable,
+ IN BOOLEAN ResetMCastFilter,
+ IN UINTN MCastFilterCnt OPTIONAL,
+ IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL
);
EFI_STATUS
EFIAPI
GasketSnpStationAddress (
- IN EMU_SNP_PROTOCOL *This,
- IN BOOLEAN Reset,
- IN EFI_MAC_ADDRESS *New OPTIONAL
+ IN EMU_SNP_PROTOCOL *This,
+ IN BOOLEAN Reset,
+ IN EFI_MAC_ADDRESS *New OPTIONAL
);
EFI_STATUS
EFIAPI
GasketSnpStatistics (
- IN EMU_SNP_PROTOCOL *This,
- IN BOOLEAN Reset,
- IN OUT UINTN *StatisticsSize OPTIONAL,
- OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL
+ IN EMU_SNP_PROTOCOL *This,
+ IN BOOLEAN Reset,
+ IN OUT UINTN *StatisticsSize OPTIONAL,
+ OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL
);
EFI_STATUS
EFIAPI
GasketSnpMCastIpToMac (
- IN EMU_SNP_PROTOCOL *This,
- IN BOOLEAN IPv6,
- IN EFI_IP_ADDRESS *IP,
- OUT EFI_MAC_ADDRESS *MAC
+ IN EMU_SNP_PROTOCOL *This,
+ IN BOOLEAN IPv6,
+ IN EFI_IP_ADDRESS *IP,
+ OUT EFI_MAC_ADDRESS *MAC
);
EFI_STATUS
EFIAPI
GasketSnpNvData (
- IN EMU_SNP_PROTOCOL *This,
- IN BOOLEAN ReadWrite,
- IN UINTN Offset,
- IN UINTN BufferSize,
- IN OUT VOID *Buffer
+ IN EMU_SNP_PROTOCOL *This,
+ IN BOOLEAN ReadWrite,
+ IN UINTN Offset,
+ IN UINTN BufferSize,
+ IN OUT VOID *Buffer
);
EFI_STATUS
EFIAPI
GasketSnpGetStatus (
- IN EMU_SNP_PROTOCOL *This,
- OUT UINT32 *InterruptStatus OPTIONAL,
- OUT VOID **TxBuf OPTIONAL
+ IN EMU_SNP_PROTOCOL *This,
+ OUT UINT32 *InterruptStatus OPTIONAL,
+ OUT VOID **TxBuf OPTIONAL
);
EFI_STATUS
EFIAPI
GasketSnpTransmit (
- IN EMU_SNP_PROTOCOL *This,
- IN UINTN HeaderSize,
- IN UINTN BufferSize,
- IN VOID *Buffer,
- IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
- IN EFI_MAC_ADDRESS *DestAddr OPTIONAL,
- IN UINT16 *Protocol OPTIONAL
+ IN EMU_SNP_PROTOCOL *This,
+ IN UINTN HeaderSize,
+ IN UINTN BufferSize,
+ IN VOID *Buffer,
+ IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
+ IN EFI_MAC_ADDRESS *DestAddr OPTIONAL,
+ IN UINT16 *Protocol OPTIONAL
);
EFI_STATUS
EFIAPI
GasketSnpReceive (
- IN EMU_SNP_PROTOCOL *This,
- OUT UINTN *HeaderSize OPTIONAL,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer,
- OUT EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
- OUT EFI_MAC_ADDRESS *DestAddr OPTIONAL,
- OUT UINT16 *Protocol OPTIONAL
+ IN EMU_SNP_PROTOCOL *This,
+ OUT UINTN *HeaderSize OPTIONAL,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer,
+ OUT EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
+ OUT EFI_MAC_ADDRESS *DestAddr OPTIONAL,
+ OUT UINT16 *Protocol OPTIONAL
);
-
#endif
-
-
diff --git a/EmulatorPkg/Unix/Host/Host.c b/EmulatorPkg/Unix/Host/Host.c
index b4e5510613..38c01c84af 100644
--- a/EmulatorPkg/Unix/Host/Host.c
+++ b/EmulatorPkg/Unix/Host/Host.c
@@ -9,23 +9,21 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "Host.h"
#ifdef __APPLE__
-#define MAP_ANONYMOUS MAP_ANON
+#define MAP_ANONYMOUS MAP_ANON
#endif
-
//
// Globals
//
-EMU_THUNK_PPI mSecEmuThunkPpi = {
+EMU_THUNK_PPI mSecEmuThunkPpi = {
GasketSecUnixPeiAutoScan,
GasketSecUnixFdAddress,
GasketSecEmuThunkAddress
};
-char *gGdbWorkingFileName = NULL;
-unsigned int mScriptSymbolChangesCount = 0;
-
+char *gGdbWorkingFileName = NULL;
+unsigned int mScriptSymbolChangesCount = 0;
//
// Default information about where the FD is located.
@@ -34,8 +32,8 @@ unsigned int mScriptSymbolChangesCount = 0;
// The number of array elements is allocated base on parsing
// EFI_FIRMWARE_VOLUMES and the memory is never freed.
//
-UINTN gFdInfoCount = 0;
-EMU_FD_INFO *gFdInfo;
+UINTN gFdInfoCount = 0;
+EMU_FD_INFO *gFdInfo;
//
// Array that supports separate memory ranges.
@@ -46,16 +44,12 @@ EMU_FD_INFO *gFdInfo;
UINTN gSystemMemoryCount = 0;
EMU_SYSTEM_MEMORY *gSystemMemory;
-
-
UINTN mImageContextModHandleArraySize = 0;
-IMAGE_CONTEXT_TO_MOD_HANDLE *mImageContextModHandleArray = NULL;
+IMAGE_CONTEXT_TO_MOD_HANDLE *mImageContextModHandleArray = NULL;
EFI_PEI_PPI_DESCRIPTOR *gPpiList;
-
-int gInXcode = 0;
-
+int gInXcode = 0;
/*++
Breakpoint target for Xcode project. Set in the Xcode XML
@@ -71,8 +65,6 @@ SecGdbConfigBreak (
{
}
-
-
/*++
Routine Description:
@@ -121,8 +113,8 @@ main (
// If dlopen doesn't work, then we build a gdb script to allow the
// symbols to be loaded.
//
- Index = strlen (*Argv);
- gGdbWorkingFileName = AllocatePool (Index + strlen(".gdb") + 1);
+ Index = strlen (*Argv);
+ gGdbWorkingFileName = AllocatePool (Index + strlen (".gdb") + 1);
strcpy (gGdbWorkingFileName, *Argv);
strcat (gGdbWorkingFileName, ".gdb");
@@ -139,8 +131,8 @@ main (
setbuf (stdout, 0);
setbuf (stderr, 0);
- MemorySizeStr = (CHAR16 *) PcdGetPtr (PcdEmuMemorySize);
- FirmwareVolumesStr = (CHAR16 *) PcdGetPtr (PcdEmuFirmwareVolume);
+ MemorySizeStr = (CHAR16 *)PcdGetPtr (PcdEmuMemorySize);
+ FirmwareVolumesStr = (CHAR16 *)PcdGetPtr (PcdEmuFirmwareVolume);
//
// PPIs pased into PEI_CORE
@@ -169,17 +161,18 @@ main (
//
// Allocate space for gSystemMemory Array
//
- gSystemMemoryCount = CountSeparatorsInString (MemorySizeStr, '!') + 1;
- gSystemMemory = AllocateZeroPool (gSystemMemoryCount * sizeof (EMU_SYSTEM_MEMORY));
+ gSystemMemoryCount = CountSeparatorsInString (MemorySizeStr, '!') + 1;
+ gSystemMemory = AllocateZeroPool (gSystemMemoryCount * sizeof (EMU_SYSTEM_MEMORY));
if (gSystemMemory == NULL) {
printf ("ERROR : Can not allocate memory for system. Exiting.\n");
exit (1);
}
+
//
// Allocate space for gSystemMemory Array
//
- gFdInfoCount = CountSeparatorsInString (FirmwareVolumesStr, '!') + 1;
- gFdInfo = AllocateZeroPool (gFdInfoCount * sizeof (EMU_FD_INFO));
+ gFdInfoCount = CountSeparatorsInString (FirmwareVolumesStr, '!') + 1;
+ gFdInfo = AllocateZeroPool (gFdInfoCount * sizeof (EMU_FD_INFO));
if (gFdInfo == NULL) {
printf ("ERROR : Can not allocate memory for fd info. Exiting.\n");
exit (1);
@@ -192,31 +185,35 @@ main (
// on a real platform this would be SRAM, or using the cache as RAM.
// Set InitialStackMemory to zero so UnixOpenFile will allocate a new mapping
//
- InitialStackMemorySize = STACK_SIZE;
- InitialStackMemory = (UINTN)MapMemory (
- 0, (UINT32) InitialStackMemorySize,
- PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANONYMOUS | MAP_PRIVATE
- );
+ InitialStackMemorySize = STACK_SIZE;
+ InitialStackMemory = (UINTN)MapMemory (
+ 0,
+ (UINT32)InitialStackMemorySize,
+ PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_ANONYMOUS | MAP_PRIVATE
+ );
if (InitialStackMemory == 0) {
printf ("ERROR : Can not open SecStack Exiting\n");
exit (1);
}
- printf (" OS Emulator passing in %u KB of temp RAM at 0x%08lx to SEC\n",
+ printf (
+ " OS Emulator passing in %u KB of temp RAM at 0x%08lx to SEC\n",
(unsigned int)(InitialStackMemorySize / 1024),
(unsigned long)InitialStackMemory
);
- for (StackPointer = (UINTN*) (UINTN) InitialStackMemory;
- StackPointer < (UINTN*)(UINTN)((UINTN) InitialStackMemory + (UINT64) InitialStackMemorySize);
- StackPointer ++) {
+ for (StackPointer = (UINTN *)(UINTN)InitialStackMemory;
+ StackPointer < (UINTN *)(UINTN)((UINTN)InitialStackMemory + (UINT64)InitialStackMemorySize);
+ StackPointer++)
+ {
*StackPointer = 0x5AA55AA5;
}
//
// Open All the firmware volumes and remember the info in the gFdInfo global
//
- FileName = (CHAR8 *) AllocatePool (StrLen (FirmwareVolumesStr) + 1);
+ FileName = (CHAR8 *)AllocatePool (StrLen (FirmwareVolumesStr) + 1);
if (FileName == NULL) {
printf ("ERROR : Can not allocate memory for firmware volume string\n");
exit (1);
@@ -225,39 +222,43 @@ main (
Index2 = 0;
for (Done = FALSE, Index = 0, PeiIndex = 0, SecFile = NULL;
FirmwareVolumesStr[Index2] != 0;
- Index++) {
+ Index++)
+ {
for (Index1 = 0; (FirmwareVolumesStr[Index2] != '!') && (FirmwareVolumesStr[Index2] != 0); Index2++) {
FileName[Index1++] = FirmwareVolumesStr[Index2];
}
+
if (FirmwareVolumesStr[Index2] == '!') {
Index2++;
}
- FileName[Index1] = '\0';
+
+ FileName[Index1] = '\0';
if (Index == 0) {
// Map FV Recovery Read Only and other areas Read/Write
Status = MapFd0 (
- FileName,
- &gFdInfo[0].Address,
- &gFdInfo[0].Size
- );
+ FileName,
+ &gFdInfo[0].Address,
+ &gFdInfo[0].Size
+ );
} else {
//
// Open the FD and remember where it got mapped into our processes address space
// Maps Read Only
//
Status = MapFile (
- FileName,
- &gFdInfo[Index].Address,
- &gFdInfo[Index].Size
- );
+ FileName,
+ &gFdInfo[Index].Address,
+ &gFdInfo[Index].Size
+ );
}
+
if (EFI_ERROR (Status)) {
printf ("ERROR : Can not open Firmware Device File %s (%x). Exiting.\n", FileName, (unsigned int)Status);
exit (1);
}
- printf (" FD loaded from %s at 0x%08lx",FileName, (unsigned long)gFdInfo[Index].Address);
+ printf (" FD loaded from %s at 0x%08lx", FileName, (unsigned long)gFdInfo[Index].Address);
if (SecFile == NULL) {
//
@@ -265,11 +266,11 @@ main (
// Load the first one we find.
//
FileHandle = NULL;
- Status = PeiServicesFfsFindNextFile (
- EFI_FV_FILETYPE_SECURITY_CORE,
- (EFI_PEI_FV_HANDLE)(UINTN)gFdInfo[Index].Address,
- &FileHandle
- );
+ Status = PeiServicesFfsFindNextFile (
+ EFI_FV_FILETYPE_SECURITY_CORE,
+ (EFI_PEI_FV_HANDLE)(UINTN)gFdInfo[Index].Address,
+ &FileHandle
+ );
if (!EFI_ERROR (Status)) {
Status = PeiServicesFfsFindSectionData (EFI_SECTION_PE32, FileHandle, &SecFile);
if (!EFI_ERROR (Status)) {
@@ -293,9 +294,9 @@ main (
// map this memory into the SEC process memory space.
//
Index1 = 0;
- Index = 0;
+ Index = 0;
while (1) {
- UINTN val = 0;
+ UINTN val = 0;
//
// Save the size of the memory.
//
@@ -303,10 +304,12 @@ main (
val = val * 10 + MemorySizeStr[Index1] - '0';
Index1++;
}
+
gSystemMemory[Index++].Size = val * 0x100000;
if (MemorySizeStr[Index1] == 0) {
break;
}
+
Index1++;
}
@@ -315,7 +318,7 @@ main (
//
// Hand off to SEC
//
- SecLoadFromCore ((UINTN) InitialStackMemory, (UINTN) InitialStackMemorySize, (UINTN) gFdInfo[0].Address, SecFile);
+ SecLoadFromCore ((UINTN)InitialStackMemory, (UINTN)InitialStackMemorySize, (UINTN)gFdInfo[0].Address, SecFile);
//
// If we get here, then the SEC Core returned. This is an error as SEC should
@@ -325,40 +328,40 @@ main (
exit (1);
}
-
EFI_PHYSICAL_ADDRESS *
MapMemory (
- IN INTN fd,
- IN UINT64 length,
- IN INTN prot,
- IN INTN flags
+ IN INTN fd,
+ IN UINT64 length,
+ IN INTN prot,
+ IN INTN flags
)
{
- STATIC UINTN base = 0x40000000;
- CONST UINTN align = (1 << 24);
- VOID *res = NULL;
- BOOLEAN isAligned = 0;
+ STATIC UINTN base = 0x40000000;
+ CONST UINTN align = (1 << 24);
+ VOID *res = NULL;
+ BOOLEAN isAligned = 0;
//
// Try to get an aligned block somewhere in the address space of this
// process.
//
- while((!isAligned) && (base != 0)) {
+ while ((!isAligned) && (base != 0)) {
res = mmap ((void *)base, length, prot, flags, fd, 0);
if (res == MAP_FAILED) {
return NULL;
}
+
if ((((UINTN)res) & ~(align-1)) == (UINTN)res) {
- isAligned=1;
+ isAligned = 1;
} else {
- munmap(res, length);
+ munmap (res, length);
base += align;
}
}
+
return res;
}
-
/*++
Routine Description:
@@ -389,16 +392,16 @@ MapFile (
OUT UINT64 *Length
)
{
- int fd;
- VOID *res;
- UINTN FileSize;
+ int fd;
+ VOID *res;
+ UINTN FileSize;
fd = open (FileName, O_RDWR);
if (fd < 0) {
return EFI_NOT_FOUND;
}
- FileSize = lseek (fd, 0, SEEK_END);
+ FileSize = lseek (fd, 0, SEEK_END);
res = MapMemory (fd, FileSize, PROT_READ | PROT_EXEC, MAP_PRIVATE);
@@ -409,8 +412,8 @@ MapFile (
return EFI_DEVICE_ERROR;
}
- *Length = (UINT64) FileSize;
- *BaseAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) res;
+ *Length = (UINT64)FileSize;
+ *BaseAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)res;
return EFI_SUCCESS;
}
@@ -422,16 +425,17 @@ MapFd0 (
OUT UINT64 *Length
)
{
- int fd;
- void *res, *res2, *res3;
- UINTN FileSize;
- UINTN FvSize;
- void *EmuMagicPage;
+ int fd;
+ void *res, *res2, *res3;
+ UINTN FileSize;
+ UINTN FvSize;
+ void *EmuMagicPage;
fd = open (FileName, O_RDWR);
if (fd < 0) {
return EFI_NOT_FOUND;
}
+
FileSize = lseek (fd, 0, SEEK_END);
FvSize = FixedPcdGet64 (PcdEmuFlashFvRecoverySize);
@@ -469,13 +473,13 @@ MapFd0 (
// Map the rest of the FD as read/write
res2 = mmap (
- (void *)(UINTN)(FixedPcdGet64 (PcdEmuFlashFvRecoveryBase) + FvSize),
- FileSize - FvSize,
- PROT_READ | PROT_WRITE | PROT_EXEC,
- MAP_SHARED,
- fd,
- FvSize
- );
+ (void *)(UINTN)(FixedPcdGet64 (PcdEmuFlashFvRecoveryBase) + FvSize),
+ FileSize - FvSize,
+ PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_SHARED,
+ fd,
+ FvSize
+ );
close (fd);
if (res2 == MAP_FAILED) {
perror ("MapFd0() Failed res2 =");
@@ -504,13 +508,12 @@ MapFd0 (
}
}
- *Length = (UINT64) FileSize;
- *BaseAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) res;
+ *Length = (UINT64)FileSize;
+ *BaseAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)res;
return EFI_SUCCESS;
}
-
/*++
Routine Description:
@@ -528,24 +531,24 @@ Returns:
**/
VOID
SecLoadFromCore (
- IN UINTN LargestRegion,
- IN UINTN LargestRegionSize,
- IN UINTN BootFirmwareVolumeBase,
- IN VOID *PeiCorePe32File
+ IN UINTN LargestRegion,
+ IN UINTN LargestRegionSize,
+ IN UINTN BootFirmwareVolumeBase,
+ IN VOID *PeiCorePe32File
)
{
- EFI_STATUS Status;
- EFI_PHYSICAL_ADDRESS TopOfMemory;
- VOID *TopOfStack;
- EFI_PHYSICAL_ADDRESS PeiCoreEntryPoint;
- EFI_SEC_PEI_HAND_OFF *SecCoreData;
- UINTN PeiStackSize;
+ EFI_STATUS Status;
+ EFI_PHYSICAL_ADDRESS TopOfMemory;
+ VOID *TopOfStack;
+ EFI_PHYSICAL_ADDRESS PeiCoreEntryPoint;
+ EFI_SEC_PEI_HAND_OFF *SecCoreData;
+ UINTN PeiStackSize;
//
// Compute Top Of Memory for Stack and PEI Core Allocations
//
TopOfMemory = LargestRegion + LargestRegionSize;
- PeiStackSize = (UINTN)RShiftU64((UINT64)STACK_SIZE,1);
+ PeiStackSize = (UINTN)RShiftU64 ((UINT64)STACK_SIZE, 1);
//
// |-----------| <---- TemporaryRamBase + TemporaryRamSize
@@ -562,22 +565,21 @@ SecLoadFromCore (
//
// Reservet space for storing PeiCore's parament in stack.
//
- TopOfStack = (VOID *)((UINTN)TopOfStack - sizeof (EFI_SEC_PEI_HAND_OFF) - CPU_STACK_ALIGNMENT);
- TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);
-
+ TopOfStack = (VOID *)((UINTN)TopOfStack - sizeof (EFI_SEC_PEI_HAND_OFF) - CPU_STACK_ALIGNMENT);
+ TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);
//
// Bind this information into the SEC hand-off state
//
- SecCoreData = (EFI_SEC_PEI_HAND_OFF*)(UINTN) TopOfStack;
- SecCoreData->DataSize = sizeof(EFI_SEC_PEI_HAND_OFF);
- SecCoreData->BootFirmwareVolumeBase = (VOID*)BootFirmwareVolumeBase;
+ SecCoreData = (EFI_SEC_PEI_HAND_OFF *)(UINTN)TopOfStack;
+ SecCoreData->DataSize = sizeof (EFI_SEC_PEI_HAND_OFF);
+ SecCoreData->BootFirmwareVolumeBase = (VOID *)BootFirmwareVolumeBase;
SecCoreData->BootFirmwareVolumeSize = PcdGet32 (PcdEmuFirmwareFdSize);
- SecCoreData->TemporaryRamBase = (VOID*)(UINTN)LargestRegion;
+ SecCoreData->TemporaryRamBase = (VOID *)(UINTN)LargestRegion;
SecCoreData->TemporaryRamSize = STACK_SIZE;
SecCoreData->StackBase = SecCoreData->TemporaryRamBase;
SecCoreData->StackSize = PeiStackSize;
- SecCoreData->PeiTemporaryRamBase = (VOID*) ((UINTN) SecCoreData->TemporaryRamBase + PeiStackSize);
+ SecCoreData->PeiTemporaryRamBase = (VOID *)((UINTN)SecCoreData->TemporaryRamBase + PeiStackSize);
SecCoreData->PeiTemporaryRamSize = STACK_SIZE - PeiStackSize;
//
@@ -585,14 +587,14 @@ SecLoadFromCore (
//
Status = SecPeCoffGetEntryPoint (PeiCorePe32File, (VOID **)&PeiCoreEntryPoint);
if (EFI_ERROR (Status)) {
- return ;
+ return;
}
//
// Transfer control to the SEC Core
//
PeiSwitchStacks (
- (SWITCH_STACK_ENTRY_POINT) (UINTN) PeiCoreEntryPoint,
+ (SWITCH_STACK_ENTRY_POINT)(UINTN)PeiCoreEntryPoint,
SecCoreData,
(VOID *)gPpiList,
TopOfStack
@@ -600,10 +602,9 @@ SecLoadFromCore (
//
// If we get here, then the SEC Core returned. This is an error
//
- return ;
+ return;
}
-
/*++
Routine Description:
@@ -631,29 +632,30 @@ SecUnixPeiAutoScan (
OUT UINT64 *MemorySize
)
{
- void *res;
+ void *res;
if (Index >= gSystemMemoryCount) {
return EFI_UNSUPPORTED;
}
*MemoryBase = 0;
- res = MapMemory (
- 0, gSystemMemory[Index].Size,
- PROT_READ | PROT_WRITE | PROT_EXEC,
- MAP_PRIVATE | MAP_ANONYMOUS
- );
+ res = MapMemory (
+ 0,
+ gSystemMemory[Index].Size,
+ PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_PRIVATE | MAP_ANONYMOUS
+ );
if (res == MAP_FAILED) {
return EFI_DEVICE_ERROR;
}
- *MemorySize = gSystemMemory[Index].Size;
- *MemoryBase = (UINTN)res;
+
+ *MemorySize = gSystemMemory[Index].Size;
+ *MemoryBase = (UINTN)res;
gSystemMemory[Index].Memory = *MemoryBase;
return EFI_SUCCESS;
}
-
/*++
Routine Description:
@@ -675,7 +677,7 @@ Returns:
**/
BOOLEAN
EfiSystemMemoryRange (
- IN VOID *MemoryAddress
+ IN VOID *MemoryAddress
)
{
UINTN Index;
@@ -684,7 +686,8 @@ EfiSystemMemoryRange (
MemoryBase = (EFI_PHYSICAL_ADDRESS)(UINTN)MemoryAddress;
for (Index = 0; Index < gSystemMemoryCount; Index++) {
if ((MemoryBase >= gSystemMemory[Index].Memory) &&
- (MemoryBase < (gSystemMemory[Index].Memory + gSystemMemory[Index].Size)) ) {
+ (MemoryBase < (gSystemMemory[Index].Memory + gSystemMemory[Index].Size)))
+ {
return TRUE;
}
}
@@ -692,7 +695,6 @@ EfiSystemMemoryRange (
return FALSE;
}
-
/*++
Routine Description:
@@ -715,8 +717,6 @@ SecEmuThunkAddress (
return &gEmuThunkProtocol;
}
-
-
RETURN_STATUS
EFIAPI
SecPeCoffGetEntryPoint (
@@ -728,10 +728,10 @@ SecPeCoffGetEntryPoint (
PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
ZeroMem (&ImageContext, sizeof (ImageContext));
- ImageContext.Handle = Pe32Data;
- ImageContext.ImageRead = (PE_COFF_LOADER_READ_FILE) SecImageRead;
+ ImageContext.Handle = Pe32Data;
+ ImageContext.ImageRead = (PE_COFF_LOADER_READ_FILE)SecImageRead;
- Status = PeCoffLoaderGetImageInfo (&ImageContext);
+ Status = PeCoffLoaderGetImageInfo (&ImageContext);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -741,7 +741,7 @@ SecPeCoffGetEntryPoint (
// Relocate image to match the address where it resides
//
ImageContext.ImageAddress = (UINTN)Pe32Data;
- Status = PeCoffLoaderLoadImage (&ImageContext);
+ Status = PeCoffLoaderLoadImage (&ImageContext);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -755,10 +755,11 @@ SecPeCoffGetEntryPoint (
// Or just return image entry point
//
ImageContext.PdbPointer = PeCoffLoaderGetPdbPointer (Pe32Data);
- Status = PeCoffLoaderGetEntryPoint (Pe32Data, EntryPoint);
+ Status = PeCoffLoaderGetEntryPoint (Pe32Data, EntryPoint);
if (EFI_ERROR (Status)) {
return Status;
}
+
ImageContext.EntryPoint = (UINTN)*EntryPoint;
}
@@ -769,8 +770,6 @@ SecPeCoffGetEntryPoint (
return Status;
}
-
-
/*++
Routine Description:
@@ -804,7 +803,7 @@ SecUnixFdAddress (
*FdSize = gFdInfo[Index].Size;
*FixUp = 0;
- if (*FdBase == 0 && *FdSize == 0) {
+ if ((*FdBase == 0) && (*FdSize == 0)) {
return EFI_UNSUPPORTED;
}
@@ -820,7 +819,6 @@ SecUnixFdAddress (
return EFI_SUCCESS;
}
-
/*++
Routine Description:
@@ -836,11 +834,11 @@ Returns:
**/
UINTN
CountSeparatorsInString (
- IN const CHAR16 *String,
- IN CHAR16 Separator
+ IN const CHAR16 *String,
+ IN CHAR16 Separator
)
{
- UINTN Count;
+ UINTN Count;
for (Count = 0; *String != '\0'; String++) {
if (*String == Separator) {
@@ -851,15 +849,15 @@ CountSeparatorsInString (
return Count;
}
-
EFI_STATUS
EFIAPI
SecImageRead (
- IN VOID *FileHandle,
- IN UINTN FileOffset,
- IN OUT UINTN *ReadSize,
- OUT VOID *Buffer
+ IN VOID *FileHandle,
+ IN UINTN FileOffset,
+ IN OUT UINTN *ReadSize,
+ OUT VOID *Buffer
)
+
/*++
Routine Description:
@@ -876,13 +874,13 @@ Returns:
**/
{
- CHAR8 *Destination8;
- CHAR8 *Source8;
- UINTN Length;
+ CHAR8 *Destination8;
+ CHAR8 *Source8;
+ UINTN Length;
- Destination8 = Buffer;
- Source8 = (CHAR8 *) ((UINTN) FileHandle + FileOffset);
- Length = *ReadSize;
+ Destination8 = Buffer;
+ Source8 = (CHAR8 *)((UINTN)FileHandle + FileOffset);
+ Length = *ReadSize;
while (Length--) {
*(Destination8++) = *(Source8++);
}
@@ -890,7 +888,6 @@ Returns:
return EFI_SUCCESS;
}
-
/*++
Routine Description:
@@ -909,14 +906,13 @@ Returns:
**/
EFI_STATUS
AddHandle (
- IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
- IN VOID *ModHandle
+ IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
+ IN VOID *ModHandle
)
{
- UINTN Index;
- IMAGE_CONTEXT_TO_MOD_HANDLE *Array;
- UINTN PreviousSize;
-
+ UINTN Index;
+ IMAGE_CONTEXT_TO_MOD_HANDLE *Array;
+ UINTN PreviousSize;
Array = mImageContextModHandleArray;
for (Index = 0; Index < mImageContextModHandleArraySize; Index++, Array++) {
@@ -936,7 +932,7 @@ AddHandle (
// copy the old values to the new location. But it does
// not zero the new memory area.
//
- PreviousSize = mImageContextModHandleArraySize * sizeof (IMAGE_CONTEXT_TO_MOD_HANDLE);
+ PreviousSize = mImageContextModHandleArraySize * sizeof (IMAGE_CONTEXT_TO_MOD_HANDLE);
mImageContextModHandleArraySize += MAX_IMAGE_CONTEXT_TO_MOD_HANDLE_ARRAY_SIZE;
mImageContextModHandleArray = ReallocatePool (
@@ -954,7 +950,6 @@ AddHandle (
return AddHandle (ImageContext, ModHandle);
}
-
/*++
Routine Description:
@@ -971,7 +966,7 @@ Returns:
**/
VOID *
RemoveHandle (
- IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
{
UINTN Index;
@@ -998,60 +993,60 @@ RemoveHandle (
return NULL;
}
-
-
BOOLEAN
IsPdbFile (
- IN CHAR8 *PdbFileName
+ IN CHAR8 *PdbFileName
)
{
- UINTN Len;
+ UINTN Len;
if (PdbFileName == NULL) {
return FALSE;
}
Len = strlen (PdbFileName);
- if ((Len < 5)|| (PdbFileName[Len - 4] != '.')) {
+ if ((Len < 5) || (PdbFileName[Len - 4] != '.')) {
return FALSE;
}
- if ((PdbFileName[Len - 3] == 'P' || PdbFileName[Len - 3] == 'p') &&
- (PdbFileName[Len - 2] == 'D' || PdbFileName[Len - 2] == 'd') &&
- (PdbFileName[Len - 1] == 'B' || PdbFileName[Len - 1] == 'b')) {
+ if (((PdbFileName[Len - 3] == 'P') || (PdbFileName[Len - 3] == 'p')) &&
+ ((PdbFileName[Len - 2] == 'D') || (PdbFileName[Len - 2] == 'd')) &&
+ ((PdbFileName[Len - 1] == 'B') || (PdbFileName[Len - 1] == 'b')))
+ {
return TRUE;
}
return FALSE;
}
-
-#define MAX_SPRINT_BUFFER_SIZE 0x200
+#define MAX_SPRINT_BUFFER_SIZE 0x200
void
PrintLoadAddress (
- IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
{
if (ImageContext->PdbPointer == NULL) {
- fprintf (stderr,
+ fprintf (
+ stderr,
"0x%08lx Loading NO DEBUG with entry point 0x%08lx\n",
(unsigned long)(ImageContext->ImageAddress),
(unsigned long)ImageContext->EntryPoint
);
} else {
- fprintf (stderr,
+ fprintf (
+ stderr,
"0x%08lx Loading %s with entry point 0x%08lx\n",
(unsigned long)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders),
ImageContext->PdbPointer,
(unsigned long)ImageContext->EntryPoint
);
}
+
// Keep output synced up
fflush (stderr);
}
-
/**
Loads the image using dlopen so symbols will be automatically
loaded by gdb.
@@ -1064,18 +1059,17 @@ PrintLoadAddress (
**/
BOOLEAN
DlLoadImage (
- IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
{
-
-#ifdef __APPLE__
+ #ifdef __APPLE__
return FALSE;
-#else
+ #else
- void *Handle = NULL;
- void *Entry = NULL;
+ void *Handle = NULL;
+ void *Entry = NULL;
if (ImageContext->PdbPointer == NULL) {
return FALSE;
@@ -1086,19 +1080,19 @@ DlLoadImage (
}
fprintf (
- stderr,
- "Loading %s 0x%08lx - entry point 0x%08lx\n",
- ImageContext->PdbPointer,
- (unsigned long)ImageContext->ImageAddress,
- (unsigned long)ImageContext->EntryPoint
- );
+ stderr,
+ "Loading %s 0x%08lx - entry point 0x%08lx\n",
+ ImageContext->PdbPointer,
+ (unsigned long)ImageContext->ImageAddress,
+ (unsigned long)ImageContext->EntryPoint
+ );
Handle = dlopen (ImageContext->PdbPointer, RTLD_NOW);
if (Handle != NULL) {
Entry = dlsym (Handle, "_ModuleEntryPoint");
AddHandle (ImageContext, Handle);
} else {
- printf("%s\n", dlerror());
+ printf ("%s\n", dlerror ());
}
if (Entry != NULL) {
@@ -1109,25 +1103,23 @@ DlLoadImage (
return FALSE;
}
-#endif
+ #endif
}
-
#ifdef __APPLE__
-__attribute__((noinline))
+__attribute__ ((noinline))
#endif
VOID
SecGdbScriptBreak (
- char *FileName,
- int FileNameLength,
- long unsigned int LoadAddress,
- int AddSymbolFlag
+ char *FileName,
+ int FileNameLength,
+ long unsigned int LoadAddress,
+ int AddSymbolFlag
)
{
return;
}
-
/**
Adds the image to a gdb script so its symbols can be loaded.
The AddFirmwareSymbolFile helper macro is used.
@@ -1137,18 +1129,17 @@ SecGdbScriptBreak (
**/
VOID
GdbScriptAddImage (
- IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
{
-
PrintLoadAddress (ImageContext);
- if (ImageContext->PdbPointer != NULL && !IsPdbFile (ImageContext->PdbPointer)) {
+ if ((ImageContext->PdbPointer != NULL) && !IsPdbFile (ImageContext->PdbPointer)) {
FILE *GdbTempFile;
if (FeaturePcdGet (PcdEmulatorLazyLoadSymbols)) {
GdbTempFile = fopen (gGdbWorkingFileName, "a");
if (GdbTempFile != NULL) {
- long unsigned int SymbolsAddr = (long unsigned int)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders);
+ long unsigned int SymbolsAddr = (long unsigned int)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders);
mScriptSymbolChangesCount++;
fprintf (
GdbTempFile,
@@ -1188,11 +1179,10 @@ GdbScriptAddImage (
}
}
-
VOID
EFIAPI
SecPeCoffRelocateImageExtraAction (
- IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
{
if (!DlLoadImage (ImageContext)) {
@@ -1200,7 +1190,6 @@ SecPeCoffRelocateImageExtraAction (
}
}
-
/**
Adds the image to a gdb script so its symbols can be unloaded.
The RemoveFirmwareSymbolFile helper macro is used.
@@ -1210,7 +1199,7 @@ SecPeCoffRelocateImageExtraAction (
**/
VOID
GdbScriptRemoveImage (
- IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
{
FILE *GdbTempFile;
@@ -1257,27 +1246,24 @@ GdbScriptRemoveImage (
}
}
-
VOID
EFIAPI
SecPeCoffUnloadImageExtraAction (
- IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
{
- VOID *Handle;
+ VOID *Handle;
//
// Check to see if the image symbols were loaded with gdb script, or dlopen
//
Handle = RemoveHandle (ImageContext);
if (Handle != NULL) {
-#ifndef __APPLE__
+ #ifndef __APPLE__
dlclose (Handle);
-#endif
+ #endif
return;
}
GdbScriptRemoveImage (ImageContext);
}
-
-
diff --git a/EmulatorPkg/Unix/Host/Host.h b/EmulatorPkg/Unix/Host/Host.h
index a372ecaadb..0c81cdfc01 100644
--- a/EmulatorPkg/Unix/Host/Host.h
+++ b/EmulatorPkg/Unix/Host/Host.h
@@ -30,9 +30,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <sys/time.h>
#if __CYGWIN__
-#include <sys/dirent.h>
+ #include <sys/dirent.h>
#else
-#include <sys/dir.h>
+ #include <sys/dir.h>
#endif
#include <sys/mman.h>
@@ -56,19 +56,19 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <ifaddrs.h>
#ifdef __APPLE__
-#include <net/if_dl.h>
-#include <net/bpf.h>
-#include <sys/param.h>
-#include <sys/mount.h>
-#include <sys/disk.h>
+ #include <net/if_dl.h>
+ #include <net/bpf.h>
+ #include <sys/param.h>
+ #include <sys/mount.h>
+ #include <sys/disk.h>
#define _XOPEN_SOURCE
-#ifndef _Bool
- #define _Bool char // for clang debug
-#endif
+ #ifndef _Bool
+#define _Bool char // for clang debug
+ #endif
#else
-#include <termio.h>
-#include <sys/vfs.h>
-#include <linux/fs.h>
+ #include <termio.h>
+ #include <sys/vfs.h>
+ #include <linux/fs.h>
#endif
#include <utime.h>
@@ -120,31 +120,27 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Guid/FileSystemInfo.h>
#include <Guid/FileSystemVolumeLabelInfo.h>
-
#include "Gasket.h"
-
-#define STACK_SIZE 0x20000
+#define STACK_SIZE 0x20000
typedef struct {
- EFI_PHYSICAL_ADDRESS Address;
- UINT64 Size;
+ EFI_PHYSICAL_ADDRESS Address;
+ UINT64 Size;
} EMU_FD_INFO;
typedef struct {
- EFI_PHYSICAL_ADDRESS Memory;
- UINT64 Size;
+ EFI_PHYSICAL_ADDRESS Memory;
+ UINT64 Size;
} EMU_SYSTEM_MEMORY;
-
-#define MAX_IMAGE_CONTEXT_TO_MOD_HANDLE_ARRAY_SIZE 0x100
+#define MAX_IMAGE_CONTEXT_TO_MOD_HANDLE_ARRAY_SIZE 0x100
typedef struct {
- PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext;
- VOID *ModHandle;
+ PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext;
+ VOID *ModHandle;
} IMAGE_CONTEXT_TO_MOD_HANDLE;
-
EFI_STATUS
EFIAPI
SecUnixPeiLoadFile (
@@ -163,18 +159,18 @@ main (
VOID
SecLoadFromCore (
- IN UINTN LargestRegion,
- IN UINTN LargestRegionSize,
- IN UINTN BootFirmwareVolumeBase,
- IN VOID *PeiCoreFile
+ IN UINTN LargestRegion,
+ IN UINTN LargestRegionSize,
+ IN UINTN BootFirmwareVolumeBase,
+ IN VOID *PeiCoreFile
);
EFI_STATUS
SecLoadFile (
- IN VOID *Pe32Data,
- IN EFI_PHYSICAL_ADDRESS *ImageAddress,
- IN UINT64 *ImageSize,
- IN EFI_PHYSICAL_ADDRESS *EntryPoint
+ IN VOID *Pe32Data,
+ IN EFI_PHYSICAL_ADDRESS *ImageAddress,
+ IN UINT64 *ImageSize,
+ IN EFI_PHYSICAL_ADDRESS *EntryPoint
);
EFI_STATUS
@@ -192,23 +188,23 @@ SecFfsFindNextFile (
EFI_STATUS
SecFfsFindSectionData (
- IN EFI_SECTION_TYPE SectionType,
- IN EFI_FFS_FILE_HEADER *FfsFileHeader,
- IN OUT VOID **SectionData
+ IN EFI_SECTION_TYPE SectionType,
+ IN EFI_FFS_FILE_HEADER *FfsFileHeader,
+ IN OUT VOID **SectionData
);
EFI_STATUS
EFIAPI
SecUnixPeCoffLoaderLoadAsDll (
- IN CHAR8 *PdbFileName,
- IN VOID **ImageEntryPoint,
- OUT VOID **ModHandle
+ IN CHAR8 *PdbFileName,
+ IN VOID **ImageEntryPoint,
+ OUT VOID **ModHandle
);
EFI_STATUS
EFIAPI
SecUnixPeCoffLoaderFreeLibrary (
- OUT VOID *ModHandle
+ OUT VOID *ModHandle
);
EFI_STATUS
@@ -230,53 +226,51 @@ GasketSecUnixFdAddress (
)
;
-
EFI_STATUS
GetImageReadFunction (
- IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
- IN EFI_PHYSICAL_ADDRESS *TopOfMemory
+ IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
+ IN EFI_PHYSICAL_ADDRESS *TopOfMemory
);
EFI_STATUS
EFIAPI
SecImageRead (
- IN VOID *FileHandle,
- IN UINTN FileOffset,
- IN OUT UINTN *ReadSize,
- OUT VOID *Buffer
+ IN VOID *FileHandle,
+ IN UINTN FileOffset,
+ IN OUT UINTN *ReadSize,
+ OUT VOID *Buffer
);
CHAR16 *
AsciiToUnicode (
- IN CHAR8 *Ascii,
- IN UINTN *StrLen OPTIONAL
+ IN CHAR8 *Ascii,
+ IN UINTN *StrLen OPTIONAL
);
UINTN
CountSeparatorsInString (
- IN const CHAR16 *String,
- IN CHAR16 Separator
+ IN const CHAR16 *String,
+ IN CHAR16 Separator
);
EFI_STATUS
EFIAPI
SecTemporaryRamSupport (
- IN CONST EFI_PEI_SERVICES **PeiServices,
- IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase,
- IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase,
- IN UINTN CopySize
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase,
+ IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase,
+ IN UINTN CopySize
);
EFI_STATUS
EFIAPI
GasketSecTemporaryRamSupport (
- IN CONST EFI_PEI_SERVICES **PeiServices,
- IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase,
- IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase,
- IN UINTN CopySize
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase,
+ IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase,
+ IN UINTN CopySize
);
-
RETURN_STATUS
EFIAPI
SecPeCoffGetEntryPoint (
@@ -296,7 +290,6 @@ SecPeCoffLoaderUnloadImageExtraAction (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
);
-
VOID
PeiSwitchStacks (
IN SWITCH_STACK_ENTRY_POINT EntryPoint,
@@ -310,13 +303,13 @@ SecInitThunkProtocol (
VOID
);
-
EFI_PHYSICAL_ADDRESS *
MapMemory (
- INTN fd,
- UINT64 length,
- INTN prot,
- INTN flags);
+ INTN fd,
+ UINT64 length,
+ INTN prot,
+ INTN flags
+ );
EFI_STATUS
MapFile (
@@ -334,21 +327,34 @@ MapFd0 (
BOOLEAN
EfiSystemMemoryRange (
- IN VOID *MemoryAddress
+ IN VOID *MemoryAddress
+ );
+
+VOID
+SecSleep (
+ UINT64 Nanoseconds
);
+VOID
+SecEnableInterrupt (
+ VOID
+ );
-VOID SecSleep (UINT64 Nanoseconds);
-VOID SecEnableInterrupt (VOID);
-VOID SecDisableInterrupt (VOID);
-BOOLEAN SecInterruptEanbled (VOID);
+VOID
+SecDisableInterrupt (
+ VOID
+ );
+BOOLEAN
+SecInterruptEanbled (
+ VOID
+ );
-extern EMU_THUNK_PROTOCOL gEmuThunkProtocol;
-extern EMU_IO_THUNK_PROTOCOL gX11ThunkIo;
-extern EMU_IO_THUNK_PROTOCOL gPosixFileSystemThunkIo;
-extern EMU_IO_THUNK_PROTOCOL gPthreadThunkIo;
-extern EMU_IO_THUNK_PROTOCOL gBlockIoThunkIo;
-extern EMU_IO_THUNK_PROTOCOL gSnpThunkIo;
+extern EMU_THUNK_PROTOCOL gEmuThunkProtocol;
+extern EMU_IO_THUNK_PROTOCOL gX11ThunkIo;
+extern EMU_IO_THUNK_PROTOCOL gPosixFileSystemThunkIo;
+extern EMU_IO_THUNK_PROTOCOL gPthreadThunkIo;
+extern EMU_IO_THUNK_PROTOCOL gBlockIoThunkIo;
+extern EMU_IO_THUNK_PROTOCOL gSnpThunkIo;
#endif
diff --git a/EmulatorPkg/Unix/Host/Ia32/SwitchStack.c b/EmulatorPkg/Unix/Host/Ia32/SwitchStack.c
index 0184de2894..18028f3791 100644
--- a/EmulatorPkg/Unix/Host/Ia32/SwitchStack.c
+++ b/EmulatorPkg/Unix/Host/Ia32/SwitchStack.c
@@ -9,7 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "Host.h"
-
/**
Transfers control to a function starting with a new stack.
@@ -49,15 +48,14 @@ PeiSwitchStacks (
//
ASSERT (((UINTN)NewStack & (CPU_STACK_ALIGNMENT - 1)) == 0);
- JumpBuffer.Eip = (UINTN)EntryPoint;
- JumpBuffer.Esp = (UINTN)NewStack - sizeof (VOID*);
- JumpBuffer.Esp -= sizeof (Context1) + sizeof (Context2);
- ((VOID**)JumpBuffer.Esp)[1] = Context1;
- ((VOID**)JumpBuffer.Esp)[2] = Context2;
+ JumpBuffer.Eip = (UINTN)EntryPoint;
+ JumpBuffer.Esp = (UINTN)NewStack - sizeof (VOID *);
+ JumpBuffer.Esp -= sizeof (Context1) + sizeof (Context2);
+ ((VOID **)JumpBuffer.Esp)[1] = Context1;
+ ((VOID **)JumpBuffer.Esp)[2] = Context2;
LongJump (&JumpBuffer, (UINTN)-1);
-
//
// PeiSwitchStacks () will never return
//
diff --git a/EmulatorPkg/Unix/Host/LinuxPacketFilter.c b/EmulatorPkg/Unix/Host/LinuxPacketFilter.c
index 2b772ab884..87c3dd6be4 100644
--- a/EmulatorPkg/Unix/Host/LinuxPacketFilter.c
+++ b/EmulatorPkg/Unix/Host/LinuxPacketFilter.c
@@ -12,21 +12,18 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-
#include "Host.h"
#ifndef __APPLE__
-#define EMU_SNP_PRIVATE_SIGNATURE SIGNATURE_32('E', 'M', 's', 'n')
+#define EMU_SNP_PRIVATE_SIGNATURE SIGNATURE_32('E', 'M', 's', 'n')
typedef struct {
- UINTN Signature;
-
- EMU_IO_THUNK_PROTOCOL *Thunk;
-
+ UINTN Signature;
- EMU_SNP_PROTOCOL EmuSnp;
- EFI_SIMPLE_NETWORK_MODE *Mode;
+ EMU_IO_THUNK_PROTOCOL *Thunk;
+ EMU_SNP_PROTOCOL EmuSnp;
+ EFI_SIMPLE_NETWORK_MODE *Mode;
} EMU_SNP_PRIVATE;
#define EMU_SNP_PRIVATE_DATA_FROM_THIS(a) \
@@ -48,7 +45,7 @@ EmuSnpCreateMapping (
IN EFI_SIMPLE_NETWORK_MODE *Mode
)
{
- EMU_SNP_PRIVATE *Private;
+ EMU_SNP_PRIVATE *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -74,7 +71,7 @@ EmuSnpStart (
IN EMU_SNP_PROTOCOL *This
)
{
- EMU_SNP_PRIVATE *Private;
+ EMU_SNP_PRIVATE *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -98,7 +95,7 @@ EmuSnpStop (
IN EMU_SNP_PROTOCOL *This
)
{
- EMU_SNP_PRIVATE *Private;
+ EMU_SNP_PRIVATE *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -133,12 +130,12 @@ EmuSnpStop (
**/
EFI_STATUS
EmuSnpInitialize (
- IN EMU_SNP_PROTOCOL *This,
- IN UINTN ExtraRxBufferSize OPTIONAL,
- IN UINTN ExtraTxBufferSize OPTIONAL
+ IN EMU_SNP_PROTOCOL *This,
+ IN UINTN ExtraRxBufferSize OPTIONAL,
+ IN UINTN ExtraTxBufferSize OPTIONAL
)
{
- EMU_SNP_PRIVATE *Private;
+ EMU_SNP_PRIVATE *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -163,11 +160,11 @@ EmuSnpInitialize (
**/
EFI_STATUS
EmuSnpReset (
- IN EMU_SNP_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EMU_SNP_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
)
{
- EMU_SNP_PRIVATE *Private;
+ EMU_SNP_PRIVATE *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -192,7 +189,7 @@ EmuSnpShutdown (
IN EMU_SNP_PROTOCOL *This
)
{
- EMU_SNP_PRIVATE *Private;
+ EMU_SNP_PRIVATE *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -225,15 +222,15 @@ EmuSnpShutdown (
**/
EFI_STATUS
EmuSnpReceiveFilters (
- IN EMU_SNP_PROTOCOL *This,
- IN UINT32 Enable,
- IN UINT32 Disable,
- IN BOOLEAN ResetMCastFilter,
- IN UINTN MCastFilterCnt OPTIONAL,
- IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL
+ IN EMU_SNP_PROTOCOL *This,
+ IN UINT32 Enable,
+ IN UINT32 Disable,
+ IN BOOLEAN ResetMCastFilter,
+ IN UINTN MCastFilterCnt OPTIONAL,
+ IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL
)
{
- EMU_SNP_PRIVATE *Private;
+ EMU_SNP_PRIVATE *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -257,12 +254,12 @@ EmuSnpReceiveFilters (
**/
EFI_STATUS
EmuSnpStationAddress (
- IN EMU_SNP_PROTOCOL *This,
- IN BOOLEAN Reset,
- IN EFI_MAC_ADDRESS *New OPTIONAL
+ IN EMU_SNP_PROTOCOL *This,
+ IN BOOLEAN Reset,
+ IN EFI_MAC_ADDRESS *New OPTIONAL
)
{
- EMU_SNP_PRIVATE *Private;
+ EMU_SNP_PRIVATE *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -292,13 +289,13 @@ EmuSnpStationAddress (
**/
EFI_STATUS
EmuSnpStatistics (
- IN EMU_SNP_PROTOCOL *This,
- IN BOOLEAN Reset,
- IN OUT UINTN *StatisticsSize OPTIONAL,
- OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL
+ IN EMU_SNP_PROTOCOL *This,
+ IN BOOLEAN Reset,
+ IN OUT UINTN *StatisticsSize OPTIONAL,
+ OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL
)
{
- EMU_SNP_PRIVATE *Private;
+ EMU_SNP_PRIVATE *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -328,13 +325,13 @@ EmuSnpStatistics (
**/
EFI_STATUS
EmuSnpMCastIpToMac (
- IN EMU_SNP_PROTOCOL *This,
- IN BOOLEAN IPv6,
- IN EFI_IP_ADDRESS *IP,
- OUT EFI_MAC_ADDRESS *MAC
+ IN EMU_SNP_PROTOCOL *This,
+ IN BOOLEAN IPv6,
+ IN EFI_IP_ADDRESS *IP,
+ OUT EFI_MAC_ADDRESS *MAC
)
{
- EMU_SNP_PRIVATE *Private;
+ EMU_SNP_PRIVATE *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -363,14 +360,14 @@ EmuSnpMCastIpToMac (
**/
EFI_STATUS
EmuSnpNvData (
- IN EMU_SNP_PROTOCOL *This,
- IN BOOLEAN ReadWrite,
- IN UINTN Offset,
- IN UINTN BufferSize,
- IN OUT VOID *Buffer
+ IN EMU_SNP_PROTOCOL *This,
+ IN BOOLEAN ReadWrite,
+ IN UINTN Offset,
+ IN UINTN BufferSize,
+ IN OUT VOID *Buffer
)
{
- EMU_SNP_PRIVATE *Private;
+ EMU_SNP_PRIVATE *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -404,12 +401,12 @@ EmuSnpNvData (
**/
EFI_STATUS
EmuSnpGetStatus (
- IN EMU_SNP_PROTOCOL *This,
- OUT UINT32 *InterruptStatus OPTIONAL,
- OUT VOID **TxBuf OPTIONAL
+ IN EMU_SNP_PROTOCOL *This,
+ OUT UINT32 *InterruptStatus OPTIONAL,
+ OUT VOID **TxBuf OPTIONAL
)
{
- EMU_SNP_PRIVATE *Private;
+ EMU_SNP_PRIVATE *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -451,16 +448,16 @@ EmuSnpGetStatus (
**/
EFI_STATUS
EmuSnpTransmit (
- IN EMU_SNP_PROTOCOL *This,
- IN UINTN HeaderSize,
- IN UINTN BufferSize,
- IN VOID *Buffer,
- IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
- IN EFI_MAC_ADDRESS *DestAddr OPTIONAL,
- IN UINT16 *Protocol OPTIONAL
+ IN EMU_SNP_PROTOCOL *This,
+ IN UINTN HeaderSize,
+ IN UINTN BufferSize,
+ IN VOID *Buffer,
+ IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
+ IN EFI_MAC_ADDRESS *DestAddr OPTIONAL,
+ IN UINT16 *Protocol OPTIONAL
)
{
- EMU_SNP_PRIVATE *Private;
+ EMU_SNP_PRIVATE *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -501,24 +498,23 @@ EmuSnpTransmit (
**/
EFI_STATUS
EmuSnpReceive (
- IN EMU_SNP_PROTOCOL *This,
- OUT UINTN *HeaderSize OPTIONAL,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer,
- OUT EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
- OUT EFI_MAC_ADDRESS *DestAddr OPTIONAL,
- OUT UINT16 *Protocol OPTIONAL
+ IN EMU_SNP_PROTOCOL *This,
+ OUT UINTN *HeaderSize OPTIONAL,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer,
+ OUT EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
+ OUT EFI_MAC_ADDRESS *DestAddr OPTIONAL,
+ OUT UINT16 *Protocol OPTIONAL
)
{
- EMU_SNP_PRIVATE *Private;
+ EMU_SNP_PRIVATE *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);
return EFI_UNSUPPORTED;
}
-
-EMU_SNP_PROTOCOL gEmuSnpProtocol = {
+EMU_SNP_PROTOCOL gEmuSnpProtocol = {
GasketSnpCreateMapping,
GasketSnpStart,
GasketSnpStop,
@@ -537,7 +533,7 @@ EMU_SNP_PROTOCOL gEmuSnpProtocol = {
EFI_STATUS
EmuSnpThunkOpen (
- IN EMU_IO_THUNK_PROTOCOL *This
+ IN EMU_IO_THUNK_PROTOCOL *This
)
{
EMU_SNP_PRIVATE *Private;
@@ -555,7 +551,6 @@ EmuSnpThunkOpen (
return EFI_OUT_OF_RESOURCES;
}
-
Private->Signature = EMU_SNP_PRIVATE_SIGNATURE;
Private->Thunk = This;
CopyMem (&Private->EmuSnp, &gEmuSnpProtocol, sizeof (gEmuSnpProtocol));
@@ -565,10 +560,9 @@ EmuSnpThunkOpen (
return EFI_SUCCESS;
}
-
EFI_STATUS
EmuSnpThunkClose (
- IN EMU_IO_THUNK_PROTOCOL *This
+ IN EMU_IO_THUNK_PROTOCOL *This
)
{
EMU_SNP_PRIVATE *Private;
@@ -583,9 +577,7 @@ EmuSnpThunkClose (
return EFI_SUCCESS;
}
-
-
-EMU_IO_THUNK_PROTOCOL gSnpThunkIo = {
+EMU_IO_THUNK_PROTOCOL gSnpThunkIo = {
&gEmuSnpProtocolGuid,
NULL,
NULL,
diff --git a/EmulatorPkg/Unix/Host/MemoryAllocationLib.c b/EmulatorPkg/Unix/Host/MemoryAllocationLib.c
index 456f451c16..4e3c8faa3c 100644
--- a/EmulatorPkg/Unix/Host/MemoryAllocationLib.c
+++ b/EmulatorPkg/Unix/Host/MemoryAllocationLib.c
@@ -30,10 +30,9 @@ AllocatePool (
IN UINTN AllocationSize
)
{
- return (VOID*) malloc (AllocationSize);
+ return (VOID *)malloc (AllocationSize);
}
-
/**
Allocates and zeros a buffer of type EfiBootServicesData.
@@ -53,7 +52,7 @@ AllocateZeroPool (
IN UINTN AllocationSize
)
{
- VOID *Buffer;
+ VOID *Buffer;
Buffer = AllocatePool (AllocationSize);
if (Buffer == NULL) {
@@ -65,7 +64,6 @@ AllocateZeroPool (
return Buffer;
}
-
/**
Reallocates a buffer of type EfiBootServicesData.
@@ -95,7 +93,7 @@ ReallocatePool (
IN VOID *OldBuffer OPTIONAL
)
{
- VOID *NewBuffer;
+ VOID *NewBuffer;
NewBuffer = AllocatePool (NewSize);
if (NewBuffer == NULL) {
@@ -113,7 +111,6 @@ ReallocatePool (
return NewBuffer;
}
-
/**
Frees a buffer that was previously allocated with one of the pool allocation functions in the
Memory Allocation Library.
@@ -131,9 +128,8 @@ ReallocatePool (
VOID
EFIAPI
FreePool (
- IN VOID *Buffer
+ IN VOID *Buffer
)
{
- free ((void *) Buffer);
+ free ((void *)Buffer);
}
-
diff --git a/EmulatorPkg/Unix/Host/PosixFileSystem.c b/EmulatorPkg/Unix/Host/PosixFileSystem.c
index 0a618abcd8..ae3fe72a05 100644
--- a/EmulatorPkg/Unix/Host/PosixFileSystem.c
+++ b/EmulatorPkg/Unix/Host/PosixFileSystem.c
@@ -10,16 +10,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "Host.h"
-
-#define EMU_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE SIGNATURE_32 ('E', 'P', 'f', 's')
+#define EMU_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE SIGNATURE_32 ('E', 'P', 'f', 's')
typedef struct {
- UINTN Signature;
- EMU_IO_THUNK_PROTOCOL *Thunk;
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL SimpleFileSystem;
- CHAR8 *FilePath;
- CHAR16 *VolumeLabel;
- BOOLEAN FileHandlesOpen;
+ UINTN Signature;
+ EMU_IO_THUNK_PROTOCOL *Thunk;
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL SimpleFileSystem;
+ CHAR8 *FilePath;
+ CHAR16 *VolumeLabel;
+ BOOLEAN FileHandlesOpen;
} EMU_SIMPLE_FILE_SYSTEM_PRIVATE;
#define EMU_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS(a) \
@@ -29,21 +28,20 @@ typedef struct {
EMU_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE \
)
-
-#define EMU_EFI_FILE_PRIVATE_SIGNATURE SIGNATURE_32 ('E', 'P', 'f', 'i')
+#define EMU_EFI_FILE_PRIVATE_SIGNATURE SIGNATURE_32 ('E', 'P', 'f', 'i')
typedef struct {
- UINTN Signature;
- EMU_IO_THUNK_PROTOCOL *Thunk;
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem;
- EFI_FILE_PROTOCOL EfiFile;
- int fd;
- DIR *Dir;
- BOOLEAN IsRootDirectory;
- BOOLEAN IsDirectoryPath;
- BOOLEAN IsOpenedByRead;
- char *FileName;
- struct dirent *Dirent;
+ UINTN Signature;
+ EMU_IO_THUNK_PROTOCOL *Thunk;
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem;
+ EFI_FILE_PROTOCOL EfiFile;
+ int fd;
+ DIR *Dir;
+ BOOLEAN IsRootDirectory;
+ BOOLEAN IsDirectoryPath;
+ BOOLEAN IsOpenedByRead;
+ char *FileName;
+ struct dirent *Dirent;
} EMU_EFI_FILE_PRIVATE;
#define EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS(a) \
@@ -55,22 +53,21 @@ typedef struct {
EFI_STATUS
PosixFileGetInfo (
- IN EFI_FILE_PROTOCOL *This,
- IN EFI_GUID *InformationType,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN EFI_GUID *InformationType,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
);
EFI_STATUS
PosixFileSetInfo (
- IN EFI_FILE_PROTOCOL *This,
- IN EFI_GUID *InformationType,
- IN UINTN BufferSize,
- IN VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN EFI_GUID *InformationType,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
);
-
-EFI_FILE_PROTOCOL gPosixFileProtocol = {
+EFI_FILE_PROTOCOL gPosixFileProtocol = {
EFI_FILE_REVISION,
GasketPosixFileOpen,
GasketPosixFileCLose,
@@ -84,12 +81,11 @@ EFI_FILE_PROTOCOL gPosixFileProtocol = {
GasketPosixFileFlush
};
-EFI_SIMPLE_FILE_SYSTEM_PROTOCOL gPosixFileSystemProtocol = {
+EFI_SIMPLE_FILE_SYSTEM_PROTOCOL gPosixFileSystemProtocol = {
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION,
GasketPosixOpenVolume,
};
-
/**
Open the root directory on a volume.
@@ -107,17 +103,17 @@ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL gPosixFileSystemProtocol = {
**/
EFI_STATUS
PosixOpenVolume (
- IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,
- OUT EFI_FILE_PROTOCOL **Root
+ IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,
+ OUT EFI_FILE_PROTOCOL **Root
)
{
- EFI_STATUS Status;
- EMU_SIMPLE_FILE_SYSTEM_PRIVATE *Private;
- EMU_EFI_FILE_PRIVATE *PrivateFile;
+ EFI_STATUS Status;
+ EMU_SIMPLE_FILE_SYSTEM_PRIVATE *Private;
+ EMU_EFI_FILE_PRIVATE *PrivateFile;
- Private = EMU_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (This);
+ Private = EMU_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (This);
- Status = EFI_OUT_OF_RESOURCES;
+ Status = EFI_OUT_OF_RESOURCES;
PrivateFile = malloc (sizeof (EMU_EFI_FILE_PRIVATE));
if (PrivateFile == NULL) {
goto Done;
@@ -127,24 +123,25 @@ PosixOpenVolume (
if (PrivateFile->FileName == NULL) {
goto Done;
}
+
AsciiStrCpyS (
PrivateFile->FileName,
AsciiStrSize (Private->FilePath),
Private->FilePath
);
- PrivateFile->Signature = EMU_EFI_FILE_PRIVATE_SIGNATURE;
- PrivateFile->Thunk = Private->Thunk;
- PrivateFile->SimpleFileSystem = This;
- PrivateFile->IsRootDirectory = TRUE;
- PrivateFile->IsDirectoryPath = TRUE;
- PrivateFile->IsOpenedByRead = TRUE;
+ PrivateFile->Signature = EMU_EFI_FILE_PRIVATE_SIGNATURE;
+ PrivateFile->Thunk = Private->Thunk;
+ PrivateFile->SimpleFileSystem = This;
+ PrivateFile->IsRootDirectory = TRUE;
+ PrivateFile->IsDirectoryPath = TRUE;
+ PrivateFile->IsOpenedByRead = TRUE;
CopyMem (&PrivateFile->EfiFile, &gPosixFileProtocol, sizeof (EFI_FILE_PROTOCOL));
- PrivateFile->fd = -1;
- PrivateFile->Dir = NULL;
- PrivateFile->Dirent = NULL;
+ PrivateFile->fd = -1;
+ PrivateFile->Dir = NULL;
+ PrivateFile->Dirent = NULL;
*Root = &PrivateFile->EfiFile;
@@ -171,27 +168,27 @@ Done:
return Status;
}
-
EFI_STATUS
-ErrnoToEfiStatus ()
+ErrnoToEfiStatus (
+ )
{
switch (errno) {
- case EACCES:
- return EFI_ACCESS_DENIED;
+ case EACCES:
+ return EFI_ACCESS_DENIED;
- case EDQUOT:
- case ENOSPC:
- return EFI_VOLUME_FULL;
+ case EDQUOT:
+ case ENOSPC:
+ return EFI_VOLUME_FULL;
- default:
- return EFI_DEVICE_ERROR;
+ default:
+ return EFI_DEVICE_ERROR;
}
}
VOID
CutPrefix (
IN CHAR8 *Str,
- IN UINTN Count
+ IN UINTN Count
)
{
CHAR8 *Pointer;
@@ -207,53 +204,51 @@ CutPrefix (
*Pointer = *(Pointer + Count);
}
-
VOID
PosixSystemTimeToEfiTime (
- IN time_t SystemTime,
- OUT EFI_TIME *Time
+ IN time_t SystemTime,
+ OUT EFI_TIME *Time
)
{
- struct tm *tm;
-
- tm = gmtime (&SystemTime);
- Time->Year = tm->tm_year;
- Time->Month = tm->tm_mon + 1;
- Time->Day = tm->tm_mday;
- Time->Hour = tm->tm_hour;
- Time->Minute = tm->tm_min;
- Time->Second = tm->tm_sec;
+ struct tm *tm;
+
+ tm = gmtime (&SystemTime);
+ Time->Year = tm->tm_year;
+ Time->Month = tm->tm_mon + 1;
+ Time->Day = tm->tm_mday;
+ Time->Hour = tm->tm_hour;
+ Time->Minute = tm->tm_min;
+ Time->Second = tm->tm_sec;
Time->Nanosecond = 0;
Time->TimeZone = timezone / 60;
Time->Daylight = (daylight ? EFI_TIME_ADJUST_DAYLIGHT : 0) | (tm->tm_isdst > 0 ? EFI_TIME_IN_DAYLIGHT : 0);
}
-
EFI_STATUS
UnixSimpleFileSystemFileInfo (
- EMU_EFI_FILE_PRIVATE *PrivateFile,
- IN CHAR8 *FileName,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
+ EMU_EFI_FILE_PRIVATE *PrivateFile,
+ IN CHAR8 *FileName,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
)
{
- EFI_STATUS Status;
- UINTN Size;
- UINTN NameSize;
- UINTN ResultSize;
- EFI_FILE_INFO *Info;
- CHAR8 *RealFileName;
- CHAR8 *TempPointer;
- CHAR16 *BufferFileName;
- struct stat buf;
+ EFI_STATUS Status;
+ UINTN Size;
+ UINTN NameSize;
+ UINTN ResultSize;
+ EFI_FILE_INFO *Info;
+ CHAR8 *RealFileName;
+ CHAR8 *TempPointer;
+ CHAR16 *BufferFileName;
+ struct stat buf;
if (FileName != NULL) {
RealFileName = FileName;
} else if (PrivateFile->IsRootDirectory) {
RealFileName = "";
} else {
- RealFileName = PrivateFile->FileName;
+ RealFileName = PrivateFile->FileName;
}
TempPointer = RealFileName;
@@ -265,26 +260,27 @@ UnixSimpleFileSystemFileInfo (
TempPointer++;
}
- Size = SIZE_OF_EFI_FILE_INFO;
- NameSize = AsciiStrSize (RealFileName) * 2;
- ResultSize = Size + NameSize;
+ Size = SIZE_OF_EFI_FILE_INFO;
+ NameSize = AsciiStrSize (RealFileName) * 2;
+ ResultSize = Size + NameSize;
if (*BufferSize < ResultSize) {
*BufferSize = ResultSize;
return EFI_BUFFER_TOO_SMALL;
}
- if (stat (FileName == NULL ? PrivateFile->FileName : FileName, &buf) < 0) {
+
+ if (stat ((FileName == NULL) ? PrivateFile->FileName : FileName, &buf) < 0) {
return EFI_DEVICE_ERROR;
}
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
- Info = Buffer;
+ Info = Buffer;
ZeroMem (Info, ResultSize);
- Info->Size = ResultSize;
- Info->FileSize = buf.st_size;
- Info->PhysicalSize = MultU64x32 (buf.st_blocks, buf.st_blksize);
+ Info->Size = ResultSize;
+ Info->FileSize = buf.st_size;
+ Info->PhysicalSize = MultU64x32 (buf.st_blocks, buf.st_blksize);
PosixSystemTimeToEfiTime (buf.st_ctime, &Info->CreateTime);
PosixSystemTimeToEfiTime (buf.st_atime, &Info->LastAccessTime);
@@ -294,15 +290,15 @@ UnixSimpleFileSystemFileInfo (
Info->Attribute |= EFI_FILE_READ_ONLY;
}
- if (S_ISDIR(buf.st_mode)) {
+ if (S_ISDIR (buf.st_mode)) {
Info->Attribute |= EFI_FILE_DIRECTORY;
}
-
- BufferFileName = (CHAR16 *)((CHAR8 *) Buffer + Size);
+ BufferFileName = (CHAR16 *)((CHAR8 *)Buffer + Size);
while (*RealFileName) {
*BufferFileName++ = *RealFileName++;
}
+
*BufferFileName = 0;
*BufferSize = ResultSize;
@@ -315,16 +311,16 @@ IsZero (
IN UINTN Length
)
{
- if (Buffer == NULL || Length == 0) {
+ if ((Buffer == NULL) || (Length == 0)) {
return FALSE;
}
- if (*(UINT8 *) Buffer != 0) {
+ if (*(UINT8 *)Buffer != 0) {
return FALSE;
}
if (Length > 1) {
- if (!CompareMem (Buffer, (UINT8 *) Buffer + 1, Length - 1)) {
+ if (!CompareMem (Buffer, (UINT8 *)Buffer + 1, Length - 1)) {
return FALSE;
}
}
@@ -332,8 +328,6 @@ IsZero (
return TRUE;
}
-
-
/**
Opens a new file relative to the source file's location.
@@ -356,37 +350,37 @@ IsZero (
**/
EFI_STATUS
PosixFileOpen (
- IN EFI_FILE_PROTOCOL *This,
- OUT EFI_FILE_PROTOCOL **NewHandle,
- IN CHAR16 *FileName,
- IN UINT64 OpenMode,
- IN UINT64 Attributes
+ IN EFI_FILE_PROTOCOL *This,
+ OUT EFI_FILE_PROTOCOL **NewHandle,
+ IN CHAR16 *FileName,
+ IN UINT64 OpenMode,
+ IN UINT64 Attributes
)
{
- EFI_FILE_PROTOCOL *Root;
- EMU_EFI_FILE_PRIVATE *PrivateFile;
- EMU_EFI_FILE_PRIVATE *NewPrivateFile;
- EMU_SIMPLE_FILE_SYSTEM_PRIVATE *PrivateRoot;
- EFI_STATUS Status;
- CHAR16 *Src;
- char *Dst;
- CHAR8 *RealFileName;
- char *ParseFileName;
- char *GuardPointer;
- CHAR8 TempChar;
- UINTN Count;
- BOOLEAN TrailingDash;
- BOOLEAN LoopFinish;
- UINTN InfoSize;
- EFI_FILE_INFO *Info;
- struct stat finfo;
- int res;
- UINTN Size;
-
- PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
- PrivateRoot = EMU_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (PrivateFile->SimpleFileSystem);
- NewPrivateFile = NULL;
- Status = EFI_OUT_OF_RESOURCES;
+ EFI_FILE_PROTOCOL *Root;
+ EMU_EFI_FILE_PRIVATE *PrivateFile;
+ EMU_EFI_FILE_PRIVATE *NewPrivateFile;
+ EMU_SIMPLE_FILE_SYSTEM_PRIVATE *PrivateRoot;
+ EFI_STATUS Status;
+ CHAR16 *Src;
+ char *Dst;
+ CHAR8 *RealFileName;
+ char *ParseFileName;
+ char *GuardPointer;
+ CHAR8 TempChar;
+ UINTN Count;
+ BOOLEAN TrailingDash;
+ BOOLEAN LoopFinish;
+ UINTN InfoSize;
+ EFI_FILE_INFO *Info;
+ struct stat finfo;
+ int res;
+ UINTN Size;
+
+ PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
+ PrivateRoot = EMU_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (PrivateFile->SimpleFileSystem);
+ NewPrivateFile = NULL;
+ Status = EFI_OUT_OF_RESOURCES;
//
// BUGBUG: assume an open of root
@@ -394,16 +388,17 @@ PosixFileOpen (
//
TrailingDash = FALSE;
if ((StrCmp (FileName, L"\\") == 0) ||
- (StrCmp (FileName, L".") == 0 && PrivateFile->IsRootDirectory)) {
+ ((StrCmp (FileName, L".") == 0) && PrivateFile->IsRootDirectory))
+ {
OpenRoot:
- Status = PosixOpenVolume (PrivateFile->SimpleFileSystem, &Root);
- NewPrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (Root);
+ Status = PosixOpenVolume (PrivateFile->SimpleFileSystem, &Root);
+ NewPrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (Root);
goto Done;
}
if (FileName[StrLen (FileName) - 1] == L'\\') {
- TrailingDash = TRUE;
- FileName[StrLen (FileName) - 1] = 0;
+ TrailingDash = TRUE;
+ FileName[StrLen (FileName) - 1] = 0;
}
//
@@ -416,7 +411,7 @@ OpenRoot:
CopyMem (NewPrivateFile, PrivateFile, sizeof (EMU_EFI_FILE_PRIVATE));
- Size = AsciiStrSize (PrivateFile->FileName) + 1 + StrLen (FileName) + 1;
+ Size = AsciiStrSize (PrivateFile->FileName) + 1 + StrLen (FileName) + 1;
NewPrivateFile->FileName = malloc (Size);
if (NewPrivateFile->FileName == NULL) {
goto Done;
@@ -430,9 +425,10 @@ OpenRoot:
AsciiStrCpyS (NewPrivateFile->FileName, Size, PrivateFile->FileName);
Src = FileName;
}
- Dst = NewPrivateFile->FileName + AsciiStrLen (NewPrivateFile->FileName);
+
+ Dst = NewPrivateFile->FileName + AsciiStrLen (NewPrivateFile->FileName);
GuardPointer = NewPrivateFile->FileName + AsciiStrLen (PrivateRoot->FilePath);
- *Dst++ = '/';
+ *Dst++ = '/';
// Convert unicode to ascii and '\' to '/'
while (*Src) {
if (*Src == '\\') {
@@ -440,10 +436,11 @@ OpenRoot:
} else {
*Dst++ = *Src;
}
+
Src++;
}
- *Dst = 0;
+ *Dst = 0;
//
// Get rid of . and .., except leading . or ..
@@ -453,16 +450,16 @@ OpenRoot:
// GuardPointer protect simplefilesystem root path not be destroyed
//
- LoopFinish = FALSE;
+ LoopFinish = FALSE;
while (!LoopFinish) {
LoopFinish = TRUE;
for (ParseFileName = GuardPointer; *ParseFileName; ParseFileName++) {
- if (*ParseFileName == '.' &&
- (*(ParseFileName + 1) == 0 || *(ParseFileName + 1) == '/') &&
- *(ParseFileName - 1) == '/'
- ) {
-
+ if ((*ParseFileName == '.') &&
+ ((*(ParseFileName + 1) == 0) || (*(ParseFileName + 1) == '/')) &&
+ (*(ParseFileName - 1) == '/')
+ )
+ {
//
// cut /.
//
@@ -471,12 +468,12 @@ OpenRoot:
break;
}
- if (*ParseFileName == '.' &&
- *(ParseFileName + 1) == '.' &&
- (*(ParseFileName + 2) == 0 || *(ParseFileName + 2) == '/') &&
- *(ParseFileName - 1) == '/'
- ) {
-
+ if ((*ParseFileName == '.') &&
+ (*(ParseFileName + 1) == '.') &&
+ ((*(ParseFileName + 2) == 0) || (*(ParseFileName + 2) == '/')) &&
+ (*(ParseFileName - 1) == '/')
+ )
+ {
ParseFileName--;
Count = 3;
@@ -505,7 +502,7 @@ OpenRoot:
goto OpenRoot;
}
- RealFileName = NewPrivateFile->FileName + AsciiStrLen(NewPrivateFile->FileName) - 1;
+ RealFileName = NewPrivateFile->FileName + AsciiStrLen (NewPrivateFile->FileName) - 1;
while (RealFileName > NewPrivateFile->FileName && *RealFileName != '/') {
RealFileName--;
}
@@ -514,13 +511,12 @@ OpenRoot:
*(RealFileName - 1) = 0;
*(RealFileName - 1) = TempChar;
-
//
// Test whether file or directory
//
NewPrivateFile->IsRootDirectory = FALSE;
- NewPrivateFile->fd = -1;
- NewPrivateFile->Dir = NULL;
+ NewPrivateFile->fd = -1;
+ NewPrivateFile->Dir = NULL;
if (OpenMode & EFI_FILE_MODE_CREATE) {
if (Attributes & EFI_FILE_DIRECTORY) {
NewPrivateFile->IsDirectoryPath = TRUE;
@@ -529,7 +525,7 @@ OpenRoot:
}
} else {
res = stat (NewPrivateFile->FileName, &finfo);
- if (res == 0 && S_ISDIR(finfo.st_mode)) {
+ if ((res == 0) && S_ISDIR (finfo.st_mode)) {
NewPrivateFile->IsDirectoryPath = TRUE;
} else {
NewPrivateFile->IsDirectoryPath = FALSE;
@@ -554,7 +550,7 @@ OpenRoot:
//
if (mkdir (NewPrivateFile->FileName, 0777) != 0) {
if (errno != EEXIST) {
- //free (TempFileName);
+ // free (TempFileName);
Status = EFI_ACCESS_DENIED;
goto Done;
}
@@ -571,16 +567,15 @@ OpenRoot:
goto Done;
}
-
} else {
//
// deal with file
//
NewPrivateFile->fd = open (
- NewPrivateFile->FileName,
- ((OpenMode & EFI_FILE_MODE_CREATE) ? O_CREAT : 0) | (NewPrivateFile->IsOpenedByRead ? O_RDONLY : O_RDWR),
- 0666
- );
+ NewPrivateFile->FileName,
+ ((OpenMode & EFI_FILE_MODE_CREATE) ? O_CREAT : 0) | (NewPrivateFile->IsOpenedByRead ? O_RDONLY : O_RDWR),
+ 0666
+ );
if (NewPrivateFile->fd < 0) {
if (errno == ENOENT) {
Status = EFI_NOT_FOUND;
@@ -590,13 +585,13 @@ OpenRoot:
}
}
- if ((OpenMode & EFI_FILE_MODE_CREATE) && Status == EFI_SUCCESS) {
+ if ((OpenMode & EFI_FILE_MODE_CREATE) && (Status == EFI_SUCCESS)) {
//
// Set the attribute
//
- InfoSize = 0;
- Info = NULL;
- Status = PosixFileGetInfo (&NewPrivateFile->EfiFile, &gEfiFileInfoGuid, &InfoSize, Info);
+ InfoSize = 0;
+ Info = NULL;
+ Status = PosixFileGetInfo (&NewPrivateFile->EfiFile, &gEfiFileInfoGuid, &InfoSize, Info);
if (Status != EFI_BUFFER_TOO_SMALL) {
Status = EFI_DEVICE_ERROR;
goto Done;
@@ -618,10 +613,10 @@ OpenRoot:
free (Info);
}
-Done: ;
+Done:;
if (TrailingDash) {
- FileName[StrLen (FileName) + 1] = 0;
- FileName[StrLen (FileName)] = L'\\';
+ FileName[StrLen (FileName) + 1] = 0;
+ FileName[StrLen (FileName)] = L'\\';
}
if (EFI_ERROR (Status)) {
@@ -639,8 +634,6 @@ Done: ;
return Status;
}
-
-
/**
Close the file handle
@@ -654,18 +647,19 @@ PosixFileCLose (
IN EFI_FILE_PROTOCOL *This
)
{
- EMU_EFI_FILE_PRIVATE *PrivateFile;
+ EMU_EFI_FILE_PRIVATE *PrivateFile;
PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
if (PrivateFile->fd >= 0) {
close (PrivateFile->fd);
}
+
if (PrivateFile->Dir != NULL) {
closedir (PrivateFile->Dir);
}
- PrivateFile->fd = -1;
+ PrivateFile->fd = -1;
PrivateFile->Dir = NULL;
if (PrivateFile->FileName) {
@@ -677,7 +671,6 @@ PosixFileCLose (
return EFI_SUCCESS;
}
-
/**
Close and delete the file handle.
@@ -692,8 +685,8 @@ PosixFileDelete (
IN EFI_FILE_PROTOCOL *This
)
{
- EFI_STATUS Status;
- EMU_EFI_FILE_PRIVATE *PrivateFile;
+ EFI_STATUS Status;
+ EMU_EFI_FILE_PRIVATE *PrivateFile;
PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
Status = EFI_WARN_DELETE_FAILURE;
@@ -724,7 +717,6 @@ PosixFileDelete (
return Status;
}
-
/**
Read data from the file.
@@ -741,19 +733,19 @@ PosixFileDelete (
**/
EFI_STATUS
PosixFileRead (
- IN EFI_FILE_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
)
{
- EMU_EFI_FILE_PRIVATE *PrivateFile;
- EFI_STATUS Status;
- int Res;
- UINTN Size;
- UINTN NameSize;
- UINTN ResultSize;
- CHAR8 *FullFileName;
- UINTN FullFileNameSize;
+ EMU_EFI_FILE_PRIVATE *PrivateFile;
+ EFI_STATUS Status;
+ int Res;
+ UINTN Size;
+ UINTN NameSize;
+ UINTN ResultSize;
+ CHAR8 *FullFileName;
+ UINTN FullFileNameSize;
PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
@@ -768,8 +760,9 @@ PosixFileRead (
Status = EFI_DEVICE_ERROR;
goto Done;
}
+
*BufferSize = Res;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
goto Done;
}
@@ -785,26 +778,27 @@ PosixFileRead (
PrivateFile->Dirent = readdir (PrivateFile->Dir);
if (PrivateFile->Dirent == NULL) {
*BufferSize = 0;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
goto Done;
}
}
- Size = SIZE_OF_EFI_FILE_INFO;
- NameSize = AsciiStrLen (PrivateFile->Dirent->d_name) + 1;
- ResultSize = Size + 2 * NameSize;
+ Size = SIZE_OF_EFI_FILE_INFO;
+ NameSize = AsciiStrLen (PrivateFile->Dirent->d_name) + 1;
+ ResultSize = Size + 2 * NameSize;
if (*BufferSize < ResultSize) {
*BufferSize = ResultSize;
- Status = EFI_BUFFER_TOO_SMALL;
+ Status = EFI_BUFFER_TOO_SMALL;
goto Done;
}
- Status = EFI_SUCCESS;
+
+ Status = EFI_SUCCESS;
*BufferSize = ResultSize;
- FullFileNameSize = AsciiStrLen(PrivateFile->FileName) + 1 + NameSize;
- FullFileName = malloc (FullFileNameSize);
+ FullFileNameSize = AsciiStrLen (PrivateFile->FileName) + 1 + NameSize;
+ FullFileName = malloc (FullFileNameSize);
if (FullFileName == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Done;
@@ -814,11 +808,11 @@ PosixFileRead (
AsciiStrCatS (FullFileName, FullFileNameSize, "/");
AsciiStrCatS (FullFileName, FullFileNameSize, PrivateFile->Dirent->d_name);
Status = UnixSimpleFileSystemFileInfo (
- PrivateFile,
- FullFileName,
- BufferSize,
- Buffer
- );
+ PrivateFile,
+ FullFileName,
+ BufferSize,
+ Buffer
+ );
free (FullFileName);
PrivateFile->Dirent = NULL;
@@ -827,8 +821,6 @@ Done:
return Status;
}
-
-
/**
Write data to a file.
@@ -849,15 +841,14 @@ Done:
**/
EFI_STATUS
PosixFileWrite (
- IN EFI_FILE_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- IN VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN OUT UINTN *BufferSize,
+ IN VOID *Buffer
)
{
EMU_EFI_FILE_PRIVATE *PrivateFile;
int Res;
-
PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
if (PrivateFile->fd < 0) {
@@ -881,8 +872,6 @@ PosixFileWrite (
return EFI_SUCCESS;
}
-
-
/**
Set a files current position
@@ -895,12 +884,12 @@ PosixFileWrite (
**/
EFI_STATUS
PosixFileSetPossition (
- IN EFI_FILE_PROTOCOL *This,
- IN UINT64 Position
+ IN EFI_FILE_PROTOCOL *This,
+ IN UINT64 Position
)
{
- EMU_EFI_FILE_PRIVATE *PrivateFile;
- off_t Pos;
+ EMU_EFI_FILE_PRIVATE *PrivateFile;
+ off_t Pos;
PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
@@ -912,23 +901,24 @@ PosixFileSetPossition (
if (PrivateFile->Dir == NULL) {
return EFI_DEVICE_ERROR;
}
+
rewinddir (PrivateFile->Dir);
return EFI_SUCCESS;
} else {
- if (Position == (UINT64) -1) {
+ if (Position == (UINT64)-1) {
Pos = lseek (PrivateFile->fd, 0, SEEK_END);
} else {
Pos = lseek (PrivateFile->fd, Position, SEEK_SET);
}
+
if (Pos == (off_t)-1) {
return ErrnoToEfiStatus ();
}
+
return EFI_SUCCESS;
}
}
-
-
/**
Get a file's current position
@@ -941,26 +931,25 @@ PosixFileSetPossition (
**/
EFI_STATUS
PosixFileGetPossition (
- IN EFI_FILE_PROTOCOL *This,
- OUT UINT64 *Position
+ IN EFI_FILE_PROTOCOL *This,
+ OUT UINT64 *Position
)
{
EFI_STATUS Status;
EMU_EFI_FILE_PRIVATE *PrivateFile;
- PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
+ PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
if (PrivateFile->IsDirectoryPath) {
Status = EFI_UNSUPPORTED;
} else {
*Position = (UINT64)lseek (PrivateFile->fd, 0, SEEK_CUR);
- Status = (*Position == (UINT64) -1) ? ErrnoToEfiStatus () : EFI_SUCCESS;
+ Status = (*Position == (UINT64)-1) ? ErrnoToEfiStatus () : EFI_SUCCESS;
}
return Status;
}
-
/**
Get information about a file.
@@ -981,18 +970,18 @@ PosixFileGetPossition (
**/
EFI_STATUS
PosixFileGetInfo (
- IN EFI_FILE_PROTOCOL *This,
- IN EFI_GUID *InformationType,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN EFI_GUID *InformationType,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
)
{
- EFI_STATUS Status;
- EMU_EFI_FILE_PRIVATE *PrivateFile;
- EFI_FILE_SYSTEM_INFO *FileSystemInfoBuffer;
- int UnixStatus;
- EMU_SIMPLE_FILE_SYSTEM_PRIVATE *PrivateRoot;
- struct statfs buf;
+ EFI_STATUS Status;
+ EMU_EFI_FILE_PRIVATE *PrivateFile;
+ EFI_FILE_SYSTEM_INFO *FileSystemInfoBuffer;
+ int UnixStatus;
+ EMU_SIMPLE_FILE_SYSTEM_PRIVATE *PrivateRoot;
+ struct statfs buf;
PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
PrivateRoot = EMU_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (PrivateFile->SimpleFileSystem);
@@ -1011,25 +1000,23 @@ PosixFileGetInfo (
return EFI_DEVICE_ERROR;
}
- FileSystemInfoBuffer = (EFI_FILE_SYSTEM_INFO *) Buffer;
- FileSystemInfoBuffer->Size = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel);
- FileSystemInfoBuffer->ReadOnly = FALSE;
+ FileSystemInfoBuffer = (EFI_FILE_SYSTEM_INFO *)Buffer;
+ FileSystemInfoBuffer->Size = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel);
+ FileSystemInfoBuffer->ReadOnly = FALSE;
//
// Succeeded
//
- FileSystemInfoBuffer->VolumeSize = MultU64x32 (buf.f_blocks, buf.f_bsize);
- FileSystemInfoBuffer->FreeSpace = MultU64x32 (buf.f_bavail, buf.f_bsize);
- FileSystemInfoBuffer->BlockSize = buf.f_bsize;
-
+ FileSystemInfoBuffer->VolumeSize = MultU64x32 (buf.f_blocks, buf.f_bsize);
+ FileSystemInfoBuffer->FreeSpace = MultU64x32 (buf.f_bavail, buf.f_bsize);
+ FileSystemInfoBuffer->BlockSize = buf.f_bsize;
StrCpyS (
- (CHAR16 *) FileSystemInfoBuffer->VolumeLabel,
+ (CHAR16 *)FileSystemInfoBuffer->VolumeLabel,
(*BufferSize - SIZE_OF_EFI_FILE_SYSTEM_INFO) / sizeof (CHAR16),
PrivateRoot->VolumeLabel
);
*BufferSize = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel);
-
} else if (CompareGuid (InformationType, &gEfiFileSystemVolumeLabelInfoIdGuid)) {
if (*BufferSize < StrSize (PrivateRoot->VolumeLabel)) {
*BufferSize = StrSize (PrivateRoot->VolumeLabel);
@@ -1037,18 +1024,16 @@ PosixFileGetInfo (
}
StrCpyS (
- (CHAR16 *) Buffer,
+ (CHAR16 *)Buffer,
*BufferSize / sizeof (CHAR16),
PrivateRoot->VolumeLabel
);
*BufferSize = StrSize (PrivateRoot->VolumeLabel);
-
}
return Status;
}
-
/**
Set information about a file
@@ -1068,42 +1053,42 @@ PosixFileGetInfo (
**/
EFI_STATUS
PosixFileSetInfo (
- IN EFI_FILE_PROTOCOL *This,
- IN EFI_GUID *InformationType,
- IN UINTN BufferSize,
- IN VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN EFI_GUID *InformationType,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
)
{
- EMU_SIMPLE_FILE_SYSTEM_PRIVATE *PrivateRoot;
- EMU_EFI_FILE_PRIVATE *PrivateFile;
- EFI_FILE_INFO *OldFileInfo;
- EFI_FILE_INFO *NewFileInfo;
- EFI_STATUS Status;
- UINTN OldInfoSize;
- mode_t NewAttr;
- struct stat OldAttr;
- CHAR8 *OldFileName;
- CHAR8 *NewFileName;
- CHAR8 *CharPointer;
- BOOLEAN AttrChangeFlag;
- BOOLEAN NameChangeFlag;
- BOOLEAN SizeChangeFlag;
- BOOLEAN TimeChangeFlag;
- struct tm NewLastAccessSystemTime;
- struct tm NewLastWriteSystemTime;
- EFI_FILE_SYSTEM_INFO *NewFileSystemInfo;
- CHAR8 *AsciiFilePtr;
- CHAR16 *UnicodeFilePtr;
- int UnixStatus;
- struct utimbuf Utime;
- UINTN Size;
-
- PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
- PrivateRoot = EMU_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (PrivateFile->SimpleFileSystem);
- errno = 0;
- Status = EFI_UNSUPPORTED;
- OldFileInfo = NewFileInfo = NULL;
- OldFileName = NewFileName = NULL;
+ EMU_SIMPLE_FILE_SYSTEM_PRIVATE *PrivateRoot;
+ EMU_EFI_FILE_PRIVATE *PrivateFile;
+ EFI_FILE_INFO *OldFileInfo;
+ EFI_FILE_INFO *NewFileInfo;
+ EFI_STATUS Status;
+ UINTN OldInfoSize;
+ mode_t NewAttr;
+ struct stat OldAttr;
+ CHAR8 *OldFileName;
+ CHAR8 *NewFileName;
+ CHAR8 *CharPointer;
+ BOOLEAN AttrChangeFlag;
+ BOOLEAN NameChangeFlag;
+ BOOLEAN SizeChangeFlag;
+ BOOLEAN TimeChangeFlag;
+ struct tm NewLastAccessSystemTime;
+ struct tm NewLastWriteSystemTime;
+ EFI_FILE_SYSTEM_INFO *NewFileSystemInfo;
+ CHAR8 *AsciiFilePtr;
+ CHAR16 *UnicodeFilePtr;
+ int UnixStatus;
+ struct utimbuf Utime;
+ UINTN Size;
+
+ PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
+ PrivateRoot = EMU_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (PrivateFile->SimpleFileSystem);
+ errno = 0;
+ Status = EFI_UNSUPPORTED;
+ OldFileInfo = NewFileInfo = NULL;
+ OldFileName = NewFileName = NULL;
AttrChangeFlag = NameChangeFlag = SizeChangeFlag = TimeChangeFlag = FALSE;
//
@@ -1115,7 +1100,7 @@ PosixFileSetInfo (
goto Done;
}
- NewFileSystemInfo = (EFI_FILE_SYSTEM_INFO *) Buffer;
+ NewFileSystemInfo = (EFI_FILE_SYSTEM_INFO *)Buffer;
free (PrivateRoot->VolumeLabel);
@@ -1146,7 +1131,7 @@ PosixFileSetInfo (
StrCpyS (
PrivateRoot->VolumeLabel,
StrSize (PrivateRoot->VolumeLabel) / sizeof (CHAR16),
- (CHAR16 *) Buffer
+ (CHAR16 *)Buffer
);
Status = EFI_SUCCESS;
@@ -1170,11 +1155,12 @@ PosixFileSetInfo (
//
// Check for invalid set file information parameters.
//
- NewFileInfo = (EFI_FILE_INFO *) Buffer;
- if (NewFileInfo->Size <= sizeof (EFI_FILE_INFO) ||
+ NewFileInfo = (EFI_FILE_INFO *)Buffer;
+ if ((NewFileInfo->Size <= sizeof (EFI_FILE_INFO)) ||
(NewFileInfo->Attribute &~(EFI_FILE_VALID_ATTR)) ||
- (sizeof (UINTN) == 4 && NewFileInfo->Size > 0xFFFFFFFF)
- ) {
+ ((sizeof (UINTN) == 4) && (NewFileInfo->Size > 0xFFFFFFFF))
+ )
+ {
Status = EFI_INVALID_PARAMETER;
goto Done;
}
@@ -1184,7 +1170,7 @@ PosixFileSetInfo (
// of change request this is.
//
OldInfoSize = 0;
- Status = UnixSimpleFileSystemFileInfo (PrivateFile, NULL, &OldInfoSize, NULL);
+ Status = UnixSimpleFileSystemFileInfo (PrivateFile, NULL, &OldInfoSize, NULL);
if (Status != EFI_BUFFER_TOO_SMALL) {
Status = EFI_DEVICE_ERROR;
goto Done;
@@ -1215,37 +1201,40 @@ PosixFileSetInfo (
// Make full pathname from new filename and rootpath.
//
if (NewFileInfo->FileName[0] == '\\') {
- Size = AsciiStrLen (PrivateRoot->FilePath) + 1 + StrLen (NewFileInfo->FileName) + 1;
+ Size = AsciiStrLen (PrivateRoot->FilePath) + 1 + StrLen (NewFileInfo->FileName) + 1;
NewFileName = malloc (Size);
if (NewFileName == NULL) {
goto Done;
}
AsciiStrCpyS (NewFileName, Size, PrivateRoot->FilePath);
- AsciiFilePtr = NewFileName + AsciiStrLen(NewFileName);
- UnicodeFilePtr = NewFileInfo->FileName + 1;
- *AsciiFilePtr++ ='/';
+ AsciiFilePtr = NewFileName + AsciiStrLen (NewFileName);
+ UnicodeFilePtr = NewFileInfo->FileName + 1;
+ *AsciiFilePtr++ = '/';
} else {
- Size = AsciiStrLen (PrivateFile->FileName) + 2 + StrLen (NewFileInfo->FileName) + 1;
+ Size = AsciiStrLen (PrivateFile->FileName) + 2 + StrLen (NewFileInfo->FileName) + 1;
NewFileName = malloc (Size);
if (NewFileName == NULL) {
goto Done;
}
AsciiStrCpyS (NewFileName, Size, PrivateRoot->FilePath);
- AsciiFilePtr = NewFileName + AsciiStrLen(NewFileName);
+ AsciiFilePtr = NewFileName + AsciiStrLen (NewFileName);
if ((AsciiFilePtr[-1] != '/') && (NewFileInfo->FileName[0] != '/')) {
// make sure there is a / between Root FilePath and NewFileInfo Filename
AsciiFilePtr[0] = '/';
AsciiFilePtr[1] = '\0';
AsciiFilePtr++;
}
+
UnicodeFilePtr = NewFileInfo->FileName;
}
+
// Convert to ascii.
while (*UnicodeFilePtr) {
*AsciiFilePtr++ = *UnicodeFilePtr++;
}
+
*AsciiFilePtr = 0;
//
@@ -1280,15 +1269,18 @@ PosixFileSetInfo (
//
if (!IsZero (&NewFileInfo->CreateTime, sizeof (EFI_TIME)) &&
CompareMem (&NewFileInfo->CreateTime, &OldFileInfo->CreateTime, sizeof (EFI_TIME))
- ) {
+ )
+ {
TimeChangeFlag = TRUE;
} else if (!IsZero (&NewFileInfo->LastAccessTime, sizeof (EFI_TIME)) &&
CompareMem (&NewFileInfo->LastAccessTime, &OldFileInfo->LastAccessTime, sizeof (EFI_TIME))
- ) {
+ )
+ {
TimeChangeFlag = TRUE;
} else if (!IsZero (&NewFileInfo->ModificationTime, sizeof (EFI_TIME)) &&
CompareMem (&NewFileInfo->ModificationTime, &OldFileInfo->ModificationTime, sizeof (EFI_TIME))
- ) {
+ )
+ {
TimeChangeFlag = TRUE;
}
@@ -1346,7 +1338,7 @@ PosixFileSetInfo (
NewFileName
);
} else {
- Status = EFI_DEVICE_ERROR;
+ Status = EFI_DEVICE_ERROR;
goto Done;
}
}
@@ -1369,34 +1361,33 @@ PosixFileSetInfo (
Status = ErrnoToEfiStatus ();
goto Done;
}
-
}
//
// Time change
//
if (TimeChangeFlag) {
- NewLastAccessSystemTime.tm_year = NewFileInfo->LastAccessTime.Year;
- NewLastAccessSystemTime.tm_mon = NewFileInfo->LastAccessTime.Month;
- NewLastAccessSystemTime.tm_mday = NewFileInfo->LastAccessTime.Day;
- NewLastAccessSystemTime.tm_hour = NewFileInfo->LastAccessTime.Hour;
- NewLastAccessSystemTime.tm_min = NewFileInfo->LastAccessTime.Minute;
- NewLastAccessSystemTime.tm_sec = NewFileInfo->LastAccessTime.Second;
- NewLastAccessSystemTime.tm_isdst = 0;
+ NewLastAccessSystemTime.tm_year = NewFileInfo->LastAccessTime.Year;
+ NewLastAccessSystemTime.tm_mon = NewFileInfo->LastAccessTime.Month;
+ NewLastAccessSystemTime.tm_mday = NewFileInfo->LastAccessTime.Day;
+ NewLastAccessSystemTime.tm_hour = NewFileInfo->LastAccessTime.Hour;
+ NewLastAccessSystemTime.tm_min = NewFileInfo->LastAccessTime.Minute;
+ NewLastAccessSystemTime.tm_sec = NewFileInfo->LastAccessTime.Second;
+ NewLastAccessSystemTime.tm_isdst = 0;
Utime.actime = mktime (&NewLastAccessSystemTime);
- NewLastWriteSystemTime.tm_year = NewFileInfo->ModificationTime.Year;
- NewLastWriteSystemTime.tm_mon = NewFileInfo->ModificationTime.Month;
- NewLastWriteSystemTime.tm_mday = NewFileInfo->ModificationTime.Day;
- NewLastWriteSystemTime.tm_hour = NewFileInfo->ModificationTime.Hour;
- NewLastWriteSystemTime.tm_min = NewFileInfo->ModificationTime.Minute;
- NewLastWriteSystemTime.tm_sec = NewFileInfo->ModificationTime.Second;
- NewLastWriteSystemTime.tm_isdst = 0;
+ NewLastWriteSystemTime.tm_year = NewFileInfo->ModificationTime.Year;
+ NewLastWriteSystemTime.tm_mon = NewFileInfo->ModificationTime.Month;
+ NewLastWriteSystemTime.tm_mday = NewFileInfo->ModificationTime.Day;
+ NewLastWriteSystemTime.tm_hour = NewFileInfo->ModificationTime.Hour;
+ NewLastWriteSystemTime.tm_min = NewFileInfo->ModificationTime.Minute;
+ NewLastWriteSystemTime.tm_sec = NewFileInfo->ModificationTime.Second;
+ NewLastWriteSystemTime.tm_isdst = 0;
Utime.modtime = mktime (&NewLastWriteSystemTime);
- if (Utime.actime == (time_t)-1 || Utime.modtime == (time_t)-1) {
+ if ((Utime.actime == (time_t)-1) || (Utime.modtime == (time_t)-1)) {
goto Done;
}
@@ -1438,7 +1429,6 @@ Done:
return Status;
}
-
/**
Flush data back for the file handle.
@@ -1459,8 +1449,7 @@ PosixFileFlush (
IN EFI_FILE_PROTOCOL *This
)
{
- EMU_EFI_FILE_PRIVATE *PrivateFile;
-
+ EMU_EFI_FILE_PRIVATE *PrivateFile;
PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
@@ -1483,11 +1472,9 @@ PosixFileFlush (
return EFI_SUCCESS;
}
-
-
EFI_STATUS
PosixFileSystmeThunkOpen (
- IN EMU_IO_THUNK_PROTOCOL *This
+ IN EMU_IO_THUNK_PROTOCOL *This
)
{
EMU_SIMPLE_FILE_SYSTEM_PRIVATE *Private;
@@ -1516,8 +1503,8 @@ PosixFileSystmeThunkOpen (
for (i = 0; This->ConfigString[i] != 0; i++) {
Private->FilePath[i] = This->ConfigString[i];
}
- Private->FilePath[i] = 0;
+ Private->FilePath[i] = 0;
Private->VolumeLabel = malloc (StrSize (L"EFI_EMULATED"));
if (Private->VolumeLabel == NULL) {
@@ -1525,6 +1512,7 @@ PosixFileSystmeThunkOpen (
free (Private);
return EFI_OUT_OF_RESOURCES;
}
+
StrCpyS (
Private->VolumeLabel,
StrSize (L"EFI_EMULATED") / sizeof (CHAR16),
@@ -1541,10 +1529,9 @@ PosixFileSystmeThunkOpen (
return EFI_SUCCESS;
}
-
EFI_STATUS
PosixFileSystmeThunkClose (
- IN EMU_IO_THUNK_PROTOCOL *This
+ IN EMU_IO_THUNK_PROTOCOL *This
)
{
EMU_SIMPLE_FILE_SYSTEM_PRIVATE *Private;
@@ -1566,6 +1553,7 @@ PosixFileSystmeThunkClose (
if (Private->VolumeLabel != NULL) {
free (Private->VolumeLabel);
}
+
free (This->Private);
This->Private = NULL;
}
@@ -1573,8 +1561,7 @@ PosixFileSystmeThunkClose (
return EFI_SUCCESS;
}
-
-EMU_IO_THUNK_PROTOCOL gPosixFileSystemThunkIo = {
+EMU_IO_THUNK_PROTOCOL gPosixFileSystemThunkIo = {
&gEfiSimpleFileSystemProtocolGuid,
NULL,
NULL,
@@ -1583,5 +1570,3 @@ EMU_IO_THUNK_PROTOCOL gPosixFileSystemThunkIo = {
GasketPosixFileSystmeThunkClose,
NULL
};
-
-
diff --git a/EmulatorPkg/Unix/Host/Pthreads.c b/EmulatorPkg/Unix/Host/Pthreads.c
index 025687c356..ec3a38e573 100644
--- a/EmulatorPkg/Unix/Host/Pthreads.c
+++ b/EmulatorPkg/Unix/Host/Pthreads.c
@@ -12,48 +12,43 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "Host.h"
#include <pthread.h>
-
UINTN
EFIAPI
PthreadMutexLock (
- IN VOID *Mutex
+ IN VOID *Mutex
)
{
return (UINTN)pthread_mutex_lock ((pthread_mutex_t *)Mutex);
}
-
-
UINTN
EFIAPI
PthreadMutexUnLock (
- IN VOID *Mutex
+ IN VOID *Mutex
)
{
return (UINTN)pthread_mutex_unlock ((pthread_mutex_t *)Mutex);
}
-
UINTN
EFIAPI
PthreadMutexTryLock (
- IN VOID *Mutex
+ IN VOID *Mutex
)
{
return (UINTN)pthread_mutex_trylock ((pthread_mutex_t *)Mutex);
}
-
VOID *
PthreadMutexInit (
IN VOID
)
{
- pthread_mutex_t *Mutex;
- int err;
+ pthread_mutex_t *Mutex;
+ int err;
Mutex = malloc (sizeof (pthread_mutex_t));
- err = pthread_mutex_init (Mutex, NULL);
+ err = pthread_mutex_init (Mutex, NULL);
if (err == 0) {
return Mutex;
}
@@ -61,10 +56,9 @@ PthreadMutexInit (
return NULL;
}
-
UINTN
PthreadMutexDestroy (
- IN VOID *Mutex
+ IN VOID *Mutex
)
{
if (Mutex != NULL) {
@@ -76,11 +70,11 @@ PthreadMutexDestroy (
// Can't store this data on PthreadCreate stack so we need a global
typedef struct {
- pthread_mutex_t Mutex;
- THREAD_THUNK_THREAD_ENTRY Start;
+ pthread_mutex_t Mutex;
+ THREAD_THUNK_THREAD_ENTRY Start;
} THREAD_MANGLE;
-THREAD_MANGLE mThreadMangle = {
+THREAD_MANGLE mThreadMangle = {
PTHREAD_MUTEX_INITIALIZER,
NULL
};
@@ -90,11 +84,11 @@ SecFakePthreadStart (
VOID *Context
)
{
- THREAD_THUNK_THREAD_ENTRY Start;
- sigset_t SigMask;
+ THREAD_THUNK_THREAD_ENTRY Start;
+ sigset_t SigMask;
// Save global on the stack before we unlock
- Start = mThreadMangle.Start;
+ Start = mThreadMangle.Start;
pthread_mutex_unlock (&mThreadMangle.Mutex);
// Mask all signals to the APs
@@ -109,19 +103,19 @@ SecFakePthreadStart (
// This is a great example of how all problems in computer
// science can be solved by adding another level of indirection
//
- return (VOID *)ReverseGasketUint64 ((UINTN)Start, (UINTN)Context);
+ return (VOID *)ReverseGasketUint64 ((UINTN)Start, (UINTN)Context);
}
UINTN
PthreadCreate (
- IN VOID *Thread,
- IN VOID *Attribute,
- IN THREAD_THUNK_THREAD_ENTRY Start,
- IN VOID *Context
+ IN VOID *Thread,
+ IN VOID *Attribute,
+ IN THREAD_THUNK_THREAD_ENTRY Start,
+ IN VOID *Context
)
{
- int err;
- BOOLEAN EnabledOnEntry;
+ int err;
+ BOOLEAN EnabledOnEntry;
//
// Threads inherit interrupt state so disable interrupts before we start thread
@@ -135,7 +129,7 @@ PthreadCreate (
// Acquire lock for global, SecFakePthreadStart runs in a different thread.
pthread_mutex_lock (&mThreadMangle.Mutex);
- mThreadMangle.Start = Start;
+ mThreadMangle.Start = Start;
err = pthread_create (Thread, Attribute, SecFakePthreadStart, Context);
if (err != 0) {
@@ -151,17 +145,15 @@ PthreadCreate (
return err;
}
-
VOID
PthreadExit (
- IN VOID *ValuePtr
+ IN VOID *ValuePtr
)
{
pthread_exit (ValuePtr);
return;
}
-
UINTN
PthreadSelf (
VOID
@@ -173,8 +165,7 @@ PthreadSelf (
return (UINTN)pthread_self ();
}
-
-EMU_THREAD_THUNK_PROTOCOL gPthreadThunk = {
+EMU_THREAD_THUNK_PROTOCOL gPthreadThunk = {
GasketPthreadMutexLock,
GasketPthreadMutexUnLock,
GasketPthreadMutexTryLock,
@@ -185,10 +176,9 @@ EMU_THREAD_THUNK_PROTOCOL gPthreadThunk = {
GasketPthreadSelf
};
-
EFI_STATUS
PthreadOpen (
- IN EMU_IO_THUNK_PROTOCOL *This
+ IN EMU_IO_THUNK_PROTOCOL *This
)
{
if (This->Instance != 0) {
@@ -206,17 +196,15 @@ PthreadOpen (
return EFI_SUCCESS;
}
-
EFI_STATUS
PthreadClose (
- IN EMU_IO_THUNK_PROTOCOL *This
+ IN EMU_IO_THUNK_PROTOCOL *This
)
{
return EFI_SUCCESS;
}
-
-EMU_IO_THUNK_PROTOCOL gPthreadThunkIo = {
+EMU_IO_THUNK_PROTOCOL gPthreadThunkIo = {
&gEmuThreadThunkProtocolGuid,
NULL,
NULL,
@@ -225,5 +213,3 @@ EMU_IO_THUNK_PROTOCOL gPthreadThunkIo = {
GasketPthreadClose,
NULL
};
-
-
diff --git a/EmulatorPkg/Unix/Host/X11GraphicsWindow.c b/EmulatorPkg/Unix/Host/X11GraphicsWindow.c
index 5325a0e35b..a30cc19dbe 100644
--- a/EmulatorPkg/Unix/Host/X11GraphicsWindow.c
+++ b/EmulatorPkg/Unix/Host/X11GraphicsWindow.c
@@ -22,140 +22,147 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define KEYSYM_LOWER 0
#define KEYSYM_UPPER 1
-
struct uga_drv_shift_mask {
- unsigned char shift;
- unsigned char size;
- unsigned char csize;
+ unsigned char shift;
+ unsigned char size;
+ unsigned char csize;
};
-#define NBR_KEYS 32
+#define NBR_KEYS 32
typedef struct {
- EMU_GRAPHICS_WINDOW_PROTOCOL GraphicsIo;
+ EMU_GRAPHICS_WINDOW_PROTOCOL GraphicsIo;
- Display *display;
- int screen; // values for window_size in main
- Window win;
- GC gc;
- Visual *visual;
+ Display *display;
+ int screen; // values for window_size in main
+ Window win;
+ GC gc;
+ Visual *visual;
- int depth;
- unsigned int width;
- unsigned int height;
- unsigned int line_bytes;
- unsigned int pixel_shift;
- unsigned char *image_data;
+ int depth;
+ unsigned int width;
+ unsigned int height;
+ unsigned int line_bytes;
+ unsigned int pixel_shift;
+ unsigned char *image_data;
- struct uga_drv_shift_mask r, g, b;
+ struct uga_drv_shift_mask r, g, b;
- int use_shm;
- XShmSegmentInfo xshm_info;
- XImage *image;
- char *Title;
+ int use_shm;
+ XShmSegmentInfo xshm_info;
+ XImage *image;
+ char *Title;
- unsigned int key_rd;
- unsigned int key_wr;
- unsigned int key_count;
- EFI_KEY_DATA keys[NBR_KEYS];
+ unsigned int key_rd;
+ unsigned int key_wr;
+ unsigned int key_count;
+ EFI_KEY_DATA keys[NBR_KEYS];
- EFI_KEY_STATE KeyState;
+ EFI_KEY_STATE KeyState;
EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK MakeRegisterdKeyCallback;
EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK BreakRegisterdKeyCallback;
VOID *RegisterdKeyCallbackContext;
- int previous_x;
- int previous_y;
- EFI_SIMPLE_POINTER_STATE pointer_state;
- int pointer_state_changed;
+ int previous_x;
+ int previous_y;
+ EFI_SIMPLE_POINTER_STATE pointer_state;
+ int pointer_state_changed;
} GRAPHICS_IO_PRIVATE;
void
-HandleEvents(
- IN GRAPHICS_IO_PRIVATE *Drv
+HandleEvents (
+ IN GRAPHICS_IO_PRIVATE *Drv
);
void
fill_shift_mask (
- IN struct uga_drv_shift_mask *sm,
- IN unsigned long mask
+ IN struct uga_drv_shift_mask *sm,
+ IN unsigned long mask
)
{
sm->shift = 0;
- sm->size = 0;
+ sm->size = 0;
while ((mask & 1) == 0) {
mask >>= 1;
sm->shift++;
}
+
while (mask & 1) {
sm->size++;
mask >>= 1;
}
+
sm->csize = 8 - sm->size;
}
int
TryCreateShmImage (
- IN GRAPHICS_IO_PRIVATE *Drv
+ IN GRAPHICS_IO_PRIVATE *Drv
)
{
Drv->image = XShmCreateImage (
- Drv->display, Drv->visual,
- Drv->depth, ZPixmap, NULL, &Drv->xshm_info,
- Drv->width, Drv->height
+ Drv->display,
+ Drv->visual,
+ Drv->depth,
+ ZPixmap,
+ NULL,
+ &Drv->xshm_info,
+ Drv->width,
+ Drv->height
);
if (Drv->image == NULL) {
return 0;
}
switch (Drv->image->bitmap_unit) {
- case 32:
- Drv->pixel_shift = 2;
- break;
- case 16:
- Drv->pixel_shift = 1;
- break;
- case 8:
- Drv->pixel_shift = 0;
- break;
+ case 32:
+ Drv->pixel_shift = 2;
+ break;
+ case 16:
+ Drv->pixel_shift = 1;
+ break;
+ case 8:
+ Drv->pixel_shift = 0;
+ break;
}
Drv->xshm_info.shmid = shmget (
- IPC_PRIVATE, Drv->image->bytes_per_line * Drv->image->height,
- IPC_CREAT | 0777
- );
+ IPC_PRIVATE,
+ Drv->image->bytes_per_line * Drv->image->height,
+ IPC_CREAT | 0777
+ );
if (Drv->xshm_info.shmid < 0) {
- XDestroyImage(Drv->image);
+ XDestroyImage (Drv->image);
return 0;
}
Drv->image_data = shmat (Drv->xshm_info.shmid, NULL, 0);
- if(!Drv->image_data) {
+ if (!Drv->image_data) {
shmctl (Drv->xshm_info.shmid, IPC_RMID, NULL);
- XDestroyImage(Drv->image);
+ XDestroyImage (Drv->image);
return 0;
}
-#ifndef __APPLE__
+ #ifndef __APPLE__
//
// This closes shared memory in real time on OS X. Only closes after folks quit using
// it on Linux.
//
shmctl (Drv->xshm_info.shmid, IPC_RMID, NULL);
-#endif
+ #endif
- Drv->xshm_info.shmaddr = (char*)Drv->image_data;
- Drv->image->data = (char*)Drv->image_data;
+ Drv->xshm_info.shmaddr = (char *)Drv->image_data;
+ Drv->image->data = (char *)Drv->image_data;
if (!XShmAttach (Drv->display, &Drv->xshm_info)) {
shmdt (Drv->image_data);
- XDestroyImage(Drv->image);
+ XDestroyImage (Drv->image);
return 0;
}
+
return 1;
}
-
EFI_STATUS
X11Size (
IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo,
@@ -163,8 +170,8 @@ X11Size (
IN UINT32 Height
)
{
- GRAPHICS_IO_PRIVATE *Drv;
- XSizeHints size_hints;
+ GRAPHICS_IO_PRIVATE *Drv;
+ XSizeHints size_hints;
// Destroy current buffer if created.
Drv = (GRAPHICS_IO_PRIVATE *)GraphicsIo;
@@ -177,15 +184,15 @@ X11Size (
}
Drv->image_data = NULL;
- Drv->image = NULL;
+ Drv->image = NULL;
}
- Drv->width = Width;
+ Drv->width = Width;
Drv->height = Height;
XResizeWindow (Drv->display, Drv->win, Width, Height);
// Allocate image.
- if (XShmQueryExtension(Drv->display) && TryCreateShmImage(Drv)) {
+ if (XShmQueryExtension (Drv->display) && TryCreateShmImage (Drv)) {
Drv->use_shm = 1;
} else {
Drv->use_shm = 0;
@@ -198,12 +205,18 @@ X11Size (
}
Drv->image_data = malloc ((Drv->width * Drv->height) << Drv->pixel_shift);
- Drv->image = XCreateImage (
- Drv->display, Drv->visual, Drv->depth,
- ZPixmap, 0, (char *)Drv->image_data,
- Drv->width, Drv->height,
- 8 << Drv->pixel_shift, 0
- );
+ Drv->image = XCreateImage (
+ Drv->display,
+ Drv->visual,
+ Drv->depth,
+ ZPixmap,
+ 0,
+ (char *)Drv->image_data,
+ Drv->width,
+ Drv->height,
+ 8 << Drv->pixel_shift,
+ 0
+ );
}
Drv->line_bytes = Drv->image->bytes_per_line;
@@ -213,8 +226,8 @@ X11Size (
fill_shift_mask (&Drv->b, Drv->image->blue_mask);
// Set WM hints.
- size_hints.flags = PSize | PMinSize | PMaxSize;
- size_hints.min_width = size_hints.max_width = size_hints.base_width = Width;
+ size_hints.flags = PSize | PMinSize | PMaxSize;
+ size_hints.min_width = size_hints.max_width = size_hints.base_width = Width;
size_hints.min_height = size_hints.max_height = size_hints.base_height = Height;
XSetWMNormalHints (Drv->display, Drv->win, &size_hints);
@@ -225,9 +238,9 @@ X11Size (
void
handleKeyEvent (
- IN GRAPHICS_IO_PRIVATE *Drv,
- IN XEvent *ev,
- IN BOOLEAN Make
+ IN GRAPHICS_IO_PRIVATE *Drv,
+ IN XEvent *ev,
+ IN BOOLEAN Make
)
{
KeySym *KeySym;
@@ -250,8 +263,8 @@ handleKeyEvent (
//
KeySym = XGetKeyboardMapping (Drv->display, ev->xkey.keycode, 1, &KeySymArraySize);
- KeyData.Key.ScanCode = 0;
- KeyData.Key.UnicodeChar = 0;
+ KeyData.Key.ScanCode = 0;
+ KeyData.Key.UnicodeChar = 0;
KeyData.KeyState.KeyShiftState = 0;
//
@@ -268,186 +281,250 @@ handleKeyEvent (
// Skipping EFI_MENU_KEY_PRESSED and EFI_SYS_REQ_PRESSED
switch (*KeySym) {
- case XK_Control_R:
- if (Make) {
- Drv->KeyState.KeyShiftState |= EFI_RIGHT_CONTROL_PRESSED;
- } else {
- Drv->KeyState.KeyShiftState &= ~EFI_RIGHT_CONTROL_PRESSED;
- }
- break;
- case XK_Control_L:
- if (Make) {
- Drv->KeyState.KeyShiftState |= EFI_LEFT_CONTROL_PRESSED;
- } else {
- Drv->KeyState.KeyShiftState &= ~EFI_LEFT_CONTROL_PRESSED;
- }
- break;
-
- case XK_Shift_R:
- if (Make) {
- Drv->KeyState.KeyShiftState |= EFI_RIGHT_SHIFT_PRESSED;
- } else {
- Drv->KeyState.KeyShiftState &= ~EFI_RIGHT_SHIFT_PRESSED;
- }
- break;
- case XK_Shift_L:
- if (Make) {
- Drv->KeyState.KeyShiftState |= EFI_LEFT_SHIFT_PRESSED;
- } else {
- Drv->KeyState.KeyShiftState &= ~EFI_LEFT_SHIFT_PRESSED;
- }
- break;
-
- case XK_Mode_switch:
- if (Make) {
- Drv->KeyState.KeyShiftState |= EFI_LEFT_ALT_PRESSED;
- } else {
- Drv->KeyState.KeyShiftState &= ~EFI_LEFT_ALT_PRESSED;
- }
- break;
-
- case XK_Meta_R:
- if (Make) {
- Drv->KeyState.KeyShiftState |= EFI_RIGHT_LOGO_PRESSED;
- } else {
- Drv->KeyState.KeyShiftState &= ~EFI_RIGHT_LOGO_PRESSED;
- }
- break;
- case XK_Meta_L:
- if (Make) {
- Drv->KeyState.KeyShiftState |= EFI_LEFT_LOGO_PRESSED;
- } else {
- Drv->KeyState.KeyShiftState &= ~EFI_LEFT_LOGO_PRESSED;
- }
- break;
-
- case XK_KP_Home:
- case XK_Home: KeyData.Key.ScanCode = SCAN_HOME; break;
-
- case XK_KP_End:
- case XK_End: KeyData.Key.ScanCode = SCAN_END; break;
-
- case XK_KP_Left:
- case XK_Left: KeyData.Key.ScanCode = SCAN_LEFT; break;
-
- case XK_KP_Right:
- case XK_Right: KeyData.Key.ScanCode = SCAN_RIGHT; break;
-
- case XK_KP_Up:
- case XK_Up: KeyData.Key.ScanCode = SCAN_UP; break;
-
- case XK_KP_Down:
- case XK_Down: KeyData.Key.ScanCode = SCAN_DOWN; break;
-
- case XK_KP_Delete:
- case XK_Delete: KeyData.Key.ScanCode = SCAN_DELETE; break;
-
- case XK_KP_Insert:
- case XK_Insert: KeyData.Key.ScanCode = SCAN_INSERT; break;
-
- case XK_KP_Page_Up:
- case XK_Page_Up: KeyData.Key.ScanCode = SCAN_PAGE_UP; break;
-
- case XK_KP_Page_Down:
- case XK_Page_Down: KeyData.Key.ScanCode = SCAN_PAGE_DOWN; break;
-
- case XK_Escape: KeyData.Key.ScanCode = SCAN_ESC; break;
-
- case XK_Pause: KeyData.Key.ScanCode = SCAN_PAUSE; break;
-
- case XK_KP_F1:
- case XK_F1: KeyData.Key.ScanCode = SCAN_F1; break;
-
- case XK_KP_F2:
- case XK_F2: KeyData.Key.ScanCode = SCAN_F2; break;
-
- case XK_KP_F3:
- case XK_F3: KeyData.Key.ScanCode = SCAN_F3; break;
-
- case XK_KP_F4:
- case XK_F4: KeyData.Key.ScanCode = SCAN_F4; break;
+ case XK_Control_R:
+ if (Make) {
+ Drv->KeyState.KeyShiftState |= EFI_RIGHT_CONTROL_PRESSED;
+ } else {
+ Drv->KeyState.KeyShiftState &= ~EFI_RIGHT_CONTROL_PRESSED;
+ }
- case XK_F5: KeyData.Key.ScanCode = SCAN_F5; break;
- case XK_F6: KeyData.Key.ScanCode = SCAN_F6; break;
- case XK_F7: KeyData.Key.ScanCode = SCAN_F7; break;
+ break;
+ case XK_Control_L:
+ if (Make) {
+ Drv->KeyState.KeyShiftState |= EFI_LEFT_CONTROL_PRESSED;
+ } else {
+ Drv->KeyState.KeyShiftState &= ~EFI_LEFT_CONTROL_PRESSED;
+ }
- // Don't map into X11 by default on a Mac
- // System Preferences->Keyboard->Keyboard Shortcuts can be configured
- // to not use higher function keys as shortcuts and the will show up
- // in X11.
- case XK_F8: KeyData.Key.ScanCode = SCAN_F8; break;
- case XK_F9: KeyData.Key.ScanCode = SCAN_F9; break;
- case XK_F10: KeyData.Key.ScanCode = SCAN_F10; break;
+ break;
- case XK_F11: KeyData.Key.ScanCode = SCAN_F11; break;
- case XK_F12: KeyData.Key.ScanCode = SCAN_F12; break;
+ case XK_Shift_R:
+ if (Make) {
+ Drv->KeyState.KeyShiftState |= EFI_RIGHT_SHIFT_PRESSED;
+ } else {
+ Drv->KeyState.KeyShiftState &= ~EFI_RIGHT_SHIFT_PRESSED;
+ }
- case XK_F13: KeyData.Key.ScanCode = SCAN_F13; break;
- case XK_F14: KeyData.Key.ScanCode = SCAN_F14; break;
- case XK_F15: KeyData.Key.ScanCode = SCAN_F15; break;
- case XK_F16: KeyData.Key.ScanCode = SCAN_F16; break;
- case XK_F17: KeyData.Key.ScanCode = SCAN_F17; break;
- case XK_F18: KeyData.Key.ScanCode = SCAN_F18; break;
- case XK_F19: KeyData.Key.ScanCode = SCAN_F19; break;
- case XK_F20: KeyData.Key.ScanCode = SCAN_F20; break;
- case XK_F21: KeyData.Key.ScanCode = SCAN_F21; break;
- case XK_F22: KeyData.Key.ScanCode = SCAN_F22; break;
- case XK_F23: KeyData.Key.ScanCode = SCAN_F23; break;
- case XK_F24: KeyData.Key.ScanCode = SCAN_F24; break;
+ break;
+ case XK_Shift_L:
+ if (Make) {
+ Drv->KeyState.KeyShiftState |= EFI_LEFT_SHIFT_PRESSED;
+ } else {
+ Drv->KeyState.KeyShiftState &= ~EFI_LEFT_SHIFT_PRESSED;
+ }
- // No mapping in X11
- //case XK_: KeyData.Key.ScanCode = SCAN_MUTE; break;
- //case XK_: KeyData.Key.ScanCode = SCAN_VOLUME_UP; break;
- //case XK_: KeyData.Key.ScanCode = SCAN_VOLUME_DOWN; break;
- //case XK_: KeyData.Key.ScanCode = SCAN_BRIGHTNESS_UP; break;
- //case XK_: KeyData.Key.ScanCode = SCAN_BRIGHTNESS_DOWN; break;
- //case XK_: KeyData.Key.ScanCode = SCAN_SUSPEND; break;
- //case XK_: KeyData.Key.ScanCode = SCAN_HIBERNATE; break;
- //case XK_: KeyData.Key.ScanCode = SCAN_TOGGLE_DISPLAY; break;
- //case XK_: KeyData.Key.ScanCode = SCAN_RECOVERY; break;
- //case XK_: KeyData.Key.ScanCode = SCAN_EJECT; break;
+ break;
- case XK_BackSpace: KeyData.Key.UnicodeChar = 0x0008; break;
+ case XK_Mode_switch:
+ if (Make) {
+ Drv->KeyState.KeyShiftState |= EFI_LEFT_ALT_PRESSED;
+ } else {
+ Drv->KeyState.KeyShiftState &= ~EFI_LEFT_ALT_PRESSED;
+ }
- case XK_KP_Tab:
- case XK_Tab: KeyData.Key.UnicodeChar = 0x0009; break;
+ break;
- case XK_Linefeed: KeyData.Key.UnicodeChar = 0x000a; break;
+ case XK_Meta_R:
+ if (Make) {
+ Drv->KeyState.KeyShiftState |= EFI_RIGHT_LOGO_PRESSED;
+ } else {
+ Drv->KeyState.KeyShiftState &= ~EFI_RIGHT_LOGO_PRESSED;
+ }
- case XK_KP_Enter:
- case XK_Return: KeyData.Key.UnicodeChar = 0x000d; break;
+ break;
+ case XK_Meta_L:
+ if (Make) {
+ Drv->KeyState.KeyShiftState |= EFI_LEFT_LOGO_PRESSED;
+ } else {
+ Drv->KeyState.KeyShiftState &= ~EFI_LEFT_LOGO_PRESSED;
+ }
- case XK_KP_Equal : KeyData.Key.UnicodeChar = L'='; break;
- case XK_KP_Multiply : KeyData.Key.UnicodeChar = L'*'; break;
- case XK_KP_Add : KeyData.Key.UnicodeChar = L'+'; break;
- case XK_KP_Separator : KeyData.Key.UnicodeChar = L'~'; break;
- case XK_KP_Subtract : KeyData.Key.UnicodeChar = L'-'; break;
- case XK_KP_Decimal : KeyData.Key.UnicodeChar = L'.'; break;
- case XK_KP_Divide : KeyData.Key.UnicodeChar = L'/'; break;
-
- case XK_KP_0 : KeyData.Key.UnicodeChar = L'0'; break;
- case XK_KP_1 : KeyData.Key.UnicodeChar = L'1'; break;
- case XK_KP_2 : KeyData.Key.UnicodeChar = L'2'; break;
- case XK_KP_3 : KeyData.Key.UnicodeChar = L'3'; break;
- case XK_KP_4 : KeyData.Key.UnicodeChar = L'4'; break;
- case XK_KP_5 : KeyData.Key.UnicodeChar = L'5'; break;
- case XK_KP_6 : KeyData.Key.UnicodeChar = L'6'; break;
- case XK_KP_7 : KeyData.Key.UnicodeChar = L'7'; break;
- case XK_KP_8 : KeyData.Key.UnicodeChar = L'8'; break;
- case XK_KP_9 : KeyData.Key.UnicodeChar = L'9'; break;
-
- default:
- ;
+ break;
+
+ case XK_KP_Home:
+ case XK_Home: KeyData.Key.ScanCode = SCAN_HOME;
+ break;
+
+ case XK_KP_End:
+ case XK_End: KeyData.Key.ScanCode = SCAN_END;
+ break;
+
+ case XK_KP_Left:
+ case XK_Left: KeyData.Key.ScanCode = SCAN_LEFT;
+ break;
+
+ case XK_KP_Right:
+ case XK_Right: KeyData.Key.ScanCode = SCAN_RIGHT;
+ break;
+
+ case XK_KP_Up:
+ case XK_Up: KeyData.Key.ScanCode = SCAN_UP;
+ break;
+
+ case XK_KP_Down:
+ case XK_Down: KeyData.Key.ScanCode = SCAN_DOWN;
+ break;
+
+ case XK_KP_Delete:
+ case XK_Delete: KeyData.Key.ScanCode = SCAN_DELETE;
+ break;
+
+ case XK_KP_Insert:
+ case XK_Insert: KeyData.Key.ScanCode = SCAN_INSERT;
+ break;
+
+ case XK_KP_Page_Up:
+ case XK_Page_Up: KeyData.Key.ScanCode = SCAN_PAGE_UP;
+ break;
+
+ case XK_KP_Page_Down:
+ case XK_Page_Down: KeyData.Key.ScanCode = SCAN_PAGE_DOWN;
+ break;
+
+ case XK_Escape: KeyData.Key.ScanCode = SCAN_ESC;
+ break;
+
+ case XK_Pause: KeyData.Key.ScanCode = SCAN_PAUSE;
+ break;
+
+ case XK_KP_F1:
+ case XK_F1: KeyData.Key.ScanCode = SCAN_F1;
+ break;
+
+ case XK_KP_F2:
+ case XK_F2: KeyData.Key.ScanCode = SCAN_F2;
+ break;
+
+ case XK_KP_F3:
+ case XK_F3: KeyData.Key.ScanCode = SCAN_F3;
+ break;
+
+ case XK_KP_F4:
+ case XK_F4: KeyData.Key.ScanCode = SCAN_F4;
+ break;
+
+ case XK_F5: KeyData.Key.ScanCode = SCAN_F5;
+ break;
+ case XK_F6: KeyData.Key.ScanCode = SCAN_F6;
+ break;
+ case XK_F7: KeyData.Key.ScanCode = SCAN_F7;
+ break;
+
+ // Don't map into X11 by default on a Mac
+ // System Preferences->Keyboard->Keyboard Shortcuts can be configured
+ // to not use higher function keys as shortcuts and the will show up
+ // in X11.
+ case XK_F8: KeyData.Key.ScanCode = SCAN_F8;
+ break;
+ case XK_F9: KeyData.Key.ScanCode = SCAN_F9;
+ break;
+ case XK_F10: KeyData.Key.ScanCode = SCAN_F10;
+ break;
+
+ case XK_F11: KeyData.Key.ScanCode = SCAN_F11;
+ break;
+ case XK_F12: KeyData.Key.ScanCode = SCAN_F12;
+ break;
+
+ case XK_F13: KeyData.Key.ScanCode = SCAN_F13;
+ break;
+ case XK_F14: KeyData.Key.ScanCode = SCAN_F14;
+ break;
+ case XK_F15: KeyData.Key.ScanCode = SCAN_F15;
+ break;
+ case XK_F16: KeyData.Key.ScanCode = SCAN_F16;
+ break;
+ case XK_F17: KeyData.Key.ScanCode = SCAN_F17;
+ break;
+ case XK_F18: KeyData.Key.ScanCode = SCAN_F18;
+ break;
+ case XK_F19: KeyData.Key.ScanCode = SCAN_F19;
+ break;
+ case XK_F20: KeyData.Key.ScanCode = SCAN_F20;
+ break;
+ case XK_F21: KeyData.Key.ScanCode = SCAN_F21;
+ break;
+ case XK_F22: KeyData.Key.ScanCode = SCAN_F22;
+ break;
+ case XK_F23: KeyData.Key.ScanCode = SCAN_F23;
+ break;
+ case XK_F24: KeyData.Key.ScanCode = SCAN_F24;
+ break;
+
+ // No mapping in X11
+ // case XK_: KeyData.Key.ScanCode = SCAN_MUTE; break;
+ // case XK_: KeyData.Key.ScanCode = SCAN_VOLUME_UP; break;
+ // case XK_: KeyData.Key.ScanCode = SCAN_VOLUME_DOWN; break;
+ // case XK_: KeyData.Key.ScanCode = SCAN_BRIGHTNESS_UP; break;
+ // case XK_: KeyData.Key.ScanCode = SCAN_BRIGHTNESS_DOWN; break;
+ // case XK_: KeyData.Key.ScanCode = SCAN_SUSPEND; break;
+ // case XK_: KeyData.Key.ScanCode = SCAN_HIBERNATE; break;
+ // case XK_: KeyData.Key.ScanCode = SCAN_TOGGLE_DISPLAY; break;
+ // case XK_: KeyData.Key.ScanCode = SCAN_RECOVERY; break;
+ // case XK_: KeyData.Key.ScanCode = SCAN_EJECT; break;
+
+ case XK_BackSpace: KeyData.Key.UnicodeChar = 0x0008;
+ break;
+
+ case XK_KP_Tab:
+ case XK_Tab: KeyData.Key.UnicodeChar = 0x0009;
+ break;
+
+ case XK_Linefeed: KeyData.Key.UnicodeChar = 0x000a;
+ break;
+
+ case XK_KP_Enter:
+ case XK_Return: KeyData.Key.UnicodeChar = 0x000d;
+ break;
+
+ case XK_KP_Equal: KeyData.Key.UnicodeChar = L'=';
+ break;
+ case XK_KP_Multiply: KeyData.Key.UnicodeChar = L'*';
+ break;
+ case XK_KP_Add: KeyData.Key.UnicodeChar = L'+';
+ break;
+ case XK_KP_Separator: KeyData.Key.UnicodeChar = L'~';
+ break;
+ case XK_KP_Subtract: KeyData.Key.UnicodeChar = L'-';
+ break;
+ case XK_KP_Decimal: KeyData.Key.UnicodeChar = L'.';
+ break;
+ case XK_KP_Divide: KeyData.Key.UnicodeChar = L'/';
+ break;
+
+ case XK_KP_0: KeyData.Key.UnicodeChar = L'0';
+ break;
+ case XK_KP_1: KeyData.Key.UnicodeChar = L'1';
+ break;
+ case XK_KP_2: KeyData.Key.UnicodeChar = L'2';
+ break;
+ case XK_KP_3: KeyData.Key.UnicodeChar = L'3';
+ break;
+ case XK_KP_4: KeyData.Key.UnicodeChar = L'4';
+ break;
+ case XK_KP_5: KeyData.Key.UnicodeChar = L'5';
+ break;
+ case XK_KP_6: KeyData.Key.UnicodeChar = L'6';
+ break;
+ case XK_KP_7: KeyData.Key.UnicodeChar = L'7';
+ break;
+ case XK_KP_8: KeyData.Key.UnicodeChar = L'8';
+ break;
+ case XK_KP_9: KeyData.Key.UnicodeChar = L'9';
+ break;
+
+ default:
+ ;
}
// The global state is our state
- KeyData.KeyState.KeyShiftState = Drv->KeyState.KeyShiftState;
+ KeyData.KeyState.KeyShiftState = Drv->KeyState.KeyShiftState;
KeyData.KeyState.KeyToggleState = Drv->KeyState.KeyToggleState;
if (*KeySym < XK_BackSpace) {
if (((Drv->KeyState.KeyShiftState & (EFI_LEFT_SHIFT_PRESSED | EFI_RIGHT_SHIFT_PRESSED)) != 0) ||
- ((Drv->KeyState.KeyToggleState & EFI_CAPS_LOCK_ACTIVE) != 0) ) {
-
+ ((Drv->KeyState.KeyToggleState & EFI_CAPS_LOCK_ACTIVE) != 0))
+ {
KeyData.Key.UnicodeChar = (CHAR16)KeySym[KEYSYM_UPPER];
// Per UEFI spec since we converted the Unicode clear the shift bits we pass up
@@ -457,7 +534,6 @@ handleKeyEvent (
}
} else {
// XK_BackSpace is the start of XK_MISCELLANY. These are the XK_? keys we process in this file
- ;
}
if (Make) {
@@ -465,32 +541,31 @@ handleKeyEvent (
Drv->key_wr = (Drv->key_wr + 1) % NBR_KEYS;
Drv->key_count++;
if (Drv->MakeRegisterdKeyCallback != NULL) {
- ReverseGasketUint64Uint64 (Drv->MakeRegisterdKeyCallback ,Drv->RegisterdKeyCallbackContext, &KeyData);
+ ReverseGasketUint64Uint64 (Drv->MakeRegisterdKeyCallback, Drv->RegisterdKeyCallbackContext, &KeyData);
}
} else {
if (Drv->BreakRegisterdKeyCallback != NULL) {
- ReverseGasketUint64Uint64 (Drv->BreakRegisterdKeyCallback ,Drv->RegisterdKeyCallbackContext, &KeyData);
+ ReverseGasketUint64Uint64 (Drv->BreakRegisterdKeyCallback, Drv->RegisterdKeyCallbackContext, &KeyData);
}
}
}
-
void
-handleMouseMoved(
- IN GRAPHICS_IO_PRIVATE *Drv,
- IN XEvent *ev
+handleMouseMoved (
+ IN GRAPHICS_IO_PRIVATE *Drv,
+ IN XEvent *ev
)
{
if (ev->xmotion.x != Drv->previous_x) {
- Drv->pointer_state.RelativeMovementX += ( ev->xmotion.x - Drv->previous_x );
- Drv->previous_x = ev->xmotion.x;
- Drv->pointer_state_changed = 1;
+ Drv->pointer_state.RelativeMovementX += (ev->xmotion.x - Drv->previous_x);
+ Drv->previous_x = ev->xmotion.x;
+ Drv->pointer_state_changed = 1;
}
if (ev->xmotion.y != Drv->previous_y) {
- Drv->pointer_state.RelativeMovementY += ( ev->xmotion.y - Drv->previous_y );
- Drv->previous_y = ev->xmotion.y;
- Drv->pointer_state_changed = 1;
+ Drv->pointer_state.RelativeMovementY += (ev->xmotion.y - Drv->previous_y);
+ Drv->previous_y = ev->xmotion.y;
+ Drv->pointer_state_changed = 1;
}
Drv->pointer_state.RelativeMovementZ = 0;
@@ -498,90 +573,124 @@ handleMouseMoved(
void
handleMouseDown (
- IN GRAPHICS_IO_PRIVATE *Drv,
- IN XEvent *ev,
- IN BOOLEAN Pressed
+ IN GRAPHICS_IO_PRIVATE *Drv,
+ IN XEvent *ev,
+ IN BOOLEAN Pressed
)
{
if (ev->xbutton.button == Button1) {
- Drv->pointer_state_changed = (Drv->pointer_state.LeftButton != Pressed);
+ Drv->pointer_state_changed = (Drv->pointer_state.LeftButton != Pressed);
Drv->pointer_state.LeftButton = Pressed;
}
+
if ( ev->xbutton.button == Button2 ) {
- Drv->pointer_state_changed = (Drv->pointer_state.RightButton != Pressed);
+ Drv->pointer_state_changed = (Drv->pointer_state.RightButton != Pressed);
Drv->pointer_state.RightButton = Pressed;
}
}
void
Redraw (
- IN GRAPHICS_IO_PRIVATE *Drv,
- IN UINTN X,
- IN UINTN Y,
- IN UINTN Width,
- IN UINTN Height
+ IN GRAPHICS_IO_PRIVATE *Drv,
+ IN UINTN X,
+ IN UINTN Y,
+ IN UINTN Width,
+ IN UINTN Height
)
{
if (Drv->use_shm) {
XShmPutImage (
- Drv->display, Drv->win, Drv->gc, Drv->image, X, Y, X, Y, Width, Height, False
+ Drv->display,
+ Drv->win,
+ Drv->gc,
+ Drv->image,
+ X,
+ Y,
+ X,
+ Y,
+ Width,
+ Height,
+ False
);
} else {
XPutImage (
- Drv->display, Drv->win, Drv->gc, Drv->image, X, Y, X, Y, Width, Height
+ Drv->display,
+ Drv->win,
+ Drv->gc,
+ Drv->image,
+ X,
+ Y,
+ X,
+ Y,
+ Width,
+ Height
);
}
- XFlush(Drv->display);
+
+ XFlush (Drv->display);
}
void
-HandleEvent(GRAPHICS_IO_PRIVATE *Drv, XEvent *ev)
+HandleEvent (
+ GRAPHICS_IO_PRIVATE *Drv,
+ XEvent *ev
+ )
{
switch (ev->type) {
- case Expose:
- Redraw (Drv, ev->xexpose.x, ev->xexpose.y,
- ev->xexpose.width, ev->xexpose.height);
- break;
- case GraphicsExpose:
- Redraw (Drv, ev->xgraphicsexpose.x, ev->xgraphicsexpose.y,
- ev->xgraphicsexpose.width, ev->xgraphicsexpose.height);
- break;
- case KeyPress:
- handleKeyEvent (Drv, ev, TRUE);
- break;
- case KeyRelease:
- handleKeyEvent (Drv, ev, FALSE);
- break;
- case MappingNotify:
- XRefreshKeyboardMapping (&ev->xmapping);
- break;
- case MotionNotify:
- handleMouseMoved (Drv, ev);
- break;
- case ButtonPress:
- handleMouseDown (Drv, ev, TRUE);
- break;
- case ButtonRelease:
- handleMouseDown (Drv, ev, FALSE);
- break;
-#if 0
- case DestroyNotify:
- XCloseDisplay (Drv->display);
- exit (1);
- break;
-#endif
- case NoExpose:
- default:
- break;
+ case Expose:
+ Redraw (
+ Drv,
+ ev->xexpose.x,
+ ev->xexpose.y,
+ ev->xexpose.width,
+ ev->xexpose.height
+ );
+ break;
+ case GraphicsExpose:
+ Redraw (
+ Drv,
+ ev->xgraphicsexpose.x,
+ ev->xgraphicsexpose.y,
+ ev->xgraphicsexpose.width,
+ ev->xgraphicsexpose.height
+ );
+ break;
+ case KeyPress:
+ handleKeyEvent (Drv, ev, TRUE);
+ break;
+ case KeyRelease:
+ handleKeyEvent (Drv, ev, FALSE);
+ break;
+ case MappingNotify:
+ XRefreshKeyboardMapping (&ev->xmapping);
+ break;
+ case MotionNotify:
+ handleMouseMoved (Drv, ev);
+ break;
+ case ButtonPress:
+ handleMouseDown (Drv, ev, TRUE);
+ break;
+ case ButtonRelease:
+ handleMouseDown (Drv, ev, FALSE);
+ break;
+ #if 0
+ case DestroyNotify:
+ XCloseDisplay (Drv->display);
+ exit (1);
+ break;
+ #endif
+ case NoExpose:
+ default:
+ break;
}
}
void
HandleEvents (
- IN GRAPHICS_IO_PRIVATE *Drv
+ IN GRAPHICS_IO_PRIVATE *Drv
)
{
- XEvent ev;
+ XEvent ev;
while (XPending (Drv->display) != 0) {
XNextEvent (Drv->display, &ev);
@@ -591,37 +700,36 @@ HandleEvents (
unsigned long
X11PixelToColor (
- IN GRAPHICS_IO_PRIVATE *Drv,
- IN EFI_UGA_PIXEL pixel
+ IN GRAPHICS_IO_PRIVATE *Drv,
+ IN EFI_UGA_PIXEL pixel
)
{
return ((pixel.Red >> Drv->r.csize) << Drv->r.shift)
- | ((pixel.Green >> Drv->g.csize) << Drv->g.shift)
- | ((pixel.Blue >> Drv->b.csize) << Drv->b.shift);
+ | ((pixel.Green >> Drv->g.csize) << Drv->g.shift)
+ | ((pixel.Blue >> Drv->b.csize) << Drv->b.shift);
}
EFI_UGA_PIXEL
X11ColorToPixel (
- IN GRAPHICS_IO_PRIVATE *Drv,
- IN unsigned long val
+ IN GRAPHICS_IO_PRIVATE *Drv,
+ IN unsigned long val
)
{
- EFI_UGA_PIXEL Pixel;
+ EFI_UGA_PIXEL Pixel;
memset (&Pixel, 0, sizeof (EFI_UGA_PIXEL));
// Truncation not an issue since X11 and EFI are both using 8 bits per color
- Pixel.Red = (val >> Drv->r.shift) << Drv->r.csize;
+ Pixel.Red = (val >> Drv->r.shift) << Drv->r.csize;
Pixel.Green = (val >> Drv->g.shift) << Drv->g.csize;
- Pixel.Blue = (val >> Drv->b.shift) << Drv->b.csize;
+ Pixel.Blue = (val >> Drv->b.shift) << Drv->b.csize;
return Pixel;
}
-
EFI_STATUS
X11CheckKey (
- IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo
+ IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo
)
{
GRAPHICS_IO_PRIVATE *Drv;
@@ -643,8 +751,8 @@ X11GetKey (
IN EFI_KEY_DATA *KeyData
)
{
- EFI_STATUS EfiStatus;
- GRAPHICS_IO_PRIVATE *Drv;
+ EFI_STATUS EfiStatus;
+ GRAPHICS_IO_PRIVATE *Drv;
Drv = (GRAPHICS_IO_PRIVATE *)GraphicsIo;
@@ -660,11 +768,10 @@ X11GetKey (
return EFI_SUCCESS;
}
-
EFI_STATUS
X11KeySetState (
- IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo,
- IN EFI_KEY_TOGGLE_STATE *KeyToggleState
+ IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo,
+ IN EFI_KEY_TOGGLE_STATE *KeyToggleState
)
{
GRAPHICS_IO_PRIVATE *Drv;
@@ -684,13 +791,12 @@ X11KeySetState (
return EFI_SUCCESS;
}
-
EFI_STATUS
X11RegisterKeyNotify (
- IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo,
- IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK MakeCallBack,
- IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK BreakCallBack,
- IN VOID *Context
+ IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo,
+ IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK MakeCallBack,
+ IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK BreakCallBack,
+ IN VOID *Context
)
{
GRAPHICS_IO_PRIVATE *Drv;
@@ -704,36 +810,35 @@ X11RegisterKeyNotify (
return EFI_SUCCESS;
}
-
EFI_STATUS
X11Blt (
- IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo,
- IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,
- IN EFI_UGA_BLT_OPERATION BltOperation,
- IN EMU_GRAPHICS_WINDOWS__BLT_ARGS *Args
+ IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo,
+ IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,
+ IN EFI_UGA_BLT_OPERATION BltOperation,
+ IN EMU_GRAPHICS_WINDOWS__BLT_ARGS *Args
)
{
- GRAPHICS_IO_PRIVATE *Private;
- UINTN DstY;
- UINTN SrcY;
- UINTN DstX;
- UINTN SrcX;
- UINTN Index;
- EFI_UGA_PIXEL *Blt;
- UINT8 *Dst;
- UINT8 *Src;
- UINTN Nbr;
- unsigned long Color;
- XEvent ev;
+ GRAPHICS_IO_PRIVATE *Private;
+ UINTN DstY;
+ UINTN SrcY;
+ UINTN DstX;
+ UINTN SrcX;
+ UINTN Index;
+ EFI_UGA_PIXEL *Blt;
+ UINT8 *Dst;
+ UINT8 *Src;
+ UINTN Nbr;
+ unsigned long Color;
+ XEvent ev;
Private = (GRAPHICS_IO_PRIVATE *)GraphicsIo;
-
//
// Check bounds
//
- if (BltOperation == EfiUgaVideoToBltBuffer
- || BltOperation == EfiUgaVideoToVideo) {
+ if ( (BltOperation == EfiUgaVideoToBltBuffer)
+ || (BltOperation == EfiUgaVideoToVideo))
+ {
//
// Source is Video.
//
@@ -746,9 +851,10 @@ X11Blt (
}
}
- if (BltOperation == EfiUgaBltBufferToVideo
- || BltOperation == EfiUgaVideoToVideo
- || BltOperation == EfiUgaVideoFill) {
+ if ( (BltOperation == EfiUgaBltBufferToVideo)
+ || (BltOperation == EfiUgaVideoToVideo)
+ || (BltOperation == EfiUgaVideoFill))
+ {
//
// Destination is Video
//
@@ -762,106 +868,125 @@ X11Blt (
}
switch (BltOperation) {
- case EfiUgaVideoToBltBuffer:
- Blt = (EFI_UGA_PIXEL *)((UINT8 *)BltBuffer + (Args->DestinationY * Args->Delta) + Args->DestinationX * sizeof (EFI_UGA_PIXEL));
- Args->Delta -= Args->Width * sizeof (EFI_UGA_PIXEL);
- for (SrcY = Args->SourceY; SrcY < (Args->Height + Args->SourceY); SrcY++) {
- for (SrcX = Args->SourceX; SrcX < (Args->Width + Args->SourceX); SrcX++) {
- *Blt++ = X11ColorToPixel (Private, XGetPixel (Private->image, SrcX, SrcY));
+ case EfiUgaVideoToBltBuffer:
+ Blt = (EFI_UGA_PIXEL *)((UINT8 *)BltBuffer + (Args->DestinationY * Args->Delta) + Args->DestinationX * sizeof (EFI_UGA_PIXEL));
+ Args->Delta -= Args->Width * sizeof (EFI_UGA_PIXEL);
+ for (SrcY = Args->SourceY; SrcY < (Args->Height + Args->SourceY); SrcY++) {
+ for (SrcX = Args->SourceX; SrcX < (Args->Width + Args->SourceX); SrcX++) {
+ *Blt++ = X11ColorToPixel (Private, XGetPixel (Private->image, SrcX, SrcY));
+ }
+
+ Blt = (EFI_UGA_PIXEL *)((UINT8 *)Blt + Args->Delta);
}
- Blt = (EFI_UGA_PIXEL *) ((UINT8 *) Blt + Args->Delta);
- }
- break;
- case EfiUgaBltBufferToVideo:
- Blt = (EFI_UGA_PIXEL *)((UINT8 *)BltBuffer + (Args->SourceY * Args->Delta) + Args->SourceX * sizeof (EFI_UGA_PIXEL));
- Args->Delta -= Args->Width * sizeof (EFI_UGA_PIXEL);
- for (DstY = Args->DestinationY; DstY < (Args->Height + Args->DestinationY); DstY++) {
- for (DstX = Args->DestinationX; DstX < (Args->Width + Args->DestinationX); DstX++) {
- XPutPixel(Private->image, DstX, DstY, X11PixelToColor(Private, *Blt));
- Blt++;
- }
- Blt = (EFI_UGA_PIXEL *) ((UINT8 *) Blt + Args->Delta);
- }
- break;
- case EfiUgaVideoToVideo:
- Dst = Private->image_data + (Args->DestinationX << Private->pixel_shift)
- + Args->DestinationY * Private->line_bytes;
- Src = Private->image_data + (Args->SourceX << Private->pixel_shift)
- + Args->SourceY * Private->line_bytes;
- Nbr = Args->Width << Private->pixel_shift;
- if (Args->DestinationY < Args->SourceY) {
- for (Index = 0; Index < Args->Height; Index++) {
- memcpy (Dst, Src, Nbr);
- Dst += Private->line_bytes;
- Src += Private->line_bytes;
+
+ break;
+ case EfiUgaBltBufferToVideo:
+ Blt = (EFI_UGA_PIXEL *)((UINT8 *)BltBuffer + (Args->SourceY * Args->Delta) + Args->SourceX * sizeof (EFI_UGA_PIXEL));
+ Args->Delta -= Args->Width * sizeof (EFI_UGA_PIXEL);
+ for (DstY = Args->DestinationY; DstY < (Args->Height + Args->DestinationY); DstY++) {
+ for (DstX = Args->DestinationX; DstX < (Args->Width + Args->DestinationX); DstX++) {
+ XPutPixel (Private->image, DstX, DstY, X11PixelToColor (Private, *Blt));
+ Blt++;
+ }
+
+ Blt = (EFI_UGA_PIXEL *)((UINT8 *)Blt + Args->Delta);
}
- } else {
- Dst += (Args->Height - 1) * Private->line_bytes;
- Src += (Args->Height - 1) * Private->line_bytes;
- for (Index = 0; Index < Args->Height; Index++) {
- //
- // Source and Destination Y may be equal, therefore Dst and Src may
- // overlap.
- //
- memmove (Dst, Src, Nbr);
- Dst -= Private->line_bytes;
- Src -= Private->line_bytes;
+
+ break;
+ case EfiUgaVideoToVideo:
+ Dst = Private->image_data + (Args->DestinationX << Private->pixel_shift)
+ + Args->DestinationY * Private->line_bytes;
+ Src = Private->image_data + (Args->SourceX << Private->pixel_shift)
+ + Args->SourceY * Private->line_bytes;
+ Nbr = Args->Width << Private->pixel_shift;
+ if (Args->DestinationY < Args->SourceY) {
+ for (Index = 0; Index < Args->Height; Index++) {
+ memcpy (Dst, Src, Nbr);
+ Dst += Private->line_bytes;
+ Src += Private->line_bytes;
+ }
+ } else {
+ Dst += (Args->Height - 1) * Private->line_bytes;
+ Src += (Args->Height - 1) * Private->line_bytes;
+ for (Index = 0; Index < Args->Height; Index++) {
+ //
+ // Source and Destination Y may be equal, therefore Dst and Src may
+ // overlap.
+ //
+ memmove (Dst, Src, Nbr);
+ Dst -= Private->line_bytes;
+ Src -= Private->line_bytes;
+ }
}
- }
- break;
- case EfiUgaVideoFill:
- Color = X11PixelToColor(Private, *BltBuffer);
- for (DstY = Args->DestinationY; DstY < (Args->Height + Args->DestinationY); DstY++) {
- for (DstX = Args->DestinationX; DstX < (Args->Width + Args->DestinationX); DstX++) {
- XPutPixel(Private->image, DstX, DstY, Color);
+
+ break;
+ case EfiUgaVideoFill:
+ Color = X11PixelToColor (Private, *BltBuffer);
+ for (DstY = Args->DestinationY; DstY < (Args->Height + Args->DestinationY); DstY++) {
+ for (DstX = Args->DestinationX; DstX < (Args->Width + Args->DestinationX); DstX++) {
+ XPutPixel (Private->image, DstX, DstY, Color);
+ }
}
- }
- break;
- default:
- return EFI_INVALID_PARAMETER;
+
+ break;
+ default:
+ return EFI_INVALID_PARAMETER;
}
//
// Refresh screen.
//
switch (BltOperation) {
- case EfiUgaVideoToVideo:
- XCopyArea(
- Private->display, Private->win, Private->win, Private->gc,
- Args->SourceX, Args->SourceY, Args->Width, Args->Height,
- Args->DestinationX, Args->DestinationY
- );
-
- while (1) {
- XNextEvent (Private->display, &ev);
- HandleEvent (Private, &ev);
- if (ev.type == NoExpose || ev.type == GraphicsExpose) {
- break;
+ case EfiUgaVideoToVideo:
+ XCopyArea (
+ Private->display,
+ Private->win,
+ Private->win,
+ Private->gc,
+ Args->SourceX,
+ Args->SourceY,
+ Args->Width,
+ Args->Height,
+ Args->DestinationX,
+ Args->DestinationY
+ );
+
+ while (1) {
+ XNextEvent (Private->display, &ev);
+ HandleEvent (Private, &ev);
+ if ((ev.type == NoExpose) || (ev.type == GraphicsExpose)) {
+ break;
+ }
}
- }
- break;
- case EfiUgaVideoFill:
- Color = X11PixelToColor (Private, *BltBuffer);
- XSetForeground (Private->display, Private->gc, Color);
- XFillRectangle (
- Private->display, Private->win, Private->gc,
- Args->DestinationX, Args->DestinationY, Args->Width, Args->Height
- );
- XFlush (Private->display);
- break;
- case EfiUgaBltBufferToVideo:
- Redraw (Private, Args->DestinationX, Args->DestinationY, Args->Width, Args->Height);
- break;
- default:
- break;
+
+ break;
+ case EfiUgaVideoFill:
+ Color = X11PixelToColor (Private, *BltBuffer);
+ XSetForeground (Private->display, Private->gc, Color);
+ XFillRectangle (
+ Private->display,
+ Private->win,
+ Private->gc,
+ Args->DestinationX,
+ Args->DestinationY,
+ Args->Width,
+ Args->Height
+ );
+ XFlush (Private->display);
+ break;
+ case EfiUgaBltBufferToVideo:
+ Redraw (Private, Args->DestinationX, Args->DestinationY, Args->Width, Args->Height);
+ break;
+ default:
+ break;
}
+
return EFI_SUCCESS;
}
-
EFI_STATUS
X11CheckPointer (
- IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo
+ IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo
)
{
GRAPHICS_IO_PRIVATE *Drv;
@@ -876,15 +1001,14 @@ X11CheckPointer (
return EFI_NOT_READY;
}
-
EFI_STATUS
X11GetPointerState (
IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo,
IN EFI_SIMPLE_POINTER_STATE *State
)
{
- EFI_STATUS EfiStatus;
- GRAPHICS_IO_PRIVATE *Drv;
+ EFI_STATUS EfiStatus;
+ GRAPHICS_IO_PRIVATE *Drv;
Drv = (GRAPHICS_IO_PRIVATE *)GraphicsIo;
@@ -898,60 +1022,62 @@ X11GetPointerState (
Drv->pointer_state.RelativeMovementX = 0;
Drv->pointer_state.RelativeMovementY = 0;
Drv->pointer_state.RelativeMovementZ = 0;
- Drv->pointer_state_changed = 0;
+ Drv->pointer_state_changed = 0;
return EFI_SUCCESS;
}
-
-
EFI_STATUS
X11GraphicsWindowOpen (
- IN EMU_IO_THUNK_PROTOCOL *This
+ IN EMU_IO_THUNK_PROTOCOL *This
)
{
- GRAPHICS_IO_PRIVATE *Drv;
- unsigned int border_width = 0;
- char *display_name = NULL;
+ GRAPHICS_IO_PRIVATE *Drv;
+ unsigned int border_width = 0;
+ char *display_name = NULL;
Drv = (GRAPHICS_IO_PRIVATE *)calloc (1, sizeof (GRAPHICS_IO_PRIVATE));
if (Drv == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- Drv->GraphicsIo.Size = GasketX11Size;
- Drv->GraphicsIo.CheckKey = GasketX11CheckKey;
- Drv->GraphicsIo.GetKey = GasketX11GetKey;
- Drv->GraphicsIo.KeySetState = GasketX11KeySetState;
- Drv->GraphicsIo.RegisterKeyNotify = GasketX11RegisterKeyNotify;
- Drv->GraphicsIo.Blt = GasketX11Blt;
- Drv->GraphicsIo.CheckPointer = GasketX11CheckPointer;
- Drv->GraphicsIo.GetPointerState = GasketX11GetPointerState;
-
-
- Drv->key_count = 0;
- Drv->key_rd = 0;
- Drv->key_wr = 0;
+ Drv->GraphicsIo.Size = GasketX11Size;
+ Drv->GraphicsIo.CheckKey = GasketX11CheckKey;
+ Drv->GraphicsIo.GetKey = GasketX11GetKey;
+ Drv->GraphicsIo.KeySetState = GasketX11KeySetState;
+ Drv->GraphicsIo.RegisterKeyNotify = GasketX11RegisterKeyNotify;
+ Drv->GraphicsIo.Blt = GasketX11Blt;
+ Drv->GraphicsIo.CheckPointer = GasketX11CheckPointer;
+ Drv->GraphicsIo.GetPointerState = GasketX11GetPointerState;
+
+ Drv->key_count = 0;
+ Drv->key_rd = 0;
+ Drv->key_wr = 0;
Drv->KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID;
Drv->KeyState.KeyToggleState = EFI_TOGGLE_STATE_VALID;
Drv->MakeRegisterdKeyCallback = NULL;
Drv->BreakRegisterdKeyCallback = NULL;
Drv->RegisterdKeyCallbackContext = NULL;
-
Drv->display = XOpenDisplay (display_name);
if (Drv->display == NULL) {
fprintf (stderr, "uga: cannot connect to X server %s\n", XDisplayName (display_name));
free (Drv);
return EFI_DEVICE_ERROR;
}
+
Drv->screen = DefaultScreen (Drv->display);
Drv->visual = DefaultVisual (Drv->display, Drv->screen);
- Drv->win = XCreateSimpleWindow (
- Drv->display, RootWindow (Drv->display, Drv->screen),
- 0, 0, 4, 4, border_width,
- WhitePixel (Drv->display, Drv->screen),
- BlackPixel (Drv->display, Drv->screen)
- );
+ Drv->win = XCreateSimpleWindow (
+ Drv->display,
+ RootWindow (Drv->display, Drv->screen),
+ 0,
+ 0,
+ 4,
+ 4,
+ border_width,
+ WhitePixel (Drv->display, Drv->screen),
+ BlackPixel (Drv->display, Drv->screen)
+ );
Drv->depth = DefaultDepth (Drv->display, Drv->screen);
XDefineCursor (Drv->display, Drv->win, XCreateFontCursor (Drv->display, XC_pirate));
@@ -960,9 +1086,10 @@ X11GraphicsWindowOpen (
UnicodeStrToAsciiStrS (This->ConfigString, Drv->Title, StrSize (This->ConfigString));
XStoreName (Drv->display, Drv->win, Drv->Title);
-// XAutoRepeatOff (Drv->display);
+ // XAutoRepeatOff (Drv->display);
XSelectInput (
- Drv->display, Drv->win,
+ Drv->display,
+ Drv->win,
ExposureMask | KeyPressMask | KeyReleaseMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask
);
Drv->gc = DefaultGC (Drv->display, Drv->screen);
@@ -972,13 +1099,12 @@ X11GraphicsWindowOpen (
return EFI_SUCCESS;
}
-
EFI_STATUS
X11GraphicsWindowClose (
- IN EMU_IO_THUNK_PROTOCOL *This
+ IN EMU_IO_THUNK_PROTOCOL *This
)
{
- GRAPHICS_IO_PRIVATE *Drv;
+ GRAPHICS_IO_PRIVATE *Drv;
Drv = (GRAPHICS_IO_PRIVATE *)This->Private;
@@ -987,29 +1113,29 @@ X11GraphicsWindowClose (
}
if (Drv->image != NULL) {
- XDestroyImage(Drv->image);
+ XDestroyImage (Drv->image);
if (Drv->use_shm) {
shmdt (Drv->image_data);
}
Drv->image_data = NULL;
- Drv->image = NULL;
+ Drv->image = NULL;
}
+
XDestroyWindow (Drv->display, Drv->win);
XCloseDisplay (Drv->display);
-#ifdef __APPLE__
+ #ifdef __APPLE__
// Free up the shared memory
shmctl (Drv->xshm_info.shmid, IPC_RMID, NULL);
-#endif
+ #endif
free (Drv);
return EFI_SUCCESS;
}
-
-EMU_IO_THUNK_PROTOCOL gX11ThunkIo = {
+EMU_IO_THUNK_PROTOCOL gX11ThunkIo = {
&gEmuGraphicsWindowProtocolGuid,
NULL,
NULL,
@@ -1018,5 +1144,3 @@ EMU_IO_THUNK_PROTOCOL gX11ThunkIo = {
GasketX11GraphicsWindowClose,
NULL
};
-
-
diff --git a/EmulatorPkg/Win/Host/WinBlockIo.c b/EmulatorPkg/Win/Host/WinBlockIo.c
index f602a6a01d..c7cfbee2e0 100644
--- a/EmulatorPkg/Win/Host/WinBlockIo.c
+++ b/EmulatorPkg/Win/Host/WinBlockIo.c
@@ -7,63 +7,60 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "WinHost.h"
-#define WIN_NT_BLOCK_IO_PRIVATE_SIGNATURE SIGNATURE_32 ('N', 'T', 'b', 'k')
+#define WIN_NT_BLOCK_IO_PRIVATE_SIGNATURE SIGNATURE_32 ('N', 'T', 'b', 'k')
typedef struct {
- UINTN Signature;
+ UINTN Signature;
- EMU_IO_THUNK_PROTOCOL *Thunk;
+ EMU_IO_THUNK_PROTOCOL *Thunk;
- CHAR16 *FileName;
- BOOLEAN Removable;
- BOOLEAN Readonly;
+ CHAR16 *FileName;
+ BOOLEAN Removable;
+ BOOLEAN Readonly;
- HANDLE NtHandle;
- UINT32 BlockSize;
+ HANDLE NtHandle;
+ UINT32 BlockSize;
- EFI_BLOCK_IO_MEDIA *Media;
- EMU_BLOCK_IO_PROTOCOL EmuBlockIo;
+ EFI_BLOCK_IO_MEDIA *Media;
+ EMU_BLOCK_IO_PROTOCOL EmuBlockIo;
} WIN_NT_BLOCK_IO_PRIVATE;
#define WIN_NT_BLOCK_IO_PRIVATE_DATA_FROM_THIS(a) \
CR(a, WIN_NT_BLOCK_IO_PRIVATE, EmuBlockIo, WIN_NT_BLOCK_IO_PRIVATE_SIGNATURE)
-
EFI_STATUS
WinNtBlockIoReset (
- IN EMU_BLOCK_IO_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EMU_BLOCK_IO_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
);
-
-
-
EFI_STATUS
SetFilePointer64 (
- IN WIN_NT_BLOCK_IO_PRIVATE *Private,
- IN INT64 DistanceToMove,
- OUT UINT64 *NewFilePointer,
- IN DWORD MoveMethod
-)
+ IN WIN_NT_BLOCK_IO_PRIVATE *Private,
+ IN INT64 DistanceToMove,
+ OUT UINT64 *NewFilePointer,
+ IN DWORD MoveMethod
+ )
+
/*++
This function extends the capability of SetFilePointer to accept 64 bit parameters
--*/
{
- EFI_STATUS Status;
- LARGE_INTEGER LargeInt;
+ EFI_STATUS Status;
+ LARGE_INTEGER LargeInt;
LargeInt.QuadPart = DistanceToMove;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
LargeInt.LowPart = SetFilePointer (
- Private->NtHandle,
- LargeInt.LowPart,
- &LargeInt.HighPart,
- MoveMethod
- );
+ Private->NtHandle,
+ LargeInt.LowPart,
+ &LargeInt.HighPart,
+ MoveMethod
+ );
- if (LargeInt.LowPart == -1 && GetLastError () != NO_ERROR) {
+ if ((LargeInt.LowPart == -1) && (GetLastError () != NO_ERROR)) {
Status = EFI_INVALID_PARAMETER;
}
@@ -74,16 +71,14 @@ This function extends the capability of SetFilePointer to accept 64 bit paramete
return Status;
}
-
-
EFI_STATUS
WinNtBlockIoOpenDevice (
- IN WIN_NT_BLOCK_IO_PRIVATE *Private,
- IN EFI_BLOCK_IO_MEDIA *Media
+ IN WIN_NT_BLOCK_IO_PRIVATE *Private,
+ IN EFI_BLOCK_IO_MEDIA *Media
)
{
- EFI_STATUS Status;
- UINT64 FileSize;
+ EFI_STATUS Status;
+ UINT64 FileSize;
//
// If the device is already opened, close it
@@ -96,19 +91,19 @@ WinNtBlockIoOpenDevice (
// Open the device
//
Private->NtHandle = CreateFile (
- Private->FileName,
- GENERIC_READ | (Private->Readonly ? 0 : GENERIC_WRITE),
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL,
- OPEN_ALWAYS, // Create if it doesn't exist
- 0,
- NULL
- );
+ Private->FileName,
+ GENERIC_READ | (Private->Readonly ? 0 : GENERIC_WRITE),
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ OPEN_ALWAYS, // Create if it doesn't exist
+ 0,
+ NULL
+ );
if (Private->NtHandle == INVALID_HANDLE_VALUE) {
DEBUG ((DEBUG_INFO, "OpenBlock: Could not open %S, %x\n", Private->FileName, GetLastError ()));
Media->MediaPresent = FALSE;
- Status = EFI_NO_MEDIA;
+ Status = EFI_NO_MEDIA;
goto Done;
}
@@ -138,15 +133,14 @@ Done:
return Status;
}
-
EFI_STATUS
EFIAPI
WinNtBlockIoCreateMapping (
- IN EMU_BLOCK_IO_PROTOCOL *This,
- IN EFI_BLOCK_IO_MEDIA *Media
+ IN EMU_BLOCK_IO_PROTOCOL *This,
+ IN EFI_BLOCK_IO_MEDIA *Media
)
{
- WIN_NT_BLOCK_IO_PRIVATE *Private;
+ WIN_NT_BLOCK_IO_PRIVATE *Private;
Private = WIN_NT_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);
@@ -164,7 +158,6 @@ WinNtBlockIoCreateMapping (
Media->LowestAlignedLba = 0;
Media->LogicalBlocksPerPhysicalBlock = 0;
-
// EFI_BLOCK_IO_PROTOCOL_REVISION3
Media->OptimalTransferLengthGranularity = 0;
@@ -175,12 +168,11 @@ WinNtBlockIoCreateMapping (
return WinNtBlockIoOpenDevice (Private, Media);
}
-
-
EFI_STATUS
WinNtBlockIoError (
- IN WIN_NT_BLOCK_IO_PRIVATE *Private
-)
+ IN WIN_NT_BLOCK_IO_PRIVATE *Private
+ )
+
/*++
Routine Description:
@@ -197,49 +189,47 @@ Returns:
--*/
{
- EFI_BLOCK_IO_MEDIA *Media;
- EFI_STATUS Status;
+ EFI_BLOCK_IO_MEDIA *Media;
+ EFI_STATUS Status;
Media = Private->Media;
switch (GetLastError ()) {
-
- case ERROR_NOT_READY:
- Media->ReadOnly = FALSE;
- Media->MediaPresent = FALSE;
- Status = EFI_NO_MEDIA;
- break;
-
- case ERROR_WRONG_DISK:
- Media->ReadOnly = FALSE;
- Media->MediaPresent = TRUE;
- Media->MediaId++;
- Status = EFI_MEDIA_CHANGED;
- break;
-
- case ERROR_WRITE_PROTECT:
- Media->ReadOnly = TRUE;
- Status = EFI_WRITE_PROTECTED;
- break;
-
- default:
- Status = EFI_DEVICE_ERROR;
- break;
+ case ERROR_NOT_READY:
+ Media->ReadOnly = FALSE;
+ Media->MediaPresent = FALSE;
+ Status = EFI_NO_MEDIA;
+ break;
+
+ case ERROR_WRONG_DISK:
+ Media->ReadOnly = FALSE;
+ Media->MediaPresent = TRUE;
+ Media->MediaId++;
+ Status = EFI_MEDIA_CHANGED;
+ break;
+
+ case ERROR_WRITE_PROTECT:
+ Media->ReadOnly = TRUE;
+ Status = EFI_WRITE_PROTECTED;
+ break;
+
+ default:
+ Status = EFI_DEVICE_ERROR;
+ break;
}
- if (Status == EFI_NO_MEDIA || Status == EFI_MEDIA_CHANGED) {
+ if ((Status == EFI_NO_MEDIA) || (Status == EFI_MEDIA_CHANGED)) {
WinNtBlockIoReset (&Private->EmuBlockIo, FALSE);
}
return Status;
}
-
EFI_STATUS
WinNtSignalToken (
- IN OUT EFI_BLOCK_IO2_TOKEN *Token,
- IN EFI_STATUS Status
-)
+ IN OUT EFI_BLOCK_IO2_TOKEN *Token,
+ IN EFI_STATUS Status
+ )
{
if (Token != NULL) {
if (Token->Event != NULL) {
@@ -248,6 +238,7 @@ WinNtSignalToken (
return EFI_SUCCESS;
}
}
+
return Status;
}
@@ -291,15 +282,15 @@ WinNtBlockIoReadBlocks (
IN EFI_LBA Lba,
IN OUT EFI_BLOCK_IO2_TOKEN *Token,
IN UINTN BufferSize,
- OUT VOID *Buffer
+ OUT VOID *Buffer
)
{
- WIN_NT_BLOCK_IO_PRIVATE *Private;
- BOOL Flag;
- EFI_STATUS Status;
- DWORD BytesRead;
- UINT64 DistanceToMove;
- UINT64 DistanceMoved;
+ WIN_NT_BLOCK_IO_PRIVATE *Private;
+ BOOL Flag;
+ EFI_STATUS Status;
+ DWORD BytesRead;
+ UINT64 DistanceToMove;
+ UINT64 DistanceMoved;
Private = WIN_NT_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);
@@ -307,7 +298,7 @@ WinNtBlockIoReadBlocks (
// Seek to proper position
//
DistanceToMove = MultU64x32 (Lba, (UINT32)Private->BlockSize);
- Status = SetFilePointer64 (Private, DistanceToMove, &DistanceMoved, FILE_BEGIN);
+ Status = SetFilePointer64 (Private, DistanceToMove, &DistanceMoved, FILE_BEGIN);
if (EFI_ERROR (Status) || (DistanceToMove != DistanceMoved)) {
DEBUG ((DEBUG_INIT, "ReadBlocks: SetFilePointer failed\n"));
@@ -323,7 +314,6 @@ WinNtBlockIoReadBlocks (
return WinNtSignalToken (Token, EFI_SUCCESS);
}
-
/**
Write BufferSize bytes from Lba into Buffer.
@@ -365,12 +355,12 @@ WinNtBlockIoWriteBlocks (
IN VOID *Buffer
)
{
- WIN_NT_BLOCK_IO_PRIVATE *Private;
- UINTN BytesWritten;
- BOOL Success;
- EFI_STATUS Status;
- UINT64 DistanceToMove;
- UINT64 DistanceMoved;
+ WIN_NT_BLOCK_IO_PRIVATE *Private;
+ UINTN BytesWritten;
+ BOOL Success;
+ EFI_STATUS Status;
+ UINT64 DistanceToMove;
+ UINT64 DistanceMoved;
Private = WIN_NT_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);
@@ -378,7 +368,7 @@ WinNtBlockIoWriteBlocks (
// Seek to proper position
//
DistanceToMove = MultU64x32 (Lba, (UINT32)Private->BlockSize);
- Status = SetFilePointer64 (Private, DistanceToMove, &DistanceMoved, FILE_BEGIN);
+ Status = SetFilePointer64 (Private, DistanceToMove, &DistanceMoved, FILE_BEGIN);
if (EFI_ERROR (Status) || (DistanceToMove != DistanceMoved)) {
DEBUG ((DEBUG_INIT, "WriteBlocks: SetFilePointer failed\n"));
@@ -422,14 +412,13 @@ WinNtBlockIoWriteBlocks (
**/
EFI_STATUS
WinNtBlockIoFlushBlocks (
- IN EMU_BLOCK_IO_PROTOCOL *This,
- IN OUT EFI_BLOCK_IO2_TOKEN *Token
+ IN EMU_BLOCK_IO_PROTOCOL *This,
+ IN OUT EFI_BLOCK_IO2_TOKEN *Token
)
{
return WinNtSignalToken (Token, EFI_SUCCESS);
}
-
/**
Reset the block device hardware.
@@ -445,11 +434,11 @@ WinNtBlockIoFlushBlocks (
**/
EFI_STATUS
WinNtBlockIoReset (
- IN EMU_BLOCK_IO_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EMU_BLOCK_IO_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
)
{
- WIN_NT_BLOCK_IO_PRIVATE *Private;
+ WIN_NT_BLOCK_IO_PRIVATE *Private;
Private = WIN_NT_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);
@@ -461,7 +450,7 @@ WinNtBlockIoReset (
return EFI_SUCCESS;
}
-EMU_BLOCK_IO_PROTOCOL gEmuBlockIoProtocol = {
+EMU_BLOCK_IO_PROTOCOL gEmuBlockIoProtocol = {
WinNtBlockIoReset,
WinNtBlockIoReadBlocks,
WinNtBlockIoWriteBlocks,
@@ -472,7 +461,7 @@ EMU_BLOCK_IO_PROTOCOL gEmuBlockIoProtocol = {
EFI_STATUS
EFIAPI
WinNtBlockIoThunkOpen (
- IN EMU_IO_THUNK_PROTOCOL *This
+ IN EMU_IO_THUNK_PROTOCOL *This
)
{
WIN_NT_BLOCK_IO_PRIVATE *Private;
@@ -487,12 +476,13 @@ WinNtBlockIoThunkOpen (
Private->Thunk = This;
CopyMem (&Private->EmuBlockIo, &gEmuBlockIoProtocol, sizeof (gEmuBlockIoProtocol));
Private->BlockSize = 512;
- Private->NtHandle = INVALID_HANDLE_VALUE;
+ Private->NtHandle = INVALID_HANDLE_VALUE;
Private->FileName = AllocateCopyPool (StrSize (This->ConfigString), This->ConfigString);
if (Private->FileName == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
//
// Parse ConfigString
// <ConfigString> := <FileName> ':' [RF][OW] ':' <BlockSize>
@@ -503,12 +493,14 @@ WinNtBlockIoThunkOpen (
Private->Readonly = FALSE;
} else {
for (*Str++ = L'\0'; *Str != L'\0'; Str++) {
- if (*Str == 'R' || *Str == 'F') {
- Private->Removable = (BOOLEAN) (*Str == L'R');
+ if ((*Str == 'R') || (*Str == 'F')) {
+ Private->Removable = (BOOLEAN)(*Str == L'R');
}
- if (*Str == 'O' || *Str == 'W') {
- Private->Readonly = (BOOLEAN) (*Str == L'O');
+
+ if ((*Str == 'O') || (*Str == 'W')) {
+ Private->Readonly = (BOOLEAN)(*Str == L'O');
}
+
if (*Str == ':') {
Private->BlockSize = wcstol (++Str, NULL, 0);
break;
@@ -521,11 +513,10 @@ WinNtBlockIoThunkOpen (
return EFI_SUCCESS;
}
-
EFI_STATUS
EFIAPI
WinNtBlockIoThunkClose (
- IN EMU_IO_THUNK_PROTOCOL *This
+ IN EMU_IO_THUNK_PROTOCOL *This
)
{
WIN_NT_BLOCK_IO_PRIVATE *Private;
@@ -536,15 +527,14 @@ WinNtBlockIoThunkClose (
if (Private->FileName != NULL) {
FreePool (Private->FileName);
}
+
FreePool (Private);
}
return EFI_SUCCESS;
}
-
-
-EMU_IO_THUNK_PROTOCOL mWinNtBlockIoThunkIo = {
+EMU_IO_THUNK_PROTOCOL mWinNtBlockIoThunkIo = {
&gEmuBlockIoProtocolGuid,
NULL,
NULL,
diff --git a/EmulatorPkg/Win/Host/WinFileSystem.c b/EmulatorPkg/Win/Host/WinFileSystem.c
index f6b06b1c92..5ca404020c 100644
--- a/EmulatorPkg/Win/Host/WinFileSystem.c
+++ b/EmulatorPkg/Win/Host/WinFileSystem.c
@@ -9,15 +9,14 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "WinHost.h"
-
-#define WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE SIGNATURE_32 ('N', 'T', 'f', 's')
+#define WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE SIGNATURE_32 ('N', 'T', 'f', 's')
typedef struct {
- UINTN Signature;
- EMU_IO_THUNK_PROTOCOL *Thunk;
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL SimpleFileSystem;
- CHAR16 *FilePath;
- CHAR16 *VolumeLabel;
+ UINTN Signature;
+ EMU_IO_THUNK_PROTOCOL *Thunk;
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL SimpleFileSystem;
+ CHAR16 *FilePath;
+ CHAR16 *VolumeLabel;
} WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE;
#define WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS(a) \
@@ -27,23 +26,22 @@ typedef struct {
WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE \
)
-
-#define WIN_NT_EFI_FILE_PRIVATE_SIGNATURE SIGNATURE_32 ('l', 'o', 'f', 's')
+#define WIN_NT_EFI_FILE_PRIVATE_SIGNATURE SIGNATURE_32 ('l', 'o', 'f', 's')
typedef struct {
- UINTN Signature;
- EMU_IO_THUNK_PROTOCOL *Thunk;
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem;
- EFI_FILE_PROTOCOL EfiFile;
- HANDLE LHandle;
- HANDLE DirHandle;
- BOOLEAN IsRootDirectory;
- BOOLEAN IsDirectoryPath;
- BOOLEAN IsOpenedByRead;
- CHAR16 *FilePath;
- WCHAR *FileName;
- BOOLEAN IsValidFindBuf;
- WIN32_FIND_DATA FindBuf;
+ UINTN Signature;
+ EMU_IO_THUNK_PROTOCOL *Thunk;
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem;
+ EFI_FILE_PROTOCOL EfiFile;
+ HANDLE LHandle;
+ HANDLE DirHandle;
+ BOOLEAN IsRootDirectory;
+ BOOLEAN IsDirectoryPath;
+ BOOLEAN IsOpenedByRead;
+ CHAR16 *FilePath;
+ WCHAR *FileName;
+ BOOLEAN IsValidFindBuf;
+ WIN32_FIND_DATA FindBuf;
} WIN_NT_EFI_FILE_PRIVATE;
#define WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS(a) \
@@ -53,32 +51,31 @@ typedef struct {
WIN_NT_EFI_FILE_PRIVATE_SIGNATURE \
)
-extern EFI_FILE_PROTOCOL gWinNtFileProtocol;
-extern EFI_SIMPLE_FILE_SYSTEM_PROTOCOL gWinNtFileSystemProtocol;
+extern EFI_FILE_PROTOCOL gWinNtFileProtocol;
+extern EFI_SIMPLE_FILE_SYSTEM_PROTOCOL gWinNtFileSystemProtocol;
EFI_STATUS
WinNtFileGetInfo (
- IN EFI_FILE_PROTOCOL *This,
- IN EFI_GUID *InformationType,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN EFI_GUID *InformationType,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
);
EFI_STATUS
WinNtFileSetInfo (
- IN EFI_FILE_PROTOCOL *This,
- IN EFI_GUID *InformationType,
- IN UINTN BufferSize,
- IN VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN EFI_GUID *InformationType,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
);
-
-
CHAR16 *
EfiStrChr (
- IN CHAR16 *Str,
- IN CHAR16 Chr
-)
+ IN CHAR16 *Str,
+ IN CHAR16 Chr
+ )
+
/*++
Routine Description:
@@ -109,24 +106,22 @@ Returns:
return (*Str == Chr) ? Str : NULL;
}
-
-
BOOLEAN
IsZero (
IN VOID *Buffer,
IN UINTN Length
)
{
- if (Buffer == NULL || Length == 0) {
+ if ((Buffer == NULL) || (Length == 0)) {
return FALSE;
}
- if (*(UINT8 *) Buffer != 0) {
+ if (*(UINT8 *)Buffer != 0) {
return FALSE;
}
if (Length > 1) {
- if (!CompareMem (Buffer, (UINT8 *) Buffer + 1, Length - 1)) {
+ if (!CompareMem (Buffer, (UINT8 *)Buffer + 1, Length - 1)) {
return FALSE;
}
}
@@ -147,13 +142,14 @@ CutPrefix (
}
if (Count != 0) {
- for (Pointer = Str; *(Pointer + Count); Pointer++) {
- *Pointer = *(Pointer + Count);
- }
+ for (Pointer = Str; *(Pointer + Count); Pointer++) {
+ *Pointer = *(Pointer + Count);
+ }
- *Pointer = *(Pointer + Count);
+ *Pointer = *(Pointer + Count);
}
}
+
/**
Open the root directory on a volume.
@@ -171,17 +167,17 @@ CutPrefix (
**/
EFI_STATUS
WinNtOpenVolume (
- IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,
- OUT EFI_FILE_PROTOCOL **Root
+ IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,
+ OUT EFI_FILE_PROTOCOL **Root
)
{
- EFI_STATUS Status;
- WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE *Private;
- WIN_NT_EFI_FILE_PRIVATE *PrivateFile;
- CHAR16 *TempFileName;
- UINTN Size;
+ EFI_STATUS Status;
+ WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE *Private;
+ WIN_NT_EFI_FILE_PRIVATE *PrivateFile;
+ CHAR16 *TempFileName;
+ UINTN Size;
- if (This == NULL || Root == NULL) {
+ if ((This == NULL) || (Root == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -205,20 +201,22 @@ WinNtOpenVolume (
goto Done;
}
- StrCpyS (PrivateFile->FilePath,
+ StrCpyS (
+ PrivateFile->FilePath,
StrSize (Private->FilePath) / sizeof (CHAR16),
Private->FilePath
);
- StrCpyS (PrivateFile->FileName,
+ StrCpyS (
+ PrivateFile->FileName,
StrSize (Private->FilePath) / sizeof (CHAR16),
PrivateFile->FilePath
);
- PrivateFile->Signature = WIN_NT_EFI_FILE_PRIVATE_SIGNATURE;
- PrivateFile->Thunk = Private->Thunk;
+ PrivateFile->Signature = WIN_NT_EFI_FILE_PRIVATE_SIGNATURE;
+ PrivateFile->Thunk = Private->Thunk;
PrivateFile->SimpleFileSystem = This;
- PrivateFile->IsRootDirectory = TRUE;
- PrivateFile->IsDirectoryPath = TRUE;
- PrivateFile->IsOpenedByRead = TRUE;
+ PrivateFile->IsRootDirectory = TRUE;
+ PrivateFile->IsDirectoryPath = TRUE;
+ PrivateFile->IsOpenedByRead = TRUE;
CopyMem (&PrivateFile->EfiFile, &gWinNtFileProtocol, sizeof (gWinNtFileProtocol));
PrivateFile->IsValidFindBuf = FALSE;
@@ -226,14 +224,14 @@ WinNtOpenVolume (
// Set DirHandle
//
PrivateFile->DirHandle = CreateFile (
- PrivateFile->FilePath,
- GENERIC_READ,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL,
- OPEN_EXISTING,
- FILE_FLAG_BACKUP_SEMANTICS,
- NULL
- );
+ PrivateFile->FilePath,
+ GENERIC_READ,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ OPEN_EXISTING,
+ FILE_FLAG_BACKUP_SEMANTICS,
+ NULL
+ );
if (PrivateFile->DirHandle == INVALID_HANDLE_VALUE) {
Status = EFI_NOT_FOUND;
@@ -243,12 +241,13 @@ WinNtOpenVolume (
//
// Find the first file under it
//
- Size = StrSize (PrivateFile->FilePath);
- Size += StrSize (L"\\*");
+ Size = StrSize (PrivateFile->FilePath);
+ Size += StrSize (L"\\*");
TempFileName = AllocatePool (Size);
if (TempFileName == NULL) {
goto Done;
}
+
StrCpyS (TempFileName, Size / sizeof (CHAR16), PrivateFile->FilePath);
StrCatS (TempFileName, Size / sizeof (CHAR16), L"\\*");
@@ -260,6 +259,7 @@ WinNtOpenVolume (
} else {
PrivateFile->IsValidFindBuf = TRUE;
}
+
*Root = &PrivateFile->EfiFile;
Status = EFI_SUCCESS;
@@ -292,10 +292,10 @@ Done:
**/
UINTN
CountLeadingDots (
- IN CONST CHAR16 * FileNameToken
-)
+ IN CONST CHAR16 *FileNameToken
+ )
{
- UINTN Num;
+ UINTN Num;
Num = 0;
while (*FileNameToken == L'.') {
@@ -306,13 +306,13 @@ CountLeadingDots (
return Num;
}
-
BOOLEAN
IsFileNameTokenValid (
- IN CONST CHAR16 * FileNameToken
-)
+ IN CONST CHAR16 *FileNameToken
+ )
{
- UINTN Num;
+ UINTN Num;
+
if (StrStr (FileNameToken, L"/") != NULL) {
//
// No L'/' in file name.
@@ -337,7 +337,6 @@ IsFileNameTokenValid (
return TRUE;
}
-
/**
Return the first string token found in the indirect pointer a String named by FileName.
@@ -352,22 +351,23 @@ IsFileNameTokenValid (
**/
CHAR16 *
GetNextFileNameToken (
- IN OUT CONST CHAR16 ** FileName
-)
+ IN OUT CONST CHAR16 **FileName
+ )
{
- CHAR16 *SlashPos;
- CHAR16 *Token;
- UINTN Offset;
+ CHAR16 *SlashPos;
+ CHAR16 *Token;
+ UINTN Offset;
+
ASSERT (**FileName != L'\\');
ASSERT (**FileName != L'\0');
SlashPos = StrStr (*FileName, L"\\");
if (SlashPos == NULL) {
- Token = AllocateCopyPool (StrSize (*FileName), *FileName);
+ Token = AllocateCopyPool (StrSize (*FileName), *FileName);
*FileName = NULL;
} else {
Offset = SlashPos - *FileName;
- Token = AllocateZeroPool ((Offset + 1) * sizeof (CHAR16));
+ Token = AllocateZeroPool ((Offset + 1) * sizeof (CHAR16));
StrnCpyS (Token, Offset + 1, *FileName, Offset);
//
// Point *FileName to the next character after L'\'.
@@ -384,7 +384,6 @@ GetNextFileNameToken (
return Token;
}
-
/**
Check if a FileName contains only Valid Characters.
@@ -400,14 +399,13 @@ GetNextFileNameToken (
@return FALSE FileName contains at least one invalid character.
**/
-
BOOLEAN
IsFileNameValid (
- IN CONST CHAR16 *FileName
+ IN CONST CHAR16 *FileName
)
{
- CHAR16 *Token;
- BOOLEAN Valid;
+ CHAR16 *Token;
+ BOOLEAN Valid;
//
// If FileName is just L'\', then it is a valid pathname.
@@ -415,6 +413,7 @@ IsFileNameValid (
if (StrCmp (FileName, L"\\") == 0) {
return TRUE;
}
+
//
// We don't support two or more adjacent L'\'.
//
@@ -425,7 +424,7 @@ IsFileNameValid (
//
// Is FileName has a leading L"\", skip to next character.
//
- if (FileName [0] == L'\\') {
+ if (FileName[0] == L'\\') {
FileName++;
}
@@ -434,14 +433,14 @@ IsFileNameValid (
Valid = IsFileNameTokenValid (Token);
FreePool (Token);
- if (!Valid)
+ if (!Valid) {
return FALSE;
+ }
} while (FileName != NULL);
return TRUE;
}
-
/**
Opens a new file relative to the source file's location.
@@ -464,35 +463,34 @@ IsFileNameValid (
**/
EFI_STATUS
WinNtFileOpen (
- IN EFI_FILE_PROTOCOL *This,
- OUT EFI_FILE_PROTOCOL **NewHandle,
- IN CHAR16 *FileName,
- IN UINT64 OpenMode,
- IN UINT64 Attributes
+ IN EFI_FILE_PROTOCOL *This,
+ OUT EFI_FILE_PROTOCOL **NewHandle,
+ IN CHAR16 *FileName,
+ IN UINT64 OpenMode,
+ IN UINT64 Attributes
)
{
- WIN_NT_EFI_FILE_PRIVATE *PrivateFile;
- WIN_NT_EFI_FILE_PRIVATE *NewPrivateFile;
- WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE *PrivateRoot;
- EFI_STATUS Status;
- CHAR16 *RealFileName;
- CHAR16 *TempFileName;
- CHAR16 *ParseFileName;
- CHAR16 *GuardPointer;
- CHAR16 TempChar;
- DWORD LastError;
- UINTN Count;
- BOOLEAN LoopFinish;
- UINTN InfoSize;
- EFI_FILE_INFO *Info;
- UINTN Size;
-
+ WIN_NT_EFI_FILE_PRIVATE *PrivateFile;
+ WIN_NT_EFI_FILE_PRIVATE *NewPrivateFile;
+ WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE *PrivateRoot;
+ EFI_STATUS Status;
+ CHAR16 *RealFileName;
+ CHAR16 *TempFileName;
+ CHAR16 *ParseFileName;
+ CHAR16 *GuardPointer;
+ CHAR16 TempChar;
+ DWORD LastError;
+ UINTN Count;
+ BOOLEAN LoopFinish;
+ UINTN InfoSize;
+ EFI_FILE_INFO *Info;
+ UINTN Size;
//
// Init local variables
//
- PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
- PrivateRoot = WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (PrivateFile->SimpleFileSystem);
+ PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
+ PrivateRoot = WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (PrivateFile->SimpleFileSystem);
NewPrivateFile = NULL;
//
@@ -502,6 +500,7 @@ WinNtFileOpen (
if (TempFileName == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
StrCpyS (TempFileName, StrSize (FileName) / sizeof (CHAR16), FileName);
FileName = TempFileName;
@@ -513,26 +512,30 @@ WinNtFileOpen (
// If file name does not equal to "." or ".." and not trailed with "\..",
// then we trim the leading/trailing blanks and trailing dots
//
- if (StrCmp (FileName, L".") != 0 && StrCmp (FileName, L"..") != 0 &&
- ((StrLen (FileName) >= 3) ? (StrCmp (&FileName[StrLen (FileName) - 3], L"\\..") != 0) : TRUE)) {
+ if ((StrCmp (FileName, L".") != 0) && (StrCmp (FileName, L"..") != 0) &&
+ ((StrLen (FileName) >= 3) ? (StrCmp (&FileName[StrLen (FileName) - 3], L"\\..") != 0) : TRUE))
+ {
//
// Trim leading blanks
//
Count = 0;
for (TempFileName = FileName;
- *TempFileName != 0 && *TempFileName == L' ';
- TempFileName++) {
+ *TempFileName != 0 && *TempFileName == L' ';
+ TempFileName++)
+ {
Count++;
}
+
CutPrefix (FileName, Count);
//
// Trim trailing blanks
//
for (TempFileName = FileName + StrLen (FileName) - 1;
- TempFileName >= FileName && (*TempFileName == L' ');
- TempFileName--) {
- ;
+ TempFileName >= FileName && (*TempFileName == L' ');
+ TempFileName--)
+ {
}
+
*(TempFileName + 1) = 0;
}
@@ -567,9 +570,9 @@ WinNtFileOpen (
);
}
- Size = StrSize (NewPrivateFile->FilePath);
- Size += StrSize (L"\\");
- Size += StrSize (FileName);
+ Size = StrSize (NewPrivateFile->FilePath);
+ Size += StrSize (L"\\");
+ Size += StrSize (FileName);
NewPrivateFile->FileName = AllocatePool (Size);
if (NewPrivateFile->FileName == NULL) {
Status = EFI_OUT_OF_RESOURCES;
@@ -608,15 +611,14 @@ WinNtFileOpen (
LoopFinish = FALSE;
while (!LoopFinish) {
-
LoopFinish = TRUE;
for (ParseFileName = GuardPointer; *ParseFileName; ParseFileName++) {
- if (*ParseFileName == L'.' &&
- (*(ParseFileName + 1) == 0 || *(ParseFileName + 1) == L'\\') &&
- *(ParseFileName - 1) == L'\\'
- ) {
-
+ if ((*ParseFileName == L'.') &&
+ ((*(ParseFileName + 1) == 0) || (*(ParseFileName + 1) == L'\\')) &&
+ (*(ParseFileName - 1) == L'\\')
+ )
+ {
//
// cut \.
//
@@ -625,12 +627,12 @@ WinNtFileOpen (
break;
}
- if (*ParseFileName == L'.' &&
- *(ParseFileName + 1) == L'.' &&
- (*(ParseFileName + 2) == 0 || *(ParseFileName + 2) == L'\\') &&
- *(ParseFileName - 1) == L'\\'
- ) {
-
+ if ((*ParseFileName == L'.') &&
+ (*(ParseFileName + 1) == L'.') &&
+ ((*(ParseFileName + 2) == 0) || (*(ParseFileName + 2) == L'\\')) &&
+ (*(ParseFileName - 1) == L'\\')
+ )
+ {
ParseFileName--;
Count = 3;
@@ -659,7 +661,7 @@ WinNtFileOpen (
TempChar = 0;
if (RealFileName != NewPrivateFile->FileName) {
- TempChar = *(RealFileName - 1);
+ TempChar = *(RealFileName - 1);
*(RealFileName - 1) = 0;
}
@@ -693,14 +695,14 @@ WinNtFileOpen (
}
} else {
NewPrivateFile->LHandle = CreateFile (
- NewPrivateFile->FileName,
- GENERIC_READ,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL,
- OPEN_EXISTING,
- 0,
- NULL
- );
+ NewPrivateFile->FileName,
+ GENERIC_READ,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ OPEN_EXISTING,
+ 0,
+ NULL
+ );
if (NewPrivateFile->LHandle != INVALID_HANDLE_VALUE) {
NewPrivateFile->IsDirectoryPath = FALSE;
@@ -724,9 +726,8 @@ WinNtFileOpen (
// deal with directory
//
if (NewPrivateFile->IsDirectoryPath) {
-
- Size = StrSize (NewPrivateFile->FileName);
- Size += StrSize (L"\\*");
+ Size = StrSize (NewPrivateFile->FileName);
+ Size += StrSize (L"\\*");
TempFileName = AllocatePool (Size);
if (TempFileName == NULL) {
Status = EFI_OUT_OF_RESOURCES;
@@ -740,7 +741,6 @@ WinNtFileOpen (
// Create a directory
//
if (!CreateDirectory (TempFileName, NULL)) {
-
LastError = GetLastError ();
if (LastError != ERROR_ALREADY_EXISTS) {
FreePool (TempFileName);
@@ -751,31 +751,30 @@ WinNtFileOpen (
}
NewPrivateFile->DirHandle = CreateFile (
- TempFileName,
- NewPrivateFile->IsOpenedByRead ? GENERIC_READ : (GENERIC_READ | GENERIC_WRITE),
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL,
- OPEN_EXISTING,
- FILE_FLAG_BACKUP_SEMANTICS,
- NULL
- );
+ TempFileName,
+ NewPrivateFile->IsOpenedByRead ? GENERIC_READ : (GENERIC_READ | GENERIC_WRITE),
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ OPEN_EXISTING,
+ FILE_FLAG_BACKUP_SEMANTICS,
+ NULL
+ );
if (NewPrivateFile->DirHandle == INVALID_HANDLE_VALUE) {
-
NewPrivateFile->DirHandle = CreateFile (
- TempFileName,
- GENERIC_READ,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL,
- OPEN_EXISTING,
- FILE_FLAG_BACKUP_SEMANTICS,
- NULL
- );
+ TempFileName,
+ GENERIC_READ,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ OPEN_EXISTING,
+ FILE_FLAG_BACKUP_SEMANTICS,
+ NULL
+ );
if (NewPrivateFile->DirHandle != INVALID_HANDLE_VALUE) {
CloseHandle (NewPrivateFile->DirHandle);
NewPrivateFile->DirHandle = INVALID_HANDLE_VALUE;
- Status = EFI_ACCESS_DENIED;
+ Status = EFI_ACCESS_DENIED;
} else {
Status = EFI_NOT_FOUND;
}
@@ -802,25 +801,25 @@ WinNtFileOpen (
//
if (!NewPrivateFile->IsOpenedByRead) {
NewPrivateFile->LHandle = CreateFile (
- NewPrivateFile->FileName,
- GENERIC_READ | GENERIC_WRITE,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL,
- (OpenMode & EFI_FILE_MODE_CREATE) ? OPEN_ALWAYS : OPEN_EXISTING,
- 0,
- NULL
- );
+ NewPrivateFile->FileName,
+ GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ (OpenMode & EFI_FILE_MODE_CREATE) ? OPEN_ALWAYS : OPEN_EXISTING,
+ 0,
+ NULL
+ );
if (NewPrivateFile->LHandle == INVALID_HANDLE_VALUE) {
NewPrivateFile->LHandle = CreateFile (
- NewPrivateFile->FileName,
- GENERIC_READ,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL,
- OPEN_EXISTING,
- 0,
- NULL
- );
+ NewPrivateFile->FileName,
+ GENERIC_READ,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ OPEN_EXISTING,
+ 0,
+ NULL
+ );
if (NewPrivateFile->LHandle == INVALID_HANDLE_VALUE) {
Status = EFI_NOT_FOUND;
@@ -832,14 +831,14 @@ WinNtFileOpen (
}
} else {
NewPrivateFile->LHandle = CreateFile (
- NewPrivateFile->FileName,
- GENERIC_READ,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL,
- OPEN_EXISTING,
- 0,
- NULL
- );
+ NewPrivateFile->FileName,
+ GENERIC_READ,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ OPEN_EXISTING,
+ 0,
+ NULL
+ );
if (NewPrivateFile->LHandle == INVALID_HANDLE_VALUE) {
Status = EFI_NOT_FOUND;
@@ -847,12 +846,12 @@ WinNtFileOpen (
}
}
- if ((OpenMode & EFI_FILE_MODE_CREATE) && Status == EFI_SUCCESS) {
+ if ((OpenMode & EFI_FILE_MODE_CREATE) && (Status == EFI_SUCCESS)) {
//
// Set the attribute
//
InfoSize = 0;
- Info = NULL;
+ Info = NULL;
Status = WinNtFileGetInfo (&NewPrivateFile->EfiFile, &gEfiFileInfoGuid, &InfoSize, Info);
@@ -905,8 +904,6 @@ Done:
return Status;
}
-
-
/**
Close the file handle
@@ -920,7 +917,7 @@ WinNtFileClose (
IN EFI_FILE_PROTOCOL *This
)
{
- WIN_NT_EFI_FILE_PRIVATE *PrivateFile;
+ WIN_NT_EFI_FILE_PRIVATE *PrivateFile;
PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
@@ -934,7 +931,7 @@ WinNtFileClose (
PrivateFile->LHandle = INVALID_HANDLE_VALUE;
}
- if (PrivateFile->IsDirectoryPath && PrivateFile->DirHandle != INVALID_HANDLE_VALUE) {
+ if (PrivateFile->IsDirectoryPath && (PrivateFile->DirHandle != INVALID_HANDLE_VALUE)) {
CloseHandle (PrivateFile->DirHandle);
PrivateFile->DirHandle = INVALID_HANDLE_VALUE;
}
@@ -950,10 +947,8 @@ WinNtFileClose (
FreePool (PrivateFile);
return EFI_SUCCESS;
-
}
-
/**
Close and delete the file handle.
@@ -968,8 +963,8 @@ WinNtFileDelete (
IN EFI_FILE_PROTOCOL *This
)
{
- EFI_STATUS Status;
- WIN_NT_EFI_FILE_PRIVATE *PrivateFile;
+ EFI_STATUS Status;
+ WIN_NT_EFI_FILE_PRIVATE *PrivateFile;
PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
@@ -1011,7 +1006,8 @@ WinNtSystemTimeToEfiTime (
IN SYSTEMTIME *SystemTime,
IN TIME_ZONE_INFORMATION *TimeZone,
OUT EFI_TIME *Time
-)
+ )
+
/*++
Routine Description:
@@ -1030,14 +1026,14 @@ Returns:
--*/
{
- Time->Year = (UINT16)SystemTime->wYear;
- Time->Month = (UINT8)SystemTime->wMonth;
- Time->Day = (UINT8)SystemTime->wDay;
- Time->Hour = (UINT8)SystemTime->wHour;
- Time->Minute = (UINT8)SystemTime->wMinute;
- Time->Second = (UINT8)SystemTime->wSecond;
+ Time->Year = (UINT16)SystemTime->wYear;
+ Time->Month = (UINT8)SystemTime->wMonth;
+ Time->Day = (UINT8)SystemTime->wDay;
+ Time->Hour = (UINT8)SystemTime->wHour;
+ Time->Minute = (UINT8)SystemTime->wMinute;
+ Time->Second = (UINT8)SystemTime->wSecond;
Time->Nanosecond = (UINT32)SystemTime->wMilliseconds * 1000000;
- Time->TimeZone = (INT16)TimeZone->Bias;
+ Time->TimeZone = (INT16)TimeZone->Bias;
if (TimeZone->StandardDate.wMonth) {
Time->Daylight = EFI_TIME_ADJUST_DAYLIGHT;
@@ -1054,21 +1050,20 @@ Returns:
**/
VOID
WinNtFileTimeToEfiTime (
- IN CONST WIN_NT_EFI_FILE_PRIVATE *PrivateFile,
- IN TIME_ZONE_INFORMATION *TimeZone,
- IN CONST FILETIME *FileTime,
- OUT EFI_TIME *EfiTime
-)
+ IN CONST WIN_NT_EFI_FILE_PRIVATE *PrivateFile,
+ IN TIME_ZONE_INFORMATION *TimeZone,
+ IN CONST FILETIME *FileTime,
+ OUT EFI_TIME *EfiTime
+ )
{
- FILETIME TempFileTime;
- SYSTEMTIME SystemTime;
+ FILETIME TempFileTime;
+ SYSTEMTIME SystemTime;
FileTimeToLocalFileTime (FileTime, &TempFileTime);
FileTimeToSystemTime (&TempFileTime, &SystemTime);
WinNtSystemTimeToEfiTime (&SystemTime, TimeZone, EfiTime);
}
-
/**
Read data from the file.
@@ -1085,24 +1080,24 @@ WinNtFileTimeToEfiTime (
**/
EFI_STATUS
WinNtFileRead (
- IN EFI_FILE_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
)
{
- WIN_NT_EFI_FILE_PRIVATE *PrivateFile;
- EFI_STATUS Status;
- UINTN Size;
- UINTN NameSize;
- UINTN ResultSize;
- UINTN Index;
- EFI_FILE_INFO *Info;
- WCHAR *pw;
- TIME_ZONE_INFORMATION TimeZone;
- EFI_FILE_INFO *FileInfo;
- UINT64 Pos;
- UINT64 FileSize;
- UINTN FileInfoSize;
+ WIN_NT_EFI_FILE_PRIVATE *PrivateFile;
+ EFI_STATUS Status;
+ UINTN Size;
+ UINTN NameSize;
+ UINTN ResultSize;
+ UINTN Index;
+ EFI_FILE_INFO *Info;
+ WCHAR *pw;
+ TIME_ZONE_INFORMATION TimeZone;
+ EFI_FILE_INFO *FileInfo;
+ UINT64 Pos;
+ UINT64 FileSize;
+ UINTN FileInfoSize;
PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
@@ -1112,31 +1107,30 @@ WinNtFileRead (
}
if (!PrivateFile->IsDirectoryPath) {
-
if (This->GetPosition (This, &Pos) != EFI_SUCCESS) {
Status = EFI_DEVICE_ERROR;
goto Done;
}
FileInfoSize = SIZE_OF_EFI_FILE_SYSTEM_INFO;
- FileInfo = AllocatePool (FileInfoSize);
+ FileInfo = AllocatePool (FileInfoSize);
Status = This->GetInfo (
- This,
- &gEfiFileInfoGuid,
- &FileInfoSize,
- FileInfo
- );
+ This,
+ &gEfiFileInfoGuid,
+ &FileInfoSize,
+ FileInfo
+ );
if (Status == EFI_BUFFER_TOO_SMALL) {
FreePool (FileInfo);
FileInfo = AllocatePool (FileInfoSize);
- Status = This->GetInfo (
- This,
- &gEfiFileInfoGuid,
- &FileInfoSize,
- FileInfo
- );
+ Status = This->GetInfo (
+ This,
+ &gEfiFileInfoGuid,
+ &FileInfoSize,
+ FileInfo
+ );
}
if (EFI_ERROR (Status)) {
@@ -1160,12 +1154,12 @@ WinNtFileRead (
}
Status = ReadFile (
- PrivateFile->LHandle,
- Buffer,
- (DWORD)*BufferSize,
- (LPDWORD)BufferSize,
- NULL
- ) ? EFI_SUCCESS : EFI_DEVICE_ERROR;
+ PrivateFile->LHandle,
+ Buffer,
+ (DWORD)*BufferSize,
+ (LPDWORD)BufferSize,
+ NULL
+ ) ? EFI_SUCCESS : EFI_DEVICE_ERROR;
goto Done;
}
@@ -1174,7 +1168,7 @@ WinNtFileRead (
//
if (!PrivateFile->IsValidFindBuf) {
*BufferSize = 0;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
goto Done;
}
@@ -1244,8 +1238,6 @@ Done:
return Status;
}
-
-
/**
Write data to a file.
@@ -1266,13 +1258,13 @@ Done:
**/
EFI_STATUS
WinNtFileWrite (
- IN EFI_FILE_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- IN VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN OUT UINTN *BufferSize,
+ IN VOID *Buffer
)
{
- WIN_NT_EFI_FILE_PRIVATE *PrivateFile;
- EFI_STATUS Status;
+ WIN_NT_EFI_FILE_PRIVATE *PrivateFile;
+ EFI_STATUS Status;
PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
@@ -1292,12 +1284,12 @@ WinNtFileWrite (
}
Status = WriteFile (
- PrivateFile->LHandle,
- Buffer,
- (DWORD)*BufferSize,
- (LPDWORD)BufferSize,
- NULL
- ) ? EFI_SUCCESS : EFI_DEVICE_ERROR;
+ PrivateFile->LHandle,
+ Buffer,
+ (DWORD)*BufferSize,
+ (LPDWORD)BufferSize,
+ NULL
+ ) ? EFI_SUCCESS : EFI_DEVICE_ERROR;
Done:
return Status;
@@ -1307,8 +1299,6 @@ Done:
//
}
-
-
/**
Set a files current position
@@ -1321,16 +1311,16 @@ Done:
**/
EFI_STATUS
WinNtFileSetPossition (
- IN EFI_FILE_PROTOCOL *This,
- IN UINT64 Position
+ IN EFI_FILE_PROTOCOL *This,
+ IN UINT64 Position
)
{
- EFI_STATUS Status;
- WIN_NT_EFI_FILE_PRIVATE *PrivateFile;
- UINT32 PosLow;
- UINT32 PosHigh;
- CHAR16 *FileName;
- UINTN Size;
+ EFI_STATUS Status;
+ WIN_NT_EFI_FILE_PRIVATE *PrivateFile;
+ UINT32 PosLow;
+ UINT32 PosHigh;
+ CHAR16 *FileName;
+ UINTN Size;
PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
@@ -1340,8 +1330,8 @@ WinNtFileSetPossition (
goto Done;
}
- Size = StrSize (PrivateFile->FileName);
- Size += StrSize (L"\\*");
+ Size = StrSize (PrivateFile->FileName);
+ Size += StrSize (L"\\*");
FileName = AllocatePool (Size);
if (FileName == NULL) {
Status = EFI_OUT_OF_RESOURCES;
@@ -1382,8 +1372,6 @@ Done:
return Status;
}
-
-
/**
Get a file's current position
@@ -1396,41 +1384,38 @@ Done:
**/
EFI_STATUS
WinNtFileGetPossition (
- IN EFI_FILE_PROTOCOL *This,
- OUT UINT64 *Position
+ IN EFI_FILE_PROTOCOL *This,
+ OUT UINT64 *Position
)
{
- EFI_STATUS Status;
- WIN_NT_EFI_FILE_PRIVATE *PrivateFile;
- INT32 PositionHigh;
- UINT64 PosHigh64;
+ EFI_STATUS Status;
+ WIN_NT_EFI_FILE_PRIVATE *PrivateFile;
+ INT32 PositionHigh;
+ UINT64 PosHigh64;
PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
PositionHigh = 0;
- PosHigh64 = 0;
+ PosHigh64 = 0;
if (PrivateFile->IsDirectoryPath) {
-
Status = EFI_UNSUPPORTED;
goto Done;
-
} else {
-
PositionHigh = 0;
- *Position = SetFilePointer (
- PrivateFile->LHandle,
- 0,
- (PLONG)&PositionHigh,
- FILE_CURRENT
- );
+ *Position = SetFilePointer (
+ PrivateFile->LHandle,
+ 0,
+ (PLONG)&PositionHigh,
+ FILE_CURRENT
+ );
Status = *Position == 0xffffffff ? EFI_DEVICE_ERROR : EFI_SUCCESS;
if (EFI_ERROR (Status)) {
goto Done;
}
- PosHigh64 = PositionHigh;
+ PosHigh64 = PositionHigh;
*Position += LShiftU64 (PosHigh64, 32);
}
@@ -1438,13 +1423,13 @@ Done:
return Status;
}
-
EFI_STATUS
WinNtSimpleFileSystemFileInfo (
IN WIN_NT_EFI_FILE_PRIVATE *PrivateFile,
IN OUT UINTN *BufferSize,
OUT VOID *Buffer
-)
+ )
+
/*++
Routine Description:
@@ -1476,7 +1461,7 @@ Returns:
Size = SIZE_OF_EFI_FILE_INFO;
RealFileName = PrivateFile->FileName;
- TempPointer = RealFileName;
+ TempPointer = RealFileName;
while (*TempPointer) {
if (*TempPointer == '\\') {
RealFileName = TempPointer + 1;
@@ -1484,6 +1469,7 @@ Returns:
TempPointer++;
}
+
NameSize = StrSize (RealFileName);
ResultSize = Size + NameSize;
@@ -1499,8 +1485,8 @@ Returns:
GetFileInformationByHandle (
PrivateFile->IsDirectoryPath ? PrivateFile->DirHandle : PrivateFile->LHandle,
&FileInfo
- );
- Info->FileSize = FileInfo.nFileSizeLow;
+ );
+ Info->FileSize = FileInfo.nFileSizeLow;
Info->PhysicalSize = Info->FileSize;
GetTimeZoneInformation (&TimeZone);
@@ -1563,27 +1549,27 @@ Returns:
**/
EFI_STATUS
WinNtFileGetInfo (
- IN EFI_FILE_PROTOCOL *This,
- IN EFI_GUID *InformationType,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN EFI_GUID *InformationType,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
)
{
- EFI_STATUS Status;
- WIN_NT_EFI_FILE_PRIVATE *PrivateFile;
- EFI_FILE_SYSTEM_INFO *FileSystemInfoBuffer;
- UINT32 SectorsPerCluster;
- UINT32 BytesPerSector;
- UINT32 FreeClusters;
- UINT32 TotalClusters;
- UINT32 BytesPerCluster;
- CHAR16 *DriveName;
- BOOLEAN DriveNameFound;
- BOOL NtStatus;
- UINTN Index;
- WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE *PrivateRoot;
-
- if (This == NULL || InformationType == NULL || BufferSize == NULL) {
+ EFI_STATUS Status;
+ WIN_NT_EFI_FILE_PRIVATE *PrivateFile;
+ EFI_FILE_SYSTEM_INFO *FileSystemInfoBuffer;
+ UINT32 SectorsPerCluster;
+ UINT32 BytesPerSector;
+ UINT32 FreeClusters;
+ UINT32 TotalClusters;
+ UINT32 BytesPerCluster;
+ CHAR16 *DriveName;
+ BOOLEAN DriveNameFound;
+ BOOL NtStatus;
+ UINTN Index;
+ WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE *PrivateRoot;
+
+ if ((This == NULL) || (InformationType == NULL) || (BufferSize == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -1599,19 +1585,19 @@ WinNtFileGetInfo (
if (CompareGuid (InformationType, &gEfiFileSystemInfoGuid)) {
if (*BufferSize < SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel)) {
*BufferSize = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel);
- Status = EFI_BUFFER_TOO_SMALL;
+ Status = EFI_BUFFER_TOO_SMALL;
goto Done;
}
- FileSystemInfoBuffer = (EFI_FILE_SYSTEM_INFO *)Buffer;
- FileSystemInfoBuffer->Size = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel);
+ FileSystemInfoBuffer = (EFI_FILE_SYSTEM_INFO *)Buffer;
+ FileSystemInfoBuffer->Size = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel);
FileSystemInfoBuffer->ReadOnly = FALSE;
//
// Try to get the drive name
//
DriveNameFound = FALSE;
- DriveName = AllocatePool (StrSize (PrivateFile->FilePath) + 1);
+ DriveName = AllocatePool (StrSize (PrivateFile->FilePath) + 1);
if (DriveName == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Done;
@@ -1623,25 +1609,22 @@ WinNtFileGetInfo (
PrivateFile->FilePath
);
for (Index = 0; DriveName[Index] != 0 && DriveName[Index] != ':'; Index++) {
- ;
}
if (DriveName[Index] == ':') {
DriveName[Index + 1] = '\\';
DriveName[Index + 2] = 0;
- DriveNameFound = TRUE;
- } else if (DriveName[0] == '\\' && DriveName[1] == '\\') {
+ DriveNameFound = TRUE;
+ } else if ((DriveName[0] == '\\') && (DriveName[1] == '\\')) {
for (Index = 2; DriveName[Index] != 0 && DriveName[Index] != '\\'; Index++) {
- ;
}
if (DriveName[Index] == '\\') {
DriveNameFound = TRUE;
for (Index++; DriveName[Index] != 0 && DriveName[Index] != '\\'; Index++) {
- ;
}
- DriveName[Index] = '\\';
+ DriveName[Index] = '\\';
DriveName[Index + 1] = 0;
}
}
@@ -1650,12 +1633,12 @@ WinNtFileGetInfo (
// Try GetDiskFreeSpace first
//
NtStatus = GetDiskFreeSpace (
- DriveNameFound ? DriveName : NULL,
- (LPDWORD)&SectorsPerCluster,
- (LPDWORD)&BytesPerSector,
- (LPDWORD)&FreeClusters,
- (LPDWORD)&TotalClusters
- );
+ DriveNameFound ? DriveName : NULL,
+ (LPDWORD)&SectorsPerCluster,
+ (LPDWORD)&BytesPerSector,
+ (LPDWORD)&FreeClusters,
+ (LPDWORD)&TotalClusters
+ );
if (DriveName) {
FreePool (DriveName);
}
@@ -1664,22 +1647,21 @@ WinNtFileGetInfo (
//
// Succeeded
//
- BytesPerCluster = BytesPerSector * SectorsPerCluster;
+ BytesPerCluster = BytesPerSector * SectorsPerCluster;
FileSystemInfoBuffer->VolumeSize = MultU64x32 (TotalClusters, BytesPerCluster);
- FileSystemInfoBuffer->FreeSpace = MultU64x32 (FreeClusters, BytesPerCluster);
- FileSystemInfoBuffer->BlockSize = BytesPerCluster;
-
+ FileSystemInfoBuffer->FreeSpace = MultU64x32 (FreeClusters, BytesPerCluster);
+ FileSystemInfoBuffer->BlockSize = BytesPerCluster;
} else {
//
// try GetDiskFreeSpaceEx then
//
FileSystemInfoBuffer->BlockSize = 0;
- NtStatus = GetDiskFreeSpaceEx (
- PrivateFile->FilePath,
- (PULARGE_INTEGER)(&FileSystemInfoBuffer->FreeSpace),
- (PULARGE_INTEGER)(&FileSystemInfoBuffer->VolumeSize),
- NULL
- );
+ NtStatus = GetDiskFreeSpaceEx (
+ PrivateFile->FilePath,
+ (PULARGE_INTEGER)(&FileSystemInfoBuffer->FreeSpace),
+ (PULARGE_INTEGER)(&FileSystemInfoBuffer->VolumeSize),
+ NULL
+ );
if (!NtStatus) {
Status = EFI_DEVICE_ERROR;
goto Done;
@@ -1692,13 +1674,13 @@ WinNtFileGetInfo (
PrivateRoot->VolumeLabel
);
*BufferSize = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel);
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
}
if (CompareGuid (InformationType, &gEfiFileSystemVolumeLabelInfoIdGuid)) {
if (*BufferSize < StrSize (PrivateRoot->VolumeLabel)) {
*BufferSize = StrSize (PrivateRoot->VolumeLabel);
- Status = EFI_BUFFER_TOO_SMALL;
+ Status = EFI_BUFFER_TOO_SMALL;
goto Done;
}
@@ -1708,14 +1690,13 @@ WinNtFileGetInfo (
PrivateRoot->VolumeLabel
);
*BufferSize = StrSize (PrivateRoot->VolumeLabel);
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
}
Done:
return Status;
}
-
/**
Set information about a file
@@ -1735,39 +1716,39 @@ Done:
**/
EFI_STATUS
WinNtFileSetInfo (
- IN EFI_FILE_PROTOCOL *This,
- IN EFI_GUID *InformationType,
- IN UINTN BufferSize,
- IN VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN EFI_GUID *InformationType,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
)
{
- WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE *PrivateRoot;
- WIN_NT_EFI_FILE_PRIVATE *PrivateFile;
- EFI_FILE_INFO *OldFileInfo;
- EFI_FILE_INFO *NewFileInfo;
- EFI_STATUS Status;
- UINTN OldInfoSize;
- INTN NtStatus;
- UINT32 NewAttr;
- UINT32 OldAttr;
- CHAR16 *OldFileName;
- CHAR16 *NewFileName;
- CHAR16 *TempFileName;
- CHAR16 *CharPointer;
- BOOLEAN AttrChangeFlag;
- BOOLEAN NameChangeFlag;
- BOOLEAN SizeChangeFlag;
- BOOLEAN TimeChangeFlag;
- UINT64 CurPos;
- SYSTEMTIME NewCreationSystemTime;
- SYSTEMTIME NewLastAccessSystemTime;
- SYSTEMTIME NewLastWriteSystemTime;
- FILETIME NewCreationFileTime;
- FILETIME NewLastAccessFileTime;
- FILETIME NewLastWriteFileTime;
- WIN32_FIND_DATA FindBuf;
- EFI_FILE_SYSTEM_INFO *NewFileSystemInfo;
- UINTN Size;
+ WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE *PrivateRoot;
+ WIN_NT_EFI_FILE_PRIVATE *PrivateFile;
+ EFI_FILE_INFO *OldFileInfo;
+ EFI_FILE_INFO *NewFileInfo;
+ EFI_STATUS Status;
+ UINTN OldInfoSize;
+ INTN NtStatus;
+ UINT32 NewAttr;
+ UINT32 OldAttr;
+ CHAR16 *OldFileName;
+ CHAR16 *NewFileName;
+ CHAR16 *TempFileName;
+ CHAR16 *CharPointer;
+ BOOLEAN AttrChangeFlag;
+ BOOLEAN NameChangeFlag;
+ BOOLEAN SizeChangeFlag;
+ BOOLEAN TimeChangeFlag;
+ UINT64 CurPos;
+ SYSTEMTIME NewCreationSystemTime;
+ SYSTEMTIME NewLastAccessSystemTime;
+ SYSTEMTIME NewLastWriteSystemTime;
+ FILETIME NewCreationFileTime;
+ FILETIME NewLastAccessFileTime;
+ FILETIME NewLastWriteFileTime;
+ WIN32_FIND_DATA FindBuf;
+ EFI_FILE_SYSTEM_INFO *NewFileSystemInfo;
+ UINTN Size;
//
// Initialise locals.
@@ -1775,9 +1756,9 @@ WinNtFileSetInfo (
PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
PrivateRoot = WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (PrivateFile->SimpleFileSystem);
- Status = EFI_UNSUPPORTED;
- OldFileInfo = NewFileInfo = NULL;
- OldFileName = NewFileName = NULL;
+ Status = EFI_UNSUPPORTED;
+ OldFileInfo = NewFileInfo = NULL;
+ OldFileName = NewFileName = NULL;
AttrChangeFlag = NameChangeFlag = SizeChangeFlag = TimeChangeFlag = FALSE;
//
@@ -1790,7 +1771,6 @@ WinNtFileSetInfo (
goto Done;
}
-
FreePool (PrivateRoot->VolumeLabel);
PrivateRoot->VolumeLabel = AllocatePool (StrSize (NewFileSystemInfo->VolumeLabel));
if (PrivateRoot->VolumeLabel == NULL) {
@@ -1847,9 +1827,10 @@ WinNtFileSetInfo (
NewFileInfo = (EFI_FILE_INFO *)Buffer;
if ((NewFileInfo->Size <= SIZE_OF_EFI_FILE_INFO) ||
- (NewFileInfo->Attribute &~(EFI_FILE_VALID_ATTR)) ||
- (sizeof (UINTN) == 4 && NewFileInfo->Size > 0xFFFFFFFF)
- ) {
+ (NewFileInfo->Attribute &~(EFI_FILE_VALID_ATTR)) ||
+ ((sizeof (UINTN) == 4) && (NewFileInfo->Size > 0xFFFFFFFF))
+ )
+ {
Status = EFI_INVALID_PARAMETER;
goto Done;
}
@@ -1865,7 +1846,7 @@ WinNtFileSetInfo (
// of change request this is.
//
OldInfoSize = 0;
- Status = WinNtSimpleFileSystemFileInfo (PrivateFile, &OldInfoSize, NULL);
+ Status = WinNtSimpleFileSystemFileInfo (PrivateFile, &OldInfoSize, NULL);
if (Status != EFI_BUFFER_TOO_SMALL) {
Status = EFI_DEVICE_ERROR;
@@ -1900,9 +1881,9 @@ WinNtFileSetInfo (
// Make full pathname from new filename and rootpath.
//
if (NewFileInfo->FileName[0] == '\\') {
- Size = StrSize (PrivateRoot->FilePath);
- Size += StrSize (L"\\");
- Size += StrSize (NewFileInfo->FileName);
+ Size = StrSize (PrivateRoot->FilePath);
+ Size += StrSize (L"\\");
+ Size += StrSize (NewFileInfo->FileName);
NewFileName = AllocatePool (Size);
if (NewFileName == NULL) {
Status = EFI_OUT_OF_RESOURCES;
@@ -1913,9 +1894,9 @@ WinNtFileSetInfo (
StrCatS (NewFileName, Size / sizeof (CHAR16), L"\\");
StrCatS (NewFileName, Size / sizeof (CHAR16), NewFileInfo->FileName + 1);
} else {
- Size = StrSize (PrivateFile->FilePath);
- Size += StrSize (L"\\");
- Size += StrSize (NewFileInfo->FileName);
+ Size = StrSize (PrivateFile->FilePath);
+ Size += StrSize (L"\\");
+ Size += StrSize (NewFileInfo->FileName);
NewFileName = AllocatePool (Size);
if (NewFileName == NULL) {
Status = EFI_OUT_OF_RESOURCES;
@@ -1958,16 +1939,19 @@ WinNtFileSetInfo (
// Is there a time stamp change request?
//
if (!IsZero (&NewFileInfo->CreateTime, sizeof (EFI_TIME)) &&
- CompareMem (&NewFileInfo->CreateTime, &OldFileInfo->CreateTime, sizeof (EFI_TIME))
- ) {
+ CompareMem (&NewFileInfo->CreateTime, &OldFileInfo->CreateTime, sizeof (EFI_TIME))
+ )
+ {
TimeChangeFlag = TRUE;
} else if (!IsZero (&NewFileInfo->LastAccessTime, sizeof (EFI_TIME)) &&
- CompareMem (&NewFileInfo->LastAccessTime, &OldFileInfo->LastAccessTime, sizeof (EFI_TIME))
- ) {
+ CompareMem (&NewFileInfo->LastAccessTime, &OldFileInfo->LastAccessTime, sizeof (EFI_TIME))
+ )
+ {
TimeChangeFlag = TRUE;
} else if (!IsZero (&NewFileInfo->ModificationTime, sizeof (EFI_TIME)) &&
- CompareMem (&NewFileInfo->ModificationTime, &OldFileInfo->ModificationTime, sizeof (EFI_TIME))
- ) {
+ CompareMem (&NewFileInfo->ModificationTime, &OldFileInfo->ModificationTime, sizeof (EFI_TIME))
+ )
+ {
TimeChangeFlag = TRUE;
}
@@ -2013,7 +1997,7 @@ WinNtFileSetInfo (
}
}
- if (PrivateFile->IsDirectoryPath && PrivateFile->DirHandle != INVALID_HANDLE_VALUE) {
+ if (PrivateFile->IsDirectoryPath && (PrivateFile->DirHandle != INVALID_HANDLE_VALUE)) {
CloseHandle (PrivateFile->DirHandle);
PrivateFile->DirHandle = INVALID_HANDLE_VALUE;
}
@@ -2034,22 +2018,22 @@ WinNtFileSetInfo (
StrCpyS (PrivateFile->FileName, StrSize (NewFileName) / sizeof (CHAR16), NewFileName);
- Size = StrSize (NewFileName);
- Size += StrSize (L"\\*");
+ Size = StrSize (NewFileName);
+ Size += StrSize (L"\\*");
TempFileName = AllocatePool (Size);
StrCpyS (TempFileName, Size / sizeof (CHAR16), NewFileName);
if (!PrivateFile->IsDirectoryPath) {
PrivateFile->LHandle = CreateFile (
- TempFileName,
- PrivateFile->IsOpenedByRead ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL,
- OPEN_EXISTING,
- 0,
- NULL
- );
+ TempFileName,
+ PrivateFile->IsOpenedByRead ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ OPEN_EXISTING,
+ 0,
+ NULL
+ );
FreePool (TempFileName);
@@ -2062,14 +2046,14 @@ WinNtFileSetInfo (
}
} else {
PrivateFile->DirHandle = CreateFile (
- TempFileName,
- PrivateFile->IsOpenedByRead ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL,
- OPEN_EXISTING,
- FILE_FLAG_BACKUP_SEMANTICS,
- NULL
- );
+ TempFileName,
+ PrivateFile->IsOpenedByRead ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ OPEN_EXISTING,
+ FILE_FLAG_BACKUP_SEMANTICS,
+ NULL
+ );
StrCatS (TempFileName, Size / sizeof (CHAR16), L"\\*");
PrivateFile->LHandle = FindFirstFile (TempFileName, &FindBuf);
@@ -2078,7 +2062,7 @@ WinNtFileSetInfo (
}
} else {
Status = EFI_ACCESS_DENIED;
- Reopen:;
+Reopen:;
NtStatus = SetFileAttributes (OldFileName, OldAttr);
@@ -2086,32 +2070,32 @@ WinNtFileSetInfo (
goto Done;
}
- Size = StrSize (OldFileName);
- Size += StrSize (L"\\*");
+ Size = StrSize (OldFileName);
+ Size += StrSize (L"\\*");
TempFileName = AllocatePool (Size);
StrCpyS (TempFileName, Size / sizeof (CHAR16), OldFileName);
if (!PrivateFile->IsDirectoryPath) {
PrivateFile->LHandle = CreateFile (
- TempFileName,
- PrivateFile->IsOpenedByRead ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL,
- OPEN_EXISTING,
- 0,
- NULL
- );
+ TempFileName,
+ PrivateFile->IsOpenedByRead ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ OPEN_EXISTING,
+ 0,
+ NULL
+ );
} else {
PrivateFile->DirHandle = CreateFile (
- TempFileName,
- PrivateFile->IsOpenedByRead ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL,
- OPEN_EXISTING,
- FILE_FLAG_BACKUP_SEMANTICS,
- NULL
- );
+ TempFileName,
+ PrivateFile->IsOpenedByRead ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ OPEN_EXISTING,
+ FILE_FLAG_BACKUP_SEMANTICS,
+ NULL
+ );
StrCatS (TempFileName, Size / sizeof (CHAR16), L"\\*");
PrivateFile->LHandle = FindFirstFile (TempFileName, &FindBuf);
@@ -2120,7 +2104,6 @@ WinNtFileSetInfo (
FreePool (TempFileName);
goto Done;
-
}
}
@@ -2163,83 +2146,88 @@ WinNtFileSetInfo (
// Time change
//
if (TimeChangeFlag) {
-
- NewCreationSystemTime.wYear = NewFileInfo->CreateTime.Year;
- NewCreationSystemTime.wMonth = NewFileInfo->CreateTime.Month;
- NewCreationSystemTime.wDay = NewFileInfo->CreateTime.Day;
- NewCreationSystemTime.wHour = NewFileInfo->CreateTime.Hour;
- NewCreationSystemTime.wMinute = NewFileInfo->CreateTime.Minute;
- NewCreationSystemTime.wSecond = NewFileInfo->CreateTime.Second;
+ NewCreationSystemTime.wYear = NewFileInfo->CreateTime.Year;
+ NewCreationSystemTime.wMonth = NewFileInfo->CreateTime.Month;
+ NewCreationSystemTime.wDay = NewFileInfo->CreateTime.Day;
+ NewCreationSystemTime.wHour = NewFileInfo->CreateTime.Hour;
+ NewCreationSystemTime.wMinute = NewFileInfo->CreateTime.Minute;
+ NewCreationSystemTime.wSecond = NewFileInfo->CreateTime.Second;
NewCreationSystemTime.wMilliseconds = 0;
if (!SystemTimeToFileTime (
- &NewCreationSystemTime,
- &NewCreationFileTime
- )) {
+ &NewCreationSystemTime,
+ &NewCreationFileTime
+ ))
+ {
goto Done;
}
if (!LocalFileTimeToFileTime (
- &NewCreationFileTime,
- &NewCreationFileTime
- )) {
+ &NewCreationFileTime,
+ &NewCreationFileTime
+ ))
+ {
goto Done;
}
- NewLastAccessSystemTime.wYear = NewFileInfo->LastAccessTime.Year;
- NewLastAccessSystemTime.wMonth = NewFileInfo->LastAccessTime.Month;
- NewLastAccessSystemTime.wDay = NewFileInfo->LastAccessTime.Day;
- NewLastAccessSystemTime.wHour = NewFileInfo->LastAccessTime.Hour;
- NewLastAccessSystemTime.wMinute = NewFileInfo->LastAccessTime.Minute;
- NewLastAccessSystemTime.wSecond = NewFileInfo->LastAccessTime.Second;
+ NewLastAccessSystemTime.wYear = NewFileInfo->LastAccessTime.Year;
+ NewLastAccessSystemTime.wMonth = NewFileInfo->LastAccessTime.Month;
+ NewLastAccessSystemTime.wDay = NewFileInfo->LastAccessTime.Day;
+ NewLastAccessSystemTime.wHour = NewFileInfo->LastAccessTime.Hour;
+ NewLastAccessSystemTime.wMinute = NewFileInfo->LastAccessTime.Minute;
+ NewLastAccessSystemTime.wSecond = NewFileInfo->LastAccessTime.Second;
NewLastAccessSystemTime.wMilliseconds = 0;
if (!SystemTimeToFileTime (
- &NewLastAccessSystemTime,
- &NewLastAccessFileTime
- )) {
+ &NewLastAccessSystemTime,
+ &NewLastAccessFileTime
+ ))
+ {
goto Done;
}
if (!LocalFileTimeToFileTime (
- &NewLastAccessFileTime,
- &NewLastAccessFileTime
- )) {
+ &NewLastAccessFileTime,
+ &NewLastAccessFileTime
+ ))
+ {
goto Done;
}
- NewLastWriteSystemTime.wYear = NewFileInfo->ModificationTime.Year;
- NewLastWriteSystemTime.wMonth = NewFileInfo->ModificationTime.Month;
- NewLastWriteSystemTime.wDay = NewFileInfo->ModificationTime.Day;
- NewLastWriteSystemTime.wHour = NewFileInfo->ModificationTime.Hour;
- NewLastWriteSystemTime.wMinute = NewFileInfo->ModificationTime.Minute;
- NewLastWriteSystemTime.wSecond = NewFileInfo->ModificationTime.Second;
+ NewLastWriteSystemTime.wYear = NewFileInfo->ModificationTime.Year;
+ NewLastWriteSystemTime.wMonth = NewFileInfo->ModificationTime.Month;
+ NewLastWriteSystemTime.wDay = NewFileInfo->ModificationTime.Day;
+ NewLastWriteSystemTime.wHour = NewFileInfo->ModificationTime.Hour;
+ NewLastWriteSystemTime.wMinute = NewFileInfo->ModificationTime.Minute;
+ NewLastWriteSystemTime.wSecond = NewFileInfo->ModificationTime.Second;
NewLastWriteSystemTime.wMilliseconds = 0;
if (!SystemTimeToFileTime (
- &NewLastWriteSystemTime,
- &NewLastWriteFileTime
- )) {
+ &NewLastWriteSystemTime,
+ &NewLastWriteFileTime
+ ))
+ {
goto Done;
}
if (!LocalFileTimeToFileTime (
- &NewLastWriteFileTime,
- &NewLastWriteFileTime
- )) {
+ &NewLastWriteFileTime,
+ &NewLastWriteFileTime
+ ))
+ {
goto Done;
}
if (!SetFileTime (
- PrivateFile->IsDirectoryPath ? PrivateFile->DirHandle : PrivateFile->LHandle,
- &NewCreationFileTime,
- &NewLastAccessFileTime,
- &NewLastWriteFileTime
- )) {
+ PrivateFile->IsDirectoryPath ? PrivateFile->DirHandle : PrivateFile->LHandle,
+ &NewCreationFileTime,
+ &NewLastAccessFileTime,
+ &NewLastWriteFileTime
+ ))
+ {
Status = EFI_DEVICE_ERROR;
goto Done;
}
-
}
//
@@ -2295,7 +2283,6 @@ Done:
return Status;
}
-
/**
Flush data back for the file handle.
@@ -2351,14 +2338,11 @@ Done:
//
// bugbug: - Use Windows error reporting.
//
-
}
-
-
EFI_STATUS
WinNtFileSystmeThunkOpen (
- IN EMU_IO_THUNK_PROTOCOL *This
+ IN EMU_IO_THUNK_PROTOCOL *This
)
{
WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE *Private;
@@ -2390,10 +2374,9 @@ WinNtFileSystmeThunkOpen (
return EFI_SUCCESS;
}
-
EFI_STATUS
WinNtFileSystmeThunkClose (
- IN EMU_IO_THUNK_PROTOCOL *This
+ IN EMU_IO_THUNK_PROTOCOL *This
)
{
WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE *Private;
@@ -2404,15 +2387,16 @@ WinNtFileSystmeThunkClose (
if (Private->VolumeLabel != NULL) {
FreePool (Private->VolumeLabel);
}
+
if (Private->FilePath != NULL) {
FreePool (Private->FilePath);
}
+
FreePool (Private);
return EFI_SUCCESS;
}
-
-EFI_FILE_PROTOCOL gWinNtFileProtocol = {
+EFI_FILE_PROTOCOL gWinNtFileProtocol = {
EFI_FILE_REVISION,
WinNtFileOpen,
WinNtFileClose,
@@ -2426,13 +2410,12 @@ EFI_FILE_PROTOCOL gWinNtFileProtocol = {
WinNtFileFlush
};
-EFI_SIMPLE_FILE_SYSTEM_PROTOCOL gWinNtFileSystemProtocol = {
+EFI_SIMPLE_FILE_SYSTEM_PROTOCOL gWinNtFileSystemProtocol = {
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION,
WinNtOpenVolume
};
-
-EMU_IO_THUNK_PROTOCOL mWinNtFileSystemThunkIo = {
+EMU_IO_THUNK_PROTOCOL mWinNtFileSystemThunkIo = {
&gEfiSimpleFileSystemProtocolGuid,
NULL,
NULL,
@@ -2441,5 +2424,3 @@ EMU_IO_THUNK_PROTOCOL mWinNtFileSystemThunkIo = {
WinNtFileSystmeThunkClose,
NULL
};
-
-
diff --git a/EmulatorPkg/Win/Host/WinGop.h b/EmulatorPkg/Win/Host/WinGop.h
index 7a8f01a37c..2799778ca9 100644
--- a/EmulatorPkg/Win/Host/WinGop.h
+++ b/EmulatorPkg/Win/Host/WinGop.h
@@ -17,7 +17,6 @@ Abstract:
#ifndef _WIN_GOP_H_
#define _WIN_GOP_H_
-
#include "WinHost.h"
#include <Protocol/EmuIoThunk.h>
@@ -39,87 +38,85 @@ Abstract:
// The value is 1 if the ALT key is down while the key is pressed/released;
// it is 0 if the WM_SYSKEYDOWN message is posted to the active window
// because no window has the keyboard focus.
-#define GOP_EXTENDED_KEY (0x1 << 24)
-#define GOP_ALT_KEY_PRESSED (0x1 << 29)
+#define GOP_EXTENDED_KEY (0x1 << 24)
+#define GOP_ALT_KEY_PRESSED (0x1 << 29)
-#define KEYBOARD_TIMER_INTERVAL 200000 // 0.02s
+#define KEYBOARD_TIMER_INTERVAL 200000 // 0.02s
-#define MAX_Q 256
+#define MAX_Q 256
typedef struct {
- UINTN Front;
- UINTN Rear;
- EFI_KEY_DATA Q[MAX_Q];
- CRITICAL_SECTION Cs;
+ UINTN Front;
+ UINTN Rear;
+ EFI_KEY_DATA Q[MAX_Q];
+ CRITICAL_SECTION Cs;
} GOP_QUEUE_FIXED;
-#define WIN_NT_GOP_CLASS_NAME L"WinNtGopWindow"
-
+#define WIN_NT_GOP_CLASS_NAME L"WinNtGopWindow"
typedef struct {
- UINT64 Signature;
- EMU_GRAPHICS_WINDOW_PROTOCOL GraphicsWindowIo;
+ UINT64 Signature;
+ EMU_GRAPHICS_WINDOW_PROTOCOL GraphicsWindowIo;
//
// GOP Private Data knowing when to start hardware
//
- BOOLEAN HardwareNeedsStarting;
+ BOOLEAN HardwareNeedsStarting;
- CHAR16 *WindowName;
- CHAR16 Buffer[160];
+ CHAR16 *WindowName;
+ CHAR16 Buffer[160];
- HANDLE ThreadInited; // Semaphore
- HANDLE ThreadHandle; // Thread
- DWORD ThreadId;
+ HANDLE ThreadInited; // Semaphore
+ HANDLE ThreadHandle; // Thread
+ DWORD ThreadId;
- HWND WindowHandle;
- WNDCLASSEX WindowsClass;
+ HWND WindowHandle;
+ WNDCLASSEX WindowsClass;
- UINT32 Width;
- UINT32 Height;
+ UINT32 Width;
+ UINT32 Height;
//
// This screen is used to redraw the screen when windows events happen. It's
// updated in the main thread and displayed in the windows thread.
//
- BITMAPV4HEADER *VirtualScreenInfo;
+ BITMAPV4HEADER *VirtualScreenInfo;
- FRAME_BUFFER_CONFIGURE *FrameBufferConfigure;
+ FRAME_BUFFER_CONFIGURE *FrameBufferConfigure;
//
// Keyboard Queue used by Simple Text In.
// QueueForRead: WinProc thread adds, and main thread removes.
//
- GOP_QUEUE_FIXED QueueForRead;
+ GOP_QUEUE_FIXED QueueForRead;
EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK MakeRegisterdKeyCallback;
EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK BreakRegisterdKeyCallback;
VOID *RegisterdKeyCallbackContext;
- EFI_KEY_STATE KeyState;
- BOOLEAN LeftShift;
- BOOLEAN RightShift;
- BOOLEAN LeftAlt;
- BOOLEAN RightAlt;
- BOOLEAN LeftCtrl;
- BOOLEAN RightCtrl;
- BOOLEAN LeftLogo;
- BOOLEAN RightLogo;
- BOOLEAN Menu;
- BOOLEAN SysReq;
- BOOLEAN NumLock;
- BOOLEAN ScrollLock;
- BOOLEAN CapsLock;
- BOOLEAN IsPartialKeySupport;
- INT32 PointerPreviousX;
- INT32 PointerPreviousY;
- BOOLEAN PointerStateChanged;
- EFI_SIMPLE_POINTER_STATE PointerState;
+ EFI_KEY_STATE KeyState;
+ BOOLEAN LeftShift;
+ BOOLEAN RightShift;
+ BOOLEAN LeftAlt;
+ BOOLEAN RightAlt;
+ BOOLEAN LeftCtrl;
+ BOOLEAN RightCtrl;
+ BOOLEAN LeftLogo;
+ BOOLEAN RightLogo;
+ BOOLEAN Menu;
+ BOOLEAN SysReq;
+ BOOLEAN NumLock;
+ BOOLEAN ScrollLock;
+ BOOLEAN CapsLock;
+ BOOLEAN IsPartialKeySupport;
+ INT32 PointerPreviousX;
+ INT32 PointerPreviousY;
+ BOOLEAN PointerStateChanged;
+ EFI_SIMPLE_POINTER_STATE PointerState;
} GRAPHICS_PRIVATE_DATA;
#define GRAPHICS_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('g', 'f', 'x', 'd')
#define GRAPHICS_PRIVATE_DATA_FROM_THIS(a) \
CR(a, GRAPHICS_PRIVATE_DATA, GraphicsWindowIo, GRAPHICS_PRIVATE_DATA_SIGNATURE)
-
//
// Gop Hardware abstraction internal worker functions
//
@@ -135,8 +132,8 @@ typedef struct {
**/
EFI_STATUS
GopPrivateAddKey (
- IN GRAPHICS_PRIVATE_DATA *Private,
- IN EFI_INPUT_KEY Key
+ IN GRAPHICS_PRIVATE_DATA *Private,
+ IN EFI_INPUT_KEY Key
);
EFI_STATUS
@@ -149,29 +146,29 @@ WinNtWndGetKey (
EFI_STATUS
EFIAPI
WinNtWndCheckKey (
- IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo
+ IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo
);
EFI_STATUS
EFIAPI
WinNtWndKeySetState (
- IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo,
- IN EFI_KEY_TOGGLE_STATE *KeyToggleState
+ IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo,
+ IN EFI_KEY_TOGGLE_STATE *KeyToggleState
);
EFI_STATUS
EFIAPI
WinNtWndRegisterKeyNotify (
- IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo,
- IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK MakeCallBack,
- IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK BreakCallBack,
- IN VOID *Context
+ IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo,
+ IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK MakeCallBack,
+ IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK BreakCallBack,
+ IN VOID *Context
);
EFI_STATUS
EFIAPI
WinNtWndCheckPointer (
- IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo
+ IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo
);
EFI_STATUS
@@ -180,13 +177,13 @@ WinNtWndGetPointerState (
IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo,
IN EFI_SIMPLE_POINTER_STATE *State
);
+
EFI_STATUS
GopPrivateCreateQ (
- IN GRAPHICS_PRIVATE_DATA *Private,
- IN GOP_QUEUE_FIXED *Queue
+ IN GRAPHICS_PRIVATE_DATA *Private,
+ IN GOP_QUEUE_FIXED *Queue
);
-
/**
TODO: Add function description
@@ -197,8 +194,8 @@ GopPrivateCreateQ (
**/
EFI_STATUS
GopPrivateDestroyQ (
- IN GRAPHICS_PRIVATE_DATA *Private,
- IN GOP_QUEUE_FIXED *Queue
+ IN GRAPHICS_PRIVATE_DATA *Private,
+ IN GOP_QUEUE_FIXED *Queue
);
-#endif
+#endif
diff --git a/EmulatorPkg/Win/Host/WinGopInput.c b/EmulatorPkg/Win/Host/WinGopInput.c
index 6ae7aa4c37..1c67a1cb40 100644
--- a/EmulatorPkg/Win/Host/WinGopInput.c
+++ b/EmulatorPkg/Win/Host/WinGopInput.c
@@ -22,10 +22,8 @@ Abstract:
**/
-
#include "WinGop.h"
-
/**
TODO: Add function description
@@ -36,8 +34,8 @@ Abstract:
**/
EFI_STATUS
GopPrivateCreateQ (
- IN GRAPHICS_PRIVATE_DATA *Private,
- IN GOP_QUEUE_FIXED *Queue
+ IN GRAPHICS_PRIVATE_DATA *Private,
+ IN GOP_QUEUE_FIXED *Queue
)
{
InitializeCriticalSection (&Queue->Cs);
@@ -46,7 +44,6 @@ GopPrivateCreateQ (
return EFI_SUCCESS;
}
-
/**
TODO: Add function description
@@ -57,8 +54,8 @@ GopPrivateCreateQ (
**/
EFI_STATUS
GopPrivateDestroyQ (
- IN GRAPHICS_PRIVATE_DATA *Private,
- IN GOP_QUEUE_FIXED *Queue
+ IN GRAPHICS_PRIVATE_DATA *Private,
+ IN GOP_QUEUE_FIXED *Queue
)
{
Queue->Front = 0;
@@ -67,7 +64,6 @@ GopPrivateDestroyQ (
return EFI_SUCCESS;
}
-
/**
TODO: Add function description
@@ -80,9 +76,9 @@ GopPrivateDestroyQ (
**/
EFI_STATUS
GopPrivateAddQ (
- IN GRAPHICS_PRIVATE_DATA *Private,
- IN GOP_QUEUE_FIXED *Queue,
- IN EFI_KEY_DATA *KeyData
+ IN GRAPHICS_PRIVATE_DATA *Private,
+ IN GOP_QUEUE_FIXED *Queue,
+ IN EFI_KEY_DATA *KeyData
)
{
EnterCriticalSection (&Queue->Cs);
@@ -93,13 +89,12 @@ GopPrivateAddQ (
}
CopyMem (&Queue->Q[Queue->Rear], KeyData, sizeof (EFI_KEY_DATA));
- Queue->Rear = (Queue->Rear + 1) % MAX_Q;
+ Queue->Rear = (Queue->Rear + 1) % MAX_Q;
LeaveCriticalSection (&Queue->Cs);
return EFI_SUCCESS;
}
-
/**
TODO: Add function description
@@ -112,9 +107,9 @@ GopPrivateAddQ (
**/
EFI_STATUS
GopPrivateDeleteQ (
- IN GRAPHICS_PRIVATE_DATA *Private,
- IN GOP_QUEUE_FIXED *Queue,
- OUT EFI_KEY_DATA *Key
+ IN GRAPHICS_PRIVATE_DATA *Private,
+ IN GOP_QUEUE_FIXED *Queue,
+ OUT EFI_KEY_DATA *Key
)
{
EnterCriticalSection (&Queue->Cs);
@@ -125,9 +120,9 @@ GopPrivateDeleteQ (
}
CopyMem (Key, &Queue->Q[Queue->Front], sizeof (EFI_KEY_DATA));
- Queue->Front = (Queue->Front + 1) % MAX_Q;
+ Queue->Front = (Queue->Front + 1) % MAX_Q;
- if (Key->Key.ScanCode == SCAN_NULL && Key->Key.UnicodeChar == CHAR_NULL) {
+ if ((Key->Key.ScanCode == SCAN_NULL) && (Key->Key.UnicodeChar == CHAR_NULL)) {
if (!Private->IsPartialKeySupport) {
//
// If partial keystrok is not enabled, don't return the partial keystroke.
@@ -137,11 +132,11 @@ GopPrivateDeleteQ (
return EFI_NOT_READY;
}
}
+
LeaveCriticalSection (&Queue->Cs);
return EFI_SUCCESS;
}
-
/**
TODO: Add function description
@@ -153,7 +148,7 @@ GopPrivateDeleteQ (
**/
EFI_STATUS
GopPrivateCheckQ (
- IN GOP_QUEUE_FIXED *Queue
+ IN GOP_QUEUE_FIXED *Queue
)
{
if (Queue->Front == Queue->Rear) {
@@ -171,8 +166,8 @@ GopPrivateCheckQ (
**/
VOID
InitializeKeyState (
- IN GRAPHICS_PRIVATE_DATA *Private,
- IN EFI_KEY_STATE *KeyState
+ IN GRAPHICS_PRIVATE_DATA *Private,
+ IN EFI_KEY_STATE *KeyState
)
{
KeyState->KeyShiftState = EFI_SHIFT_STATE_VALID;
@@ -182,44 +177,57 @@ InitializeKeyState (
// Record Key shift state and toggle state
//
if (Private->LeftCtrl) {
- KeyState->KeyShiftState |= EFI_LEFT_CONTROL_PRESSED;
+ KeyState->KeyShiftState |= EFI_LEFT_CONTROL_PRESSED;
}
+
if (Private->RightCtrl) {
- KeyState->KeyShiftState |= EFI_RIGHT_CONTROL_PRESSED;
+ KeyState->KeyShiftState |= EFI_RIGHT_CONTROL_PRESSED;
}
+
if (Private->LeftAlt) {
- KeyState->KeyShiftState |= EFI_LEFT_ALT_PRESSED;
+ KeyState->KeyShiftState |= EFI_LEFT_ALT_PRESSED;
}
+
if (Private->RightAlt) {
- KeyState->KeyShiftState |= EFI_RIGHT_ALT_PRESSED;
+ KeyState->KeyShiftState |= EFI_RIGHT_ALT_PRESSED;
}
+
if (Private->LeftShift) {
- KeyState->KeyShiftState |= EFI_LEFT_SHIFT_PRESSED;
+ KeyState->KeyShiftState |= EFI_LEFT_SHIFT_PRESSED;
}
+
if (Private->RightShift) {
- KeyState->KeyShiftState |= EFI_RIGHT_SHIFT_PRESSED;
+ KeyState->KeyShiftState |= EFI_RIGHT_SHIFT_PRESSED;
}
+
if (Private->LeftLogo) {
- KeyState->KeyShiftState |= EFI_LEFT_LOGO_PRESSED;
+ KeyState->KeyShiftState |= EFI_LEFT_LOGO_PRESSED;
}
+
if (Private->RightLogo) {
- KeyState->KeyShiftState |= EFI_RIGHT_LOGO_PRESSED;
+ KeyState->KeyShiftState |= EFI_RIGHT_LOGO_PRESSED;
}
+
if (Private->Menu) {
- KeyState->KeyShiftState |= EFI_MENU_KEY_PRESSED;
+ KeyState->KeyShiftState |= EFI_MENU_KEY_PRESSED;
}
+
if (Private->SysReq) {
- KeyState->KeyShiftState |= EFI_SYS_REQ_PRESSED;
+ KeyState->KeyShiftState |= EFI_SYS_REQ_PRESSED;
}
+
if (Private->CapsLock) {
KeyState->KeyToggleState |= EFI_CAPS_LOCK_ACTIVE;
}
+
if (Private->NumLock) {
KeyState->KeyToggleState |= EFI_NUM_LOCK_ACTIVE;
}
+
if (Private->ScrollLock) {
KeyState->KeyToggleState |= EFI_SCROLL_LOCK_ACTIVE;
}
+
if (Private->IsPartialKeySupport) {
KeyState->KeyToggleState |= EFI_KEY_STATE_EXPOSED;
}
@@ -241,7 +249,7 @@ GopPrivateAddKey (
IN EFI_INPUT_KEY Key
)
{
- EFI_KEY_DATA KeyData;
+ EFI_KEY_DATA KeyData;
KeyData.Key = Key;
InitializeKeyState (Private, &KeyData.KeyState);
@@ -251,7 +259,8 @@ GopPrivateAddKey (
//
if ((Private->LeftCtrl || Private->RightCtrl) &&
(KeyData.Key.UnicodeChar >= 1) && (KeyData.Key.UnicodeChar <= 26)
- ) {
+ )
+ {
if ((Private->LeftShift || Private->RightShift) == Private->CapsLock) {
KeyData.Key.UnicodeChar = (CHAR16)(KeyData.Key.UnicodeChar + L'a' - 1);
} else {
@@ -264,7 +273,8 @@ GopPrivateAddKey (
//
if (((KeyData.Key.UnicodeChar >= L'a') && (KeyData.Key.UnicodeChar <= L'z')) ||
((KeyData.Key.UnicodeChar >= L'A') && (KeyData.Key.UnicodeChar <= L'Z'))
- ) {
+ )
+ {
KeyData.KeyState.KeyShiftState &= ~(EFI_LEFT_SHIFT_PRESSED | EFI_RIGHT_SHIFT_PRESSED);
}
@@ -276,26 +286,26 @@ GopPrivateAddKey (
return EFI_SUCCESS;
}
-
EFI_STATUS
EFIAPI
WinNtWndCheckKey (
- IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo
+ IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo
)
{
- GRAPHICS_PRIVATE_DATA *Private;
+ GRAPHICS_PRIVATE_DATA *Private;
Private = GRAPHICS_PRIVATE_DATA_FROM_THIS (GraphicsIo);
return GopPrivateCheckQ (&Private->QueueForRead);
-
}
+
EFI_STATUS
EFIAPI
WinNtWndGetKey (
IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo,
IN EFI_KEY_DATA *KeyData
)
+
/*++
Routine Description:
@@ -316,15 +326,15 @@ WinNtWndGetKey (
--*/
{
- EFI_STATUS Status;
- GRAPHICS_PRIVATE_DATA *Private;
+ EFI_STATUS Status;
+ GRAPHICS_PRIVATE_DATA *Private;
Private = GRAPHICS_PRIVATE_DATA_FROM_THIS (GraphicsIo);
ZeroMem (&KeyData->Key, sizeof (KeyData->Key));
InitializeKeyState (Private, &KeyData->KeyState);
- Status = GopPrivateCheckQ (&Private->QueueForRead);
+ Status = GopPrivateCheckQ (&Private->QueueForRead);
if (!EFI_ERROR (Status)) {
//
// If a Key press exists try and read it.
@@ -336,7 +346,7 @@ WinNtWndGetKey (
// EFI_NOT_READY.
//
if (!Private->IsPartialKeySupport) {
- if (KeyData->Key.ScanCode == SCAN_NULL && KeyData->Key.UnicodeChar == CHAR_NULL) {
+ if ((KeyData->Key.ScanCode == SCAN_NULL) && (KeyData->Key.UnicodeChar == CHAR_NULL)) {
Status = EFI_NOT_READY;
}
}
@@ -344,51 +354,53 @@ WinNtWndGetKey (
}
return Status;
-
}
EFI_STATUS
EFIAPI
WinNtWndKeySetState (
- IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo,
- IN EFI_KEY_TOGGLE_STATE *KeyToggleState
+ IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo,
+ IN EFI_KEY_TOGGLE_STATE *KeyToggleState
)
{
- GRAPHICS_PRIVATE_DATA *Private;
+ GRAPHICS_PRIVATE_DATA *Private;
- Private = GRAPHICS_PRIVATE_DATA_FROM_THIS (GraphicsIo);
- Private->ScrollLock = FALSE;
- Private->NumLock = FALSE;
- Private->CapsLock = FALSE;
+ Private = GRAPHICS_PRIVATE_DATA_FROM_THIS (GraphicsIo);
+ Private->ScrollLock = FALSE;
+ Private->NumLock = FALSE;
+ Private->CapsLock = FALSE;
Private->IsPartialKeySupport = FALSE;
if ((*KeyToggleState & EFI_SCROLL_LOCK_ACTIVE) == EFI_SCROLL_LOCK_ACTIVE) {
Private->ScrollLock = TRUE;
}
+
if ((*KeyToggleState & EFI_NUM_LOCK_ACTIVE) == EFI_NUM_LOCK_ACTIVE) {
Private->NumLock = TRUE;
}
+
if ((*KeyToggleState & EFI_CAPS_LOCK_ACTIVE) == EFI_CAPS_LOCK_ACTIVE) {
Private->CapsLock = TRUE;
}
+
if ((*KeyToggleState & EFI_KEY_STATE_EXPOSED) == EFI_KEY_STATE_EXPOSED) {
Private->IsPartialKeySupport = TRUE;
}
+
Private->KeyState.KeyToggleState = *KeyToggleState;
return EFI_SUCCESS;
}
-
EFI_STATUS
EFIAPI
WinNtWndRegisterKeyNotify (
- IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo,
- IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK MakeCallBack,
- IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK BreakCallBack,
- IN VOID *Context
+ IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo,
+ IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK MakeCallBack,
+ IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK BreakCallBack,
+ IN VOID *Context
)
{
- GRAPHICS_PRIVATE_DATA *Private;
+ GRAPHICS_PRIVATE_DATA *Private;
Private = GRAPHICS_PRIVATE_DATA_FROM_THIS (GraphicsIo);
@@ -402,10 +414,10 @@ WinNtWndRegisterKeyNotify (
EFI_STATUS
EFIAPI
WinNtWndCheckPointer (
- IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo
+ IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo
)
{
- GRAPHICS_PRIVATE_DATA *Private;
+ GRAPHICS_PRIVATE_DATA *Private;
Private = GRAPHICS_PRIVATE_DATA_FROM_THIS (GraphicsIo);
@@ -423,7 +435,7 @@ WinNtWndGetPointerState (
IN EFI_SIMPLE_POINTER_STATE *State
)
{
- GRAPHICS_PRIVATE_DATA *Private;
+ GRAPHICS_PRIVATE_DATA *Private;
Private = GRAPHICS_PRIVATE_DATA_FROM_THIS (GraphicsIo);
diff --git a/EmulatorPkg/Win/Host/WinGopScreen.c b/EmulatorPkg/Win/Host/WinGopScreen.c
index 74011e225e..661573d777 100644
--- a/EmulatorPkg/Win/Host/WinGopScreen.c
+++ b/EmulatorPkg/Win/Host/WinGopScreen.c
@@ -18,8 +18,8 @@ Abstract:
#include "WinGop.h"
-DWORD mTlsIndex = TLS_OUT_OF_INDEXES;
-DWORD mTlsIndexUseCount = 0; // lets us know when we can free mTlsIndex.
+DWORD mTlsIndex = TLS_OUT_OF_INDEXES;
+DWORD mTlsIndexUseCount = 0; // lets us know when we can free mTlsIndex.
BOOLEAN
WinNtGopConvertParamToEfiKeyShiftState (
@@ -30,75 +30,78 @@ WinNtGopConvertParamToEfiKeyShiftState (
)
{
switch (*wParam) {
- //
- // BUGBUG: Only GetAsyncKeyState() and GetKeyState() can distinguish
- // left and right Ctrl, and Shift key.
- // Neither of the two is defined in EFI_WIN_NT_THUNK_PROTOCOL.
- // Therefor, we can not set the correct Shift state here.
- //
- case VK_SHIFT:
- if ((*lParam & GOP_EXTENDED_KEY) == GOP_EXTENDED_KEY) {
+ //
+ // BUGBUG: Only GetAsyncKeyState() and GetKeyState() can distinguish
+ // left and right Ctrl, and Shift key.
+ // Neither of the two is defined in EFI_WIN_NT_THUNK_PROTOCOL.
+ // Therefor, we can not set the correct Shift state here.
+ //
+ case VK_SHIFT:
+ if ((*lParam & GOP_EXTENDED_KEY) == GOP_EXTENDED_KEY) {
Private->RightShift = Flag;
} else {
Private->LeftShift = Flag;
}
- return TRUE;
- case VK_LSHIFT:
- Private->LeftShift = Flag;
- return TRUE;
+ return TRUE;
- case VK_RSHIFT:
- Private->RightShift = Flag;
- return TRUE;
+ case VK_LSHIFT:
+ Private->LeftShift = Flag;
+ return TRUE;
- case VK_CONTROL:
- if ((*lParam & GOP_EXTENDED_KEY) == GOP_EXTENDED_KEY) {
- Private->RightCtrl= Flag;
+ case VK_RSHIFT:
+ Private->RightShift = Flag;
+ return TRUE;
+
+ case VK_CONTROL:
+ if ((*lParam & GOP_EXTENDED_KEY) == GOP_EXTENDED_KEY) {
+ Private->RightCtrl = Flag;
} else {
Private->LeftCtrl = Flag;
}
- return TRUE;
- case VK_LCONTROL:
- Private->LeftCtrl = Flag;
- return TRUE;
+ return TRUE;
- case VK_RCONTROL:
- Private->RightCtrl = Flag;
- return TRUE;
+ case VK_LCONTROL:
+ Private->LeftCtrl = Flag;
+ return TRUE;
- case VK_LWIN:
- Private->LeftLogo = Flag;
- return TRUE;
+ case VK_RCONTROL:
+ Private->RightCtrl = Flag;
+ return TRUE;
- case VK_RWIN:
- Private->RightLogo = Flag;
- return TRUE;
+ case VK_LWIN:
+ Private->LeftLogo = Flag;
+ return TRUE;
- case VK_APPS:
- Private->Menu = Flag;
- return TRUE;
- //
- // BUGBUG: PrintScreen/SysRq can not trigger WM_KEYDOWN message,
- // so SySReq shift state is not supported here.
- //
- case VK_PRINT:
- Private->SysReq = Flag;
- return TRUE;
- //
- // For Alt Keystroke.
- //
- case VK_MENU:
- if ((*lParam & GOP_EXTENDED_KEY) == GOP_EXTENDED_KEY) {
+ case VK_RWIN:
+ Private->RightLogo = Flag;
+ return TRUE;
+
+ case VK_APPS:
+ Private->Menu = Flag;
+ return TRUE;
+ //
+ // BUGBUG: PrintScreen/SysRq can not trigger WM_KEYDOWN message,
+ // so SySReq shift state is not supported here.
+ //
+ case VK_PRINT:
+ Private->SysReq = Flag;
+ return TRUE;
+ //
+ // For Alt Keystroke.
+ //
+ case VK_MENU:
+ if ((*lParam & GOP_EXTENDED_KEY) == GOP_EXTENDED_KEY) {
Private->RightAlt = Flag;
} else {
Private->LeftAlt = Flag;
}
- return TRUE;
- default:
- return FALSE;
+ return TRUE;
+
+ default:
+ return FALSE;
}
}
@@ -110,68 +113,138 @@ WinNtGopConvertParamToEfiKey (
IN EFI_INPUT_KEY *Key
)
{
- BOOLEAN Flag;
+ BOOLEAN Flag;
+
Flag = FALSE;
switch (*wParam) {
- case VK_HOME: Key->ScanCode = SCAN_HOME; Flag = TRUE; break;
- case VK_END: Key->ScanCode = SCAN_END; Flag = TRUE; break;
- case VK_LEFT: Key->ScanCode = SCAN_LEFT; Flag = TRUE; break;
- case VK_RIGHT: Key->ScanCode = SCAN_RIGHT; Flag = TRUE; break;
- case VK_UP: Key->ScanCode = SCAN_UP; Flag = TRUE; break;
- case VK_DOWN: Key->ScanCode = SCAN_DOWN; Flag = TRUE; break;
- case VK_DELETE: Key->ScanCode = SCAN_DELETE; Flag = TRUE; break;
- case VK_INSERT: Key->ScanCode = SCAN_INSERT; Flag = TRUE; break;
- case VK_PRIOR: Key->ScanCode = SCAN_PAGE_UP; Flag = TRUE; break;
- case VK_NEXT: Key->ScanCode = SCAN_PAGE_DOWN; Flag = TRUE; break;
- case VK_ESCAPE: Key->ScanCode = SCAN_ESC; Flag = TRUE; break;
-
- case VK_F1: Key->ScanCode = SCAN_F1; Flag = TRUE; break;
- case VK_F2: Key->ScanCode = SCAN_F2; Flag = TRUE; break;
- case VK_F3: Key->ScanCode = SCAN_F3; Flag = TRUE; break;
- case VK_F4: Key->ScanCode = SCAN_F4; Flag = TRUE; break;
- case VK_F5: Key->ScanCode = SCAN_F5; Flag = TRUE; break;
- case VK_F6: Key->ScanCode = SCAN_F6; Flag = TRUE; break;
- case VK_F7: Key->ScanCode = SCAN_F7; Flag = TRUE; break;
- case VK_F8: Key->ScanCode = SCAN_F8; Flag = TRUE; break;
- case VK_F9: Key->ScanCode = SCAN_F9; Flag = TRUE; break;
- case VK_F11: Key->ScanCode = SCAN_F11; Flag = TRUE; break;
- case VK_F12: Key->ScanCode = SCAN_F12; Flag = TRUE; break;
-
- case VK_F13: Key->ScanCode = SCAN_F13; Flag = TRUE; break;
- case VK_F14: Key->ScanCode = SCAN_F14; Flag = TRUE; break;
- case VK_F15: Key->ScanCode = SCAN_F15; Flag = TRUE; break;
- case VK_F16: Key->ScanCode = SCAN_F16; Flag = TRUE; break;
- case VK_F17: Key->ScanCode = SCAN_F17; Flag = TRUE; break;
- case VK_F18: Key->ScanCode = SCAN_F18; Flag = TRUE; break;
- case VK_F19: Key->ScanCode = SCAN_F19; Flag = TRUE; break;
- case VK_F20: Key->ScanCode = SCAN_F20; Flag = TRUE; break;
- case VK_F21: Key->ScanCode = SCAN_F21; Flag = TRUE; break;
- case VK_F22: Key->ScanCode = SCAN_F22; Flag = TRUE; break;
- case VK_F23: Key->ScanCode = SCAN_F23; Flag = TRUE; break;
- case VK_F24: Key->ScanCode = SCAN_F24; Flag = TRUE; break;
- case VK_PAUSE: Key->ScanCode = SCAN_PAUSE; Flag = TRUE; break;
-
- //
- // Set toggle state
- //
- case VK_NUMLOCK:
- Private->NumLock = (BOOLEAN)(!Private->NumLock);
- Flag = TRUE;
- break;
- case VK_SCROLL:
- Private->ScrollLock = (BOOLEAN)(!Private->ScrollLock);
- Flag = TRUE;
- break;
- case VK_CAPITAL:
- Private->CapsLock = (BOOLEAN)(!Private->CapsLock);
- Flag = TRUE;
- break;
+ case VK_HOME: Key->ScanCode = SCAN_HOME;
+ Flag = TRUE;
+ break;
+ case VK_END: Key->ScanCode = SCAN_END;
+ Flag = TRUE;
+ break;
+ case VK_LEFT: Key->ScanCode = SCAN_LEFT;
+ Flag = TRUE;
+ break;
+ case VK_RIGHT: Key->ScanCode = SCAN_RIGHT;
+ Flag = TRUE;
+ break;
+ case VK_UP: Key->ScanCode = SCAN_UP;
+ Flag = TRUE;
+ break;
+ case VK_DOWN: Key->ScanCode = SCAN_DOWN;
+ Flag = TRUE;
+ break;
+ case VK_DELETE: Key->ScanCode = SCAN_DELETE;
+ Flag = TRUE;
+ break;
+ case VK_INSERT: Key->ScanCode = SCAN_INSERT;
+ Flag = TRUE;
+ break;
+ case VK_PRIOR: Key->ScanCode = SCAN_PAGE_UP;
+ Flag = TRUE;
+ break;
+ case VK_NEXT: Key->ScanCode = SCAN_PAGE_DOWN;
+ Flag = TRUE;
+ break;
+ case VK_ESCAPE: Key->ScanCode = SCAN_ESC;
+ Flag = TRUE;
+ break;
+
+ case VK_F1: Key->ScanCode = SCAN_F1;
+ Flag = TRUE;
+ break;
+ case VK_F2: Key->ScanCode = SCAN_F2;
+ Flag = TRUE;
+ break;
+ case VK_F3: Key->ScanCode = SCAN_F3;
+ Flag = TRUE;
+ break;
+ case VK_F4: Key->ScanCode = SCAN_F4;
+ Flag = TRUE;
+ break;
+ case VK_F5: Key->ScanCode = SCAN_F5;
+ Flag = TRUE;
+ break;
+ case VK_F6: Key->ScanCode = SCAN_F6;
+ Flag = TRUE;
+ break;
+ case VK_F7: Key->ScanCode = SCAN_F7;
+ Flag = TRUE;
+ break;
+ case VK_F8: Key->ScanCode = SCAN_F8;
+ Flag = TRUE;
+ break;
+ case VK_F9: Key->ScanCode = SCAN_F9;
+ Flag = TRUE;
+ break;
+ case VK_F11: Key->ScanCode = SCAN_F11;
+ Flag = TRUE;
+ break;
+ case VK_F12: Key->ScanCode = SCAN_F12;
+ Flag = TRUE;
+ break;
+
+ case VK_F13: Key->ScanCode = SCAN_F13;
+ Flag = TRUE;
+ break;
+ case VK_F14: Key->ScanCode = SCAN_F14;
+ Flag = TRUE;
+ break;
+ case VK_F15: Key->ScanCode = SCAN_F15;
+ Flag = TRUE;
+ break;
+ case VK_F16: Key->ScanCode = SCAN_F16;
+ Flag = TRUE;
+ break;
+ case VK_F17: Key->ScanCode = SCAN_F17;
+ Flag = TRUE;
+ break;
+ case VK_F18: Key->ScanCode = SCAN_F18;
+ Flag = TRUE;
+ break;
+ case VK_F19: Key->ScanCode = SCAN_F19;
+ Flag = TRUE;
+ break;
+ case VK_F20: Key->ScanCode = SCAN_F20;
+ Flag = TRUE;
+ break;
+ case VK_F21: Key->ScanCode = SCAN_F21;
+ Flag = TRUE;
+ break;
+ case VK_F22: Key->ScanCode = SCAN_F22;
+ Flag = TRUE;
+ break;
+ case VK_F23: Key->ScanCode = SCAN_F23;
+ Flag = TRUE;
+ break;
+ case VK_F24: Key->ScanCode = SCAN_F24;
+ Flag = TRUE;
+ break;
+ case VK_PAUSE: Key->ScanCode = SCAN_PAUSE;
+ Flag = TRUE;
+ break;
+
+ //
+ // Set toggle state
+ //
+ case VK_NUMLOCK:
+ Private->NumLock = (BOOLEAN)(!Private->NumLock);
+ Flag = TRUE;
+ break;
+ case VK_SCROLL:
+ Private->ScrollLock = (BOOLEAN)(!Private->ScrollLock);
+ Flag = TRUE;
+ break;
+ case VK_CAPITAL:
+ Private->CapsLock = (BOOLEAN)(!Private->CapsLock);
+ Flag = TRUE;
+ break;
}
return (WinNtGopConvertParamToEfiKeyShiftState (Private, wParam, lParam, TRUE)) == TRUE ? TRUE : Flag;
}
-
//
// GOP Protocol Member Functions
//
@@ -185,15 +258,15 @@ WinNtWndSize (
IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo,
IN UINT32 Width,
IN UINT32 Height
-)
+ )
{
- RETURN_STATUS RStatus;
- EFI_GRAPHICS_OUTPUT_MODE_INFORMATION Info;
- GRAPHICS_PRIVATE_DATA *Private;
- RECT Rect;
- BITMAPV4HEADER *VirtualScreenInfo;
- FRAME_BUFFER_CONFIGURE *FrameBufferConfigure;
- UINTN FrameBufferConfigureSize;
+ RETURN_STATUS RStatus;
+ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION Info;
+ GRAPHICS_PRIVATE_DATA *Private;
+ RECT Rect;
+ BITMAPV4HEADER *VirtualScreenInfo;
+ FRAME_BUFFER_CONFIGURE *FrameBufferConfigure;
+ UINTN FrameBufferConfigureSize;
Private = GRAPHICS_PRIVATE_DATA_FROM_THIS (GraphicsIo);
@@ -202,10 +275,10 @@ WinNtWndSize (
// This buffer is the virtual screen/frame buffer.
//
VirtualScreenInfo = HeapAlloc (
- GetProcessHeap (),
- HEAP_ZERO_MEMORY,
- Width * Height * sizeof (RGBQUAD) + sizeof (BITMAPV4HEADER)
- );
+ GetProcessHeap (),
+ HEAP_ZERO_MEMORY,
+ Width * Height * sizeof (RGBQUAD) + sizeof (BITMAPV4HEADER)
+ );
if (VirtualScreenInfo == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -214,10 +287,10 @@ WinNtWndSize (
// Update the virtual screen info data structure
// Use negative Height to make sure screen/buffer are using the same coordinate.
//
- VirtualScreenInfo->bV4Size = sizeof (BITMAPV4HEADER);
- VirtualScreenInfo->bV4Width = Width;
- VirtualScreenInfo->bV4Height = -(LONG)Height;
- VirtualScreenInfo->bV4Planes = 1;
+ VirtualScreenInfo->bV4Size = sizeof (BITMAPV4HEADER);
+ VirtualScreenInfo->bV4Width = Width;
+ VirtualScreenInfo->bV4Height = -(LONG)Height;
+ VirtualScreenInfo->bV4Planes = 1;
VirtualScreenInfo->bV4BitCount = 32;
//
// uncompressed
@@ -229,20 +302,21 @@ WinNtWndSize (
Info.PixelFormat = PixelBlueGreenRedReserved8BitPerColor;
Info.PixelsPerScanLine = Width;
FrameBufferConfigureSize = 0;
- RStatus = FrameBufferBltConfigure (VirtualScreenInfo + 1, &Info, NULL, &FrameBufferConfigureSize);
+ RStatus = FrameBufferBltConfigure (VirtualScreenInfo + 1, &Info, NULL, &FrameBufferConfigureSize);
ASSERT (RStatus == EFI_BUFFER_TOO_SMALL);
FrameBufferConfigure = AllocatePool (FrameBufferConfigureSize);
if (FrameBufferConfigure == NULL) {
HeapFree (GetProcessHeap (), 0, VirtualScreenInfo);
return EFI_OUT_OF_RESOURCES;
}
+
RStatus = FrameBufferBltConfigure (VirtualScreenInfo + 1, &Info, FrameBufferConfigure, &FrameBufferConfigureSize);
ASSERT_RETURN_ERROR (RStatus);
-
if (Private->FrameBufferConfigure != NULL) {
FreePool (Private->FrameBufferConfigure);
}
+
Private->FrameBufferConfigure = FrameBufferConfigure;
//
@@ -253,6 +327,7 @@ WinNtWndSize (
if (Private->VirtualScreenInfo != NULL) {
HeapFree (GetProcessHeap (), 0, Private->VirtualScreenInfo);
}
+
Private->VirtualScreenInfo = VirtualScreenInfo;
Private->Width = Width;
@@ -321,24 +396,27 @@ WinNtWndSize (
// TODO: Delta - add argument and description to function comment
EFI_STATUS
WinNtWndBlt (
- IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo,
- IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,
- IN EFI_UGA_BLT_OPERATION BltOperation,
- IN EMU_GRAPHICS_WINDOWS__BLT_ARGS *Args
-)
+ IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo,
+ IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,
+ IN EFI_UGA_BLT_OPERATION BltOperation,
+ IN EMU_GRAPHICS_WINDOWS__BLT_ARGS *Args
+ )
{
- RETURN_STATUS RStatus;
- GRAPHICS_PRIVATE_DATA *Private;
- RECT Rect;
+ RETURN_STATUS RStatus;
+ GRAPHICS_PRIVATE_DATA *Private;
+ RECT Rect;
Private = GRAPHICS_PRIVATE_DATA_FROM_THIS (GraphicsIo);
RStatus = FrameBufferBlt (
Private->FrameBufferConfigure,
BltBuffer,
BltOperation,
- Args->SourceX, Args->SourceY,
- Args->DestinationX, Args->DestinationY,
- Args->Width, Args->Height,
+ Args->SourceX,
+ Args->SourceY,
+ Args->DestinationX,
+ Args->DestinationY,
+ Args->Width,
+ Args->Height,
Args->Delta
);
if (RETURN_ERROR (RStatus)) {
@@ -370,8 +448,6 @@ WinNtWndBlt (
return EFI_SUCCESS;
}
-
-
/**
Win32 Windows event handler.
@@ -393,14 +469,14 @@ WinNtGopThreadWindowProc (
IN LPARAM lParam
)
{
- GRAPHICS_PRIVATE_DATA *Private;
- HDC Handle;
- PAINTSTRUCT PaintStruct;
- LPARAM Index;
- EFI_INPUT_KEY Key;
- BOOLEAN AltIsPress;
- INT32 PosX;
- INT32 PosY;
+ GRAPHICS_PRIVATE_DATA *Private;
+ HDC Handle;
+ PAINTSTRUCT PaintStruct;
+ LPARAM Index;
+ EFI_INPUT_KEY Key;
+ BOOLEAN AltIsPress;
+ INT32 PosX;
+ INT32 PosY;
//
// Use mTlsIndex global to get a Thread Local Storage version of Private.
@@ -408,190 +484,195 @@ WinNtGopThreadWindowProc (
// a unique thread.
//
AltIsPress = FALSE;
- Private = TlsGetValue (mTlsIndex);
+ Private = TlsGetValue (mTlsIndex);
ASSERT (NULL != Private);
switch (iMsg) {
- case WM_PAINT:
- Handle = BeginPaint (hwnd, &PaintStruct);
-
- SetDIBitsToDevice (
- Handle, // Destination Device Context
- 0, // Destination X - 0
- 0, // Destination Y - 0
- Private->Width, // Width
- Private->Height, // Height
- 0, // Source X
- 0, // Source Y
- 0, // DIB Start Scan Line
- Private->Height, // Number of scan lines
- Private->VirtualScreenInfo + 1, // Address of array of DIB bits
- (BITMAPINFO *) Private->VirtualScreenInfo, // Address of structure with bitmap info
- DIB_RGB_COLORS // RGB or palette indexes
- );
-
- EndPaint (hwnd, &PaintStruct);
- return 0;
-
- //
- // F10 and the ALT key do not create a WM_KEYDOWN message, thus this special case
- // WM_SYSKEYDOWN is posted when F10 is pressed or
- // holds down ALT key and then presses another key.
- //
- case WM_SYSKEYDOWN:
-
- Key.ScanCode = 0;
- Key.UnicodeChar = CHAR_NULL;
- switch (wParam) {
- case VK_F10:
- Key.ScanCode = SCAN_F10;
- Key.UnicodeChar = CHAR_NULL;
- GopPrivateAddKey (Private, Key);
+ case WM_PAINT:
+ Handle = BeginPaint (hwnd, &PaintStruct);
+
+ SetDIBitsToDevice (
+ Handle, // Destination Device Context
+ 0, // Destination X - 0
+ 0, // Destination Y - 0
+ Private->Width, // Width
+ Private->Height, // Height
+ 0, // Source X
+ 0, // Source Y
+ 0, // DIB Start Scan Line
+ Private->Height, // Number of scan lines
+ Private->VirtualScreenInfo + 1, // Address of array of DIB bits
+ (BITMAPINFO *)Private->VirtualScreenInfo, // Address of structure with bitmap info
+ DIB_RGB_COLORS // RGB or palette indexes
+ );
+
+ EndPaint (hwnd, &PaintStruct);
return 0;
- }
//
- // If ALT or ALT + modifier key is pressed.
+ // F10 and the ALT key do not create a WM_KEYDOWN message, thus this special case
+ // WM_SYSKEYDOWN is posted when F10 is pressed or
+ // holds down ALT key and then presses another key.
//
- if (WinNtGopConvertParamToEfiKey (Private, &wParam, &lParam, &Key)) {
- if (Key.ScanCode != 0){
+ case WM_SYSKEYDOWN:
+
+ Key.ScanCode = 0;
+ Key.UnicodeChar = CHAR_NULL;
+ switch (wParam) {
+ case VK_F10:
+ Key.ScanCode = SCAN_F10;
+ Key.UnicodeChar = CHAR_NULL;
+ GopPrivateAddKey (Private, Key);
+ return 0;
+ }
+
+ //
+ // If ALT or ALT + modifier key is pressed.
+ //
+ if (WinNtGopConvertParamToEfiKey (Private, &wParam, &lParam, &Key)) {
+ if (Key.ScanCode != 0) {
+ //
+ // If ALT is pressed with other ScanCode.
+ // Always revers the left Alt for simple.
+ //
+ Private->LeftAlt = TRUE;
+ }
+
+ GopPrivateAddKey (Private, Key);
//
- // If ALT is pressed with other ScanCode.
- // Always revers the left Alt for simple.
+ // When Alt is released there is no windoes message, so
+ // clean it after using it.
//
- Private->LeftAlt = TRUE;
+ Private->RightAlt = FALSE;
+ Private->LeftAlt = FALSE;
+ return 0;
}
- GopPrivateAddKey (Private, Key);
+
+ AltIsPress = TRUE;
+
+ case WM_CHAR:
//
- // When Alt is released there is no windoes message, so
- // clean it after using it.
+ // The ESC key also generate WM_CHAR.
//
- Private->RightAlt = FALSE;
- Private->LeftAlt = FALSE;
+ if (wParam == 0x1B) {
+ return 0;
+ }
+
+ if (AltIsPress == TRUE) {
+ //
+ // If AltIsPress is true that means the Alt key is pressed.
+ //
+ Private->LeftAlt = TRUE;
+ }
+
+ for (Index = 0; Index < (lParam & 0xffff); Index++) {
+ if (wParam != 0) {
+ Key.UnicodeChar = (CHAR16)wParam;
+ Key.ScanCode = SCAN_NULL;
+ GopPrivateAddKey (Private, Key);
+ }
+ }
+
+ if (AltIsPress == TRUE) {
+ //
+ // When Alt is released there is no windoes message, so
+ // clean it after using it.
+ //
+ Private->LeftAlt = FALSE;
+ Private->RightAlt = FALSE;
+ }
+
return 0;
- }
- AltIsPress = TRUE;
- case WM_CHAR:
- //
- // The ESC key also generate WM_CHAR.
- //
- if (wParam == 0x1B) {
+ case WM_SYSKEYUP:
+ //
+ // ALT is pressed with another key released
+ //
+ WinNtGopConvertParamToEfiKeyShiftState (Private, &wParam, &lParam, FALSE);
return 0;
- }
- if (AltIsPress == TRUE) {
+ case WM_KEYDOWN:
+ Key.ScanCode = SCAN_NULL;
+ Key.UnicodeChar = CHAR_NULL;
//
- // If AltIsPress is true that means the Alt key is pressed.
+ // A value key press will cause a WM_KEYDOWN first, then cause a WM_CHAR
+ // So if there is no modifier key updated, skip the WM_KEYDOWN even.
//
- Private->LeftAlt = TRUE;
- }
- for (Index = 0; Index < (lParam & 0xffff); Index++) {
- if (wParam != 0) {
- Key.UnicodeChar = (CHAR16) wParam;
- Key.ScanCode = SCAN_NULL;
+ if (WinNtGopConvertParamToEfiKey (Private, &wParam, &lParam, &Key)) {
+ //
+ // Support the partial keystroke, add all keydown event into the queue.
+ //
GopPrivateAddKey (Private, Key);
}
- }
- if (AltIsPress == TRUE) {
- //
- // When Alt is released there is no windoes message, so
- // clean it after using it.
- //
- Private->LeftAlt = FALSE;
- Private->RightAlt = FALSE;
- }
- return 0;
- case WM_SYSKEYUP:
- //
- // ALT is pressed with another key released
- //
- WinNtGopConvertParamToEfiKeyShiftState (Private, &wParam, &lParam, FALSE);
- return 0;
+ return 0;
- case WM_KEYDOWN:
- Key.ScanCode = SCAN_NULL;
- Key.UnicodeChar = CHAR_NULL;
- //
- // A value key press will cause a WM_KEYDOWN first, then cause a WM_CHAR
- // So if there is no modifier key updated, skip the WM_KEYDOWN even.
- //
- if (WinNtGopConvertParamToEfiKey (Private, &wParam, &lParam, &Key)) {
+ case WM_KEYUP:
+ WinNtGopConvertParamToEfiKeyShiftState (Private, &wParam, &lParam, FALSE);
+ return 0;
+
+ case WM_MOUSEMOVE:
+ PosX = GET_X_LPARAM (lParam);
+ PosY = GET_Y_LPARAM (lParam);
+
+ if (Private->PointerPreviousX != PosX) {
+ Private->PointerState.RelativeMovementX += (PosX - Private->PointerPreviousX);
+ Private->PointerPreviousX = PosX;
+ Private->PointerStateChanged = TRUE;
+ }
+
+ if (Private->PointerPreviousY != PosY) {
+ Private->PointerState.RelativeMovementY += (PosY - Private->PointerPreviousY);
+ Private->PointerPreviousY = PosY;
+ Private->PointerStateChanged = TRUE;
+ }
+
+ Private->PointerState.RelativeMovementZ = 0;
+ return 0;
+
+ case WM_LBUTTONDOWN:
+ Private->PointerState.LeftButton = TRUE;
+ Private->PointerStateChanged = TRUE;
+ return 0;
+
+ case WM_LBUTTONUP:
+ Private->PointerState.LeftButton = FALSE;
+ Private->PointerStateChanged = TRUE;
+ return 0;
+
+ case WM_RBUTTONDOWN:
+ Private->PointerState.RightButton = TRUE;
+ Private->PointerStateChanged = TRUE;
+ return 0;
+
+ case WM_RBUTTONUP:
+ Private->PointerState.RightButton = FALSE;
+ Private->PointerStateChanged = TRUE;
+ return 0;
+
+ case WM_CLOSE:
//
- // Support the partial keystroke, add all keydown event into the queue.
+ // This close message is issued by user, core is not aware of this,
+ // so don't release the window display resource, just hide the window.
//
- GopPrivateAddKey (Private, Key);
- }
- return 0;
-
- case WM_KEYUP:
- WinNtGopConvertParamToEfiKeyShiftState (Private, &wParam, &lParam, FALSE);
- return 0;
-
- case WM_MOUSEMOVE:
- PosX = GET_X_LPARAM (lParam);
- PosY = GET_Y_LPARAM (lParam);
-
- if (Private->PointerPreviousX != PosX) {
- Private->PointerState.RelativeMovementX += (PosX - Private->PointerPreviousX);
- Private->PointerPreviousX = PosX;
- Private->PointerStateChanged = TRUE;
- }
-
- if (Private->PointerPreviousY != PosY) {
- Private->PointerState.RelativeMovementY += (PosY - Private->PointerPreviousY);
- Private->PointerPreviousY = PosY;
- Private->PointerStateChanged = TRUE;
- }
-
- Private->PointerState.RelativeMovementZ = 0;
- return 0;
-
- case WM_LBUTTONDOWN:
- Private->PointerState.LeftButton = TRUE;
- Private->PointerStateChanged = TRUE;
- return 0;
-
- case WM_LBUTTONUP:
- Private->PointerState.LeftButton = FALSE;
- Private->PointerStateChanged = TRUE;
- return 0;
-
- case WM_RBUTTONDOWN:
- Private->PointerState.RightButton = TRUE;
- Private->PointerStateChanged = TRUE;
- return 0;
-
- case WM_RBUTTONUP:
- Private->PointerState.RightButton = FALSE;
- Private->PointerStateChanged = TRUE;
- return 0;
-
- case WM_CLOSE:
- //
- // This close message is issued by user, core is not aware of this,
- // so don't release the window display resource, just hide the window.
- //
- ShowWindow (Private->WindowHandle, SW_HIDE);
- return 0;
+ ShowWindow (Private->WindowHandle, SW_HIDE);
+ return 0;
- case WM_DESTROY:
- DestroyWindow (hwnd);
- PostQuitMessage (0);
+ case WM_DESTROY:
+ DestroyWindow (hwnd);
+ PostQuitMessage (0);
- HeapFree (GetProcessHeap (), 0, Private->VirtualScreenInfo);
+ HeapFree (GetProcessHeap (), 0, Private->VirtualScreenInfo);
- ExitThread (0);
+ ExitThread (0);
- default:
- break;
- };
+ default:
+ break;
+ }
return DefWindowProc (hwnd, iMsg, wParam, lParam);
}
-
/**
This thread simulates the end of WinMain () application. Each Window needs
to process its events. The messages are dispatched to
@@ -607,14 +688,14 @@ WinNtGopThreadWindowProc (
DWORD
WINAPI
WinNtGopThreadWinMain (
- LPVOID lpParameter
+ LPVOID lpParameter
)
{
MSG Message;
GRAPHICS_PRIVATE_DATA *Private;
RECT Rect;
- Private = (GRAPHICS_PRIVATE_DATA *) lpParameter;
+ Private = (GRAPHICS_PRIVATE_DATA *)lpParameter;
ASSERT (NULL != Private);
//
@@ -624,7 +705,7 @@ WinNtGopThreadWinMain (
//
TlsSetValue (mTlsIndex, Private);
- Private->ThreadId = GetCurrentThreadId ();
+ Private->ThreadId = GetCurrentThreadId ();
Private->WindowsClass.cbSize = sizeof (WNDCLASSEX);
Private->WindowsClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
@@ -645,7 +726,6 @@ WinNtGopThreadWinMain (
Private->Width = 100;
Private->Height = 100;
-
//
// This call will fail after the first time, but thats O.K. since we only need
// WIN_NT_GOP_CLASS_NAME to exist to create the window.
@@ -703,7 +783,6 @@ WinNtGopThreadWinMain (
return (DWORD)Message.wParam;
}
-
/**
TODO: Add function description
@@ -719,11 +798,11 @@ WinNtGopThreadWinMain (
EFI_STATUS
EFIAPI
WinNtGraphicsWindowOpen (
- IN EMU_IO_THUNK_PROTOCOL *This
+ IN EMU_IO_THUNK_PROTOCOL *This
)
{
- DWORD NewThreadId;
- GRAPHICS_PRIVATE_DATA *Private;
+ DWORD NewThreadId;
+ GRAPHICS_PRIVATE_DATA *Private;
Private = AllocateZeroPool (sizeof (*Private));
@@ -758,7 +837,7 @@ WinNtGraphicsWindowOpen (
NULL,
0,
WinNtGopThreadWinMain,
- (VOID *) Private,
+ (VOID *)Private,
0,
&NewThreadId
);
@@ -770,7 +849,7 @@ WinNtGraphicsWindowOpen (
WaitForSingleObject (Private->ThreadInited, INFINITE);
CloseHandle (Private->ThreadInited);
- This->Private = Private;
+ This->Private = Private;
This->Interface = &Private->GraphicsWindowIo;
return EFI_SUCCESS;
@@ -779,10 +858,10 @@ WinNtGraphicsWindowOpen (
EFI_STATUS
EFIAPI
WinNtGraphicsWindowClose (
- IN EMU_IO_THUNK_PROTOCOL *This
-)
+ IN EMU_IO_THUNK_PROTOCOL *This
+ )
{
- GRAPHICS_PRIVATE_DATA *Private;
+ GRAPHICS_PRIVATE_DATA *Private;
Private = (GRAPHICS_PRIVATE_DATA *)This->Private;
@@ -807,16 +886,14 @@ WinNtGraphicsWindowClose (
UnregisterClass (
Private->WindowsClass.lpszClassName,
Private->WindowsClass.hInstance
- );
+ );
}
-
GopPrivateDestroyQ (Private, &Private->QueueForRead);
return EFI_SUCCESS;
}
-
-EMU_IO_THUNK_PROTOCOL mWinNtWndThunkIo = {
+EMU_IO_THUNK_PROTOCOL mWinNtWndThunkIo = {
&gEmuGraphicsWindowProtocolGuid,
NULL,
NULL,
diff --git a/EmulatorPkg/Win/Host/WinHost.c b/EmulatorPkg/Win/Host/WinHost.c
index ffd1b9944d..93247c5043 100644
--- a/EmulatorPkg/Win/Host/WinHost.c
+++ b/EmulatorPkg/Win/Host/WinHost.c
@@ -16,26 +16,26 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "WinHost.h"
#ifndef SE_TIME_ZONE_NAME
-#define SE_TIME_ZONE_NAME TEXT("SeTimeZonePrivilege")
+#define SE_TIME_ZONE_NAME TEXT("SeTimeZonePrivilege")
#endif
//
// The growth size for array of module handle entries
//
-#define MAX_PDB_NAME_TO_MOD_HANDLE_ARRAY_SIZE 0x100
+#define MAX_PDB_NAME_TO_MOD_HANDLE_ARRAY_SIZE 0x100
//
// Module handle entry structure
//
typedef struct {
- CHAR8 *PdbPointer;
- VOID *ModHandle;
+ CHAR8 *PdbPointer;
+ VOID *ModHandle;
} PDB_NAME_TO_MOD_HANDLE;
//
// An Array to hold the module handles
//
-PDB_NAME_TO_MOD_HANDLE *mPdbNameModHandleArray = NULL;
+PDB_NAME_TO_MOD_HANDLE *mPdbNameModHandleArray = NULL;
UINTN mPdbNameModHandleArraySize = 0;
//
@@ -44,8 +44,8 @@ UINTN mPdbNameModHandleArraySize = 0;
// The number of array elements is allocated base on parsing
// PcdWinNtFirmwareVolume and the memory is never freed.
//
-UINTN gFdInfoCount = 0;
-NT_FD_INFO *gFdInfo;
+UINTN gFdInfoCount = 0;
+NT_FD_INFO *gFdInfo;
//
// Array that supports separate memory ranges.
@@ -53,8 +53,8 @@ NT_FD_INFO *gFdInfo;
// The number of array elements is allocated base on parsing
// PcdWinNtMemorySizeForSecMain value and the memory is never freed.
//
-UINTN gSystemMemoryCount = 0;
-NT_SYSTEM_MEMORY *gSystemMemory;
+UINTN gSystemMemoryCount = 0;
+NT_SYSTEM_MEMORY *gSystemMemory;
/*++
@@ -90,7 +90,7 @@ WinPeiAutoScan (
//
// Allocate enough memory space for emulator
//
- gSystemMemory[Index].Memory = (EFI_PHYSICAL_ADDRESS) (UINTN) VirtualAlloc (NULL, (SIZE_T) (gSystemMemory[Index].Size), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
+ gSystemMemory[Index].Memory = (EFI_PHYSICAL_ADDRESS)(UINTN)VirtualAlloc (NULL, (SIZE_T)(gSystemMemory[Index].Size), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
if (gSystemMemory[Index].Memory == 0) {
return EFI_OUT_OF_RESOURCES;
}
@@ -130,12 +130,11 @@ WinFdAddress (
return EFI_UNSUPPORTED;
}
-
*FdBase = (EFI_PHYSICAL_ADDRESS)(UINTN)gFdInfo[Index].Address;
*FdSize = (UINT64)gFdInfo[Index].Size;
*FixUp = 0;
- if (*FdBase == 0 && *FdSize == 0) {
+ if ((*FdBase == 0) && (*FdSize == 0)) {
return EFI_UNSUPPORTED;
}
@@ -173,8 +172,7 @@ WinThunk (
return &gEmuThunkProtocol;
}
-
-EMU_THUNK_PPI mSecEmuThunkPpi = {
+EMU_THUNK_PPI mSecEmuThunkPpi = {
WinPeiAutoScan,
WinFdAddress,
WinThunk
@@ -227,7 +225,7 @@ Returns:
**/
BOOLEAN
EfiSystemMemoryRange (
- IN VOID *MemoryAddress
+ IN VOID *MemoryAddress
)
{
UINTN Index;
@@ -236,7 +234,8 @@ EfiSystemMemoryRange (
MemoryBase = (EFI_PHYSICAL_ADDRESS)(UINTN)MemoryAddress;
for (Index = 0; Index < gSystemMemoryCount; Index++) {
if ((MemoryBase >= gSystemMemory[Index].Memory) &&
- (MemoryBase < (gSystemMemory[Index].Memory + gSystemMemory[Index].Size)) ) {
+ (MemoryBase < (gSystemMemory[Index].Memory + gSystemMemory[Index].Size)))
+ {
return TRUE;
}
}
@@ -244,15 +243,15 @@ EfiSystemMemoryRange (
return FALSE;
}
-
EFI_STATUS
WinNtOpenFile (
- IN CHAR16 *FileName OPTIONAL,
- IN UINT32 MapSize,
- IN DWORD CreationDisposition,
- IN OUT VOID **BaseAddress,
- OUT UINTN *Length
+ IN CHAR16 *FileName OPTIONAL,
+ IN UINT32 MapSize,
+ IN DWORD CreationDisposition,
+ IN OUT VOID **BaseAddress,
+ OUT UINTN *Length
)
+
/*++
Routine Description:
@@ -300,6 +299,7 @@ Returns:
return EFI_NOT_FOUND;
}
}
+
//
// Map the open file into a memory range
//
@@ -314,17 +314,18 @@ Returns:
if (NtMapHandle == NULL) {
return EFI_DEVICE_ERROR;
}
+
//
// Get the virtual address (address in the emulator) of the mapped file
//
VirtualAddress = MapViewOfFileEx (
- NtMapHandle,
- FILE_MAP_EXECUTE | FILE_MAP_ALL_ACCESS,
- 0,
- 0,
- MapSize,
- *BaseAddress
- );
+ NtMapHandle,
+ FILE_MAP_EXECUTE | FILE_MAP_ALL_ACCESS,
+ 0,
+ 0,
+ MapSize,
+ *BaseAddress
+ );
if (VirtualAddress == NULL) {
return EFI_DEVICE_ERROR;
}
@@ -334,11 +335,11 @@ Returns:
// Seek to the end of the file to figure out the true file size.
//
FileSize = SetFilePointer (
- NtFileHandle,
- 0,
- NULL,
- FILE_END
- );
+ NtFileHandle,
+ 0,
+ NULL,
+ FILE_END
+ );
if (FileSize == -1) {
return EFI_DEVICE_ERROR;
}
@@ -356,10 +357,11 @@ Returns:
INTN
EFIAPI
main (
- IN INT Argc,
- IN CHAR8 **Argv,
- IN CHAR8 **Envp
+ IN INT Argc,
+ IN CHAR8 **Argv,
+ IN CHAR8 **Envp
)
+
/*++
Routine Description:
@@ -376,37 +378,37 @@ Returns:
--*/
{
- EFI_STATUS Status;
- HANDLE Token;
- TOKEN_PRIVILEGES TokenPrivileges;
- VOID *TemporaryRam;
- UINT32 TemporaryRamSize;
- VOID *EmuMagicPage;
- UINTN Index;
- UINTN Index1;
- CHAR16 *FileName;
- CHAR16 *FileNamePtr;
- BOOLEAN Done;
- EFI_PEI_FILE_HANDLE FileHandle;
- VOID *SecFile;
- CHAR16 *MemorySizeStr;
- CHAR16 *FirmwareVolumesStr;
- UINTN ProcessAffinityMask;
- UINTN SystemAffinityMask;
- INT32 LowBit;
+ EFI_STATUS Status;
+ HANDLE Token;
+ TOKEN_PRIVILEGES TokenPrivileges;
+ VOID *TemporaryRam;
+ UINT32 TemporaryRamSize;
+ VOID *EmuMagicPage;
+ UINTN Index;
+ UINTN Index1;
+ CHAR16 *FileName;
+ CHAR16 *FileNamePtr;
+ BOOLEAN Done;
+ EFI_PEI_FILE_HANDLE FileHandle;
+ VOID *SecFile;
+ CHAR16 *MemorySizeStr;
+ CHAR16 *FirmwareVolumesStr;
+ UINTN ProcessAffinityMask;
+ UINTN SystemAffinityMask;
+ INT32 LowBit;
//
// Enable the privilege so that RTC driver can successfully run SetTime()
//
- OpenProcessToken (GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &Token);
- if (LookupPrivilegeValue(NULL, SE_TIME_ZONE_NAME, &TokenPrivileges.Privileges[0].Luid)) {
- TokenPrivileges.PrivilegeCount = 1;
+ OpenProcessToken (GetCurrentProcess (), TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &Token);
+ if (LookupPrivilegeValue (NULL, SE_TIME_ZONE_NAME, &TokenPrivileges.Privileges[0].Luid)) {
+ TokenPrivileges.PrivilegeCount = 1;
TokenPrivileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
- AdjustTokenPrivileges(Token, FALSE, &TokenPrivileges, 0, (PTOKEN_PRIVILEGES) NULL, 0);
+ AdjustTokenPrivileges (Token, FALSE, &TokenPrivileges, 0, (PTOKEN_PRIVILEGES)NULL, 0);
}
- MemorySizeStr = (CHAR16 *) PcdGetPtr (PcdEmuMemorySize);
- FirmwareVolumesStr = (CHAR16 *) PcdGetPtr (PcdEmuFirmwareVolume);
+ MemorySizeStr = (CHAR16 *)PcdGetPtr (PcdEmuMemorySize);
+ FirmwareVolumesStr = (CHAR16 *)PcdGetPtr (PcdEmuFirmwareVolume);
SecPrint ("\n\rEDK II WIN Host Emulation Environment from http://www.tianocore.org/edk2/\n\r");
@@ -448,8 +450,8 @@ Returns:
//
// Allocate space for gSystemMemory Array
//
- gSystemMemoryCount = CountSeparatorsInString (MemorySizeStr, '!') + 1;
- gSystemMemory = calloc (gSystemMemoryCount, sizeof (NT_SYSTEM_MEMORY));
+ gSystemMemoryCount = CountSeparatorsInString (MemorySizeStr, '!') + 1;
+ gSystemMemory = calloc (gSystemMemoryCount, sizeof (NT_SYSTEM_MEMORY));
if (gSystemMemory == NULL) {
SecPrint ("ERROR : Can not allocate memory for %S. Exiting.\n\r", MemorySizeStr);
exit (1);
@@ -458,12 +460,13 @@ Returns:
//
// Allocate space for gSystemMemory Array
//
- gFdInfoCount = CountSeparatorsInString (FirmwareVolumesStr, '!') + 1;
- gFdInfo = calloc (gFdInfoCount, sizeof (NT_FD_INFO));
+ gFdInfoCount = CountSeparatorsInString (FirmwareVolumesStr, '!') + 1;
+ gFdInfo = calloc (gFdInfoCount, sizeof (NT_FD_INFO));
if (gFdInfo == NULL) {
SecPrint ("ERROR : Can not allocate memory for %S. Exiting.\n\r", FirmwareVolumesStr);
exit (1);
}
+
//
// Setup Boot Mode.
//
@@ -475,14 +478,16 @@ Returns:
// Set TemporaryRam to zero so WinNtOpenFile will allocate a new mapping
//
TemporaryRamSize = TEMPORARY_RAM_SIZE;
- TemporaryRam = VirtualAlloc (NULL, (SIZE_T) (TemporaryRamSize), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
+ TemporaryRam = VirtualAlloc (NULL, (SIZE_T)(TemporaryRamSize), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
if (TemporaryRam == NULL) {
SecPrint ("ERROR : Can not allocate enough space for SecStack\n\r");
exit (1);
}
+
SetMem32 (TemporaryRam, TemporaryRamSize, PcdGet32 (PcdInitValueInTempStack));
- SecPrint (" OS Emulator passing in %u KB of temp RAM at 0x%08lx to SEC\n\r",
+ SecPrint (
+ " OS Emulator passing in %u KB of temp RAM at 0x%08lx to SEC\n\r",
TemporaryRamSize / SIZE_1KB,
TemporaryRam
);
@@ -497,12 +502,12 @@ Returns:
if (EmuMagicPage != NULL) {
UINT64 Size;
Status = WinNtOpenFile (
- NULL,
- SIZE_4KB,
- 0,
- &EmuMagicPage,
- &Size
- );
+ NULL,
+ SIZE_4KB,
+ 0,
+ &EmuMagicPage,
+ &Size
+ );
if (EFI_ERROR (Status)) {
SecPrint ("ERROR : Could not allocate PeiServicesTablePage @ %p\n\r", EmuMagicPage);
return EFI_DEVICE_ERROR;
@@ -521,25 +526,26 @@ Returns:
for (Done = FALSE, Index = 0, SecFile = NULL; !Done; Index++) {
FileName = FileNamePtr;
- for (Index1 = 0; (FileNamePtr[Index1] != '!') && (FileNamePtr[Index1] != 0); Index1++)
- ;
+ for (Index1 = 0; (FileNamePtr[Index1] != '!') && (FileNamePtr[Index1] != 0); Index1++) {
+ }
+
if (FileNamePtr[Index1] == 0) {
Done = TRUE;
} else {
- FileNamePtr[Index1] = '\0';
- FileNamePtr = &FileNamePtr[Index1 + 1];
+ FileNamePtr[Index1] = '\0';
+ FileNamePtr = &FileNamePtr[Index1 + 1];
}
//
// Open the FD and remember where it got mapped into our processes address space
//
Status = WinNtOpenFile (
- FileName,
- 0,
- OPEN_EXISTING,
- &gFdInfo[Index].Address,
- &gFdInfo[Index].Size
- );
+ FileName,
+ 0,
+ OPEN_EXISTING,
+ &gFdInfo[Index].Address,
+ &gFdInfo[Index].Size
+ );
if (EFI_ERROR (Status)) {
SecPrint ("ERROR : Can not open Firmware Device File %S (0x%X). Exiting.\n\r", FileName, Status);
exit (1);
@@ -553,11 +559,11 @@ Returns:
// Load the first one we find.
//
FileHandle = NULL;
- Status = PeiServicesFfsFindNextFile (
- EFI_FV_FILETYPE_SECURITY_CORE,
- (EFI_PEI_FV_HANDLE)gFdInfo[Index].Address,
- &FileHandle
- );
+ Status = PeiServicesFfsFindNextFile (
+ EFI_FV_FILETYPE_SECURITY_CORE,
+ (EFI_PEI_FV_HANDLE)gFdInfo[Index].Address,
+ &FileHandle
+ );
if (!EFI_ERROR (Status)) {
Status = PeiServicesFfsFindSectionData (EFI_SECTION_PE32, FileHandle, &SecFile);
if (!EFI_ERROR (Status)) {
@@ -568,6 +574,7 @@ Returns:
SecPrint ("\n\r");
}
+
//
// Calculate memory regions and store the information in the gSystemMemory
// global for later use. The autosizing code will use this data to
@@ -582,8 +589,9 @@ Returns:
//
// Find the next region
//
- for (Index1 = 0; MemorySizeStr[Index1] != '!' && MemorySizeStr[Index1] != 0; Index1++)
- ;
+ for (Index1 = 0; MemorySizeStr[Index1] != '!' && MemorySizeStr[Index1] != 0; Index1++) {
+ }
+
if (MemorySizeStr[Index1] == 0) {
Done = TRUE;
}
@@ -608,12 +616,13 @@ Returns:
VOID
SecLoadSecCore (
- IN UINTN TemporaryRam,
- IN UINTN TemporaryRamSize,
- IN VOID *BootFirmwareVolumeBase,
- IN UINTN BootFirmwareVolumeSize,
- IN VOID *SecCorePe32File
+ IN UINTN TemporaryRam,
+ IN UINTN TemporaryRamSize,
+ IN VOID *BootFirmwareVolumeBase,
+ IN UINTN BootFirmwareVolumeSize,
+ IN VOID *SecCorePe32File
)
+
/*++
Routine Description:
@@ -630,11 +639,11 @@ Returns:
--*/
{
- EFI_STATUS Status;
- VOID *TopOfStack;
- VOID *SecCoreEntryPoint;
- EFI_SEC_PEI_HAND_OFF *SecCoreData;
- UINTN SecStackSize;
+ EFI_STATUS Status;
+ VOID *TopOfStack;
+ VOID *SecCoreEntryPoint;
+ EFI_SEC_PEI_HAND_OFF *SecCoreData;
+ UINTN SecStackSize;
//
// Compute Top Of Memory for Stack and PEI Core Allocations
@@ -650,37 +659,37 @@ Returns:
// | Stack |
// |-----------| <---- TemporaryRamBase
//
- TopOfStack = (VOID *)(TemporaryRam + SecStackSize);
+ TopOfStack = (VOID *)(TemporaryRam + SecStackSize);
//
// Reservet space for storing PeiCore's parament in stack.
//
- TopOfStack = (VOID *)((UINTN)TopOfStack - sizeof (EFI_SEC_PEI_HAND_OFF) - CPU_STACK_ALIGNMENT);
- TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);
+ TopOfStack = (VOID *)((UINTN)TopOfStack - sizeof (EFI_SEC_PEI_HAND_OFF) - CPU_STACK_ALIGNMENT);
+ TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);
//
// Bind this information into the SEC hand-off state
//
- SecCoreData = (EFI_SEC_PEI_HAND_OFF*)(UINTN)TopOfStack;
+ SecCoreData = (EFI_SEC_PEI_HAND_OFF *)(UINTN)TopOfStack;
SecCoreData->DataSize = sizeof (EFI_SEC_PEI_HAND_OFF);
SecCoreData->BootFirmwareVolumeBase = BootFirmwareVolumeBase;
SecCoreData->BootFirmwareVolumeSize = BootFirmwareVolumeSize;
- SecCoreData->TemporaryRamBase = (VOID*)TemporaryRam;
+ SecCoreData->TemporaryRamBase = (VOID *)TemporaryRam;
SecCoreData->TemporaryRamSize = TemporaryRamSize;
SecCoreData->StackBase = SecCoreData->TemporaryRamBase;
SecCoreData->StackSize = SecStackSize;
- SecCoreData->PeiTemporaryRamBase = (VOID*) ((UINTN) SecCoreData->TemporaryRamBase + SecStackSize);
+ SecCoreData->PeiTemporaryRamBase = (VOID *)((UINTN)SecCoreData->TemporaryRamBase + SecStackSize);
SecCoreData->PeiTemporaryRamSize = TemporaryRamSize - SecStackSize;
//
// Load the PEI Core from a Firmware Volume
//
Status = SecPeCoffGetEntryPoint (
- SecCorePe32File,
- &SecCoreEntryPoint
- );
+ SecCorePe32File,
+ &SecCoreEntryPoint
+ );
if (EFI_ERROR (Status)) {
- return ;
+ return;
}
//
@@ -695,7 +704,7 @@ Returns:
//
// If we get here, then the SEC Core returned. This is an error
//
- return ;
+ return;
}
RETURN_STATUS
@@ -705,26 +714,28 @@ SecPeCoffGetEntryPoint (
IN OUT VOID **EntryPoint
)
{
- EFI_STATUS Status;
- PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
+ EFI_STATUS Status;
+ PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
ZeroMem (&ImageContext, sizeof (ImageContext));
- ImageContext.Handle = Pe32Data;
+ ImageContext.Handle = Pe32Data;
- ImageContext.ImageRead = (PE_COFF_LOADER_READ_FILE) SecImageRead;
+ ImageContext.ImageRead = (PE_COFF_LOADER_READ_FILE)SecImageRead;
- Status = PeCoffLoaderGetImageInfo (&ImageContext);
+ Status = PeCoffLoaderGetImageInfo (&ImageContext);
if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Allocate space in NT (not emulator) memory with ReadWrite and Execute attribute.
// Extra space is for alignment
//
- ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) VirtualAlloc (NULL, (SIZE_T) (ImageContext.ImageSize + (ImageContext.SectionAlignment * 2)), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
+ ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)VirtualAlloc (NULL, (SIZE_T)(ImageContext.ImageSize + (ImageContext.SectionAlignment * 2)), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
if (ImageContext.ImageAddress == 0) {
return EFI_OUT_OF_RESOURCES;
}
+
//
// Align buffer on section boundary
//
@@ -741,7 +752,7 @@ SecPeCoffGetEntryPoint (
return Status;
}
- *EntryPoint = (VOID *)(UINTN)ImageContext.EntryPoint;
+ *EntryPoint = (VOID *)(UINTN)ImageContext.EntryPoint;
return EFI_SUCCESS;
}
@@ -749,11 +760,12 @@ SecPeCoffGetEntryPoint (
EFI_STATUS
EFIAPI
SecImageRead (
- IN VOID *FileHandle,
- IN UINTN FileOffset,
- IN OUT UINTN *ReadSize,
- OUT VOID *Buffer
+ IN VOID *FileHandle,
+ IN UINTN FileOffset,
+ IN OUT UINTN *ReadSize,
+ OUT VOID *Buffer
)
+
/*++
Routine Description:
@@ -770,13 +782,13 @@ Returns:
--*/
{
- CHAR8 *Destination8;
- CHAR8 *Source8;
- UINTN Length;
+ CHAR8 *Destination8;
+ CHAR8 *Source8;
+ UINTN Length;
- Destination8 = Buffer;
- Source8 = (CHAR8 *) ((UINTN) FileHandle + FileOffset);
- Length = *ReadSize;
+ Destination8 = Buffer;
+ Source8 = (CHAR8 *)((UINTN)FileHandle + FileOffset);
+ Length = *ReadSize;
while (Length--) {
*(Destination8++) = *(Source8++);
}
@@ -786,9 +798,10 @@ Returns:
CHAR16 *
AsciiToUnicode (
- IN CHAR8 *Ascii,
- IN UINTN *StrLen OPTIONAL
+ IN CHAR8 *Ascii,
+ IN UINTN *StrLen OPTIONAL
)
+
/*++
Routine Description:
@@ -810,15 +823,16 @@ Returns:
//
// Allocate a buffer for unicode string
//
- for (Index = 0; Ascii[Index] != '\0'; Index++)
- ;
+ for (Index = 0; Ascii[Index] != '\0'; Index++) {
+ }
+
Unicode = malloc ((Index + 1) * sizeof (CHAR16));
if (Unicode == NULL) {
return NULL;
}
for (Index = 0; Ascii[Index] != '\0'; Index++) {
- Unicode[Index] = (CHAR16) Ascii[Index];
+ Unicode[Index] = (CHAR16)Ascii[Index];
}
Unicode[Index] = '\0';
@@ -832,9 +846,10 @@ Returns:
UINTN
CountSeparatorsInString (
- IN CONST CHAR16 *String,
- IN CHAR16 Separator
+ IN CONST CHAR16 *String,
+ IN CHAR16 Separator
)
+
/*++
Routine Description:
@@ -849,7 +864,7 @@ Returns:
--*/
{
- UINTN Count;
+ UINTN Count;
for (Count = 0; *String != '\0'; String++) {
if (*String == Separator) {
@@ -871,8 +886,8 @@ Returns:
--*/
EFI_STATUS
AddModHandle (
- IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
- IN VOID *ModHandle
+ IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
+ IN VOID *ModHandle
)
{
@@ -888,7 +903,7 @@ AddModHandle (
//
Array = mPdbNameModHandleArray;
for (Index = 0; Index < mPdbNameModHandleArraySize; Index++, Array++) {
- if (Array->PdbPointer != NULL && Array->ModHandle == ModHandle) {
+ if ((Array->PdbPointer != NULL) && (Array->ModHandle == ModHandle)) {
return EFI_ALREADY_STARTED;
}
}
@@ -899,9 +914,9 @@ AddModHandle (
//
// Make a copy of the stirng and store the ModHandle
//
- Handle = GetProcessHeap ();
- Size = AsciiStrLen (ImageContext->PdbPointer) + 1;
- Array->PdbPointer = HeapAlloc ( Handle, HEAP_ZERO_MEMORY, Size);
+ Handle = GetProcessHeap ();
+ Size = AsciiStrLen (ImageContext->PdbPointer) + 1;
+ Array->PdbPointer = HeapAlloc (Handle, HEAP_ZERO_MEMORY, Size);
ASSERT (Array->PdbPointer != NULL);
AsciiStrCpyS (Array->PdbPointer, Size, ImageContext->PdbPointer);
@@ -914,17 +929,18 @@ AddModHandle (
// No free space in mPdbNameModHandleArray so grow it by
// MAX_PDB_NAME_TO_MOD_HANDLE_ARRAY_SIZE entires.
//
- PreviousSize = mPdbNameModHandleArraySize * sizeof (PDB_NAME_TO_MOD_HANDLE);
+ PreviousSize = mPdbNameModHandleArraySize * sizeof (PDB_NAME_TO_MOD_HANDLE);
mPdbNameModHandleArraySize += MAX_PDB_NAME_TO_MOD_HANDLE_ARRAY_SIZE;
//
// re-allocate a new buffer and copy the old values to the new locaiton.
//
- TempArray = HeapAlloc (GetProcessHeap (),
- HEAP_ZERO_MEMORY,
- mPdbNameModHandleArraySize * sizeof (PDB_NAME_TO_MOD_HANDLE)
- );
+ TempArray = HeapAlloc (
+ GetProcessHeap (),
+ HEAP_ZERO_MEMORY,
+ mPdbNameModHandleArraySize * sizeof (PDB_NAME_TO_MOD_HANDLE)
+ );
- CopyMem ((VOID *) (UINTN) TempArray, (VOID *) (UINTN)mPdbNameModHandleArray, PreviousSize);
+ CopyMem ((VOID *)(UINTN)TempArray, (VOID *)(UINTN)mPdbNameModHandleArray, PreviousSize);
HeapFree (GetProcessHeap (), 0, mPdbNameModHandleArray);
@@ -947,7 +963,7 @@ AddModHandle (
**/
VOID *
RemoveModHandle (
- IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
{
UINTN Index;
@@ -962,7 +978,7 @@ RemoveModHandle (
Array = mPdbNameModHandleArray;
for (Index = 0; Index < mPdbNameModHandleArraySize; Index++, Array++) {
- if ((Array->PdbPointer != NULL) && (AsciiStrCmp(Array->PdbPointer, ImageContext->PdbPointer) == 0)) {
+ if ((Array->PdbPointer != NULL) && (AsciiStrCmp (Array->PdbPointer, ImageContext->PdbPointer) == 0)) {
//
// If you find a match return it and delete the entry
//
@@ -978,14 +994,14 @@ RemoveModHandle (
VOID
EFIAPI
PeCoffLoaderRelocateImageExtraAction (
- IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
{
- EFI_STATUS Status;
- VOID *DllEntryPoint;
- CHAR16 *DllFileName;
- HMODULE Library;
- UINTN Index;
+ EFI_STATUS Status;
+ VOID *DllEntryPoint;
+ CHAR16 *DllFileName;
+ HMODULE Library;
+ UINTN Index;
ASSERT (ImageContext != NULL);
//
@@ -1003,7 +1019,8 @@ PeCoffLoaderRelocateImageExtraAction (
// Load the DLL if it's not an EBC image.
//
if ((ImageContext->PdbPointer != NULL) &&
- (ImageContext->Machine != EFI_IMAGE_MACHINE_EBC)) {
+ (ImageContext->Machine != EFI_IMAGE_MACHINE_EBC))
+ {
//
// Convert filename from ASCII to Unicode
//
@@ -1012,7 +1029,7 @@ PeCoffLoaderRelocateImageExtraAction (
//
// Check that we have a valid filename
//
- if (Index < 5 || DllFileName[Index - 4] != '.') {
+ if ((Index < 5) || (DllFileName[Index - 4] != '.')) {
free (DllFileName);
//
@@ -1022,12 +1039,13 @@ PeCoffLoaderRelocateImageExtraAction (
//
return;
}
+
//
// Replace .PDB with .DLL on the filename
//
- DllFileName[Index - 3] = 'D';
- DllFileName[Index - 2] = 'L';
- DllFileName[Index - 1] = 'L';
+ DllFileName[Index - 3] = 'D';
+ DllFileName[Index - 2] = 'L';
+ DllFileName[Index - 1] = 'L';
//
// Load the .DLL file into the user process's address space for source
@@ -1043,8 +1061,7 @@ PeCoffLoaderRelocateImageExtraAction (
// checking as the we can point to the PE32 image loaded by Tiano. This
// step is only needed for source level debugging
//
- DllEntryPoint = (VOID *) (UINTN) GetProcAddress (Library, "InitializeDriver");
-
+ DllEntryPoint = (VOID *)(UINTN)GetProcAddress (Library, "InitializeDriver");
}
if ((Library != NULL) && (DllEntryPoint != NULL)) {
@@ -1059,7 +1076,7 @@ PeCoffLoaderRelocateImageExtraAction (
//
// This DLL is not already loaded, so source level debugging is supported.
//
- ImageContext->EntryPoint = (EFI_PHYSICAL_ADDRESS) (UINTN) DllEntryPoint;
+ ImageContext->EntryPoint = (EFI_PHYSICAL_ADDRESS)(UINTN)DllEntryPoint;
SecPrint ("LoadLibraryEx (\n\r %S,\n\r NULL, DONT_RESOLVE_DLL_REFERENCES)\n\r", DllFileName);
}
} else {
@@ -1074,7 +1091,7 @@ VOID
EFIAPI
PeCoffLoaderUnloadImageExtraAction (
IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
-)
+ )
{
VOID *ModHandle;
diff --git a/EmulatorPkg/Win/Host/WinHost.h b/EmulatorPkg/Win/Host/WinHost.h
index b36fea254e..49d42d1ad8 100644
--- a/EmulatorPkg/Win/Host/WinHost.h
+++ b/EmulatorPkg/Win/Host/WinHost.h
@@ -12,6 +12,7 @@ Abstract:
Include file for Windows Host
**/
+
#ifndef _HOST_H_
#define _HOST_H_
@@ -45,17 +46,16 @@ Abstract:
#include <Library/PeCoffExtraActionLib.h>
#include <Library/NetLib.h>
-
-#define TEMPORARY_RAM_SIZE 0x20000
+#define TEMPORARY_RAM_SIZE 0x20000
typedef struct {
- VOID *Address;
- UINTN Size;
+ VOID *Address;
+ UINTN Size;
} NT_FD_INFO;
typedef struct {
- EFI_PHYSICAL_ADDRESS Memory;
- UINT64 Size;
+ EFI_PHYSICAL_ADDRESS Memory;
+ UINT64 Size;
} NT_SYSTEM_MEMORY;
RETURN_STATUS
@@ -63,16 +63,17 @@ EFIAPI
SecPeCoffGetEntryPoint (
IN VOID *Pe32Data,
IN OUT VOID **EntryPoint
-);
+ );
VOID
SecLoadSecCore (
- IN UINTN TemporaryRam,
- IN UINTN TemporaryRamSize,
- IN VOID *BootFirmwareVolumeBase,
- IN UINTN BootFirmwareVolumeSize,
- IN VOID *SecCorePe32File
-)
+ IN UINTN TemporaryRam,
+ IN UINTN TemporaryRamSize,
+ IN VOID *BootFirmwareVolumeBase,
+ IN UINTN BootFirmwareVolumeSize,
+ IN VOID *SecCorePe32File
+ )
+
/*++
Routine Description:
@@ -97,6 +98,7 @@ SecWinNtFdAddress (
IN OUT EFI_PHYSICAL_ADDRESS *FdBase,
IN OUT UINT64 *FdSize
)
+
/*++
Routine Description:
@@ -116,15 +118,15 @@ Returns:
--*/
;
-
EFI_STATUS
EFIAPI
SecImageRead (
- IN VOID *FileHandle,
- IN UINTN FileOffset,
- IN OUT UINTN *ReadSize,
- OUT VOID *Buffer
+ IN VOID *FileHandle,
+ IN UINTN FileOffset,
+ IN OUT UINTN *ReadSize,
+ OUT VOID *Buffer
)
+
/*++
Routine Description:
@@ -147,9 +149,10 @@ Returns:
CHAR16 *
AsciiToUnicode (
- IN CHAR8 *Ascii,
- IN UINTN *StrLen OPTIONAL
+ IN CHAR8 *Ascii,
+ IN UINTN *StrLen OPTIONAL
)
+
/*++
Routine Description:
@@ -170,9 +173,10 @@ Returns:
UINTN
CountSeparatorsInString (
- IN CONST CHAR16 *String,
- IN CHAR16 Separator
+ IN CONST CHAR16 *String,
+ IN CHAR16 Separator
)
+
/*++
Routine Description:
@@ -193,16 +197,18 @@ Returns:
BOOLEAN
EfiSystemMemoryRange (
- IN VOID *MemoryAddress
+ IN VOID *MemoryAddress
);
+
VOID
SecInitializeThunk (
VOID
-);
-extern EMU_THUNK_PROTOCOL gEmuThunkProtocol;
-extern EMU_IO_THUNK_PROTOCOL mWinNtWndThunkIo;
-extern EMU_IO_THUNK_PROTOCOL mWinNtFileSystemThunkIo;
-extern EMU_IO_THUNK_PROTOCOL mWinNtBlockIoThunkIo;
-extern EMU_IO_THUNK_PROTOCOL mWinNtSnpThunkIo;
+ );
+
+extern EMU_THUNK_PROTOCOL gEmuThunkProtocol;
+extern EMU_IO_THUNK_PROTOCOL mWinNtWndThunkIo;
+extern EMU_IO_THUNK_PROTOCOL mWinNtFileSystemThunkIo;
+extern EMU_IO_THUNK_PROTOCOL mWinNtBlockIoThunkIo;
+extern EMU_IO_THUNK_PROTOCOL mWinNtSnpThunkIo;
#endif
diff --git a/EmulatorPkg/Win/Host/WinInclude.h b/EmulatorPkg/Win/Host/WinInclude.h
index 8a9ae7d746..c2b6cfa3d6 100644
--- a/EmulatorPkg/Win/Host/WinInclude.h
+++ b/EmulatorPkg/Win/Host/WinInclude.h
@@ -19,13 +19,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#pragma warning(disable : 4028)
#pragma warning(disable : 4133)
-#define GUID _WINNT_DUP_GUID_____
+#define GUID _WINNT_DUP_GUID_____
#define _LIST_ENTRY _WINNT_DUP_LIST_ENTRY_FORWARD
#define LIST_ENTRY _WINNT_DUP_LIST_ENTRY
#if defined (MDE_CPU_IA32) && (_MSC_VER < 1800)
-#define InterlockedIncrement _WINNT_DUP_InterlockedIncrement
-#define InterlockedDecrement _WINNT_DUP_InterlockedDecrement
-#define InterlockedCompareExchange64 _WINNT_DUP_InterlockedCompareExchange64
+#define InterlockedIncrement _WINNT_DUP_InterlockedIncrement
+#define InterlockedDecrement _WINNT_DUP_InterlockedDecrement
+#define InterlockedCompareExchange64 _WINNT_DUP_InterlockedCompareExchange64
#endif
#undef UNALIGNED
#undef CONST
@@ -36,7 +36,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// It should be removed after the root cause why
// size_t is undefined when go into the line below is found.
#if defined (MDE_CPU_IA32)
-typedef UINT32 size_t ;
+typedef UINT32 size_t;
#endif
#include "windows.h"
@@ -51,7 +51,7 @@ typedef UINT32 size_t ;
#undef InterlockedCompareExchangePointer
#undef CreateEventEx
-#define VOID void
+#define VOID void
//
// Prevent collisions with Windows API name macros that deal with Unicode/Not issues
@@ -66,5 +66,4 @@ typedef UINT32 size_t ;
#pragma warning(default : 4115)
#pragma warning(default : 4201)
-
#endif
diff --git a/EmulatorPkg/Win/Host/WinMemoryAllocationLib.c b/EmulatorPkg/Win/Host/WinMemoryAllocationLib.c
index a29ebddd14..4d972d2c2e 100644
--- a/EmulatorPkg/Win/Host/WinMemoryAllocationLib.c
+++ b/EmulatorPkg/Win/Host/WinMemoryAllocationLib.c
@@ -30,10 +30,9 @@ AllocatePool (
IN UINTN AllocationSize
)
{
- return (VOID*) malloc (AllocationSize);
+ return (VOID *)malloc (AllocationSize);
}
-
/**
Allocates and zeros a buffer of type EfiBootServicesData.
@@ -53,7 +52,7 @@ AllocateZeroPool (
IN UINTN AllocationSize
)
{
- VOID *Buffer;
+ VOID *Buffer;
Buffer = AllocatePool (AllocationSize);
if (Buffer == NULL) {
@@ -65,7 +64,6 @@ AllocateZeroPool (
return Buffer;
}
-
/**
Reallocates a buffer of type EfiBootServicesData.
@@ -95,7 +93,7 @@ ReallocatePool (
IN VOID *OldBuffer OPTIONAL
)
{
- VOID *NewBuffer;
+ VOID *NewBuffer;
NewBuffer = AllocatePool (NewSize);
if (NewBuffer == NULL) {
@@ -143,10 +141,10 @@ AllocateCopyPool (
if (Memory != NULL) {
Memory = CopyMem (Memory, Buffer, AllocationSize);
}
+
return Memory;
}
-
/**
Frees a buffer that was previously allocated with one of the pool allocation functions in the
Memory Allocation Library.
@@ -164,9 +162,8 @@ AllocateCopyPool (
VOID
EFIAPI
FreePool (
- IN VOID *Buffer
+ IN VOID *Buffer
)
{
- free ((void *) Buffer);
+ free ((void *)Buffer);
}
-
diff --git a/EmulatorPkg/Win/Host/WinPacketFilter.c b/EmulatorPkg/Win/Host/WinPacketFilter.c
index 0b751f97e3..21859897c8 100644
--- a/EmulatorPkg/Win/Host/WinPacketFilter.c
+++ b/EmulatorPkg/Win/Host/WinPacketFilter.c
@@ -20,16 +20,16 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#pragma pack(1)
typedef struct _NT_NET_INTERFACE_INFO {
- UINT32 InterfaceIndex;
- EFI_MAC_ADDRESS MacAddr;
+ UINT32 InterfaceIndex;
+ EFI_MAC_ADDRESS MacAddr;
} NT_NET_INTERFACE_INFO;
#pragma pack()
-#define NET_ETHER_HEADER_SIZE 14
-#define MAX_INTERFACE_INFO_NUMBER 16
-#define SNP_MAX_TX_BUFFER_NUM 65536
-#define SNP_TX_BUFFER_INCREASEMENT 32
-#define DEFAULT_SELECTED_NIC_INDEX 0
+#define NET_ETHER_HEADER_SIZE 14
+#define MAX_INTERFACE_INFO_NUMBER 16
+#define SNP_MAX_TX_BUFFER_NUM 65536
+#define SNP_TX_BUFFER_INCREASEMENT 32
+#define DEFAULT_SELECTED_NIC_INDEX 0
//
// Functions in Net Library
@@ -37,8 +37,8 @@ typedef struct _NT_NET_INTERFACE_INFO {
typedef
INT32
(*NT_NET_INITIALIZE) (
- IN OUT UINT32 *InterfaceCount,
- IN OUT NT_NET_INTERFACE_INFO * InterfaceInfoBuffer
+ IN OUT UINT32 *InterfaceCount,
+ IN OUT NT_NET_INTERFACE_INFO *InterfaceInfoBuffer
);
typedef
@@ -50,85 +50,84 @@ INT32
typedef
INT32
(*NT_NET_SET_RECEIVE_FILTER) (
- IN UINT32 Index,
- IN UINT32 EnableFilter,
- IN UINT32 MCastFilterCnt,
- IN EFI_MAC_ADDRESS * MCastFilter
+ IN UINT32 Index,
+ IN UINT32 EnableFilter,
+ IN UINT32 MCastFilterCnt,
+ IN EFI_MAC_ADDRESS *MCastFilter
);
typedef
INT32
(*NT_NET_RECEIVE) (
- IN UINT32 Index,
- IN OUT UINT32 *BufferSize,
- OUT VOID *Buffer
+ IN UINT32 Index,
+ IN OUT UINT32 *BufferSize,
+ OUT VOID *Buffer
);
typedef
INT32
(*NT_NET_TRANSMIT) (
- IN UINT32 Index,
- IN UINT32 HeaderSize,
- IN UINT32 BufferSize,
- IN VOID *Buffer,
- IN EFI_MAC_ADDRESS * SrcAddr,
- IN EFI_MAC_ADDRESS * DestAddr,
- IN UINT16 *Protocol
+ IN UINT32 Index,
+ IN UINT32 HeaderSize,
+ IN UINT32 BufferSize,
+ IN VOID *Buffer,
+ IN EFI_MAC_ADDRESS *SrcAddr,
+ IN EFI_MAC_ADDRESS *DestAddr,
+ IN UINT16 *Protocol
);
typedef struct _NT_NET_UTILITY_TABLE {
- NT_NET_INITIALIZE Initialize;
- NT_NET_FINALIZE Finalize;
- NT_NET_SET_RECEIVE_FILTER SetReceiveFilter;
- NT_NET_RECEIVE Receive;
- NT_NET_TRANSMIT Transmit;
+ NT_NET_INITIALIZE Initialize;
+ NT_NET_FINALIZE Finalize;
+ NT_NET_SET_RECEIVE_FILTER SetReceiveFilter;
+ NT_NET_RECEIVE Receive;
+ NT_NET_TRANSMIT Transmit;
} NT_NET_UTILITY_TABLE;
//
// Instance data for each fake SNP instance
//
-#define WIN_NT_INSTANCE_SIGNATURE SIGNATURE_32 ('N', 'T', 'I', 'S')
+#define WIN_NT_INSTANCE_SIGNATURE SIGNATURE_32 ('N', 'T', 'I', 'S')
typedef struct {
- UINT32 Signature;
+ UINT32 Signature;
//
// Array of the recycled transmit buffer address.
//
- UINT64 *RecycledTxBuf;
+ UINT64 *RecycledTxBuf;
//
// Current number of recycled buffer pointers in RecycledTxBuf.
//
- UINT32 RecycledTxBufCount;
+ UINT32 RecycledTxBufCount;
//
// The maximum number of recycled buffer pointers in RecycledTxBuf.
//
- UINT32 MaxRecycledTxBuf;
- EFI_SIMPLE_NETWORK_MODE Mode;
- NT_NET_INTERFACE_INFO InterfaceInfo;
+ UINT32 MaxRecycledTxBuf;
+ EFI_SIMPLE_NETWORK_MODE Mode;
+ NT_NET_INTERFACE_INFO InterfaceInfo;
} WIN_NT_INSTANCE_DATA;
//
// Instance data for each SNP private instance
//
-#define WIN_NT_SIMPLE_NETWORK_PRIVATE_SIGNATURE SIGNATURE_32 ('N', 'T', 's', 'n')
+#define WIN_NT_SIMPLE_NETWORK_PRIVATE_SIGNATURE SIGNATURE_32 ('N', 'T', 's', 'n')
typedef struct {
- UINTN Signature;
- EMU_IO_THUNK_PROTOCOL *Thunk;
- EMU_SNP_PROTOCOL EmuSnp;
- EFI_SIMPLE_NETWORK_MODE *Mode;
- HMODULE NetworkLibraryHandle;
- NT_NET_UTILITY_TABLE NtNetUtilityTable;
- WIN_NT_INSTANCE_DATA Instance;
+ UINTN Signature;
+ EMU_IO_THUNK_PROTOCOL *Thunk;
+ EMU_SNP_PROTOCOL EmuSnp;
+ EFI_SIMPLE_NETWORK_MODE *Mode;
+ HMODULE NetworkLibraryHandle;
+ NT_NET_UTILITY_TABLE NtNetUtilityTable;
+ WIN_NT_INSTANCE_DATA Instance;
} WIN_NT_SNP_PRIVATE;
#define WIN_NT_SNP_PRIVATE_DATA_FROM_THIS(a) \
CR(a, WIN_NT_SNP_PRIVATE, EmuSnp, WIN_NT_SIMPLE_NETWORK_PRIVATE_SIGNATURE)
-
/**
Register storage for SNP Mode.
@@ -145,7 +144,7 @@ WinNtSnpCreateMapping (
IN EFI_SIMPLE_NETWORK_MODE *Mode
)
{
- WIN_NT_SNP_PRIVATE *Private;
+ WIN_NT_SNP_PRIVATE *Private;
Private = WIN_NT_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -181,7 +180,7 @@ WinNtSnpStart (
IN EMU_SNP_PROTOCOL *This
)
{
- WIN_NT_SNP_PRIVATE *Private;
+ WIN_NT_SNP_PRIVATE *Private;
Private = WIN_NT_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -221,7 +220,7 @@ WinNtSnpStop (
IN EMU_SNP_PROTOCOL *This
)
{
- WIN_NT_SNP_PRIVATE *Private;
+ WIN_NT_SNP_PRIVATE *Private;
Private = WIN_NT_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -271,12 +270,12 @@ WinNtSnpStop (
**/
EFI_STATUS
WinNtSnpInitialize (
- IN EMU_SNP_PROTOCOL *This,
- IN UINTN ExtraRxBufferSize OPTIONAL,
- IN UINTN ExtraTxBufferSize OPTIONAL
+ IN EMU_SNP_PROTOCOL *This,
+ IN UINTN ExtraRxBufferSize OPTIONAL,
+ IN UINTN ExtraTxBufferSize OPTIONAL
)
{
- WIN_NT_SNP_PRIVATE *Private;
+ WIN_NT_SNP_PRIVATE *Private;
Private = WIN_NT_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -293,7 +292,7 @@ WinNtSnpInitialize (
break;
}
- Private->Mode->MCastFilterCount = 0;
+ Private->Mode->MCastFilterCount = 0;
Private->Mode->ReceiveFilterSetting = 0;
ZeroMem (Private->Mode->MCastFilter, sizeof (Private->Mode->MCastFilter));
@@ -320,11 +319,11 @@ WinNtSnpInitialize (
**/
EFI_STATUS
WinNtSnpReset (
- IN EMU_SNP_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EMU_SNP_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
)
{
- WIN_NT_SNP_PRIVATE *Private;
+ WIN_NT_SNP_PRIVATE *Private;
Private = WIN_NT_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -362,7 +361,7 @@ WinNtSnpShutdown (
IN EMU_SNP_PROTOCOL *This
)
{
- WIN_NT_SNP_PRIVATE *Private;
+ WIN_NT_SNP_PRIVATE *Private;
Private = WIN_NT_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -382,7 +381,7 @@ WinNtSnpShutdown (
Private->Mode->State = EfiSimpleNetworkStarted;
Private->Mode->ReceiveFilterSetting = 0;
- Private->Mode->MCastFilterCount = 0;
+ Private->Mode->MCastFilterCount = 0;
ZeroMem (Private->Mode->MCastFilter, sizeof (Private->Mode->MCastFilter));
return EFI_SUCCESS;
@@ -414,25 +413,25 @@ WinNtSnpShutdown (
**/
EFI_STATUS
WinNtSnpReceiveFilters (
- IN EMU_SNP_PROTOCOL *This,
- IN UINT32 Enable,
- IN UINT32 Disable,
- IN BOOLEAN ResetMCastFilter,
- IN UINTN MCastFilterCnt OPTIONAL,
- IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL
+ IN EMU_SNP_PROTOCOL *This,
+ IN UINT32 Enable,
+ IN UINT32 Disable,
+ IN BOOLEAN ResetMCastFilter,
+ IN UINTN MCastFilterCnt OPTIONAL,
+ IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL
)
{
- WIN_NT_SNP_PRIVATE *Private;
- INT32 ReturnValue;
+ WIN_NT_SNP_PRIVATE *Private;
+ INT32 ReturnValue;
Private = WIN_NT_SNP_PRIVATE_DATA_FROM_THIS (This);
ReturnValue = Private->NtNetUtilityTable.SetReceiveFilter (
- Private->Instance.InterfaceInfo.InterfaceIndex,
- Enable,
- (UINT32)MCastFilterCnt,
- MCastFilter
- );
+ Private->Instance.InterfaceInfo.InterfaceIndex,
+ Enable,
+ (UINT32)MCastFilterCnt,
+ MCastFilter
+ );
if (ReturnValue <= 0) {
return EFI_DEVICE_ERROR;
@@ -458,12 +457,12 @@ WinNtSnpReceiveFilters (
**/
EFI_STATUS
WinNtSnpStationAddress (
- IN EMU_SNP_PROTOCOL *This,
- IN BOOLEAN Reset,
- IN EFI_MAC_ADDRESS *New OPTIONAL
+ IN EMU_SNP_PROTOCOL *This,
+ IN BOOLEAN Reset,
+ IN EFI_MAC_ADDRESS *New OPTIONAL
)
{
- WIN_NT_SNP_PRIVATE *Private;
+ WIN_NT_SNP_PRIVATE *Private;
Private = WIN_NT_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -493,13 +492,13 @@ WinNtSnpStationAddress (
**/
EFI_STATUS
WinNtSnpStatistics (
- IN EMU_SNP_PROTOCOL *This,
- IN BOOLEAN Reset,
- IN OUT UINTN *StatisticsSize OPTIONAL,
- OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL
+ IN EMU_SNP_PROTOCOL *This,
+ IN BOOLEAN Reset,
+ IN OUT UINTN *StatisticsSize OPTIONAL,
+ OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL
)
{
- WIN_NT_SNP_PRIVATE *Private;
+ WIN_NT_SNP_PRIVATE *Private;
Private = WIN_NT_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -529,13 +528,13 @@ WinNtSnpStatistics (
**/
EFI_STATUS
WinNtSnpMCastIpToMac (
- IN EMU_SNP_PROTOCOL *This,
- IN BOOLEAN IPv6,
- IN EFI_IP_ADDRESS *IP,
- OUT EFI_MAC_ADDRESS *MAC
+ IN EMU_SNP_PROTOCOL *This,
+ IN BOOLEAN IPv6,
+ IN EFI_IP_ADDRESS *IP,
+ OUT EFI_MAC_ADDRESS *MAC
)
{
- WIN_NT_SNP_PRIVATE *Private;
+ WIN_NT_SNP_PRIVATE *Private;
Private = WIN_NT_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -564,14 +563,14 @@ WinNtSnpMCastIpToMac (
**/
EFI_STATUS
WinNtSnpNvData (
- IN EMU_SNP_PROTOCOL *This,
- IN BOOLEAN ReadWrite,
- IN UINTN Offset,
- IN UINTN BufferSize,
- IN OUT VOID *Buffer
+ IN EMU_SNP_PROTOCOL *This,
+ IN BOOLEAN ReadWrite,
+ IN UINTN Offset,
+ IN UINTN BufferSize,
+ IN OUT VOID *Buffer
)
{
- WIN_NT_SNP_PRIVATE *Private;
+ WIN_NT_SNP_PRIVATE *Private;
Private = WIN_NT_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -605,21 +604,21 @@ WinNtSnpNvData (
**/
EFI_STATUS
WinNtSnpGetStatus (
- IN EMU_SNP_PROTOCOL *This,
- OUT UINT32 *InterruptStatus OPTIONAL,
- OUT VOID **TxBuf OPTIONAL
+ IN EMU_SNP_PROTOCOL *This,
+ OUT UINT32 *InterruptStatus OPTIONAL,
+ OUT VOID **TxBuf OPTIONAL
)
{
- WIN_NT_SNP_PRIVATE *Private;
+ WIN_NT_SNP_PRIVATE *Private;
Private = WIN_NT_SNP_PRIVATE_DATA_FROM_THIS (This);
if (TxBuf != NULL) {
if (Private->Instance.RecycledTxBufCount != 0) {
- Private->Instance.RecycledTxBufCount --;
- *((UINT8 **) TxBuf) = (UINT8 *) (UINTN)Private->Instance.RecycledTxBuf[Private->Instance.RecycledTxBufCount];
+ Private->Instance.RecycledTxBufCount--;
+ *((UINT8 **)TxBuf) = (UINT8 *)(UINTN)Private->Instance.RecycledTxBuf[Private->Instance.RecycledTxBufCount];
} else {
- *((UINT8 **) TxBuf) = NULL;
+ *((UINT8 **)TxBuf) = NULL;
}
}
@@ -665,18 +664,18 @@ WinNtSnpGetStatus (
**/
EFI_STATUS
WinNtSnpTransmit (
- IN EMU_SNP_PROTOCOL *This,
- IN UINTN HeaderSize,
- IN UINTN BufferSize,
- IN VOID *Buffer,
- IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
- IN EFI_MAC_ADDRESS *DestAddr OPTIONAL,
- IN UINT16 *Protocol OPTIONAL
+ IN EMU_SNP_PROTOCOL *This,
+ IN UINTN HeaderSize,
+ IN UINTN BufferSize,
+ IN VOID *Buffer,
+ IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
+ IN EFI_MAC_ADDRESS *DestAddr OPTIONAL,
+ IN UINT16 *Protocol OPTIONAL
)
{
- WIN_NT_SNP_PRIVATE *Private;
- INT32 ReturnValue;
- UINT64 *Tmp;
+ WIN_NT_SNP_PRIVATE *Private;
+ INT32 ReturnValue;
+ UINT64 *Tmp;
Private = WIN_NT_SNP_PRIVATE_DATA_FROM_THIS (This);
@@ -685,14 +684,14 @@ WinNtSnpTransmit (
}
ReturnValue = Private->NtNetUtilityTable.Transmit (
- Private->Instance.InterfaceInfo.InterfaceIndex,
- (UINT32)HeaderSize,
- (UINT32)BufferSize,
- Buffer,
- SrcAddr,
- DestAddr,
- Protocol
- );
+ Private->Instance.InterfaceInfo.InterfaceIndex,
+ (UINT32)HeaderSize,
+ (UINT32)BufferSize,
+ Buffer,
+ SrcAddr,
+ DestAddr,
+ Protocol
+ );
if (ReturnValue < 0) {
return EFI_DEVICE_ERROR;
@@ -702,16 +701,17 @@ WinNtSnpTransmit (
}
if (Private->Instance.RecycledTxBufCount < Private->Instance.MaxRecycledTxBuf) {
- Private->Instance.RecycledTxBuf[Private->Instance.RecycledTxBufCount] = (UINT64) Buffer;
- Private->Instance.RecycledTxBufCount ++;
+ Private->Instance.RecycledTxBuf[Private->Instance.RecycledTxBufCount] = (UINT64)Buffer;
+ Private->Instance.RecycledTxBufCount++;
} else {
Tmp = malloc (sizeof (UINT64) * (Private->Instance.MaxRecycledTxBuf + SNP_TX_BUFFER_INCREASEMENT));
if (Tmp == NULL) {
return EFI_DEVICE_ERROR;
}
+
CopyMem (Tmp, Private->Instance.RecycledTxBuf, sizeof (UINT64) * Private->Instance.RecycledTxBufCount);
free (Private->Instance.RecycledTxBuf);
- Private->Instance.RecycledTxBuf = Tmp;
+ Private->Instance.RecycledTxBuf = Tmp;
Private->Instance.MaxRecycledTxBuf += SNP_TX_BUFFER_INCREASEMENT;
}
}
@@ -753,30 +753,30 @@ WinNtSnpTransmit (
**/
EFI_STATUS
WinNtSnpReceive (
- IN EMU_SNP_PROTOCOL *This,
- OUT UINTN *HeaderSize OPTIONAL,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer,
- OUT EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
- OUT EFI_MAC_ADDRESS *DestAddr OPTIONAL,
- OUT UINT16 *Protocol OPTIONAL
+ IN EMU_SNP_PROTOCOL *This,
+ OUT UINTN *HeaderSize OPTIONAL,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer,
+ OUT EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
+ OUT EFI_MAC_ADDRESS *DestAddr OPTIONAL,
+ OUT UINT16 *Protocol OPTIONAL
)
{
- WIN_NT_SNP_PRIVATE *Private;
- INT32 ReturnValue;
- UINTN BufSize;
+ WIN_NT_SNP_PRIVATE *Private;
+ INT32 ReturnValue;
+ UINTN BufSize;
Private = WIN_NT_SNP_PRIVATE_DATA_FROM_THIS (This);
- BufSize = *BufferSize;
+ BufSize = *BufferSize;
ASSERT (Private->NtNetUtilityTable.Receive != NULL);
ReturnValue = Private->NtNetUtilityTable.Receive (
- Private->Instance.InterfaceInfo.InterfaceIndex,
- BufferSize,
- Buffer
- );
+ Private->Instance.InterfaceInfo.InterfaceIndex,
+ BufferSize,
+ Buffer
+ );
if (ReturnValue < 0) {
if (ReturnValue == -100) {
@@ -794,16 +794,16 @@ WinNtSnpReceive (
if (SrcAddr != NULL) {
ZeroMem (SrcAddr, sizeof (EFI_MAC_ADDRESS));
- CopyMem (SrcAddr, ((UINT8 *) Buffer) + 6, 6);
+ CopyMem (SrcAddr, ((UINT8 *)Buffer) + 6, 6);
}
if (DestAddr != NULL) {
ZeroMem (DestAddr, sizeof (EFI_MAC_ADDRESS));
- CopyMem (DestAddr, ((UINT8 *) Buffer), 6);
+ CopyMem (DestAddr, ((UINT8 *)Buffer), 6);
}
if (Protocol != NULL) {
- *Protocol = NTOHS (*((UINT16 *) (((UINT8 *) Buffer) + 12)));
+ *Protocol = NTOHS (*((UINT16 *)(((UINT8 *)Buffer) + 12)));
}
return (*BufferSize <= BufSize) ? EFI_SUCCESS : EFI_BUFFER_TOO_SMALL;
@@ -821,27 +821,27 @@ WinNtSnpReceive (
**/
EFI_STATUS
WinNtInitializeInstanceData (
- IN OUT WIN_NT_INSTANCE_DATA *Instance,
- IN NT_NET_INTERFACE_INFO *NetInfo
+ IN OUT WIN_NT_INSTANCE_DATA *Instance,
+ IN NT_NET_INTERFACE_INFO *NetInfo
)
{
- if (Instance == NULL || NetInfo == NULL) {
+ if ((Instance == NULL) || (NetInfo == NULL)) {
return EFI_INVALID_PARAMETER;
}
ZeroMem (Instance, sizeof (WIN_NT_INSTANCE_DATA));
- Instance->Signature = WIN_NT_INSTANCE_SIGNATURE;
- Instance->RecycledTxBufCount = 0;
- Instance->MaxRecycledTxBuf = 32;
- Instance->Mode.State = EfiSimpleNetworkInitialized;
- Instance->Mode.HwAddressSize = NET_ETHER_ADDR_LEN;
- Instance->Mode.MediaHeaderSize = NET_ETHER_HEADER_SIZE;
- Instance->Mode.MaxPacketSize = 1500;
- Instance->Mode.MaxMCastFilterCount = MAX_MCAST_FILTER_CNT;
- Instance->Mode.IfType = NET_IFTYPE_ETHERNET;
+ Instance->Signature = WIN_NT_INSTANCE_SIGNATURE;
+ Instance->RecycledTxBufCount = 0;
+ Instance->MaxRecycledTxBuf = 32;
+ Instance->Mode.State = EfiSimpleNetworkInitialized;
+ Instance->Mode.HwAddressSize = NET_ETHER_ADDR_LEN;
+ Instance->Mode.MediaHeaderSize = NET_ETHER_HEADER_SIZE;
+ Instance->Mode.MaxPacketSize = 1500;
+ Instance->Mode.MaxMCastFilterCount = MAX_MCAST_FILTER_CNT;
+ Instance->Mode.IfType = NET_IFTYPE_ETHERNET;
Instance->Mode.MediaPresentSupported = TRUE;
- Instance->Mode.MediaPresent = TRUE;
+ Instance->Mode.MediaPresent = TRUE;
//
// Allocate the RecycledTxBuf.
@@ -856,7 +856,6 @@ WinNtInitializeInstanceData (
//
CopyMem (&Instance->InterfaceInfo, NetInfo, sizeof (Instance->InterfaceInfo));
-
//
// Set broadcast address
//
@@ -865,8 +864,8 @@ WinNtInitializeInstanceData (
//
// Copy Current/PermanentAddress MAC address
//
- CopyMem (&Instance->Mode.CurrentAddress, &Instance->InterfaceInfo.MacAddr, sizeof(Instance->Mode.CurrentAddress));
- CopyMem (&Instance->Mode.PermanentAddress, &Instance->InterfaceInfo.MacAddr, sizeof(Instance->Mode.PermanentAddress));
+ CopyMem (&Instance->Mode.CurrentAddress, &Instance->InterfaceInfo.MacAddr, sizeof (Instance->Mode.CurrentAddress));
+ CopyMem (&Instance->Mode.PermanentAddress, &Instance->InterfaceInfo.MacAddr, sizeof (Instance->Mode.PermanentAddress));
//
// Since the fake SNP is based on a real NIC, to avoid conflict with the host
@@ -892,20 +891,20 @@ WinNtInitializeInstanceData (
**/
EFI_STATUS
WintNtInitializeNetUtilityData (
- IN OUT WIN_NT_SNP_PRIVATE *Private,
+ IN OUT WIN_NT_SNP_PRIVATE *Private,
IN UINT8 ActiveInstance
)
{
- EFI_STATUS Status;
- CHAR16 *DllFileNameU;
- INT32 ReturnValue;
- BOOLEAN NetUtilityLibInitDone;
- NT_NET_INTERFACE_INFO NetInterfaceInfoBuffer[MAX_INTERFACE_INFO_NUMBER];
- UINT32 InterfaceCount;
- UINT8 ActiveInterfaceIndex;
+ EFI_STATUS Status;
+ CHAR16 *DllFileNameU;
+ INT32 ReturnValue;
+ BOOLEAN NetUtilityLibInitDone;
+ NT_NET_INTERFACE_INFO NetInterfaceInfoBuffer[MAX_INTERFACE_INFO_NUMBER];
+ UINT32 InterfaceCount;
+ UINT8 ActiveInterfaceIndex;
if (Private == NULL) {
- return EFI_INVALID_PARAMETER;
+ return EFI_INVALID_PARAMETER;
}
NetUtilityLibInitDone = FALSE;
@@ -920,31 +919,31 @@ WintNtInitializeNetUtilityData (
return EFI_NOT_FOUND;
}
- Private->NtNetUtilityTable.Initialize = (NT_NET_INITIALIZE) GetProcAddress (Private->NetworkLibraryHandle, NETWORK_LIBRARY_INITIALIZE);
+ Private->NtNetUtilityTable.Initialize = (NT_NET_INITIALIZE)GetProcAddress (Private->NetworkLibraryHandle, NETWORK_LIBRARY_INITIALIZE);
if (NULL == Private->NtNetUtilityTable.Initialize) {
Status = EFI_NOT_FOUND;
goto ErrorReturn;
}
- Private->NtNetUtilityTable.Finalize = (NT_NET_FINALIZE) GetProcAddress (Private->NetworkLibraryHandle, NETWORK_LIBRARY_FINALIZE);
+ Private->NtNetUtilityTable.Finalize = (NT_NET_FINALIZE)GetProcAddress (Private->NetworkLibraryHandle, NETWORK_LIBRARY_FINALIZE);
if (NULL == Private->NtNetUtilityTable.Finalize) {
Status = EFI_NOT_FOUND;
goto ErrorReturn;
}
- Private->NtNetUtilityTable.SetReceiveFilter = (NT_NET_SET_RECEIVE_FILTER) GetProcAddress (Private->NetworkLibraryHandle, NETWORK_LIBRARY_SET_RCV_FILTER);
+ Private->NtNetUtilityTable.SetReceiveFilter = (NT_NET_SET_RECEIVE_FILTER)GetProcAddress (Private->NetworkLibraryHandle, NETWORK_LIBRARY_SET_RCV_FILTER);
if (NULL == Private->NtNetUtilityTable.SetReceiveFilter) {
Status = EFI_NOT_FOUND;
goto ErrorReturn;
}
- Private->NtNetUtilityTable.Receive = (NT_NET_RECEIVE) GetProcAddress (Private->NetworkLibraryHandle, NETWORK_LIBRARY_RECEIVE);
+ Private->NtNetUtilityTable.Receive = (NT_NET_RECEIVE)GetProcAddress (Private->NetworkLibraryHandle, NETWORK_LIBRARY_RECEIVE);
if (NULL == Private->NtNetUtilityTable.Receive) {
Status = EFI_NOT_FOUND;
goto ErrorReturn;
}
- Private->NtNetUtilityTable.Transmit = (NT_NET_TRANSMIT) GetProcAddress (Private->NetworkLibraryHandle, NETWORK_LIBRARY_TRANSMIT);
+ Private->NtNetUtilityTable.Transmit = (NT_NET_TRANSMIT)GetProcAddress (Private->NetworkLibraryHandle, NETWORK_LIBRARY_TRANSMIT);
if (NULL == Private->NtNetUtilityTable.Transmit) {
Status = EFI_NOT_FOUND;
goto ErrorReturn;
@@ -979,7 +978,7 @@ WintNtInitializeNetUtilityData (
//
Status = WinNtInitializeInstanceData (&Private->Instance, &NetInterfaceInfoBuffer[ActiveInterfaceIndex]);
if (EFI_ERROR (Status)) {
- goto ErrorReturn;
+ goto ErrorReturn;
}
return EFI_SUCCESS;
@@ -987,7 +986,7 @@ WintNtInitializeNetUtilityData (
ErrorReturn:
if (Private->Instance.RecycledTxBuf != NULL) {
- free (Private->Instance.RecycledTxBuf);
+ free (Private->Instance.RecycledTxBuf);
}
if (NetUtilityLibInitDone) {
@@ -1011,7 +1010,7 @@ ErrorReturn:
**/
EFI_STATUS
WintNtReleaseNetUtilityData (
- IN OUT WIN_NT_SNP_PRIVATE *Private
+ IN OUT WIN_NT_SNP_PRIVATE *Private
)
{
if (Private == NULL) {
@@ -1019,7 +1018,7 @@ WintNtReleaseNetUtilityData (
}
if (Private->Instance.RecycledTxBuf != NULL) {
- free (Private->Instance.RecycledTxBuf);
+ free (Private->Instance.RecycledTxBuf);
}
if (Private->NtNetUtilityTable.Finalize != NULL) {
@@ -1031,7 +1030,7 @@ WintNtReleaseNetUtilityData (
return EFI_SUCCESS;
}
-EMU_SNP_PROTOCOL mWinNtSnpProtocol = {
+EMU_SNP_PROTOCOL mWinNtSnpProtocol = {
WinNtSnpCreateMapping,
WinNtSnpStart,
WinNtSnpStop,
@@ -1061,7 +1060,7 @@ EMU_SNP_PROTOCOL mWinNtSnpProtocol = {
**/
EFI_STATUS
WinNtSnpThunkOpen (
- IN EMU_IO_THUNK_PROTOCOL *This
+ IN EMU_IO_THUNK_PROTOCOL *This
)
{
WIN_NT_SNP_PRIVATE *Private;
@@ -1089,7 +1088,7 @@ WinNtSnpThunkOpen (
This->Interface = &Private->EmuSnp;
This->Private = Private;
- if (This->ConfigString != NULL && This->ConfigString[0] != '\0') {
+ if ((This->ConfigString != NULL) && (This->ConfigString[0] != '\0')) {
HostInterfaceIndex = (UINT8)StrDecimalToUintn (This->ConfigString);
}
@@ -1108,7 +1107,7 @@ WinNtSnpThunkOpen (
**/
EFI_STATUS
WinNtSnpThunkClose (
- IN EMU_IO_THUNK_PROTOCOL *This
+ IN EMU_IO_THUNK_PROTOCOL *This
)
{
WIN_NT_SNP_PRIVATE *Private;
@@ -1124,7 +1123,7 @@ WinNtSnpThunkClose (
return EFI_SUCCESS;
}
-EMU_IO_THUNK_PROTOCOL mWinNtSnpThunkIo = {
+EMU_IO_THUNK_PROTOCOL mWinNtSnpThunkIo = {
&gEmuSnpProtocolGuid,
NULL,
NULL,
diff --git a/EmulatorPkg/Win/Host/WinThunk.c b/EmulatorPkg/Win/Host/WinThunk.c
index a77be2a64b..008e5755db 100644
--- a/EmulatorPkg/Win/Host/WinThunk.c
+++ b/EmulatorPkg/Win/Host/WinThunk.c
@@ -32,33 +32,32 @@ Abstract:
UINTN
SecWriteStdErr (
- IN UINT8 *Buffer,
- IN UINTN NumberOfBytes
+ IN UINT8 *Buffer,
+ IN UINTN NumberOfBytes
)
{
- BOOL Success;
- DWORD CharCount;
+ BOOL Success;
+ DWORD CharCount;
CharCount = (DWORD)NumberOfBytes;
- Success = WriteFile (
- GetStdHandle (STD_ERROR_HANDLE),
- Buffer,
- CharCount,
- &CharCount,
- NULL
- );
+ Success = WriteFile (
+ GetStdHandle (STD_ERROR_HANDLE),
+ Buffer,
+ CharCount,
+ &CharCount,
+ NULL
+ );
return Success ? CharCount : 0;
}
-
EFI_STATUS
SecConfigStdIn (
VOID
)
{
- BOOL Success;
- DWORD Mode;
+ BOOL Success;
+ DWORD Mode;
Success = GetConsoleMode (GetStdHandle (STD_INPUT_HANDLE), &Mode);
if (Success) {
@@ -67,17 +66,17 @@ SecConfigStdIn (
//
Mode &= ~(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT | ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT);
-#if defined(NTDDI_VERSION) && defined (NTDDI_WIN10_TH2) && (NTDDI_VERSION > NTDDI_WIN10_TH2)
+ #if defined (NTDDI_VERSION) && defined (NTDDI_WIN10_TH2) && (NTDDI_VERSION > NTDDI_WIN10_TH2)
//
// Enable virtual terminal input for Win10 above TH2
//
Mode |= ENABLE_VIRTUAL_TERMINAL_INPUT;
-#endif
+ #endif
Success = SetConsoleMode (GetStdHandle (STD_INPUT_HANDLE), Mode);
}
-#if defined(NTDDI_VERSION) && defined (NTDDI_WIN10_TH2) && (NTDDI_VERSION > NTDDI_WIN10_TH2)
+ #if defined (NTDDI_VERSION) && defined (NTDDI_WIN10_TH2) && (NTDDI_VERSION > NTDDI_WIN10_TH2)
//
// Enable terminal mode for Win10 above TH2
//
@@ -85,32 +84,33 @@ SecConfigStdIn (
Success = GetConsoleMode (GetStdHandle (STD_OUTPUT_HANDLE), &Mode);
if (Success) {
Success = SetConsoleMode (
- GetStdHandle (STD_OUTPUT_HANDLE),
- Mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING | DISABLE_NEWLINE_AUTO_RETURN
- );
+ GetStdHandle (STD_OUTPUT_HANDLE),
+ Mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING | DISABLE_NEWLINE_AUTO_RETURN
+ );
}
}
-#endif
+
+ #endif
return Success ? EFI_SUCCESS : EFI_DEVICE_ERROR;
}
UINTN
SecWriteStdOut (
- IN UINT8 *Buffer,
- IN UINTN NumberOfBytes
+ IN UINT8 *Buffer,
+ IN UINTN NumberOfBytes
)
{
- BOOL Success;
- DWORD CharCount;
+ BOOL Success;
+ DWORD CharCount;
CharCount = (DWORD)NumberOfBytes;
- Success = WriteFile (
- GetStdHandle (STD_OUTPUT_HANDLE),
- Buffer,
- CharCount,
- &CharCount,
- NULL
- );
+ Success = WriteFile (
+ GetStdHandle (STD_OUTPUT_HANDLE),
+ Buffer,
+ CharCount,
+ &CharCount,
+ NULL
+ );
return Success ? CharCount : 0;
}
@@ -120,34 +120,35 @@ SecPollStdIn (
VOID
)
{
- BOOL Success;
- INPUT_RECORD Record;
- DWORD RecordNum;
+ BOOL Success;
+ INPUT_RECORD Record;
+ DWORD RecordNum;
do {
Success = GetNumberOfConsoleInputEvents (GetStdHandle (STD_INPUT_HANDLE), &RecordNum);
if (!Success || (RecordNum == 0)) {
break;
}
+
Success = PeekConsoleInput (
- GetStdHandle (STD_INPUT_HANDLE),
- &Record,
- 1,
- &RecordNum
- );
+ GetStdHandle (STD_INPUT_HANDLE),
+ &Record,
+ 1,
+ &RecordNum
+ );
if (Success && (RecordNum == 1)) {
- if (Record.EventType == KEY_EVENT && Record.Event.KeyEvent.bKeyDown) {
+ if ((Record.EventType == KEY_EVENT) && Record.Event.KeyEvent.bKeyDown) {
return TRUE;
} else {
//
// Consume the non-key event.
//
Success = ReadConsoleInput (
- GetStdHandle (STD_INPUT_HANDLE),
- &Record,
- 1,
- &RecordNum
- );
+ GetStdHandle (STD_INPUT_HANDLE),
+ &Record,
+ 1,
+ &RecordNum
+ );
}
}
} while (Success);
@@ -157,37 +158,38 @@ SecPollStdIn (
UINTN
SecReadStdIn (
- IN UINT8 *Buffer,
- IN UINTN NumberOfBytes
+ IN UINT8 *Buffer,
+ IN UINTN NumberOfBytes
)
{
- BOOL Success;
- INPUT_RECORD Record;
- DWORD RecordNum;
- UINTN BytesReturn;
+ BOOL Success;
+ INPUT_RECORD Record;
+ DWORD RecordNum;
+ UINTN BytesReturn;
if (!SecPollStdIn ()) {
return 0;
}
+
Success = ReadConsoleInput (
- GetStdHandle (STD_INPUT_HANDLE),
- &Record,
- 1,
- &RecordNum
- );
+ GetStdHandle (STD_INPUT_HANDLE),
+ &Record,
+ 1,
+ &RecordNum
+ );
ASSERT (Success && (RecordNum == 1) && (Record.EventType == KEY_EVENT) && (Record.Event.KeyEvent.bKeyDown));
NumberOfBytes = MIN (Record.Event.KeyEvent.wRepeatCount, NumberOfBytes);
BytesReturn = NumberOfBytes;
while (NumberOfBytes-- != 0) {
Buffer[NumberOfBytes] = Record.Event.KeyEvent.uChar.AsciiChar;
}
+
return BytesReturn;
}
-
VOID *
SecAlloc (
- IN UINTN Size
+ IN UINTN Size
)
{
return malloc ((size_t)Size);
@@ -195,7 +197,7 @@ SecAlloc (
BOOLEAN
SecFree (
- IN VOID *Ptr
+ IN VOID *Ptr
)
{
if (EfiSystemMemoryRange (Ptr)) {
@@ -208,13 +210,11 @@ SecFree (
return TRUE;
}
-
-
//
// Define a global that we can use to shut down the NT timer thread when
// the timer is canceled.
//
-BOOLEAN mCancelTimerThread = FALSE;
+BOOLEAN mCancelTimerThread = FALSE;
//
// The notification function to call on every timer interrupt
@@ -224,41 +224,40 @@ EMU_SET_TIMER_CALLBACK *mTimerNotifyFunction = NULL;
//
// The thread handle for this driver
//
-HANDLE mNtMainThreadHandle;
+HANDLE mNtMainThreadHandle;
//
// The timer value from the last timer interrupt
//
-UINT32 mNtLastTick;
+UINT32 mNtLastTick;
//
// Critical section used to update varibles shared between the main thread and
// the timer interrupt thread.
//
-CRITICAL_SECTION mNtCriticalSection;
+CRITICAL_SECTION mNtCriticalSection;
//
// Worker Functions
//
-UINT mMMTimerThreadID = 0;
+UINT mMMTimerThreadID = 0;
-volatile BOOLEAN mInterruptEnabled = FALSE;
+volatile BOOLEAN mInterruptEnabled = FALSE;
VOID
CALLBACK
MMTimerThread (
- UINT wTimerID,
- UINT msg,
- DWORD dwUser,
- DWORD dw1,
- DWORD dw2
-)
+ UINT wTimerID,
+ UINT msg,
+ DWORD dwUser,
+ DWORD dw1,
+ DWORD dw2
+ )
{
- UINT32 CurrentTick;
- UINT32 Delta;
+ UINT32 CurrentTick;
+ UINT32 Delta;
if (!mCancelTimerThread) {
-
//
// Suspend the main thread until we are done.
// Enter the critical section before suspending
@@ -306,14 +305,13 @@ MMTimerThread (
// Get the current system tick
//
CurrentTick = GetTickCount ();
- Delta = CurrentTick - mNtLastTick;
+ Delta = CurrentTick - mNtLastTick;
mNtLastTick = CurrentTick;
//
// If delay was more then 1 second, ignore it (probably debugging case)
//
if (Delta < 1000) {
-
//
// Only invoke the callback function if a Non-NULL handler has been
// registered. Assume all other handlers are legal.
@@ -332,18 +330,17 @@ MMTimerThread (
timeKillEvent (wTimerID);
mMMTimerThreadID = 0;
}
-
}
VOID
SecSetTimer (
IN UINT64 TimerPeriod,
IN EMU_SET_TIMER_CALLBACK Callback
-)
+ )
{
//
-// If TimerPeriod is 0, then the timer thread should be canceled
-//
+ // If TimerPeriod is 0, then the timer thread should be canceled
+ //
if (TimerPeriod == 0) {
//
// Cancel the timer thread
@@ -384,23 +381,24 @@ SecSetTimer (
SetThreadPriority (
GetCurrentThread (),
THREAD_PRIORITY_HIGHEST
- );
+ );
mMMTimerThreadID = timeSetEvent (
- (UINT)TimerPeriod,
- 0,
- MMTimerThread,
- (DWORD_PTR)NULL,
- TIME_PERIODIC | TIME_KILL_SYNCHRONOUS | TIME_CALLBACK_FUNCTION
- );
+ (UINT)TimerPeriod,
+ 0,
+ MMTimerThread,
+ (DWORD_PTR)NULL,
+ TIME_PERIODIC | TIME_KILL_SYNCHRONOUS | TIME_CALLBACK_FUNCTION
+ );
}
+
mTimerNotifyFunction = Callback;
}
VOID
SecInitializeThunk (
VOID
-)
+ )
{
InitializeCriticalSection (&mNtCriticalSection);
@@ -412,7 +410,7 @@ SecInitializeThunk (
0,
FALSE,
DUPLICATE_SAME_ACCESS
- );
+ );
}
VOID
@@ -423,7 +421,6 @@ SecEnableInterrupt (
mInterruptEnabled = TRUE;
}
-
VOID
SecDisableInterrupt (
VOID
@@ -432,7 +429,6 @@ SecDisableInterrupt (
mInterruptEnabled = FALSE;
}
-
UINT64
SecQueryPerformanceFrequency (
VOID
@@ -450,17 +446,14 @@ SecQueryPerformanceCounter (
return 0;
}
-
-
VOID
SecSleep (
- IN UINT64 Nanoseconds
+ IN UINT64 Nanoseconds
)
{
Sleep ((DWORD)DivU64x32 (Nanoseconds, 1000000));
}
-
VOID
SecCpuSleep (
VOID
@@ -469,40 +462,38 @@ SecCpuSleep (
Sleep (1);
}
-
VOID
SecExit (
- UINTN Status
+ UINTN Status
)
{
exit ((int)Status);
}
-
VOID
SecGetTime (
- OUT EFI_TIME *Time,
- OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL
+ OUT EFI_TIME *Time,
+ OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL
)
{
- SYSTEMTIME SystemTime;
- TIME_ZONE_INFORMATION TimeZone;
+ SYSTEMTIME SystemTime;
+ TIME_ZONE_INFORMATION TimeZone;
GetLocalTime (&SystemTime);
GetTimeZoneInformation (&TimeZone);
- Time->Year = (UINT16)SystemTime.wYear;
- Time->Month = (UINT8)SystemTime.wMonth;
- Time->Day = (UINT8)SystemTime.wDay;
- Time->Hour = (UINT8)SystemTime.wHour;
- Time->Minute = (UINT8)SystemTime.wMinute;
- Time->Second = (UINT8)SystemTime.wSecond;
+ Time->Year = (UINT16)SystemTime.wYear;
+ Time->Month = (UINT8)SystemTime.wMonth;
+ Time->Day = (UINT8)SystemTime.wDay;
+ Time->Hour = (UINT8)SystemTime.wHour;
+ Time->Minute = (UINT8)SystemTime.wMinute;
+ Time->Second = (UINT8)SystemTime.wSecond;
Time->Nanosecond = (UINT32)(SystemTime.wMilliseconds * 1000000);
- Time->TimeZone = (INT16)TimeZone.Bias;
+ Time->TimeZone = (INT16)TimeZone.Bias;
if (Capabilities != NULL) {
Capabilities->Resolution = 1;
- Capabilities->Accuracy = 50000000;
+ Capabilities->Accuracy = 50000000;
Capabilities->SetsToZero = FALSE;
}
@@ -514,30 +505,30 @@ SecGetTime (
EFI_STATUS
SecSetTime (
- IN EFI_TIME *Time
+ IN EFI_TIME *Time
)
{
- TIME_ZONE_INFORMATION TimeZone;
- SYSTEMTIME SystemTime;
- BOOL Flag;
+ TIME_ZONE_INFORMATION TimeZone;
+ SYSTEMTIME SystemTime;
+ BOOL Flag;
//
// Set Daylight savings time information and Time Zone
//
GetTimeZoneInformation (&TimeZone);
TimeZone.StandardDate.wMonth = Time->Daylight;
- TimeZone.Bias = Time->TimeZone;
- Flag = SetTimeZoneInformation (&TimeZone);
+ TimeZone.Bias = Time->TimeZone;
+ Flag = SetTimeZoneInformation (&TimeZone);
if (!Flag) {
return EFI_DEVICE_ERROR;
}
- SystemTime.wYear = Time->Year;
- SystemTime.wMonth = Time->Month;
- SystemTime.wDay = Time->Day;
- SystemTime.wHour = Time->Hour;
- SystemTime.wMinute = Time->Minute;
- SystemTime.wSecond = Time->Second;
+ SystemTime.wYear = Time->Year;
+ SystemTime.wMonth = Time->Month;
+ SystemTime.wDay = Time->Day;
+ SystemTime.wHour = Time->Hour;
+ SystemTime.wMinute = Time->Minute;
+ SystemTime.wSecond = Time->Second;
SystemTime.wMilliseconds = (INT16)(Time->Nanosecond / 1000000);
Flag = SetLocalTime (&SystemTime);
@@ -549,7 +540,7 @@ SecSetTime (
}
}
-EMU_THUNK_PROTOCOL gEmuThunkProtocol = {
+EMU_THUNK_PROTOCOL gEmuThunkProtocol = {
SecWriteStdErr,
SecConfigStdIn,
SecWriteStdOut,
@@ -574,7 +565,5 @@ EMU_THUNK_PROTOCOL gEmuThunkProtocol = {
GetNextThunkProtocol
};
-
#pragma warning(default : 4996)
#pragma warning(default : 4232)
-