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>
This commit is contained in:
Michael Kubacki
2021-12-05 14:53:57 -08:00
committed by mergify[bot]
parent e7108d0e96
commit a550d468a6
111 changed files with 6170 additions and 6345 deletions

View File

@ -37,9 +37,9 @@ GetArg (
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
gImageHandle, gImageHandle,
&gEfiShellParametersProtocolGuid, &gEfiShellParametersProtocolGuid,
(VOID**)&ShellParameters (VOID **)&ShellParameters
); );
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
@ -94,8 +94,8 @@ UefiMain (
EFI_IPv4_ADDRESS RedfishServiceIpMask; EFI_IPv4_ADDRESS RedfishServiceIpMask;
UINTN RedfishServiceIpPort; UINTN RedfishServiceIpPort;
Status = GetArg(); Status = GetArg ();
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
@ -104,39 +104,41 @@ UefiMain (
// RedfishPlatformConfig.efi -s HostIpAddress HostIpMask RedfishServiceIpAddress RedfishServiceIpMask RedfishServiceIpPort // RedfishPlatformConfig.efi -s HostIpAddress HostIpMask RedfishServiceIpAddress RedfishServiceIpMask RedfishServiceIpPort
// RedfishPlatformConfig.efi -a RedfishServiceIpAddress RedfishServiceIpMask RedfishServiceIpPort // RedfishPlatformConfig.efi -a RedfishServiceIpAddress RedfishServiceIpMask RedfishServiceIpPort
// //
if (Argc != 7 && Argc != 5) { if ((Argc != 7) && (Argc != 5)) {
PrintHelp ();
PrintHelp();
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
if (StrCmp(Argv[1], L"-s") == 0) { if (StrCmp (Argv[1], L"-s") == 0) {
HostIpAssignmentType = 1; HostIpAssignmentType = 1;
Status = NetLibStrToIp4 (Argv[2], &HostIpAddress); Status = NetLibStrToIp4 (Argv[2], &HostIpAddress);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
PrintHelp(); PrintHelp ();
return Status; return Status;
} }
Status = NetLibStrToIp4 (Argv[3], &HostIpMask); Status = NetLibStrToIp4 (Argv[3], &HostIpMask);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
PrintHelp(); PrintHelp ();
return Status; return Status;
} }
Status = NetLibStrToIp4 (Argv[4], &RedfishServiceIpAddress); Status = NetLibStrToIp4 (Argv[4], &RedfishServiceIpAddress);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
PrintHelp(); PrintHelp ();
return Status; return Status;
} }
Status = NetLibStrToIp4 (Argv[5], &RedfishServiceIpMask); Status = NetLibStrToIp4 (Argv[5], &RedfishServiceIpMask);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
PrintHelp(); PrintHelp ();
return Status; return Status;
} }
ReturnStatus = StrDecimalToUintnS (Argv[6], NULL, &RedfishServiceIpPort); ReturnStatus = StrDecimalToUintnS (Argv[6], NULL, &RedfishServiceIpPort);
if (RETURN_ERROR (ReturnStatus)) { if (RETURN_ERROR (ReturnStatus)) {
PrintHelp(); PrintHelp ();
return Status; return Status;
} }
@ -214,24 +216,24 @@ UefiMain (
Print (L"RedfishServiceIpMask: %s has been set Successfully!\n", Argv[5]); Print (L"RedfishServiceIpMask: %s has been set Successfully!\n", Argv[5]);
Print (L"RedfishServiceIpPort: %s has been set Successfully!\n", Argv[6]); Print (L"RedfishServiceIpPort: %s has been set Successfully!\n", Argv[6]);
Print (L"Please Restart!\n"); Print (L"Please Restart!\n");
} else if (StrCmp (Argv[1], L"-a") == 0) {
} else if (StrCmp(Argv[1], L"-a") == 0) {
HostIpAssignmentType = 3; HostIpAssignmentType = 3;
Status = NetLibStrToIp4 (Argv[2], &RedfishServiceIpAddress); Status = NetLibStrToIp4 (Argv[2], &RedfishServiceIpAddress);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
PrintHelp(); PrintHelp ();
return Status; return Status;
} }
Status = NetLibStrToIp4 (Argv[3], &RedfishServiceIpMask); Status = NetLibStrToIp4 (Argv[3], &RedfishServiceIpMask);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
PrintHelp(); PrintHelp ();
return Status; return Status;
} }
ReturnStatus = StrDecimalToUintnS (Argv[4], NULL, &RedfishServiceIpPort); ReturnStatus = StrDecimalToUintnS (Argv[4], NULL, &RedfishServiceIpPort);
if (RETURN_ERROR (ReturnStatus)) { if (RETURN_ERROR (ReturnStatus)) {
PrintHelp(); PrintHelp ();
return Status; return Status;
} }
@ -285,12 +287,10 @@ UefiMain (
Print (L"RedfishServiceIpMask: %s has been set Successfully!\n", Argv[3]); Print (L"RedfishServiceIpMask: %s has been set Successfully!\n", Argv[3]);
Print (L"RedfishServiceIpPort: %s has been set Successfully!\n", Argv[4]); Print (L"RedfishServiceIpPort: %s has been set Successfully!\n", Argv[4]);
Print (L"Please Restart!\n"); Print (L"Please Restart!\n");
} else if (StrCmp(Argv[1], L"-h") == 0 || StrCmp(Argv[1], L"-help") == 0) { } else if ((StrCmp (Argv[1], L"-h") == 0) || (StrCmp (Argv[1], L"-help") == 0)) {
PrintHelp ();
PrintHelp();
} else { } else {
PrintHelp ();
PrintHelp();
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }

View File

@ -24,6 +24,7 @@ PeimInitializeAutoScanPei (
IN EFI_PEI_FILE_HANDLE FileHandle, IN EFI_PEI_FILE_HANDLE FileHandle,
IN CONST EFI_PEI_SERVICES **PeiServices IN CONST EFI_PEI_SERVICES **PeiServices
) )
/*++ /*++
Routine Description: Routine Description:
@ -46,7 +47,6 @@ Returns:
UINTN Index; UINTN Index;
EFI_RESOURCE_ATTRIBUTE_TYPE Attributes; EFI_RESOURCE_ATTRIBUTE_TYPE Attributes;
DEBUG ((DEBUG_ERROR, "Emu Autoscan PEIM Loaded\n")); DEBUG ((DEBUG_ERROR, "Emu Autoscan PEIM Loaded\n"));
// //
@ -91,6 +91,7 @@ Returns:
MemorySize MemorySize
); );
} }
Index++; Index++;
} while (!EFI_ERROR (Status)); } while (!EFI_ERROR (Status));

View File

@ -6,8 +6,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
// //
// The package level header files this module uses // 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/PcdLib.h>
#include <Library/PeiServicesLib.h> #include <Library/PeiServicesLib.h>
// //
// The protocols, PPI and GUID defintions for this module // 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/DebugLib.h>
#include <Library/PeimEntryPoint.h> #include <Library/PeimEntryPoint.h>
// //
// Module globals // Module globals
// //
@ -50,6 +46,7 @@ InitializeBootMode (
IN EFI_PEI_FILE_HANDLE FileHandle, IN EFI_PEI_FILE_HANDLE FileHandle,
IN CONST EFI_PEI_SERVICES **PeiServices IN CONST EFI_PEI_SERVICES **PeiServices
) )
/*++ /*++
Routine Description: Routine Description:

View File

@ -42,7 +42,7 @@ CPU_ARCH_PROTOCOL_PRIVATE mCpuTemplate = {
#define EFI_CPU_DATA_MAXIMUM_LENGTH 0x100 #define EFI_CPU_DATA_MAXIMUM_LENGTH 0x100
SMBIOS_TABLE_TYPE4 mCpuSmbiosType4 = { SMBIOS_TABLE_TYPE4 mCpuSmbiosType4 = {
{ EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION, sizeof (SMBIOS_TABLE_TYPE4), 0}, { EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION, sizeof (SMBIOS_TABLE_TYPE4), 0 },
1, // Socket String 1, // Socket String
ProcessorOther, // ProcessorType; ///< The enumeration value from PROCESSOR_TYPE_DATA. ProcessorOther, // ProcessorType; ///< The enumeration value from PROCESSOR_TYPE_DATA.
ProcessorFamilyOther, // ProcessorFamily; ///< The enumeration value from PROCESSOR_FAMILY_DATA. ProcessorFamilyOther, // ProcessorFamily; ///< The enumeration value from PROCESSOR_FAMILY_DATA.
@ -129,7 +129,6 @@ CHAR8 *mCpuSmbiosType4Strings[] = {
NULL NULL
}; };
/** /**
Create SMBIOS record. Create SMBIOS record.
@ -190,10 +189,12 @@ LogSmbiosData (
StringSize = AsciiStrSize (StringPack[Index]); StringSize = AsciiStrSize (StringPack[Index]);
Size += StringSize; Size += StringSize;
} }
if (StringPack[0] == NULL) { if (StringPack[0] == NULL) {
// At least a double null is required // At least a double null is required
Size += 1; Size += 1;
} }
// Don't forget the terminating double null // Don't forget the terminating double null
Size += 1; Size += 1;
} }
@ -203,6 +204,7 @@ LogSmbiosData (
if (Record == NULL) { if (Record == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
CopyMem (Record, Template, Template->Length); CopyMem (Record, Template, Template->Length);
// Append string pack // Append string pack
@ -212,6 +214,7 @@ LogSmbiosData (
CopyMem (Str, StringPack[Index], StringSize); CopyMem (Str, StringPack[Index], StringSize);
Str += StringSize; Str += StringSize;
} }
*Str = 0; *Str = 0;
SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED; SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
@ -227,17 +230,14 @@ LogSmbiosData (
return Status; return Status;
} }
VOID VOID
CpuUpdateSmbios ( CpuUpdateSmbios (
IN UINTN MaxCpus IN UINTN MaxCpus
) )
{ {
mCpuSmbiosType4.CoreCount = (UINT8) MaxCpus; mCpuSmbiosType4.CoreCount = (UINT8)MaxCpus;
mCpuSmbiosType4.EnabledCoreCount = (UINT8) MaxCpus; mCpuSmbiosType4.EnabledCoreCount = (UINT8)MaxCpus;
mCpuSmbiosType4.ThreadCount = (UINT8) MaxCpus; mCpuSmbiosType4.ThreadCount = (UINT8)MaxCpus;
// //
// The value of 1234 is fake value for CPU frequency // The value of 1234 is fake value for CPU frequency
// //
@ -245,7 +245,6 @@ CpuUpdateSmbios (
LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER *)&mCpuSmbiosType4, mCpuSmbiosType4Strings); LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER *)&mCpuSmbiosType4, mCpuSmbiosType4Strings);
} }
// //
// Service routines for the driver // Service routines for the driver
// //
@ -265,6 +264,7 @@ EmuFlushCpuDataCache (
// //
return EFI_SUCCESS; return EFI_SUCCESS;
} }
// //
// Other flush types are not supported by Emu emulator // Other flush types are not supported by Emu emulator
// //
@ -338,9 +338,10 @@ EmuRegisterInterruptHandler (
// //
// Do parameter checking for EFI spec conformance // Do parameter checking for EFI spec conformance
// //
if (InterruptType < 0 || InterruptType > 0xff) { if ((InterruptType < 0) || (InterruptType > 0xff)) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
// //
// Do nothing for Emu emulation // Do nothing for Emu emulation
// //
@ -373,7 +374,6 @@ EmuGetTimerValue (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EmuSetMemoryAttributes ( EmuSetMemoryAttributes (
@ -396,9 +396,6 @@ EmuSetMemoryAttributes (
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
/** /**
Callback function for idle events. Callback function for idle events.
@ -417,7 +414,6 @@ IdleLoopEventCallback (
gEmuThunk->CpuSleep (); gEmuThunk->CpuSleep ();
} }
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
InitializeCpu ( InitializeCpu (
@ -444,7 +440,6 @@ InitializeCpu (
CpuUpdateSmbios (MaxCpu); CpuUpdateSmbios (MaxCpu);
Status = gBS->CreateEventEx ( Status = gBS->CreateEventEx (
EVT_NOTIFY_SIGNAL, EVT_NOTIFY_SIGNAL,
TPL_NOTIFY, TPL_NOTIFY,
@ -455,11 +450,12 @@ InitializeCpu (
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
Status = gBS->InstallMultipleProtocolInterfaces ( Status = gBS->InstallMultipleProtocolInterfaces (
&mCpuTemplate.Handle, &mCpuTemplate.Handle,
&gEfiCpuArchProtocolGuid, &mCpuTemplate.Cpu, &gEfiCpuArchProtocolGuid,
&gEfiCpuIo2ProtocolGuid, &mCpuTemplate.CpuIo, &mCpuTemplate.Cpu,
&gEfiCpuIo2ProtocolGuid,
&mCpuTemplate.CpuIo,
NULL NULL
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);

View File

@ -10,7 +10,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _CPU_ARCHITECTURAL_PROTOCOL_DRIVER_H_ #ifndef _CPU_ARCHITECTURAL_PROTOCOL_DRIVER_H_
#define _CPU_ARCHITECTURAL_PROTOCOL_DRIVER_H_ #define _CPU_ARCHITECTURAL_PROTOCOL_DRIVER_H_
#include <PiDxe.h> #include <PiDxe.h>
#include <IndustryStandard/SmBios.h> #include <IndustryStandard/SmBios.h>
@ -32,8 +31,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/UefiLib.h> #include <Library/UefiLib.h>
#include <Library/PcdLib.h> #include <Library/PcdLib.h>
// //
// Internal Data Structures // Internal Data Structures
// //
@ -50,7 +47,6 @@ typedef struct {
// Local Data for CPU interface goes here // Local Data for CPU interface goes here
// //
BOOLEAN InterruptState; BOOLEAN InterruptState;
} CPU_ARCH_PROTOCOL_PRIVATE; } CPU_ARCH_PROTOCOL_PRIVATE;
#define CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS(a) \ #define CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS(a) \
@ -60,8 +56,6 @@ typedef struct {
CPU_ARCH_PROT_PRIVATE_SIGNATURE \ CPU_ARCH_PROT_PRIVATE_SIGNATURE \
) )
typedef enum { typedef enum {
CPU_STATE_IDLE, CPU_STATE_IDLE,
CPU_STATE_BLOCKED, CPU_STATE_BLOCKED,
@ -70,7 +64,6 @@ typedef enum {
CPU_STATE_FINISHED CPU_STATE_FINISHED
} PROCESSOR_STATE; } PROCESSOR_STATE;
// //
// Define Individual Processor Data block. // Define Individual Processor Data block.
// //
@ -84,7 +77,6 @@ typedef struct {
EFI_EVENT CheckThisAPEvent; EFI_EVENT CheckThisAPEvent;
} PROCESSOR_DATA_BLOCK; } PROCESSOR_DATA_BLOCK;
// //
// Define MP data block which consumes individual processor block. // Define MP data block which consumes individual processor block.
// //
@ -106,10 +98,6 @@ typedef struct {
BOOLEAN TimeoutActive; BOOLEAN TimeoutActive;
} MP_SYSTEM_DATA; } MP_SYSTEM_DATA;
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
CpuMemoryServiceRead ( CpuMemoryServiceRead (
@ -232,5 +220,4 @@ CpuMpServicesWhoAmI (
extern EFI_MP_SERVICES_PROTOCOL mMpServicesTemplate; extern EFI_MP_SERVICES_PROTOCOL mMpServicesTemplate;
#endif #endif

View File

@ -47,6 +47,7 @@ CpuMemoryServiceRead (
IN UINTN Count, IN UINTN Count,
IN OUT VOID *Buffer IN OUT VOID *Buffer
) )
/*++ /*++
Routine Description: Routine Description:
@ -101,6 +102,7 @@ CpuMemoryServiceWrite (
IN UINTN Count, IN UINTN Count,
IN OUT VOID *Buffer IN OUT VOID *Buffer
) )
/*++ /*++
Routine Description: Routine Description:
@ -154,6 +156,7 @@ CpuIoServiceRead (
IN UINTN Count, IN UINTN Count,
IN OUT VOID *UserBuffer IN OUT VOID *UserBuffer
) )
/*++ /*++
Routine Description: Routine Description:
@ -186,7 +189,7 @@ Returns:
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
Address = (UINTN) UserAddress; Address = (UINTN)UserAddress;
if (Width >= EfiCpuIoWidthMaximum) { if (Width >= EfiCpuIoWidthMaximum) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
@ -212,6 +215,7 @@ CpuIoServiceWrite (
IN UINTN Count, IN UINTN Count,
IN OUT VOID *UserBuffer IN OUT VOID *UserBuffer
) )
/*++ /*++
Routine Description: Routine Description:
@ -248,7 +252,7 @@ Returns:
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
Address = (UINTN) UserAddress; Address = (UINTN)UserAddress;
if (Width >= EfiCpuIoWidthMaximum) { if (Width >= EfiCpuIoWidthMaximum) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
@ -265,7 +269,6 @@ Returns:
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/*++ /*++
Routine Description: Routine Description:
@ -304,7 +307,7 @@ CpuIoCheckAddressRange (
// //
// For FiFo type, the target address won't increase during the access, so treat count as 1 // 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; Count = 1;
} }
@ -314,11 +317,9 @@ CpuIoCheckAddressRange (
} }
AlignMask = (1 << Width) - 1; AlignMask = (1 << Width) - 1;
if ((UINTN) Buffer & AlignMask) { if ((UINTN)Buffer & AlignMask) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -37,14 +37,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "CpuDriver.h" #include "CpuDriver.h"
MP_SYSTEM_DATA gMPSystem; MP_SYSTEM_DATA gMPSystem;
EMU_THREAD_THUNK_PROTOCOL *gThread = NULL; EMU_THREAD_THUNK_PROTOCOL *gThread = NULL;
EFI_EVENT gReadToBootEvent; EFI_EVENT gReadToBootEvent;
BOOLEAN gReadToBoot = FALSE; BOOLEAN gReadToBoot = FALSE;
UINTN gPollInterval; UINTN gPollInterval;
BOOLEAN BOOLEAN
IsBSP ( IsBSP (
VOID VOID
@ -61,7 +59,6 @@ IsBSP (
return (gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag & PROCESSOR_AS_BSP_BIT) != 0; return (gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag & PROCESSOR_AS_BSP_BIT) != 0;
} }
VOID VOID
SetApProcedure ( SetApProcedure (
IN PROCESSOR_DATA_BLOCK *Processor, IN PROCESSOR_DATA_BLOCK *Processor,
@ -75,7 +72,6 @@ SetApProcedure (
gThread->MutexUnlock (Processor->ProcedureLock); gThread->MutexUnlock (Processor->ProcedureLock);
} }
EFI_STATUS EFI_STATUS
GetNextBlockedNumber ( GetNextBlockedNumber (
OUT UINTN *NextNumber OUT UINTN *NextNumber
@ -121,11 +117,12 @@ CalculateAndStallInterval (
{ {
UINTN StallTime; UINTN StallTime;
if (Timeout < gPollInterval && Timeout != 0) { if ((Timeout < gPollInterval) && (Timeout != 0)) {
StallTime = Timeout; StallTime = Timeout;
} else { } else {
StallTime = gPollInterval; StallTime = gPollInterval;
} }
gBS->Stall (StallTime); gBS->Stall (StallTime);
return StallTime; return StallTime;
@ -188,8 +185,6 @@ CpuMpServicesGetNumberOfProcessors (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Gets detailed MP-related information on the requested processor at the 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. instant this call is made. This service may only be called from the BSP.
@ -240,7 +235,6 @@ CpuMpServicesGetProcessorInfo (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
This service executes a caller provided function on all enabled APs. APs can 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 run either simultaneously or one at a time in sequence. This service supports
@ -397,7 +391,6 @@ CpuMpServicesStartupAllAps (
PROCESSOR_STATE ProcessorState; PROCESSOR_STATE ProcessorState;
UINTN Timeout; UINTN Timeout;
if (!IsBSP ()) { if (!IsBSP ()) {
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
@ -425,12 +418,14 @@ CpuMpServicesStartupAllAps (
// Skip Disabled processors // Skip Disabled processors
continue; continue;
} }
gThread->MutexLock(ProcessorData->StateLock);
gThread->MutexLock (ProcessorData->StateLock);
if (ProcessorData->State != CPU_STATE_IDLE) { if (ProcessorData->State != CPU_STATE_IDLE) {
gThread->MutexUnlock (ProcessorData->StateLock); gThread->MutexUnlock (ProcessorData->StateLock);
return EFI_NOT_READY; return EFI_NOT_READY;
} }
gThread->MutexUnlock(ProcessorData->StateLock);
gThread->MutexUnlock (ProcessorData->StateLock);
} }
if (FailedCpuList != NULL) { if (FailedCpuList != NULL) {
@ -438,6 +433,7 @@ CpuMpServicesStartupAllAps (
if (gMPSystem.FailedList == NULL) { if (gMPSystem.FailedList == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
SetMemN (gMPSystem.FailedList, (gMPSystem.NumberOfProcessors + 1) * sizeof (UINTN), END_OF_CPU_LIST); SetMemN (gMPSystem.FailedList, (gMPSystem.NumberOfProcessors + 1) * sizeof (UINTN), END_OF_CPU_LIST);
gMPSystem.FailedListIndex = 0; gMPSystem.FailedListIndex = 0;
*FailedCpuList = gMPSystem.FailedList; *FailedCpuList = gMPSystem.FailedList;
@ -472,7 +468,7 @@ CpuMpServicesStartupAllAps (
// state 1 by 1, until the previous 1 finished its task // state 1 by 1, until the previous 1 finished its task
// if not "SingleThread", all APs are put to ready state from the beginning // 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); ASSERT (ProcessorData->State == CPU_STATE_IDLE);
ProcessorData->State = APInitialState; ProcessorData->State = APInitialState;
gThread->MutexUnlock (ProcessorData->StateLock); gThread->MutexUnlock (ProcessorData->StateLock);
@ -519,7 +515,6 @@ CpuMpServicesStartupAllAps (
gPollInterval gPollInterval
); );
return Status; return Status;
} }
while (TRUE) { while (TRUE) {
@ -590,7 +585,6 @@ Done:
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
This service lets the caller get one enabled AP to execute a caller-provided 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 function. The caller can request the BSP to either wait for the completion
@ -711,12 +705,13 @@ CpuMpServicesStartupThisAP (
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
gThread->MutexLock(gMPSystem.ProcessorData[ProcessorNumber].StateLock); gThread->MutexLock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);
if (gMPSystem.ProcessorData[ProcessorNumber].State != CPU_STATE_IDLE) { if (gMPSystem.ProcessorData[ProcessorNumber].State != CPU_STATE_IDLE) {
gThread->MutexUnlock(gMPSystem.ProcessorData[ProcessorNumber].StateLock); gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);
return EFI_NOT_READY; return EFI_NOT_READY;
} }
gThread->MutexUnlock(gMPSystem.ProcessorData[ProcessorNumber].StateLock);
gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);
if ((WaitEvent != NULL) && gReadToBoot) { if ((WaitEvent != NULL) && gReadToBoot) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
@ -759,10 +754,8 @@ CpuMpServicesStartupThisAP (
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
This service switches the requested AP to be the BSP from that point onward. 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 This service changes the BSP for all purposes. This call can only be performed
@ -829,6 +822,7 @@ CpuMpServicesSwitchBSP (
break; break;
} }
} }
ASSERT (Index != gMPSystem.NumberOfProcessors); ASSERT (Index != gMPSystem.NumberOfProcessors);
gThread->MutexLock (gMPSystem.ProcessorData[ProcessorNumber].StateLock); gThread->MutexLock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);
@ -836,6 +830,7 @@ CpuMpServicesSwitchBSP (
gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock); gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);
return EFI_NOT_READY; return EFI_NOT_READY;
} }
gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock); gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);
// Skip for now as we need switch a bunch of stack stuff around and it's complex // 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; return EFI_NOT_READY;
} }
/** /**
This service lets the caller enable or disable an AP from this point onward. This service lets the caller enable or disable an AP from this point onward.
This service may only be called from the BSP. This service may only be called from the BSP.
@ -911,17 +905,20 @@ CpuMpServicesEnableDisableAP (
gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock); gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock); gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);
if (EnableAP) { if (EnableAP) {
if ((gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag & PROCESSOR_ENABLED_BIT) == 0 ) { if ((gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag & PROCESSOR_ENABLED_BIT) == 0 ) {
gMPSystem.NumberOfEnabledProcessors++; gMPSystem.NumberOfEnabledProcessors++;
} }
gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag |= PROCESSOR_ENABLED_BIT; gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag |= PROCESSOR_ENABLED_BIT;
} else { } else {
if ((gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag & PROCESSOR_ENABLED_BIT) == PROCESSOR_ENABLED_BIT ) { if ((gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag & PROCESSOR_ENABLED_BIT) == PROCESSOR_ENABLED_BIT ) {
gMPSystem.NumberOfEnabledProcessors--; gMPSystem.NumberOfEnabledProcessors--;
} }
gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag &= ~PROCESSOR_ENABLED_BIT; gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag &= ~PROCESSOR_ENABLED_BIT;
} }
@ -933,7 +930,6 @@ CpuMpServicesEnableDisableAP (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
This return the handle number for the calling processor. This service may be This return the handle number for the calling processor. This service may be
called from the BSP and APs. called from the BSP and APs.
@ -983,8 +979,6 @@ CpuMpServicesWhoAmI (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EFI_MP_SERVICES_PROTOCOL mMpServicesTemplate = { EFI_MP_SERVICES_PROTOCOL mMpServicesTemplate = {
CpuMpServicesGetNumberOfProcessors, CpuMpServicesGetNumberOfProcessors,
CpuMpServicesGetProcessorInfo, CpuMpServicesGetProcessorInfo,
@ -995,8 +989,6 @@ EFI_MP_SERVICES_PROTOCOL mMpServicesTemplate = {
CpuMpServicesWhoAmI CpuMpServicesWhoAmI
}; };
/*++ /*++
If timeout occurs in StartupAllAps(), a timer is set, which invokes this If timeout occurs in StartupAllAps(), a timer is set, which invokes this
procedure periodically to check whether all APs have finished. procedure periodically to check whether all APs have finished.
@ -1041,9 +1033,10 @@ CpuCheckAllAPsStatus (
// So, try lock it. If we can get it, cool, do our thing. // So, try lock it. If we can get it, cool, do our thing.
// otherwise, just dump out & try again on the next iteration. // otherwise, just dump out & try again on the next iteration.
Status = gThread->MutexTryLock (ProcessorData->StateLock); Status = gThread->MutexTryLock (ProcessorData->StateLock);
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
return; return;
} }
ProcessorState = ProcessorData->State; ProcessorState = ProcessorData->State;
gThread->MutexUnlock (ProcessorData->StateLock); gThread->MutexUnlock (ProcessorData->StateLock);
@ -1073,7 +1066,7 @@ CpuCheckAllAPsStatus (
} }
} }
if (gMPSystem.TimeoutActive && gMPSystem.Timeout == 0) { if (gMPSystem.TimeoutActive && (gMPSystem.Timeout == 0)) {
// //
// Timeout // Timeout
// //
@ -1092,9 +1085,10 @@ CpuCheckAllAPsStatus (
// Mark the // Mark the
Status = gThread->MutexTryLock (ProcessorData->StateLock); Status = gThread->MutexTryLock (ProcessorData->StateLock);
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
return; return;
} }
ProcessorState = ProcessorData->State; ProcessorState = ProcessorData->State;
gThread->MutexUnlock (ProcessorData->StateLock); gThread->MutexUnlock (ProcessorData->StateLock);
@ -1104,17 +1098,20 @@ CpuCheckAllAPsStatus (
if (gMPSystem.FailedList[Cpu] == END_OF_CPU_LIST) { if (gMPSystem.FailedList[Cpu] == END_OF_CPU_LIST) {
break; break;
} }
if (gMPSystem.FailedList[ProcessorNumber] == Cpu) { if (gMPSystem.FailedList[ProcessorNumber] == Cpu) {
Found = TRUE; Found = TRUE;
break; break;
} }
} }
if (!Found) { if (!Found) {
gMPSystem.FailedList[gMPSystem.FailedListIndex++] = Cpu; gMPSystem.FailedList[gMPSystem.FailedListIndex++] = Cpu;
} }
} }
} }
} }
// Force terminal exit // Force terminal exit
gMPSystem.FinishCount = gMPSystem.StartCount; gMPSystem.FinishCount = gMPSystem.StartCount;
} }
@ -1138,7 +1135,7 @@ CpuCheckAllAPsStatus (
Status = gBS->SignalEvent (gMPSystem.WaitEvent); Status = gBS->SignalEvent (gMPSystem.WaitEvent);
return ; return;
} }
VOID VOID
@ -1152,7 +1149,7 @@ CpuCheckThisAPStatus (
PROCESSOR_DATA_BLOCK *ProcessorData; PROCESSOR_DATA_BLOCK *ProcessorData;
PROCESSOR_STATE ProcessorState; PROCESSOR_STATE ProcessorState;
ProcessorData = (PROCESSOR_DATA_BLOCK *) Context; ProcessorData = (PROCESSOR_DATA_BLOCK *)Context;
// //
// This is an Interrupt Service routine. // This is an Interrupt Service routine.
@ -1162,9 +1159,10 @@ CpuCheckThisAPStatus (
// otherwise, just dump out & try again on the next iteration. // otherwise, just dump out & try again on the next iteration.
// //
Status = gThread->MutexTryLock (ProcessorData->StateLock); Status = gThread->MutexTryLock (ProcessorData->StateLock);
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
return; return;
} }
ProcessorState = ProcessorData->State; ProcessorState = ProcessorData->State;
gThread->MutexUnlock (ProcessorData->StateLock); gThread->MutexUnlock (ProcessorData->StateLock);
@ -1180,10 +1178,9 @@ CpuCheckThisAPStatus (
gThread->MutexUnlock (ProcessorData->StateLock); gThread->MutexUnlock (ProcessorData->StateLock);
} }
return ; return;
} }
/*++ /*++
This function is called by all processors (both BSP and AP) once and collects MP related data This function is called by all processors (both BSP and AP) once and collects MP related data
@ -1205,7 +1202,7 @@ FillInProcessorInformation (
gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag |= PROCESSOR_AS_BSP_BIT; 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.Core = 0;
gMPSystem.ProcessorData[ProcessorNumber].Info.Location.Thread = 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;
@ -1267,7 +1264,6 @@ CpuDriverApIdolLoop (
return 0; return 0;
} }
EFI_STATUS EFI_STATUS
InitializeMpSystemData ( InitializeMpSystemData (
IN UINTN NumberOfProcessors IN UINTN NumberOfProcessors
@ -1276,7 +1272,6 @@ InitializeMpSystemData (
EFI_STATUS Status; EFI_STATUS Status;
UINTN Index; UINTN Index;
// //
// Clear the data structure area first. // Clear the data structure area first.
// //
@ -1302,7 +1297,6 @@ InitializeMpSystemData (
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
for (Index = 0; Index < gMPSystem.NumberOfProcessors; Index++) { for (Index = 0; Index < gMPSystem.NumberOfProcessors; Index++) {
if ((gMPSystem.ProcessorData[Index].Info.StatusFlag & PROCESSOR_AS_BSP_BIT) == PROCESSOR_AS_BSP_BIT) { if ((gMPSystem.ProcessorData[Index].Info.StatusFlag & PROCESSOR_AS_BSP_BIT) == PROCESSOR_AS_BSP_BIT) {
// Skip BSP // Skip BSP
@ -1318,12 +1312,11 @@ InitializeMpSystemData (
(VOID *)Index (VOID *)Index
); );
Status = gBS->CreateEvent ( Status = gBS->CreateEvent (
EVT_TIMER | EVT_NOTIFY_SIGNAL, EVT_TIMER | EVT_NOTIFY_SIGNAL,
TPL_CALLBACK, TPL_CALLBACK,
CpuCheckThisAPStatus, CpuCheckThisAPStatus,
(VOID *) &gMPSystem.ProcessorData[Index], (VOID *)&gMPSystem.ProcessorData[Index],
&gMPSystem.ProcessorData[Index].CheckThisAPEvent &gMPSystem.ProcessorData[Index].CheckThisAPEvent
); );
} }
@ -1331,8 +1324,6 @@ InitializeMpSystemData (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Invoke a notification event Invoke a notification event
@ -1351,8 +1342,6 @@ CpuReadToBootFunction (
gReadToBoot = TRUE; gReadToBoot = TRUE;
} }
EFI_STATUS EFI_STATUS
CpuMpServicesInit ( CpuMpServicesInit (
OUT UINTN *MaxCpus OUT UINTN *MaxCpus
@ -1379,7 +1368,7 @@ CpuMpServicesInit (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
gPollInterval = (UINTN) PcdGet64 (PcdEmuMpServicesPollingInterval); gPollInterval = (UINTN)PcdGet64 (PcdEmuMpServicesPollingInterval);
Status = InitializeMpSystemData (*MaxCpus); Status = InitializeMpSystemData (*MaxCpus);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -1395,10 +1384,9 @@ CpuMpServicesInit (
Handle = NULL; Handle = NULL;
Status = gBS->InstallMultipleProtocolInterfaces ( Status = gBS->InstallMultipleProtocolInterfaces (
&Handle, &Handle,
&gEfiMpServiceProtocolGuid, &mMpServicesTemplate, &gEfiMpServiceProtocolGuid,
&mMpServicesTemplate,
NULL NULL
); );
return Status; return Status;
} }

View File

@ -16,6 +16,7 @@ Abstract:
// //
// EFI Component Name Functions // EFI Component Name Functions
// //
/** /**
Retrieves a Unicode string that is the user readable name of the driver. Retrieves a Unicode string that is the user readable name of the driver.
@ -63,7 +64,6 @@ EmuBlockIoComponentNameGetDriverName (
OUT CHAR16 **DriverName OUT CHAR16 **DriverName
); );
/** /**
Retrieves a Unicode string that is the user readable name of the controller Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver. that is being managed by a driver.
@ -155,15 +155,14 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gEmuBlockIoCompon
// EFI Component Name 2 Protocol // EFI Component Name 2 Protocol
// //
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuBlockIoComponentName2 = { GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuBlockIoComponentName2 = {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) EmuBlockIoComponentNameGetDriverName, (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)EmuBlockIoComponentNameGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) EmuBlockIoComponentNameGetControllerName, (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)EmuBlockIoComponentNameGetControllerName,
"en" "en"
}; };
EFI_UNICODE_STRING_TABLE mEmuBlockIoDriverNameTable[] = { EFI_UNICODE_STRING_TABLE mEmuBlockIoDriverNameTable[] = {
{ "eng;en", L"Emu Block I/O Driver" }, { "eng;en", L"Emu Block I/O Driver" },
{ NULL , NULL } { NULL, NULL }
}; };
/** /**
@ -310,6 +309,7 @@ EmuBlockIoComponentNameGetControllerName (
if (ChildHandle != NULL) { if (ChildHandle != NULL) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
// //
// Make sure this driver is currently managing ControllerHandle // Make sure this driver is currently managing ControllerHandle
// //
@ -321,6 +321,7 @@ EmuBlockIoComponentNameGetControllerName (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
// //
// Get our context back // Get our context back
// //

View File

@ -129,7 +129,7 @@ EmuBlockIoDriverConfigurationSetOptions (
return Status; return Status;
} }
if (ActionRequired == NULL || ControllerHandle == NULL) { if ((ActionRequired == NULL) || (ControllerHandle == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -294,7 +294,7 @@ EmuBlockIoDriverConfigurationForceDefaults (
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
if (ActionRequired == NULL || ControllerHandle == NULL) { if ((ActionRequired == NULL) || (ControllerHandle == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }

View File

@ -41,7 +41,7 @@ EFI_DRIVER_DIAGNOSTICS_PROTOCOL gEmuBlockIoDriverDiagnostics = {
// EFI Driver Diagnostics 2 Protocol // EFI Driver Diagnostics 2 Protocol
// //
GLOBAL_REMOVE_IF_UNREFERENCED EFI_DRIVER_DIAGNOSTICS2_PROTOCOL gEmuBlockIoDriverDiagnostics2 = { GLOBAL_REMOVE_IF_UNREFERENCED EFI_DRIVER_DIAGNOSTICS2_PROTOCOL gEmuBlockIoDriverDiagnostics2 = {
(EFI_DRIVER_DIAGNOSTICS2_RUN_DIAGNOSTICS) EmuBlockIoDriverDiagnosticsRunDiagnostics, (EFI_DRIVER_DIAGNOSTICS2_RUN_DIAGNOSTICS)EmuBlockIoDriverDiagnosticsRunDiagnostics,
"en" "en"
}; };
@ -57,6 +57,7 @@ EmuBlockIoDriverDiagnosticsRunDiagnostics (
OUT UINTN *BufferSize, OUT UINTN *BufferSize,
OUT CHAR16 **Buffer OUT CHAR16 **Buffer
) )
/*++ /*++
Routine Description: Routine Description:
@ -124,12 +125,12 @@ EmuBlockIoDriverDiagnosticsRunDiagnostics (
BOOLEAN Found; BOOLEAN Found;
UINTN Index; UINTN Index;
if (Language == NULL || if ((Language == NULL) ||
ErrorType == NULL || (ErrorType == NULL) ||
Buffer == NULL || (Buffer == NULL) ||
ControllerHandle == NULL || (ControllerHandle == NULL) ||
BufferSize == NULL) { (BufferSize == NULL))
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -145,17 +146,23 @@ EmuBlockIoDriverDiagnosticsRunDiagnostics (
Found = TRUE; Found = TRUE;
break; break;
} }
SupportedLanguages += 3; SupportedLanguages += 3;
} else { } else {
for (Index = 0; SupportedLanguages[Index] != 0 && SupportedLanguages[Index] != ';'; Index++); for (Index = 0; SupportedLanguages[Index] != 0 && SupportedLanguages[Index] != ';'; Index++) {
if ((AsciiStrnCmp(SupportedLanguages, Language, Index) == 0) && (Language[Index] == 0)) { }
if ((AsciiStrnCmp (SupportedLanguages, Language, Index) == 0) && (Language[Index] == 0)) {
Found = TRUE; Found = TRUE;
break; break;
} }
SupportedLanguages += Index; SupportedLanguages += Index;
for (; *SupportedLanguages != 0 && *SupportedLanguages == ';'; SupportedLanguages++); for ( ; *SupportedLanguages != 0 && *SupportedLanguages == ';'; SupportedLanguages++) {
} }
} }
}
// //
// If Language is not a member of SupportedLanguages, then return EFI_UNSUPPORTED // If Language is not a member of SupportedLanguages, then return EFI_UNSUPPORTED
// //
@ -168,7 +175,7 @@ EmuBlockIoDriverDiagnosticsRunDiagnostics (
if (DiagnosticType != EfiDriverDiagnosticTypeStandard) { if (DiagnosticType != EfiDriverDiagnosticTypeStandard) {
*ErrorType = &gEfiBlockIoProtocolGuid; *ErrorType = &gEfiBlockIoProtocolGuid;
*BufferSize = 0x60; *BufferSize = 0x60;
Buffer = AllocatePool ((UINTN) (*BufferSize)); Buffer = AllocatePool ((UINTN)(*BufferSize));
CopyMem (*Buffer, L"Windows Block I/O Driver Diagnostics Failed\n", *BufferSize); CopyMem (*Buffer, L"Windows Block I/O Driver Diagnostics Failed\n", *BufferSize);
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }

View File

@ -7,7 +7,6 @@ bbe
#include "EmuBlockIo.h" #include "EmuBlockIo.h"
/** /**
Reset the block device hardware. Reset the block device hardware.
@ -100,7 +99,6 @@ EmuBlockIo2ReadBlocksEx (
return Status; return Status;
} }
/** /**
Write BufferSize bytes from Lba into Buffer. Write BufferSize bytes from Lba into Buffer.
@ -157,8 +155,6 @@ EmuBlockIo2WriteBlocksEx (
return Status; return Status;
} }
/** /**
Flush the Block Device. Flush the Block Device.
@ -202,8 +198,6 @@ EmuBlockIo2Flush (
return Status; return Status;
} }
/** /**
Reset the Block Device. Reset the Block Device.
@ -236,7 +230,6 @@ EmuBlockIoReset (
return Status; return Status;
} }
/** /**
Read BufferSize bytes from Lba into Buffer. Read BufferSize bytes from Lba into Buffer.
@ -282,7 +275,6 @@ EmuBlockIoReadBlocks (
return Status; return Status;
} }
/** /**
Write BufferSize bytes from Lba into Buffer. Write BufferSize bytes from Lba into Buffer.
@ -361,8 +353,6 @@ EmuBlockIoFlushBlocks (
return Status; return Status;
} }
/** /**
Tests to see if this driver supports a given controller. If a child device is provided, 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. it further tests to see if this driver supports creating a handle for the specified child device.
@ -451,7 +441,6 @@ EmuBlockIoDriverBindingSupported (
return Status; return Status;
} }
/** /**
Starts a device controller or a bus controller. Starts a device controller or a bus controller.
@ -573,8 +562,10 @@ EmuBlockIoDriverBindingStart (
Status = gBS->InstallMultipleProtocolInterfaces ( Status = gBS->InstallMultipleProtocolInterfaces (
&Handle, &Handle,
&gEfiBlockIoProtocolGuid, &Private->BlockIo, &gEfiBlockIoProtocolGuid,
&gEfiBlockIo2ProtocolGuid, &Private->BlockIo2, &Private->BlockIo,
&gEfiBlockIo2ProtocolGuid,
&Private->BlockIo2,
NULL NULL
); );
@ -586,7 +577,6 @@ Done:
} }
gBS->FreePool (Private); gBS->FreePool (Private);
} }
gBS->CloseProtocol ( gBS->CloseProtocol (
@ -600,7 +590,6 @@ Done:
return Status; return Status;
} }
/** /**
Stops a device controller or a bus controller. Stops a device controller or a bus controller.
@ -659,8 +648,10 @@ EmuBlockIoDriverBindingStop (
Status = gBS->UninstallMultipleProtocolInterfaces ( Status = gBS->UninstallMultipleProtocolInterfaces (
Private->EfiHandle, Private->EfiHandle,
&gEfiBlockIoProtocolGuid, &Private->BlockIo, &gEfiBlockIoProtocolGuid,
&gEfiBlockIo2ProtocolGuid, &Private->BlockIo2, &Private->BlockIo,
&gEfiBlockIo2ProtocolGuid,
&Private->BlockIo2,
NULL NULL
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
@ -686,10 +677,6 @@ EmuBlockIoDriverBindingStop (
return Status; return Status;
} }
EFI_DRIVER_BINDING_PROTOCOL gEmuBlockIoDriverBinding = { EFI_DRIVER_BINDING_PROTOCOL gEmuBlockIoDriverBinding = {
EmuBlockIoDriverBindingSupported, EmuBlockIoDriverBindingSupported,
EmuBlockIoDriverBindingStart, EmuBlockIoDriverBindingStart,
@ -699,9 +686,6 @@ EFI_DRIVER_BINDING_PROTOCOL gEmuBlockIoDriverBinding = {
NULL NULL
}; };
/** /**
The user Entry Point for module EmuBlockIo . The user code starts with this function. The user Entry Point for module EmuBlockIo . The user code starts with this function.
@ -735,9 +719,5 @@ InitializeEmuBlockIo (
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
return Status; return Status;
} }

View File

@ -38,7 +38,6 @@ Abstract:
#include <Library/MemoryAllocationLib.h> #include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h> #include <Library/UefiBootServicesTableLib.h>
// //
// Language supported for driverconfiguration protocol // Language supported for driverconfiguration protocol
// //
@ -55,7 +54,6 @@ typedef struct {
EFI_BLOCK_IO_MEDIA Media; EFI_BLOCK_IO_MEDIA Media;
EFI_UNICODE_STRING_TABLE *ControllerNameTable; EFI_UNICODE_STRING_TABLE *ControllerNameTable;
} EMU_BLOCK_IO_PRIVATE; } EMU_BLOCK_IO_PRIVATE;
#define EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS(a) \ #define EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS(a) \
@ -64,7 +62,6 @@ typedef struct {
#define EMU_BLOCK_IO2_PRIVATE_DATA_FROM_THIS(a) \ #define EMU_BLOCK_IO2_PRIVATE_DATA_FROM_THIS(a) \
CR(a, EMU_BLOCK_IO_PRIVATE, BlockIo2, EMU_BLOCK_IO_PRIVATE_SIGNATURE) CR(a, EMU_BLOCK_IO_PRIVATE, BlockIo2, EMU_BLOCK_IO_PRIVATE_SIGNATURE)
// //
// Block I/O Global Variables // Block I/O Global Variables
// //

View File

@ -41,14 +41,14 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gEmuBusDriverCompo
// EFI Component Name 2 Protocol // EFI Component Name 2 Protocol
// //
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuBusDriverComponentName2 = { GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuBusDriverComponentName2 = {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) EmuBusDriverComponentNameGetDriverName, (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)EmuBusDriverComponentNameGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) EmuBusDriverComponentNameGetControllerName, (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)EmuBusDriverComponentNameGetControllerName,
"en" "en"
}; };
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mEmuBusDriverNameTable[] = { GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mEmuBusDriverNameTable[] = {
{ "eng", L"Emu Bus Driver" }, { "eng", L"Emu Bus Driver" },
{ NULL , NULL } { NULL, NULL }
}; };
/** /**
@ -223,7 +223,7 @@ EmuBusDriverComponentNameGetControllerName (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ChildHandle, ChildHandle,
&gEmuIoThunkProtocolGuid, &gEmuIoThunkProtocolGuid,
(VOID**)&EmuIo, (VOID **)&EmuIo,
gEmuBusDriverBinding.DriverBindingHandle, gEmuBusDriverBinding.DriverBindingHandle,
ChildHandle, ChildHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL

View File

@ -10,8 +10,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "EmuBusDriverDxe.h" #include "EmuBusDriverDxe.h"
// //
// DriverBinding protocol global // DriverBinding protocol global
// //
@ -24,8 +22,6 @@ EFI_DRIVER_BINDING_PROTOCOL gEmuBusDriverBinding = {
NULL NULL
}; };
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EmuBusDriverBindingSupported ( EmuBusDriverBindingSupported (
@ -52,9 +48,10 @@ EmuBusDriverBindingSupported (
// If RemainingDevicePath isn't the End of Device Path Node, // If RemainingDevicePath isn't the End of Device Path Node,
// check its validation // check its validation
// //
if (RemainingDevicePath->Type != HARDWARE_DEVICE_PATH || if ((RemainingDevicePath->Type != HARDWARE_DEVICE_PATH) ||
RemainingDevicePath->SubType != HW_VENDOR_DP || (RemainingDevicePath->SubType != HW_VENDOR_DP) ||
DevicePathNodeLength(RemainingDevicePath) != sizeof(EMU_VENDOR_DEVICE_PATH_NODE)) { (DevicePathNodeLength (RemainingDevicePath) != sizeof (EMU_VENDOR_DEVICE_PATH_NODE)))
{
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
} }
@ -66,7 +63,7 @@ EmuBusDriverBindingSupported (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ControllerHandle, ControllerHandle,
&gEmuThunkProtocolGuid, &gEmuThunkProtocolGuid,
(VOID **)&EmuThunk , (VOID **)&EmuThunk,
This->DriverBindingHandle, This->DriverBindingHandle,
ControllerHandle, ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER EFI_OPEN_PROTOCOL_BY_DRIVER
@ -108,7 +105,6 @@ EmuBusDriverBindingSupported (
return Status; return Status;
} }
// //
// Close protocol, don't use device path protocol in the Support() function // Close protocol, don't use device path protocol in the Support() function
// //
@ -122,7 +118,6 @@ EmuBusDriverBindingSupported (
return Status; return Status;
} }
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EmuBusDriverBindingStart ( EmuBusDriverBindingStart (
@ -156,7 +151,7 @@ EmuBusDriverBindingStart (
ControllerHandle, ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER EFI_OPEN_PROTOCOL_BY_DRIVER
); );
if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) { if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
return Status; return Status;
} }
@ -168,7 +163,7 @@ EmuBusDriverBindingStart (
ControllerHandle, ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER EFI_OPEN_PROTOCOL_BY_DRIVER
); );
if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) { if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
return Status; return Status;
} }
@ -196,10 +191,10 @@ EmuBusDriverBindingStart (
FALSE FALSE
); );
Status = gBS->InstallMultipleProtocolInterfaces ( Status = gBS->InstallMultipleProtocolInterfaces (
&ControllerHandle, &ControllerHandle,
&gEfiCallerIdGuid, EmuBusDevice, &gEfiCallerIdGuid,
EmuBusDevice,
NULL NULL
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -209,7 +204,6 @@ EmuBusDriverBindingStart (
} }
} }
for (Status = EFI_SUCCESS, EmuIoThunk = NULL; !EFI_ERROR (Status); ) { for (Status = EFI_SUCCESS, EmuIoThunk = NULL; !EFI_ERROR (Status); ) {
Status = EmuThunk->GetNextProtocol (TRUE, &EmuIoThunk); Status = EmuThunk->GetNextProtocol (TRUE, &EmuIoThunk);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -228,12 +222,13 @@ EmuBusDriverBindingStart (
// If RemainingDevicePath isn't the End of Device Path Node, // If RemainingDevicePath isn't the End of Device Path Node,
// check its validation // check its validation
// //
Node = (EMU_VENDOR_DEVICE_PATH_NODE *) RemainingDevicePath; Node = (EMU_VENDOR_DEVICE_PATH_NODE *)RemainingDevicePath;
if (Node->VendorDevicePath.Header.Type == HARDWARE_DEVICE_PATH && if ((Node->VendorDevicePath.Header.Type == HARDWARE_DEVICE_PATH) &&
Node->VendorDevicePath.Header.SubType == HW_VENDOR_DP && (Node->VendorDevicePath.Header.SubType == HW_VENDOR_DP) &&
DevicePathNodeLength (&Node->VendorDevicePath.Header) == sizeof (EMU_VENDOR_DEVICE_PATH_NODE) (DevicePathNodeLength (&Node->VendorDevicePath.Header) == sizeof (EMU_VENDOR_DEVICE_PATH_NODE))
) { )
if (CompareGuid (&Node->VendorDevicePath.Guid, EmuIoThunk->Protocol) && Node->Instance == EmuIoThunk->Instance) { {
if (CompareGuid (&Node->VendorDevicePath.Guid, EmuIoThunk->Protocol) && (Node->Instance == EmuIoThunk->Instance)) {
CreateDevice = TRUE; CreateDevice = TRUE;
} }
} }
@ -284,8 +279,10 @@ EmuBusDriverBindingStart (
InstallStatus = gBS->InstallMultipleProtocolInterfaces ( InstallStatus = gBS->InstallMultipleProtocolInterfaces (
&EmuDevice->Handle, &EmuDevice->Handle,
&gEfiDevicePathProtocolGuid, EmuDevice->DevicePath, &gEfiDevicePathProtocolGuid,
&gEmuIoThunkProtocolGuid, &EmuDevice->EmuIoThunk, EmuDevice->DevicePath,
&gEmuIoThunkProtocolGuid,
&EmuDevice->EmuIoThunk,
NULL NULL
); );
if (EFI_ERROR (InstallStatus)) { if (EFI_ERROR (InstallStatus)) {
@ -298,7 +295,7 @@ EmuBusDriverBindingStart (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ControllerHandle, ControllerHandle,
&gEmuThunkProtocolGuid, &gEmuThunkProtocolGuid,
(VOID **)&EmuThunk , (VOID **)&EmuThunk,
This->DriverBindingHandle, This->DriverBindingHandle,
EmuDevice->Handle, EmuDevice->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@ -313,7 +310,6 @@ EmuBusDriverBindingStart (
return InstallStatus; return InstallStatus;
} }
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EmuBusDriverBindingStop ( EmuBusDriverBindingStop (
@ -354,7 +350,8 @@ EmuBusDriverBindingStop (
gBS->UninstallMultipleProtocolInterfaces ( gBS->UninstallMultipleProtocolInterfaces (
ControllerHandle, ControllerHandle,
&gEfiCallerIdGuid, EmuBusDevice, &gEfiCallerIdGuid,
EmuBusDevice,
NULL NULL
); );
@ -381,7 +378,6 @@ EmuBusDriverBindingStop (
AllChildrenStopped = TRUE; AllChildrenStopped = TRUE;
for (Index = 0; Index < NumberOfChildren; Index++) { for (Index = 0; Index < NumberOfChildren; Index++) {
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ChildHandleBuffer[Index], ChildHandleBuffer[Index],
&gEmuIoThunkProtocolGuid, &gEmuIoThunkProtocolGuid,
@ -402,8 +398,10 @@ EmuBusDriverBindingStop (
Status = gBS->UninstallMultipleProtocolInterfaces ( Status = gBS->UninstallMultipleProtocolInterfaces (
EmuDevice->Handle, EmuDevice->Handle,
&gEfiDevicePathProtocolGuid, EmuDevice->DevicePath, &gEfiDevicePathProtocolGuid,
&gEmuIoThunkProtocolGuid, &EmuDevice->EmuIoThunk, EmuDevice->DevicePath,
&gEmuIoThunkProtocolGuid,
&EmuDevice->EmuIoThunk,
NULL NULL
); );
@ -411,7 +409,7 @@ EmuBusDriverBindingStop (
gBS->OpenProtocol ( gBS->OpenProtocol (
ControllerHandle, ControllerHandle,
&gEmuThunkProtocolGuid, &gEmuThunkProtocolGuid,
(VOID **) &EmuThunk , (VOID **)&EmuThunk,
This->DriverBindingHandle, This->DriverBindingHandle,
EmuDevice->Handle, EmuDevice->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@ -437,7 +435,6 @@ EmuBusDriverBindingStop (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/*++ /*++
Routine Description: Routine Description:
@ -483,12 +480,10 @@ EmuBusCreateDevicePath (
return AppendDevicePathNode ( return AppendDevicePathNode (
RootDevicePath, RootDevicePath,
(EFI_DEVICE_PATH_PROTOCOL *) &DevicePath (EFI_DEVICE_PATH_PROTOCOL *)&DevicePath
); );
} }
/** /**
The user Entry Point for module EmuBusDriver. The user code starts with this function. The user Entry Point for module EmuBusDriver. The user code starts with this function.
@ -519,10 +514,5 @@ InitializeEmuBusDriver (
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
return Status; return Status;
} }

View File

@ -29,7 +29,6 @@ extern EFI_DRIVER_BINDING_PROTOCOL gEmuBusDriverBinding;
extern EFI_COMPONENT_NAME_PROTOCOL gEmuBusDriverComponentName; extern EFI_COMPONENT_NAME_PROTOCOL gEmuBusDriverComponentName;
extern EFI_COMPONENT_NAME2_PROTOCOL gEmuBusDriverComponentName2; extern EFI_COMPONENT_NAME2_PROTOCOL gEmuBusDriverComponentName2;
// //
// Unix Bus Controller Structure // Unix Bus Controller Structure
// //
@ -58,14 +57,11 @@ typedef struct {
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath; EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
EFI_UNICODE_STRING_TABLE *ControllerNameTable; EFI_UNICODE_STRING_TABLE *ControllerNameTable;
} EMU_IO_DEVICE; } EMU_IO_DEVICE;
#define EMU_IO_DEVICE_FROM_THIS(a) \ #define EMU_IO_DEVICE_FROM_THIS(a) \
CR(a, EMU_IO_DEVICE, EmuIoThunk, EMU_IO_DEVICE_SIGNATURE) CR(a, EMU_IO_DEVICE, EmuIoThunk, EMU_IO_DEVICE_SIGNATURE)
// //
// Driver Binding Protocol function prototypes // Driver Binding Protocol function prototypes
// //
@ -77,7 +73,6 @@ EmuBusDriverBindingSupported (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
); );
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EmuBusDriverBindingStart ( EmuBusDriverBindingStart (
@ -86,7 +81,6 @@ EmuBusDriverBindingStart (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
); );
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EmuBusDriverBindingStop ( EmuBusDriverBindingStop (
@ -106,5 +100,4 @@ EmuBusCreateDevicePath (
IN UINT16 InstanceNumber IN UINT16 InstanceNumber
); );
#endif #endif

View File

@ -48,18 +48,16 @@ EFI_COMPONENT_NAME_PROTOCOL gEmuGopComponentName = {
// EFI Component Name 2 Protocol // EFI Component Name 2 Protocol
// //
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuGopComponentName2 = { GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuGopComponentName2 = {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) EmuGopComponentNameGetDriverName, (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)EmuGopComponentNameGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) EmuGopComponentNameGetControllerName, (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)EmuGopComponentNameGetControllerName,
"en" "en"
}; };
EFI_UNICODE_STRING_TABLE mEmuGopDriverNameTable[] = { EFI_UNICODE_STRING_TABLE mEmuGopDriverNameTable[] = {
{ "eng", L"Emulator GOP Driver" }, { "eng", L"Emulator GOP Driver" },
{ NULL , NULL } { NULL, NULL }
}; };
/** /**
Retrieves a Unicode string that is the user readable name of the driver. 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 Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver. that is being managed by a driver.
@ -217,6 +214,7 @@ EmuGopComponentNameGetControllerName (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
// //
// Get our context back // Get our context back
// //

View File

@ -29,7 +29,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/UefiBootServicesTableLib.h> #include <Library/UefiBootServicesTableLib.h>
#include <Library/KeyMapLib.h> #include <Library/KeyMapLib.h>
#define MAX_Q 256 #define MAX_Q 256
typedef struct { typedef struct {
@ -58,8 +57,6 @@ typedef struct {
UINT32 RefreshRate; UINT32 RefreshRate;
} GOP_MODE_DATA; } GOP_MODE_DATA;
extern EFI_DRIVER_BINDING_PROTOCOL gEmuGopDriverBinding; extern EFI_DRIVER_BINDING_PROTOCOL gEmuGopDriverBinding;
extern EFI_COMPONENT_NAME_PROTOCOL gEmuGopComponentName; extern EFI_COMPONENT_NAME_PROTOCOL gEmuGopComponentName;
@ -85,7 +82,6 @@ typedef struct {
// //
GOP_MODE_DATA *ModeData; GOP_MODE_DATA *ModeData;
// //
// UGA Private Data knowing when to start hardware // UGA Private Data knowing when to start hardware
// //
@ -100,7 +96,6 @@ typedef struct {
LIST_ENTRY NotifyList; LIST_ENTRY NotifyList;
} GOP_PRIVATE_DATA; } GOP_PRIVATE_DATA;
#define GOP_PRIVATE_DATA_FROM_THIS(a) \ #define GOP_PRIVATE_DATA_FROM_THIS(a) \
CR(a, GOP_PRIVATE_DATA, GraphicsOutput, GOP_PRIVATE_DATA_SIGNATURE) CR(a, GOP_PRIVATE_DATA, GraphicsOutput, GOP_PRIVATE_DATA_SIGNATURE)
@ -113,7 +108,6 @@ typedef struct {
#define GOP_PRIVATE_DATA_FROM_POINTER_MODE_THIS(a) \ #define GOP_PRIVATE_DATA_FROM_POINTER_MODE_THIS(a) \
CR(a, GOP_PRIVATE_DATA, SimplePointer, GOP_PRIVATE_DATA_SIGNATURE) CR(a, GOP_PRIVATE_DATA, SimplePointer, GOP_PRIVATE_DATA_SIGNATURE)
// //
// Global Protocol Variables // Global Protocol Variables
// //
@ -139,7 +133,6 @@ EmuGopDestructor (
IN GOP_PRIVATE_DATA *Private IN GOP_PRIVATE_DATA *Private
); );
EFI_STATUS EFI_STATUS
GopPrivateAddQ ( GopPrivateAddQ (
IN GOP_PRIVATE_DATA *Private, IN GOP_PRIVATE_DATA *Private,

View File

@ -9,11 +9,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "Gop.h" #include "Gop.h"
EFI_STATUS EFI_STATUS
FreeNotifyList ( FreeNotifyList (
IN OUT LIST_ENTRY *ListHead IN OUT LIST_ENTRY *ListHead
) )
/*++ /*++
Routine Description: Routine Description:
@ -34,6 +34,7 @@ Returns:
if (ListHead == NULL) { if (ListHead == NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
while (!IsListEmpty (ListHead)) { while (!IsListEmpty (ListHead)) {
NotifyNode = CR ( NotifyNode = CR (
ListHead->ForwardLink, ListHead->ForwardLink,
@ -48,7 +49,6 @@ Returns:
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Tests to see if this driver supports a given controller. If a child device is provided, 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. it further tests to see if this driver supports creating a handle for the specified child device.
@ -132,7 +132,6 @@ EmuGopDriverBindingSupported (
return Status; return Status;
} }
/** /**
Starts a device controller or a bus controller. Starts a device controller or a bus controller.
@ -207,6 +206,7 @@ EmuGopDriverBindingStart (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto Done; goto Done;
} }
// //
// Set up context record // Set up context record
// //
@ -234,21 +234,25 @@ EmuGopDriverBindingStart (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto Done; goto Done;
} }
// //
// Publish the Gop interface to the world // Publish the Gop interface to the world
// //
Status = gBS->InstallMultipleProtocolInterfaces ( Status = gBS->InstallMultipleProtocolInterfaces (
&Private->Handle, &Private->Handle,
&gEfiGraphicsOutputProtocolGuid, &Private->GraphicsOutput, &gEfiGraphicsOutputProtocolGuid,
&gEfiSimpleTextInProtocolGuid, &Private->SimpleTextIn, &Private->GraphicsOutput,
&gEfiSimplePointerProtocolGuid, &Private->SimplePointer, &gEfiSimpleTextInProtocolGuid,
&gEfiSimpleTextInputExProtocolGuid, &Private->SimpleTextInEx, &Private->SimpleTextIn,
&gEfiSimplePointerProtocolGuid,
&Private->SimplePointer,
&gEfiSimpleTextInputExProtocolGuid,
&Private->SimpleTextInEx,
NULL NULL
); );
Done: Done:
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
gBS->CloseProtocol ( gBS->CloseProtocol (
Handle, Handle,
&gEmuIoThunkProtocolGuid, &gEmuIoThunkProtocolGuid,
@ -263,12 +267,15 @@ Done:
if (Private->ControllerNameTable != NULL) { if (Private->ControllerNameTable != NULL) {
FreeUnicodeStringTable (Private->ControllerNameTable); FreeUnicodeStringTable (Private->ControllerNameTable);
} }
if (Private->SimpleTextIn.WaitForKey != NULL) { if (Private->SimpleTextIn.WaitForKey != NULL) {
gBS->CloseEvent (Private->SimpleTextIn.WaitForKey); gBS->CloseEvent (Private->SimpleTextIn.WaitForKey);
} }
if (Private->SimpleTextInEx.WaitForKeyEx != NULL) { if (Private->SimpleTextInEx.WaitForKeyEx != NULL) {
gBS->CloseEvent (Private->SimpleTextInEx.WaitForKeyEx); gBS->CloseEvent (Private->SimpleTextInEx.WaitForKeyEx);
} }
FreeNotifyList (&Private->NotifyList); FreeNotifyList (&Private->NotifyList);
gBS->FreePool (Private); gBS->FreePool (Private);
@ -278,8 +285,6 @@ Done:
return Status; return Status;
} }
/** /**
Stops a device controller or a bus controller. Stops a device controller or a bus controller.
@ -344,10 +349,14 @@ EmuGopDriverBindingStop (
// //
Status = gBS->UninstallMultipleProtocolInterfaces ( Status = gBS->UninstallMultipleProtocolInterfaces (
Private->Handle, Private->Handle,
&gEfiGraphicsOutputProtocolGuid, &Private->GraphicsOutput, &gEfiGraphicsOutputProtocolGuid,
&gEfiSimpleTextInProtocolGuid, &Private->SimpleTextIn, &Private->GraphicsOutput,
&gEfiSimplePointerProtocolGuid, &Private->SimplePointer, &gEfiSimpleTextInProtocolGuid,
&gEfiSimpleTextInputExProtocolGuid, &Private->SimpleTextInEx, &Private->SimpleTextIn,
&gEfiSimplePointerProtocolGuid,
&Private->SimplePointer,
&gEfiSimpleTextInputExProtocolGuid,
&Private->SimpleTextInEx,
NULL NULL
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
@ -380,13 +389,11 @@ EmuGopDriverBindingStop (
FreeNotifyList (&Private->NotifyList); FreeNotifyList (&Private->NotifyList);
gBS->FreePool (Private); gBS->FreePool (Private);
} }
return Status; return Status;
} }
/// ///
/// This protocol provides the services required to determine if a driver supports a given controller. /// 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. /// If a controller is supported, then it also provides routines to start and stop the controller.
@ -400,8 +407,6 @@ EFI_DRIVER_BINDING_PROTOCOL gEmuGopDriverBinding = {
NULL NULL
}; };
/** /**
The user Entry Point for module EmuGop. The user code starts with this function. The user Entry Point for module EmuGop. The user code starts with this function.
@ -431,7 +436,5 @@ InitializeEmuGop (
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
return Status; return Status;
} }

View File

@ -9,12 +9,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "Gop.h" #include "Gop.h"
BOOLEAN BOOLEAN
GopPrivateIsKeyRegistered ( GopPrivateIsKeyRegistered (
IN EFI_KEY_DATA *RegsiteredData, IN EFI_KEY_DATA *RegsiteredData,
IN EFI_KEY_DATA *InputData IN EFI_KEY_DATA *InputData
) )
/*++ /*++
Routine Description: Routine Description:
@ -35,27 +35,29 @@ Returns:
ASSERT (RegsiteredData != NULL && InputData != NULL); ASSERT (RegsiteredData != NULL && InputData != NULL);
if ((RegsiteredData->Key.ScanCode != InputData->Key.ScanCode) || if ((RegsiteredData->Key.ScanCode != InputData->Key.ScanCode) ||
(RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar)) { (RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar))
{
return FALSE; return FALSE;
} }
// //
// Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored. // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.
// //
if (RegsiteredData->KeyState.KeyShiftState != 0 && if ((RegsiteredData->KeyState.KeyShiftState != 0) &&
RegsiteredData->KeyState.KeyShiftState != InputData->KeyState.KeyShiftState) { (RegsiteredData->KeyState.KeyShiftState != InputData->KeyState.KeyShiftState))
{
return FALSE; 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 FALSE;
} }
return TRUE; return TRUE;
} }
VOID VOID
EFIAPI EFIAPI
GopPrivateMakeCallbackFunction ( GopPrivateMakeCallbackFunction (
@ -84,7 +86,6 @@ GopPrivateMakeCallbackFunction (
} }
} }
VOID VOID
EFIAPI EFIAPI
GopPrivateBreakCallbackFunction ( GopPrivateBreakCallbackFunction (
@ -95,8 +96,6 @@ GopPrivateBreakCallbackFunction (
KeyMapBreak (KeyData); KeyMapBreak (KeyData);
} }
// //
// Simple Text In implementation. // Simple Text In implementation.
// //
@ -135,8 +134,8 @@ EmuGopSimpleTextInReset (
// //
// A reset is draining the Queue // 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 // Leave critical section and return
@ -145,7 +144,6 @@ EmuGopSimpleTextInReset (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Reads the next keystroke from the input device. The WaitForKey Event can Reads the next keystroke from the input device. The WaitForKey Event can
be used to test for existence of a keystroke via WaitForEvent () call. be used to test for existence of a keystroke via WaitForEvent () call.
@ -200,8 +198,6 @@ EmuGopSimpleTextInReadKeyStroke (
return Status; return Status;
} }
/** /**
SimpleTextIn and SimpleTextInEx Notify Wait Event SimpleTextIn and SimpleTextInEx Notify Wait Event
@ -220,7 +216,7 @@ EmuGopSimpleTextInWaitForKey (
EFI_STATUS Status; EFI_STATUS Status;
EFI_TPL OldTpl; EFI_TPL OldTpl;
Private = (GOP_PRIVATE_DATA *) Context; Private = (GOP_PRIVATE_DATA *)Context;
if (Private->EmuGraphicsWindow == NULL) { if (Private->EmuGraphicsWindow == NULL) {
return; return;
} }
@ -237,18 +233,17 @@ EmuGopSimpleTextInWaitForKey (
// //
gBS->SignalEvent (Event); gBS->SignalEvent (Event);
} }
// //
// Leave critical section and return // Leave critical section and return
// //
gBS->RestoreTPL (OldTpl); gBS->RestoreTPL (OldTpl);
} }
// //
// Simple Text Input Ex protocol functions // Simple Text Input Ex protocol functions
// //
/** /**
The Reset() function resets the input device hardware. As part The Reset() function resets the input device hardware. As part
of initialization process, the firmware/device will make a quick of initialization process, the firmware/device will make a quick
@ -280,6 +275,7 @@ EmuGopSimpleTextInExResetEx (
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
IN BOOLEAN ExtendedVerification IN BOOLEAN ExtendedVerification
) )
/*++ /*++
Routine Description: Routine Description:
@ -297,8 +293,6 @@ EmuGopSimpleTextInExResetEx (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
The function reads the next keystroke from the input device. If The function reads the next keystroke from the input device. If
there is no pending keystroke the function returns there is no pending keystroke the function returns
@ -354,6 +348,7 @@ EmuGopSimpleTextInExReadKeyStrokeEx (
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
OUT EFI_KEY_DATA *KeyData OUT EFI_KEY_DATA *KeyData
) )
/*++ /*++
Routine Description: Routine Description:
@ -378,7 +373,6 @@ EmuGopSimpleTextInExReadKeyStrokeEx (
GOP_PRIVATE_DATA *Private; GOP_PRIVATE_DATA *Private;
EFI_TPL OldTpl; EFI_TPL OldTpl;
if (KeyData == NULL) { if (KeyData == NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -393,7 +387,7 @@ EmuGopSimpleTextInExReadKeyStrokeEx (
// //
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 // Leave critical section and return
@ -403,8 +397,6 @@ EmuGopSimpleTextInExReadKeyStrokeEx (
return Status; return Status;
} }
/** /**
The SetState() function allows the input device hardware to The SetState() function allows the input device hardware to
have state settings adjusted. have state settings adjusted.
@ -446,7 +438,8 @@ EmuGopSimpleTextInExSetState (
} }
if (((Private->KeyState.KeyToggleState & EFI_TOGGLE_STATE_VALID) != EFI_TOGGLE_STATE_VALID) || 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; return EFI_UNSUPPORTED;
} }
@ -464,7 +457,6 @@ EmuGopSimpleTextInExSetState (
return Status; return Status;
} }
/** /**
SimpleTextIn and SimpleTextInEx Notify Wait Event SimpleTextIn and SimpleTextInEx Notify Wait Event
@ -484,8 +476,6 @@ EmuGopRegisterKeyCallback (
ExNotify->KeyNotificationFn (&ExNotify->KeyData); ExNotify->KeyNotificationFn (&ExNotify->KeyData);
} }
/** /**
The RegisterKeystrokeNotify() function registers a function The RegisterKeystrokeNotify() function registers a function
which will be called when a specified keystroke will occur. which will be called when a specified keystroke will occur.
@ -526,7 +516,7 @@ EmuGopSimpleTextInExRegisterKeyNotify (
LIST_ENTRY *Link; LIST_ENTRY *Link;
EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *NewNotify; 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; return EFI_INVALID_PARAMETER;
} }
@ -553,14 +543,14 @@ EmuGopSimpleTextInExRegisterKeyNotify (
// //
// Allocate resource to save the notification function // 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) { if (NewNotify == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
NewNotify->Signature = EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE; NewNotify->Signature = EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE;
NewNotify->KeyNotificationFn = KeyNotificationFunction; NewNotify->KeyNotificationFn = KeyNotificationFunction;
NewNotify->NotifyHandle = (EFI_HANDLE) NewNotify; NewNotify->NotifyHandle = (EFI_HANDLE)NewNotify;
CopyMem (&NewNotify->KeyData, KeyData, sizeof (KeyData)); CopyMem (&NewNotify->KeyData, KeyData, sizeof (KeyData));
InsertTailList (&Private->NotifyList, &NewNotify->NotifyEntry); InsertTailList (&Private->NotifyList, &NewNotify->NotifyEntry);
@ -573,14 +563,11 @@ EmuGopSimpleTextInExRegisterKeyNotify (
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
*NotifyHandle = NewNotify->NotifyHandle; *NotifyHandle = NewNotify->NotifyHandle;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
The UnregisterKeystrokeNotify() function removes the The UnregisterKeystrokeNotify() function removes the
notification which was previously registered. notification which was previously registered.
@ -602,6 +589,7 @@ EmuGopSimpleTextInExUnregisterKeyNotify (
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
IN VOID *NotificationHandle IN VOID *NotificationHandle
) )
/*++ /*++
Routine Description: Routine Description:
@ -625,7 +613,7 @@ EmuGopSimpleTextInExUnregisterKeyNotify (
return EFI_INVALID_PARAMETER; 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; return EFI_INVALID_PARAMETER;
} }
@ -657,8 +645,6 @@ EmuGopSimpleTextInExUnregisterKeyNotify (
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
/** /**
Initialize SimplelTextIn and SimpleTextInEx protocols in the Private Initialize SimplelTextIn and SimpleTextInEx protocols in the Private
context structure. context structure.
@ -690,7 +676,6 @@ EmuGopInitializeSimpleTextInForWindow (
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
// //
// Initialize Simple Text In Ex // Initialize Simple Text In Ex
// //
@ -714,21 +699,13 @@ EmuGopInitializeSimpleTextInForWindow (
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
return Status; return Status;
} }
// //
// Simple Pointer implementation. // Simple Pointer implementation.
// //
/** /**
Resets the pointer device hardware. Resets the pointer device hardware.
@ -765,8 +742,8 @@ EmuGopSimplePointerReset (
// //
// A reset is draining the Queue // 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 // Leave critical section and return
@ -775,7 +752,6 @@ EmuGopSimplePointerReset (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Retrieves the current state of a pointer device. Retrieves the current state of a pointer device.
@ -820,7 +796,6 @@ EmuGopSimplePointerGetState (
return Status; return Status;
} }
/** /**
SimplePointer Notify Wait Event SimplePointer Notify Wait Event
@ -839,7 +814,7 @@ EmuGopSimplePointerWaitForInput (
EFI_STATUS Status; EFI_STATUS Status;
EFI_TPL OldTpl; EFI_TPL OldTpl;
Private = (GOP_PRIVATE_DATA *) Context; Private = (GOP_PRIVATE_DATA *)Context;
if (Private->EmuGraphicsWindow == NULL) { if (Private->EmuGraphicsWindow == NULL) {
return; return;
} }
@ -856,13 +831,13 @@ EmuGopSimplePointerWaitForInput (
// //
gBS->SignalEvent (Event); gBS->SignalEvent (Event);
} }
// //
// Leave critical section and return // Leave critical section and return
// //
gBS->RestoreTPL (OldTpl); gBS->RestoreTPL (OldTpl);
} }
/** /**
SimplePointer constructor SimplePointer constructor

View File

@ -18,17 +18,15 @@ Abstract:
#include "Gop.h" #include "Gop.h"
EFI_EVENT mGopScreenExitBootServicesEvent; EFI_EVENT mGopScreenExitBootServicesEvent;
GOP_MODE_DATA mGopModeData[] = { GOP_MODE_DATA mGopModeData[] = {
{ 800, 600, 0, 0 }, { 800, 600, 0, 0 },
{ 640, 480, 0, 0 }, { 640, 480, 0, 0 },
{ 720, 400, 0, 0 }, { 720, 400, 0, 0 },
{1024, 768, 0, 0 }, { 1024, 768, 0, 0 },
{1280, 1024, 0, 0 } { 1280, 1024, 0, 0 }
}; };
/** /**
Returns information for an available graphics mode that the graphics device Returns information for an available graphics mode that the graphics device
@ -59,7 +57,7 @@ EmuGopQuerytMode (
Private = GOP_PRIVATE_DATA_FROM_THIS (This); 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; return EFI_INVALID_PARAMETER;
} }
@ -79,8 +77,6 @@ EmuGopQuerytMode (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Set the video device into the specified mode and clears the visible portions of Set the video device into the specified mode and clears the visible portions of
the output display to black. the output display to black.
@ -132,14 +128,12 @@ EmuGopSetMode (
Private->HardwareNeedsStarting = FALSE; Private->HardwareNeedsStarting = FALSE;
} }
Status = Private->EmuGraphicsWindow->Size (
Status = Private->EmuGraphicsWindow->Size(
Private->EmuGraphicsWindow, Private->EmuGraphicsWindow,
ModeData->HorizontalResolution, ModeData->HorizontalResolution,
ModeData->VerticalResolution ModeData->VerticalResolution
); );
Fill.Red = 0; Fill.Red = 0;
Fill.Green = 0; Fill.Green = 0;
Fill.Blue = 0; Fill.Blue = 0;
@ -158,8 +152,6 @@ EmuGopSetMode (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Blt a rectangle of pixels on the graphics screen. Blt stands for BLock Transfer. Blt a rectangle of pixels on the graphics screen. Blt stands for BLock Transfer.
@ -206,9 +198,10 @@ EmuGopBlt (
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (Width == 0 || Height == 0) { if ((Width == 0) || (Height == 0)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
// //
// If Delta is zero, then the entire BltBuffer is being used, so Delta // 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, // is the number of bytes in each row of BltBuffer. Since BltBuffer is Width pixels size,
@ -248,7 +241,6 @@ EmuGopBlt (
return Status; return Status;
} }
// //
// Construction and Destruction functions // Construction and Destruction functions
// //
@ -270,7 +262,6 @@ EmuGopSupported (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EFI_STATUS EFI_STATUS
EmuGopStartWindow ( EmuGopStartWindow (
IN GOP_PRIVATE_DATA *Private, IN GOP_PRIVATE_DATA *Private,
@ -306,6 +297,7 @@ EmuGopStartWindow (
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
return Status; return Status;
} }
@ -327,12 +319,13 @@ EmuGopConstructor (
if (Private->GraphicsOutput.Mode == NULL) { if (Private->GraphicsOutput.Mode == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
Private->GraphicsOutput.Mode->Info = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION)); Private->GraphicsOutput.Mode->Info = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));
if (Private->GraphicsOutput.Mode->Info == NULL) { if (Private->GraphicsOutput.Mode->Info == NULL) {
return EFI_OUT_OF_RESOURCES; 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. // Till now, we have no idea about the window size.
// //
@ -342,7 +335,7 @@ EmuGopConstructor (
Private->GraphicsOutput.Mode->Info->VerticalResolution = 0; Private->GraphicsOutput.Mode->Info->VerticalResolution = 0;
Private->GraphicsOutput.Mode->Info->PixelFormat = PixelBltOnly; Private->GraphicsOutput.Mode->Info->PixelFormat = PixelBltOnly;
Private->GraphicsOutput.Mode->SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION); Private->GraphicsOutput.Mode->SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
Private->GraphicsOutput.Mode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS) (UINTN) NULL; Private->GraphicsOutput.Mode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS)(UINTN)NULL;
Private->GraphicsOutput.Mode->FrameBufferSize = 0; Private->GraphicsOutput.Mode->FrameBufferSize = 0;
Private->HardwareNeedsStarting = TRUE; Private->HardwareNeedsStarting = TRUE;
@ -355,8 +348,6 @@ EmuGopConstructor (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EFI_STATUS EFI_STATUS
EmuGopDestructor ( EmuGopDestructor (
GOP_PRIVATE_DATA *Private GOP_PRIVATE_DATA *Private
@ -374,19 +365,20 @@ EmuGopDestructor (
if (Private->GraphicsOutput.Mode->Info != NULL) { if (Private->GraphicsOutput.Mode->Info != NULL) {
FreePool (Private->GraphicsOutput.Mode->Info); FreePool (Private->GraphicsOutput.Mode->Info);
} }
FreePool (Private->GraphicsOutput.Mode); FreePool (Private->GraphicsOutput.Mode);
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
VOID VOID
EFIAPI EFIAPI
ShutdownGopEvent ( ShutdownGopEvent (
IN EFI_EVENT Event, IN EFI_EVENT Event,
IN VOID *Context IN VOID *Context
) )
/*++ /*++
Routine Description: Routine Description:

View File

@ -110,7 +110,6 @@ EmuSimpleFileSystemComponentNameGetDriverName (
); );
} }
/** /**
Retrieves a Unicode string that is the user readable name of the controller Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver. that is being managed by a driver.
@ -211,13 +210,14 @@ EmuSimpleFileSystemComponentNameGetControllerName (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
// //
// Get our context back // Get our context back
// //
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ControllerHandle, ControllerHandle,
&gEfiSimpleFileSystemProtocolGuid, &gEfiSimpleFileSystemProtocolGuid,
(VOID**)&SimpleFileSystem, (VOID **)&SimpleFileSystem,
gEmuSimpleFileSystemDriverBinding.DriverBindingHandle, gEmuSimpleFileSystemDriverBinding.DriverBindingHandle,
ControllerHandle, ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL

View File

@ -12,9 +12,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "EmuSimpleFileSystem.h" #include "EmuSimpleFileSystem.h"
/** /**
Opens a new file relative to the source file's location. Opens a new file relative to the source file's location.
@ -53,7 +50,7 @@ EmuSimpleFileSystemOpen (
// //
// Check for obvious invalid parameters. // Check for obvious invalid parameters.
// //
if (This == NULL || NewHandle == NULL || FileName == NULL) { if ((This == NULL) || (NewHandle == NULL) || (FileName == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -88,7 +85,6 @@ EmuSimpleFileSystemOpen (
goto Done; goto Done;
} }
Status = PrivateFile->Io->Open (PrivateFile->Io, &NewPrivateFile->Io, FileName, OpenMode, Attributes); Status = PrivateFile->Io->Open (PrivateFile->Io, &NewPrivateFile->Io, FileName, OpenMode, Attributes);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
*NewHandle = &NewPrivateFile->EfiFile; *NewHandle = &NewPrivateFile->EfiFile;
@ -103,8 +99,6 @@ Done:
return Status; return Status;
} }
/** /**
Close the file handle Close the file handle
@ -141,7 +135,6 @@ EmuSimpleFileSystemClose (
return Status; return Status;
} }
/** /**
Close and delete the file handle. Close and delete the file handle.
@ -179,7 +172,6 @@ EmuSimpleFileSystemDelete (
return Status; return Status;
} }
/** /**
Read data from the file. Read data from the file.
@ -206,7 +198,7 @@ EmuSimpleFileSystemRead (
EMU_EFI_FILE_PRIVATE *PrivateFile; EMU_EFI_FILE_PRIVATE *PrivateFile;
EFI_TPL OldTpl; EFI_TPL OldTpl;
if (This == NULL || BufferSize == NULL) { if ((This == NULL) || (BufferSize == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -225,7 +217,6 @@ EmuSimpleFileSystemRead (
return Status; return Status;
} }
/** /**
Write data to a file. Write data to a file.
@ -256,7 +247,7 @@ EmuSimpleFileSystemWrite (
EMU_EFI_FILE_PRIVATE *PrivateFile; EMU_EFI_FILE_PRIVATE *PrivateFile;
EFI_TPL OldTpl; EFI_TPL OldTpl;
if (This == NULL || BufferSize == NULL || Buffer == NULL) { if ((This == NULL) || (BufferSize == NULL) || (Buffer == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -270,7 +261,6 @@ EmuSimpleFileSystemWrite (
return Status; return Status;
} }
/** /**
Get a file's current position Get a file's current position
@ -292,7 +282,7 @@ EmuSimpleFileSystemGetPosition (
EMU_EFI_FILE_PRIVATE *PrivateFile; EMU_EFI_FILE_PRIVATE *PrivateFile;
EFI_TPL OldTpl; EFI_TPL OldTpl;
if (This == NULL || Position == NULL) { if ((This == NULL) || (Position == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -306,8 +296,6 @@ EmuSimpleFileSystemGetPosition (
return Status; return Status;
} }
/** /**
Set file's current position Set file's current position
@ -343,7 +331,6 @@ EmuSimpleFileSystemSetPosition (
return Status; return Status;
} }
/** /**
Get information about a file. Get information about a file.
@ -375,7 +362,7 @@ EmuSimpleFileSystemGetInfo (
EMU_EFI_FILE_PRIVATE *PrivateFile; EMU_EFI_FILE_PRIVATE *PrivateFile;
EFI_TPL OldTpl; EFI_TPL OldTpl;
if (This == NULL || InformationType == NULL || BufferSize == NULL) { if ((This == NULL) || (InformationType == NULL) || (BufferSize == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -389,7 +376,6 @@ EmuSimpleFileSystemGetInfo (
return Status; return Status;
} }
/** /**
Set information about a file Set information about a file
@ -410,7 +396,7 @@ EmuSimpleFileSystemGetInfo (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EmuSimpleFileSystemSetInfo ( EmuSimpleFileSystemSetInfo (
IN EFI_FILE_PROTOCOL*This, IN EFI_FILE_PROTOCOL *This,
IN EFI_GUID *InformationType, IN EFI_GUID *InformationType,
IN UINTN BufferSize, IN UINTN BufferSize,
IN VOID *Buffer IN VOID *Buffer
@ -423,7 +409,7 @@ EmuSimpleFileSystemSetInfo (
// //
// Check for invalid parameters. // 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; return EFI_INVALID_PARAMETER;
} }
@ -437,7 +423,6 @@ EmuSimpleFileSystemSetInfo (
return Status; return Status;
} }
/** /**
Flush data back for the file handle. Flush data back for the file handle.
@ -477,8 +462,6 @@ EmuSimpleFileSystemFlush (
return Status; return Status;
} }
/** /**
Open the root directory on a volume. Open the root directory on a volume.
@ -508,7 +491,7 @@ EmuSimpleFileSystemOpenVolume (
Status = EFI_UNSUPPORTED; Status = EFI_UNSUPPORTED;
if (This == NULL || Root == NULL) { if ((This == NULL) || (Root == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -562,7 +545,6 @@ EmuSimpleFileSystemOpenVolume (
FALSE FALSE
); );
Done: Done:
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
if (PrivateFile) { if (PrivateFile) {
@ -666,8 +648,6 @@ EmuSimpleFileSystemDriverBindingSupported (
return Status; return Status;
} }
/** /**
Starts a device controller or a bus controller. Starts a device controller or a bus controller.
@ -778,7 +758,8 @@ EmuSimpleFileSystemDriverBindingStart (
Status = gBS->InstallMultipleProtocolInterfaces ( Status = gBS->InstallMultipleProtocolInterfaces (
&ControllerHandle, &ControllerHandle,
&gEfiSimpleFileSystemProtocolGuid, &Private->SimpleFileSystem, &gEfiSimpleFileSystemProtocolGuid,
&Private->SimpleFileSystem,
NULL NULL
); );
@ -790,7 +771,6 @@ Done:
} }
gBS->FreePool (Private); gBS->FreePool (Private);
} }
gBS->CloseProtocol ( gBS->CloseProtocol (
@ -804,7 +784,6 @@ Done:
return Status; return Status;
} }
/** /**
Stops a device controller or a bus controller. Stops a device controller or a bus controller.
@ -866,7 +845,8 @@ EmuSimpleFileSystemDriverBindingStop (
// //
Status = gBS->UninstallMultipleProtocolInterfaces ( Status = gBS->UninstallMultipleProtocolInterfaces (
ControllerHandle, ControllerHandle,
&gEfiSimpleFileSystemProtocolGuid, &Private->SimpleFileSystem, &gEfiSimpleFileSystemProtocolGuid,
&Private->SimpleFileSystem,
NULL NULL
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
@ -892,7 +872,6 @@ EmuSimpleFileSystemDriverBindingStop (
return Status; return Status;
} }
EFI_DRIVER_BINDING_PROTOCOL gEmuSimpleFileSystemDriverBinding = { EFI_DRIVER_BINDING_PROTOCOL gEmuSimpleFileSystemDriverBinding = {
EmuSimpleFileSystemDriverBindingSupported, EmuSimpleFileSystemDriverBindingSupported,
EmuSimpleFileSystemDriverBindingStart, EmuSimpleFileSystemDriverBindingStart,
@ -902,9 +881,6 @@ EFI_DRIVER_BINDING_PROTOCOL gEmuSimpleFileSystemDriverBinding = {
NULL NULL
}; };
/** /**
The user Entry Point for module EmuSimpleFileSystem. The user code starts with this function. The user Entry Point for module EmuSimpleFileSystem. The user code starts with this function.
@ -917,7 +893,7 @@ EFI_DRIVER_BINDING_PROTOCOL gEmuSimpleFileSystemDriverBinding = {
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
InitializeEmuSimpleFileSystem( InitializeEmuSimpleFileSystem (
IN EFI_HANDLE ImageHandle, IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable IN EFI_SYSTEM_TABLE *SystemTable
) )

View File

@ -30,7 +30,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/MemoryAllocationLib.h> #include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h> #include <Library/UefiBootServicesTableLib.h>
extern EFI_DRIVER_BINDING_PROTOCOL gEmuSimpleFileSystemDriverBinding; extern EFI_DRIVER_BINDING_PROTOCOL gEmuSimpleFileSystemDriverBinding;
extern EFI_COMPONENT_NAME_PROTOCOL gEmuSimpleFileSystemComponentName; extern EFI_COMPONENT_NAME_PROTOCOL gEmuSimpleFileSystemComponentName;
extern EFI_COMPONENT_NAME2_PROTOCOL gEmuSimpleFileSystemComponentName2; extern EFI_COMPONENT_NAME2_PROTOCOL gEmuSimpleFileSystemComponentName2;
@ -69,6 +68,4 @@ typedef struct {
EMU_EFI_FILE_PRIVATE_SIGNATURE \ EMU_EFI_FILE_PRIVATE_SIGNATURE \
) )
#endif #endif

View File

@ -17,6 +17,7 @@ Abstract:
// //
// EFI Component Name Functions // EFI Component Name Functions
// //
/** /**
Retrieves a Unicode string that is the user readable name of the driver. Retrieves a Unicode string that is the user readable name of the driver.
@ -64,7 +65,6 @@ EmuSnpDriverComponentNameGetDriverName (
OUT CHAR16 **DriverName OUT CHAR16 **DriverName
); );
/** /**
Retrieves a Unicode string that is the user readable name of the controller Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver. that is being managed by a driver.
@ -143,7 +143,6 @@ EmuSnpDriverComponentNameGetControllerName (
OUT CHAR16 **ControllerName OUT CHAR16 **ControllerName
); );
// //
// EFI Component Name Protocol // EFI Component Name Protocol
// //
@ -157,12 +156,11 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gEmuSnpDriverComponen
// EFI Component Name 2 Protocol // EFI Component Name 2 Protocol
// //
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuSnpDriverComponentName2 = { GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuSnpDriverComponentName2 = {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) EmuSnpDriverComponentNameGetDriverName, (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)EmuSnpDriverComponentNameGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) EmuSnpDriverComponentNameGetControllerName, (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)EmuSnpDriverComponentNameGetControllerName,
"en" "en"
}; };
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mEmuSnpDriverNameTable[] = { GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mEmuSnpDriverNameTable[] = {
{ {
"eng;en", "eng;en",

View File

@ -15,8 +15,6 @@ Abstract:
#include "EmuSnpDxe.h" #include "EmuSnpDxe.h"
EFI_SIMPLE_NETWORK_PROTOCOL gEmuSnpTemplate = { EFI_SIMPLE_NETWORK_PROTOCOL gEmuSnpTemplate = {
EFI_SIMPLE_NETWORK_PROTOCOL_REVISION, EFI_SIMPLE_NETWORK_PROTOCOL_REVISION,
EmuSnpStart, EmuSnpStart,
@ -34,7 +32,7 @@ EFI_SIMPLE_NETWORK_PROTOCOL gEmuSnpTemplate = {
EmuSnpReceive, EmuSnpReceive,
NULL, // WaitForPacket NULL, // WaitForPacket
NULL // Mode NULL // Mode
}; };
EFI_SIMPLE_NETWORK_MODE gEmuSnpModeTemplate = { EFI_SIMPLE_NETWORK_MODE gEmuSnpModeTemplate = {
EfiSimpleNetworkStopped, // State EfiSimpleNetworkStopped, // State
@ -48,7 +46,9 @@ EFI_SIMPLE_NETWORK_MODE gEmuSnpModeTemplate = {
MAX_MCAST_FILTER_CNT, // MaxMCastFilterCount MAX_MCAST_FILTER_CNT, // MaxMCastFilterCount
0, // MCastFilterCount 0, // MCastFilterCount
{ {
{ { 0 } } {
{ 0 }
}
}, // MCastFilter }, // MCastFilter
{ {
{ 0 } { 0 }
@ -66,7 +66,6 @@ EFI_SIMPLE_NETWORK_MODE gEmuSnpModeTemplate = {
TRUE // MediaPresent TRUE // MediaPresent
}; };
/** /**
Changes the state of a network interface from "stopped" to "started". Changes the state of a network interface from "stopped" to "started".
@ -77,7 +76,7 @@ EFI_SIMPLE_NETWORK_MODE gEmuSnpModeTemplate = {
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EmuSnpStart( EmuSnpStart (
IN EFI_SIMPLE_NETWORK_PROTOCOL *This IN EFI_SIMPLE_NETWORK_PROTOCOL *This
) )
{ {
@ -90,7 +89,6 @@ EmuSnpStart(
return Status; return Status;
} }
/** /**
Changes the state of a network interface from "started" to "stopped". Changes the state of a network interface from "started" to "stopped".
@ -114,7 +112,6 @@ EmuSnpStop (
return Status; return Status;
} }
/** /**
Resets a network adapter and allocates the transmit and receive buffers Resets a network adapter and allocates the transmit and receive buffers
required by the network interface; optionally, also requests allocation required by the network interface; optionally, also requests allocation
@ -354,7 +351,6 @@ EmuSnpMcastIptoMac (
return Status; return Status;
} }
/** /**
Performs read and write operations on the NVRAM device attached to a Performs read and write operations on the NVRAM device attached to a
network interface. network interface.
@ -390,7 +386,6 @@ EmuSnpNvdata (
return Status; return Status;
} }
/** /**
Reads the current interrupt status and recycled transmit buffer status from Reads the current interrupt status and recycled transmit buffer status from
a network interface. a network interface.
@ -429,7 +424,6 @@ EmuSnpGetStatus (
return Status; return Status;
} }
/** /**
Places a packet in the transmit queue of a network interface. Places a packet in the transmit queue of a network interface.
@ -466,7 +460,7 @@ EmuSnpTransmit (
IN EFI_SIMPLE_NETWORK_PROTOCOL *This, IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
IN UINTN HeaderSize, IN UINTN HeaderSize,
IN UINTN BufferSize, IN UINTN BufferSize,
IN VOID* Buffer, IN VOID *Buffer,
IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL, IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
IN EFI_MAC_ADDRESS *DestAddr OPTIONAL, IN EFI_MAC_ADDRESS *DestAddr OPTIONAL,
IN UINT16 *Protocol OPTIONAL IN UINT16 *Protocol OPTIONAL
@ -548,8 +542,6 @@ EmuSnpReceive (
return Status; return Status;
} }
/** /**
Test to see if this driver supports ControllerHandle. This service Test to see if this driver supports ControllerHandle. This service
is called by the EFI boot service ConnectController(). In is called by the EFI boot service ConnectController(). In
@ -583,15 +575,15 @@ EmuSnpDriverBindingSupported (
if (RemainingDevicePath != NULL) { if (RemainingDevicePath != NULL) {
if (!IsDevicePathEnd (RemainingDevicePath)) { if (!IsDevicePathEnd (RemainingDevicePath)) {
Node = (MAC_ADDR_DEVICE_PATH *)RemainingDevicePath; Node = (MAC_ADDR_DEVICE_PATH *)RemainingDevicePath;
if (Node->Header.Type != MESSAGING_DEVICE_PATH || if ((Node->Header.Type != MESSAGING_DEVICE_PATH) ||
Node->Header.SubType != MSG_MAC_ADDR_DP) { (Node->Header.SubType != MSG_MAC_ADDR_DP))
{
// If the remaining device path does not match we don't support the request // If the remaining device path does not match we don't support the request
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
} }
} }
// //
// Open the IO Abstraction(s) needed to perform the supported test // Open the IO Abstraction(s) needed to perform the supported test
// //
@ -617,14 +609,13 @@ EmuSnpDriverBindingSupported (
ControllerHandle ControllerHandle
); );
// //
// Open the EFI Device Path protocol needed to perform the supported test // Open the EFI Device Path protocol needed to perform the supported test
// //
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ControllerHandle, ControllerHandle,
&gEfiDevicePathProtocolGuid, &gEfiDevicePathProtocolGuid,
(VOID **) &ParentDevicePath, (VOID **)&ParentDevicePath,
This->DriverBindingHandle, This->DriverBindingHandle,
ControllerHandle, ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER EFI_OPEN_PROTOCOL_BY_DRIVER
@ -658,7 +649,6 @@ EmuSnpDriverBindingSupported (
return Status; return Status;
} }
/** /**
Start this driver on ControllerHandle. This service is called by the Start this driver on ControllerHandle. This service is called by the
EFI boot service ConnectController(). In order to make EFI boot service ConnectController(). In order to make
@ -694,10 +684,10 @@ EmuSnpDriverBindingStart (
// //
// Grab the protocols we need // Grab the protocols we need
// //
Status = gBS->OpenProtocol( Status = gBS->OpenProtocol (
ControllerHandle, ControllerHandle,
&gEfiDevicePathProtocolGuid, &gEfiDevicePathProtocolGuid,
( VOID ** ) &ParentDevicePath, (VOID **)&ParentDevicePath,
This->DriverBindingHandle, This->DriverBindingHandle,
ControllerHandle, ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER EFI_OPEN_PROTOCOL_BY_DRIVER
@ -747,7 +737,6 @@ EmuSnpDriverBindingStart (
Private->Snp.Mode = &Private->Mode; Private->Snp.Mode = &Private->Mode;
Private->ControllerNameTable = NULL; Private->ControllerNameTable = NULL;
Status = Private->Io->CreateMapping (Private->Io, &Private->Mode); Status = Private->Io->CreateMapping (Private->Io, &Private->Mode);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto Done; goto Done;
@ -763,7 +752,7 @@ EmuSnpDriverBindingStart (
Node.Header.SubType = MSG_MAC_ADDR_DP; Node.Header.SubType = MSG_MAC_ADDR_DP;
Node.IfType = Private->Mode.IfType; 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)); CopyMem (&Node.MacAddress, &Private->Mode.CurrentAddress, sizeof (EFI_MAC_ADDRESS));
@ -795,10 +784,12 @@ EmuSnpDriverBindingStart (
// //
// Create Child Handle // Create Child Handle
// //
Status = gBS->InstallMultipleProtocolInterfaces( Status = gBS->InstallMultipleProtocolInterfaces (
&Private->DeviceHandle, &Private->DeviceHandle,
&gEfiSimpleNetworkProtocolGuid, &Private->Snp, &gEfiSimpleNetworkProtocolGuid,
&gEfiDevicePathProtocolGuid, Private->DevicePath, &Private->Snp,
&gEfiDevicePathProtocolGuid,
Private->DevicePath,
NULL NULL
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -822,8 +813,9 @@ Done:
if (Private != NULL) { if (Private != NULL) {
FreePool (Private); FreePool (Private);
} }
if (ParentDevicePath != NULL) { if (ParentDevicePath != NULL) {
gBS->CloseProtocol( gBS->CloseProtocol (
ControllerHandle, ControllerHandle,
&gEfiDevicePathProtocolGuid, &gEfiDevicePathProtocolGuid,
This->DriverBindingHandle, This->DriverBindingHandle,
@ -892,14 +884,13 @@ EmuSnpDriverBindingStop (
ASSERT (NumberOfChildren == 1); ASSERT (NumberOfChildren == 1);
// //
// Get our context back. // Get our context back.
// //
Status = gBS->OpenProtocol( Status = gBS->OpenProtocol (
ChildHandleBuffer[0], ChildHandleBuffer[0],
&gEfiSimpleNetworkProtocolGuid, &gEfiSimpleNetworkProtocolGuid,
( VOID ** ) &Snp, (VOID **)&Snp,
This->DriverBindingHandle, This->DriverBindingHandle,
ControllerHandle, ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -912,7 +903,7 @@ EmuSnpDriverBindingStop (
ASSERT (Private->DeviceHandle == ChildHandleBuffer[0]); ASSERT (Private->DeviceHandle == ChildHandleBuffer[0]);
ASSERT (Private->EfiHandle == ControllerHandle); ASSERT (Private->EfiHandle == ControllerHandle);
Status = gBS->CloseProtocol( Status = gBS->CloseProtocol (
ControllerHandle, ControllerHandle,
&gEmuIoThunkProtocolGuid, &gEmuIoThunkProtocolGuid,
This->DriverBindingHandle, This->DriverBindingHandle,
@ -920,10 +911,12 @@ EmuSnpDriverBindingStop (
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
Status = gBS->UninstallMultipleProtocolInterfaces( Status = gBS->UninstallMultipleProtocolInterfaces (
Private->DeviceHandle, Private->DeviceHandle,
&gEfiSimpleNetworkProtocolGuid, &Private->Snp, &gEfiSimpleNetworkProtocolGuid,
&gEfiDevicePathProtocolGuid, Private->DevicePath, &Private->Snp,
&gEfiDevicePathProtocolGuid,
Private->DevicePath,
NULL NULL
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -947,7 +940,6 @@ EmuSnpDriverBindingStop (
return Status; return Status;
} }
EFI_DRIVER_BINDING_PROTOCOL gEmuSnpDriverBinding = { EFI_DRIVER_BINDING_PROTOCOL gEmuSnpDriverBinding = {
EmuSnpDriverBindingSupported, EmuSnpDriverBindingSupported,
EmuSnpDriverBindingStart, EmuSnpDriverBindingStart,
@ -957,8 +949,6 @@ EFI_DRIVER_BINDING_PROTOCOL gEmuSnpDriverBinding = {
NULL NULL
}; };
/** /**
This is the declaration of an EFI image entry point. This entry point is 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 the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
@ -983,7 +973,7 @@ InitializeEmuSnpDriver (
// //
// Install the Driver Protocols // Install the Driver Protocols
// //
Status = EfiLibInstallDriverBindingComponentName2( Status = EfiLibInstallDriverBindingComponentName2 (
ImageHandle, ImageHandle,
SystemTable, SystemTable,
&gEmuSnpDriverBinding, &gEmuSnpDriverBinding,

View File

@ -22,7 +22,6 @@ Abstract:
#include <Protocol/EmuIoThunk.h> #include <Protocol/EmuIoThunk.h>
#include <Protocol/EmuSnp.h> #include <Protocol/EmuSnp.h>
#include <Library/BaseLib.h> #include <Library/BaseLib.h>
#include <Library/DebugLib.h> #include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h> #include <Library/BaseMemoryLib.h>
@ -52,7 +51,6 @@ typedef struct {
EFI_SIMPLE_NETWORK_MODE Mode; EFI_SIMPLE_NETWORK_MODE Mode;
EFI_UNICODE_STRING_TABLE *ControllerNameTable; EFI_UNICODE_STRING_TABLE *ControllerNameTable;
} EMU_SNP_PRIVATE_DATA; } EMU_SNP_PRIVATE_DATA;
#define EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS(a) \ #define EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS(a) \
@ -82,9 +80,9 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gEmuSnpDriverComponentName2;
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EmuSnpDriverBindingSupported ( EmuSnpDriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL * This, IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle, 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 EFI_STATUS
EFIAPI EFIAPI
EmuSnpDriverBindingStart ( EmuSnpDriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL * This, IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle, 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 EFI_STATUS
EFIAPI EFIAPI
EmuSnpStart( EmuSnpStart (
IN EFI_SIMPLE_NETWORK_PROTOCOL* This IN EFI_SIMPLE_NETWORK_PROTOCOL *This
); );
/** /**
@ -161,8 +159,8 @@ EmuSnpStart(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EmuSnpStop( EmuSnpStop (
IN EFI_SIMPLE_NETWORK_PROTOCOL* This IN EFI_SIMPLE_NETWORK_PROTOCOL *This
); );
/** /**
@ -187,8 +185,8 @@ EmuSnpStop(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EmuSnpInitialize( EmuSnpInitialize (
IN EFI_SIMPLE_NETWORK_PROTOCOL* This, IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
IN UINTN ExtraRxBufferSize OPTIONAL, IN UINTN ExtraRxBufferSize OPTIONAL,
IN UINTN ExtraTxBufferSize OPTIONAL IN UINTN ExtraTxBufferSize OPTIONAL
); );
@ -207,8 +205,8 @@ EmuSnpInitialize(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EmuSnpReset( EmuSnpReset (
IN EFI_SIMPLE_NETWORK_PROTOCOL* This, IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
IN BOOLEAN ExtendedVerification IN BOOLEAN ExtendedVerification
); );
@ -223,8 +221,8 @@ EmuSnpReset(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EmuSnpShutdown( EmuSnpShutdown (
IN EFI_SIMPLE_NETWORK_PROTOCOL* This IN EFI_SIMPLE_NETWORK_PROTOCOL *This
); );
/** /**
@ -250,13 +248,13 @@ EmuSnpShutdown(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EmuSnpReceiveFilters( EmuSnpReceiveFilters (
IN EFI_SIMPLE_NETWORK_PROTOCOL* This, IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
IN UINT32 EnableBits, IN UINT32 EnableBits,
IN UINT32 DisableBits, IN UINT32 DisableBits,
IN BOOLEAN ResetMcastFilter, IN BOOLEAN ResetMcastFilter,
IN UINTN McastFilterCount OPTIONAL, IN UINTN McastFilterCount OPTIONAL,
IN EFI_MAC_ADDRESS* McastFilter OPTIONAL IN EFI_MAC_ADDRESS *McastFilter OPTIONAL
); );
/** /**
@ -272,10 +270,10 @@ EmuSnpReceiveFilters(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EmuSnpStationAddress( EmuSnpStationAddress (
IN EFI_SIMPLE_NETWORK_PROTOCOL* This, IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
IN BOOLEAN Reset, IN BOOLEAN Reset,
IN EFI_MAC_ADDRESS* NewMacAddr OPTIONAL IN EFI_MAC_ADDRESS *NewMacAddr OPTIONAL
); );
/** /**
@ -299,11 +297,11 @@ EmuSnpStationAddress(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EmuSnpStatistics( EmuSnpStatistics (
IN EFI_SIMPLE_NETWORK_PROTOCOL* This, IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
IN BOOLEAN Reset, IN BOOLEAN Reset,
IN OUT UINTN* StatisticsSize OPTIONAL, IN OUT UINTN *StatisticsSize OPTIONAL,
OUT EFI_NETWORK_STATISTICS* StatisticsTable OPTIONAL OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL
); );
/** /**
@ -327,11 +325,11 @@ EmuSnpStatistics(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EmuSnpMcastIptoMac( EmuSnpMcastIptoMac (
IN EFI_SIMPLE_NETWORK_PROTOCOL* This, IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
IN BOOLEAN Ipv6, IN BOOLEAN Ipv6,
IN EFI_IP_ADDRESS* Ip, IN EFI_IP_ADDRESS *Ip,
OUT EFI_MAC_ADDRESS* Mac OUT EFI_MAC_ADDRESS *Mac
); );
/** /**
@ -352,12 +350,12 @@ EmuSnpMcastIptoMac(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EmuSnpNvdata( EmuSnpNvdata (
IN EFI_SIMPLE_NETWORK_PROTOCOL* This, IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
IN BOOLEAN ReadOrWrite, IN BOOLEAN ReadOrWrite,
IN UINTN Offset, IN UINTN Offset,
IN UINTN BufferSize, IN UINTN BufferSize,
IN OUT VOID* Buffer IN OUT VOID *Buffer
); );
/** /**
@ -383,10 +381,10 @@ EmuSnpNvdata(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EmuSnpGetStatus( EmuSnpGetStatus (
IN EFI_SIMPLE_NETWORK_PROTOCOL* This, IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
OUT UINT32* InterruptStatus, OUT UINT32 *InterruptStatus,
OUT VOID** TxBuffer OUT VOID **TxBuffer
); );
/** /**
@ -420,14 +418,14 @@ EmuSnpGetStatus(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EmuSnpTransmit( EmuSnpTransmit (
IN EFI_SIMPLE_NETWORK_PROTOCOL* This, IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
IN UINTN HeaderSize, IN UINTN HeaderSize,
IN UINTN BufferSize, IN UINTN BufferSize,
IN VOID* Buffer, IN VOID *Buffer,
IN EFI_MAC_ADDRESS* SrcAddr OPTIONAL, IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
IN EFI_MAC_ADDRESS* DestAddr OPTIONAL, IN EFI_MAC_ADDRESS *DestAddr OPTIONAL,
IN UINT16* Protocol OPTIONAL IN UINT16 *Protocol OPTIONAL
); );
/** /**
@ -462,21 +460,21 @@ EmuSnpTransmit(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EmuSnpReceive( EmuSnpReceive (
IN EFI_SIMPLE_NETWORK_PROTOCOL* This, IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
OUT UINTN* HeaderSize OPTIONAL, OUT UINTN *HeaderSize OPTIONAL,
IN OUT UINTN* BuffSize, IN OUT UINTN *BuffSize,
OUT VOID* Buffer, OUT VOID *Buffer,
OUT EFI_MAC_ADDRESS* SourceAddr OPTIONAL, OUT EFI_MAC_ADDRESS *SourceAddr OPTIONAL,
OUT EFI_MAC_ADDRESS* DestinationAddr OPTIONAL, OUT EFI_MAC_ADDRESS *DestinationAddr OPTIONAL,
OUT UINT16* Protocol OPTIONAL OUT UINT16 *Protocol OPTIONAL
); );
VOID VOID
EFIAPI EFIAPI
EmuSnpWaitForPacketNotify( EmuSnpWaitForPacketNotify (
IN EFI_EVENT Event, IN EFI_EVENT Event,
IN VOID* Private IN VOID *Private
); );
#endif // _EMU_SNP_H_ #endif // _EMU_SNP_H_

View File

@ -29,8 +29,8 @@ EMU_THUNK_DEVICE_PATH mEmuThunkDevicePath = {
HARDWARE_DEVICE_PATH, HARDWARE_DEVICE_PATH,
HW_VENDOR_DP, HW_VENDOR_DP,
{ {
(UINT8) (sizeof (EMU_VENDOR_DEVICE_PATH_NODE)), (UINT8)(sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),
(UINT8) ((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8) (UINT8)((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)
} }
}, },
EMU_THUNK_PROTOCOL_GUID EMU_THUNK_PROTOCOL_GUID
@ -47,13 +47,13 @@ EMU_THUNK_DEVICE_PATH mEmuThunkDevicePath = {
} }
}; };
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
InitializeEmuThunk ( InitializeEmuThunk (
IN EFI_HANDLE ImageHandle, IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable IN EFI_SYSTEM_TABLE *SystemTable
) )
/*++ /*++
Routine Description: Routine Description:
@ -74,8 +74,10 @@ Returns:
Handle = NULL; Handle = NULL;
Status = gBS->InstallMultipleProtocolInterfaces ( Status = gBS->InstallMultipleProtocolInterfaces (
&Handle, &Handle,
&gEmuThunkProtocolGuid, gEmuThunk, &gEmuThunkProtocolGuid,
&gEfiDevicePathProtocolGuid, &mEmuThunkDevicePath, gEmuThunk,
&gEfiDevicePathProtocolGuid,
&mEmuThunkDevicePath,
NULL NULL
); );

View File

@ -21,6 +21,7 @@ PeimInitializeFirmwareVolumePei (
IN EFI_PEI_FILE_HANDLE FileHandle, IN EFI_PEI_FILE_HANDLE FileHandle,
IN CONST EFI_PEI_SERVICES **PeiServices IN CONST EFI_PEI_SERVICES **PeiServices
) )
/*++ /*++
Routine Description: Routine Description:
@ -67,7 +68,7 @@ Returns:
// //
// Assume the FD starts with an FV header // 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 // Make an FV Hob for the first FV in the FD

View File

@ -7,7 +7,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#include "PiPei.h" #include "PiPei.h"
#include <Guid/SystemNvDataGuid.h> #include <Guid/SystemNvDataGuid.h>
@ -27,6 +26,7 @@ PeimInitializeFlashMap (
IN EFI_PEI_FILE_HANDLE FileHandle, IN EFI_PEI_FILE_HANDLE FileHandle,
IN CONST EFI_PEI_SERVICES **PeiServices IN CONST EFI_PEI_SERVICES **PeiServices
) )
/*++ /*++
Routine Description: Routine Description:

View File

@ -67,14 +67,13 @@ EFI_FW_VOL_BLOCK_DEVICE mFvbDeviceTemplate = {
} }
}; };
VOID VOID
EFIAPI EFIAPI
FvbVirtualddressChangeEvent ( FvbVirtualddressChangeEvent (
IN EFI_EVENT Event, IN EFI_EVENT Event,
IN VOID *Context IN VOID *Context
) )
/*++ /*++
Routine Description: Routine Description:
@ -100,7 +99,7 @@ Returns:
EFI_FW_VOL_INSTANCE *FwhInstance; EFI_FW_VOL_INSTANCE *FwhInstance;
UINTN Index; UINTN Index;
EfiConvertPointer (0x0, (VOID **) &mFvbModuleGlobal->FvInstance[FVB_VIRTUAL]); EfiConvertPointer (0x0, (VOID **)&mFvbModuleGlobal->FvInstance[FVB_VIRTUAL]);
// //
// Convert the base address of all the instances // Convert the base address of all the instances
@ -108,16 +107,16 @@ Returns:
Index = 0; Index = 0;
FwhInstance = mFvbModuleGlobal->FvInstance[FVB_PHYSICAL]; FwhInstance = mFvbModuleGlobal->FvInstance[FVB_PHYSICAL];
while (Index < mFvbModuleGlobal->NumFv) { while (Index < mFvbModuleGlobal->NumFv) {
EfiConvertPointer (0x0, (VOID **) &FwhInstance->FvBase[FVB_VIRTUAL]); EfiConvertPointer (0x0, (VOID **)&FwhInstance->FvBase[FVB_VIRTUAL]);
FwhInstance = (EFI_FW_VOL_INSTANCE *) FwhInstance = (EFI_FW_VOL_INSTANCE *)
( (
(UINTN) ((UINT8 *) FwhInstance) + FwhInstance->VolumeHeader.HeaderLength + (UINTN)((UINT8 *)FwhInstance) + FwhInstance->VolumeHeader.HeaderLength +
(sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER)) (sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER))
); );
Index++; Index++;
} }
EfiConvertPointer (0x0, (VOID **) &mFvbModuleGlobal); EfiConvertPointer (0x0, (VOID **)&mFvbModuleGlobal);
} }
EFI_STATUS EFI_STATUS
@ -127,6 +126,7 @@ GetFvbInstance (
OUT EFI_FW_VOL_INSTANCE **FwhInstance, OUT EFI_FW_VOL_INSTANCE **FwhInstance,
IN BOOLEAN Virtual IN BOOLEAN Virtual
) )
/*++ /*++
Routine Description: Routine Description:
@ -151,6 +151,7 @@ Returns:
if (Instance >= Global->NumFv) { if (Instance >= Global->NumFv) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
// //
// Find the right instance of the FVB private data // Find the right instance of the FVB private data
// //
@ -158,7 +159,7 @@ Returns:
while (Instance > 0) { while (Instance > 0) {
FwhRecord = (EFI_FW_VOL_INSTANCE *) FwhRecord = (EFI_FW_VOL_INSTANCE *)
( (
(UINTN) ((UINT8 *) FwhRecord) + FwhRecord->VolumeHeader.HeaderLength + (UINTN)((UINT8 *)FwhRecord) + FwhRecord->VolumeHeader.HeaderLength +
(sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER)) (sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER))
); );
Instance--; Instance--;
@ -176,6 +177,7 @@ FvbGetPhysicalAddress (
IN ESAL_FWB_GLOBAL *Global, IN ESAL_FWB_GLOBAL *Global,
IN BOOLEAN Virtual IN BOOLEAN Virtual
) )
/*++ /*++
Routine Description: Routine Description:
@ -217,6 +219,7 @@ FvbGetVolumeAttributes (
IN ESAL_FWB_GLOBAL *Global, IN ESAL_FWB_GLOBAL *Global,
IN BOOLEAN Virtual IN BOOLEAN Virtual
) )
/*++ /*++
Routine Description: Routine Description:
@ -260,6 +263,7 @@ FvbGetLbaAddress (
IN ESAL_FWB_GLOBAL *Global, IN ESAL_FWB_GLOBAL *Global,
IN BOOLEAN Virtual IN BOOLEAN Virtual
) )
/*++ /*++
Routine Description: Routine Description:
@ -311,7 +315,7 @@ Returns:
NumBlocks = BlockMap->NumBlocks; NumBlocks = BlockMap->NumBlocks;
BlockLength = BlockMap->Length; BlockLength = BlockMap->Length;
if (NumBlocks == 0 || BlockLength == 0) { if ((NumBlocks == 0) || (BlockLength == 0)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -320,8 +324,8 @@ Returns:
// //
// The map entry found // The map entry found
// //
if (Lba >= StartLba && Lba < NextLba) { if ((Lba >= StartLba) && (Lba < NextLba)) {
Offset = Offset + (UINTN) MultU64x32 ((Lba - StartLba), BlockLength); Offset = Offset + (UINTN)MultU64x32 ((Lba - StartLba), BlockLength);
if (LbaAddress != NULL) { if (LbaAddress != NULL) {
*LbaAddress = FwhInstance->FvBase[Virtual] + Offset; *LbaAddress = FwhInstance->FvBase[Virtual] + Offset;
} }
@ -331,7 +335,7 @@ Returns:
} }
if (NumOfBlocks != NULL) { if (NumOfBlocks != NULL) {
*NumOfBlocks = (UINTN) (NextLba - Lba); *NumOfBlocks = (UINTN)(NextLba - Lba);
} }
return EFI_SUCCESS; return EFI_SUCCESS;
@ -353,6 +357,7 @@ FvbReadBlock (
IN ESAL_FWB_GLOBAL *Global, IN ESAL_FWB_GLOBAL *Global,
IN BOOLEAN Virtual IN BOOLEAN Virtual
) )
/*++ /*++
Routine Description: Routine Description:
@ -404,6 +409,7 @@ Returns:
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
// //
// Check if the FV is read enabled // Check if the FV is read enabled
// //
@ -412,6 +418,7 @@ Returns:
if ((Attributes & EFI_FVB2_READ_STATUS) == 0) { if ((Attributes & EFI_FVB2_READ_STATUS) == 0) {
return EFI_ACCESS_DENIED; return EFI_ACCESS_DENIED;
} }
// //
// Perform boundary checks and adjust NumBytes // Perform boundary checks and adjust NumBytes
// //
@ -420,11 +427,11 @@ Returns:
} }
if (LbaLength < (*NumBytes + BlockOffset)) { if (LbaLength < (*NumBytes + BlockOffset)) {
*NumBytes = (UINT32) (LbaLength - BlockOffset); *NumBytes = (UINT32)(LbaLength - BlockOffset);
Status = EFI_BAD_BUFFER_SIZE; Status = EFI_BAD_BUFFER_SIZE;
} }
CopyMem (Buffer, (UINT8 *) (LbaAddress + BlockOffset), (UINTN) (*NumBytes)); CopyMem (Buffer, (UINT8 *)(LbaAddress + BlockOffset), (UINTN)(*NumBytes));
return Status; return Status;
} }
@ -439,6 +446,7 @@ FvbWriteBlock (
IN ESAL_FWB_GLOBAL *Global, IN ESAL_FWB_GLOBAL *Global,
IN BOOLEAN Virtual IN BOOLEAN Virtual
) )
/*++ /*++
Routine Description: Routine Description:
@ -489,6 +497,7 @@ Returns:
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
// //
// Check if the FV is write enabled // Check if the FV is write enabled
// //
@ -497,6 +506,7 @@ Returns:
if ((Attributes & EFI_FVB2_WRITE_STATUS) == 0) { if ((Attributes & EFI_FVB2_WRITE_STATUS) == 0) {
return EFI_ACCESS_DENIED; return EFI_ACCESS_DENIED;
} }
// //
// Perform boundary checks and adjust NumBytes // Perform boundary checks and adjust NumBytes
// //
@ -505,13 +515,14 @@ Returns:
} }
if (LbaLength < (*NumBytes + BlockOffset)) { if (LbaLength < (*NumBytes + BlockOffset)) {
*NumBytes = (UINT32) (LbaLength - BlockOffset); *NumBytes = (UINT32)(LbaLength - BlockOffset);
Status = EFI_BAD_BUFFER_SIZE; Status = EFI_BAD_BUFFER_SIZE;
} }
// //
// Write data // Write data
// //
CopyMem ((UINT8 *) (LbaAddress + BlockOffset), Buffer, (UINTN) (*NumBytes)); CopyMem ((UINT8 *)(LbaAddress + BlockOffset), Buffer, (UINTN)(*NumBytes));
return Status; return Status;
} }
@ -523,6 +534,7 @@ FvbEraseBlock (
IN ESAL_FWB_GLOBAL *Global, IN ESAL_FWB_GLOBAL *Global,
IN BOOLEAN Virtual IN BOOLEAN Virtual
) )
/*++ /*++
Routine Description: Routine Description:
@ -545,7 +557,6 @@ Returns:
**/ **/
{ {
EFI_FVB_ATTRIBUTES_2 Attributes; EFI_FVB_ATTRIBUTES_2 Attributes;
UINTN LbaAddress; UINTN LbaAddress;
UINTN LbaLength; UINTN LbaLength;
@ -560,6 +571,7 @@ Returns:
if ((Attributes & EFI_FVB2_WRITE_STATUS) == 0) { if ((Attributes & EFI_FVB2_WRITE_STATUS) == 0) {
return EFI_ACCESS_DENIED; return EFI_ACCESS_DENIED;
} }
// //
// Get the starting address of the block for erase. // Get the starting address of the block for erase.
// //
@ -575,7 +587,7 @@ Returns:
Data = 0x0; Data = 0x0;
} }
SetMem ((UINT8 *) LbaAddress, LbaLength, Data); SetMem ((UINT8 *)LbaAddress, LbaLength, Data);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -587,6 +599,7 @@ FvbSetVolumeAttributes (
IN ESAL_FWB_GLOBAL *Global, IN ESAL_FWB_GLOBAL *Global,
IN BOOLEAN Virtual IN BOOLEAN Virtual
) )
/*++ /*++
Routine Description: Routine Description:
@ -622,14 +635,13 @@ Returns:
EFI_STATUS Status; EFI_STATUS Status;
EFI_FVB_ATTRIBUTES_2 UnchangedAttributes; EFI_FVB_ATTRIBUTES_2 UnchangedAttributes;
// //
// Find the right instance of the FVB private data // Find the right instance of the FVB private data
// //
Status = GetFvbInstance (Instance, Global, &FwhInstance, Virtual); Status = GetFvbInstance (Instance, Global, &FwhInstance, Virtual);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
AttribPtr = (EFI_FVB_ATTRIBUTES_2 *) &(FwhInstance->VolumeHeader.Attributes); AttribPtr = (EFI_FVB_ATTRIBUTES_2 *)&(FwhInstance->VolumeHeader.Attributes);
OldAttributes = *AttribPtr; OldAttributes = *AttribPtr;
Capabilities = OldAttributes & (EFI_FVB2_READ_DISABLED_CAP | \ Capabilities = OldAttributes & (EFI_FVB2_READ_DISABLED_CAP | \
EFI_FVB2_READ_ENABLED_CAP | \ EFI_FVB2_READ_ENABLED_CAP | \
@ -667,6 +679,7 @@ Returns:
return EFI_ACCESS_DENIED; return EFI_ACCESS_DENIED;
} }
} }
// //
// Test read disable // Test read disable
// //
@ -675,6 +688,7 @@ Returns:
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
} }
// //
// Test read enable // Test read enable
// //
@ -683,6 +697,7 @@ Returns:
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
} }
// //
// Test write disable // Test write disable
// //
@ -691,6 +706,7 @@ Returns:
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
} }
// //
// Test write enable // Test write enable
// //
@ -699,6 +715,7 @@ Returns:
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
} }
// //
// Test lock // Test lock
// //
@ -714,6 +731,7 @@ Returns:
return EFI_SUCCESS; return EFI_SUCCESS;
} }
// //
// FVB protocol APIs // FVB protocol APIs
// //
@ -723,6 +741,7 @@ FvbProtocolGetPhysicalAddress (
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
OUT EFI_PHYSICAL_ADDRESS *Address OUT EFI_PHYSICAL_ADDRESS *Address
) )
/*++ /*++
Routine Description: Routine Description:
@ -756,6 +775,7 @@ FvbProtocolGetBlockSize (
OUT UINTN *BlockSize, OUT UINTN *BlockSize,
OUT UINTN *NumOfBlocks OUT UINTN *NumOfBlocks
) )
/*++ /*++
Routine Description: Routine Description:
@ -798,6 +818,7 @@ FvbProtocolGetAttributes (
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
OUT EFI_FVB_ATTRIBUTES_2 *Attributes OUT EFI_FVB_ATTRIBUTES_2 *Attributes
) )
/*++ /*++
Routine Description: Routine Description:
@ -825,6 +846,7 @@ FvbProtocolSetAttributes (
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes
) )
/*++ /*++
Routine Description: Routine Description:
@ -852,6 +874,7 @@ FvbProtocolEraseBlocks (
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
... ...
) )
/*++ /*++
Routine Description: Routine Description:
@ -905,7 +928,7 @@ Returns:
// //
// Check input parameters // Check input parameters
// //
if (NumOfLba == 0 || (StartingLba + NumOfLba) > NumOfBlocks) { if ((NumOfLba == 0) || ((StartingLba + NumOfLba) > NumOfBlocks)) {
VA_END (args); VA_END (args);
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -932,7 +955,6 @@ Returns:
StartingLba++; StartingLba++;
NumOfLba--; NumOfLba--;
} }
} while (1); } while (1);
VA_END (args); VA_END (args);
@ -949,6 +971,7 @@ FvbProtocolWrite (
IN OUT UINTN *NumBytes, IN OUT UINTN *NumBytes,
IN UINT8 *Buffer IN UINT8 *Buffer
) )
/*++ /*++
Routine Description: Routine Description:
@ -980,7 +1003,6 @@ Returns:
**/ **/
{ {
EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
FvbDevice = FVB_DEVICE_FROM_THIS (This); FvbDevice = FVB_DEVICE_FROM_THIS (This);
@ -997,6 +1019,7 @@ FvbProtocolRead (
IN OUT UINTN *NumBytes, IN OUT UINTN *NumBytes,
IN UINT8 *Buffer IN UINT8 *Buffer
) )
/*++ /*++
Routine Description: 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); FvbDevice = FVB_DEVICE_FROM_THIS (This);
return FvbReadBlock (FvbDevice->Instance, Lba, Offset, NumBytes, Buffer, mFvbModuleGlobal, EfiGoneVirtual ()); return FvbReadBlock (FvbDevice->Instance, Lba, Offset, NumBytes, Buffer, mFvbModuleGlobal, EfiGoneVirtual ());
} }
EFI_STATUS EFI_STATUS
ValidateFvHeader ( ValidateFvHeader (
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader
) )
/*++ /*++
Routine Description: Routine Description:
@ -1065,16 +1089,18 @@ Returns:
// //
if ((FwVolHeader->Revision != EFI_FVH_REVISION) || if ((FwVolHeader->Revision != EFI_FVH_REVISION) ||
(FwVolHeader->Signature != EFI_FVH_SIGNATURE) || (FwVolHeader->Signature != EFI_FVH_SIGNATURE) ||
(FwVolHeader->FvLength == ((UINTN) -1)) || (FwVolHeader->FvLength == ((UINTN)-1)) ||
((FwVolHeader->HeaderLength & 0x01) != 0) ((FwVolHeader->HeaderLength & 0x01) != 0)
) { )
{
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
// //
// Verify the header checksum // Verify the header checksum
// //
HeaderLength = (UINT16) (FwVolHeader->HeaderLength / 2); HeaderLength = (UINT16)(FwVolHeader->HeaderLength / 2);
Ptr = (UINT16 *) FwVolHeader; Ptr = (UINT16 *)FwVolHeader;
Checksum = 0; Checksum = 0;
while (HeaderLength > 0) { while (HeaderLength > 0) {
Checksum = Checksum + (*Ptr); Checksum = Checksum + (*Ptr);
@ -1095,6 +1121,7 @@ FvbInitialize (
IN EFI_HANDLE ImageHandle, IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable IN EFI_SYSTEM_TABLE *SystemTable
) )
/*++ /*++
Routine Description: Routine Description:
@ -1136,7 +1163,7 @@ Returns:
Status = gBS->AllocatePool ( Status = gBS->AllocatePool (
EfiRuntimeServicesData, EfiRuntimeServicesData,
sizeof (ESAL_FWB_GLOBAL), sizeof (ESAL_FWB_GLOBAL),
(VOID**) &mFvbModuleGlobal (VOID **)&mFvbModuleGlobal
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
@ -1165,7 +1192,7 @@ Returns:
continue; continue;
} }
FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) BaseAddress; FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)BaseAddress;
Status = ValidateFvHeader (FwVolHeader); Status = ValidateFvHeader (FwVolHeader);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
// //
@ -1190,7 +1217,7 @@ Returns:
Status = gBS->AllocatePool ( Status = gBS->AllocatePool (
EfiRuntimeServicesData, EfiRuntimeServicesData,
BufferSize, BufferSize,
(VOID**) &mFvbModuleGlobal->FvInstance[FVB_PHYSICAL] (VOID **)&mFvbModuleGlobal->FvInstance[FVB_PHYSICAL]
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
@ -1223,7 +1250,7 @@ Returns:
continue; continue;
} }
FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) BaseAddress; FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)BaseAddress;
Status = ValidateFvHeader (FwVolHeader); Status = ValidateFvHeader (FwVolHeader);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
// //
@ -1234,20 +1261,21 @@ Returns:
FvHob.Raw = GET_NEXT_HOB (FvHob); FvHob.Raw = GET_NEXT_HOB (FvHob);
continue; continue;
} }
// //
// Write healthy FV header back. // Write healthy FV header back.
// //
CopyMem ( CopyMem (
(VOID *) (UINTN) BaseAddress, (VOID *)(UINTN)BaseAddress,
(VOID *) FwVolHeader, (VOID *)FwVolHeader,
FwVolHeader->HeaderLength FwVolHeader->HeaderLength
); );
} }
FwhInstance->FvBase[FVB_PHYSICAL] = (UINTN) BaseAddress; FwhInstance->FvBase[FVB_PHYSICAL] = (UINTN)BaseAddress;
FwhInstance->FvBase[FVB_VIRTUAL] = (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); FwVolHeader = &(FwhInstance->VolumeHeader);
EfiInitializeLock (&(FwhInstance->FvbDevLock), TPL_HIGH_LEVEL); EfiInitializeLock (&(FwhInstance->FvbDevLock), TPL_HIGH_LEVEL);
@ -1265,6 +1293,7 @@ Returns:
NumOfBlocks = NumOfBlocks + PtrBlockMapEntry->NumBlocks; NumOfBlocks = NumOfBlocks + PtrBlockMapEntry->NumBlocks;
} }
// //
// The total number of blocks in the FV. // The total number of blocks in the FV.
// //
@ -1276,7 +1305,7 @@ Returns:
Status = gBS->AllocatePool ( Status = gBS->AllocatePool (
EfiRuntimeServicesData, EfiRuntimeServicesData,
sizeof (EFI_FW_VOL_BLOCK_DEVICE), sizeof (EFI_FW_VOL_BLOCK_DEVICE),
(VOID**) &FvbDevice (VOID **)&FvbDevice
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
@ -1294,7 +1323,7 @@ Returns:
// //
// Find a handle with a matching device path that has supports FW Block protocol // 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)); CopyMem (TempFwbDevicePath, &FvbDevice->DevicePath, sizeof (FV_DEVICE_PATH));
Status = gBS->LocateDevicePath (&gEfiFirmwareVolumeBlockProtocolGuid, &TempFwbDevicePath, &FwbHandle); Status = gBS->LocateDevicePath (&gEfiFirmwareVolumeBlockProtocolGuid, &TempFwbDevicePath, &FwbHandle);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -1318,7 +1347,7 @@ Returns:
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
FwbHandle, FwbHandle,
&gEfiFirmwareVolumeBlockProtocolGuid, &gEfiFirmwareVolumeBlockProtocolGuid,
(VOID**)&OldFwbInterface (VOID **)&OldFwbInterface
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
@ -1329,7 +1358,6 @@ Returns:
&FvbDevice->FwVolBlockInstance &FvbDevice->FwVolBlockInstance
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} else { } else {
// //
// There was a FVB protocol on an End Device Path node // There was a FVB protocol on an End Device Path node
@ -1339,7 +1367,7 @@ Returns:
FwhInstance = (EFI_FW_VOL_INSTANCE *) FwhInstance = (EFI_FW_VOL_INSTANCE *)
( (
(UINTN) ((UINT8 *) FwhInstance) + FwVolHeader->HeaderLength + (UINTN)((UINT8 *)FwhInstance) + FwVolHeader->HeaderLength +
(sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER)) (sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER))
); );

View File

@ -31,7 +31,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/PcdLib.h> #include <Library/PcdLib.h>
#include <Library/DevicePathLib.h> #include <Library/DevicePathLib.h>
typedef struct { typedef struct {
UINT64 FvLength; UINT64 FvLength;
EFI_FIRMWARE_VOLUME_HEADER FvbInfo; EFI_FIRMWARE_VOLUME_HEADER FvbInfo;

View File

@ -122,7 +122,6 @@ FvbInitialize (
) )
; ;
VOID VOID
EFIAPI EFIAPI
FvbClassAddressChangeEvent ( FvbClassAddressChangeEvent (

View File

@ -13,7 +13,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define EFI_EMU_SYSTEM_CONFIG_GUID \ #define EFI_EMU_SYSTEM_CONFIG_GUID \
{ 0x9C4FB516, 0x3A1E, 0xD847, { 0xA1, 0xA1, 0x70, 0x58, 0xB6, 0x98, 0x67, 0x32 } } { 0x9C4FB516, 0x3A1E, 0xD847, { 0xA1, 0xA1, 0x70, 0x58, 0xB6, 0x98, 0x67, 0x32 } }
#pragma pack(1) #pragma pack(1)
typedef struct { typedef struct {
// //
@ -24,7 +23,6 @@ typedef struct {
} EMU_SYSTEM_CONFIGURATION; } EMU_SYSTEM_CONFIGURATION;
#pragma pack() #pragma pack()
extern EFI_GUID gEmuSystemConfigGuid; extern EFI_GUID gEmuSystemConfigGuid;
#endif #endif

View File

@ -10,10 +10,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Protocol/EmuThunk.h> #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 Serach the EMU IO Thunk database for a matching EMU IO Thunk
Protocol instance. Protocol instance.
@ -32,5 +30,4 @@ GetIoThunkInstance (
IN UINTN Instance IN UINTN Instance
); );
#endif #endif

View File

@ -7,7 +7,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Protocol/SimpleTextInEx.h> #include <Protocol/SimpleTextInEx.h>
/** /**
KeyMapMake gets called on key presses. KeyMapMake gets called on key presses.

View File

@ -8,8 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef __PPI_LIST_LIB_H__ #ifndef __PPI_LIST_LIB_H__
#define __PPI_LIST_LIB_H__ #define __PPI_LIST_LIB_H__
extern CONST EFI_PEI_PPI_DESCRIPTOR *gPpiList; extern CONST EFI_PEI_PPI_DESCRIPTOR *gPpiList;
#endif #endif

View File

@ -15,13 +15,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <IndustryStandard/SmBios.h> #include <IndustryStandard/SmBios.h>
#include <Protocol/Smbios.h> #include <Protocol/Smbios.h>
/// ///
/// Cache copy of the SMBIOS Protocol pointer /// Cache copy of the SMBIOS Protocol pointer
/// ///
extern EFI_SMBIOS_PROTOCOL *gSmbios; extern EFI_SMBIOS_PROTOCOL *gSmbios;
/// ///
/// Template for SMBIOS table initialization. /// Template for SMBIOS table initialization.
/// The SMBIOS_TABLE_STRING types in the formated area must match the /// The SMBIOS_TABLE_STRING types in the formated area must match the
@ -38,7 +36,6 @@ typedef struct {
CHAR8 **StringArray; CHAR8 **StringArray;
} SMBIOS_TEMPLATE_ENTRY; } SMBIOS_TEMPLATE_ENTRY;
/** /**
Create an initial SMBIOS Table from an array of 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. entries. SMBIOS_TEMPLATE_ENTRY.NULL indicates the end of the table.
@ -54,8 +51,6 @@ SmbiosLibInitializeFromTemplate (
IN SMBIOS_TEMPLATE_ENTRY *Template IN SMBIOS_TEMPLATE_ENTRY *Template
); );
/** /**
Create SMBIOS record. Create SMBIOS record.
@ -92,7 +87,6 @@ SmbiosLibCreateEntry (
IN CHAR8 **StringArray IN CHAR8 **StringArray
); );
/** /**
Update the string associated with an existing SMBIOS record. Update the string associated with an existing SMBIOS record.
@ -155,7 +149,6 @@ SmbiosLibReadString (
IN EFI_SMBIOS_STRING StringNumber IN EFI_SMBIOS_STRING StringNumber
); );
/** /**
Allow the caller to discover a specific SMBIOS entry, and patch it if necissary. Allow the caller to discover a specific SMBIOS entry, and patch it if necissary.
@ -190,7 +183,4 @@ SmbiosLibRemove (
OUT EFI_SMBIOS_HANDLE SmbiosHandle OUT EFI_SMBIOS_HANDLE SmbiosHandle
); );
#endif #endif

View File

@ -9,13 +9,11 @@
#include <PiPei.h> #include <PiPei.h>
EFI_PEI_PPI_DESCRIPTOR * EFI_PEI_PPI_DESCRIPTOR *
GetThunkPpiList ( GetThunkPpiList (
VOID VOID
); );
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
AddThunkPpi ( AddThunkPpi (
@ -23,5 +21,3 @@ AddThunkPpi (
IN EFI_GUID *Guid, IN EFI_GUID *Guid,
IN VOID *Ppi IN VOID *Ppi
); );

View File

@ -10,7 +10,6 @@
#include <Uefi.h> #include <Uefi.h>
#include <Protocol/EmuIoThunk.h> #include <Protocol/EmuIoThunk.h>
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
AddThunkProtocol ( AddThunkProtocol (
@ -25,5 +24,3 @@ GetNextThunkProtocol (
IN BOOLEAN EmuBusDriver, IN BOOLEAN EmuBusDriver,
OUT EMU_IO_THUNK_PROTOCOL **Instance OUT EMU_IO_THUNK_PROTOCOL **Instance
); );

View File

@ -13,8 +13,6 @@
#define EMU_THUNK_PPI_GUID \ #define EMU_THUNK_PPI_GUID \
{ 0xB958B78C, 0x1D3E, 0xEE40, { 0x8B, 0xF4, 0xF0, 0x63, 0x2D, 0x06, 0x39, 0x16 } } { 0xB958B78C, 0x1D3E, 0xEE40, { 0x8B, 0xF4, 0xF0, 0x63, 0x2D, 0x06, 0x39, 0x16 } }
/*++ /*++
Routine Description: Routine Description:
@ -33,13 +31,12 @@ Returns:
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *EMU_PEI_AUTOSCAN) ( (EFIAPI *EMU_PEI_AUTOSCAN)(
IN UINTN Index, IN UINTN Index,
OUT EFI_PHYSICAL_ADDRESS *MemoryBase, OUT EFI_PHYSICAL_ADDRESS *MemoryBase,
OUT UINT64 *MemorySize OUT UINT64 *MemorySize
); );
/*++ /*++
Routine Description: Routine Description:
@ -59,14 +56,13 @@ Returns:
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *EMU_PEI_FD_INFORMATION) ( (EFIAPI *EMU_PEI_FD_INFORMATION)(
IN UINTN Index, IN UINTN Index,
IN OUT EFI_PHYSICAL_ADDRESS *FdBase, IN OUT EFI_PHYSICAL_ADDRESS *FdBase,
IN OUT UINT64 *FdSize, IN OUT UINT64 *FdSize,
IN OUT EFI_PHYSICAL_ADDRESS *FixUp IN OUT EFI_PHYSICAL_ADDRESS *FixUp
); );
/*++ /*++
Routine Description: Routine Description:
@ -78,12 +74,10 @@ Returns:
**/ **/
typedef typedef
VOID * VOID *
(EFIAPI *EMU_PEI_THUNK_INTERFACE) ( (EFIAPI *EMU_PEI_THUNK_INTERFACE)(
VOID VOID
); );
/*++ /*++
Routine Description: Routine Description:
@ -102,14 +96,13 @@ Returns:
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *EMU_PEI_LOAD_FILE) ( (EFIAPI *EMU_PEI_LOAD_FILE)(
VOID *Pe32Data, VOID *Pe32Data,
EFI_PHYSICAL_ADDRESS *ImageAddress, EFI_PHYSICAL_ADDRESS *ImageAddress,
UINT64 *ImageSize, UINT64 *ImageSize,
EFI_PHYSICAL_ADDRESS *EntryPoint EFI_PHYSICAL_ADDRESS *EntryPoint
); );
typedef struct { typedef struct {
EMU_PEI_AUTOSCAN MemoryAutoScan; EMU_PEI_AUTOSCAN MemoryAutoScan;
EMU_PEI_FD_INFORMATION FirmwareDevices; EMU_PEI_FD_INFORMATION FirmwareDevices;

View File

@ -21,8 +21,6 @@
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. Reset the block device hardware.
@ -38,7 +36,7 @@ typedef struct _EMU_BLOCK_IO_PROTOCOL EMU_BLOCK_IO_PROTOCOL;
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *EMU_BLOCK_RESET) ( (EFIAPI *EMU_BLOCK_RESET)(
IN EMU_BLOCK_IO_PROTOCOL *This, IN EMU_BLOCK_IO_PROTOCOL *This,
IN BOOLEAN ExtendedVerification IN BOOLEAN ExtendedVerification
); );
@ -78,7 +76,7 @@ EFI_STATUS
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *EMU_BLOCK_READ) ( (EFIAPI *EMU_BLOCK_READ)(
IN EMU_BLOCK_IO_PROTOCOL *This, IN EMU_BLOCK_IO_PROTOCOL *This,
IN UINT32 MediaId, IN UINT32 MediaId,
IN EFI_LBA LBA, IN EFI_LBA LBA,
@ -120,7 +118,7 @@ EFI_STATUS
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *EMU_BLOCK_WRITE) ( (EFIAPI *EMU_BLOCK_WRITE)(
IN EMU_BLOCK_IO_PROTOCOL *This, IN EMU_BLOCK_IO_PROTOCOL *This,
IN UINT32 MediaId, IN UINT32 MediaId,
IN EFI_LBA LBA, IN EFI_LBA LBA,
@ -153,20 +151,18 @@ EFI_STATUS
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *EMU_BLOCK_FLUSH) ( (EFIAPI *EMU_BLOCK_FLUSH)(
IN EMU_BLOCK_IO_PROTOCOL *This, IN EMU_BLOCK_IO_PROTOCOL *This,
IN OUT EFI_BLOCK_IO2_TOKEN *Token IN OUT EFI_BLOCK_IO2_TOKEN *Token
); );
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *EMU_BLOCK_CREATE_MAPPING) ( (EFIAPI *EMU_BLOCK_CREATE_MAPPING)(
IN EMU_BLOCK_IO_PROTOCOL *This, IN EMU_BLOCK_IO_PROTOCOL *This,
IN EFI_BLOCK_IO_MEDIA *Media IN EFI_BLOCK_IO_MEDIA *Media
); );
/// ///
/// The Block I/O2 protocol defines an extension to the Block I/O protocol which /// 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 /// enables the ability to read and write data at a block level in a non-blocking
@ -183,4 +179,3 @@ struct _EMU_BLOCK_IO_PROTOCOL {
extern EFI_GUID gEmuBlockIoProtocolGuid; extern EFI_GUID gEmuBlockIoProtocolGuid;
#endif #endif

View File

@ -55,28 +55,26 @@ EFI_STATUS
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *EMU_GRAPHICS_WINDOWS_KEY_SET_STATE) ( (EFIAPI *EMU_GRAPHICS_WINDOWS_KEY_SET_STATE)(
IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows, IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows,
IN EFI_KEY_TOGGLE_STATE *KeyToggleState IN EFI_KEY_TOGGLE_STATE *KeyToggleState
); );
typedef typedef
VOID VOID
(EFIAPI *EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK) ( (EFIAPI *EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK)(
IN VOID *Context, IN VOID *Context,
IN EFI_KEY_DATA *KeyData IN EFI_KEY_DATA *KeyData
); );
typedef typedef
EFI_STATUS 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_PROTOCOL *GraphicsWindows,
IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK CallBack, IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK CallBack,
IN VOID *Context IN VOID *Context
); );
typedef struct { typedef struct {
UINTN SourceX; UINTN SourceX;
UINTN SourceY; UINTN SourceY;
@ -98,7 +96,7 @@ EFI_STATUS
typedef typedef
BOOLEAN BOOLEAN
(EFIAPI *EMU_GRAPHICS_WINDOWS_IS_KEY_PRESSED) ( (EFIAPI *EMU_GRAPHICS_WINDOWS_IS_KEY_PRESSED)(
IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows, IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows,
IN EFI_KEY_DATA *KeyData IN EFI_KEY_DATA *KeyData
); );
@ -128,7 +126,6 @@ struct _EMU_GRAPHICS_WINDOW_PROTOCOL {
EMU_GRAPHICS_WINDOWS_GET_POINTER_STATE GetPointerState; EMU_GRAPHICS_WINDOWS_GET_POINTER_STATE GetPointerState;
}; };
extern EFI_GUID gEmuGraphicsWindowProtocolGuid; extern EFI_GUID gEmuGraphicsWindowProtocolGuid;
#endif #endif

View File

@ -48,29 +48,27 @@ EFI_STATUS
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *EMU_GRAPHICS_WINDOWS_KEY_SET_STATE) ( (EFIAPI *EMU_GRAPHICS_WINDOWS_KEY_SET_STATE)(
IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows, IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows,
IN EFI_KEY_TOGGLE_STATE *KeyToggleState IN EFI_KEY_TOGGLE_STATE *KeyToggleState
); );
typedef typedef
VOID VOID
(EFIAPI *EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK) ( (EFIAPI *EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK)(
IN VOID *Context, IN VOID *Context,
IN EFI_KEY_DATA *KeyData IN EFI_KEY_DATA *KeyData
); );
typedef typedef
EFI_STATUS 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_PROTOCOL *GraphicsWindows,
IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK MakeCallBack, IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK MakeCallBack,
IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK BreakCallBack, IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK BreakCallBack,
IN VOID *Context IN VOID *Context
); );
typedef struct { typedef struct {
UINTN SourceX; UINTN SourceX;
UINTN SourceY; UINTN SourceY;
@ -92,7 +90,7 @@ EFI_STATUS
typedef typedef
BOOLEAN BOOLEAN
(EFIAPI *EMU_GRAPHICS_WINDOWS_IS_KEY_PRESSED) ( (EFIAPI *EMU_GRAPHICS_WINDOWS_IS_KEY_PRESSED)(
IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows, IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows,
IN EFI_KEY_DATA *KeyData IN EFI_KEY_DATA *KeyData
); );
@ -122,7 +120,6 @@ struct _EMU_GRAPHICS_WINDOW_PROTOCOL {
EMU_GRAPHICS_WINDOWS_GET_POINTER_STATE GetPointerState; EMU_GRAPHICS_WINDOWS_GET_POINTER_STATE GetPointerState;
}; };
extern EFI_GUID gEmuGraphicsWindowProtocolGuid; extern EFI_GUID gEmuGraphicsWindowProtocolGuid;
#endif #endif

View File

@ -10,23 +10,20 @@
#ifndef __EMU_IO_THUNK__ #ifndef __EMU_IO_THUNK__
#define __EMU_IO_THUNK__ #define __EMU_IO_THUNK__
#define EMU_IO_THUNK_PROTOCO_GUID \ #define EMU_IO_THUNK_PROTOCO_GUID \
{ 0x453368F6, 0x7C85, 0x434A, { 0xA9, 0x8A, 0x72, 0xD1, 0xB7, 0xFF, 0xA9, 0x26 } } { 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 typedef
EFI_STATUS EFI_STATUS
(EFIAPI *EMU_IO_THUNK_PROTOCOL_CLOSE_OPEN) ( (EFIAPI *EMU_IO_THUNK_PROTOCOL_CLOSE_OPEN)(
IN EMU_IO_THUNK_PROTOCOL *This IN EMU_IO_THUNK_PROTOCOL *This
); );
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *EMU_IO_THUNK_PROTOCOL_CLOSE_CLOSE) ( (EFIAPI *EMU_IO_THUNK_PROTOCOL_CLOSE_CLOSE)(
IN EMU_IO_THUNK_PROTOCOL *This IN EMU_IO_THUNK_PROTOCOL *This
); );

View File

@ -19,7 +19,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
typedef struct _EMU_SNP_PROTOCOL EMU_SNP_PROTOCOL; typedef struct _EMU_SNP_PROTOCOL EMU_SNP_PROTOCOL;
/** /**
Register storage for SNP Mode. Register storage for SNP Mode.
@ -37,7 +36,6 @@ EFI_STATUS
IN EFI_SIMPLE_NETWORK_MODE *Mode IN EFI_SIMPLE_NETWORK_MODE *Mode
); );
/** /**
Changes the state of a network interface from "stopped" to "started". Changes the state of a network interface from "stopped" to "started".

View File

@ -11,55 +11,47 @@
#ifndef __EMU_THREAD_THUNK__ #ifndef __EMU_THREAD_THUNK__
#define __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 typedef
UINTN UINTN
(EFIAPI *THREAD_THUNK_MUTEX_LOCK) ( (EFIAPI *THREAD_THUNK_MUTEX_LOCK)(
IN VOID *Mutex IN VOID *Mutex
); );
typedef typedef
UINTN UINTN
(EFIAPI *THREAD_THUNK_MUTEX_UNLOCK) ( (EFIAPI *THREAD_THUNK_MUTEX_UNLOCK)(
IN VOID *Mutex IN VOID *Mutex
); );
typedef typedef
UINTN UINTN
(EFIAPI *THREAD_THUNK_MUTEX_TRY_LOCK) ( (EFIAPI *THREAD_THUNK_MUTEX_TRY_LOCK)(
IN VOID *Mutex IN VOID *Mutex
); );
typedef typedef
VOID * VOID *
(EFIAPI *THREAD_THUNK_MUTEX_INIT) ( (EFIAPI *THREAD_THUNK_MUTEX_INIT)(
IN VOID IN VOID
); );
typedef typedef
UINTN UINTN
(EFIAPI *THREAD_THUNK_MUTEX_DISTROY) ( (EFIAPI *THREAD_THUNK_MUTEX_DISTROY)(
IN VOID *Mutex IN VOID *Mutex
); );
typedef typedef
VOID * VOID *
(EFIAPI *THREAD_THUNK_THREAD_ENTRY) ( (EFIAPI *THREAD_THUNK_THREAD_ENTRY)(
IN VOID *Context IN VOID *Context
); );
typedef typedef
UINTN UINTN
(EFIAPI *THREAD_THUNK_CREATE_THREAD) ( (EFIAPI *THREAD_THUNK_CREATE_THREAD)(
IN VOID *Thread, IN VOID *Thread,
IN VOID *Attribute, IN VOID *Attribute,
IN THREAD_THUNK_THREAD_ENTRY Start, IN THREAD_THUNK_THREAD_ENTRY Start,
@ -68,18 +60,16 @@ UINTN
typedef typedef
VOID VOID
(EFIAPI *THREAD_THUNK_EXIT_THREAD) ( (EFIAPI *THREAD_THUNK_EXIT_THREAD)(
IN VOID *ValuePtr IN VOID *ValuePtr
); );
typedef typedef
UINTN UINTN
(EFIAPI *THREAD_THUNK_SELF) ( (EFIAPI *THREAD_THUNK_SELF)(
VOID VOID
); );
struct _EMU_THREAD_THUNK_PROTOCOL { struct _EMU_THREAD_THUNK_PROTOCOL {
THREAD_THUNK_MUTEX_LOCK MutexLock; THREAD_THUNK_MUTEX_LOCK MutexLock;
THREAD_THUNK_MUTEX_UNLOCK MutexUnlock; THREAD_THUNK_MUTEX_UNLOCK MutexUnlock;
@ -94,4 +84,3 @@ struct _EMU_THREAD_THUNK_PROTOCOL {
extern EFI_GUID gEmuThreadThunkProtocolGuid; extern EFI_GUID gEmuThreadThunkProtocolGuid;
#endif #endif

View File

@ -21,7 +21,6 @@
#include <Protocol/EmuIoThunk.h> #include <Protocol/EmuIoThunk.h>
#include <Protocol/DevicePath.h> #include <Protocol/DevicePath.h>
typedef struct { typedef struct {
VENDOR_DEVICE_PATH VendorDevicePath; VENDOR_DEVICE_PATH VendorDevicePath;
UINT32 Instance; UINT32 Instance;
@ -32,155 +31,146 @@ typedef struct {
EFI_DEVICE_PATH_PROTOCOL EndDevicePath; EFI_DEVICE_PATH_PROTOCOL EndDevicePath;
} EMU_THUNK_DEVICE_PATH; } EMU_THUNK_DEVICE_PATH;
typedef struct _EMU_THUNK_PROTOCOL EMU_THUNK_PROTOCOL; typedef struct _EMU_THUNK_PROTOCOL EMU_THUNK_PROTOCOL;
typedef typedef
UINTN UINTN
(EFIAPI *EMU_WRITE_STD_ERROR) ( (EFIAPI *EMU_WRITE_STD_ERROR)(
IN UINT8 *Buffer, IN UINT8 *Buffer,
IN UINTN NumberOfBytes IN UINTN NumberOfBytes
); );
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *EMU_CONFIG_STD_IN) ( (EFIAPI *EMU_CONFIG_STD_IN)(
VOID VOID
); );
typedef typedef
UINTN UINTN
(EFIAPI *EMU_WRITE_STD_OUT) ( (EFIAPI *EMU_WRITE_STD_OUT)(
IN UINT8 *Buffer, IN UINT8 *Buffer,
IN UINTN NumberOfBytes IN UINTN NumberOfBytes
); );
typedef typedef
UINTN UINTN
(EFIAPI *EMU_READ_STD_IN) ( (EFIAPI *EMU_READ_STD_IN)(
OUT UINT8 *Buffer, OUT UINT8 *Buffer,
IN UINTN NumberOfBytes IN UINTN NumberOfBytes
); );
typedef typedef
BOOLEAN BOOLEAN
(EFIAPI *EMU_POLL_STD_IN) ( (EFIAPI *EMU_POLL_STD_IN)(
VOID VOID
); );
typedef typedef
VOID * VOID *
(EFIAPI *EMU_OS_MALLOC) ( (EFIAPI *EMU_OS_MALLOC)(
IN UINTN Size IN UINTN Size
); );
typedef typedef
VOID * VOID *
(EFIAPI *EMU_OS_VMALLOC) ( (EFIAPI *EMU_OS_VMALLOC)(
IN UINTN Size IN UINTN Size
); );
typedef typedef
BOOLEAN BOOLEAN
(EFIAPI *EMU_OS_FREE) ( (EFIAPI *EMU_OS_FREE)(
IN VOID *Ptr IN VOID *Ptr
); );
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *EMU_PE_COFF_GET_ENTRY_POINT) ( (EFIAPI *EMU_PE_COFF_GET_ENTRY_POINT)(
IN VOID *Pe32Data, IN VOID *Pe32Data,
IN OUT VOID **EntryPoint IN OUT VOID **EntryPoint
); );
typedef typedef
VOID VOID
(EFIAPI *EMU_PE_COFF_RELOCATE_EXTRA_ACTION) ( (EFIAPI *EMU_PE_COFF_RELOCATE_EXTRA_ACTION)(
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
); );
typedef typedef
VOID VOID
(EFIAPI *EMU_PE_COFF_UNLOAD_EXTRA_ACTION) ( (EFIAPI *EMU_PE_COFF_UNLOAD_EXTRA_ACTION)(
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
); );
typedef typedef
VOID VOID
(EFIAPI *EMU_ENABLE_INERRUPTS) ( (EFIAPI *EMU_ENABLE_INERRUPTS)(
VOID VOID
); );
typedef typedef
VOID VOID
(EFIAPI *EMU_DISABLE_INERRUPTS) ( (EFIAPI *EMU_DISABLE_INERRUPTS)(
VOID VOID
); );
typedef typedef
UINT64 UINT64
(EFIAPI *EMU_QUERY_PERFORMANCE_FREQENCY) ( (EFIAPI *EMU_QUERY_PERFORMANCE_FREQENCY)(
VOID VOID
); );
typedef typedef
UINT64 UINT64
(EFIAPI *EMU_QUERY_PERFORMANCE_COUNTER) ( (EFIAPI *EMU_QUERY_PERFORMANCE_COUNTER)(
VOID VOID
); );
typedef typedef
VOID VOID
(EFIAPI *EMU_SLEEP) ( (EFIAPI *EMU_SLEEP)(
IN UINT64 Milliseconds IN UINT64 Milliseconds
); );
typedef typedef
VOID VOID
(EFIAPI *EMU_CPU_SLEEP) ( (EFIAPI *EMU_CPU_SLEEP)(
VOID VOID
); );
typedef typedef
VOID VOID
(EFIAPI *EMU_EXIT) ( (EFIAPI *EMU_EXIT)(
IN UINTN Status IN UINTN Status
); );
typedef typedef
VOID VOID
(EFIAPI *EMU_GET_TIME) ( (EFIAPI *EMU_GET_TIME)(
OUT EFI_TIME *Time, OUT EFI_TIME *Time,
OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL
); );
typedef typedef
VOID VOID
(EFIAPI *EMU_SET_TIME) ( (EFIAPI *EMU_SET_TIME)(
IN EFI_TIME *Time IN EFI_TIME *Time
); );
typedef typedef
VOID VOID
(EFIAPI EMU_SET_TIMER_CALLBACK) ( (EFIAPI EMU_SET_TIMER_CALLBACK)(
IN UINT64 DeltaMs IN UINT64 DeltaMs
); );
typedef typedef
VOID VOID
(EFIAPI *EMU_SET_TIMER) ( (EFIAPI *EMU_SET_TIMER)(
IN UINT64 PeriodMs, IN UINT64 PeriodMs,
IN EMU_SET_TIMER_CALLBACK CallBack IN EMU_SET_TIMER_CALLBACK CallBack
); );
/** /**
Enumerates the current set of protocol instances that abstract OS services from EFI. Enumerates the current set of protocol instances that abstract OS services from EFI.
@ -203,12 +193,11 @@ VOID
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *EMU_GET_NEXT_PROTOCOL) ( (EFIAPI *EMU_GET_NEXT_PROTOCOL)(
IN BOOLEAN EmuBusDriver, IN BOOLEAN EmuBusDriver,
OUT EMU_IO_THUNK_PROTOCOL **Instance OPTIONAL OUT EMU_IO_THUNK_PROTOCOL **Instance OPTIONAL
); );
struct _EMU_THUNK_PROTOCOL { struct _EMU_THUNK_PROTOCOL {
// Used for early debug printing // Used for early debug printing
EMU_WRITE_STD_ERROR WriteStdErr; EMU_WRITE_STD_ERROR WriteStdErr;
@ -224,7 +213,6 @@ struct _EMU_THUNK_PROTOCOL {
EMU_OS_VMALLOC Valloc; EMU_OS_VMALLOC Valloc;
EMU_OS_FREE Free; EMU_OS_FREE Free;
/// ///
/// PE/COFF loader hooks to get symbols loaded /// PE/COFF loader hooks to get symbols loaded
/// ///

View File

@ -19,7 +19,6 @@
#include <Library/BaseMemoryLib.h> #include <Library/BaseMemoryLib.h>
#include <Library/DevicePathLib.h> #include <Library/DevicePathLib.h>
/** /**
Converts a Vendor device path structure to its string representative. Converts a Vendor device path structure to its string representative.
@ -52,18 +51,22 @@ DevPathToTextVendorLib (
CatPrint (Str, L"EmuThunk()"); CatPrint (Str, L"EmuThunk()");
return EFI_SUCCESS; return EFI_SUCCESS;
} }
if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuGraphicsWindowProtocolGuid)) { if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuGraphicsWindowProtocolGuid)) {
CatPrint (Str, L"EmuGraphics(%d)", Vendor->Instance); CatPrint (Str, L"EmuGraphics(%d)", Vendor->Instance);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEfiSimpleFileSystemProtocolGuid)) { if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEfiSimpleFileSystemProtocolGuid)) {
CatPrint (Str, L"EmuFs(%d)", Vendor->Instance); CatPrint (Str, L"EmuFs(%d)", Vendor->Instance);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuBlockIoProtocolGuid)) { if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuBlockIoProtocolGuid)) {
CatPrint (Str, L"EmuBlk(%d)", Vendor->Instance); CatPrint (Str, L"EmuBlk(%d)", Vendor->Instance);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuThreadThunkProtocolGuid)) { if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuThreadThunkProtocolGuid)) {
CatPrint (Str, L"EmuThread()"); CatPrint (Str, L"EmuThread()");
return EFI_SUCCESS; return EFI_SUCCESS;
@ -89,13 +92,13 @@ DevPathFromTextEmuThunk (
VENDOR_DEVICE_PATH *Vendor; VENDOR_DEVICE_PATH *Vendor;
Str = GetNextParamStr (&TextDeviceNode); Str = GetNextParamStr (&TextDeviceNode);
Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode ( Vendor = (VENDOR_DEVICE_PATH *)CreateDeviceNode (
HARDWARE_DEVICE_PATH, HARDWARE_DEVICE_PATH,
HW_VENDOR_DP, HW_VENDOR_DP,
(UINT16) sizeof (VENDOR_DEVICE_PATH) (UINT16)sizeof (VENDOR_DEVICE_PATH)
); );
CopyGuid (&Vendor->Guid, &gEmuThunkProtocolGuid); CopyGuid (&Vendor->Guid, &gEmuThunkProtocolGuid);
return (EFI_DEVICE_PATH_PROTOCOL *) Vendor; return (EFI_DEVICE_PATH_PROTOCOL *)Vendor;
} }
/** /**
@ -115,13 +118,13 @@ DevPathFromTextEmuThread (
VENDOR_DEVICE_PATH *Vendor; VENDOR_DEVICE_PATH *Vendor;
Str = GetNextParamStr (&TextDeviceNode); Str = GetNextParamStr (&TextDeviceNode);
Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode ( Vendor = (VENDOR_DEVICE_PATH *)CreateDeviceNode (
HARDWARE_DEVICE_PATH, HARDWARE_DEVICE_PATH,
HW_VENDOR_DP, HW_VENDOR_DP,
(UINT16) sizeof (VENDOR_DEVICE_PATH) (UINT16)sizeof (VENDOR_DEVICE_PATH)
); );
CopyGuid (&Vendor->Guid, &gEmuThreadThunkProtocolGuid); CopyGuid (&Vendor->Guid, &gEmuThreadThunkProtocolGuid);
return (EFI_DEVICE_PATH_PROTOCOL *) Vendor; return (EFI_DEVICE_PATH_PROTOCOL *)Vendor;
} }
/** /**
@ -141,15 +144,15 @@ DevPathFromTextEmuFs (
EMU_VENDOR_DEVICE_PATH_NODE *Vendor; EMU_VENDOR_DEVICE_PATH_NODE *Vendor;
Str = GetNextParamStr (&TextDeviceNode); Str = GetNextParamStr (&TextDeviceNode);
Vendor = (EMU_VENDOR_DEVICE_PATH_NODE *) CreateDeviceNode ( Vendor = (EMU_VENDOR_DEVICE_PATH_NODE *)CreateDeviceNode (
HARDWARE_DEVICE_PATH, HARDWARE_DEVICE_PATH,
HW_VENDOR_DP, HW_VENDOR_DP,
(UINT16) sizeof (EMU_VENDOR_DEVICE_PATH_NODE) (UINT16)sizeof (EMU_VENDOR_DEVICE_PATH_NODE)
); );
CopyGuid (&Vendor->VendorDevicePath.Guid, &gEfiSimpleFileSystemProtocolGuid); 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;
} }
/** /**

View File

@ -16,8 +16,6 @@
#include <Protocol/Timer.h> #include <Protocol/Timer.h>
/** /**
Stalls the CPU for at least the given number of microseconds. Stalls the CPU for at least the given number of microseconds.
@ -37,7 +35,6 @@ MicroSecondDelay (
return NanoSecondDelay (MicroSeconds * 1000); return NanoSecondDelay (MicroSeconds * 1000);
} }
/** /**
Stalls the CPU for at least the given number of nanoseconds. Stalls the CPU for at least the given number of nanoseconds.
@ -58,7 +55,6 @@ NanoSecondDelay (
return NanoSeconds; return NanoSeconds;
} }
/** /**
Retrieves the current value of a 64-bit free running performance counter. Retrieves the current value of a 64-bit free running performance counter.
@ -109,10 +105,10 @@ GetPerformanceCounterProperties (
OUT UINT64 *EndValue OPTIONAL OUT UINT64 *EndValue OPTIONAL
) )
{ {
if (StartValue != NULL) { if (StartValue != NULL) {
*StartValue = 0ULL; *StartValue = 0ULL;
} }
if (EndValue != NULL) { if (EndValue != NULL) {
*EndValue = (UINT64)-1LL; *EndValue = (UINT64)-1LL;
} }
@ -157,8 +153,8 @@ GetTimeInNanoSecond (
// i.e. highest bit set in Remainder should <= 33. // i.e. highest bit set in Remainder should <= 33.
// //
Shift = MAX (0, HighBitSet64 (Remainder) - 33); Shift = MAX (0, HighBitSet64 (Remainder) - 33);
Remainder = RShiftU64 (Remainder, (UINTN) Shift); Remainder = RShiftU64 (Remainder, (UINTN)Shift);
Frequency = RShiftU64 (Frequency, (UINTN) Shift); Frequency = RShiftU64 (Frequency, (UINTN)Shift);
NanoSeconds += DivU64x64Remainder (MultU64x32 (Remainder, 1000000000u), Frequency, NULL); NanoSeconds += DivU64x64Remainder (MultU64x32 (Remainder, 1000000000u), Frequency, NULL);
return NanoSeconds; return NanoSeconds;

View File

@ -15,7 +15,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
EMU_THUNK_PROTOCOL *gEmuThunk = NULL; EMU_THUNK_PROTOCOL *gEmuThunk = NULL;
/** /**
The constructor function caches the pointer of EMU Thunk protocol. The constructor function caches the pointer of EMU Thunk protocol.
@ -43,7 +42,6 @@ DxeEmuLibConstructor (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Serach the EMU IO Thunk database for a matching EMU IO Thunk Serach the EMU IO Thunk database for a matching EMU IO Thunk
Protocol instance. Protocol instance.

View File

@ -25,7 +25,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// //
EMU_THUNK_PROTOCOL *mThunk = NULL; EMU_THUNK_PROTOCOL *mThunk = NULL;
/** /**
The constructor function gets the pointer of the WinNT thunk functions The constructor function gets the pointer of the WinNT thunk functions
It will ASSERT() if Unix thunk protocol is not installed. It will ASSERT() if Unix thunk protocol is not installed.
@ -73,8 +72,6 @@ PeCoffLoaderRelocateImageExtraAction (
} }
} }
/** /**
Performs additional actions just before a PE/COFF image is unloaded. Any resources Performs additional actions just before a PE/COFF image is unloaded. Any resources
that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed. that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.

View File

@ -8,14 +8,10 @@
**/ **/
#include <PiDxe.h> #include <PiDxe.h>
#include <Library/SerialPortLib.h> #include <Library/SerialPortLib.h>
#include <Library/EmuThunkLib.h> #include <Library/EmuThunkLib.h>
/** /**
Initialize the serial device hardware. Initialize the serial device hardware.
@ -63,7 +59,6 @@ SerialPortWrite (
return gEmuThunk->WriteStdOut (Buffer, NumberOfBytes); return gEmuThunk->WriteStdOut (Buffer, NumberOfBytes);
} }
/** /**
Read data from serial device and save the datas in buffer. Read data from serial device and save the datas in buffer.
@ -149,6 +144,7 @@ SerialPortGetControl (
if (!SerialPortPoll ()) { if (!SerialPortPoll ()) {
*Control = EFI_SERIAL_INPUT_BUFFER_EMPTY; *Control = EFI_SERIAL_INPUT_BUFFER_EMPTY;
} }
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }
@ -198,4 +194,3 @@ SerialPortSetAttributes (
{ {
return RETURN_UNSUPPORTED; return RETURN_UNSUPPORTED;
} }

View File

@ -8,14 +8,10 @@
**/ **/
#include <PiDxe.h> #include <PiDxe.h>
#include <Library/SerialPortLib.h> #include <Library/SerialPortLib.h>
#include <Library/EmuThunkLib.h> #include <Library/EmuThunkLib.h>
/** /**
Initialize the serial device hardware. Initialize the serial device hardware.
@ -67,7 +63,6 @@ SerialPortWrite (
return gEmuThunk->WriteStdErr (Buffer, NumberOfBytes); return gEmuThunk->WriteStdErr (Buffer, NumberOfBytes);
} }
/** /**
Read data from serial device and save the datas in buffer. Read data from serial device and save the datas in buffer.
@ -113,5 +108,3 @@ SerialPortPoll (
{ {
return FALSE; return FALSE;
} }

View File

@ -16,7 +16,6 @@
#include <Protocol/Timer.h> #include <Protocol/Timer.h>
STATIC UINT64 gTimerPeriod = 0; STATIC UINT64 gTimerPeriod = 0;
STATIC EFI_TIMER_ARCH_PROTOCOL *gTimerAp = NULL; STATIC EFI_TIMER_ARCH_PROTOCOL *gTimerAp = NULL;
STATIC EFI_EVENT gTimerEvent = NULL; STATIC EFI_EVENT gTimerEvent = NULL;
@ -46,8 +45,6 @@ RegisterTimerArchProtocol (
} }
} }
/** /**
Stalls the CPU for at least the given number of microseconds. Stalls the CPU for at least the given number of microseconds.
@ -67,7 +64,6 @@ MicroSecondDelay (
return NanoSecondDelay (MicroSeconds * 1000); return NanoSecondDelay (MicroSeconds * 1000);
} }
/** /**
Stalls the CPU for at least the given number of nanoseconds. Stalls the CPU for at least the given number of nanoseconds.
@ -90,7 +86,8 @@ NanoSecondDelay (
if ((gTimerPeriod != 0) && if ((gTimerPeriod != 0) &&
((UINT64)NanoSeconds > gTimerPeriod) && ((UINT64)NanoSeconds > gTimerPeriod) &&
(EfiGetCurrentTpl () == TPL_APPLICATION)) { (EfiGetCurrentTpl () == TPL_APPLICATION))
{
// //
// This stall is long, so use gBS->WaitForEvent () to yield CPU to DXE Core // This stall is long, so use gBS->WaitForEvent () to yield CPU to DXE Core
// //
@ -101,14 +98,13 @@ NanoSecondDelay (
Status = gBS->WaitForEvent (sizeof (gTimerEvent)/sizeof (EFI_EVENT), &gTimerEvent, &Index); Status = gBS->WaitForEvent (sizeof (gTimerEvent)/sizeof (EFI_EVENT), &gTimerEvent, &Index);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} else { } else {
gEmuThunk->Sleep (NanoSeconds); gEmuThunk->Sleep (NanoSeconds);
} }
return NanoSeconds; return NanoSeconds;
} }
/** /**
Retrieves the current value of a 64-bit free running performance counter. Retrieves the current value of a 64-bit free running performance counter.
@ -159,10 +155,10 @@ GetPerformanceCounterProperties (
OUT UINT64 *EndValue OPTIONAL OUT UINT64 *EndValue OPTIONAL
) )
{ {
if (StartValue != NULL) { if (StartValue != NULL) {
*StartValue = 0ULL; *StartValue = 0ULL;
} }
if (EndValue != NULL) { if (EndValue != NULL) {
*EndValue = (UINT64)-1LL; *EndValue = (UINT64)-1LL;
} }
@ -170,7 +166,6 @@ GetPerformanceCounterProperties (
return gEmuThunk->QueryPerformanceFrequency (); return gEmuThunk->QueryPerformanceFrequency ();
} }
/** /**
Register for the Timer AP protocol. Register for the Timer AP protocol.
@ -235,8 +230,8 @@ GetTimeInNanoSecond (
// i.e. highest bit set in Remainder should <= 33. // i.e. highest bit set in Remainder should <= 33.
// //
Shift = MAX (0, HighBitSet64 (Remainder) - 33); Shift = MAX (0, HighBitSet64 (Remainder) - 33);
Remainder = RShiftU64 (Remainder, (UINTN) Shift); Remainder = RShiftU64 (Remainder, (UINTN)Shift);
Frequency = RShiftU64 (Frequency, (UINTN) Shift); Frequency = RShiftU64 (Frequency, (UINTN)Shift);
NanoSeconds += DivU64x64Remainder (MultU64x32 (Remainder, 1000000000u), Frequency, NULL); NanoSeconds += DivU64x64Remainder (MultU64x32 (Remainder, 1000000000u), Frequency, NULL);
return NanoSeconds; return NanoSeconds;

View File

@ -15,10 +15,8 @@
**/ **/
#include <Uefi.h> #include <Uefi.h>
#include <Library/MemoryAllocationLib.h> #include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h> #include <Library/UefiBootServicesTableLib.h>
#include <Library/BaseMemoryLib.h> #include <Library/BaseMemoryLib.h>
@ -151,7 +149,7 @@ FreePages (
// The Free thunk will not free memory allocated in emulated EFI memory. // 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 // The assmuption is this was allocated directly by EFI. We need this as some
// times protocols or EFI BootServices can return dynamically allocated buffers. // 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); ASSERT_EFI_ERROR (Status);
} }
} }
@ -195,6 +193,7 @@ InternalAllocateAlignedPages (
if (Pages == 0) { if (Pages == 0) {
return NULL; return NULL;
} }
if (Alignment > EFI_PAGE_SIZE) { if (Alignment > EFI_PAGE_SIZE) {
// //
// Caculate the total number of pages since alignment is larger than page size. // Caculate the total number of pages since alignment is larger than page size.
@ -210,15 +209,17 @@ InternalAllocateAlignedPages (
if (Memory != NULL) { if (Memory != NULL) {
return 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) { if (UnalignedPages > 0) {
// //
// Free first unaligned page(s). // Free first unaligned page(s).
// //
FreePages (Memory, UnalignedPages); FreePages (Memory, UnalignedPages);
} }
Memory = (VOID *) (AlignedMemory + EFI_PAGES_TO_SIZE (Pages));
Memory = (VOID *)(AlignedMemory + EFI_PAGES_TO_SIZE (Pages));
UnalignedPages = RealPages - Pages - UnalignedPages; UnalignedPages = RealPages - Pages - UnalignedPages;
if (UnalignedPages > 0) { if (UnalignedPages > 0) {
// //
@ -234,9 +235,11 @@ InternalAllocateAlignedPages (
if (Memory != NULL) { if (Memory != NULL) {
return NULL; return NULL;
} }
AlignedMemory = (UINTN) Memory;
AlignedMemory = (UINTN)Memory;
} }
return (VOID *) AlignedMemory;
return (VOID *)AlignedMemory;
} }
/** /**
@ -458,6 +461,7 @@ InternalAllocateZeroPool (
if (Memory != NULL) { if (Memory != NULL) {
Memory = ZeroMem (Memory, AllocationSize); Memory = ZeroMem (Memory, AllocationSize);
} }
return Memory; return Memory;
} }
@ -554,12 +558,13 @@ InternalAllocateCopyPool (
VOID *Memory; VOID *Memory;
ASSERT (Buffer != NULL); ASSERT (Buffer != NULL);
ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1)); ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN)Buffer + 1));
Memory = InternalAllocatePool (PoolType, AllocationSize); Memory = InternalAllocatePool (PoolType, AllocationSize);
if (Memory != NULL) { if (Memory != NULL) {
Memory = CopyMem (Memory, Buffer, AllocationSize); Memory = CopyMem (Memory, Buffer, AllocationSize);
} }
return Memory; return Memory;
} }
@ -677,10 +682,11 @@ InternalReallocatePool (
VOID *NewBuffer; VOID *NewBuffer;
NewBuffer = InternalAllocateZeroPool (PoolType, NewSize); NewBuffer = InternalAllocateZeroPool (PoolType, NewSize);
if (NewBuffer != NULL && OldBuffer != NULL) { if ((NewBuffer != NULL) && (OldBuffer != NULL)) {
CopyMem (NewBuffer, OldBuffer, MIN (OldSize, NewSize)); CopyMem (NewBuffer, OldBuffer, MIN (OldSize, NewSize));
FreePool (OldBuffer); FreePool (OldBuffer);
} }
return NewBuffer; return NewBuffer;
} }
@ -810,4 +816,3 @@ FreePool (
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
} }

View File

@ -8,7 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Uefi.h> #include <Uefi.h>
#include <Protocol/SimpleTextInEx.h> #include <Protocol/SimpleTextInEx.h>
/** /**
KeyMapMake gets called on key presses. KeyMapMake gets called on key presses.

View File

@ -29,7 +29,7 @@ CONST EFI_PEI_SERVICES **gPeiServices;
VOID VOID
EFIAPI EFIAPI
SetPeiServicesTablePointer ( SetPeiServicesTablePointer (
IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer IN CONST EFI_PEI_SERVICES **PeiServicesTablePointer
) )
{ {
ASSERT (PeiServicesTablePointer != NULL); ASSERT (PeiServicesTablePointer != NULL);
@ -58,7 +58,6 @@ GetPeiServicesTablePointer (
return gPeiServices; return gPeiServices;
} }
/** /**
The constructor function caches the pointer to PEI services. The constructor function caches the pointer to PEI services.
@ -108,4 +107,3 @@ MigratePeiServicesTablePointer (
// //
return; return;
} }

View File

@ -39,7 +39,6 @@ EmuPeCoffGetThunkStucture (
EMU_THUNK_PPI *ThunkPpi; EMU_THUNK_PPI *ThunkPpi;
EFI_STATUS Status; EFI_STATUS Status;
// //
// Locate Unix ThunkPpi for retrieving standard output handle // Locate Unix ThunkPpi for retrieving standard output handle
// //
@ -47,11 +46,11 @@ EmuPeCoffGetThunkStucture (
&gEmuThunkPpiGuid, &gEmuThunkPpiGuid,
0, 0,
NULL, NULL,
(VOID **) &ThunkPpi (VOID **)&ThunkPpi
); );
ASSERT_EFI_ERROR (Status); 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; return EFI_SUCCESS;
} }
@ -71,12 +70,12 @@ PeCoffLoaderRelocateImageExtraAction (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
) )
{ {
if (EMU_MAGIC_PAGE()->Thunk == NULL) { if (EMU_MAGIC_PAGE ()->Thunk == NULL) {
EmuPeCoffGetThunkStucture (); 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 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 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
) )
{ {
if (EMU_MAGIC_PAGE()->Thunk == NULL) { if (EMU_MAGIC_PAGE ()->Thunk == NULL) {
EmuPeCoffGetThunkStucture (); EmuPeCoffGetThunkStucture ();
} }
EMU_MAGIC_PAGE()->Thunk->PeCoffUnloadImageExtraAction (ImageContext);
EMU_MAGIC_PAGE ()->Thunk->PeCoffUnloadImageExtraAction (ImageContext);
} }

View File

@ -15,8 +15,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Ppi/EmuThunk.h> #include <Ppi/EmuThunk.h>
#include <Protocol/EmuThunk.h> #include <Protocol/EmuThunk.h>
/** /**
Retrieves and returns a pointer to the entry point to a PE/COFF image that has been loaded 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. into system memory with the PE/COFF Loader Library functions.
@ -52,7 +50,7 @@ PeCoffLoaderGetEntryPoint (
&gEmuThunkPpiGuid, &gEmuThunkPpiGuid,
0, 0,
NULL, NULL,
(VOID **) &ThunkPpi (VOID **)&ThunkPpi
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
@ -86,8 +84,7 @@ PeCoffLoaderGetMachineType (
DosHdr = (EFI_IMAGE_DOS_HEADER *)Pe32Data; DosHdr = (EFI_IMAGE_DOS_HEADER *)Pe32Data;
if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) { 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 { } else {
Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)(Pe32Data); Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)(Pe32Data);
} }
@ -148,7 +145,7 @@ PeCoffLoaderGetPdbPointer (
// //
// DOS image header is present, so read the PE header after the DOS image header. // 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 { } else {
// //
// DOS image header is not present, so PE header is at the image base. // DOS image header is not present, so PE header is at the image base.
@ -160,7 +157,7 @@ PeCoffLoaderGetPdbPointer (
if (Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress != 0) { if (Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress != 0) {
DirectoryEntry = &Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG]; DirectoryEntry = &Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG];
TEImageAdjust = sizeof (EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize; TEImageAdjust = sizeof (EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize;
DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)((UINTN) Hdr.Te + DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)((UINTN)Hdr.Te +
Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress + Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress +
TEImageAdjust); TEImageAdjust);
} }
@ -197,14 +194,14 @@ PeCoffLoaderGetPdbPointer (
// //
NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes; NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;
DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]); DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) Pe32Data + DirectoryEntry->VirtualAddress); DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)((UINTN)Pe32Data + DirectoryEntry->VirtualAddress);
} else if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) { } else if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {
// //
// Use PE32+ offset get Debug Directory Entry // Use PE32+ offset get Debug Directory Entry
// //
NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes; NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;
DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]); DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) Pe32Data + DirectoryEntry->VirtualAddress); DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)((UINTN)Pe32Data + DirectoryEntry->VirtualAddress);
} }
if (NumberOfRvaAndSizes <= EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) { if (NumberOfRvaAndSizes <= EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) {
@ -215,21 +212,21 @@ PeCoffLoaderGetPdbPointer (
return NULL; return NULL;
} }
if (DebugEntry == NULL || DirectoryEntry == NULL) { if ((DebugEntry == NULL) || (DirectoryEntry == NULL)) {
return NULL; return NULL;
} }
for (DirCount = 0; DirCount < DirectoryEntry->Size; DirCount += sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY), DebugEntry++) { for (DirCount = 0; DirCount < DirectoryEntry->Size; DirCount += sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY), DebugEntry++) {
if (DebugEntry->Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) { if (DebugEntry->Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {
if (DebugEntry->SizeOfData > 0) { if (DebugEntry->SizeOfData > 0) {
CodeViewEntryPointer = (VOID *) ((UINTN) DebugEntry->RVA + ((UINTN)Pe32Data) + (UINTN)TEImageAdjust); CodeViewEntryPointer = (VOID *)((UINTN)DebugEntry->RVA + ((UINTN)Pe32Data) + (UINTN)TEImageAdjust);
switch (* (UINT32 *) CodeViewEntryPointer) { switch (*(UINT32 *)CodeViewEntryPointer) {
case CODEVIEW_SIGNATURE_NB10: case CODEVIEW_SIGNATURE_NB10:
return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY)); return (VOID *)((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY));
case CODEVIEW_SIGNATURE_RSDS: case CODEVIEW_SIGNATURE_RSDS:
return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY)); return (VOID *)((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY));
case CODEVIEW_SIGNATURE_MTOC: case CODEVIEW_SIGNATURE_MTOC:
return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY)); return (VOID *)((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY));
default: default:
break; break;
} }
@ -240,7 +237,6 @@ PeCoffLoaderGetPdbPointer (
return NULL; return NULL;
} }
/** /**
Returns the size of the PE/COFF headers Returns the size of the PE/COFF headers
@ -270,7 +266,7 @@ PeCoffGetSizeOfHeaders (
// //
// DOS image header is present, so read the PE header after the DOS image header. // 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 { } else {
// //
// DOS image header is not present, so PE header is at the image base. // DOS image header is not present, so PE header is at the image base.
@ -286,6 +282,5 @@ PeCoffGetSizeOfHeaders (
SizeOfHeaders = 0; SizeOfHeaders = 0;
} }
return (UINT32) SizeOfHeaders; return (UINT32)SizeOfHeaders;
} }

View File

@ -9,7 +9,6 @@
**/ **/
#include <PiPei.h> #include <PiPei.h>
#include <Library/SerialPortLib.h> #include <Library/SerialPortLib.h>
#include <Library/PeiServicesLib.h> #include <Library/PeiServicesLib.h>
@ -17,8 +16,6 @@
#include <Ppi/EmuThunk.h> #include <Ppi/EmuThunk.h>
#include <Protocol/EmuThunk.h> #include <Protocol/EmuThunk.h>
/** /**
Initialize the serial device hardware. Initialize the serial device hardware.
@ -74,7 +71,7 @@ SerialPortWrite (
&gEmuThunkPpiGuid, &gEmuThunkPpiGuid,
0, 0,
NULL, NULL,
(VOID **) &ThunkPpi (VOID **)&ThunkPpi
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Thunk = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk (); Thunk = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();
@ -84,7 +81,6 @@ SerialPortWrite (
return 0; return 0;
} }
/** /**
Read data from serial device and save the datas in buffer. Read data from serial device and save the datas in buffer.
@ -130,4 +126,3 @@ SerialPortPoll (
{ {
return FALSE; return FALSE;
} }

View File

@ -16,7 +16,6 @@
#include <Ppi/MemoryDiscovered.h> #include <Ppi/MemoryDiscovered.h>
CONST EFI_PEI_SERVICES **gPeiServices = NULL; CONST EFI_PEI_SERVICES **gPeiServices = NULL;
/** /**
@ -33,7 +32,7 @@ CONST EFI_PEI_SERVICES **gPeiServices = NULL;
VOID VOID
EFIAPI EFIAPI
SetPeiServicesTablePointer ( SetPeiServicesTablePointer (
IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer IN CONST EFI_PEI_SERVICES **PeiServicesTablePointer
) )
{ {
ASSERT (PeiServicesTablePointer != NULL); ASSERT (PeiServicesTablePointer != NULL);
@ -64,8 +63,6 @@ GetPeiServicesTablePointer (
return gPeiServices; return gPeiServices;
} }
/** /**
Notification service to be called when gEmuThunkPpiGuid is installed. Notification service to be called when gEmuThunkPpiGuid is installed.
@ -91,14 +88,12 @@ PeiServicesTablePointerNotifyCallback (
return EFI_SUCCESS; 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), (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
&gEfiPeiMemoryDiscoveredPpiGuid, &gEfiPeiMemoryDiscoveredPpiGuid,
PeiServicesTablePointerNotifyCallback PeiServicesTablePointerNotifyCallback
}; };
/** /**
Constructor register notification on when PPI updates. If PPI is Constructor register notification on when PPI updates. If PPI is
alreay installed registering the notify will cause the handle to alreay installed registering the notify will cause the handle to
@ -153,4 +148,3 @@ MigratePeiServicesTablePointer (
// //
return; return;
} }

View File

@ -16,7 +16,6 @@
#include <Library/DebugLib.h> #include <Library/DebugLib.h>
#include <Library/EmuMagicPageLib.h> #include <Library/EmuMagicPageLib.h>
/** /**
Caches a pointer PEI Services Table. Caches a pointer PEI Services Table.
@ -31,12 +30,12 @@
VOID VOID
EFIAPI EFIAPI
SetPeiServicesTablePointer ( SetPeiServicesTablePointer (
IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer IN CONST EFI_PEI_SERVICES **PeiServicesTablePointer
) )
{ {
ASSERT (PeiServicesTablePointer != NULL); ASSERT (PeiServicesTablePointer != NULL);
ASSERT (*PeiServicesTablePointer != NULL); ASSERT (*PeiServicesTablePointer != NULL);
EMU_MAGIC_PAGE()->PeiServicesTablePointer = PeiServicesTablePointer; EMU_MAGIC_PAGE ()->PeiServicesTablePointer = PeiServicesTablePointer;
} }
/** /**
@ -59,7 +58,7 @@ GetPeiServicesTablePointer (
{ {
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);
ASSERT (*PeiServicesTablePointer != NULL); ASSERT (*PeiServicesTablePointer != NULL);
return PeiServicesTablePointer; return PeiServicesTablePointer;
@ -91,5 +90,3 @@ MigratePeiServicesTablePointer (
// //
return; return;
} }

View File

@ -61,7 +61,7 @@ NanoSecondDelay (
&gEmuThunkPpiGuid, &gEmuThunkPpiGuid,
0, 0,
NULL, NULL,
(VOID **) &ThunkPpi (VOID **)&ThunkPpi
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Thunk = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk (); Thunk = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();
@ -100,7 +100,7 @@ GetPerformanceCounter (
&gEmuThunkPpiGuid, &gEmuThunkPpiGuid,
0, 0,
NULL, NULL,
(VOID **) &ThunkPpi (VOID **)&ThunkPpi
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Thunk = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk (); Thunk = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();
@ -151,12 +151,13 @@ GetPerformanceCounterProperties (
&gEmuThunkPpiGuid, &gEmuThunkPpiGuid,
0, 0,
NULL, NULL,
(VOID **) &ThunkPpi (VOID **)&ThunkPpi
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
if (StartValue != NULL) { if (StartValue != NULL) {
*StartValue = 0ULL; *StartValue = 0ULL;
} }
if (EndValue != NULL) { if (EndValue != NULL) {
*EndValue = (UINT64)-1LL; *EndValue = (UINT64)-1LL;
} }
@ -205,8 +206,8 @@ GetTimeInNanoSecond (
// i.e. highest bit set in Remainder should <= 33. // i.e. highest bit set in Remainder should <= 33.
// //
Shift = MAX (0, HighBitSet64 (Remainder) - 33); Shift = MAX (0, HighBitSet64 (Remainder) - 33);
Remainder = RShiftU64 (Remainder, (UINTN) Shift); Remainder = RShiftU64 (Remainder, (UINTN)Shift);
Frequency = RShiftU64 (Frequency, (UINTN) Shift); Frequency = RShiftU64 (Frequency, (UINTN)Shift);
NanoSeconds += DivU64x64Remainder (MultU64x32 (Remainder, 1000000000u), Frequency, NULL); NanoSeconds += DivU64x64Remainder (MultU64x32 (Remainder, 1000000000u), Frequency, NULL);
return NanoSeconds; return NanoSeconds;

View File

@ -30,7 +30,7 @@ SetupVariableInit (
&gEmuSystemConfigGuid, &gEmuSystemConfigGuid,
NULL, NULL,
&Size, &Size,
(VOID *) &SystemConfigData (VOID *)&SystemConfigData
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -45,7 +45,7 @@ SetupVariableInit (
&gEmuSystemConfigGuid, &gEmuSystemConfigGuid,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
sizeof (SystemConfigData), sizeof (SystemConfigData),
(VOID *) &SystemConfigData (VOID *)&SystemConfigData
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Failed to save Setup Variable to non-volatile storage, Status = %r\n", Status)); DEBUG ((DEBUG_ERROR, "Failed to save Setup Variable to non-volatile storage, Status = %r\n", Status));
@ -58,7 +58,6 @@ FvFilePath (
EFI_GUID *FileGuid EFI_GUID *FileGuid
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode; MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
@ -68,12 +67,12 @@ FvFilePath (
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
gImageHandle, gImageHandle,
&gEfiLoadedImageProtocolGuid, &gEfiLoadedImageProtocolGuid,
(VOID **) &LoadedImage (VOID **)&LoadedImage
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
return AppendDevicePathNode ( return AppendDevicePathNode (
DevicePathFromHandle (LoadedImage->DeviceHandle), DevicePathFromHandle (LoadedImage->DeviceHandle),
(EFI_DEVICE_PATH_PROTOCOL *) &FileNode (EFI_DEVICE_PATH_PROTOCOL *)&FileNode
); );
} }
@ -137,7 +136,7 @@ RegisterBootManagerMenuAppBootOption (
BOOLEAN BOOLEAN
IsBootManagerMenuAppFilePath ( IsBootManagerMenuAppFilePath (
EFI_DEVICE_PATH_PROTOCOL *DevicePath EFI_DEVICE_PATH_PROTOCOL *DevicePath
) )
{ {
EFI_HANDLE FvHandle; EFI_HANDLE FvHandle;
VOID *NameGuid; VOID *NameGuid;
@ -145,7 +144,7 @@ IsBootManagerMenuAppFilePath (
Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &DevicePath, &FvHandle); Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &DevicePath, &FvHandle);
if (!EFI_ERROR (Status)) { 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) { if (NameGuid != NULL) {
return CompareGuid (NameGuid, &mBootMenuFile); return CompareGuid (NameGuid, &mBootMenuFile);
} }
@ -189,7 +188,7 @@ GetBootManagerMenuAppOption (
// //
// If not found the BootManagerMenuApp, create it. // 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; return OptionNumber;
@ -317,7 +316,7 @@ PlatformBdsRegisterStaticBootOptions (
F2.ScanCode = SCAN_F2; F2.ScanCode = SCAN_F2;
F2.UnicodeChar = CHAR_NULL; F2.UnicodeChar = CHAR_NULL;
EfiBootManagerGetBootManagerMenu (&BootOption); EfiBootManagerGetBootManagerMenu (&BootOption);
EfiBootManagerAddKeyOptionVariable (NULL, (UINT16) BootOption.OptionNumber, 0, &F2, NULL); EfiBootManagerAddKeyOptionVariable (NULL, (UINT16)BootOption.OptionNumber, 0, &F2, NULL);
// //
// 3. Boot Device List menu // 3. Boot Device List menu
@ -348,6 +347,7 @@ BootOptionPriority (
if (StrCmp (BootOption->Description, L"UEFI Shell") == 0) { if (StrCmp (BootOption->Description, L"UEFI Shell") == 0) {
return 0; return 0;
} }
return 100; return 100;
} }
@ -377,13 +377,11 @@ PlatformBootManagerAfterConsole (
VOID VOID
) )
{ {
// //
// Go the different platform policy with different boot mode // Go the different platform policy with different boot mode
// Notes: this part code can be change with the table policy // Notes: this part code can be change with the table policy
// //
switch (GetBootModeHob ()) { switch (GetBootModeHob ()) {
case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES: case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:
case BOOT_WITH_MINIMAL_CONFIGURATION: case BOOT_WITH_MINIMAL_CONFIGURATION:
PlatformBdsDiagnostics (IGNORE, TRUE); PlatformBdsDiagnostics (IGNORE, TRUE);
@ -456,4 +454,3 @@ PlatformBootManagerUnableToBoot (
{ {
return; return;
} }

View File

@ -56,14 +56,12 @@ extern BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole[];
}\ }\
} }
typedef struct { typedef struct {
EMU_VENDOR_DEVICE_PATH_NODE EmuBus; EMU_VENDOR_DEVICE_PATH_NODE EmuBus;
EMU_VENDOR_DEVICE_PATH_NODE EmuGraphicsWindow; EMU_VENDOR_DEVICE_PATH_NODE EmuGraphicsWindow;
EFI_DEVICE_PATH_PROTOCOL End; EFI_DEVICE_PATH_PROTOCOL End;
} EMU_PLATFORM_UGA_DEVICE_PATH; } EMU_PLATFORM_UGA_DEVICE_PATH;
// //
// Platform BDS Functions // Platform BDS Functions
// //
@ -83,7 +81,6 @@ PlatformBootManagerMemoryTest (
IN EXTENDMEM_COVERAGE_LEVEL Level IN EXTENDMEM_COVERAGE_LEVEL Level
); );
VOID VOID
PlatformBdsConnectSequence ( PlatformBdsConnectSequence (
VOID VOID

View File

@ -8,8 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "PlatformBm.h" #include "PlatformBm.h"
EMU_PLATFORM_UGA_DEVICE_PATH gGopDevicePath = { EMU_PLATFORM_UGA_DEVICE_PATH gGopDevicePath = {
{ {
{ {
@ -17,8 +15,8 @@ EMU_PLATFORM_UGA_DEVICE_PATH gGopDevicePath = {
HARDWARE_DEVICE_PATH, HARDWARE_DEVICE_PATH,
HW_VENDOR_DP, HW_VENDOR_DP,
{ {
(UINT8) (sizeof (EMU_VENDOR_DEVICE_PATH_NODE)), (UINT8)(sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),
(UINT8) ((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8) (UINT8)((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)
} }
}, },
EMU_THUNK_PROTOCOL_GUID EMU_THUNK_PROTOCOL_GUID
@ -31,8 +29,8 @@ EMU_PLATFORM_UGA_DEVICE_PATH gGopDevicePath = {
HARDWARE_DEVICE_PATH, HARDWARE_DEVICE_PATH,
HW_VENDOR_DP, HW_VENDOR_DP,
{ {
(UINT8) (sizeof (EMU_VENDOR_DEVICE_PATH_NODE)), (UINT8)(sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),
(UINT8) ((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8) (UINT8)((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)
}, },
}, },
EMU_GRAPHICS_WINDOW_PROTOCOL_GUID, EMU_GRAPHICS_WINDOW_PROTOCOL_GUID,
@ -49,8 +47,8 @@ EMU_PLATFORM_UGA_DEVICE_PATH gGopDevicePath2 = {
HARDWARE_DEVICE_PATH, HARDWARE_DEVICE_PATH,
HW_VENDOR_DP, HW_VENDOR_DP,
{ {
(UINT8) (sizeof (EMU_VENDOR_DEVICE_PATH_NODE)), (UINT8)(sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),
(UINT8) ((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8) (UINT8)((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)
} }
}, },
EMU_THUNK_PROTOCOL_GUID EMU_THUNK_PROTOCOL_GUID
@ -63,8 +61,8 @@ EMU_PLATFORM_UGA_DEVICE_PATH gGopDevicePath2 = {
HARDWARE_DEVICE_PATH, HARDWARE_DEVICE_PATH,
HW_VENDOR_DP, HW_VENDOR_DP,
{ {
(UINT8) (sizeof (EMU_VENDOR_DEVICE_PATH_NODE)), (UINT8)(sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),
(UINT8) ((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8) (UINT8)((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)
}, },
}, },
EMU_GRAPHICS_WINDOW_PROTOCOL_GUID, EMU_GRAPHICS_WINDOW_PROTOCOL_GUID,
@ -79,11 +77,11 @@ EMU_PLATFORM_UGA_DEVICE_PATH gGopDevicePath2 = {
// //
BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole[] = { BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole[] = {
{ {
(EFI_DEVICE_PATH_PROTOCOL *) &gGopDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gGopDevicePath,
(CONSOLE_OUT | CONSOLE_IN) (CONSOLE_OUT | CONSOLE_IN)
}, },
{ {
(EFI_DEVICE_PATH_PROTOCOL *) &gGopDevicePath2, (EFI_DEVICE_PATH_PROTOCOL *)&gGopDevicePath2,
(CONSOLE_OUT | CONSOLE_IN) (CONSOLE_OUT | CONSOLE_IN)
}, },
{ {
@ -91,4 +89,3 @@ BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole[] = {
0 0
} }
}; };

View File

@ -52,7 +52,7 @@ PlatformBootManagerMemoryTest (
Status = gBS->LocateProtocol ( Status = gBS->LocateProtocol (
&gEfiGenericMemTestProtocolGuid, &gEfiGenericMemTestProtocolGuid,
NULL, NULL,
(VOID **) &GenMemoryTest (VOID **)&GenMemoryTest
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return EFI_SUCCESS; return EFI_SUCCESS;
@ -88,7 +88,6 @@ PlatformBootManagerMemoryTest (
ASSERT (0); ASSERT (0);
} }
DEBUG ((DEBUG_INFO, "Perform memory test (ESC to skip).\n")); DEBUG ((DEBUG_INFO, "Perform memory test (ESC to skip).\n"));
if (!PcdGetBool (PcdConInConnectOnDemand)) { if (!PcdGetBool (PcdConInConnectOnDemand)) {

View File

@ -26,7 +26,7 @@ EFIAPI
LibStopRedfishService ( LibStopRedfishService (
IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This, IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This,
IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType
); );
/** /**
Return the credential for accessing to Redfish servcice. Return the credential for accessing to Redfish servcice.
@ -44,7 +44,7 @@ GetRedfishCredential (
OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod, OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod,
OUT CHAR8 **UserId, OUT CHAR8 **UserId,
OUT CHAR8 **Password OUT CHAR8 **Password
) )
{ {
UINTN UserIdSize; UINTN UserIdSize;
UINTN PasswordSize; UINTN PasswordSize;
@ -59,14 +59,16 @@ GetRedfishCredential (
// //
UserIdSize = AsciiStrSize ((CHAR8 *)PcdGetPtr (PcdRedfishServieUserId)); UserIdSize = AsciiStrSize ((CHAR8 *)PcdGetPtr (PcdRedfishServieUserId));
PasswordSize = AsciiStrSize ((CHAR8 *)PcdGetPtr (PcdRedfishServiePassword)); 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")); DEBUG ((DEBUG_ERROR, "Incorrect string of UserID or Password for REdfish service.\n"));
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
*UserId = AllocateZeroPool (UserIdSize); *UserId = AllocateZeroPool (UserIdSize);
if (*UserId == NULL) { if (*UserId == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
CopyMem (*UserId, (CHAR8 *)PcdGetPtr (PcdRedfishServieUserId), UserIdSize); CopyMem (*UserId, (CHAR8 *)PcdGetPtr (PcdRedfishServieUserId), UserIdSize);
*Password = AllocateZeroPool (PasswordSize); *Password = AllocateZeroPool (PasswordSize);
@ -110,11 +112,11 @@ LibCredentialGetAuthInfo (
OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod, OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod,
OUT CHAR8 **UserId, OUT CHAR8 **UserId,
OUT CHAR8 **Password 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; return EFI_INVALID_PARAMETER;
} }
@ -124,7 +126,7 @@ LibCredentialGetAuthInfo (
if (mSecureBootDisabled) { if (mSecureBootDisabled) {
Status = LibStopRedfishService (This, ServiceStopTypeSecureBootDisabled); 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)); DEBUG ((DEBUG_ERROR, "SecureBoot has been disabled, but failed to stop RedfishService - %r\n", Status));
return Status; return Status;
} }
@ -161,7 +163,7 @@ EFIAPI
LibStopRedfishService ( LibStopRedfishService (
IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This, IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This,
IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType
) )
{ {
if (ServiceStopType >= ServiceStopTypeMax) { if (ServiceStopType >= ServiceStopTypeMax) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
@ -193,8 +195,10 @@ LibStopRedfishService (
mStopRedfishService = TRUE; mStopRedfishService = TRUE;
DEBUG ((DEBUG_INFO, "EFI Redfish service is stopped without Redfish service stop type!!\n")); DEBUG ((DEBUG_INFO, "EFI Redfish service is stopped without Redfish service stop type!!\n"));
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Notification of Exit Boot Service. Notification of Exit Boot Service.
@ -204,7 +208,7 @@ VOID
EFIAPI EFIAPI
LibCredentialExitBootServicesNotify ( LibCredentialExitBootServicesNotify (
IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This
) )
{ {
LibStopRedfishService (This, ServiceStopTypeExitBootService); LibStopRedfishService (This, ServiceStopTypeExitBootService);
} }
@ -218,7 +222,7 @@ VOID
EFIAPI EFIAPI
LibCredentialEndOfDxeNotify ( LibCredentialEndOfDxeNotify (
IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
UINT8 *SecureBootVar; UINT8 *SecureBootVar;
@ -226,7 +230,7 @@ LibCredentialEndOfDxeNotify (
// //
// Check Secure Boot status and lock Redfish service if Secure Boot is disabled. // 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)) { if (EFI_ERROR (Status) || (*SecureBootVar != SECURE_BOOT_MODE_ENABLE)) {
// //
// Secure Boot is disabled // Secure Boot is disabled

View File

@ -50,10 +50,11 @@ GetMacAddressInformation (
RestExServiceDevicePathData = NULL; RestExServiceDevicePathData = NULL;
RestExServiceDevicePath = NULL; RestExServiceDevicePath = NULL;
RestExServiceDevicePathData = (REST_EX_SERVICE_DEVICE_PATH_DATA *)PcdGetPtr(PcdRedfishRestExServiceDevicePath); RestExServiceDevicePathData = (REST_EX_SERVICE_DEVICE_PATH_DATA *)PcdGetPtr (PcdRedfishRestExServiceDevicePath);
if (RestExServiceDevicePathData == NULL || if ((RestExServiceDevicePathData == NULL) ||
RestExServiceDevicePathData->DevicePathNum == 0 || (RestExServiceDevicePathData->DevicePathNum == 0) ||
!IsDevicePathValid (RestExServiceDevicePathData->DevicePath, 0)) { !IsDevicePathValid (RestExServiceDevicePathData->DevicePath, 0))
{
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
@ -67,7 +68,8 @@ GetMacAddressInformation (
// //
while (!IsDevicePathEnd (RestExServiceDevicePath) && while (!IsDevicePathEnd (RestExServiceDevicePath) &&
((DevicePathType (RestExServiceDevicePath) != MESSAGING_DEVICE_PATH) || ((DevicePathType (RestExServiceDevicePath) != MESSAGING_DEVICE_PATH) ||
(DevicePathSubType (RestExServiceDevicePath) != MSG_MAC_ADDR_DP))) { (DevicePathSubType (RestExServiceDevicePath) != MSG_MAC_ADDR_DP)))
{
RestExServiceDevicePath = NextDevicePathNode (RestExServiceDevicePath); RestExServiceDevicePath = NextDevicePathNode (RestExServiceDevicePath);
} }
@ -76,6 +78,7 @@ GetMacAddressInformation (
CopyMem ((VOID *)MacAddress, (VOID *)&MacAddressDevicePath->MacAddress, sizeof (EFI_MAC_ADDRESS)); CopyMem ((VOID *)MacAddress, (VOID *)&MacAddressDevicePath->MacAddress, sizeof (EFI_MAC_ADDRESS));
return EFI_SUCCESS; return EFI_SUCCESS;
} }
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
@ -93,7 +96,7 @@ EFI_STATUS
RedfishPlatformHostInterfaceDeviceDescriptor ( RedfishPlatformHostInterfaceDeviceDescriptor (
OUT UINT8 *DeviceType, OUT UINT8 *DeviceType,
OUT REDFISH_INTERFACE_DATA **DeviceDescriptor OUT REDFISH_INTERFACE_DATA **DeviceDescriptor
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_MAC_ADDRESS MacAddress; EFI_MAC_ADDRESS MacAddress;
@ -104,6 +107,7 @@ RedfishPlatformHostInterfaceDeviceDescriptor (
if (RedfishInterfaceData == NULL) { if (RedfishInterfaceData == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
RedfishInterfaceData->DeviceType = REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2; RedfishInterfaceData->DeviceType = REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2;
// //
// Fill up device type information. // Fill up device type information.
@ -115,11 +119,13 @@ RedfishPlatformHostInterfaceDeviceDescriptor (
FreePool (RedfishInterfaceData); FreePool (RedfishInterfaceData);
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
CopyMem ((VOID *)&ThisDeviceDescriptor->MacAddress, (VOID *)&MacAddress, sizeof (ThisDeviceDescriptor->MacAddress)); 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; *DeviceDescriptor = RedfishInterfaceData;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Get platform Redfish host interface protocol data. Get platform Redfish host interface protocol data.
Caller should pass NULL in ProtocolRecord to retrive the first protocol record. Caller should pass NULL in ProtocolRecord to retrive the first protocol record.
@ -138,27 +144,30 @@ EFI_STATUS
RedfishPlatformHostInterfaceProtocolData ( RedfishPlatformHostInterfaceProtocolData (
OUT MC_HOST_INTERFACE_PROTOCOL_RECORD **ProtocolRecord, OUT MC_HOST_INTERFACE_PROTOCOL_RECORD **ProtocolRecord,
IN UINT8 IndexOfProtocolData IN UINT8 IndexOfProtocolData
) )
{ {
MC_HOST_INTERFACE_PROTOCOL_RECORD *ThisProtocolRecord; MC_HOST_INTERFACE_PROTOCOL_RECORD *ThisProtocolRecord;
if (mRedfishOverIpProtocolData == 0) { if (mRedfishOverIpProtocolData == 0) {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
if (IndexOfProtocolData == 0) { if (IndexOfProtocolData == 0) {
// //
// Return the first Redfish protocol data to caller. We only have // Return the first Redfish protocol data to caller. We only have
// one protocol data in this case. // one protocol data in this case.
// //
ThisProtocolRecord = (MC_HOST_INTERFACE_PROTOCOL_RECORD *) AllocatePool (mRedfishProtocolDataSize + sizeof (MC_HOST_INTERFACE_PROTOCOL_RECORD) - 1); ThisProtocolRecord = (MC_HOST_INTERFACE_PROTOCOL_RECORD *)AllocatePool (mRedfishProtocolDataSize + sizeof (MC_HOST_INTERFACE_PROTOCOL_RECORD) - 1);
ThisProtocolRecord->ProtocolType = MCHostInterfaceProtocolTypeRedfishOverIP; ThisProtocolRecord->ProtocolType = MCHostInterfaceProtocolTypeRedfishOverIP;
ThisProtocolRecord->ProtocolTypeDataLen = mRedfishProtocolDataSize; ThisProtocolRecord->ProtocolTypeDataLen = mRedfishProtocolDataSize;
CopyMem ((VOID *)&ThisProtocolRecord->ProtocolTypeData, (VOID *)mRedfishOverIpProtocolData, mRedfishProtocolDataSize); CopyMem ((VOID *)&ThisProtocolRecord->ProtocolTypeData, (VOID *)mRedfishOverIpProtocolData, mRedfishProtocolDataSize);
*ProtocolRecord = ThisProtocolRecord; *ProtocolRecord = ThisProtocolRecord;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
/** /**
Dump IPv4 address. Dump IPv4 address.
@ -180,6 +189,7 @@ InternalDumpIp4Addr (
DEBUG ((DEBUG_VERBOSE, "\n")); DEBUG ((DEBUG_VERBOSE, "\n"));
} }
/** /**
Dump IPv6 address. Dump IPv6 address.
@ -196,6 +206,7 @@ InternalDumpIp6Addr (
if (Ip->Addr[Index] != 0) { if (Ip->Addr[Index] != 0) {
DEBUG ((DEBUG_VERBOSE, "%x", Ip->Addr[Index])); DEBUG ((DEBUG_VERBOSE, "%x", Ip->Addr[Index]));
} }
Index++; Index++;
if (Index > 15) { if (Index > 15) {
@ -205,14 +216,17 @@ InternalDumpIp6Addr (
if (((Ip->Addr[Index] & 0xf0) == 0) && (Ip->Addr[Index - 1] != 0)) { if (((Ip->Addr[Index] & 0xf0) == 0) && (Ip->Addr[Index - 1] != 0)) {
DEBUG ((DEBUG_VERBOSE, "0")); DEBUG ((DEBUG_VERBOSE, "0"));
} }
DEBUG ((DEBUG_VERBOSE, "%x", Ip->Addr[Index])); DEBUG ((DEBUG_VERBOSE, "%x", Ip->Addr[Index]));
if (Index < 15) { if (Index < 15) {
DEBUG ((DEBUG_VERBOSE, ":")); DEBUG ((DEBUG_VERBOSE, ":"));
} }
} }
DEBUG ((DEBUG_VERBOSE, "\n")); DEBUG ((DEBUG_VERBOSE, "\n"));
} }
/** /**
Dump data Dump data
@ -226,10 +240,12 @@ InternalDumpData (
) )
{ {
UINTN Index; UINTN Index;
for (Index = 0; Index < Size; Index++) { for (Index = 0; Index < Size; Index++) {
DEBUG ((DEBUG_VERBOSE, "%02x ", (UINTN)Data[Index])); DEBUG ((DEBUG_VERBOSE, "%02x ", (UINTN)Data[Index]));
} }
} }
/** /**
Dump hex data Dump hex data
@ -260,6 +276,7 @@ InternalDumpHex (
DEBUG ((DEBUG_VERBOSE, "\n")); DEBUG ((DEBUG_VERBOSE, "\n"));
} }
/** /**
Dump Redfish over IP protocol data Dump Redfish over IP protocol data
@ -275,7 +292,7 @@ DumpRedfishIpProtocolData (
CHAR16 Hostname[16]; CHAR16 Hostname[16];
DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData: \n")); DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData: \n"));
InternalDumpHex ((UINT8 *) RedfishProtocolData, RedfishProtocolDataSize); InternalDumpHex ((UINT8 *)RedfishProtocolData, RedfishProtocolDataSize);
DEBUG ((DEBUG_VERBOSE, "Parsing as below: \n")); DEBUG ((DEBUG_VERBOSE, "Parsing as below: \n"));
@ -287,16 +304,16 @@ DumpRedfishIpProtocolData (
DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->HostIpAddress: \n")); DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->HostIpAddress: \n"));
if (RedfishProtocolData->HostIpAddressFormat == 0x01) { if (RedfishProtocolData->HostIpAddressFormat == 0x01) {
InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *) (RedfishProtocolData->HostIpAddress)); InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *)(RedfishProtocolData->HostIpAddress));
} else { } else {
InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *) (RedfishProtocolData->HostIpAddress)); InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *)(RedfishProtocolData->HostIpAddress));
} }
DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->HostIpMask: \n")); DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->HostIpMask: \n"));
if (RedfishProtocolData->HostIpAddressFormat == 0x01) { if (RedfishProtocolData->HostIpAddressFormat == 0x01) {
InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *) (RedfishProtocolData->HostIpMask)); InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *)(RedfishProtocolData->HostIpMask));
} else { } else {
InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *) (RedfishProtocolData->HostIpMask)); InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *)(RedfishProtocolData->HostIpMask));
} }
DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpDiscoveryType - %d\n", RedfishProtocolData->RedfishServiceIpDiscoveryType)); DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpDiscoveryType - %d\n", RedfishProtocolData->RedfishServiceIpDiscoveryType));
@ -305,16 +322,16 @@ DumpRedfishIpProtocolData (
DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpAddress: \n")); DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpAddress: \n"));
if (RedfishProtocolData->RedfishServiceIpAddressFormat == 0x01) { if (RedfishProtocolData->RedfishServiceIpAddressFormat == 0x01) {
InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *) (RedfishProtocolData->RedfishServiceIpAddress)); InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *)(RedfishProtocolData->RedfishServiceIpAddress));
} else { } else {
InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *) (RedfishProtocolData->RedfishServiceIpAddress)); InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *)(RedfishProtocolData->RedfishServiceIpAddress));
} }
DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpMask: \n")); DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpMask: \n"));
if (RedfishProtocolData->RedfishServiceIpAddressFormat == 0x01) { if (RedfishProtocolData->RedfishServiceIpAddressFormat == 0x01) {
InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *) (RedfishProtocolData->RedfishServiceIpMask)); InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *)(RedfishProtocolData->RedfishServiceIpMask));
} else { } else {
InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *) (RedfishProtocolData->RedfishServiceIpMask)); InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *)(RedfishProtocolData->RedfishServiceIpMask));
} }
DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpPort - %d\n", RedfishProtocolData->RedfishServiceIpPort)); DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpPort - %d\n", RedfishProtocolData->RedfishServiceIpPort));
@ -323,7 +340,7 @@ DumpRedfishIpProtocolData (
DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceHostnameLength - %d\n", RedfishProtocolData->RedfishServiceHostnameLength)); 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)); DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceHostname - %s\n", Hostname));
} }
@ -354,7 +371,7 @@ GetRedfishRecordFromVariable (
UINT8 HostNameSize; UINT8 HostNameSize;
CHAR8 RedfishHostName[20]; CHAR8 RedfishHostName[20];
if (RedfishProtocolData == NULL || RedfishProtocolDataSize == NULL) { if ((RedfishProtocolData == NULL) || (RedfishProtocolDataSize == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -446,7 +463,7 @@ GetRedfishRecordFromVariable (
RedfishServiceIpAddress.Addr[3] RedfishServiceIpAddress.Addr[3]
); );
HostNameSize = (UINT8) AsciiStrLen (RedfishHostName) + 1; HostNameSize = (UINT8)AsciiStrLen (RedfishHostName) + 1;
// //
// 2. Protocol Data Size. // 2. Protocol Data Size.
@ -456,7 +473,7 @@ GetRedfishRecordFromVariable (
// //
// 3. Protocol Data. // 3. Protocol Data.
// //
*RedfishProtocolData = (REDFISH_OVER_IP_PROTOCOL_DATA *) AllocateZeroPool (*RedfishProtocolDataSize); *RedfishProtocolData = (REDFISH_OVER_IP_PROTOCOL_DATA *)AllocateZeroPool (*RedfishProtocolDataSize);
if (*RedfishProtocolData == NULL) { if (*RedfishProtocolData == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
@ -495,7 +512,7 @@ GetRedfishRecordFromVariable (
(*RedfishProtocolData)->RedfishServiceVlanId = 0xffffffff; (*RedfishProtocolData)->RedfishServiceVlanId = 0xffffffff;
(*RedfishProtocolData)->RedfishServiceHostnameLength = HostNameSize; (*RedfishProtocolData)->RedfishServiceHostnameLength = HostNameSize;
AsciiStrCpyS ((CHAR8 *) ((*RedfishProtocolData)->RedfishServiceHostname), HostNameSize, RedfishHostName); AsciiStrCpyS ((CHAR8 *)((*RedfishProtocolData)->RedfishServiceHostname), HostNameSize, RedfishHostName);
return Status; return Status;
} }
@ -515,7 +532,7 @@ EFIAPI
RedfishPlatformHostInterfaceConstructor ( RedfishPlatformHostInterfaceConstructor (
IN EFI_HANDLE ImageHandle, IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable IN EFI_SYSTEM_TABLE *SystemTable
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
@ -524,5 +541,6 @@ RedfishPlatformHostInterfaceConstructor (
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
DumpRedfishIpProtocolData (mRedfishOverIpProtocolData, mRedfishProtocolDataSize); DumpRedfishIpProtocolData (mRedfishOverIpProtocolData, mRedfishProtocolDataSize);
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -9,7 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <PiPei.h> #include <PiPei.h>
#define GET_OCCUPIED_SIZE(ActualSize, Alignment) \ #define GET_OCCUPIED_SIZE(ActualSize, Alignment) \
(ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1)) (ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1))
@ -18,6 +17,7 @@ GetFileState (
IN UINT8 ErasePolarity, IN UINT8 ErasePolarity,
IN EFI_FFS_FILE_HEADER *FfsHeader IN EFI_FFS_FILE_HEADER *FfsHeader
) )
/*++ /*++
Routine Description: Routine Description:
@ -39,7 +39,7 @@ Returns:
FileState = FfsHeader->State; FileState = FfsHeader->State;
if (ErasePolarity != 0) { if (ErasePolarity != 0) {
FileState = (EFI_FFS_FILE_STATE)~FileState; FileState = (EFI_FFS_FILE_STATE) ~FileState;
} }
HighestBit = 0x80; HighestBit = 0x80;
@ -54,6 +54,7 @@ UINT8
CalculateHeaderChecksum ( CalculateHeaderChecksum (
IN EFI_FFS_FILE_HEADER *FileHeader IN EFI_FFS_FILE_HEADER *FileHeader
) )
/*++ /*++
Routine Description: Routine Description:
@ -72,26 +73,27 @@ Returns:
UINT8 Sum; UINT8 Sum;
Sum = 0; Sum = 0;
ptr = (UINT8 *) FileHeader; ptr = (UINT8 *)FileHeader;
for (Index = 0; Index < sizeof (EFI_FFS_FILE_HEADER) - 3; Index += 4) { for (Index = 0; Index < sizeof (EFI_FFS_FILE_HEADER) - 3; Index += 4) {
Sum = (UINT8) (Sum + ptr[Index]); Sum = (UINT8)(Sum + ptr[Index]);
Sum = (UINT8) (Sum + ptr[Index + 1]); Sum = (UINT8)(Sum + ptr[Index + 1]);
Sum = (UINT8) (Sum + ptr[Index + 2]); Sum = (UINT8)(Sum + ptr[Index + 2]);
Sum = (UINT8) (Sum + ptr[Index + 3]); Sum = (UINT8)(Sum + ptr[Index + 3]);
} }
for (; Index < sizeof (EFI_FFS_FILE_HEADER); Index++) { for ( ; Index < sizeof (EFI_FFS_FILE_HEADER); Index++) {
Sum = (UINT8) (Sum + ptr[Index]); Sum = (UINT8)(Sum + ptr[Index]);
} }
// //
// State field (since this indicates the different state of file). // 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. // 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; return Sum;
} }
@ -102,6 +104,7 @@ SecFfsFindNextFile (
IN EFI_PEI_FV_HANDLE FvHandle, IN EFI_PEI_FV_HANDLE FvHandle,
IN OUT EFI_PEI_FILE_HANDLE *FileHandle IN OUT EFI_PEI_FILE_HANDLE *FileHandle
) )
/*++ /*++
Routine Description: Routine Description:
@ -137,7 +140,7 @@ Returns:
// //
// Convert the handle of FV to FV header for memory-mapped firmware volume // 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; FileHeader = (EFI_FFS_FILE_HEADER **)FileHandle;
FvLength = FwVolHeader->FvLength; FvLength = FwVolHeader->FvLength;
@ -146,23 +149,24 @@ Returns:
} else { } else {
ErasePolarity = 0; ErasePolarity = 0;
} }
// //
// If FileHeader is not specified (NULL) start with the first file in the // If FileHeader is not specified (NULL) start with the first file in the
// firmware volume. Otherwise, start from the FileHeader. // firmware volume. Otherwise, start from the FileHeader.
// //
if (*FileHeader == NULL) { if (*FileHeader == NULL) {
FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FwVolHeader + FwVolHeader->HeaderLength); FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FwVolHeader + FwVolHeader->HeaderLength);
} else { } else {
// //
// Length is 24 bits wide so mask upper 8 bits // Length is 24 bits wide so mask upper 8 bits
// FileLength is adjusted to FileOccupiedSize as it is 8 byte aligned. // FileLength is adjusted to FileOccupiedSize as it is 8 byte aligned.
// //
FileLength = *(UINT32 *) (*FileHeader)->Size & 0x00FFFFFF; FileLength = *(UINT32 *)(*FileHeader)->Size & 0x00FFFFFF;
FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8); FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8);
FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) *FileHeader + FileOccupiedSize); 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))) { while (FileOffset < (FvLength - sizeof (EFI_FFS_FILE_HEADER))) {
// //
@ -171,42 +175,40 @@ Returns:
FileState = GetFileState (ErasePolarity, FfsFileHeader); FileState = GetFileState (ErasePolarity, FfsFileHeader);
switch (FileState) { switch (FileState) {
case EFI_FILE_HEADER_INVALID: case EFI_FILE_HEADER_INVALID:
FileOffset += sizeof (EFI_FFS_FILE_HEADER); FileOffset += sizeof (EFI_FFS_FILE_HEADER);
FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + sizeof (EFI_FFS_FILE_HEADER)); FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + sizeof (EFI_FFS_FILE_HEADER));
break; break;
case EFI_FILE_DATA_VALID: case EFI_FILE_DATA_VALID:
case EFI_FILE_MARKED_FOR_UPDATE: case EFI_FILE_MARKED_FOR_UPDATE:
if (CalculateHeaderChecksum (FfsFileHeader) == 0) { if (CalculateHeaderChecksum (FfsFileHeader) == 0) {
FileLength = *(UINT32 *) (FfsFileHeader->Size) & 0x00FFFFFF; FileLength = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;
FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8); FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8);
if ((SearchType == FfsFileHeader->Type) || (SearchType == EFI_FV_FILETYPE_ALL)) { if ((SearchType == FfsFileHeader->Type) || (SearchType == EFI_FV_FILETYPE_ALL)) {
*FileHeader = FfsFileHeader; *FileHeader = FfsFileHeader;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
FileOffset += FileOccupiedSize; FileOffset += FileOccupiedSize;
FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + FileOccupiedSize); FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + FileOccupiedSize);
} else { } else {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
break; break;
case EFI_FILE_DELETED: case EFI_FILE_DELETED:
FileLength = *(UINT32 *) (FfsFileHeader->Size) & 0x00FFFFFF; FileLength = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;
FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8); FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8);
FileOffset += FileOccupiedSize; FileOffset += FileOccupiedSize;
FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + FileOccupiedSize); FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + FileOccupiedSize);
break; break;
default: default:
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
} }
@ -219,6 +221,7 @@ SecFfsFindSectionData (
IN EFI_FFS_FILE_HEADER *FfsFileHeader, IN EFI_FFS_FILE_HEADER *FfsFileHeader,
IN OUT VOID **SectionData IN OUT VOID **SectionData
) )
/*++ /*++
Routine Description: Routine Description:
@ -247,29 +250,29 @@ Returns:
// Does not include FfsFileHeader header size // Does not include FfsFileHeader header size
// FileSize is adjusted to FileOccupiedSize as it is 8 byte aligned. // FileSize is adjusted to FileOccupiedSize as it is 8 byte aligned.
// //
Section = (EFI_COMMON_SECTION_HEADER *) (FfsFileHeader + 1); Section = (EFI_COMMON_SECTION_HEADER *)(FfsFileHeader + 1);
FileSize = *(UINT32 *) (FfsFileHeader->Size) & 0x00FFFFFF; FileSize = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;
FileSize -= sizeof (EFI_FFS_FILE_HEADER); FileSize -= sizeof (EFI_FFS_FILE_HEADER);
*SectionData = NULL; *SectionData = NULL;
ParsedLength = 0; ParsedLength = 0;
while (ParsedLength < FileSize) { while (ParsedLength < FileSize) {
if (Section->Type == SectionType) { if (Section->Type == SectionType) {
*SectionData = (VOID *) (Section + 1); *SectionData = (VOID *)(Section + 1);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
// //
// Size is 24 bits wide so mask upper 8 bits. // Size is 24 bits wide so mask upper 8 bits.
// SectionLength is adjusted it is 4 byte aligned. // SectionLength is adjusted it is 4 byte aligned.
// Go to the next section // Go to the next section
// //
SectionLength = *(UINT32 *) Section->Size & 0x00FFFFFF; SectionLength = *(UINT32 *)Section->Size & 0x00FFFFFF;
SectionLength = GET_OCCUPIED_SIZE (SectionLength, 4); SectionLength = GET_OCCUPIED_SIZE (SectionLength, 4);
ParsedLength += SectionLength; ParsedLength += SectionLength;
Section = (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) Section + SectionLength); Section = (EFI_COMMON_SECTION_HEADER *)((UINT8 *)Section + SectionLength);
} }
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }

View File

@ -6,15 +6,12 @@
**/ **/
#include <PiPei.h> #include <PiPei.h>
#include <Library/EmuMagicPageLib.h> #include <Library/EmuMagicPageLib.h>
#include <Library/PeiServicesLib.h> #include <Library/PeiServicesLib.h>
#include <Library/DebugLib.h> #include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h> #include <Library/BaseMemoryLib.h>
EFI_STATUS EFI_STATUS
SecFfsFindNextFile ( SecFfsFindNextFile (
IN EFI_FV_FILETYPE SearchType, IN EFI_FV_FILETYPE SearchType,
@ -29,7 +26,6 @@ SecFfsFindSectionData (
OUT VOID **SectionData OUT VOID **SectionData
); );
/** /**
This service enables a given PEIM to register an interface into the PEI Foundation. This service enables a given PEIM to register an interface into the PEI Foundation.
@ -109,14 +105,16 @@ PeiServicesLocatePpi (
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
for (PpiList = EMU_MAGIC_PAGE()->PpiList; ; PpiList++) { for (PpiList = EMU_MAGIC_PAGE ()->PpiList; ; PpiList++) {
if (CompareGuid (PpiList->Guid, Guid)) { if (CompareGuid (PpiList->Guid, Guid)) {
if (PpiDescriptor != NULL) { if (PpiDescriptor != NULL) {
*PpiDescriptor = PpiList; *PpiDescriptor = PpiList;
} }
if (Ppi != NULL) { if (Ppi != NULL) {
*Ppi = PpiList->Ppi; *Ppi = PpiList->Ppi;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -125,7 +123,6 @@ PeiServicesLocatePpi (
} }
} }
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
@ -451,7 +448,6 @@ PeiServicesFfsGetFileInfo (
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
/** /**
This service is a wrapper for the PEI Service FfsFindByName(), except the pointer to the PEI Services 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 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
@ -485,7 +481,6 @@ PeiServicesFfsFindFileByName (
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
/** /**
This service is a wrapper for the PEI Service FfsGetVolumeInfo(), except the pointer to the PEI Services 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 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface

View File

@ -8,4 +8,3 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <PiPei.h> #include <PiPei.h>
CONST EFI_PEI_PPI_DESCRIPTOR *gPpiList = NULL; CONST EFI_PEI_PPI_DESCRIPTOR *gPpiList = NULL;

View File

@ -18,10 +18,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/UefiLib.h> #include <Library/UefiLib.h>
#include <Library/SmbiosLib.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 Create an initial SMBIOS Table from an array of SMBIOS_TEMPLATE_ENTRY
entries. SMBIOS_TEMPLATE_ENTRY.NULL indicates the end of the table. entries. SMBIOS_TEMPLATE_ENTRY.NULL indicates the end of the table.
@ -53,8 +51,6 @@ SmbiosLibInitializeFromTemplate (
return Status; return Status;
} }
/** /**
Create SMBIOS record. Create SMBIOS record.
@ -108,6 +104,7 @@ SmbiosLibCreateEntry (
StringSize = AsciiStrSize (StringArray[Index]); StringSize = AsciiStrSize (StringArray[Index]);
Size += StringSize; Size += StringSize;
} }
// Don't forget the terminating double null // Don't forget the terminating double null
Size += 1; Size += 1;
} }
@ -117,6 +114,7 @@ SmbiosLibCreateEntry (
if (Record == NULL) { if (Record == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
CopyMem (Record, SmbiosEntry, SmbiosEntry->Length); CopyMem (Record, SmbiosEntry, SmbiosEntry->Length);
if (StringArray != NULL) { if (StringArray != NULL) {
@ -127,6 +125,7 @@ SmbiosLibCreateEntry (
CopyMem (Str, StringArray[Index], StringSize); CopyMem (Str, StringArray[Index], StringSize);
Str += StringSize; Str += StringSize;
} }
*Str = 0; *Str = 0;
} }
@ -142,8 +141,6 @@ SmbiosLibCreateEntry (
return Status; return Status;
} }
/** /**
Update the string associated with an existing SMBIOS record. Update the string associated with an existing SMBIOS record.
@ -182,7 +179,6 @@ SmbiosLibUpdateString (
return gSmbios->UpdateString (gSmbios, &SmbiosHandle, &StringIndex, String); return gSmbios->UpdateString (gSmbios, &SmbiosHandle, &StringIndex, String);
} }
/** /**
Update the string associated with an existing SMBIOS record. Update the string associated with an existing SMBIOS record.
@ -223,6 +219,7 @@ SmbiosLibUpdateUnicodeString (
if (Ascii == NULL) { if (Ascii == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
UnicodeStrToAsciiStrS (String, Ascii, StrSize (String)); UnicodeStrToAsciiStrS (String, Ascii, StrSize (String));
StringIndex = StringNumber; StringIndex = StringNumber;
@ -232,7 +229,6 @@ SmbiosLibUpdateUnicodeString (
return Status; return Status;
} }
/** /**
Allow caller to read a specific SMBIOS string Allow caller to read a specific SMBIOS string
@ -253,10 +249,11 @@ SmbiosLibReadString (
UINTN Match; UINTN Match;
Data = (CHAR8 *)Header + Header->Length; Data = (CHAR8 *)Header + Header->Length;
for (Match = 1;!(*Data == 0 && *(Data+1) == 0); ) { for (Match = 1; !(*Data == 0 && *(Data+1) == 0); ) {
if (StringNumber == Match) { if (StringNumber == Match) {
return Data; return Data;
} }
Data++; Data++;
if (*(Data - 1) == '\0') { if (*(Data - 1) == '\0') {
Match++; Match++;
@ -266,7 +263,6 @@ SmbiosLibReadString (
return NULL; return NULL;
} }
/** /**
Allow the caller to discover a specific SMBIOS entry, and patch it if necissary. Allow the caller to discover a specific SMBIOS entry, and patch it if necissary.
@ -297,6 +293,7 @@ SmbiosLibGetRecord (
if (Match == Instance) { if (Match == Instance) {
return (SMBIOS_STRUCTURE *)Record; return (SMBIOS_STRUCTURE *)Record;
} }
Match++; Match++;
} }
} while (!EFI_ERROR (Status)); } while (!EFI_ERROR (Status));
@ -304,7 +301,6 @@ SmbiosLibGetRecord (
return NULL; return NULL;
} }
/** /**
Remove an SMBIOS record. Remove an SMBIOS record.
@ -324,8 +320,6 @@ SmbiosLibRemove (
return gSmbios->Remove (gSmbios, SmbiosHandle); return gSmbios->Remove (gSmbios, SmbiosHandle);
} }
/** /**
@param ImageHandle ImageHandle of the loaded driver. @param ImageHandle ImageHandle of the loaded driver.
@ -343,4 +337,3 @@ SmbiosLibConstructor (
{ {
return gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&gSmbios); return gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&gSmbios);
} }

View File

@ -12,12 +12,9 @@
#include <Library/BaseLib.h> #include <Library/BaseLib.h>
#include <Library/MemoryAllocationLib.h> #include <Library/MemoryAllocationLib.h>
UINTN gThunkPpiListSize = 0; UINTN gThunkPpiListSize = 0;
EFI_PEI_PPI_DESCRIPTOR *gThunkPpiList = NULL; EFI_PEI_PPI_DESCRIPTOR *gThunkPpiList = NULL;
EFI_PEI_PPI_DESCRIPTOR * EFI_PEI_PPI_DESCRIPTOR *
GetThunkPpiList ( GetThunkPpiList (
VOID VOID
@ -35,7 +32,6 @@ GetThunkPpiList (
return gThunkPpiList; return gThunkPpiList;
} }
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
AddThunkPpi ( AddThunkPpi (
@ -63,8 +59,3 @@ AddThunkPpi (
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -16,7 +16,6 @@
#include <Protocol/EmuIoThunk.h> #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 { typedef struct {
@ -28,7 +27,6 @@ typedef struct {
LIST_ENTRY mThunkList = INITIALIZE_LIST_HEAD_VARIABLE (mThunkList); LIST_ENTRY mThunkList = INITIALIZE_LIST_HEAD_VARIABLE (mThunkList);
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
AddThunkProtocol ( AddThunkProtocol (
@ -53,9 +51,9 @@ AddThunkProtocol (
if (StartString == NULL) { if (StartString == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
StrCpyS (StartString, Size / sizeof (CHAR16), ConfigString); StrCpyS (StartString, Size / sizeof (CHAR16), ConfigString);
while (*StartString != '\0') { while (*StartString != '\0') {
// //
// Find the end of the sub string // Find the end of the sub string
// //
@ -77,6 +75,7 @@ AddThunkProtocol (
if (Private == NULL) { if (Private == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
Private->Signature = EMU_IO_THUNK_PROTOCOL_DATA_SIGNATURE; Private->Signature = EMU_IO_THUNK_PROTOCOL_DATA_SIGNATURE;
Private->EmuBusDriver = EmuBusDriver; Private->EmuBusDriver = EmuBusDriver;
@ -95,7 +94,6 @@ AddThunkProtocol (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
GetNextThunkProtocol ( GetNextThunkProtocol (
@ -125,13 +123,12 @@ GetNextThunkProtocol (
if (Link == &mThunkList) { if (Link == &mThunkList) {
return EFI_NOT_FOUND; 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; *Instance = &Private->Data;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
} }
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }

View File

@ -19,8 +19,6 @@
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 }, { EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS, sizeof (SMBIOS_TABLE_TYPE19), 0 },
0xffffffff, // StartingAddress; 0xffffffff, // StartingAddress;
@ -66,11 +64,11 @@ CreatePlatformSmbiosMemoryRecords (
SmbiosLibCreateEntry ((SMBIOS_STRUCTURE *)&gSmbiosType19Template, NULL); SmbiosLibCreateEntry ((SMBIOS_STRUCTURE *)&gSmbiosType19Template, NULL);
} }
HobPtr.Raw = GET_NEXT_HOB (HobPtr); HobPtr.Raw = GET_NEXT_HOB (HobPtr);
} }
} }
/** /**
Main entry for this driver. Main entry for this driver.
@ -108,12 +106,12 @@ PlatformSmbiosDriverEntryPoint (
SmbiosLibUpdateUnicodeString ( SmbiosLibUpdateUnicodeString (
SmbiosHandle, SmbiosHandle,
Smbios.Type0->BiosVersion, Smbios.Type0->BiosVersion,
(CHAR16 *) PcdGetPtr (PcdFirmwareVersionString) (CHAR16 *)PcdGetPtr (PcdFirmwareVersionString)
); );
SmbiosLibUpdateUnicodeString ( SmbiosLibUpdateUnicodeString (
SmbiosHandle, SmbiosHandle,
Smbios.Type0->BiosReleaseDate, Smbios.Type0->BiosReleaseDate,
(CHAR16 *) PcdGetPtr (PcdFirmwareReleaseDateString) (CHAR16 *)PcdGetPtr (PcdFirmwareReleaseDateString)
); );
} }

View File

@ -23,7 +23,6 @@
#include <Protocol/Smbios.h> #include <Protocol/Smbios.h>
#include <Library/SmbiosLib.h> #include <Library/SmbiosLib.h>
SMBIOS_TABLE_TYPE0 gSmbiosType0Template = { SMBIOS_TABLE_TYPE0 gSmbiosType0Template = {
{ EFI_SMBIOS_TYPE_BIOS_INFORMATION, sizeof (SMBIOS_TABLE_TYPE0), 0 }, { EFI_SMBIOS_TYPE_BIOS_INFORMATION, sizeof (SMBIOS_TABLE_TYPE0), 0 },
1, // Vendor String 1, // Vendor String
@ -101,7 +100,8 @@ SMBIOS_TABLE_TYPE1 gSmbiosType1Template = {
2, // ProductName String 2, // ProductName String
3, // Version String 3, // Version String
4, // SerialNumber 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, SystemWakeupTypePowerSwitch,
5, // SKUNumber String 5, // SKUNumber String
6, // Family String 6, // Family String
@ -157,13 +157,15 @@ SMBIOS_TABLE_TYPE3 gSmbiosType3Template = {
ChassisStateSafe, // BootupState; ChassisStateSafe, // BootupState;
ChassisStateSafe, // PowerSupplyState; ChassisStateSafe, // PowerSupplyState;
ChassisStateSafe, // ThermalState; ChassisStateSafe, // ThermalState;
ChassisSecurityStatusNone,// SecurityStatus; ChassisSecurityStatusNone, // SecurityStatus;
{ 0, 0, 0, 0 }, // OemDefined[4]; { 0, 0, 0, 0}, // OemDefined[4];
0, // Height; 0, // Height;
0, // NumberofPowerCords; 0, // NumberofPowerCords;
0, // ContainedElementCount; 0, // ContainedElementCount;
0, // ContainedElementRecordLength; 0, // ContainedElementRecordLength;
{ { 0 } }, // ContainedElements[1]; {
{ 0 }
}, // ContainedElements[1];
}; };
CHAR8 *gSmbiosType3Strings[] = { CHAR8 *gSmbiosType3Strings[] = {
"http://www.tianocore.org/edk2/", "http://www.tianocore.org/edk2/",
@ -199,7 +201,6 @@ CHAR8 *gSmbiosType8Strings2[] = {
NULL NULL
}; };
SMBIOS_TABLE_TYPE8 gSmbiosType8Template3 = { SMBIOS_TABLE_TYPE8 gSmbiosType8Template3 = {
{ EFI_SMBIOS_TYPE_PORT_CONNECTOR_INFORMATION, sizeof (SMBIOS_TABLE_TYPE8), 0 }, { EFI_SMBIOS_TYPE_PORT_CONNECTOR_INFORMATION, sizeof (SMBIOS_TABLE_TYPE8), 0 },
0, // InternalReferenceDesignator String 0, // InternalReferenceDesignator String
@ -333,7 +334,6 @@ CHAR8 *gSmbiosType11Strings[] = {
NULL NULL
}; };
SMBIOS_TABLE_TYPE12 gSmbiosType12Template = { SMBIOS_TABLE_TYPE12 gSmbiosType12Template = {
{ EFI_SMBIOS_TYPE_SYSTEM_CONFIGURATION_OPTIONS, sizeof (SMBIOS_TABLE_TYPE12), 0 }, { EFI_SMBIOS_TYPE_SYSTEM_CONFIGURATION_OPTIONS, sizeof (SMBIOS_TABLE_TYPE12), 0 },
1 // StringCount 1 // StringCount
@ -411,12 +411,10 @@ SMBIOS_TABLE_TYPE23 gSmbiosType23Template = {
SMBIOS_TABLE_TYPE32 gSmbiosType32Template = { SMBIOS_TABLE_TYPE32 gSmbiosType32Template = {
{ EFI_SMBIOS_TYPE_SYSTEM_BOOT_INFORMATION, sizeof (SMBIOS_TABLE_TYPE32), 0 }, { EFI_SMBIOS_TYPE_SYSTEM_BOOT_INFORMATION, sizeof (SMBIOS_TABLE_TYPE32), 0 },
{ 0, 0, 0, 0, 0, 0 }, // Reserved[6]; { 0, 0, 0, 0, 0, 0}, // Reserved[6];
BootInformationStatusNoError // BootStatus BootInformationStatusNoError // BootStatus
}; };
SMBIOS_TEMPLATE_ENTRY gSmbiosTemplate[] = { SMBIOS_TEMPLATE_ENTRY gSmbiosTemplate[] = {
{ (SMBIOS_STRUCTURE *)&gSmbiosType0Template, gSmbiosType0Strings }, { (SMBIOS_STRUCTURE *)&gSmbiosType0Template, gSmbiosType0Strings },
{ (SMBIOS_STRUCTURE *)&gSmbiosType1Template, gSmbiosType1Strings }, { (SMBIOS_STRUCTURE *)&gSmbiosType1Template, gSmbiosType1Strings },

View File

@ -43,9 +43,10 @@ InitializeRealTimeClock (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EmuGetTime ( EmuGetTime (
OUT EFI_TIME * Time, OUT EFI_TIME *Time,
OUT EFI_TIME_CAPABILITIES * Capabilities OPTIONAL OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL
) )
/*++ /*++
Routine Description: Routine Description:
@ -67,13 +68,11 @@ Returns:
**/ **/
{ {
// //
// Check parameter for null pointer // Check parameter for null pointer
// //
if (Time == NULL) { if (Time == NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
gEmuThunk->GetTime (Time, Capabilities); gEmuThunk->GetTime (Time, Capabilities);
@ -86,6 +85,7 @@ EFIAPI
EmuSetTime ( EmuSetTime (
IN EFI_TIME *Time IN EFI_TIME *Time
) )
/*++ /*++
Routine Description: Routine Description:
@ -111,6 +111,7 @@ Returns:
if (Time == NULL) { if (Time == NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
// //
// Make sure that the time fields are valid // Make sure that the time fields are valid
// //
@ -118,6 +119,7 @@ Returns:
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
@ -128,6 +130,7 @@ EmuGetWakeupTime (
OUT BOOLEAN *Pending, OUT BOOLEAN *Pending,
OUT EFI_TIME *Time OUT EFI_TIME *Time
) )
/*++ /*++
Routine Description: Routine Description:
@ -162,6 +165,7 @@ EmuSetWakeupTime (
IN BOOLEAN Enable, IN BOOLEAN Enable,
OUT EFI_TIME *Time OUT EFI_TIME *Time
) )
/*++ /*++
Routine Description: Routine Description:
@ -196,6 +200,7 @@ InitializeRealTimeClock (
IN EFI_HANDLE ImageHandle, IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable IN EFI_SYSTEM_TABLE *SystemTable
) )
/*++ /*++
Routine Description: Routine Description:
@ -233,6 +238,7 @@ EFI_STATUS
RtcTimeFieldsValid ( RtcTimeFieldsValid (
IN EFI_TIME *Time IN EFI_TIME *Time
) )
/*++ /*++
Routine Description: Routine Description:
@ -242,18 +248,19 @@ Routine Description:
Returns: Returns:
**/ **/
{ {
if (Time->Year < 1998 || if ((Time->Year < 1998) ||
Time->Year > 2099 || (Time->Year > 2099) ||
Time->Month < 1 || (Time->Month < 1) ||
Time->Month > 12 || (Time->Month > 12) ||
(!DayValid (Time)) || (!DayValid (Time)) ||
Time->Hour > 23 || (Time->Hour > 23) ||
Time->Minute > 59 || (Time->Minute > 59) ||
Time->Second > 59 || (Time->Second > 59) ||
Time->Nanosecond > 999999999 || (Time->Nanosecond > 999999999) ||
(!(Time->TimeZone == EFI_UNSPECIFIED_TIMEZONE || (Time->TimeZone >= -1440 && Time->TimeZone <= 1440))) || (!((Time->TimeZone == EFI_UNSPECIFIED_TIMEZONE) || ((Time->TimeZone >= -1440) && (Time->TimeZone <= 1440)))) ||
(Time->Daylight & (~(EFI_TIME_ADJUST_DAYLIGHT | EFI_TIME_IN_DAYLIGHT))) (Time->Daylight & (~(EFI_TIME_ADJUST_DAYLIGHT | EFI_TIME_IN_DAYLIGHT)))
) { )
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -265,13 +272,13 @@ DayValid (
IN EFI_TIME *Time IN EFI_TIME *Time
) )
{ {
STATIC const INTN DayOfMonth[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; STATIC const INTN DayOfMonth[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
if (Time->Day < 1 || if ((Time->Day < 1) ||
Time->Day > DayOfMonth[Time->Month - 1] || (Time->Day > DayOfMonth[Time->Month - 1]) ||
(Time->Month == 2 && (!IsLeapYear (Time) && Time->Day > 28)) ((Time->Month == 2) && (!IsLeapYear (Time) && (Time->Day > 28)))
) { )
{
return FALSE; return FALSE;
} }

View File

@ -19,7 +19,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Protocol/Reset.h> #include <Protocol/Reset.h>
VOID VOID
EFIAPI EFIAPI
EmuResetSystem ( EmuResetSystem (
@ -52,7 +51,6 @@ EmuResetSystem (
gBS->FreePool (HandleBuffer); gBS->FreePool (HandleBuffer);
} }
// //
// Discard ResetType, always return 0 as exit code // Discard ResetType, always return 0 as exit code
// //
@ -66,14 +64,13 @@ EmuResetSystem (
return; return;
} }
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
InitializeEmuReset ( InitializeEmuReset (
IN EFI_HANDLE ImageHandle, IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable IN EFI_SYSTEM_TABLE *SystemTable
) )
/*++ /*++
Routine Description: Routine Description:
@ -105,4 +102,3 @@ Returns:
return Status; return Status;
} }

View File

@ -19,7 +19,6 @@ SecSwitchStack (
UINT32 PermenentMemoryBase UINT32 PermenentMemoryBase
); );
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
SecTemporaryRamSupport ( SecTemporaryRamSupport (
@ -33,8 +32,8 @@ SecTemporaryRamSupport (
// Migrate the whole temporary memory to permanent memory. // Migrate the whole temporary memory to permanent memory.
// //
CopyMem ( CopyMem (
(VOID*)(UINTN)PermanentMemoryBase, (VOID *)(UINTN)PermanentMemoryBase,
(VOID*)(UINTN)TemporaryMemoryBase, (VOID *)(UINTN)TemporaryMemoryBase,
CopySize CopySize
); );
@ -43,7 +42,7 @@ SecTemporaryRamSupport (
// immediately, also we need fixup the stack change caused by new call into // immediately, also we need fixup the stack change caused by new call into
// permanent memory. // permanent memory.
// //
SecSwitchStack ((UINT32) TemporaryMemoryBase, (UINT32) PermanentMemoryBase); SecSwitchStack ((UINT32)TemporaryMemoryBase, (UINT32)PermanentMemoryBase);
// //
// We need *not* fix the return address because currently, // We need *not* fix the return address because currently,
@ -53,7 +52,7 @@ SecTemporaryRamSupport (
// //
// Simulate to invalid temporary memory, terminate temporary memory // Simulate to invalid temporary memory, terminate temporary memory
// //
//ZeroMem ((VOID*)(UINTN)TemporaryMemoryBase, CopySize); // ZeroMem ((VOID*)(UINTN)TemporaryMemoryBase, CopySize);
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -10,13 +10,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "Sec.h" #include "Sec.h"
EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI mSecTemporaryRamSupportPpi = { EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI mSecTemporaryRamSupportPpi = {
SecTemporaryRamSupport SecTemporaryRamSupport
}; };
EFI_PEI_PPI_DESCRIPTOR gPrivateDispatchTable[] = { EFI_PEI_PPI_DESCRIPTOR gPrivateDispatchTable[] = {
{ {
EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST, 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 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 SEC that sits on top of an OS application. So the entry and exit of this module
@ -77,7 +72,7 @@ _ModuleEntryPoint (
UINTN Index; UINTN Index;
EFI_PEI_PPI_DESCRIPTOR PpiArray[10]; EFI_PEI_PPI_DESCRIPTOR PpiArray[10];
EMU_MAGIC_PAGE()->PpiList = PpiList; EMU_MAGIC_PAGE ()->PpiList = PpiList;
ProcessLibraryConstructorList (); ProcessLibraryConstructorList ();
DEBUG ((DEBUG_ERROR, "SEC Has Started\n")); DEBUG ((DEBUG_ERROR, "SEC Has Started\n"));
@ -99,12 +94,12 @@ _ModuleEntryPoint (
// Keep everything on a good alignment // Keep everything on a good alignment
SecReseveredMemorySize = ALIGN_VALUE (SecReseveredMemorySize, CPU_STACK_ALIGNMENT); SecReseveredMemorySize = ALIGN_VALUE (SecReseveredMemorySize, CPU_STACK_ALIGNMENT);
#if 0 #if 0
// Tell the PEI Core to not use our buffer in temp RAM // Tell the PEI Core to not use our buffer in temp RAM
SecPpiList = (EFI_PEI_PPI_DESCRIPTOR *)SecCoreData->PeiTemporaryRamBase; SecPpiList = (EFI_PEI_PPI_DESCRIPTOR *)SecCoreData->PeiTemporaryRamBase;
SecCoreData->PeiTemporaryRamBase = (VOID *)((UINTN)SecCoreData->PeiTemporaryRamBase + SecReseveredMemorySize); SecCoreData->PeiTemporaryRamBase = (VOID *)((UINTN)SecCoreData->PeiTemporaryRamBase + SecReseveredMemorySize);
SecCoreData->PeiTemporaryRamSize -= SecReseveredMemorySize; SecCoreData->PeiTemporaryRamSize -= SecReseveredMemorySize;
#else #else
// //
// When I subtrack from SecCoreData->PeiTemporaryRamBase PEI Core crashes? Either there is a bug // When I subtrack from SecCoreData->PeiTemporaryRamBase PEI Core crashes? Either there is a bug
// or I don't understand temp RAM correctly? // or I don't understand temp RAM correctly?
@ -112,7 +107,7 @@ _ModuleEntryPoint (
SecPpiList = &PpiArray[0]; SecPpiList = &PpiArray[0];
ASSERT (sizeof (PpiArray) >= SecReseveredMemorySize); ASSERT (sizeof (PpiArray) >= SecReseveredMemorySize);
#endif #endif
// Copy existing list, and append our entries. // Copy existing list, and append our entries.
CopyMem (SecPpiList, PpiList, sizeof (EFI_PEI_PPI_DESCRIPTOR) * Index); CopyMem (SecPpiList, PpiList, sizeof (EFI_PEI_PPI_DESCRIPTOR) * Index);
CopyMem (&SecPpiList[Index], gPrivateDispatchTable, sizeof (gPrivateDispatchTable)); CopyMem (&SecPpiList[Index], gPrivateDispatchTable, sizeof (gPrivateDispatchTable));

View File

@ -11,7 +11,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef __SEC_H___ #ifndef __SEC_H___
#define __SEC_H___ #define __SEC_H___
#include <PiPei.h> #include <PiPei.h>
#include <Library/EmuMagicPageLib.h> #include <Library/EmuMagicPageLib.h>
#include <Library/DebugLib.h> #include <Library/DebugLib.h>
@ -21,7 +20,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Ppi/TemporaryRamSupport.h> #include <Ppi/TemporaryRamSupport.h>
// //
// I think this should be defined in a MdePkg include file? // I think this should be defined in a MdePkg include file?
// //
@ -40,6 +38,4 @@ SecTemporaryRamSupport (
IN UINTN CopySize IN UINTN CopySize
); );
#endif #endif

View File

@ -18,14 +18,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Ppi/EmuThunk.h> #include <Ppi/EmuThunk.h>
#include <Protocol/EmuThunk.h> #include <Protocol/EmuThunk.h>
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
PeiInitialzeThunkPpiToProtocolPei ( PeiInitialzeThunkPpiToProtocolPei (
IN EFI_PEI_FILE_HANDLE FileHandle, IN EFI_PEI_FILE_HANDLE FileHandle,
IN CONST EFI_PEI_SERVICES **PeiServices IN CONST EFI_PEI_SERVICES **PeiServices
) )
/*++ /*++
Routine Description: Routine Description:

View File

@ -49,15 +49,15 @@ EFI_TIMER_NOTIFY mTimerNotifyFunction = NULL;
// //
UINT64 mTimerPeriodMs; UINT64 mTimerPeriodMs;
VOID VOID
EFIAPI EFIAPI
TimerCallback (UINT64 DeltaMs) TimerCallback (
UINT64 DeltaMs
)
{ {
EFI_TPL OriginalTPL; EFI_TPL OriginalTPL;
EFI_TIMER_NOTIFY CallbackFunction; EFI_TIMER_NOTIFY CallbackFunction;
OriginalTPL = gBS->RaiseTPL (TPL_HIGH_LEVEL); OriginalTPL = gBS->RaiseTPL (TPL_HIGH_LEVEL);
if (OriginalTPL < TPL_HIGH_LEVEL) { if (OriginalTPL < TPL_HIGH_LEVEL) {
@ -73,7 +73,6 @@ TimerCallback (UINT64 DeltaMs)
} }
gBS->RestoreTPL (OriginalTPL); gBS->RestoreTPL (OriginalTPL);
} }
EFI_STATUS EFI_STATUS
@ -82,6 +81,7 @@ EmuTimerDriverRegisterHandler (
IN EFI_TIMER_ARCH_PROTOCOL *This, IN EFI_TIMER_ARCH_PROTOCOL *This,
IN EFI_TIMER_NOTIFY NotifyFunction IN EFI_TIMER_NOTIFY NotifyFunction
) )
/*++ /*++
Routine Description: Routine Description:
@ -127,11 +127,11 @@ Returns:
// //
// Check for invalid parameters // Check for invalid parameters
// //
if (NotifyFunction == NULL && mTimerNotifyFunction == NULL) { if ((NotifyFunction == NULL) && (mTimerNotifyFunction == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (NotifyFunction != NULL && mTimerNotifyFunction != NULL) { if ((NotifyFunction != NULL) && (mTimerNotifyFunction != NULL)) {
return EFI_ALREADY_STARTED; return EFI_ALREADY_STARTED;
} }
@ -142,6 +142,7 @@ Returns:
/* Enable Timer. */ /* Enable Timer. */
gEmuThunk->SetTimer (mTimerPeriodMs, TimerCallback); gEmuThunk->SetTimer (mTimerPeriodMs, TimerCallback);
} }
mTimerNotifyFunction = NotifyFunction; mTimerNotifyFunction = NotifyFunction;
return EFI_SUCCESS; return EFI_SUCCESS;
@ -153,6 +154,7 @@ EmuTimerDriverSetTimerPeriod (
IN EFI_TIMER_ARCH_PROTOCOL *This, IN EFI_TIMER_ARCH_PROTOCOL *This,
IN UINT64 TimerPeriod IN UINT64 TimerPeriod
) )
/*++ /*++
Routine Description: Routine Description:
@ -190,14 +192,14 @@ Returns:
**/ **/
{ {
// //
// If TimerPeriod is 0, then the timer thread should be canceled // 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 the TimerPeriod is valid, then create and/or adjust the period of the timer thread
// //
if (TimerPeriod == 0 if ( (TimerPeriod == 0)
|| ((TimerPeriod > TIMER_MINIMUM_VALUE) || ( (TimerPeriod > TIMER_MINIMUM_VALUE)
&& (TimerPeriod < TIMER_MAXIMUM_VALUE))) { && (TimerPeriod < TIMER_MAXIMUM_VALUE)))
{
mTimerPeriodMs = DivU64x32 (TimerPeriod + 5000, 10000); mTimerPeriodMs = DivU64x32 (TimerPeriod + 5000, 10000);
gEmuThunk->SetTimer (mTimerPeriodMs, TimerCallback); gEmuThunk->SetTimer (mTimerPeriodMs, TimerCallback);
@ -212,6 +214,7 @@ EmuTimerDriverGetTimerPeriod (
IN EFI_TIMER_ARCH_PROTOCOL *This, IN EFI_TIMER_ARCH_PROTOCOL *This,
OUT UINT64 *TimerPeriod OUT UINT64 *TimerPeriod
) )
/*++ /*++
Routine Description: Routine Description:
@ -250,6 +253,7 @@ EFIAPI
EmuTimerDriverGenerateSoftInterrupt ( EmuTimerDriverGenerateSoftInterrupt (
IN EFI_TIMER_ARCH_PROTOCOL *This IN EFI_TIMER_ARCH_PROTOCOL *This
) )
/*++ /*++
Routine Description: Routine Description:
@ -283,6 +287,7 @@ EmuTimerDriverInitialize (
IN EFI_HANDLE ImageHandle, IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable IN EFI_SYSTEM_TABLE *SystemTable
) )
/*++ /*++
Routine Description: Routine Description:
@ -341,6 +346,5 @@ Returns:
return Status; return Status;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -13,9 +13,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _TIMER_H_ #ifndef _TIMER_H_
#define _TIMER_H_ #define _TIMER_H_
// //
// Legal timer value range in 100 ns units // Legal timer value range in 100 ns units
// //

View File

@ -11,14 +11,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#include "Host.h" #include "Host.h"
#ifdef __APPLE__ #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 { typedef struct {
@ -43,13 +40,11 @@ typedef struct {
UINT32 ReceivedPackets; UINT32 ReceivedPackets;
UINT32 DroppedPackets; UINT32 DroppedPackets;
} EMU_SNP_PRIVATE; } EMU_SNP_PRIVATE;
#define EMU_SNP_PRIVATE_DATA_FROM_THIS(a) \ #define EMU_SNP_PRIVATE_DATA_FROM_THIS(a) \
CR(a, EMU_SNP_PRIVATE, EmuSnp, EMU_SNP_PRIVATE_SIGNATURE) 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... // Strange, but there doesn't appear to be any structure for the Ethernet header in edk2...
// //
@ -100,19 +95,18 @@ EmuSnpCreateMapping (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
static struct bpf_insn mFilterInstructionTemplate[] = { static struct bpf_insn mFilterInstructionTemplate[] = {
// Load 4 bytes from the destination MAC address. // 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. // 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. // 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. // 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. // 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])),
@ -121,7 +115,7 @@ static struct bpf_insn mFilterInstructionTemplate[] = {
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. // 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. // 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),
@ -133,7 +127,6 @@ static struct bpf_insn mFilterInstructionTemplate[] = {
BPF_STMT (BPF_RET + BPF_K, -1) BPF_STMT (BPF_RET + BPF_K, -1)
}; };
EFI_STATUS EFI_STATUS
OpenBpfFileDescriptor ( OpenBpfFileDescriptor (
IN EMU_SNP_PRIVATE *Private, IN EMU_SNP_PRIVATE *Private,
@ -171,7 +164,6 @@ OpenBpfFileDescriptor (
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
/** /**
Changes the state of a network interface from "stopped" to "started". Changes the state of a network interface from "stopped" to "started".
@ -293,7 +285,7 @@ EmuSnpStart (
// Install our packet filter: successful reads should only produce broadcast or unicast // Install our packet filter: successful reads should only produce broadcast or unicast
// packets directed to our fake MAC address. // packets directed to our fake MAC address.
// //
FilterProgram = malloc (sizeof (mFilterInstructionTemplate)) ; FilterProgram = malloc (sizeof (mFilterInstructionTemplate));
if ( FilterProgram == NULL ) { if ( FilterProgram == NULL ) {
goto ErrorExit; goto ErrorExit;
} }
@ -324,7 +316,6 @@ EmuSnpStart (
goto DeviceErrorExit; goto DeviceErrorExit;
} }
Private->Mode->State = EfiSimpleNetworkStarted; Private->Mode->State = EfiSimpleNetworkStarted;
} }
@ -337,10 +328,10 @@ ErrorExit:
free (Private->ReadBuffer); free (Private->ReadBuffer);
Private->ReadBuffer = NULL; Private->ReadBuffer = NULL;
} }
return Status; return Status;
} }
/** /**
Changes the state of a network interface from "started" to "stopped". Changes the state of a network interface from "started" to "stopped".
@ -381,7 +372,7 @@ EmuSnpStop (
} }
if (Private->ReadBuffer != NULL) { if (Private->ReadBuffer != NULL) {
free (Private->ReadBuffer ); free (Private->ReadBuffer);
Private->CurrentReadPointer = Private->EndReadPointer = Private->ReadBuffer = NULL; Private->CurrentReadPointer = Private->EndReadPointer = Private->ReadBuffer = NULL;
} }
@ -390,7 +381,6 @@ EmuSnpStop (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Resets a network adapter and allocates the transmit and receive buffers Resets a network adapter and allocates the transmit and receive buffers
required by the network interface; optionally, also requests allocation required by the network interface; optionally, also requests allocation
@ -450,7 +440,6 @@ EmuSnpInitialize (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Resets a network adapter and re-initializes it with the parameters that were Resets a network adapter and re-initializes it with the parameters that were
provided in the previous call to Initialize(). provided in the previous call to Initialize().
@ -493,7 +482,6 @@ EmuSnpReset (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Resets a network adapter and leaves it in a state that is safe for Resets a network adapter and leaves it in a state that is safe for
another driver to initialize. another driver to initialize.
@ -590,7 +578,6 @@ EmuSnpReceiveFilters (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Modifies or resets the current station address, if supported. Modifies or resets the current station address, if supported.
@ -620,7 +607,6 @@ EmuSnpStationAddress (
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
/** /**
Resets or collects the statistics on a network interface. Resets or collects the statistics on a network interface.
@ -657,7 +643,6 @@ EmuSnpStatistics (
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
/** /**
Converts a multicast IP address to a multicast HW MAC address. Converts a multicast IP address to a multicast HW MAC address.
@ -694,7 +679,6 @@ EmuSnpMCastIpToMac (
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
/** /**
Performs read and write operations on the NVRAM device attached to a Performs read and write operations on the NVRAM device attached to a
network interface. network interface.
@ -774,7 +758,6 @@ EmuSnpGetStatus (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Places a packet in the transmit queue of a network interface. Places a packet in the transmit queue of a network interface.
@ -837,12 +820,12 @@ EmuSnpTransmit (
SrcAddr = &Private->Mode->CurrentAddress; SrcAddr = &Private->Mode->CurrentAddress;
} }
EnetHeader = (ETHERNET_HEADER *) Buffer; EnetHeader = (ETHERNET_HEADER *)Buffer;
CopyMem (EnetHeader->DstAddr, DestAddr, NET_ETHER_ADDR_LEN); CopyMem (EnetHeader->DstAddr, DestAddr, NET_ETHER_ADDR_LEN);
CopyMem (EnetHeader->SrcAddr, SrcAddr, 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) {
@ -907,7 +890,7 @@ EmuSnpReceive (
return EFI_NOT_STARTED; return EFI_NOT_STARTED;
} }
ZeroMem (&BpfStats, sizeof( BpfStats)); ZeroMem (&BpfStats, sizeof (BpfStats));
if (ioctl (Private->BpfFd, BIOCGSTATS, &BpfStats) == 0) { if (ioctl (Private->BpfFd, BIOCGSTATS, &BpfStats) == 0) {
Private->ReceivedPackets += BpfStats.bs_recv; Private->ReceivedPackets += BpfStats.bs_recv;
@ -972,7 +955,6 @@ EmuSnpReceive (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EMU_SNP_PROTOCOL gEmuSnpProtocol = { EMU_SNP_PROTOCOL gEmuSnpProtocol = {
GasketSnpCreateMapping, GasketSnpCreateMapping,
GasketSnpStart, GasketSnpStart,
@ -1025,7 +1007,7 @@ GetInterfaceMacAddr (
IfSdl = (struct sockaddr_dl *)If->ifa_addr; IfSdl = (struct sockaddr_dl *)If->ifa_addr;
if (IfSdl->sdl_family == AF_LINK) { 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); CopyMem (&Private->MacAddress, LLADDR (IfSdl), NET_ETHER_ADDR_LEN);
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
@ -1041,7 +1023,6 @@ Exit:
return Status; return Status;
} }
EFI_STATUS EFI_STATUS
EmuSnpThunkOpen ( EmuSnpThunkOpen (
IN EMU_IO_THUNK_PROTOCOL *This IN EMU_IO_THUNK_PROTOCOL *This
@ -1062,7 +1043,6 @@ EmuSnpThunkOpen (
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
Private->Signature = EMU_SNP_PRIVATE_SIGNATURE; Private->Signature = EMU_SNP_PRIVATE_SIGNATURE;
Private->Thunk = This; Private->Thunk = This;
CopyMem (&Private->EmuSnp, &gEmuSnpProtocol, sizeof (gEmuSnpProtocol)); CopyMem (&Private->EmuSnp, &gEmuSnpProtocol, sizeof (gEmuSnpProtocol));
@ -1073,7 +1053,6 @@ EmuSnpThunkOpen (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EFI_STATUS EFI_STATUS
EmuSnpThunkClose ( EmuSnpThunkClose (
IN EMU_IO_THUNK_PROTOCOL *This IN EMU_IO_THUNK_PROTOCOL *This
@ -1091,8 +1070,6 @@ EmuSnpThunkClose (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EMU_IO_THUNK_PROTOCOL gSnpThunkIo = { EMU_IO_THUNK_PROTOCOL gSnpThunkIo = {
&gEmuSnpProtocolGuid, &gEmuSnpProtocolGuid,
NULL, NULL,

View File

@ -27,21 +27,17 @@ typedef struct {
EMU_BLOCK_IO_PROTOCOL EmuBlockIo; EMU_BLOCK_IO_PROTOCOL EmuBlockIo;
EFI_BLOCK_IO_MEDIA *Media; EFI_BLOCK_IO_MEDIA *Media;
} EMU_BLOCK_IO_PRIVATE; } EMU_BLOCK_IO_PRIVATE;
#define EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS(a) \ #define EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS(a) \
CR(a, EMU_BLOCK_IO_PRIVATE, EmuBlockIo, EMU_BLOCK_IO_PRIVATE_SIGNATURE) CR(a, EMU_BLOCK_IO_PRIVATE, EmuBlockIo, EMU_BLOCK_IO_PRIVATE_SIGNATURE)
EFI_STATUS EFI_STATUS
EmuBlockIoReset ( EmuBlockIoReset (
IN EMU_BLOCK_IO_PROTOCOL *This, IN EMU_BLOCK_IO_PROTOCOL *This,
IN BOOLEAN ExtendedVerification IN BOOLEAN ExtendedVerification
); );
/*++ /*++
This function extends the capability of SetFilePointer to accept 64 bit parameters This function extends the capability of SetFilePointer to accept 64 bit parameters
@ -72,7 +68,6 @@ SetFilePointer64 (
return Status; return Status;
} }
EFI_STATUS EFI_STATUS
EmuBlockIoOpenDevice ( EmuBlockIoOpenDevice (
IN EMU_BLOCK_IO_PRIVATE *Private IN EMU_BLOCK_IO_PRIVATE *Private
@ -82,7 +77,6 @@ EmuBlockIoOpenDevice (
UINT64 FileSize; UINT64 FileSize;
struct statfs buf; struct statfs buf;
// //
// If the device is already opened, close it // If the device is already opened, close it
// //
@ -95,7 +89,7 @@ EmuBlockIoOpenDevice (
// //
Private->fd = open (Private->Filename, Private->Mode, 0644); Private->fd = open (Private->Filename, Private->Mode, 0644);
if (Private->fd < 0) { if (Private->fd < 0) {
printf ("EmuOpenBlock: Could not open %s: %s\n", Private->Filename, strerror(errno)); printf ("EmuOpenBlock: Could not open %s: %s\n", Private->Filename, strerror (errno));
Private->Media->MediaPresent = FALSE; Private->Media->MediaPresent = FALSE;
Status = EFI_NO_MEDIA; Status = EFI_NO_MEDIA;
goto Done; goto Done;
@ -120,13 +114,14 @@ EmuBlockIoOpenDevice (
if (FileSize == 0) { if (FileSize == 0) {
// lseek fails on a real device. ioctl calls are OS specific // 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) { if (ioctl (Private->fd, DKIOCGETBLOCKSIZE, &BlockSize) == 0) {
Private->Media->BlockSize = BlockSize; Private->Media->BlockSize = BlockSize;
} }
if (ioctl (Private->fd, DKIOCGETBLOCKCOUNT, &Private->NumberOfBlocks) == 0) { if (ioctl (Private->fd, DKIOCGETBLOCKCOUNT, &Private->NumberOfBlocks) == 0) {
if ((Private->NumberOfBlocks == 0) && (BlockSize == 0x800)) { if ((Private->NumberOfBlocks == 0) && (BlockSize == 0x800)) {
// A DVD is ~ 4.37 GB so make up a number // A DVD is ~ 4.37 GB so make up a number
@ -135,9 +130,10 @@ EmuBlockIoOpenDevice (
Private->Media->LastBlock = Private->NumberOfBlocks - 1; Private->Media->LastBlock = Private->NumberOfBlocks - 1;
} }
} }
ioctl (Private->fd, DKIOCGETMAXBLOCKCOUNTWRITE, &Private->Media->OptimalTransferLengthGranularity); ioctl (Private->fd, DKIOCGETMAXBLOCKCOUNTWRITE, &Private->Media->OptimalTransferLengthGranularity);
} }
#else #else
{ {
size_t BlockSize; size_t BlockSize;
UINT64 DiskSize; UINT64 DiskSize;
@ -145,24 +141,24 @@ EmuBlockIoOpenDevice (
if (ioctl (Private->fd, BLKSSZGET, &BlockSize) == 0) { if (ioctl (Private->fd, BLKSSZGET, &BlockSize) == 0) {
Private->Media->BlockSize = BlockSize; Private->Media->BlockSize = BlockSize;
} }
if (ioctl (Private->fd, BLKGETSIZE64, &DiskSize) == 0) { 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; Private->Media->LastBlock = Private->NumberOfBlocks - 1;
} }
} }
#endif #endif
} else { } else {
Private->Media->BlockSize = Private->BlockSize; 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; Private->Media->LastBlock = Private->NumberOfBlocks - 1;
if (fstatfs (Private->fd, &buf) == 0) { if (fstatfs (Private->fd, &buf) == 0) {
#if __APPLE__ #if __APPLE__
Private->Media->OptimalTransferLengthGranularity = buf.f_iosize/buf.f_bsize; Private->Media->OptimalTransferLengthGranularity = buf.f_iosize/buf.f_bsize;
#else #else
Private->Media->OptimalTransferLengthGranularity = buf.f_bsize/buf.f_bsize; Private->Media->OptimalTransferLengthGranularity = buf.f_bsize/buf.f_bsize;
#endif #endif
} }
} }
@ -179,7 +175,6 @@ Done:
return Status; return Status;
} }
EFI_STATUS EFI_STATUS
EmuBlockIoCreateMapping ( EmuBlockIoCreateMapping (
IN EMU_BLOCK_IO_PROTOCOL *This, IN EMU_BLOCK_IO_PROTOCOL *This,
@ -206,17 +201,14 @@ EmuBlockIoCreateMapping (
Media->LowestAlignedLba = 0; Media->LowestAlignedLba = 0;
Media->LogicalBlocksPerPhysicalBlock = 0; Media->LogicalBlocksPerPhysicalBlock = 0;
// EFI_BLOCK_IO_PROTOCOL_REVISION3 // EFI_BLOCK_IO_PROTOCOL_REVISION3
Media->OptimalTransferLengthGranularity = 0; Media->OptimalTransferLengthGranularity = 0;
Status = EmuBlockIoOpenDevice (Private); Status = EmuBlockIoOpenDevice (Private);
return Status; return Status;
} }
EFI_STATUS EFI_STATUS
EmuBlockIoError ( EmuBlockIoError (
IN EMU_BLOCK_IO_PRIVATE *Private IN EMU_BLOCK_IO_PRIVATE *Private
@ -225,9 +217,7 @@ EmuBlockIoError (
EFI_STATUS Status; EFI_STATUS Status;
BOOLEAN ReinstallBlockIoFlag; BOOLEAN ReinstallBlockIoFlag;
switch (errno) { switch (errno) {
case EAGAIN: case EAGAIN:
Status = EFI_NO_MEDIA; Status = EFI_NO_MEDIA;
Private->Media->ReadOnly = FALSE; Private->Media->ReadOnly = FALSE;
@ -254,10 +244,10 @@ EmuBlockIoError (
Status = EFI_DEVICE_ERROR; Status = EFI_DEVICE_ERROR;
break; break;
} }
return Status; return Status;
} }
EFI_STATUS EFI_STATUS
EmuBlockIoReadWriteCommon ( EmuBlockIoReadWriteCommon (
IN EMU_BLOCK_IO_PRIVATE *Private, IN EMU_BLOCK_IO_PRIVATE *Private,
@ -290,7 +280,7 @@ EmuBlockIoReadWriteCommon (
return EFI_MEDIA_CHANGED; return EFI_MEDIA_CHANGED;
} }
if ((UINTN) Buffer % Private->Media->IoAlign != 0) { if ((UINTN)Buffer % Private->Media->IoAlign != 0) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -313,6 +303,7 @@ EmuBlockIoReadWriteCommon (
DEBUG ((DEBUG_INIT, "ReadBlocks: Attempted to read off end of device\n")); DEBUG ((DEBUG_INIT, "ReadBlocks: Attempted to read off end of device\n"));
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
// //
// Seek to End of File // Seek to End of File
// //
@ -327,7 +318,6 @@ EmuBlockIoReadWriteCommon (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Read BufferSize bytes from Lba into Buffer. Read BufferSize bytes from Lba into Buffer.
@ -403,10 +393,10 @@ Done:
return EFI_SUCCESS; return EFI_SUCCESS;
} }
} }
return Status; return Status;
} }
/** /**
Write BufferSize bytes from Lba into Buffer. Write BufferSize bytes from Lba into Buffer.
@ -452,7 +442,6 @@ EmuBlockIoWriteBlocks (
ssize_t len; ssize_t len;
EFI_STATUS Status; EFI_STATUS Status;
Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This); 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");
@ -486,7 +475,6 @@ Done:
return Status; return Status;
} }
/** /**
Flush the Block Device. Flush the Block Device.
@ -521,12 +509,11 @@ EmuBlockIoFlushBlocks (
if (Private->fd >= 0) { if (Private->fd >= 0) {
fsync (Private->fd); fsync (Private->fd);
#if __APPLE__ #if __APPLE__
fcntl (Private->fd, F_FULLFSYNC); fcntl (Private->fd, F_FULLFSYNC);
#endif #endif
} }
if (Token != NULL) { if (Token != NULL) {
if (Token->Event != NULL) { if (Token->Event != NULL) {
// Caller is responsible for signaling EFI Event // Caller is responsible for signaling EFI Event
@ -538,7 +525,6 @@ EmuBlockIoFlushBlocks (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Reset the block device hardware. Reset the block device hardware.
@ -570,7 +556,6 @@ EmuBlockIoReset (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
char * char *
StdDupUnicodeToAscii ( StdDupUnicodeToAscii (
IN CHAR16 *Str IN CHAR16 *Str
@ -589,12 +574,12 @@ StdDupUnicodeToAscii (
for (Ptr = Ascii; *Str != '\0'; Ptr++, Str++) { for (Ptr = Ascii; *Str != '\0'; Ptr++, Str++) {
*Ptr = *Str; *Ptr = *Str;
} }
*Ptr = 0; *Ptr = 0;
return Ascii; return Ascii;
} }
EMU_BLOCK_IO_PROTOCOL gEmuBlockIoProtocol = { EMU_BLOCK_IO_PROTOCOL gEmuBlockIoProtocol = {
GasketEmuBlockIoReset, GasketEmuBlockIoReset,
GasketEmuBlockIoReadBlocks, GasketEmuBlockIoReadBlocks,
@ -624,7 +609,6 @@ EmuBlockIoThunkOpen (
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
Private->Signature = EMU_BLOCK_IO_PRIVATE_SIGNATURE; Private->Signature = EMU_BLOCK_IO_PRIVATE_SIGNATURE;
Private->Thunk = This; Private->Thunk = This;
CopyMem (&Private->EmuBlockIo, &gEmuBlockIoProtocol, sizeof (gEmuBlockIoProtocol)); CopyMem (&Private->EmuBlockIo, &gEmuBlockIoProtocol, sizeof (gEmuBlockIoProtocol));
@ -642,12 +626,14 @@ EmuBlockIoThunkOpen (
Private->WriteProtected = FALSE; Private->WriteProtected = FALSE;
} else { } else {
for (*Str++ = '\0'; *Str != 0; Str++) { for (*Str++ = '\0'; *Str != 0; Str++) {
if (*Str == 'R' || *Str == 'F') { if ((*Str == 'R') || (*Str == 'F')) {
Private->RemovableMedia = (BOOLEAN) (*Str == 'R'); 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 == ':') { if (*Str == ':') {
Private->BlockSize = strtol (++Str, NULL, 0); Private->BlockSize = strtol (++Str, NULL, 0);
break; break;
@ -662,7 +648,6 @@ EmuBlockIoThunkOpen (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EFI_STATUS EFI_STATUS
EmuBlockIoThunkClose ( EmuBlockIoThunkClose (
IN EMU_IO_THUNK_PROTOCOL *This IN EMU_IO_THUNK_PROTOCOL *This
@ -680,6 +665,7 @@ EmuBlockIoThunkClose (
if (Private->Filename != NULL) { if (Private->Filename != NULL) {
free (Private->Filename); free (Private->Filename);
} }
free (This->Private); free (This->Private);
This->Private = NULL; This->Private = NULL;
} }
@ -687,8 +673,6 @@ EmuBlockIoThunkClose (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EMU_IO_THUNK_PROTOCOL gBlockIoThunkIo = { EMU_IO_THUNK_PROTOCOL gBlockIoThunkIo = {
&gEmuBlockIoProtocolGuid, &gEmuBlockIoProtocolGuid,
NULL, NULL,

View File

@ -20,12 +20,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifdef __APPLE__ #ifdef __APPLE__
#define DebugAssert _Mangle__DebugAssert #define DebugAssert _Mangle__DebugAssert
#include <assert.h> #include <assert.h>
#include <CoreServices/CoreServices.h> #include <CoreServices/CoreServices.h>
#include <mach/mach.h> #include <mach/mach.h>
#include <mach/mach_time.h> #include <mach/mach_time.h>
#undef DebugAssert #undef DebugAssert
#endif #endif
int settimer_initialized; int settimer_initialized;
@ -34,7 +34,6 @@ UINTN settimer_callback = 0;
BOOLEAN gEmulatorInterruptEnabled = FALSE; BOOLEAN gEmulatorInterruptEnabled = FALSE;
UINTN UINTN
SecWriteStdErr ( SecWriteStdErr (
IN UINT8 *Buffer, IN UINT8 *Buffer,
@ -48,7 +47,6 @@ SecWriteStdErr (
return (Return == -1) ? 0 : Return; return (Return == -1) ? 0 : Return;
} }
EFI_STATUS EFI_STATUS
SecConfigStdIn ( SecConfigStdIn (
VOID VOID
@ -63,7 +61,7 @@ SecConfigStdIn (
tty.c_lflag &= ~(ICANON | ECHO); tty.c_lflag &= ~(ICANON | ECHO);
tcsetattr (STDIN_FILENO, TCSANOW, &tty); 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 // now ioctl FIONREAD will do what we need
return EFI_SUCCESS; return EFI_SUCCESS;
@ -111,7 +109,6 @@ SecPollStdIn (
return (BOOLEAN)(Bytes > 0); return (BOOLEAN)(Bytes > 0);
} }
VOID * VOID *
SecMalloc ( SecMalloc (
IN UINTN Size IN UINTN Size
@ -143,9 +140,10 @@ SecFree (
return TRUE; return TRUE;
} }
void void
settimer_handler (int sig) settimer_handler (
int sig
)
{ {
struct timeval timeval; struct timeval timeval;
UINT64 delta; UINT64 delta;
@ -181,23 +179,25 @@ SecSetTimer (
if (sigaction (SIGALRM, &act, NULL) != 0) { if (sigaction (SIGALRM, &act, NULL) != 0) {
printf ("SetTimer: sigaction error %s\n", strerror (errno)); printf ("SetTimer: sigaction error %s\n", strerror (errno));
} }
if (gettimeofday (&settimer_timeval, NULL) != 0) { if (gettimeofday (&settimer_timeval, NULL) != 0) {
printf ("SetTimer: gettimeofday error %s\n", strerror (errno)); 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_usec = remainder * 1000;
timerval.it_value.tv_sec = DivU64x32(PeriodMs, 1000); timerval.it_value.tv_sec = DivU64x32 (PeriodMs, 1000);
timerval.it_interval = timerval.it_value; timerval.it_interval = timerval.it_value;
if (setitimer (ITIMER_REAL, &timerval, NULL) != 0) { if (setitimer (ITIMER_REAL, &timerval, NULL) != 0) {
printf ("SetTimer: setitimer error %s\n", strerror (errno)); printf ("SetTimer: setitimer error %s\n", strerror (errno));
} }
settimer_callback = (UINTN)CallBack; settimer_callback = (UINTN)CallBack;
} }
VOID VOID
SecEnableInterrupt ( SecEnableInterrupt (
VOID VOID
@ -213,7 +213,6 @@ SecEnableInterrupt (
pthread_sigmask (SIG_UNBLOCK, &sigset, NULL); pthread_sigmask (SIG_UNBLOCK, &sigset, NULL);
} }
VOID VOID
SecDisableInterrupt ( SecDisableInterrupt (
VOID VOID
@ -229,14 +228,14 @@ SecDisableInterrupt (
gEmulatorInterruptEnabled = FALSE; gEmulatorInterruptEnabled = FALSE;
} }
BOOLEAN BOOLEAN
SecInterruptEanbled (void) SecInterruptEanbled (
void
)
{ {
return gEmulatorInterruptEnabled; return gEmulatorInterruptEnabled;
} }
UINT64 UINT64
QueryPerformanceFrequency ( QueryPerformanceFrequency (
VOID VOID
@ -251,11 +250,10 @@ QueryPerformanceCounter (
VOID VOID
) )
{ {
#if __APPLE__ #if __APPLE__
UINT64 Start; UINT64 Start;
static mach_timebase_info_data_t sTimebaseInfo; static mach_timebase_info_data_t sTimebaseInfo;
Start = mach_absolute_time (); Start = mach_absolute_time ();
// Convert to nanoseconds. // Convert to nanoseconds.
@ -266,21 +264,19 @@ QueryPerformanceCounter (
// denominator is a fraction. // denominator is a fraction.
if ( sTimebaseInfo.denom == 0 ) { if ( sTimebaseInfo.denom == 0 ) {
(void) mach_timebase_info(&sTimebaseInfo); (void)mach_timebase_info (&sTimebaseInfo);
} }
// Do the maths. We hope that the multiplication doesn't // Do the maths. We hope that the multiplication doesn't
// overflow; the price you pay for working in fixed point. // overflow; the price you pay for working in fixed point.
return (Start * sTimebaseInfo.numer) / sTimebaseInfo.denom; return (Start * sTimebaseInfo.numer) / sTimebaseInfo.denom;
#else #else
// Need to figure out what to do for Linux? // Need to figure out what to do for Linux?
return 0; return 0;
#endif #endif
} }
VOID VOID
SecSleep ( SecSleep (
IN UINT64 Nanoseconds IN UINT64 Nanoseconds
@ -309,17 +305,20 @@ SecSleep (
if (errno != EINTR) { if (errno != EINTR) {
break; break;
} }
gettimeofday (&start, NULL); gettimeofday (&start, NULL);
if (start.tv_sec > end.tv_sec) { if (start.tv_sec > end.tv_sec) {
break; 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; break;
} }
rq = rm; rq = rm;
} }
} }
VOID VOID
SecCpuSleep ( SecCpuSleep (
VOID VOID
@ -334,7 +333,6 @@ SecCpuSleep (
nanosleep (&rq, &rm); nanosleep (&rq, &rm);
} }
VOID VOID
SecExit ( SecExit (
UINTN Status UINTN Status
@ -343,7 +341,6 @@ SecExit (
exit (Status); exit (Status);
} }
VOID VOID
SecGetTime ( SecGetTime (
OUT EFI_TIME *Time, OUT EFI_TIME *Time,
@ -374,8 +371,6 @@ SecGetTime (
} }
} }
VOID VOID
SecSetTime ( SecSetTime (
IN EFI_TIME *Time IN EFI_TIME *Time
@ -386,7 +381,6 @@ SecSetTime (
return; return;
} }
EFI_STATUS EFI_STATUS
SecGetNextProtocol ( SecGetNextProtocol (
IN BOOLEAN EmuBusDriver, IN BOOLEAN EmuBusDriver,
@ -396,7 +390,6 @@ SecGetNextProtocol (
return GetNextThunkProtocol (EmuBusDriver, Instance); return GetNextThunkProtocol (EmuBusDriver, Instance);
} }
EMU_THUNK_PROTOCOL gEmuThunkProtocol = { EMU_THUNK_PROTOCOL gEmuThunkProtocol = {
GasketSecWriteStdErr, GasketSecWriteStdErr,
GasketSecConfigStdIn, GasketSecConfigStdIn,
@ -422,7 +415,6 @@ EMU_THUNK_PROTOCOL gEmuThunkProtocol = {
GasketSecGetNextProtocol GasketSecGetNextProtocol
}; };
VOID VOID
SecInitThunkProtocol ( SecInitThunkProtocol (
VOID VOID
@ -431,4 +423,3 @@ SecInitThunkProtocol (
// timezone and daylight lib globals depend on tzset be called 1st. // timezone and daylight lib globals depend on tzset be called 1st.
tzset (); tzset ();
} }

View File

@ -65,7 +65,6 @@ GasketSecFree (
IN VOID *Ptr IN VOID *Ptr
); );
RETURN_STATUS RETURN_STATUS
EFIAPI EFIAPI
GasketSecPeCoffGetEntryPoint ( GasketSecPeCoffGetEntryPoint (
@ -116,7 +115,6 @@ GasketQueryPerformanceCounter (
VOID VOID
); );
VOID VOID
EFIAPI EFIAPI
GasketSecSleep ( GasketSecSleep (
@ -155,10 +153,8 @@ GasketSecGetNextProtocol (
OUT EMU_IO_THUNK_PROTOCOL **Instance OPTIONAL OUT EMU_IO_THUNK_PROTOCOL **Instance OPTIONAL
); );
// PPIs produced by SEC // PPIs produced by SEC
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
GasketSecUnixPeiAutoScan ( GasketSecUnixPeiAutoScan (
@ -173,7 +169,6 @@ GasketSecEmuThunkAddress (
VOID VOID
); );
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
GasketSecUnixUnixFwhAddress ( GasketSecUnixUnixFwhAddress (
@ -181,15 +176,13 @@ GasketSecUnixUnixFwhAddress (
IN OUT EFI_PHYSICAL_ADDRESS *FwhBase IN OUT EFI_PHYSICAL_ADDRESS *FwhBase
); );
// //
// Reverse (UNIX to EFIAPI) gaskets // Reverse (UNIX to EFIAPI) gaskets
// //
typedef typedef
void void
(EFIAPI *CALL_BACK) ( (EFIAPI *CALL_BACK)(
UINT64 Delta UINT64 Delta
); );
@ -210,7 +203,6 @@ ReverseGasketUint64Uint64 (
// Gasket functions for EFI_EMU_UGA_IO_PROTOCOL // Gasket functions for EFI_EMU_UGA_IO_PROTOCOL
// //
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
GasketX11Size ( GasketX11Size (
@ -248,7 +240,6 @@ GasketX11RegisterKeyNotify (
IN VOID *Context IN VOID *Context
); );
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
GasketX11Blt ( GasketX11Blt (
@ -291,36 +282,30 @@ GasketPthreadMutexLock (
IN VOID *Mutex IN VOID *Mutex
); );
UINTN UINTN
EFIAPI EFIAPI
GasketPthreadMutexUnLock ( GasketPthreadMutexUnLock (
IN VOID *Mutex IN VOID *Mutex
); );
UINTN UINTN
EFIAPI EFIAPI
GasketPthreadMutexTryLock ( GasketPthreadMutexTryLock (
IN VOID *Mutex IN VOID *Mutex
); );
VOID * VOID *
EFIAPI EFIAPI
GasketPthreadMutexInit ( GasketPthreadMutexInit (
IN VOID IN VOID
); );
UINTN UINTN
EFIAPI EFIAPI
GasketPthreadMutexDestroy ( GasketPthreadMutexDestroy (
IN VOID *Mutex IN VOID *Mutex
); );
UINTN UINTN
EFIAPI EFIAPI
GasketPthreadCreate ( GasketPthreadCreate (
@ -336,7 +321,6 @@ GasketPthreadExit (
IN VOID *ValuePtr IN VOID *ValuePtr
); );
UINTN UINTN
EFIAPI EFIAPI
GasketPthreadSelf ( GasketPthreadSelf (
@ -355,7 +339,6 @@ GasketPthreadClose (
IN EMU_IO_THUNK_PROTOCOL *This IN EMU_IO_THUNK_PROTOCOL *This
); );
// PosixFileSystem // PosixFileSystem
EFI_STATUS EFI_STATUS
@ -639,7 +622,4 @@ GasketSnpReceive (
OUT UINT16 *Protocol OPTIONAL OUT UINT16 *Protocol OPTIONAL
); );
#endif #endif

View File

@ -12,7 +12,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define MAP_ANONYMOUS MAP_ANON #define MAP_ANONYMOUS MAP_ANON
#endif #endif
// //
// Globals // Globals
// //
@ -26,7 +25,6 @@ EMU_THUNK_PPI mSecEmuThunkPpi = {
char *gGdbWorkingFileName = NULL; char *gGdbWorkingFileName = NULL;
unsigned int mScriptSymbolChangesCount = 0; unsigned int mScriptSymbolChangesCount = 0;
// //
// Default information about where the FD is located. // Default information about where the FD is located.
// This array gets filled in with information from EFI_FIRMWARE_VOLUMES // This array gets filled in with information from EFI_FIRMWARE_VOLUMES
@ -46,17 +44,13 @@ EMU_FD_INFO *gFdInfo;
UINTN gSystemMemoryCount = 0; UINTN gSystemMemoryCount = 0;
EMU_SYSTEM_MEMORY *gSystemMemory; EMU_SYSTEM_MEMORY *gSystemMemory;
UINTN mImageContextModHandleArraySize = 0; UINTN mImageContextModHandleArraySize = 0;
IMAGE_CONTEXT_TO_MOD_HANDLE *mImageContextModHandleArray = NULL; IMAGE_CONTEXT_TO_MOD_HANDLE *mImageContextModHandleArray = NULL;
EFI_PEI_PPI_DESCRIPTOR *gPpiList; EFI_PEI_PPI_DESCRIPTOR *gPpiList;
int gInXcode = 0; int gInXcode = 0;
/*++ /*++
Breakpoint target for Xcode project. Set in the Xcode XML Breakpoint target for Xcode project. Set in the Xcode XML
@ -71,8 +65,6 @@ SecGdbConfigBreak (
{ {
} }
/*++ /*++
Routine Description: Routine Description:
@ -122,7 +114,7 @@ main (
// symbols to be loaded. // symbols to be loaded.
// //
Index = strlen (*Argv); Index = strlen (*Argv);
gGdbWorkingFileName = AllocatePool (Index + strlen(".gdb") + 1); gGdbWorkingFileName = AllocatePool (Index + strlen (".gdb") + 1);
strcpy (gGdbWorkingFileName, *Argv); strcpy (gGdbWorkingFileName, *Argv);
strcat (gGdbWorkingFileName, ".gdb"); strcat (gGdbWorkingFileName, ".gdb");
@ -139,8 +131,8 @@ main (
setbuf (stdout, 0); setbuf (stdout, 0);
setbuf (stderr, 0); setbuf (stderr, 0);
MemorySizeStr = (CHAR16 *) PcdGetPtr (PcdEmuMemorySize); MemorySizeStr = (CHAR16 *)PcdGetPtr (PcdEmuMemorySize);
FirmwareVolumesStr = (CHAR16 *) PcdGetPtr (PcdEmuFirmwareVolume); FirmwareVolumesStr = (CHAR16 *)PcdGetPtr (PcdEmuFirmwareVolume);
// //
// PPIs pased into PEI_CORE // PPIs pased into PEI_CORE
@ -175,6 +167,7 @@ main (
printf ("ERROR : Can not allocate memory for system. Exiting.\n"); printf ("ERROR : Can not allocate memory for system. Exiting.\n");
exit (1); exit (1);
} }
// //
// Allocate space for gSystemMemory Array // Allocate space for gSystemMemory Array
// //
@ -194,29 +187,33 @@ main (
// //
InitialStackMemorySize = STACK_SIZE; InitialStackMemorySize = STACK_SIZE;
InitialStackMemory = (UINTN)MapMemory ( InitialStackMemory = (UINTN)MapMemory (
0, (UINT32) InitialStackMemorySize, 0,
PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANONYMOUS | MAP_PRIVATE (UINT32)InitialStackMemorySize,
PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_ANONYMOUS | MAP_PRIVATE
); );
if (InitialStackMemory == 0) { if (InitialStackMemory == 0) {
printf ("ERROR : Can not open SecStack Exiting\n"); printf ("ERROR : Can not open SecStack Exiting\n");
exit (1); 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 int)(InitialStackMemorySize / 1024),
(unsigned long)InitialStackMemory (unsigned long)InitialStackMemory
); );
for (StackPointer = (UINTN*) (UINTN) InitialStackMemory; for (StackPointer = (UINTN *)(UINTN)InitialStackMemory;
StackPointer < (UINTN*)(UINTN)((UINTN) InitialStackMemory + (UINT64) InitialStackMemorySize); StackPointer < (UINTN *)(UINTN)((UINTN)InitialStackMemory + (UINT64)InitialStackMemorySize);
StackPointer ++) { StackPointer++)
{
*StackPointer = 0x5AA55AA5; *StackPointer = 0x5AA55AA5;
} }
// //
// Open All the firmware volumes and remember the info in the gFdInfo global // 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) { if (FileName == NULL) {
printf ("ERROR : Can not allocate memory for firmware volume string\n"); printf ("ERROR : Can not allocate memory for firmware volume string\n");
exit (1); exit (1);
@ -225,13 +222,16 @@ main (
Index2 = 0; Index2 = 0;
for (Done = FALSE, Index = 0, PeiIndex = 0, SecFile = NULL; for (Done = FALSE, Index = 0, PeiIndex = 0, SecFile = NULL;
FirmwareVolumesStr[Index2] != 0; FirmwareVolumesStr[Index2] != 0;
Index++) { Index++)
{
for (Index1 = 0; (FirmwareVolumesStr[Index2] != '!') && (FirmwareVolumesStr[Index2] != 0); Index2++) { for (Index1 = 0; (FirmwareVolumesStr[Index2] != '!') && (FirmwareVolumesStr[Index2] != 0); Index2++) {
FileName[Index1++] = FirmwareVolumesStr[Index2]; FileName[Index1++] = FirmwareVolumesStr[Index2];
} }
if (FirmwareVolumesStr[Index2] == '!') { if (FirmwareVolumesStr[Index2] == '!') {
Index2++; Index2++;
} }
FileName[Index1] = '\0'; FileName[Index1] = '\0';
if (Index == 0) { if (Index == 0) {
@ -252,12 +252,13 @@ main (
&gFdInfo[Index].Size &gFdInfo[Index].Size
); );
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
printf ("ERROR : Can not open Firmware Device File %s (%x). Exiting.\n", FileName, (unsigned int)Status); printf ("ERROR : Can not open Firmware Device File %s (%x). Exiting.\n", FileName, (unsigned int)Status);
exit (1); 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) { if (SecFile == NULL) {
// //
@ -303,10 +304,12 @@ main (
val = val * 10 + MemorySizeStr[Index1] - '0'; val = val * 10 + MemorySizeStr[Index1] - '0';
Index1++; Index1++;
} }
gSystemMemory[Index++].Size = val * 0x100000; gSystemMemory[Index++].Size = val * 0x100000;
if (MemorySizeStr[Index1] == 0) { if (MemorySizeStr[Index1] == 0) {
break; break;
} }
Index1++; Index1++;
} }
@ -315,7 +318,7 @@ main (
// //
// Hand off to SEC // 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 // If we get here, then the SEC Core returned. This is an error as SEC should
@ -325,7 +328,6 @@ main (
exit (1); exit (1);
} }
EFI_PHYSICAL_ADDRESS * EFI_PHYSICAL_ADDRESS *
MapMemory ( MapMemory (
IN INTN fd, IN INTN fd,
@ -343,22 +345,23 @@ MapMemory (
// Try to get an aligned block somewhere in the address space of this // Try to get an aligned block somewhere in the address space of this
// process. // process.
// //
while((!isAligned) && (base != 0)) { while ((!isAligned) && (base != 0)) {
res = mmap ((void *)base, length, prot, flags, fd, 0); res = mmap ((void *)base, length, prot, flags, fd, 0);
if (res == MAP_FAILED) { if (res == MAP_FAILED) {
return NULL; return NULL;
} }
if ((((UINTN)res) & ~(align-1)) == (UINTN)res) { if ((((UINTN)res) & ~(align-1)) == (UINTN)res) {
isAligned=1; isAligned = 1;
} else { } else {
munmap(res, length); munmap (res, length);
base += align; base += align;
} }
} }
return res; return res;
} }
/*++ /*++
Routine Description: Routine Description:
@ -397,8 +400,8 @@ MapFile (
if (fd < 0) { if (fd < 0) {
return EFI_NOT_FOUND; 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); res = MapMemory (fd, FileSize, PROT_READ | PROT_EXEC, MAP_PRIVATE);
@ -409,8 +412,8 @@ MapFile (
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
*Length = (UINT64) FileSize; *Length = (UINT64)FileSize;
*BaseAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) res; *BaseAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)res;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -432,6 +435,7 @@ MapFd0 (
if (fd < 0) { if (fd < 0) {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
FileSize = lseek (fd, 0, SEEK_END); FileSize = lseek (fd, 0, SEEK_END);
FvSize = FixedPcdGet64 (PcdEmuFlashFvRecoverySize); FvSize = FixedPcdGet64 (PcdEmuFlashFvRecoverySize);
@ -504,13 +508,12 @@ MapFd0 (
} }
} }
*Length = (UINT64) FileSize; *Length = (UINT64)FileSize;
*BaseAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) res; *BaseAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)res;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/*++ /*++
Routine Description: Routine Description:
@ -545,7 +548,7 @@ SecLoadFromCore (
// Compute Top Of Memory for Stack and PEI Core Allocations // Compute Top Of Memory for Stack and PEI Core Allocations
// //
TopOfMemory = LargestRegion + LargestRegionSize; TopOfMemory = LargestRegion + LargestRegionSize;
PeiStackSize = (UINTN)RShiftU64((UINT64)STACK_SIZE,1); PeiStackSize = (UINTN)RShiftU64 ((UINT64)STACK_SIZE, 1);
// //
// |-----------| <---- TemporaryRamBase + TemporaryRamSize // |-----------| <---- TemporaryRamBase + TemporaryRamSize
@ -565,19 +568,18 @@ SecLoadFromCore (
TopOfStack = (VOID *)((UINTN)TopOfStack - sizeof (EFI_SEC_PEI_HAND_OFF) - CPU_STACK_ALIGNMENT); TopOfStack = (VOID *)((UINTN)TopOfStack - sizeof (EFI_SEC_PEI_HAND_OFF) - CPU_STACK_ALIGNMENT);
TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT); TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);
// //
// Bind this information into the SEC hand-off state // 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->DataSize = sizeof (EFI_SEC_PEI_HAND_OFF);
SecCoreData->BootFirmwareVolumeBase = (VOID*)BootFirmwareVolumeBase; SecCoreData->BootFirmwareVolumeBase = (VOID *)BootFirmwareVolumeBase;
SecCoreData->BootFirmwareVolumeSize = PcdGet32 (PcdEmuFirmwareFdSize); SecCoreData->BootFirmwareVolumeSize = PcdGet32 (PcdEmuFirmwareFdSize);
SecCoreData->TemporaryRamBase = (VOID*)(UINTN)LargestRegion; SecCoreData->TemporaryRamBase = (VOID *)(UINTN)LargestRegion;
SecCoreData->TemporaryRamSize = STACK_SIZE; SecCoreData->TemporaryRamSize = STACK_SIZE;
SecCoreData->StackBase = SecCoreData->TemporaryRamBase; SecCoreData->StackBase = SecCoreData->TemporaryRamBase;
SecCoreData->StackSize = PeiStackSize; SecCoreData->StackSize = PeiStackSize;
SecCoreData->PeiTemporaryRamBase = (VOID*) ((UINTN) SecCoreData->TemporaryRamBase + PeiStackSize); SecCoreData->PeiTemporaryRamBase = (VOID *)((UINTN)SecCoreData->TemporaryRamBase + PeiStackSize);
SecCoreData->PeiTemporaryRamSize = STACK_SIZE - PeiStackSize; SecCoreData->PeiTemporaryRamSize = STACK_SIZE - PeiStackSize;
// //
@ -585,14 +587,14 @@ SecLoadFromCore (
// //
Status = SecPeCoffGetEntryPoint (PeiCorePe32File, (VOID **)&PeiCoreEntryPoint); Status = SecPeCoffGetEntryPoint (PeiCorePe32File, (VOID **)&PeiCoreEntryPoint);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return ; return;
} }
// //
// Transfer control to the SEC Core // Transfer control to the SEC Core
// //
PeiSwitchStacks ( PeiSwitchStacks (
(SWITCH_STACK_ENTRY_POINT) (UINTN) PeiCoreEntryPoint, (SWITCH_STACK_ENTRY_POINT)(UINTN)PeiCoreEntryPoint,
SecCoreData, SecCoreData,
(VOID *)gPpiList, (VOID *)gPpiList,
TopOfStack TopOfStack
@ -600,10 +602,9 @@ SecLoadFromCore (
// //
// If we get here, then the SEC Core returned. This is an error // If we get here, then the SEC Core returned. This is an error
// //
return ; return;
} }
/*++ /*++
Routine Description: Routine Description:
@ -639,13 +640,15 @@ SecUnixPeiAutoScan (
*MemoryBase = 0; *MemoryBase = 0;
res = MapMemory ( res = MapMemory (
0, gSystemMemory[Index].Size, 0,
gSystemMemory[Index].Size,
PROT_READ | PROT_WRITE | PROT_EXEC, PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_PRIVATE | MAP_ANONYMOUS MAP_PRIVATE | MAP_ANONYMOUS
); );
if (res == MAP_FAILED) { if (res == MAP_FAILED) {
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
*MemorySize = gSystemMemory[Index].Size; *MemorySize = gSystemMemory[Index].Size;
*MemoryBase = (UINTN)res; *MemoryBase = (UINTN)res;
gSystemMemory[Index].Memory = *MemoryBase; gSystemMemory[Index].Memory = *MemoryBase;
@ -653,7 +656,6 @@ SecUnixPeiAutoScan (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/*++ /*++
Routine Description: Routine Description:
@ -684,7 +686,8 @@ EfiSystemMemoryRange (
MemoryBase = (EFI_PHYSICAL_ADDRESS)(UINTN)MemoryAddress; MemoryBase = (EFI_PHYSICAL_ADDRESS)(UINTN)MemoryAddress;
for (Index = 0; Index < gSystemMemoryCount; Index++) { for (Index = 0; Index < gSystemMemoryCount; Index++) {
if ((MemoryBase >= gSystemMemory[Index].Memory) && if ((MemoryBase >= gSystemMemory[Index].Memory) &&
(MemoryBase < (gSystemMemory[Index].Memory + gSystemMemory[Index].Size)) ) { (MemoryBase < (gSystemMemory[Index].Memory + gSystemMemory[Index].Size)))
{
return TRUE; return TRUE;
} }
} }
@ -692,7 +695,6 @@ EfiSystemMemoryRange (
return FALSE; return FALSE;
} }
/*++ /*++
Routine Description: Routine Description:
@ -715,8 +717,6 @@ SecEmuThunkAddress (
return &gEmuThunkProtocol; return &gEmuThunkProtocol;
} }
RETURN_STATUS RETURN_STATUS
EFIAPI EFIAPI
SecPeCoffGetEntryPoint ( SecPeCoffGetEntryPoint (
@ -729,7 +729,7 @@ SecPeCoffGetEntryPoint (
ZeroMem (&ImageContext, sizeof (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)) { if (EFI_ERROR (Status)) {
@ -759,6 +759,7 @@ SecPeCoffGetEntryPoint (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
ImageContext.EntryPoint = (UINTN)*EntryPoint; ImageContext.EntryPoint = (UINTN)*EntryPoint;
} }
@ -769,8 +770,6 @@ SecPeCoffGetEntryPoint (
return Status; return Status;
} }
/*++ /*++
Routine Description: Routine Description:
@ -804,7 +803,7 @@ SecUnixFdAddress (
*FdSize = gFdInfo[Index].Size; *FdSize = gFdInfo[Index].Size;
*FixUp = 0; *FixUp = 0;
if (*FdBase == 0 && *FdSize == 0) { if ((*FdBase == 0) && (*FdSize == 0)) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
@ -820,7 +819,6 @@ SecUnixFdAddress (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/*++ /*++
Routine Description: Routine Description:
@ -851,7 +849,6 @@ CountSeparatorsInString (
return Count; return Count;
} }
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
SecImageRead ( SecImageRead (
@ -860,6 +857,7 @@ SecImageRead (
IN OUT UINTN *ReadSize, IN OUT UINTN *ReadSize,
OUT VOID *Buffer OUT VOID *Buffer
) )
/*++ /*++
Routine Description: Routine Description:
@ -881,7 +879,7 @@ Returns:
UINTN Length; UINTN Length;
Destination8 = Buffer; Destination8 = Buffer;
Source8 = (CHAR8 *) ((UINTN) FileHandle + FileOffset); Source8 = (CHAR8 *)((UINTN)FileHandle + FileOffset);
Length = *ReadSize; Length = *ReadSize;
while (Length--) { while (Length--) {
*(Destination8++) = *(Source8++); *(Destination8++) = *(Source8++);
@ -890,7 +888,6 @@ Returns:
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/*++ /*++
Routine Description: Routine Description:
@ -917,7 +914,6 @@ AddHandle (
IMAGE_CONTEXT_TO_MOD_HANDLE *Array; IMAGE_CONTEXT_TO_MOD_HANDLE *Array;
UINTN PreviousSize; UINTN PreviousSize;
Array = mImageContextModHandleArray; Array = mImageContextModHandleArray;
for (Index = 0; Index < mImageContextModHandleArraySize; Index++, Array++) { for (Index = 0; Index < mImageContextModHandleArraySize; Index++, Array++) {
if (Array->ImageContext == NULL) { if (Array->ImageContext == NULL) {
@ -954,7 +950,6 @@ AddHandle (
return AddHandle (ImageContext, ModHandle); return AddHandle (ImageContext, ModHandle);
} }
/*++ /*++
Routine Description: Routine Description:
@ -998,8 +993,6 @@ RemoveHandle (
return NULL; return NULL;
} }
BOOLEAN BOOLEAN
IsPdbFile ( IsPdbFile (
IN CHAR8 *PdbFileName IN CHAR8 *PdbFileName
@ -1012,20 +1005,20 @@ IsPdbFile (
} }
Len = strlen (PdbFileName); Len = strlen (PdbFileName);
if ((Len < 5)|| (PdbFileName[Len - 4] != '.')) { if ((Len < 5) || (PdbFileName[Len - 4] != '.')) {
return FALSE; return FALSE;
} }
if ((PdbFileName[Len - 3] == 'P' || PdbFileName[Len - 3] == 'p') && if (((PdbFileName[Len - 3] == 'P') || (PdbFileName[Len - 3] == 'p')) &&
(PdbFileName[Len - 2] == 'D' || PdbFileName[Len - 2] == 'd') && ((PdbFileName[Len - 2] == 'D') || (PdbFileName[Len - 2] == 'd')) &&
(PdbFileName[Len - 1] == 'B' || PdbFileName[Len - 1] == 'b')) { ((PdbFileName[Len - 1] == 'B') || (PdbFileName[Len - 1] == 'b')))
{
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} }
#define MAX_SPRINT_BUFFER_SIZE 0x200 #define MAX_SPRINT_BUFFER_SIZE 0x200
void void
@ -1034,24 +1027,26 @@ PrintLoadAddress (
) )
{ {
if (ImageContext->PdbPointer == NULL) { if (ImageContext->PdbPointer == NULL) {
fprintf (stderr, fprintf (
stderr,
"0x%08lx Loading NO DEBUG with entry point 0x%08lx\n", "0x%08lx Loading NO DEBUG with entry point 0x%08lx\n",
(unsigned long)(ImageContext->ImageAddress), (unsigned long)(ImageContext->ImageAddress),
(unsigned long)ImageContext->EntryPoint (unsigned long)ImageContext->EntryPoint
); );
} else { } else {
fprintf (stderr, fprintf (
stderr,
"0x%08lx Loading %s with entry point 0x%08lx\n", "0x%08lx Loading %s with entry point 0x%08lx\n",
(unsigned long)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders), (unsigned long)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders),
ImageContext->PdbPointer, ImageContext->PdbPointer,
(unsigned long)ImageContext->EntryPoint (unsigned long)ImageContext->EntryPoint
); );
} }
// Keep output synced up // Keep output synced up
fflush (stderr); fflush (stderr);
} }
/** /**
Loads the image using dlopen so symbols will be automatically Loads the image using dlopen so symbols will be automatically
loaded by gdb. loaded by gdb.
@ -1067,12 +1062,11 @@ DlLoadImage (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
) )
{ {
#ifdef __APPLE__
#ifdef __APPLE__
return FALSE; return FALSE;
#else #else
void *Handle = NULL; void *Handle = NULL;
void *Entry = NULL; void *Entry = NULL;
@ -1098,7 +1092,7 @@ DlLoadImage (
Entry = dlsym (Handle, "_ModuleEntryPoint"); Entry = dlsym (Handle, "_ModuleEntryPoint");
AddHandle (ImageContext, Handle); AddHandle (ImageContext, Handle);
} else { } else {
printf("%s\n", dlerror()); printf ("%s\n", dlerror ());
} }
if (Entry != NULL) { if (Entry != NULL) {
@ -1109,12 +1103,11 @@ DlLoadImage (
return FALSE; return FALSE;
} }
#endif #endif
} }
#ifdef __APPLE__ #ifdef __APPLE__
__attribute__((noinline)) __attribute__ ((noinline))
#endif #endif
VOID VOID
SecGdbScriptBreak ( SecGdbScriptBreak (
@ -1127,7 +1120,6 @@ SecGdbScriptBreak (
return; return;
} }
/** /**
Adds the image to a gdb script so its symbols can be loaded. Adds the image to a gdb script so its symbols can be loaded.
The AddFirmwareSymbolFile helper macro is used. The AddFirmwareSymbolFile helper macro is used.
@ -1140,10 +1132,9 @@ GdbScriptAddImage (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
) )
{ {
PrintLoadAddress (ImageContext); PrintLoadAddress (ImageContext);
if (ImageContext->PdbPointer != NULL && !IsPdbFile (ImageContext->PdbPointer)) { if ((ImageContext->PdbPointer != NULL) && !IsPdbFile (ImageContext->PdbPointer)) {
FILE *GdbTempFile; FILE *GdbTempFile;
if (FeaturePcdGet (PcdEmulatorLazyLoadSymbols)) { if (FeaturePcdGet (PcdEmulatorLazyLoadSymbols)) {
GdbTempFile = fopen (gGdbWorkingFileName, "a"); GdbTempFile = fopen (gGdbWorkingFileName, "a");
@ -1188,7 +1179,6 @@ GdbScriptAddImage (
} }
} }
VOID VOID
EFIAPI EFIAPI
SecPeCoffRelocateImageExtraAction ( SecPeCoffRelocateImageExtraAction (
@ -1200,7 +1190,6 @@ SecPeCoffRelocateImageExtraAction (
} }
} }
/** /**
Adds the image to a gdb script so its symbols can be unloaded. Adds the image to a gdb script so its symbols can be unloaded.
The RemoveFirmwareSymbolFile helper macro is used. The RemoveFirmwareSymbolFile helper macro is used.
@ -1257,7 +1246,6 @@ GdbScriptRemoveImage (
} }
} }
VOID VOID
EFIAPI EFIAPI
SecPeCoffUnloadImageExtraAction ( SecPeCoffUnloadImageExtraAction (
@ -1271,13 +1259,11 @@ SecPeCoffUnloadImageExtraAction (
// //
Handle = RemoveHandle (ImageContext); Handle = RemoveHandle (ImageContext);
if (Handle != NULL) { if (Handle != NULL) {
#ifndef __APPLE__ #ifndef __APPLE__
dlclose (Handle); dlclose (Handle);
#endif #endif
return; return;
} }
GdbScriptRemoveImage (ImageContext); GdbScriptRemoveImage (ImageContext);
} }

View File

@ -30,9 +30,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <sys/time.h> #include <sys/time.h>
#if __CYGWIN__ #if __CYGWIN__
#include <sys/dirent.h> #include <sys/dirent.h>
#else #else
#include <sys/dir.h> #include <sys/dir.h>
#endif #endif
#include <sys/mman.h> #include <sys/mman.h>
@ -56,19 +56,19 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <ifaddrs.h> #include <ifaddrs.h>
#ifdef __APPLE__ #ifdef __APPLE__
#include <net/if_dl.h> #include <net/if_dl.h>
#include <net/bpf.h> #include <net/bpf.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/mount.h> #include <sys/mount.h>
#include <sys/disk.h> #include <sys/disk.h>
#define _XOPEN_SOURCE #define _XOPEN_SOURCE
#ifndef _Bool #ifndef _Bool
#define _Bool char // for clang debug #define _Bool char // for clang debug
#endif #endif
#else #else
#include <termio.h> #include <termio.h>
#include <sys/vfs.h> #include <sys/vfs.h>
#include <linux/fs.h> #include <linux/fs.h>
#endif #endif
#include <utime.h> #include <utime.h>
@ -120,10 +120,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Guid/FileSystemInfo.h> #include <Guid/FileSystemInfo.h>
#include <Guid/FileSystemVolumeLabelInfo.h> #include <Guid/FileSystemVolumeLabelInfo.h>
#include "Gasket.h" #include "Gasket.h"
#define STACK_SIZE 0x20000 #define STACK_SIZE 0x20000
typedef struct { typedef struct {
@ -136,7 +134,6 @@ typedef struct {
UINT64 Size; UINT64 Size;
} EMU_SYSTEM_MEMORY; } 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 { typedef struct {
@ -144,7 +141,6 @@ typedef struct {
VOID *ModHandle; VOID *ModHandle;
} IMAGE_CONTEXT_TO_MOD_HANDLE; } IMAGE_CONTEXT_TO_MOD_HANDLE;
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
SecUnixPeiLoadFile ( SecUnixPeiLoadFile (
@ -230,7 +226,6 @@ GasketSecUnixFdAddress (
) )
; ;
EFI_STATUS EFI_STATUS
GetImageReadFunction ( GetImageReadFunction (
IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext, IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
@ -276,7 +271,6 @@ GasketSecTemporaryRamSupport (
IN UINTN CopySize IN UINTN CopySize
); );
RETURN_STATUS RETURN_STATUS
EFIAPI EFIAPI
SecPeCoffGetEntryPoint ( SecPeCoffGetEntryPoint (
@ -296,7 +290,6 @@ SecPeCoffLoaderUnloadImageExtraAction (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
); );
VOID VOID
PeiSwitchStacks ( PeiSwitchStacks (
IN SWITCH_STACK_ENTRY_POINT EntryPoint, IN SWITCH_STACK_ENTRY_POINT EntryPoint,
@ -310,13 +303,13 @@ SecInitThunkProtocol (
VOID VOID
); );
EFI_PHYSICAL_ADDRESS * EFI_PHYSICAL_ADDRESS *
MapMemory ( MapMemory (
INTN fd, INTN fd,
UINT64 length, UINT64 length,
INTN prot, INTN prot,
INTN flags); INTN flags
);
EFI_STATUS EFI_STATUS
MapFile ( MapFile (
@ -337,12 +330,25 @@ EfiSystemMemoryRange (
IN VOID *MemoryAddress IN VOID *MemoryAddress
); );
VOID
SecSleep (
UINT64 Nanoseconds
);
VOID SecSleep (UINT64 Nanoseconds); VOID
VOID SecEnableInterrupt (VOID); SecEnableInterrupt (
VOID SecDisableInterrupt (VOID); VOID
BOOLEAN SecInterruptEanbled (VOID); );
VOID
SecDisableInterrupt (
VOID
);
BOOLEAN
SecInterruptEanbled (
VOID
);
extern EMU_THUNK_PROTOCOL gEmuThunkProtocol; extern EMU_THUNK_PROTOCOL gEmuThunkProtocol;
extern EMU_IO_THUNK_PROTOCOL gX11ThunkIo; extern EMU_IO_THUNK_PROTOCOL gX11ThunkIo;

View File

@ -9,7 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "Host.h" #include "Host.h"
/** /**
Transfers control to a function starting with a new stack. Transfers control to a function starting with a new stack.
@ -50,14 +49,13 @@ PeiSwitchStacks (
ASSERT (((UINTN)NewStack & (CPU_STACK_ALIGNMENT - 1)) == 0); ASSERT (((UINTN)NewStack & (CPU_STACK_ALIGNMENT - 1)) == 0);
JumpBuffer.Eip = (UINTN)EntryPoint; JumpBuffer.Eip = (UINTN)EntryPoint;
JumpBuffer.Esp = (UINTN)NewStack - sizeof (VOID*); JumpBuffer.Esp = (UINTN)NewStack - sizeof (VOID *);
JumpBuffer.Esp -= sizeof (Context1) + sizeof (Context2); JumpBuffer.Esp -= sizeof (Context1) + sizeof (Context2);
((VOID**)JumpBuffer.Esp)[1] = Context1; ((VOID **)JumpBuffer.Esp)[1] = Context1;
((VOID**)JumpBuffer.Esp)[2] = Context2; ((VOID **)JumpBuffer.Esp)[2] = Context2;
LongJump (&JumpBuffer, (UINTN)-1); LongJump (&JumpBuffer, (UINTN)-1);
// //
// PeiSwitchStacks () will never return // PeiSwitchStacks () will never return
// //

View File

@ -12,7 +12,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#include "Host.h" #include "Host.h"
#ifndef __APPLE__ #ifndef __APPLE__
@ -23,10 +22,8 @@ typedef struct {
EMU_IO_THUNK_PROTOCOL *Thunk; EMU_IO_THUNK_PROTOCOL *Thunk;
EMU_SNP_PROTOCOL EmuSnp; EMU_SNP_PROTOCOL EmuSnp;
EFI_SIMPLE_NETWORK_MODE *Mode; EFI_SIMPLE_NETWORK_MODE *Mode;
} EMU_SNP_PRIVATE; } EMU_SNP_PRIVATE;
#define EMU_SNP_PRIVATE_DATA_FROM_THIS(a) \ #define EMU_SNP_PRIVATE_DATA_FROM_THIS(a) \
@ -517,7 +514,6 @@ EmuSnpReceive (
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
EMU_SNP_PROTOCOL gEmuSnpProtocol = { EMU_SNP_PROTOCOL gEmuSnpProtocol = {
GasketSnpCreateMapping, GasketSnpCreateMapping,
GasketSnpStart, GasketSnpStart,
@ -555,7 +551,6 @@ EmuSnpThunkOpen (
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
Private->Signature = EMU_SNP_PRIVATE_SIGNATURE; Private->Signature = EMU_SNP_PRIVATE_SIGNATURE;
Private->Thunk = This; Private->Thunk = This;
CopyMem (&Private->EmuSnp, &gEmuSnpProtocol, sizeof (gEmuSnpProtocol)); CopyMem (&Private->EmuSnp, &gEmuSnpProtocol, sizeof (gEmuSnpProtocol));
@ -565,7 +560,6 @@ EmuSnpThunkOpen (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EFI_STATUS EFI_STATUS
EmuSnpThunkClose ( EmuSnpThunkClose (
IN EMU_IO_THUNK_PROTOCOL *This IN EMU_IO_THUNK_PROTOCOL *This
@ -583,8 +577,6 @@ EmuSnpThunkClose (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EMU_IO_THUNK_PROTOCOL gSnpThunkIo = { EMU_IO_THUNK_PROTOCOL gSnpThunkIo = {
&gEmuSnpProtocolGuid, &gEmuSnpProtocolGuid,
NULL, NULL,

View File

@ -30,10 +30,9 @@ AllocatePool (
IN UINTN AllocationSize IN UINTN AllocationSize
) )
{ {
return (VOID*) malloc (AllocationSize); return (VOID *)malloc (AllocationSize);
} }
/** /**
Allocates and zeros a buffer of type EfiBootServicesData. Allocates and zeros a buffer of type EfiBootServicesData.
@ -65,7 +64,6 @@ AllocateZeroPool (
return Buffer; return Buffer;
} }
/** /**
Reallocates a buffer of type EfiBootServicesData. Reallocates a buffer of type EfiBootServicesData.
@ -113,7 +111,6 @@ ReallocatePool (
return NewBuffer; return NewBuffer;
} }
/** /**
Frees a buffer that was previously allocated with one of the pool allocation functions in the Frees a buffer that was previously allocated with one of the pool allocation functions in the
Memory Allocation Library. Memory Allocation Library.
@ -134,6 +131,5 @@ FreePool (
IN VOID *Buffer IN VOID *Buffer
) )
{ {
free ((void *) Buffer); free ((void *)Buffer);
} }

View File

@ -10,7 +10,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "Host.h" #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 { typedef struct {
@ -29,7 +28,6 @@ typedef struct {
EMU_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE \ 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 { typedef struct {
@ -69,7 +67,6 @@ PosixFileSetInfo (
IN VOID *Buffer IN VOID *Buffer
); );
EFI_FILE_PROTOCOL gPosixFileProtocol = { EFI_FILE_PROTOCOL gPosixFileProtocol = {
EFI_FILE_REVISION, EFI_FILE_REVISION,
GasketPosixFileOpen, GasketPosixFileOpen,
@ -89,7 +86,6 @@ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL gPosixFileSystemProtocol = {
GasketPosixOpenVolume, GasketPosixOpenVolume,
}; };
/** /**
Open the root directory on a volume. Open the root directory on a volume.
@ -127,6 +123,7 @@ PosixOpenVolume (
if (PrivateFile->FileName == NULL) { if (PrivateFile->FileName == NULL) {
goto Done; goto Done;
} }
AsciiStrCpyS ( AsciiStrCpyS (
PrivateFile->FileName, PrivateFile->FileName,
AsciiStrSize (Private->FilePath), AsciiStrSize (Private->FilePath),
@ -171,9 +168,9 @@ Done:
return Status; return Status;
} }
EFI_STATUS EFI_STATUS
ErrnoToEfiStatus () ErrnoToEfiStatus (
)
{ {
switch (errno) { switch (errno) {
case EACCES: case EACCES:
@ -207,7 +204,6 @@ CutPrefix (
*Pointer = *(Pointer + Count); *Pointer = *(Pointer + Count);
} }
VOID VOID
PosixSystemTimeToEfiTime ( PosixSystemTimeToEfiTime (
IN time_t SystemTime, IN time_t SystemTime,
@ -229,7 +225,6 @@ PosixSystemTimeToEfiTime (
Time->Daylight = (daylight ? EFI_TIME_ADJUST_DAYLIGHT : 0) | (tm->tm_isdst > 0 ? EFI_TIME_IN_DAYLIGHT : 0); Time->Daylight = (daylight ? EFI_TIME_ADJUST_DAYLIGHT : 0) | (tm->tm_isdst > 0 ? EFI_TIME_IN_DAYLIGHT : 0);
} }
EFI_STATUS EFI_STATUS
UnixSimpleFileSystemFileInfo ( UnixSimpleFileSystemFileInfo (
EMU_EFI_FILE_PRIVATE *PrivateFile, EMU_EFI_FILE_PRIVATE *PrivateFile,
@ -273,7 +268,8 @@ UnixSimpleFileSystemFileInfo (
*BufferSize = ResultSize; *BufferSize = ResultSize;
return EFI_BUFFER_TOO_SMALL; 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; return EFI_DEVICE_ERROR;
} }
@ -294,15 +290,15 @@ UnixSimpleFileSystemFileInfo (
Info->Attribute |= EFI_FILE_READ_ONLY; Info->Attribute |= EFI_FILE_READ_ONLY;
} }
if (S_ISDIR(buf.st_mode)) { if (S_ISDIR (buf.st_mode)) {
Info->Attribute |= EFI_FILE_DIRECTORY; Info->Attribute |= EFI_FILE_DIRECTORY;
} }
BufferFileName = (CHAR16 *)((CHAR8 *)Buffer + Size);
BufferFileName = (CHAR16 *)((CHAR8 *) Buffer + Size);
while (*RealFileName) { while (*RealFileName) {
*BufferFileName++ = *RealFileName++; *BufferFileName++ = *RealFileName++;
} }
*BufferFileName = 0; *BufferFileName = 0;
*BufferSize = ResultSize; *BufferSize = ResultSize;
@ -315,16 +311,16 @@ IsZero (
IN UINTN Length IN UINTN Length
) )
{ {
if (Buffer == NULL || Length == 0) { if ((Buffer == NULL) || (Length == 0)) {
return FALSE; return FALSE;
} }
if (*(UINT8 *) Buffer != 0) { if (*(UINT8 *)Buffer != 0) {
return FALSE; return FALSE;
} }
if (Length > 1) { if (Length > 1) {
if (!CompareMem (Buffer, (UINT8 *) Buffer + 1, Length - 1)) { if (!CompareMem (Buffer, (UINT8 *)Buffer + 1, Length - 1)) {
return FALSE; return FALSE;
} }
} }
@ -332,8 +328,6 @@ IsZero (
return TRUE; return TRUE;
} }
/** /**
Opens a new file relative to the source file's location. Opens a new file relative to the source file's location.
@ -394,7 +388,8 @@ PosixFileOpen (
// //
TrailingDash = FALSE; TrailingDash = FALSE;
if ((StrCmp (FileName, L"\\") == 0) || if ((StrCmp (FileName, L"\\") == 0) ||
(StrCmp (FileName, L".") == 0 && PrivateFile->IsRootDirectory)) { ((StrCmp (FileName, L".") == 0) && PrivateFile->IsRootDirectory))
{
OpenRoot: OpenRoot:
Status = PosixOpenVolume (PrivateFile->SimpleFileSystem, &Root); Status = PosixOpenVolume (PrivateFile->SimpleFileSystem, &Root);
NewPrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (Root); NewPrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (Root);
@ -430,6 +425,7 @@ OpenRoot:
AsciiStrCpyS (NewPrivateFile->FileName, Size, PrivateFile->FileName); AsciiStrCpyS (NewPrivateFile->FileName, Size, PrivateFile->FileName);
Src = FileName; Src = FileName;
} }
Dst = NewPrivateFile->FileName + AsciiStrLen (NewPrivateFile->FileName); Dst = NewPrivateFile->FileName + AsciiStrLen (NewPrivateFile->FileName);
GuardPointer = NewPrivateFile->FileName + AsciiStrLen (PrivateRoot->FilePath); GuardPointer = NewPrivateFile->FileName + AsciiStrLen (PrivateRoot->FilePath);
*Dst++ = '/'; *Dst++ = '/';
@ -440,10 +436,11 @@ OpenRoot:
} else { } else {
*Dst++ = *Src; *Dst++ = *Src;
} }
Src++; Src++;
} }
*Dst = 0;
*Dst = 0;
// //
// Get rid of . and .., except leading . or .. // Get rid of . and .., except leading . or ..
@ -458,11 +455,11 @@ OpenRoot:
LoopFinish = TRUE; LoopFinish = TRUE;
for (ParseFileName = GuardPointer; *ParseFileName; ParseFileName++) { for (ParseFileName = GuardPointer; *ParseFileName; ParseFileName++) {
if (*ParseFileName == '.' && if ((*ParseFileName == '.') &&
(*(ParseFileName + 1) == 0 || *(ParseFileName + 1) == '/') && ((*(ParseFileName + 1) == 0) || (*(ParseFileName + 1) == '/')) &&
*(ParseFileName - 1) == '/' (*(ParseFileName - 1) == '/')
) { )
{
// //
// cut /. // cut /.
// //
@ -471,12 +468,12 @@ OpenRoot:
break; break;
} }
if (*ParseFileName == '.' && if ((*ParseFileName == '.') &&
*(ParseFileName + 1) == '.' && (*(ParseFileName + 1) == '.') &&
(*(ParseFileName + 2) == 0 || *(ParseFileName + 2) == '/') && ((*(ParseFileName + 2) == 0) || (*(ParseFileName + 2) == '/')) &&
*(ParseFileName - 1) == '/' (*(ParseFileName - 1) == '/')
) { )
{
ParseFileName--; ParseFileName--;
Count = 3; Count = 3;
@ -505,7 +502,7 @@ OpenRoot:
goto OpenRoot; goto OpenRoot;
} }
RealFileName = NewPrivateFile->FileName + AsciiStrLen(NewPrivateFile->FileName) - 1; RealFileName = NewPrivateFile->FileName + AsciiStrLen (NewPrivateFile->FileName) - 1;
while (RealFileName > NewPrivateFile->FileName && *RealFileName != '/') { while (RealFileName > NewPrivateFile->FileName && *RealFileName != '/') {
RealFileName--; RealFileName--;
} }
@ -514,7 +511,6 @@ OpenRoot:
*(RealFileName - 1) = 0; *(RealFileName - 1) = 0;
*(RealFileName - 1) = TempChar; *(RealFileName - 1) = TempChar;
// //
// Test whether file or directory // Test whether file or directory
// //
@ -529,7 +525,7 @@ OpenRoot:
} }
} else { } else {
res = stat (NewPrivateFile->FileName, &finfo); res = stat (NewPrivateFile->FileName, &finfo);
if (res == 0 && S_ISDIR(finfo.st_mode)) { if ((res == 0) && S_ISDIR (finfo.st_mode)) {
NewPrivateFile->IsDirectoryPath = TRUE; NewPrivateFile->IsDirectoryPath = TRUE;
} else { } else {
NewPrivateFile->IsDirectoryPath = FALSE; NewPrivateFile->IsDirectoryPath = FALSE;
@ -554,7 +550,7 @@ OpenRoot:
// //
if (mkdir (NewPrivateFile->FileName, 0777) != 0) { if (mkdir (NewPrivateFile->FileName, 0777) != 0) {
if (errno != EEXIST) { if (errno != EEXIST) {
//free (TempFileName); // free (TempFileName);
Status = EFI_ACCESS_DENIED; Status = EFI_ACCESS_DENIED;
goto Done; goto Done;
} }
@ -571,7 +567,6 @@ OpenRoot:
goto Done; goto Done;
} }
} else { } else {
// //
// deal with file // deal with file
@ -590,7 +585,7 @@ OpenRoot:
} }
} }
if ((OpenMode & EFI_FILE_MODE_CREATE) && Status == EFI_SUCCESS) { if ((OpenMode & EFI_FILE_MODE_CREATE) && (Status == EFI_SUCCESS)) {
// //
// Set the attribute // Set the attribute
// //
@ -618,7 +613,7 @@ OpenRoot:
free (Info); free (Info);
} }
Done: ; Done:;
if (TrailingDash) { if (TrailingDash) {
FileName[StrLen (FileName) + 1] = 0; FileName[StrLen (FileName) + 1] = 0;
FileName[StrLen (FileName)] = L'\\'; FileName[StrLen (FileName)] = L'\\';
@ -639,8 +634,6 @@ Done: ;
return Status; return Status;
} }
/** /**
Close the file handle Close the file handle
@ -661,6 +654,7 @@ PosixFileCLose (
if (PrivateFile->fd >= 0) { if (PrivateFile->fd >= 0) {
close (PrivateFile->fd); close (PrivateFile->fd);
} }
if (PrivateFile->Dir != NULL) { if (PrivateFile->Dir != NULL) {
closedir (PrivateFile->Dir); closedir (PrivateFile->Dir);
} }
@ -677,7 +671,6 @@ PosixFileCLose (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Close and delete the file handle. Close and delete the file handle.
@ -724,7 +717,6 @@ PosixFileDelete (
return Status; return Status;
} }
/** /**
Read data from the file. Read data from the file.
@ -768,6 +760,7 @@ PosixFileRead (
Status = EFI_DEVICE_ERROR; Status = EFI_DEVICE_ERROR;
goto Done; goto Done;
} }
*BufferSize = Res; *BufferSize = Res;
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
goto Done; goto Done;
@ -799,11 +792,12 @@ PosixFileRead (
Status = EFI_BUFFER_TOO_SMALL; Status = EFI_BUFFER_TOO_SMALL;
goto Done; goto Done;
} }
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
*BufferSize = ResultSize; *BufferSize = ResultSize;
FullFileNameSize = AsciiStrLen(PrivateFile->FileName) + 1 + NameSize; FullFileNameSize = AsciiStrLen (PrivateFile->FileName) + 1 + NameSize;
FullFileName = malloc (FullFileNameSize); FullFileName = malloc (FullFileNameSize);
if (FullFileName == NULL) { if (FullFileName == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
@ -827,8 +821,6 @@ Done:
return Status; return Status;
} }
/** /**
Write data to a file. Write data to a file.
@ -857,7 +849,6 @@ PosixFileWrite (
EMU_EFI_FILE_PRIVATE *PrivateFile; EMU_EFI_FILE_PRIVATE *PrivateFile;
int Res; int Res;
PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This); PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
if (PrivateFile->fd < 0) { if (PrivateFile->fd < 0) {
@ -881,8 +872,6 @@ PosixFileWrite (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Set a files current position Set a files current position
@ -912,23 +901,24 @@ PosixFileSetPossition (
if (PrivateFile->Dir == NULL) { if (PrivateFile->Dir == NULL) {
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
rewinddir (PrivateFile->Dir); rewinddir (PrivateFile->Dir);
return EFI_SUCCESS; return EFI_SUCCESS;
} else { } else {
if (Position == (UINT64) -1) { if (Position == (UINT64)-1) {
Pos = lseek (PrivateFile->fd, 0, SEEK_END); Pos = lseek (PrivateFile->fd, 0, SEEK_END);
} else { } else {
Pos = lseek (PrivateFile->fd, Position, SEEK_SET); Pos = lseek (PrivateFile->fd, Position, SEEK_SET);
} }
if (Pos == (off_t)-1) { if (Pos == (off_t)-1) {
return ErrnoToEfiStatus (); return ErrnoToEfiStatus ();
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
} }
/** /**
Get a file's current position Get a file's current position
@ -954,13 +944,12 @@ PosixFileGetPossition (
Status = EFI_UNSUPPORTED; Status = EFI_UNSUPPORTED;
} else { } else {
*Position = (UINT64)lseek (PrivateFile->fd, 0, SEEK_CUR); *Position = (UINT64)lseek (PrivateFile->fd, 0, SEEK_CUR);
Status = (*Position == (UINT64) -1) ? ErrnoToEfiStatus () : EFI_SUCCESS; Status = (*Position == (UINT64)-1) ? ErrnoToEfiStatus () : EFI_SUCCESS;
} }
return Status; return Status;
} }
/** /**
Get information about a file. Get information about a file.
@ -1011,7 +1000,7 @@ PosixFileGetInfo (
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
FileSystemInfoBuffer = (EFI_FILE_SYSTEM_INFO *) Buffer; FileSystemInfoBuffer = (EFI_FILE_SYSTEM_INFO *)Buffer;
FileSystemInfoBuffer->Size = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel); FileSystemInfoBuffer->Size = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel);
FileSystemInfoBuffer->ReadOnly = FALSE; FileSystemInfoBuffer->ReadOnly = FALSE;
@ -1022,14 +1011,12 @@ PosixFileGetInfo (
FileSystemInfoBuffer->FreeSpace = MultU64x32 (buf.f_bavail, buf.f_bsize); FileSystemInfoBuffer->FreeSpace = MultU64x32 (buf.f_bavail, buf.f_bsize);
FileSystemInfoBuffer->BlockSize = buf.f_bsize; FileSystemInfoBuffer->BlockSize = buf.f_bsize;
StrCpyS ( StrCpyS (
(CHAR16 *) FileSystemInfoBuffer->VolumeLabel, (CHAR16 *)FileSystemInfoBuffer->VolumeLabel,
(*BufferSize - SIZE_OF_EFI_FILE_SYSTEM_INFO) / sizeof (CHAR16), (*BufferSize - SIZE_OF_EFI_FILE_SYSTEM_INFO) / sizeof (CHAR16),
PrivateRoot->VolumeLabel PrivateRoot->VolumeLabel
); );
*BufferSize = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel); *BufferSize = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel);
} else if (CompareGuid (InformationType, &gEfiFileSystemVolumeLabelInfoIdGuid)) { } else if (CompareGuid (InformationType, &gEfiFileSystemVolumeLabelInfoIdGuid)) {
if (*BufferSize < StrSize (PrivateRoot->VolumeLabel)) { if (*BufferSize < StrSize (PrivateRoot->VolumeLabel)) {
*BufferSize = StrSize (PrivateRoot->VolumeLabel); *BufferSize = StrSize (PrivateRoot->VolumeLabel);
@ -1037,18 +1024,16 @@ PosixFileGetInfo (
} }
StrCpyS ( StrCpyS (
(CHAR16 *) Buffer, (CHAR16 *)Buffer,
*BufferSize / sizeof (CHAR16), *BufferSize / sizeof (CHAR16),
PrivateRoot->VolumeLabel PrivateRoot->VolumeLabel
); );
*BufferSize = StrSize (PrivateRoot->VolumeLabel); *BufferSize = StrSize (PrivateRoot->VolumeLabel);
} }
return Status; return Status;
} }
/** /**
Set information about a file Set information about a file
@ -1115,7 +1100,7 @@ PosixFileSetInfo (
goto Done; goto Done;
} }
NewFileSystemInfo = (EFI_FILE_SYSTEM_INFO *) Buffer; NewFileSystemInfo = (EFI_FILE_SYSTEM_INFO *)Buffer;
free (PrivateRoot->VolumeLabel); free (PrivateRoot->VolumeLabel);
@ -1146,7 +1131,7 @@ PosixFileSetInfo (
StrCpyS ( StrCpyS (
PrivateRoot->VolumeLabel, PrivateRoot->VolumeLabel,
StrSize (PrivateRoot->VolumeLabel) / sizeof (CHAR16), StrSize (PrivateRoot->VolumeLabel) / sizeof (CHAR16),
(CHAR16 *) Buffer (CHAR16 *)Buffer
); );
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
@ -1170,11 +1155,12 @@ PosixFileSetInfo (
// //
// Check for invalid set file information parameters. // Check for invalid set file information parameters.
// //
NewFileInfo = (EFI_FILE_INFO *) Buffer; NewFileInfo = (EFI_FILE_INFO *)Buffer;
if (NewFileInfo->Size <= sizeof (EFI_FILE_INFO) || if ((NewFileInfo->Size <= sizeof (EFI_FILE_INFO)) ||
(NewFileInfo->Attribute &~(EFI_FILE_VALID_ATTR)) || (NewFileInfo->Attribute &~(EFI_FILE_VALID_ATTR)) ||
(sizeof (UINTN) == 4 && NewFileInfo->Size > 0xFFFFFFFF) ((sizeof (UINTN) == 4) && (NewFileInfo->Size > 0xFFFFFFFF))
) { )
{
Status = EFI_INVALID_PARAMETER; Status = EFI_INVALID_PARAMETER;
goto Done; goto Done;
} }
@ -1222,9 +1208,9 @@ PosixFileSetInfo (
} }
AsciiStrCpyS (NewFileName, Size, PrivateRoot->FilePath); AsciiStrCpyS (NewFileName, Size, PrivateRoot->FilePath);
AsciiFilePtr = NewFileName + AsciiStrLen(NewFileName); AsciiFilePtr = NewFileName + AsciiStrLen (NewFileName);
UnicodeFilePtr = NewFileInfo->FileName + 1; UnicodeFilePtr = NewFileInfo->FileName + 1;
*AsciiFilePtr++ ='/'; *AsciiFilePtr++ = '/';
} else { } else {
Size = AsciiStrLen (PrivateFile->FileName) + 2 + StrLen (NewFileInfo->FileName) + 1; Size = AsciiStrLen (PrivateFile->FileName) + 2 + StrLen (NewFileInfo->FileName) + 1;
NewFileName = malloc (Size); NewFileName = malloc (Size);
@ -1233,19 +1219,22 @@ PosixFileSetInfo (
} }
AsciiStrCpyS (NewFileName, Size, PrivateRoot->FilePath); AsciiStrCpyS (NewFileName, Size, PrivateRoot->FilePath);
AsciiFilePtr = NewFileName + AsciiStrLen(NewFileName); AsciiFilePtr = NewFileName + AsciiStrLen (NewFileName);
if ((AsciiFilePtr[-1] != '/') && (NewFileInfo->FileName[0] != '/')) { if ((AsciiFilePtr[-1] != '/') && (NewFileInfo->FileName[0] != '/')) {
// make sure there is a / between Root FilePath and NewFileInfo Filename // make sure there is a / between Root FilePath and NewFileInfo Filename
AsciiFilePtr[0] = '/'; AsciiFilePtr[0] = '/';
AsciiFilePtr[1] = '\0'; AsciiFilePtr[1] = '\0';
AsciiFilePtr++; AsciiFilePtr++;
} }
UnicodeFilePtr = NewFileInfo->FileName; UnicodeFilePtr = NewFileInfo->FileName;
} }
// Convert to ascii. // Convert to ascii.
while (*UnicodeFilePtr) { while (*UnicodeFilePtr) {
*AsciiFilePtr++ = *UnicodeFilePtr++; *AsciiFilePtr++ = *UnicodeFilePtr++;
} }
*AsciiFilePtr = 0; *AsciiFilePtr = 0;
// //
@ -1280,15 +1269,18 @@ PosixFileSetInfo (
// //
if (!IsZero (&NewFileInfo->CreateTime, sizeof (EFI_TIME)) && 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; TimeChangeFlag = TRUE;
} else if (!IsZero (&NewFileInfo->LastAccessTime, sizeof (EFI_TIME)) && } 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; TimeChangeFlag = TRUE;
} else if (!IsZero (&NewFileInfo->ModificationTime, sizeof (EFI_TIME)) && } 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; TimeChangeFlag = TRUE;
} }
@ -1369,7 +1361,6 @@ PosixFileSetInfo (
Status = ErrnoToEfiStatus (); Status = ErrnoToEfiStatus ();
goto Done; goto Done;
} }
} }
// //
@ -1396,7 +1387,7 @@ PosixFileSetInfo (
Utime.modtime = mktime (&NewLastWriteSystemTime); 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; goto Done;
} }
@ -1438,7 +1429,6 @@ Done:
return Status; return Status;
} }
/** /**
Flush data back for the file handle. Flush data back for the file handle.
@ -1461,7 +1451,6 @@ PosixFileFlush (
{ {
EMU_EFI_FILE_PRIVATE *PrivateFile; 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) { if (PrivateFile->IsDirectoryPath) {
@ -1483,8 +1472,6 @@ PosixFileFlush (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EFI_STATUS EFI_STATUS
PosixFileSystmeThunkOpen ( PosixFileSystmeThunkOpen (
IN EMU_IO_THUNK_PROTOCOL *This IN EMU_IO_THUNK_PROTOCOL *This
@ -1516,8 +1503,8 @@ PosixFileSystmeThunkOpen (
for (i = 0; This->ConfigString[i] != 0; i++) { for (i = 0; This->ConfigString[i] != 0; i++) {
Private->FilePath[i] = This->ConfigString[i]; Private->FilePath[i] = This->ConfigString[i];
} }
Private->FilePath[i] = 0;
Private->FilePath[i] = 0;
Private->VolumeLabel = malloc (StrSize (L"EFI_EMULATED")); Private->VolumeLabel = malloc (StrSize (L"EFI_EMULATED"));
if (Private->VolumeLabel == NULL) { if (Private->VolumeLabel == NULL) {
@ -1525,6 +1512,7 @@ PosixFileSystmeThunkOpen (
free (Private); free (Private);
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
StrCpyS ( StrCpyS (
Private->VolumeLabel, Private->VolumeLabel,
StrSize (L"EFI_EMULATED") / sizeof (CHAR16), StrSize (L"EFI_EMULATED") / sizeof (CHAR16),
@ -1541,7 +1529,6 @@ PosixFileSystmeThunkOpen (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EFI_STATUS EFI_STATUS
PosixFileSystmeThunkClose ( PosixFileSystmeThunkClose (
IN EMU_IO_THUNK_PROTOCOL *This IN EMU_IO_THUNK_PROTOCOL *This
@ -1566,6 +1553,7 @@ PosixFileSystmeThunkClose (
if (Private->VolumeLabel != NULL) { if (Private->VolumeLabel != NULL) {
free (Private->VolumeLabel); free (Private->VolumeLabel);
} }
free (This->Private); free (This->Private);
This->Private = NULL; This->Private = NULL;
} }
@ -1573,7 +1561,6 @@ PosixFileSystmeThunkClose (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EMU_IO_THUNK_PROTOCOL gPosixFileSystemThunkIo = { EMU_IO_THUNK_PROTOCOL gPosixFileSystemThunkIo = {
&gEfiSimpleFileSystemProtocolGuid, &gEfiSimpleFileSystemProtocolGuid,
NULL, NULL,
@ -1583,5 +1570,3 @@ EMU_IO_THUNK_PROTOCOL gPosixFileSystemThunkIo = {
GasketPosixFileSystmeThunkClose, GasketPosixFileSystmeThunkClose,
NULL NULL
}; };

View File

@ -12,7 +12,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "Host.h" #include "Host.h"
#include <pthread.h> #include <pthread.h>
UINTN UINTN
EFIAPI EFIAPI
PthreadMutexLock ( PthreadMutexLock (
@ -22,8 +21,6 @@ PthreadMutexLock (
return (UINTN)pthread_mutex_lock ((pthread_mutex_t *)Mutex); return (UINTN)pthread_mutex_lock ((pthread_mutex_t *)Mutex);
} }
UINTN UINTN
EFIAPI EFIAPI
PthreadMutexUnLock ( PthreadMutexUnLock (
@ -33,7 +30,6 @@ PthreadMutexUnLock (
return (UINTN)pthread_mutex_unlock ((pthread_mutex_t *)Mutex); return (UINTN)pthread_mutex_unlock ((pthread_mutex_t *)Mutex);
} }
UINTN UINTN
EFIAPI EFIAPI
PthreadMutexTryLock ( PthreadMutexTryLock (
@ -43,7 +39,6 @@ PthreadMutexTryLock (
return (UINTN)pthread_mutex_trylock ((pthread_mutex_t *)Mutex); return (UINTN)pthread_mutex_trylock ((pthread_mutex_t *)Mutex);
} }
VOID * VOID *
PthreadMutexInit ( PthreadMutexInit (
IN VOID IN VOID
@ -61,7 +56,6 @@ PthreadMutexInit (
return NULL; return NULL;
} }
UINTN UINTN
PthreadMutexDestroy ( PthreadMutexDestroy (
IN VOID *Mutex IN VOID *Mutex
@ -151,7 +145,6 @@ PthreadCreate (
return err; return err;
} }
VOID VOID
PthreadExit ( PthreadExit (
IN VOID *ValuePtr IN VOID *ValuePtr
@ -161,7 +154,6 @@ PthreadExit (
return; return;
} }
UINTN UINTN
PthreadSelf ( PthreadSelf (
VOID VOID
@ -173,7 +165,6 @@ PthreadSelf (
return (UINTN)pthread_self (); return (UINTN)pthread_self ();
} }
EMU_THREAD_THUNK_PROTOCOL gPthreadThunk = { EMU_THREAD_THUNK_PROTOCOL gPthreadThunk = {
GasketPthreadMutexLock, GasketPthreadMutexLock,
GasketPthreadMutexUnLock, GasketPthreadMutexUnLock,
@ -185,7 +176,6 @@ EMU_THREAD_THUNK_PROTOCOL gPthreadThunk = {
GasketPthreadSelf GasketPthreadSelf
}; };
EFI_STATUS EFI_STATUS
PthreadOpen ( PthreadOpen (
IN EMU_IO_THUNK_PROTOCOL *This IN EMU_IO_THUNK_PROTOCOL *This
@ -206,7 +196,6 @@ PthreadOpen (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EFI_STATUS EFI_STATUS
PthreadClose ( PthreadClose (
IN EMU_IO_THUNK_PROTOCOL *This IN EMU_IO_THUNK_PROTOCOL *This
@ -215,7 +204,6 @@ PthreadClose (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EMU_IO_THUNK_PROTOCOL gPthreadThunkIo = { EMU_IO_THUNK_PROTOCOL gPthreadThunkIo = {
&gEmuThreadThunkProtocolGuid, &gEmuThreadThunkProtocolGuid,
NULL, NULL,
@ -225,5 +213,3 @@ EMU_IO_THUNK_PROTOCOL gPthreadThunkIo = {
GasketPthreadClose, GasketPthreadClose,
NULL NULL
}; };

View File

@ -22,7 +22,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define KEYSYM_LOWER 0 #define KEYSYM_LOWER 0
#define KEYSYM_UPPER 1 #define KEYSYM_UPPER 1
struct uga_drv_shift_mask { struct uga_drv_shift_mask {
unsigned char shift; unsigned char shift;
unsigned char size; unsigned char size;
@ -71,7 +70,7 @@ typedef struct {
} GRAPHICS_IO_PRIVATE; } GRAPHICS_IO_PRIVATE;
void void
HandleEvents( HandleEvents (
IN GRAPHICS_IO_PRIVATE *Drv IN GRAPHICS_IO_PRIVATE *Drv
); );
@ -87,10 +86,12 @@ fill_shift_mask (
mask >>= 1; mask >>= 1;
sm->shift++; sm->shift++;
} }
while (mask & 1) { while (mask & 1) {
sm->size++; sm->size++;
mask >>= 1; mask >>= 1;
} }
sm->csize = 8 - sm->size; sm->csize = 8 - sm->size;
} }
@ -100,9 +101,14 @@ TryCreateShmImage (
) )
{ {
Drv->image = XShmCreateImage ( Drv->image = XShmCreateImage (
Drv->display, Drv->visual, Drv->display,
Drv->depth, ZPixmap, NULL, &Drv->xshm_info, Drv->visual,
Drv->width, Drv->height Drv->depth,
ZPixmap,
NULL,
&Drv->xshm_info,
Drv->width,
Drv->height
); );
if (Drv->image == NULL) { if (Drv->image == NULL) {
return 0; return 0;
@ -121,41 +127,42 @@ TryCreateShmImage (
} }
Drv->xshm_info.shmid = shmget ( Drv->xshm_info.shmid = shmget (
IPC_PRIVATE, Drv->image->bytes_per_line * Drv->image->height, IPC_PRIVATE,
Drv->image->bytes_per_line * Drv->image->height,
IPC_CREAT | 0777 IPC_CREAT | 0777
); );
if (Drv->xshm_info.shmid < 0) { if (Drv->xshm_info.shmid < 0) {
XDestroyImage(Drv->image); XDestroyImage (Drv->image);
return 0; return 0;
} }
Drv->image_data = shmat (Drv->xshm_info.shmid, NULL, 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); shmctl (Drv->xshm_info.shmid, IPC_RMID, NULL);
XDestroyImage(Drv->image); XDestroyImage (Drv->image);
return 0; return 0;
} }
#ifndef __APPLE__ #ifndef __APPLE__
// //
// This closes shared memory in real time on OS X. Only closes after folks quit using // This closes shared memory in real time on OS X. Only closes after folks quit using
// it on Linux. // it on Linux.
// //
shmctl (Drv->xshm_info.shmid, IPC_RMID, NULL); shmctl (Drv->xshm_info.shmid, IPC_RMID, NULL);
#endif #endif
Drv->xshm_info.shmaddr = (char*)Drv->image_data; Drv->xshm_info.shmaddr = (char *)Drv->image_data;
Drv->image->data = (char*)Drv->image_data; Drv->image->data = (char *)Drv->image_data;
if (!XShmAttach (Drv->display, &Drv->xshm_info)) { if (!XShmAttach (Drv->display, &Drv->xshm_info)) {
shmdt (Drv->image_data); shmdt (Drv->image_data);
XDestroyImage(Drv->image); XDestroyImage (Drv->image);
return 0; return 0;
} }
return 1; return 1;
} }
EFI_STATUS EFI_STATUS
X11Size ( X11Size (
IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo, IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo,
@ -185,7 +192,7 @@ X11Size (
XResizeWindow (Drv->display, Drv->win, Width, Height); XResizeWindow (Drv->display, Drv->win, Width, Height);
// Allocate image. // Allocate image.
if (XShmQueryExtension(Drv->display) && TryCreateShmImage(Drv)) { if (XShmQueryExtension (Drv->display) && TryCreateShmImage (Drv)) {
Drv->use_shm = 1; Drv->use_shm = 1;
} else { } else {
Drv->use_shm = 0; Drv->use_shm = 0;
@ -199,10 +206,16 @@ X11Size (
Drv->image_data = malloc ((Drv->width * Drv->height) << Drv->pixel_shift); Drv->image_data = malloc ((Drv->width * Drv->height) << Drv->pixel_shift);
Drv->image = XCreateImage ( Drv->image = XCreateImage (
Drv->display, Drv->visual, Drv->depth, Drv->display,
ZPixmap, 0, (char *)Drv->image_data, Drv->visual,
Drv->width, Drv->height, Drv->depth,
8 << Drv->pixel_shift, 0 ZPixmap,
0,
(char *)Drv->image_data,
Drv->width,
Drv->height,
8 << Drv->pixel_shift,
0
); );
} }
@ -274,6 +287,7 @@ handleKeyEvent (
} else { } else {
Drv->KeyState.KeyShiftState &= ~EFI_RIGHT_CONTROL_PRESSED; Drv->KeyState.KeyShiftState &= ~EFI_RIGHT_CONTROL_PRESSED;
} }
break; break;
case XK_Control_L: case XK_Control_L:
if (Make) { if (Make) {
@ -281,6 +295,7 @@ handleKeyEvent (
} else { } else {
Drv->KeyState.KeyShiftState &= ~EFI_LEFT_CONTROL_PRESSED; Drv->KeyState.KeyShiftState &= ~EFI_LEFT_CONTROL_PRESSED;
} }
break; break;
case XK_Shift_R: case XK_Shift_R:
@ -289,6 +304,7 @@ handleKeyEvent (
} else { } else {
Drv->KeyState.KeyShiftState &= ~EFI_RIGHT_SHIFT_PRESSED; Drv->KeyState.KeyShiftState &= ~EFI_RIGHT_SHIFT_PRESSED;
} }
break; break;
case XK_Shift_L: case XK_Shift_L:
if (Make) { if (Make) {
@ -296,6 +312,7 @@ handleKeyEvent (
} else { } else {
Drv->KeyState.KeyShiftState &= ~EFI_LEFT_SHIFT_PRESSED; Drv->KeyState.KeyShiftState &= ~EFI_LEFT_SHIFT_PRESSED;
} }
break; break;
case XK_Mode_switch: case XK_Mode_switch:
@ -304,6 +321,7 @@ handleKeyEvent (
} else { } else {
Drv->KeyState.KeyShiftState &= ~EFI_LEFT_ALT_PRESSED; Drv->KeyState.KeyShiftState &= ~EFI_LEFT_ALT_PRESSED;
} }
break; break;
case XK_Meta_R: case XK_Meta_R:
@ -312,6 +330,7 @@ handleKeyEvent (
} else { } else {
Drv->KeyState.KeyShiftState &= ~EFI_RIGHT_LOGO_PRESSED; Drv->KeyState.KeyShiftState &= ~EFI_RIGHT_LOGO_PRESSED;
} }
break; break;
case XK_Meta_L: case XK_Meta_L:
if (Make) { if (Make) {
@ -319,122 +338,180 @@ handleKeyEvent (
} else { } else {
Drv->KeyState.KeyShiftState &= ~EFI_LEFT_LOGO_PRESSED; Drv->KeyState.KeyShiftState &= ~EFI_LEFT_LOGO_PRESSED;
} }
break; break;
case XK_KP_Home: case XK_KP_Home:
case XK_Home: KeyData.Key.ScanCode = SCAN_HOME; break; case XK_Home: KeyData.Key.ScanCode = SCAN_HOME;
break;
case XK_KP_End: case XK_KP_End:
case XK_End: KeyData.Key.ScanCode = SCAN_END; break; case XK_End: KeyData.Key.ScanCode = SCAN_END;
break;
case XK_KP_Left: case XK_KP_Left:
case XK_Left: KeyData.Key.ScanCode = SCAN_LEFT; break; case XK_Left: KeyData.Key.ScanCode = SCAN_LEFT;
break;
case XK_KP_Right: case XK_KP_Right:
case XK_Right: KeyData.Key.ScanCode = SCAN_RIGHT; break; case XK_Right: KeyData.Key.ScanCode = SCAN_RIGHT;
break;
case XK_KP_Up: case XK_KP_Up:
case XK_Up: KeyData.Key.ScanCode = SCAN_UP; break; case XK_Up: KeyData.Key.ScanCode = SCAN_UP;
break;
case XK_KP_Down: case XK_KP_Down:
case XK_Down: KeyData.Key.ScanCode = SCAN_DOWN; break; case XK_Down: KeyData.Key.ScanCode = SCAN_DOWN;
break;
case XK_KP_Delete: case XK_KP_Delete:
case XK_Delete: KeyData.Key.ScanCode = SCAN_DELETE; break; case XK_Delete: KeyData.Key.ScanCode = SCAN_DELETE;
break;
case XK_KP_Insert: case XK_KP_Insert:
case XK_Insert: KeyData.Key.ScanCode = SCAN_INSERT; break; case XK_Insert: KeyData.Key.ScanCode = SCAN_INSERT;
break;
case XK_KP_Page_Up: case XK_KP_Page_Up:
case XK_Page_Up: KeyData.Key.ScanCode = SCAN_PAGE_UP; break; case XK_Page_Up: KeyData.Key.ScanCode = SCAN_PAGE_UP;
break;
case XK_KP_Page_Down: case XK_KP_Page_Down:
case XK_Page_Down: KeyData.Key.ScanCode = SCAN_PAGE_DOWN; break; case XK_Page_Down: KeyData.Key.ScanCode = SCAN_PAGE_DOWN;
break;
case XK_Escape: KeyData.Key.ScanCode = SCAN_ESC; break; case XK_Escape: KeyData.Key.ScanCode = SCAN_ESC;
break;
case XK_Pause: KeyData.Key.ScanCode = SCAN_PAUSE; break; case XK_Pause: KeyData.Key.ScanCode = SCAN_PAUSE;
break;
case XK_KP_F1: case XK_KP_F1:
case XK_F1: KeyData.Key.ScanCode = SCAN_F1; break; case XK_F1: KeyData.Key.ScanCode = SCAN_F1;
break;
case XK_KP_F2: case XK_KP_F2:
case XK_F2: KeyData.Key.ScanCode = SCAN_F2; break; case XK_F2: KeyData.Key.ScanCode = SCAN_F2;
break;
case XK_KP_F3: case XK_KP_F3:
case XK_F3: KeyData.Key.ScanCode = SCAN_F3; break; case XK_F3: KeyData.Key.ScanCode = SCAN_F3;
break;
case XK_KP_F4: case XK_KP_F4:
case XK_F4: KeyData.Key.ScanCode = SCAN_F4; break; case XK_F4: KeyData.Key.ScanCode = SCAN_F4;
break;
case XK_F5: KeyData.Key.ScanCode = SCAN_F5; break; case XK_F5: KeyData.Key.ScanCode = SCAN_F5;
case XK_F6: KeyData.Key.ScanCode = SCAN_F6; break; break;
case XK_F7: KeyData.Key.ScanCode = SCAN_F7; 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 // Don't map into X11 by default on a Mac
// System Preferences->Keyboard->Keyboard Shortcuts can be configured // System Preferences->Keyboard->Keyboard Shortcuts can be configured
// to not use higher function keys as shortcuts and the will show up // to not use higher function keys as shortcuts and the will show up
// in X11. // in X11.
case XK_F8: KeyData.Key.ScanCode = SCAN_F8; break; case XK_F8: KeyData.Key.ScanCode = SCAN_F8;
case XK_F9: KeyData.Key.ScanCode = SCAN_F9; break; break;
case XK_F10: KeyData.Key.ScanCode = SCAN_F10; 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_F11: KeyData.Key.ScanCode = SCAN_F11;
case XK_F12: KeyData.Key.ScanCode = SCAN_F12; break; break;
case XK_F12: KeyData.Key.ScanCode = SCAN_F12;
break;
case XK_F13: KeyData.Key.ScanCode = SCAN_F13; break; case XK_F13: KeyData.Key.ScanCode = SCAN_F13;
case XK_F14: KeyData.Key.ScanCode = SCAN_F14; break; break;
case XK_F15: KeyData.Key.ScanCode = SCAN_F15; break; case XK_F14: KeyData.Key.ScanCode = SCAN_F14;
case XK_F16: KeyData.Key.ScanCode = SCAN_F16; break; break;
case XK_F17: KeyData.Key.ScanCode = SCAN_F17; break; case XK_F15: KeyData.Key.ScanCode = SCAN_F15;
case XK_F18: KeyData.Key.ScanCode = SCAN_F18; break; break;
case XK_F19: KeyData.Key.ScanCode = SCAN_F19; break; case XK_F16: KeyData.Key.ScanCode = SCAN_F16;
case XK_F20: KeyData.Key.ScanCode = SCAN_F20; break; break;
case XK_F21: KeyData.Key.ScanCode = SCAN_F21; break; case XK_F17: KeyData.Key.ScanCode = SCAN_F17;
case XK_F22: KeyData.Key.ScanCode = SCAN_F22; break; break;
case XK_F23: KeyData.Key.ScanCode = SCAN_F23; break; case XK_F18: KeyData.Key.ScanCode = SCAN_F18;
case XK_F24: KeyData.Key.ScanCode = SCAN_F24; break; 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 // No mapping in X11
//case XK_: KeyData.Key.ScanCode = SCAN_MUTE; break; // case XK_: KeyData.Key.ScanCode = SCAN_MUTE; break;
//case XK_: KeyData.Key.ScanCode = SCAN_VOLUME_UP; 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_VOLUME_DOWN; break;
//case XK_: KeyData.Key.ScanCode = SCAN_BRIGHTNESS_UP; 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_BRIGHTNESS_DOWN; break;
//case XK_: KeyData.Key.ScanCode = SCAN_SUSPEND; break; // case XK_: KeyData.Key.ScanCode = SCAN_SUSPEND; break;
//case XK_: KeyData.Key.ScanCode = SCAN_HIBERNATE; break; // case XK_: KeyData.Key.ScanCode = SCAN_HIBERNATE; break;
//case XK_: KeyData.Key.ScanCode = SCAN_TOGGLE_DISPLAY; break; // case XK_: KeyData.Key.ScanCode = SCAN_TOGGLE_DISPLAY; break;
//case XK_: KeyData.Key.ScanCode = SCAN_RECOVERY; break; // case XK_: KeyData.Key.ScanCode = SCAN_RECOVERY; break;
//case XK_: KeyData.Key.ScanCode = SCAN_EJECT; break; // case XK_: KeyData.Key.ScanCode = SCAN_EJECT; break;
case XK_BackSpace: KeyData.Key.UnicodeChar = 0x0008; break; case XK_BackSpace: KeyData.Key.UnicodeChar = 0x0008;
break;
case XK_KP_Tab: case XK_KP_Tab:
case XK_Tab: KeyData.Key.UnicodeChar = 0x0009; break; case XK_Tab: KeyData.Key.UnicodeChar = 0x0009;
break;
case XK_Linefeed: KeyData.Key.UnicodeChar = 0x000a; break; case XK_Linefeed: KeyData.Key.UnicodeChar = 0x000a;
break;
case XK_KP_Enter: case XK_KP_Enter:
case XK_Return: KeyData.Key.UnicodeChar = 0x000d; break; case XK_Return: KeyData.Key.UnicodeChar = 0x000d;
break;
case XK_KP_Equal : KeyData.Key.UnicodeChar = L'='; break; case XK_KP_Equal: KeyData.Key.UnicodeChar = L'=';
case XK_KP_Multiply : KeyData.Key.UnicodeChar = L'*'; break; break;
case XK_KP_Add : KeyData.Key.UnicodeChar = L'+'; break; case XK_KP_Multiply: KeyData.Key.UnicodeChar = L'*';
case XK_KP_Separator : KeyData.Key.UnicodeChar = L'~'; break; break;
case XK_KP_Subtract : KeyData.Key.UnicodeChar = L'-'; break; case XK_KP_Add: KeyData.Key.UnicodeChar = L'+';
case XK_KP_Decimal : KeyData.Key.UnicodeChar = L'.'; break; break;
case XK_KP_Divide : 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_0: KeyData.Key.UnicodeChar = L'0';
case XK_KP_1 : KeyData.Key.UnicodeChar = L'1'; break; break;
case XK_KP_2 : KeyData.Key.UnicodeChar = L'2'; break; case XK_KP_1: KeyData.Key.UnicodeChar = L'1';
case XK_KP_3 : KeyData.Key.UnicodeChar = L'3'; break; break;
case XK_KP_4 : KeyData.Key.UnicodeChar = L'4'; break; case XK_KP_2: KeyData.Key.UnicodeChar = L'2';
case XK_KP_5 : KeyData.Key.UnicodeChar = L'5'; break; break;
case XK_KP_6 : KeyData.Key.UnicodeChar = L'6'; break; case XK_KP_3: KeyData.Key.UnicodeChar = L'3';
case XK_KP_7 : KeyData.Key.UnicodeChar = L'7'; break; break;
case XK_KP_8 : KeyData.Key.UnicodeChar = L'8'; break; case XK_KP_4: KeyData.Key.UnicodeChar = L'4';
case XK_KP_9 : KeyData.Key.UnicodeChar = L'9'; break; 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: default:
; ;
@ -446,8 +523,8 @@ handleKeyEvent (
if (*KeySym < XK_BackSpace) { if (*KeySym < XK_BackSpace) {
if (((Drv->KeyState.KeyShiftState & (EFI_LEFT_SHIFT_PRESSED | EFI_RIGHT_SHIFT_PRESSED)) != 0) || 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]; KeyData.Key.UnicodeChar = (CHAR16)KeySym[KEYSYM_UPPER];
// Per UEFI spec since we converted the Unicode clear the shift bits we pass up // Per UEFI spec since we converted the Unicode clear the shift bits we pass up
@ -457,7 +534,6 @@ handleKeyEvent (
} }
} else { } else {
// XK_BackSpace is the start of XK_MISCELLANY. These are the XK_? keys we process in this file // XK_BackSpace is the start of XK_MISCELLANY. These are the XK_? keys we process in this file
;
} }
if (Make) { if (Make) {
@ -465,30 +541,29 @@ handleKeyEvent (
Drv->key_wr = (Drv->key_wr + 1) % NBR_KEYS; Drv->key_wr = (Drv->key_wr + 1) % NBR_KEYS;
Drv->key_count++; Drv->key_count++;
if (Drv->MakeRegisterdKeyCallback != NULL) { if (Drv->MakeRegisterdKeyCallback != NULL) {
ReverseGasketUint64Uint64 (Drv->MakeRegisterdKeyCallback ,Drv->RegisterdKeyCallbackContext, &KeyData); ReverseGasketUint64Uint64 (Drv->MakeRegisterdKeyCallback, Drv->RegisterdKeyCallbackContext, &KeyData);
} }
} else { } else {
if (Drv->BreakRegisterdKeyCallback != NULL) { if (Drv->BreakRegisterdKeyCallback != NULL) {
ReverseGasketUint64Uint64 (Drv->BreakRegisterdKeyCallback ,Drv->RegisterdKeyCallbackContext, &KeyData); ReverseGasketUint64Uint64 (Drv->BreakRegisterdKeyCallback, Drv->RegisterdKeyCallbackContext, &KeyData);
} }
} }
} }
void void
handleMouseMoved( handleMouseMoved (
IN GRAPHICS_IO_PRIVATE *Drv, IN GRAPHICS_IO_PRIVATE *Drv,
IN XEvent *ev IN XEvent *ev
) )
{ {
if (ev->xmotion.x != Drv->previous_x) { if (ev->xmotion.x != Drv->previous_x) {
Drv->pointer_state.RelativeMovementX += ( ev->xmotion.x - Drv->previous_x ); Drv->pointer_state.RelativeMovementX += (ev->xmotion.x - Drv->previous_x);
Drv->previous_x = ev->xmotion.x; Drv->previous_x = ev->xmotion.x;
Drv->pointer_state_changed = 1; Drv->pointer_state_changed = 1;
} }
if (ev->xmotion.y != Drv->previous_y) { if (ev->xmotion.y != Drv->previous_y) {
Drv->pointer_state.RelativeMovementY += ( ev->xmotion.y - Drv->previous_y ); Drv->pointer_state.RelativeMovementY += (ev->xmotion.y - Drv->previous_y);
Drv->previous_y = ev->xmotion.y; Drv->previous_y = ev->xmotion.y;
Drv->pointer_state_changed = 1; Drv->pointer_state_changed = 1;
} }
@ -507,6 +582,7 @@ handleMouseDown (
Drv->pointer_state_changed = (Drv->pointer_state.LeftButton != Pressed); Drv->pointer_state_changed = (Drv->pointer_state.LeftButton != Pressed);
Drv->pointer_state.LeftButton = Pressed; Drv->pointer_state.LeftButton = Pressed;
} }
if ( ev->xbutton.button == Button2 ) { 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; Drv->pointer_state.RightButton = Pressed;
@ -524,27 +600,60 @@ Redraw (
{ {
if (Drv->use_shm) { if (Drv->use_shm) {
XShmPutImage ( 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 { } else {
XPutImage ( 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 void
HandleEvent(GRAPHICS_IO_PRIVATE *Drv, XEvent *ev) HandleEvent (
GRAPHICS_IO_PRIVATE *Drv,
XEvent *ev
)
{ {
switch (ev->type) { switch (ev->type) {
case Expose: case Expose:
Redraw (Drv, ev->xexpose.x, ev->xexpose.y, Redraw (
ev->xexpose.width, ev->xexpose.height); Drv,
ev->xexpose.x,
ev->xexpose.y,
ev->xexpose.width,
ev->xexpose.height
);
break; break;
case GraphicsExpose: case GraphicsExpose:
Redraw (Drv, ev->xgraphicsexpose.x, ev->xgraphicsexpose.y, Redraw (
ev->xgraphicsexpose.width, ev->xgraphicsexpose.height); Drv,
ev->xgraphicsexpose.x,
ev->xgraphicsexpose.y,
ev->xgraphicsexpose.width,
ev->xgraphicsexpose.height
);
break; break;
case KeyPress: case KeyPress:
handleKeyEvent (Drv, ev, TRUE); handleKeyEvent (Drv, ev, TRUE);
@ -564,12 +673,12 @@ HandleEvent(GRAPHICS_IO_PRIVATE *Drv, XEvent *ev)
case ButtonRelease: case ButtonRelease:
handleMouseDown (Drv, ev, FALSE); handleMouseDown (Drv, ev, FALSE);
break; break;
#if 0 #if 0
case DestroyNotify: case DestroyNotify:
XCloseDisplay (Drv->display); XCloseDisplay (Drv->display);
exit (1); exit (1);
break; break;
#endif #endif
case NoExpose: case NoExpose:
default: default:
break; break;
@ -618,7 +727,6 @@ X11ColorToPixel (
return Pixel; return Pixel;
} }
EFI_STATUS EFI_STATUS
X11CheckKey ( X11CheckKey (
IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo
@ -660,7 +768,6 @@ X11GetKey (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EFI_STATUS EFI_STATUS
X11KeySetState ( X11KeySetState (
IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo, IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo,
@ -684,7 +791,6 @@ X11KeySetState (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EFI_STATUS EFI_STATUS
X11RegisterKeyNotify ( X11RegisterKeyNotify (
IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo, IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo,
@ -704,7 +810,6 @@ X11RegisterKeyNotify (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EFI_STATUS EFI_STATUS
X11Blt ( X11Blt (
IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo, IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo,
@ -728,12 +833,12 @@ X11Blt (
Private = (GRAPHICS_IO_PRIVATE *)GraphicsIo; Private = (GRAPHICS_IO_PRIVATE *)GraphicsIo;
// //
// Check bounds // Check bounds
// //
if (BltOperation == EfiUgaVideoToBltBuffer if ( (BltOperation == EfiUgaVideoToBltBuffer)
|| BltOperation == EfiUgaVideoToVideo) { || (BltOperation == EfiUgaVideoToVideo))
{
// //
// Source is Video. // Source is Video.
// //
@ -746,9 +851,10 @@ X11Blt (
} }
} }
if (BltOperation == EfiUgaBltBufferToVideo if ( (BltOperation == EfiUgaBltBufferToVideo)
|| BltOperation == EfiUgaVideoToVideo || (BltOperation == EfiUgaVideoToVideo)
|| BltOperation == EfiUgaVideoFill) { || (BltOperation == EfiUgaVideoFill))
{
// //
// Destination is Video // Destination is Video
// //
@ -769,19 +875,23 @@ X11Blt (
for (SrcX = Args->SourceX; SrcX < (Args->Width + Args->SourceX); SrcX++) { for (SrcX = Args->SourceX; SrcX < (Args->Width + Args->SourceX); SrcX++) {
*Blt++ = X11ColorToPixel (Private, XGetPixel (Private->image, SrcX, SrcY)); *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; break;
case EfiUgaBltBufferToVideo: case EfiUgaBltBufferToVideo:
Blt = (EFI_UGA_PIXEL *)((UINT8 *)BltBuffer + (Args->SourceY * Args->Delta) + Args->SourceX * sizeof (EFI_UGA_PIXEL)); Blt = (EFI_UGA_PIXEL *)((UINT8 *)BltBuffer + (Args->SourceY * Args->Delta) + Args->SourceX * sizeof (EFI_UGA_PIXEL));
Args->Delta -= Args->Width * sizeof (EFI_UGA_PIXEL); Args->Delta -= Args->Width * sizeof (EFI_UGA_PIXEL);
for (DstY = Args->DestinationY; DstY < (Args->Height + Args->DestinationY); DstY++) { for (DstY = Args->DestinationY; DstY < (Args->Height + Args->DestinationY); DstY++) {
for (DstX = Args->DestinationX; DstX < (Args->Width + Args->DestinationX); DstX++) { for (DstX = Args->DestinationX; DstX < (Args->Width + Args->DestinationX); DstX++) {
XPutPixel(Private->image, DstX, DstY, X11PixelToColor(Private, *Blt)); XPutPixel (Private->image, DstX, DstY, X11PixelToColor (Private, *Blt));
Blt++; Blt++;
} }
Blt = (EFI_UGA_PIXEL *) ((UINT8 *) Blt + Args->Delta);
Blt = (EFI_UGA_PIXEL *)((UINT8 *)Blt + Args->Delta);
} }
break; break;
case EfiUgaVideoToVideo: case EfiUgaVideoToVideo:
Dst = Private->image_data + (Args->DestinationX << Private->pixel_shift) Dst = Private->image_data + (Args->DestinationX << Private->pixel_shift)
@ -808,14 +918,16 @@ X11Blt (
Src -= Private->line_bytes; Src -= Private->line_bytes;
} }
} }
break; break;
case EfiUgaVideoFill: case EfiUgaVideoFill:
Color = X11PixelToColor(Private, *BltBuffer); Color = X11PixelToColor (Private, *BltBuffer);
for (DstY = Args->DestinationY; DstY < (Args->Height + Args->DestinationY); DstY++) { for (DstY = Args->DestinationY; DstY < (Args->Height + Args->DestinationY); DstY++) {
for (DstX = Args->DestinationX; DstX < (Args->Width + Args->DestinationX); DstX++) { for (DstX = Args->DestinationX; DstX < (Args->Width + Args->DestinationX); DstX++) {
XPutPixel(Private->image, DstX, DstY, Color); XPutPixel (Private->image, DstX, DstY, Color);
} }
} }
break; break;
default: default:
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
@ -826,26 +938,39 @@ X11Blt (
// //
switch (BltOperation) { switch (BltOperation) {
case EfiUgaVideoToVideo: case EfiUgaVideoToVideo:
XCopyArea( XCopyArea (
Private->display, Private->win, Private->win, Private->gc, Private->display,
Args->SourceX, Args->SourceY, Args->Width, Args->Height, Private->win,
Args->DestinationX, Args->DestinationY Private->win,
Private->gc,
Args->SourceX,
Args->SourceY,
Args->Width,
Args->Height,
Args->DestinationX,
Args->DestinationY
); );
while (1) { while (1) {
XNextEvent (Private->display, &ev); XNextEvent (Private->display, &ev);
HandleEvent (Private, &ev); HandleEvent (Private, &ev);
if (ev.type == NoExpose || ev.type == GraphicsExpose) { if ((ev.type == NoExpose) || (ev.type == GraphicsExpose)) {
break; break;
} }
} }
break; break;
case EfiUgaVideoFill: case EfiUgaVideoFill:
Color = X11PixelToColor (Private, *BltBuffer); Color = X11PixelToColor (Private, *BltBuffer);
XSetForeground (Private->display, Private->gc, Color); XSetForeground (Private->display, Private->gc, Color);
XFillRectangle ( XFillRectangle (
Private->display, Private->win, Private->gc, Private->display,
Args->DestinationX, Args->DestinationY, Args->Width, Args->Height Private->win,
Private->gc,
Args->DestinationX,
Args->DestinationY,
Args->Width,
Args->Height
); );
XFlush (Private->display); XFlush (Private->display);
break; break;
@ -855,10 +980,10 @@ X11Blt (
default: default:
break; break;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EFI_STATUS EFI_STATUS
X11CheckPointer ( X11CheckPointer (
IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo
@ -876,7 +1001,6 @@ X11CheckPointer (
return EFI_NOT_READY; return EFI_NOT_READY;
} }
EFI_STATUS EFI_STATUS
X11GetPointerState ( X11GetPointerState (
IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo, IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo,
@ -902,8 +1026,6 @@ X11GetPointerState (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EFI_STATUS EFI_STATUS
X11GraphicsWindowOpen ( X11GraphicsWindowOpen (
IN EMU_IO_THUNK_PROTOCOL *This IN EMU_IO_THUNK_PROTOCOL *This
@ -927,7 +1049,6 @@ X11GraphicsWindowOpen (
Drv->GraphicsIo.CheckPointer = GasketX11CheckPointer; Drv->GraphicsIo.CheckPointer = GasketX11CheckPointer;
Drv->GraphicsIo.GetPointerState = GasketX11GetPointerState; Drv->GraphicsIo.GetPointerState = GasketX11GetPointerState;
Drv->key_count = 0; Drv->key_count = 0;
Drv->key_rd = 0; Drv->key_rd = 0;
Drv->key_wr = 0; Drv->key_wr = 0;
@ -937,18 +1058,23 @@ X11GraphicsWindowOpen (
Drv->BreakRegisterdKeyCallback = NULL; Drv->BreakRegisterdKeyCallback = NULL;
Drv->RegisterdKeyCallbackContext = NULL; Drv->RegisterdKeyCallbackContext = NULL;
Drv->display = XOpenDisplay (display_name); Drv->display = XOpenDisplay (display_name);
if (Drv->display == NULL) { if (Drv->display == NULL) {
fprintf (stderr, "uga: cannot connect to X server %s\n", XDisplayName (display_name)); fprintf (stderr, "uga: cannot connect to X server %s\n", XDisplayName (display_name));
free (Drv); free (Drv);
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
Drv->screen = DefaultScreen (Drv->display); Drv->screen = DefaultScreen (Drv->display);
Drv->visual = DefaultVisual (Drv->display, Drv->screen); Drv->visual = DefaultVisual (Drv->display, Drv->screen);
Drv->win = XCreateSimpleWindow ( Drv->win = XCreateSimpleWindow (
Drv->display, RootWindow (Drv->display, Drv->screen), Drv->display,
0, 0, 4, 4, border_width, RootWindow (Drv->display, Drv->screen),
0,
0,
4,
4,
border_width,
WhitePixel (Drv->display, Drv->screen), WhitePixel (Drv->display, Drv->screen),
BlackPixel (Drv->display, Drv->screen) BlackPixel (Drv->display, Drv->screen)
); );
@ -960,9 +1086,10 @@ X11GraphicsWindowOpen (
UnicodeStrToAsciiStrS (This->ConfigString, Drv->Title, StrSize (This->ConfigString)); UnicodeStrToAsciiStrS (This->ConfigString, Drv->Title, StrSize (This->ConfigString));
XStoreName (Drv->display, Drv->win, Drv->Title); XStoreName (Drv->display, Drv->win, Drv->Title);
// XAutoRepeatOff (Drv->display); // XAutoRepeatOff (Drv->display);
XSelectInput ( XSelectInput (
Drv->display, Drv->win, Drv->display,
Drv->win,
ExposureMask | KeyPressMask | KeyReleaseMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask ExposureMask | KeyPressMask | KeyReleaseMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask
); );
Drv->gc = DefaultGC (Drv->display, Drv->screen); Drv->gc = DefaultGC (Drv->display, Drv->screen);
@ -972,7 +1099,6 @@ X11GraphicsWindowOpen (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EFI_STATUS EFI_STATUS
X11GraphicsWindowClose ( X11GraphicsWindowClose (
IN EMU_IO_THUNK_PROTOCOL *This IN EMU_IO_THUNK_PROTOCOL *This
@ -987,7 +1113,7 @@ X11GraphicsWindowClose (
} }
if (Drv->image != NULL) { if (Drv->image != NULL) {
XDestroyImage(Drv->image); XDestroyImage (Drv->image);
if (Drv->use_shm) { if (Drv->use_shm) {
shmdt (Drv->image_data); shmdt (Drv->image_data);
@ -996,19 +1122,19 @@ X11GraphicsWindowClose (
Drv->image_data = NULL; Drv->image_data = NULL;
Drv->image = NULL; Drv->image = NULL;
} }
XDestroyWindow (Drv->display, Drv->win); XDestroyWindow (Drv->display, Drv->win);
XCloseDisplay (Drv->display); XCloseDisplay (Drv->display);
#ifdef __APPLE__ #ifdef __APPLE__
// Free up the shared memory // Free up the shared memory
shmctl (Drv->xshm_info.shmid, IPC_RMID, NULL); shmctl (Drv->xshm_info.shmid, IPC_RMID, NULL);
#endif #endif
free (Drv); free (Drv);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EMU_IO_THUNK_PROTOCOL gX11ThunkIo = { EMU_IO_THUNK_PROTOCOL gX11ThunkIo = {
&gEmuGraphicsWindowProtocolGuid, &gEmuGraphicsWindowProtocolGuid,
NULL, NULL,
@ -1018,5 +1144,3 @@ EMU_IO_THUNK_PROTOCOL gX11ThunkIo = {
GasketX11GraphicsWindowClose, GasketX11GraphicsWindowClose,
NULL NULL
}; };

View File

@ -27,23 +27,20 @@ typedef struct {
#define WIN_NT_BLOCK_IO_PRIVATE_DATA_FROM_THIS(a) \ #define WIN_NT_BLOCK_IO_PRIVATE_DATA_FROM_THIS(a) \
CR(a, WIN_NT_BLOCK_IO_PRIVATE, EmuBlockIo, WIN_NT_BLOCK_IO_PRIVATE_SIGNATURE) CR(a, WIN_NT_BLOCK_IO_PRIVATE, EmuBlockIo, WIN_NT_BLOCK_IO_PRIVATE_SIGNATURE)
EFI_STATUS EFI_STATUS
WinNtBlockIoReset ( WinNtBlockIoReset (
IN EMU_BLOCK_IO_PROTOCOL *This, IN EMU_BLOCK_IO_PROTOCOL *This,
IN BOOLEAN ExtendedVerification IN BOOLEAN ExtendedVerification
); );
EFI_STATUS EFI_STATUS
SetFilePointer64 ( SetFilePointer64 (
IN WIN_NT_BLOCK_IO_PRIVATE *Private, IN WIN_NT_BLOCK_IO_PRIVATE *Private,
IN INT64 DistanceToMove, IN INT64 DistanceToMove,
OUT UINT64 *NewFilePointer, OUT UINT64 *NewFilePointer,
IN DWORD MoveMethod IN DWORD MoveMethod
) )
/*++ /*++
This function extends the capability of SetFilePointer to accept 64 bit parameters This function extends the capability of SetFilePointer to accept 64 bit parameters
@ -63,7 +60,7 @@ This function extends the capability of SetFilePointer to accept 64 bit paramete
MoveMethod MoveMethod
); );
if (LargeInt.LowPart == -1 && GetLastError () != NO_ERROR) { if ((LargeInt.LowPart == -1) && (GetLastError () != NO_ERROR)) {
Status = EFI_INVALID_PARAMETER; Status = EFI_INVALID_PARAMETER;
} }
@ -74,8 +71,6 @@ This function extends the capability of SetFilePointer to accept 64 bit paramete
return Status; return Status;
} }
EFI_STATUS EFI_STATUS
WinNtBlockIoOpenDevice ( WinNtBlockIoOpenDevice (
IN WIN_NT_BLOCK_IO_PRIVATE *Private, IN WIN_NT_BLOCK_IO_PRIVATE *Private,
@ -138,7 +133,6 @@ Done:
return Status; return Status;
} }
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
WinNtBlockIoCreateMapping ( WinNtBlockIoCreateMapping (
@ -164,7 +158,6 @@ WinNtBlockIoCreateMapping (
Media->LowestAlignedLba = 0; Media->LowestAlignedLba = 0;
Media->LogicalBlocksPerPhysicalBlock = 0; Media->LogicalBlocksPerPhysicalBlock = 0;
// EFI_BLOCK_IO_PROTOCOL_REVISION3 // EFI_BLOCK_IO_PROTOCOL_REVISION3
Media->OptimalTransferLengthGranularity = 0; Media->OptimalTransferLengthGranularity = 0;
@ -175,12 +168,11 @@ WinNtBlockIoCreateMapping (
return WinNtBlockIoOpenDevice (Private, Media); return WinNtBlockIoOpenDevice (Private, Media);
} }
EFI_STATUS EFI_STATUS
WinNtBlockIoError ( WinNtBlockIoError (
IN WIN_NT_BLOCK_IO_PRIVATE *Private IN WIN_NT_BLOCK_IO_PRIVATE *Private
) )
/*++ /*++
Routine Description: Routine Description:
@ -203,7 +195,6 @@ Returns:
Media = Private->Media; Media = Private->Media;
switch (GetLastError ()) { switch (GetLastError ()) {
case ERROR_NOT_READY: case ERROR_NOT_READY:
Media->ReadOnly = FALSE; Media->ReadOnly = FALSE;
Media->MediaPresent = FALSE; Media->MediaPresent = FALSE;
@ -227,19 +218,18 @@ Returns:
break; break;
} }
if (Status == EFI_NO_MEDIA || Status == EFI_MEDIA_CHANGED) { if ((Status == EFI_NO_MEDIA) || (Status == EFI_MEDIA_CHANGED)) {
WinNtBlockIoReset (&Private->EmuBlockIo, FALSE); WinNtBlockIoReset (&Private->EmuBlockIo, FALSE);
} }
return Status; return Status;
} }
EFI_STATUS EFI_STATUS
WinNtSignalToken ( WinNtSignalToken (
IN OUT EFI_BLOCK_IO2_TOKEN *Token, IN OUT EFI_BLOCK_IO2_TOKEN *Token,
IN EFI_STATUS Status IN EFI_STATUS Status
) )
{ {
if (Token != NULL) { if (Token != NULL) {
if (Token->Event != NULL) { if (Token->Event != NULL) {
@ -248,6 +238,7 @@ WinNtSignalToken (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
} }
return Status; return Status;
} }
@ -323,7 +314,6 @@ WinNtBlockIoReadBlocks (
return WinNtSignalToken (Token, EFI_SUCCESS); return WinNtSignalToken (Token, EFI_SUCCESS);
} }
/** /**
Write BufferSize bytes from Lba into Buffer. Write BufferSize bytes from Lba into Buffer.
@ -429,7 +419,6 @@ WinNtBlockIoFlushBlocks (
return WinNtSignalToken (Token, EFI_SUCCESS); return WinNtSignalToken (Token, EFI_SUCCESS);
} }
/** /**
Reset the block device hardware. Reset the block device hardware.
@ -493,6 +482,7 @@ WinNtBlockIoThunkOpen (
if (Private->FileName == NULL) { if (Private->FileName == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
// //
// Parse ConfigString // Parse ConfigString
// <ConfigString> := <FileName> ':' [RF][OW] ':' <BlockSize> // <ConfigString> := <FileName> ':' [RF][OW] ':' <BlockSize>
@ -503,12 +493,14 @@ WinNtBlockIoThunkOpen (
Private->Readonly = FALSE; Private->Readonly = FALSE;
} else { } else {
for (*Str++ = L'\0'; *Str != L'\0'; Str++) { for (*Str++ = L'\0'; *Str != L'\0'; Str++) {
if (*Str == 'R' || *Str == 'F') { if ((*Str == 'R') || (*Str == 'F')) {
Private->Removable = (BOOLEAN) (*Str == L'R'); 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 == ':') { if (*Str == ':') {
Private->BlockSize = wcstol (++Str, NULL, 0); Private->BlockSize = wcstol (++Str, NULL, 0);
break; break;
@ -521,7 +513,6 @@ WinNtBlockIoThunkOpen (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
WinNtBlockIoThunkClose ( WinNtBlockIoThunkClose (
@ -536,14 +527,13 @@ WinNtBlockIoThunkClose (
if (Private->FileName != NULL) { if (Private->FileName != NULL) {
FreePool (Private->FileName); FreePool (Private->FileName);
} }
FreePool (Private); FreePool (Private);
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EMU_IO_THUNK_PROTOCOL mWinNtBlockIoThunkIo = { EMU_IO_THUNK_PROTOCOL mWinNtBlockIoThunkIo = {
&gEmuBlockIoProtocolGuid, &gEmuBlockIoProtocolGuid,
NULL, NULL,

View File

@ -9,7 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "WinHost.h" #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 { typedef struct {
@ -27,7 +26,6 @@ typedef struct {
WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE \ 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 { typedef struct {
@ -72,13 +70,12 @@ WinNtFileSetInfo (
IN VOID *Buffer IN VOID *Buffer
); );
CHAR16 * CHAR16 *
EfiStrChr ( EfiStrChr (
IN CHAR16 *Str, IN CHAR16 *Str,
IN CHAR16 Chr IN CHAR16 Chr
) )
/*++ /*++
Routine Description: Routine Description:
@ -109,24 +106,22 @@ Returns:
return (*Str == Chr) ? Str : NULL; return (*Str == Chr) ? Str : NULL;
} }
BOOLEAN BOOLEAN
IsZero ( IsZero (
IN VOID *Buffer, IN VOID *Buffer,
IN UINTN Length IN UINTN Length
) )
{ {
if (Buffer == NULL || Length == 0) { if ((Buffer == NULL) || (Length == 0)) {
return FALSE; return FALSE;
} }
if (*(UINT8 *) Buffer != 0) { if (*(UINT8 *)Buffer != 0) {
return FALSE; return FALSE;
} }
if (Length > 1) { if (Length > 1) {
if (!CompareMem (Buffer, (UINT8 *) Buffer + 1, Length - 1)) { if (!CompareMem (Buffer, (UINT8 *)Buffer + 1, Length - 1)) {
return FALSE; return FALSE;
} }
} }
@ -154,6 +149,7 @@ CutPrefix (
*Pointer = *(Pointer + Count); *Pointer = *(Pointer + Count);
} }
} }
/** /**
Open the root directory on a volume. Open the root directory on a volume.
@ -181,7 +177,7 @@ WinNtOpenVolume (
CHAR16 *TempFileName; CHAR16 *TempFileName;
UINTN Size; UINTN Size;
if (This == NULL || Root == NULL) { if ((This == NULL) || (Root == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -205,11 +201,13 @@ WinNtOpenVolume (
goto Done; goto Done;
} }
StrCpyS (PrivateFile->FilePath, StrCpyS (
PrivateFile->FilePath,
StrSize (Private->FilePath) / sizeof (CHAR16), StrSize (Private->FilePath) / sizeof (CHAR16),
Private->FilePath Private->FilePath
); );
StrCpyS (PrivateFile->FileName, StrCpyS (
PrivateFile->FileName,
StrSize (Private->FilePath) / sizeof (CHAR16), StrSize (Private->FilePath) / sizeof (CHAR16),
PrivateFile->FilePath PrivateFile->FilePath
); );
@ -249,6 +247,7 @@ WinNtOpenVolume (
if (TempFileName == NULL) { if (TempFileName == NULL) {
goto Done; goto Done;
} }
StrCpyS (TempFileName, Size / sizeof (CHAR16), PrivateFile->FilePath); StrCpyS (TempFileName, Size / sizeof (CHAR16), PrivateFile->FilePath);
StrCatS (TempFileName, Size / sizeof (CHAR16), L"\\*"); StrCatS (TempFileName, Size / sizeof (CHAR16), L"\\*");
@ -260,6 +259,7 @@ WinNtOpenVolume (
} else { } else {
PrivateFile->IsValidFindBuf = TRUE; PrivateFile->IsValidFindBuf = TRUE;
} }
*Root = &PrivateFile->EfiFile; *Root = &PrivateFile->EfiFile;
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
@ -292,8 +292,8 @@ Done:
**/ **/
UINTN UINTN
CountLeadingDots ( CountLeadingDots (
IN CONST CHAR16 * FileNameToken IN CONST CHAR16 *FileNameToken
) )
{ {
UINTN Num; UINTN Num;
@ -306,13 +306,13 @@ CountLeadingDots (
return Num; return Num;
} }
BOOLEAN BOOLEAN
IsFileNameTokenValid ( IsFileNameTokenValid (
IN CONST CHAR16 * FileNameToken IN CONST CHAR16 *FileNameToken
) )
{ {
UINTN Num; UINTN Num;
if (StrStr (FileNameToken, L"/") != NULL) { if (StrStr (FileNameToken, L"/") != NULL) {
// //
// No L'/' in file name. // No L'/' in file name.
@ -337,7 +337,6 @@ IsFileNameTokenValid (
return TRUE; return TRUE;
} }
/** /**
Return the first string token found in the indirect pointer a String named by FileName. Return the first string token found in the indirect pointer a String named by FileName.
@ -352,12 +351,13 @@ IsFileNameTokenValid (
**/ **/
CHAR16 * CHAR16 *
GetNextFileNameToken ( GetNextFileNameToken (
IN OUT CONST CHAR16 ** FileName IN OUT CONST CHAR16 **FileName
) )
{ {
CHAR16 *SlashPos; CHAR16 *SlashPos;
CHAR16 *Token; CHAR16 *Token;
UINTN Offset; UINTN Offset;
ASSERT (**FileName != L'\\'); ASSERT (**FileName != L'\\');
ASSERT (**FileName != L'\0'); ASSERT (**FileName != L'\0');
@ -384,7 +384,6 @@ GetNextFileNameToken (
return Token; return Token;
} }
/** /**
Check if a FileName contains only Valid Characters. Check if a FileName contains only Valid Characters.
@ -400,7 +399,6 @@ GetNextFileNameToken (
@return FALSE FileName contains at least one invalid character. @return FALSE FileName contains at least one invalid character.
**/ **/
BOOLEAN BOOLEAN
IsFileNameValid ( IsFileNameValid (
IN CONST CHAR16 *FileName IN CONST CHAR16 *FileName
@ -415,6 +413,7 @@ IsFileNameValid (
if (StrCmp (FileName, L"\\") == 0) { if (StrCmp (FileName, L"\\") == 0) {
return TRUE; return TRUE;
} }
// //
// We don't support two or more adjacent L'\'. // We don't support two or more adjacent L'\'.
// //
@ -425,7 +424,7 @@ IsFileNameValid (
// //
// Is FileName has a leading L"\", skip to next character. // Is FileName has a leading L"\", skip to next character.
// //
if (FileName [0] == L'\\') { if (FileName[0] == L'\\') {
FileName++; FileName++;
} }
@ -434,14 +433,14 @@ IsFileNameValid (
Valid = IsFileNameTokenValid (Token); Valid = IsFileNameTokenValid (Token);
FreePool (Token); FreePool (Token);
if (!Valid) if (!Valid) {
return FALSE; return FALSE;
}
} while (FileName != NULL); } while (FileName != NULL);
return TRUE; return TRUE;
} }
/** /**
Opens a new file relative to the source file's location. Opens a new file relative to the source file's location.
@ -487,7 +486,6 @@ WinNtFileOpen (
EFI_FILE_INFO *Info; EFI_FILE_INFO *Info;
UINTN Size; UINTN Size;
// //
// Init local variables // Init local variables
// //
@ -502,6 +500,7 @@ WinNtFileOpen (
if (TempFileName == NULL) { if (TempFileName == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
StrCpyS (TempFileName, StrSize (FileName) / sizeof (CHAR16), FileName); StrCpyS (TempFileName, StrSize (FileName) / sizeof (CHAR16), FileName);
FileName = TempFileName; FileName = TempFileName;
@ -513,26 +512,30 @@ WinNtFileOpen (
// If file name does not equal to "." or ".." and not trailed with "\..", // If file name does not equal to "." or ".." and not trailed with "\..",
// then we trim the leading/trailing blanks and trailing dots // then we trim the leading/trailing blanks and trailing dots
// //
if (StrCmp (FileName, L".") != 0 && StrCmp (FileName, L"..") != 0 && if ((StrCmp (FileName, L".") != 0) && (StrCmp (FileName, L"..") != 0) &&
((StrLen (FileName) >= 3) ? (StrCmp (&FileName[StrLen (FileName) - 3], L"\\..") != 0) : TRUE)) { ((StrLen (FileName) >= 3) ? (StrCmp (&FileName[StrLen (FileName) - 3], L"\\..") != 0) : TRUE))
{
// //
// Trim leading blanks // Trim leading blanks
// //
Count = 0; Count = 0;
for (TempFileName = FileName; for (TempFileName = FileName;
*TempFileName != 0 && *TempFileName == L' '; *TempFileName != 0 && *TempFileName == L' ';
TempFileName++) { TempFileName++)
{
Count++; Count++;
} }
CutPrefix (FileName, Count); CutPrefix (FileName, Count);
// //
// Trim trailing blanks // Trim trailing blanks
// //
for (TempFileName = FileName + StrLen (FileName) - 1; for (TempFileName = FileName + StrLen (FileName) - 1;
TempFileName >= FileName && (*TempFileName == L' '); TempFileName >= FileName && (*TempFileName == L' ');
TempFileName--) { TempFileName--)
; {
} }
*(TempFileName + 1) = 0; *(TempFileName + 1) = 0;
} }
@ -608,15 +611,14 @@ WinNtFileOpen (
LoopFinish = FALSE; LoopFinish = FALSE;
while (!LoopFinish) { while (!LoopFinish) {
LoopFinish = TRUE; LoopFinish = TRUE;
for (ParseFileName = GuardPointer; *ParseFileName; ParseFileName++) { for (ParseFileName = GuardPointer; *ParseFileName; ParseFileName++) {
if (*ParseFileName == L'.' && if ((*ParseFileName == L'.') &&
(*(ParseFileName + 1) == 0 || *(ParseFileName + 1) == L'\\') && ((*(ParseFileName + 1) == 0) || (*(ParseFileName + 1) == L'\\')) &&
*(ParseFileName - 1) == L'\\' (*(ParseFileName - 1) == L'\\')
) { )
{
// //
// cut \. // cut \.
// //
@ -625,12 +627,12 @@ WinNtFileOpen (
break; break;
} }
if (*ParseFileName == L'.' && if ((*ParseFileName == L'.') &&
*(ParseFileName + 1) == L'.' && (*(ParseFileName + 1) == L'.') &&
(*(ParseFileName + 2) == 0 || *(ParseFileName + 2) == L'\\') && ((*(ParseFileName + 2) == 0) || (*(ParseFileName + 2) == L'\\')) &&
*(ParseFileName - 1) == L'\\' (*(ParseFileName - 1) == L'\\')
) { )
{
ParseFileName--; ParseFileName--;
Count = 3; Count = 3;
@ -724,7 +726,6 @@ WinNtFileOpen (
// deal with directory // deal with directory
// //
if (NewPrivateFile->IsDirectoryPath) { if (NewPrivateFile->IsDirectoryPath) {
Size = StrSize (NewPrivateFile->FileName); Size = StrSize (NewPrivateFile->FileName);
Size += StrSize (L"\\*"); Size += StrSize (L"\\*");
TempFileName = AllocatePool (Size); TempFileName = AllocatePool (Size);
@ -740,7 +741,6 @@ WinNtFileOpen (
// Create a directory // Create a directory
// //
if (!CreateDirectory (TempFileName, NULL)) { if (!CreateDirectory (TempFileName, NULL)) {
LastError = GetLastError (); LastError = GetLastError ();
if (LastError != ERROR_ALREADY_EXISTS) { if (LastError != ERROR_ALREADY_EXISTS) {
FreePool (TempFileName); FreePool (TempFileName);
@ -761,7 +761,6 @@ WinNtFileOpen (
); );
if (NewPrivateFile->DirHandle == INVALID_HANDLE_VALUE) { if (NewPrivateFile->DirHandle == INVALID_HANDLE_VALUE) {
NewPrivateFile->DirHandle = CreateFile ( NewPrivateFile->DirHandle = CreateFile (
TempFileName, TempFileName,
GENERIC_READ, GENERIC_READ,
@ -847,7 +846,7 @@ WinNtFileOpen (
} }
} }
if ((OpenMode & EFI_FILE_MODE_CREATE) && Status == EFI_SUCCESS) { if ((OpenMode & EFI_FILE_MODE_CREATE) && (Status == EFI_SUCCESS)) {
// //
// Set the attribute // Set the attribute
// //
@ -905,8 +904,6 @@ Done:
return Status; return Status;
} }
/** /**
Close the file handle Close the file handle
@ -934,7 +931,7 @@ WinNtFileClose (
PrivateFile->LHandle = INVALID_HANDLE_VALUE; PrivateFile->LHandle = INVALID_HANDLE_VALUE;
} }
if (PrivateFile->IsDirectoryPath && PrivateFile->DirHandle != INVALID_HANDLE_VALUE) { if (PrivateFile->IsDirectoryPath && (PrivateFile->DirHandle != INVALID_HANDLE_VALUE)) {
CloseHandle (PrivateFile->DirHandle); CloseHandle (PrivateFile->DirHandle);
PrivateFile->DirHandle = INVALID_HANDLE_VALUE; PrivateFile->DirHandle = INVALID_HANDLE_VALUE;
} }
@ -950,10 +947,8 @@ WinNtFileClose (
FreePool (PrivateFile); FreePool (PrivateFile);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Close and delete the file handle. Close and delete the file handle.
@ -1011,7 +1006,8 @@ WinNtSystemTimeToEfiTime (
IN SYSTEMTIME *SystemTime, IN SYSTEMTIME *SystemTime,
IN TIME_ZONE_INFORMATION *TimeZone, IN TIME_ZONE_INFORMATION *TimeZone,
OUT EFI_TIME *Time OUT EFI_TIME *Time
) )
/*++ /*++
Routine Description: Routine Description:
@ -1058,7 +1054,7 @@ WinNtFileTimeToEfiTime (
IN TIME_ZONE_INFORMATION *TimeZone, IN TIME_ZONE_INFORMATION *TimeZone,
IN CONST FILETIME *FileTime, IN CONST FILETIME *FileTime,
OUT EFI_TIME *EfiTime OUT EFI_TIME *EfiTime
) )
{ {
FILETIME TempFileTime; FILETIME TempFileTime;
SYSTEMTIME SystemTime; SYSTEMTIME SystemTime;
@ -1068,7 +1064,6 @@ WinNtFileTimeToEfiTime (
WinNtSystemTimeToEfiTime (&SystemTime, TimeZone, EfiTime); WinNtSystemTimeToEfiTime (&SystemTime, TimeZone, EfiTime);
} }
/** /**
Read data from the file. Read data from the file.
@ -1112,7 +1107,6 @@ WinNtFileRead (
} }
if (!PrivateFile->IsDirectoryPath) { if (!PrivateFile->IsDirectoryPath) {
if (This->GetPosition (This, &Pos) != EFI_SUCCESS) { if (This->GetPosition (This, &Pos) != EFI_SUCCESS) {
Status = EFI_DEVICE_ERROR; Status = EFI_DEVICE_ERROR;
goto Done; goto Done;
@ -1244,8 +1238,6 @@ Done:
return Status; return Status;
} }
/** /**
Write data to a file. Write data to a file.
@ -1307,8 +1299,6 @@ Done:
// //
} }
/** /**
Set a files current position Set a files current position
@ -1382,8 +1372,6 @@ Done:
return Status; return Status;
} }
/** /**
Get a file's current position Get a file's current position
@ -1411,12 +1399,9 @@ WinNtFileGetPossition (
PosHigh64 = 0; PosHigh64 = 0;
if (PrivateFile->IsDirectoryPath) { if (PrivateFile->IsDirectoryPath) {
Status = EFI_UNSUPPORTED; Status = EFI_UNSUPPORTED;
goto Done; goto Done;
} else { } else {
PositionHigh = 0; PositionHigh = 0;
*Position = SetFilePointer ( *Position = SetFilePointer (
PrivateFile->LHandle, PrivateFile->LHandle,
@ -1438,13 +1423,13 @@ Done:
return Status; return Status;
} }
EFI_STATUS EFI_STATUS
WinNtSimpleFileSystemFileInfo ( WinNtSimpleFileSystemFileInfo (
IN WIN_NT_EFI_FILE_PRIVATE *PrivateFile, IN WIN_NT_EFI_FILE_PRIVATE *PrivateFile,
IN OUT UINTN *BufferSize, IN OUT UINTN *BufferSize,
OUT VOID *Buffer OUT VOID *Buffer
) )
/*++ /*++
Routine Description: Routine Description:
@ -1484,6 +1469,7 @@ Returns:
TempPointer++; TempPointer++;
} }
NameSize = StrSize (RealFileName); NameSize = StrSize (RealFileName);
ResultSize = Size + NameSize; ResultSize = Size + NameSize;
@ -1583,7 +1569,7 @@ WinNtFileGetInfo (
UINTN Index; UINTN Index;
WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE *PrivateRoot; WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE *PrivateRoot;
if (This == NULL || InformationType == NULL || BufferSize == NULL) { if ((This == NULL) || (InformationType == NULL) || (BufferSize == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -1623,22 +1609,19 @@ WinNtFileGetInfo (
PrivateFile->FilePath PrivateFile->FilePath
); );
for (Index = 0; DriveName[Index] != 0 && DriveName[Index] != ':'; Index++) { for (Index = 0; DriveName[Index] != 0 && DriveName[Index] != ':'; Index++) {
;
} }
if (DriveName[Index] == ':') { if (DriveName[Index] == ':') {
DriveName[Index + 1] = '\\'; DriveName[Index + 1] = '\\';
DriveName[Index + 2] = 0; DriveName[Index + 2] = 0;
DriveNameFound = TRUE; DriveNameFound = TRUE;
} else if (DriveName[0] == '\\' && DriveName[1] == '\\') { } else if ((DriveName[0] == '\\') && (DriveName[1] == '\\')) {
for (Index = 2; DriveName[Index] != 0 && DriveName[Index] != '\\'; Index++) { for (Index = 2; DriveName[Index] != 0 && DriveName[Index] != '\\'; Index++) {
;
} }
if (DriveName[Index] == '\\') { if (DriveName[Index] == '\\') {
DriveNameFound = TRUE; DriveNameFound = TRUE;
for (Index++; DriveName[Index] != 0 && DriveName[Index] != '\\'; Index++) { for (Index++; DriveName[Index] != 0 && DriveName[Index] != '\\'; Index++) {
;
} }
DriveName[Index] = '\\'; DriveName[Index] = '\\';
@ -1668,7 +1651,6 @@ WinNtFileGetInfo (
FileSystemInfoBuffer->VolumeSize = MultU64x32 (TotalClusters, BytesPerCluster); FileSystemInfoBuffer->VolumeSize = MultU64x32 (TotalClusters, BytesPerCluster);
FileSystemInfoBuffer->FreeSpace = MultU64x32 (FreeClusters, BytesPerCluster); FileSystemInfoBuffer->FreeSpace = MultU64x32 (FreeClusters, BytesPerCluster);
FileSystemInfoBuffer->BlockSize = BytesPerCluster; FileSystemInfoBuffer->BlockSize = BytesPerCluster;
} else { } else {
// //
// try GetDiskFreeSpaceEx then // try GetDiskFreeSpaceEx then
@ -1715,7 +1697,6 @@ Done:
return Status; return Status;
} }
/** /**
Set information about a file Set information about a file
@ -1790,7 +1771,6 @@ WinNtFileSetInfo (
goto Done; goto Done;
} }
FreePool (PrivateRoot->VolumeLabel); FreePool (PrivateRoot->VolumeLabel);
PrivateRoot->VolumeLabel = AllocatePool (StrSize (NewFileSystemInfo->VolumeLabel)); PrivateRoot->VolumeLabel = AllocatePool (StrSize (NewFileSystemInfo->VolumeLabel));
if (PrivateRoot->VolumeLabel == NULL) { if (PrivateRoot->VolumeLabel == NULL) {
@ -1848,8 +1828,9 @@ WinNtFileSetInfo (
if ((NewFileInfo->Size <= SIZE_OF_EFI_FILE_INFO) || if ((NewFileInfo->Size <= SIZE_OF_EFI_FILE_INFO) ||
(NewFileInfo->Attribute &~(EFI_FILE_VALID_ATTR)) || (NewFileInfo->Attribute &~(EFI_FILE_VALID_ATTR)) ||
(sizeof (UINTN) == 4 && NewFileInfo->Size > 0xFFFFFFFF) ((sizeof (UINTN) == 4) && (NewFileInfo->Size > 0xFFFFFFFF))
) { )
{
Status = EFI_INVALID_PARAMETER; Status = EFI_INVALID_PARAMETER;
goto Done; goto Done;
} }
@ -1959,15 +1940,18 @@ WinNtFileSetInfo (
// //
if (!IsZero (&NewFileInfo->CreateTime, sizeof (EFI_TIME)) && 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; TimeChangeFlag = TRUE;
} else if (!IsZero (&NewFileInfo->LastAccessTime, sizeof (EFI_TIME)) && } 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; TimeChangeFlag = TRUE;
} else if (!IsZero (&NewFileInfo->ModificationTime, sizeof (EFI_TIME)) && } 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; 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); CloseHandle (PrivateFile->DirHandle);
PrivateFile->DirHandle = INVALID_HANDLE_VALUE; PrivateFile->DirHandle = INVALID_HANDLE_VALUE;
} }
@ -2078,7 +2062,7 @@ WinNtFileSetInfo (
} }
} else { } else {
Status = EFI_ACCESS_DENIED; Status = EFI_ACCESS_DENIED;
Reopen:; Reopen:;
NtStatus = SetFileAttributes (OldFileName, OldAttr); NtStatus = SetFileAttributes (OldFileName, OldAttr);
@ -2120,7 +2104,6 @@ WinNtFileSetInfo (
FreePool (TempFileName); FreePool (TempFileName);
goto Done; goto Done;
} }
} }
@ -2163,7 +2146,6 @@ WinNtFileSetInfo (
// Time change // Time change
// //
if (TimeChangeFlag) { if (TimeChangeFlag) {
NewCreationSystemTime.wYear = NewFileInfo->CreateTime.Year; NewCreationSystemTime.wYear = NewFileInfo->CreateTime.Year;
NewCreationSystemTime.wMonth = NewFileInfo->CreateTime.Month; NewCreationSystemTime.wMonth = NewFileInfo->CreateTime.Month;
NewCreationSystemTime.wDay = NewFileInfo->CreateTime.Day; NewCreationSystemTime.wDay = NewFileInfo->CreateTime.Day;
@ -2175,14 +2157,16 @@ WinNtFileSetInfo (
if (!SystemTimeToFileTime ( if (!SystemTimeToFileTime (
&NewCreationSystemTime, &NewCreationSystemTime,
&NewCreationFileTime &NewCreationFileTime
)) { ))
{
goto Done; goto Done;
} }
if (!LocalFileTimeToFileTime ( if (!LocalFileTimeToFileTime (
&NewCreationFileTime, &NewCreationFileTime,
&NewCreationFileTime &NewCreationFileTime
)) { ))
{
goto Done; goto Done;
} }
@ -2197,14 +2181,16 @@ WinNtFileSetInfo (
if (!SystemTimeToFileTime ( if (!SystemTimeToFileTime (
&NewLastAccessSystemTime, &NewLastAccessSystemTime,
&NewLastAccessFileTime &NewLastAccessFileTime
)) { ))
{
goto Done; goto Done;
} }
if (!LocalFileTimeToFileTime ( if (!LocalFileTimeToFileTime (
&NewLastAccessFileTime, &NewLastAccessFileTime,
&NewLastAccessFileTime &NewLastAccessFileTime
)) { ))
{
goto Done; goto Done;
} }
@ -2219,14 +2205,16 @@ WinNtFileSetInfo (
if (!SystemTimeToFileTime ( if (!SystemTimeToFileTime (
&NewLastWriteSystemTime, &NewLastWriteSystemTime,
&NewLastWriteFileTime &NewLastWriteFileTime
)) { ))
{
goto Done; goto Done;
} }
if (!LocalFileTimeToFileTime ( if (!LocalFileTimeToFileTime (
&NewLastWriteFileTime, &NewLastWriteFileTime,
&NewLastWriteFileTime &NewLastWriteFileTime
)) { ))
{
goto Done; goto Done;
} }
@ -2235,11 +2223,11 @@ WinNtFileSetInfo (
&NewCreationFileTime, &NewCreationFileTime,
&NewLastAccessFileTime, &NewLastAccessFileTime,
&NewLastWriteFileTime &NewLastWriteFileTime
)) { ))
{
Status = EFI_DEVICE_ERROR; Status = EFI_DEVICE_ERROR;
goto Done; goto Done;
} }
} }
// //
@ -2295,7 +2283,6 @@ Done:
return Status; return Status;
} }
/** /**
Flush data back for the file handle. Flush data back for the file handle.
@ -2351,11 +2338,8 @@ Done:
// //
// bugbug: - Use Windows error reporting. // bugbug: - Use Windows error reporting.
// //
} }
EFI_STATUS EFI_STATUS
WinNtFileSystmeThunkOpen ( WinNtFileSystmeThunkOpen (
IN EMU_IO_THUNK_PROTOCOL *This IN EMU_IO_THUNK_PROTOCOL *This
@ -2390,7 +2374,6 @@ WinNtFileSystmeThunkOpen (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EFI_STATUS EFI_STATUS
WinNtFileSystmeThunkClose ( WinNtFileSystmeThunkClose (
IN EMU_IO_THUNK_PROTOCOL *This IN EMU_IO_THUNK_PROTOCOL *This
@ -2404,14 +2387,15 @@ WinNtFileSystmeThunkClose (
if (Private->VolumeLabel != NULL) { if (Private->VolumeLabel != NULL) {
FreePool (Private->VolumeLabel); FreePool (Private->VolumeLabel);
} }
if (Private->FilePath != NULL) { if (Private->FilePath != NULL) {
FreePool (Private->FilePath); FreePool (Private->FilePath);
} }
FreePool (Private); FreePool (Private);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EFI_FILE_PROTOCOL gWinNtFileProtocol = { EFI_FILE_PROTOCOL gWinNtFileProtocol = {
EFI_FILE_REVISION, EFI_FILE_REVISION,
WinNtFileOpen, WinNtFileOpen,
@ -2431,7 +2415,6 @@ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL gWinNtFileSystemProtocol = {
WinNtOpenVolume WinNtOpenVolume
}; };
EMU_IO_THUNK_PROTOCOL mWinNtFileSystemThunkIo = { EMU_IO_THUNK_PROTOCOL mWinNtFileSystemThunkIo = {
&gEfiSimpleFileSystemProtocolGuid, &gEfiSimpleFileSystemProtocolGuid,
NULL, NULL,
@ -2441,5 +2424,3 @@ EMU_IO_THUNK_PROTOCOL mWinNtFileSystemThunkIo = {
WinNtFileSystmeThunkClose, WinNtFileSystmeThunkClose,
NULL NULL
}; };

View File

@ -17,7 +17,6 @@ Abstract:
#ifndef _WIN_GOP_H_ #ifndef _WIN_GOP_H_
#define _WIN_GOP_H_ #define _WIN_GOP_H_
#include "WinHost.h" #include "WinHost.h"
#include <Protocol/EmuIoThunk.h> #include <Protocol/EmuIoThunk.h>
@ -55,7 +54,6 @@ typedef struct {
#define WIN_NT_GOP_CLASS_NAME L"WinNtGopWindow" #define WIN_NT_GOP_CLASS_NAME L"WinNtGopWindow"
typedef struct { typedef struct {
UINT64 Signature; UINT64 Signature;
EMU_GRAPHICS_WINDOW_PROTOCOL GraphicsWindowIo; EMU_GRAPHICS_WINDOW_PROTOCOL GraphicsWindowIo;
@ -119,7 +117,6 @@ typedef struct {
#define GRAPHICS_PRIVATE_DATA_FROM_THIS(a) \ #define GRAPHICS_PRIVATE_DATA_FROM_THIS(a) \
CR(a, GRAPHICS_PRIVATE_DATA, GraphicsWindowIo, GRAPHICS_PRIVATE_DATA_SIGNATURE) CR(a, GRAPHICS_PRIVATE_DATA, GraphicsWindowIo, GRAPHICS_PRIVATE_DATA_SIGNATURE)
// //
// Gop Hardware abstraction internal worker functions // Gop Hardware abstraction internal worker functions
// //
@ -180,13 +177,13 @@ WinNtWndGetPointerState (
IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo, IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo,
IN EFI_SIMPLE_POINTER_STATE *State IN EFI_SIMPLE_POINTER_STATE *State
); );
EFI_STATUS EFI_STATUS
GopPrivateCreateQ ( GopPrivateCreateQ (
IN GRAPHICS_PRIVATE_DATA *Private, IN GRAPHICS_PRIVATE_DATA *Private,
IN GOP_QUEUE_FIXED *Queue IN GOP_QUEUE_FIXED *Queue
); );
/** /**
TODO: Add function description TODO: Add function description
@ -200,5 +197,5 @@ GopPrivateDestroyQ (
IN GRAPHICS_PRIVATE_DATA *Private, IN GRAPHICS_PRIVATE_DATA *Private,
IN GOP_QUEUE_FIXED *Queue IN GOP_QUEUE_FIXED *Queue
); );
#endif
#endif

Some files were not shown because too many files have changed in this diff Show More