diff --git a/Nt32Pkg/BootModePei/BootModePei.c b/Nt32Pkg/BootModePei/BootModePei.c deleted file mode 100644 index 6de0774820..0000000000 --- a/Nt32Pkg/BootModePei/BootModePei.c +++ /dev/null @@ -1,95 +0,0 @@ -/**@file - -Copyright (c) 2006, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - BootMode.c - -Abstract: - - Tiano PEIM to provide the platform support functionality within Windows - -**/ - - - -// -// The package level header files this module uses -// -#include -// -// The protocols, PPI and GUID defintions for this module -// -#include -#include -// -// The Library classes this module consumes -// -#include -#include - - -// -// Module globals -// -EFI_PEI_PPI_DESCRIPTOR mPpiListBootMode = { - (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), - &gEfiPeiMasterBootModePpiGuid, - NULL -}; - -EFI_PEI_PPI_DESCRIPTOR mPpiListRecoveryBootMode = { - (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), - &gEfiPeiBootInRecoveryModePpiGuid, - NULL -}; - -EFI_STATUS -EFIAPI -InitializeBootMode ( - IN EFI_PEI_FILE_HANDLE FileHandle, - IN CONST EFI_PEI_SERVICES **PeiServices - ) -/*++ - -Routine Description: - - Peform the boot mode determination logic - -Arguments: - - FileHandle - Handle of the file being invoked. - PeiServices - Describes the list of possible PEI Services. - -Returns: - - Status - EFI_SUCCESS if the boot mode could be set - ---*/ -{ - EFI_STATUS Status; - UINTN BootMode; - - DEBUG ((EFI_D_ERROR, "NT32 Boot Mode PEIM Loaded\n")); - - // - // Let's assume things are OK if not told otherwise - // Should we read an environment variable in order to easily change this? - // - BootMode = BOOT_WITH_FULL_CONFIGURATION; - - Status = (**PeiServices).SetBootMode (PeiServices, (UINT8) BootMode); - ASSERT_EFI_ERROR (Status); - - Status = (**PeiServices).InstallPpi (PeiServices, &mPpiListBootMode); - ASSERT_EFI_ERROR (Status); - - if (BootMode == BOOT_IN_RECOVERY_MODE) { - Status = (**PeiServices).InstallPpi (PeiServices, &mPpiListRecoveryBootMode); - ASSERT_EFI_ERROR (Status); - } - - return Status; -} diff --git a/Nt32Pkg/BootModePei/BootModePei.inf b/Nt32Pkg/BootModePei/BootModePei.inf deleted file mode 100644 index 2579b34d5a..0000000000 --- a/Nt32Pkg/BootModePei/BootModePei.inf +++ /dev/null @@ -1,45 +0,0 @@ -## @file -# Component description file for BootMode module -# -# This module provides platform specific function to detect boot mode. -# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
-# -# SPDX-License-Identifier: BSD-2-Clause-Patent -# -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = BootMode - FILE_GUID = B7611005-1F26-45ba-A3DB-01F39DDB2785 - MODULE_TYPE = PEIM - VERSION_STRING = 1.0 - - ENTRY_POINT = InitializeBootMode - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 EBC -# - -[Sources] - BootModePei.c - - -[Packages] - MdePkg/MdePkg.dec - - -[LibraryClasses] - PeimEntryPoint - DebugLib - - -[Ppis] - gEfiPeiMasterBootModePpiGuid # PPI ALWAYS_PRODUCED - gEfiPeiBootInRecoveryModePpiGuid # PPI SOMETIMES_PRODUCED - -[depex] - TRUE diff --git a/Nt32Pkg/CpuRuntimeDxe/Cpu.c b/Nt32Pkg/CpuRuntimeDxe/Cpu.c deleted file mode 100644 index 8bf93ae607..0000000000 --- a/Nt32Pkg/CpuRuntimeDxe/Cpu.c +++ /dev/null @@ -1,547 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - Cpu.c - -Abstract: - - NT Emulation Architectural Protocol Driver as defined in Tiano. - This CPU module abstracts the interrupt subsystem of a platform and - the CPU-specific setjump/long pair. Other services are not implemented - in this driver. - -**/ - - -#include "CpuDriver.h" - -UINT64 mTimerPeriod; - -CPU_ARCH_PROTOCOL_PRIVATE mCpuTemplate = { - CPU_ARCH_PROT_PRIVATE_SIGNATURE, - NULL, - { - WinNtFlushCpuDataCache, - WinNtEnableInterrupt, - WinNtDisableInterrupt, - WinNtGetInterruptState, - WinNtInit, - WinNtRegisterInterruptHandler, - WinNtGetTimerValue, - WinNtSetMemoryAttributes, - 1, - 4 - }, - { - CpuMemoryServiceRead, - CpuMemoryServiceWrite, - CpuIoServiceRead, - CpuIoServiceWrite - }, - 0, - TRUE -}; - -#define EFI_CPU_DATA_MAXIMUM_LENGTH 0x100 - - - -// -// Service routines for the driver -// -EFI_STATUS -EFIAPI -WinNtFlushCpuDataCache ( - IN EFI_CPU_ARCH_PROTOCOL *This, - IN EFI_PHYSICAL_ADDRESS Start, - IN UINT64 Length, - IN EFI_CPU_FLUSH_TYPE FlushType - ) -/*++ - -Routine Description: - - This routine would provide support for flushing the CPU data cache. - In the case of NT emulation environment, this flushing is not necessary and - is thus not implemented. - -Arguments: - - Pointer to CPU Architectural Protocol interface - Start adddress in memory to flush - Length of memory to flush - Flush type - -Returns: - - Status - EFI_SUCCESS - ---*/ -// TODO: This - add argument and description to function comment -// TODO: FlushType - add argument and description to function comment -// TODO: EFI_UNSUPPORTED - add return value to function comment -{ - if (FlushType == EfiCpuFlushTypeWriteBackInvalidate) { - // - // Only WB flush is supported. We actually need do nothing on NT emulator - // environment. Classify this to follow EFI spec - // - return EFI_SUCCESS; - } - // - // Other flush types are not supported by NT emulator - // - return EFI_UNSUPPORTED; -} - - -EFI_STATUS -EFIAPI -WinNtEnableInterrupt ( - IN EFI_CPU_ARCH_PROTOCOL *This - ) -/*++ - -Routine Description: - - This routine provides support for emulation of the interrupt enable of the - the system. For our purposes, CPU enable is just a BOOLEAN that the Timer - Architectural Protocol observes in order to defer behaviour while in its - emulated interrupt, or timer tick. - -Arguments: - - Pointer to CPU Architectural Protocol interface - -Returns: - - Status - EFI_SUCCESS - ---*/ -// TODO: This - add argument and description to function comment -{ - CPU_ARCH_PROTOCOL_PRIVATE *Private; - - Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This); - Private->InterruptState = TRUE; - return EFI_SUCCESS; -} - - -EFI_STATUS -EFIAPI -WinNtDisableInterrupt ( - IN EFI_CPU_ARCH_PROTOCOL *This - ) -/*++ - -Routine Description: - - This routine provides support for emulation of the interrupt disable of the - the system. For our purposes, CPU enable is just a BOOLEAN that the Timer - Architectural Protocol observes in order to defer behaviour while in its - emulated interrupt, or timer tick. - -Arguments: - - Pointer to CPU Architectural Protocol interface - -Returns: - - Status - EFI_SUCCESS - ---*/ -// TODO: This - add argument and description to function comment -{ - CPU_ARCH_PROTOCOL_PRIVATE *Private; - - Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This); - Private->InterruptState = FALSE; - return EFI_SUCCESS; -} - - -EFI_STATUS -EFIAPI -WinNtGetInterruptState ( - IN EFI_CPU_ARCH_PROTOCOL *This, - OUT BOOLEAN *State - ) -/*++ - -Routine Description: - - This routine provides support for emulation of the interrupt disable of the - the system. For our purposes, CPU enable is just a BOOLEAN that the Timer - Architectural Protocol observes in order to defer behaviour while in its - emulated interrupt, or timer tick. - -Arguments: - - Pointer to CPU Architectural Protocol interface - -Returns: - - Status - EFI_SUCCESS - ---*/ -// TODO: This - add argument and description to function comment -// TODO: State - add argument and description to function comment -// TODO: EFI_INVALID_PARAMETER - add return value to function comment -{ - CPU_ARCH_PROTOCOL_PRIVATE *Private; - - if (State == NULL) { - return EFI_INVALID_PARAMETER; - } - - Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This); - *State = Private->InterruptState; - return EFI_SUCCESS; -} - - -EFI_STATUS -EFIAPI -WinNtInit ( - IN EFI_CPU_ARCH_PROTOCOL *This, - IN EFI_CPU_INIT_TYPE InitType - ) -/*++ - -Routine Description: - - This routine would support generation of a CPU INIT. At - present, this code does not provide emulation. - -Arguments: - - Pointer to CPU Architectural Protocol interface - INIT Type - -Returns: - - Status - EFI_UNSUPPORTED - not yet implemented - ---*/ -// TODO: This - add argument and description to function comment -// TODO: InitType - add argument and description to function comment -{ - return EFI_UNSUPPORTED; -} - - -EFI_STATUS -EFIAPI -WinNtRegisterInterruptHandler ( - IN EFI_CPU_ARCH_PROTOCOL *This, - IN EFI_EXCEPTION_TYPE InterruptType, - IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler - ) -/*++ - -Routine Description: - - This routine would support registration of an interrupt handler. At - present, this code does not provide emulation. - -Arguments: - - Pointer to CPU Architectural Protocol interface - Pointer to interrupt handlers - Interrupt type - -Returns: - - Status - EFI_UNSUPPORTED - not yet implemented - ---*/ -// TODO: This - add argument and description to function comment -// TODO: InterruptType - add argument and description to function comment -// TODO: InterruptHandler - add argument and description to function comment -{ - - // - // Do parameter checking for EFI spec conformance - // - if (InterruptType < 0 || InterruptType > 0xff) { - return EFI_UNSUPPORTED; - } - // - // Do nothing for Nt32 emulation - // - return EFI_UNSUPPORTED; -} - - -EFI_STATUS -EFIAPI -WinNtGetTimerValue ( - IN EFI_CPU_ARCH_PROTOCOL *This, - IN UINT32 TimerIndex, - OUT UINT64 *TimerValue, - OUT UINT64 *TimerPeriod OPTIONAL - ) -/*++ - -Routine Description: - - This routine would support querying of an on-CPU timer. At present, - this code does not provide timer emulation. - -Arguments: - - This - Pointer to CPU Architectural Protocol interface - TimerIndex - Index of given CPU timer - TimerValue - Output of the timer - TimerPeriod - Output of the timer period - -Returns: - - EFI_UNSUPPORTED - not yet implemented - EFI_INVALID_PARAMETER - TimeValue is NULL - ---*/ -{ - if (TimerValue == NULL) { - return EFI_INVALID_PARAMETER; - } - - if (TimerIndex != 0) { - return EFI_INVALID_PARAMETER; - } - - gWinNt->QueryPerformanceCounter ((LARGE_INTEGER *)TimerValue); - - if (TimerPeriod != NULL) { - *TimerPeriod = mTimerPeriod; - } - - return EFI_SUCCESS; -} - - -EFI_STATUS -EFIAPI -WinNtSetMemoryAttributes ( - IN EFI_CPU_ARCH_PROTOCOL *This, - IN EFI_PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length, - IN UINT64 Attributes - ) -/*++ - -Routine Description: - - This routine would support querying of an on-CPU timer. At present, - this code does not provide timer emulation. - -Arguments: - - Pointer to CPU Architectural Protocol interface - Start address of memory region - The size in bytes of the memory region - The bit mask of attributes to set for the memory region - -Returns: - - Status - EFI_UNSUPPORTED - not yet implemented - ---*/ -// TODO: This - add argument and description to function comment -// TODO: BaseAddress - add argument and description to function comment -// TODO: Length - add argument and description to function comment -// TODO: Attributes - add argument and description to function comment -// TODO: EFI_INVALID_PARAMETER - add return value to function comment -{ - // - // Check for invalid parameter for Spec conformance - // - if (Length == 0) { - return EFI_INVALID_PARAMETER; - } - - // - // Do nothing for Nt32 emulation - // - return EFI_UNSUPPORTED; -} - - - -/** - Logs SMBIOS record. - - @param Smbios Pointer to SMBIOS protocol instance. - @param Buffer Pointer to the data buffer. - -**/ -VOID -LogSmbiosData ( - IN EFI_SMBIOS_PROTOCOL *Smbios, - IN UINT8 *Buffer - ) -{ - EFI_STATUS Status; - EFI_SMBIOS_HANDLE SmbiosHandle; - - SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED; - Status = Smbios->Add ( - Smbios, - NULL, - &SmbiosHandle, - (EFI_SMBIOS_TABLE_HEADER*)Buffer - ); - ASSERT_EFI_ERROR (Status); -} - - -VOID -CpuUpdateSmbios ( - VOID - ) -/*++ - -Routine Description: - This function will log processor version and frequency data to Smbios. - -Arguments: - Event - Event whose notification function is being invoked. - Context - Pointer to the notification function's context. - -Returns: - None. - ---*/ -{ - EFI_STATUS Status; - UINT32 TotalSize; - EFI_SMBIOS_PROTOCOL *Smbios; - EFI_HII_HANDLE HiiHandle; - STRING_REF Token; - UINTN CpuVerStrLen; - EFI_STRING CpuVerStr; - SMBIOS_TABLE_TYPE4 *SmbiosRecord; - CHAR8 *OptionalStrStart; - - // - // Locate Smbios protocol. - // - Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&Smbios); - - if (EFI_ERROR (Status)) { - return; - } - - // - // Initialize strings to HII database - // - HiiHandle = HiiAddPackages ( - &gEfiCallerIdGuid, - NULL, - CpuStrings, - NULL - ); - ASSERT (HiiHandle != NULL); - - Token = STRING_TOKEN (STR_PROCESSOR_VERSION); - CpuVerStr = HiiGetPackageString(&gEfiCallerIdGuid, Token, NULL); - CpuVerStrLen = StrLen(CpuVerStr); - ASSERT (CpuVerStrLen <= SMBIOS_STRING_MAX_LENGTH); - - - TotalSize = (UINT32)(sizeof(SMBIOS_TABLE_TYPE4) + CpuVerStrLen + 1 + 1); - SmbiosRecord = AllocatePool(TotalSize); - ZeroMem(SmbiosRecord, TotalSize); - - SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION; - SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE4); - // - // Make handle chosen by smbios protocol.add automatically. - // - SmbiosRecord->Hdr.Handle = 0; - // - // Processor version is the 1st string. - // - SmbiosRecord->ProcessorVersion = 1; - // - // Store CPU frequency data record to data hub - It's an emulator so make up a value - // - SmbiosRecord->CurrentSpeed = 1234; - - OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1); - UnicodeStrToAsciiStr(CpuVerStr, OptionalStrStart); - - // - // Now we have got the full smbios record, call smbios protocol to add this record. - // - LogSmbiosData(Smbios, (UINT8 *) SmbiosRecord); - FreePool (SmbiosRecord); - -} - - - -EFI_STATUS -EFIAPI -InitializeCpu ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -/*++ - -Routine Description: - - Initialize the state information for the CPU Architectural Protocol - -Arguments: - - ImageHandle of the loaded driver - Pointer to the System Table - -Returns: - - Status - - EFI_SUCCESS - protocol instance can be published - EFI_OUT_OF_RESOURCES - cannot allocate protocol data structure - EFI_DEVICE_ERROR - cannot create the thread - ---*/ -{ - EFI_STATUS Status; - UINT64 Frequency; - - // - // Retrieve the frequency of the performance counter in Hz. - // - gWinNt->QueryPerformanceFrequency ((LARGE_INTEGER *)&Frequency); - - // - // Convert frequency in Hz to a clock period in femtoseconds. - // - mTimerPeriod = DivU64x64Remainder (1000000000000000, Frequency, NULL); - - CpuUpdateSmbios (); - - Status = gBS->InstallMultipleProtocolInterfaces ( - &mCpuTemplate.Handle, - &gEfiCpuArchProtocolGuid, &mCpuTemplate.Cpu, - &gEfiCpuIo2ProtocolGuid, &mCpuTemplate.CpuIo, - NULL - ); - ASSERT_EFI_ERROR (Status); - - return Status; -} diff --git a/Nt32Pkg/CpuRuntimeDxe/CpuDriver.h b/Nt32Pkg/CpuRuntimeDxe/CpuDriver.h deleted file mode 100644 index 94f8eb459c..0000000000 --- a/Nt32Pkg/CpuRuntimeDxe/CpuDriver.h +++ /dev/null @@ -1,182 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - CpuDriver.h - -Abstract: - - NT Emulation Architectural Protocol Driver as defined in Tiano. - -**/ - -#ifndef _CPU_ARCHITECTURAL_PROTOCOL_DRIVER_H_ -#define _CPU_ARCHITECTURAL_PROTOCOL_DRIVER_H_ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -extern UINT8 CpuStrings[]; - -// -// Internal Data Structures -// -#define CPU_ARCH_PROT_PRIVATE_SIGNATURE SIGNATURE_32 ('c', 'a', 'p', 'd') - -typedef struct { - UINTN Signature; - EFI_HANDLE Handle; - - EFI_CPU_ARCH_PROTOCOL Cpu; - EFI_CPU_IO2_PROTOCOL CpuIo; - - // - // Local Data for CPU interface goes here - // - CRITICAL_SECTION NtCriticalSection; - BOOLEAN InterruptState; - -} CPU_ARCH_PROTOCOL_PRIVATE; - -#define CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS(a) \ - CR (a, \ - CPU_ARCH_PROTOCOL_PRIVATE, \ - Cpu, \ - CPU_ARCH_PROT_PRIVATE_SIGNATURE \ - ) - -EFI_STATUS -EFIAPI -CpuMemoryServiceRead ( - IN EFI_CPU_IO2_PROTOCOL *This, - IN EFI_CPU_IO_PROTOCOL_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - IN OUT VOID *Buffer - ); - -EFI_STATUS -EFIAPI -CpuMemoryServiceWrite ( - IN EFI_CPU_IO2_PROTOCOL *This, - IN EFI_CPU_IO_PROTOCOL_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - IN OUT VOID *Buffer - ); - -EFI_STATUS -EFIAPI -CpuIoServiceRead ( - IN EFI_CPU_IO2_PROTOCOL *This, - IN EFI_CPU_IO_PROTOCOL_WIDTH Width, - IN UINT64 UserAddress, - IN UINTN Count, - IN OUT VOID *UserBuffer - ); - -EFI_STATUS -EFIAPI -CpuIoServiceWrite ( - IN EFI_CPU_IO2_PROTOCOL *This, - IN EFI_CPU_IO_PROTOCOL_WIDTH Width, - IN UINT64 UserAddress, - IN UINTN Count, - IN OUT VOID *UserBuffer - ); - - -EFI_STATUS -EFIAPI -InitializeCpu ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ); - -EFI_STATUS -EFIAPI -WinNtFlushCpuDataCache ( - IN EFI_CPU_ARCH_PROTOCOL *This, - IN EFI_PHYSICAL_ADDRESS Start, - IN UINT64 Length, - IN EFI_CPU_FLUSH_TYPE FlushType - ); - -EFI_STATUS -EFIAPI -WinNtEnableInterrupt ( - IN EFI_CPU_ARCH_PROTOCOL *This - ); - -EFI_STATUS -EFIAPI -WinNtDisableInterrupt ( - IN EFI_CPU_ARCH_PROTOCOL *This - ); - -EFI_STATUS -EFIAPI -WinNtGetInterruptState ( - IN EFI_CPU_ARCH_PROTOCOL *This, - OUT BOOLEAN *State - ); - -EFI_STATUS -EFIAPI -WinNtInit ( - IN EFI_CPU_ARCH_PROTOCOL *This, - IN EFI_CPU_INIT_TYPE InitType - ); - -EFI_STATUS -EFIAPI -WinNtRegisterInterruptHandler ( - IN EFI_CPU_ARCH_PROTOCOL *This, - IN EFI_EXCEPTION_TYPE InterruptType, - IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler - ); - -EFI_STATUS -EFIAPI -WinNtGetTimerValue ( - IN EFI_CPU_ARCH_PROTOCOL *This, - IN UINT32 TimerIndex, - OUT UINT64 *TimerValue, - OUT UINT64 *TimerPeriod OPTIONAL - ); - -EFI_STATUS -EFIAPI -WinNtSetMemoryAttributes ( - IN EFI_CPU_ARCH_PROTOCOL *This, - IN EFI_PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length, - IN UINT64 Attributes - ); - - - - - - -#endif diff --git a/Nt32Pkg/CpuRuntimeDxe/CpuIo.c b/Nt32Pkg/CpuRuntimeDxe/CpuIo.c deleted file mode 100644 index 4809f9c00d..0000000000 --- a/Nt32Pkg/CpuRuntimeDxe/CpuIo.c +++ /dev/null @@ -1,335 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - CpuIo.c - -Abstract: - - This is the code that publishes the CPU I/O Protocol. - The intent herein is to have a single I/O service that can load - as early as possible, extend into runtime, and be layered upon by - the implementations of architectural protocols and the PCI Root - Bridge I/O Protocol. - -**/ - -#include - -#define IA32_MAX_IO_ADDRESS 0xFFFF -#define IA32_MAX_MEM_ADDRESS 0xFFFFFFFF - -EFI_STATUS -CpuIoCheckAddressRange ( - IN EFI_CPU_IO_PROTOCOL_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - IN VOID *Buffer, - IN UINT64 Limit - ); - -EFI_STATUS -EFIAPI -CpuMemoryServiceRead ( - IN EFI_CPU_IO2_PROTOCOL *This, - IN EFI_CPU_IO_PROTOCOL_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - IN OUT VOID *Buffer - ) -/*++ - -Routine Description: - - Perform the Memory Access Read service for the CPU I/O Protocol - -Arguments: - - Pointer to an instance of the CPU I/O Protocol - Width of the Memory Access - Address of the Memory access - Count of the number of accesses to perform - Pointer to the buffer to read or write from memory - -Returns: - - Status - - EFI_SUCCESS - The data was read from or written to the EFI - System. - EFI_INVALID_PARAMETER - Width is invalid for this EFI System. - EFI_INVALID_PARAMETER - Buffer is NULL. - EFI_UNSUPPORTED - The Buffer is not aligned for the given Width. - EFI_UNSUPPORTED - The address range specified by Address, Width, - and Count is not valid for this EFI System. - ---*/ -// TODO: This - add argument and description to function comment -{ - EFI_STATUS Status; - - if (!Buffer) { - return EFI_INVALID_PARAMETER; - } - - if ((Width < 0) || (Width >= EfiCpuIoWidthMaximum)) { - return EFI_INVALID_PARAMETER; - } - - Status = CpuIoCheckAddressRange (Width, Address, Count, Buffer, IA32_MAX_MEM_ADDRESS); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Do nothing for Nt32 version - // - return EFI_UNSUPPORTED; -} - -EFI_STATUS -EFIAPI -CpuMemoryServiceWrite ( - IN EFI_CPU_IO2_PROTOCOL *This, - IN EFI_CPU_IO_PROTOCOL_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - IN OUT VOID *Buffer - ) -/*++ - -Routine Description: - - Perform the Memory Access Read service for the CPU I/O Protocol - -Arguments: - - Pointer to an instance of the CPU I/O Protocol - Width of the Memory Access - Address of the Memory access - Count of the number of accesses to perform - Pointer to the buffer to read or write from memory - -Returns: - - Status - - EFI_SUCCESS - The data was read from or written to the EFI System. - EFI_INVALID_PARAMETER - Width is invalid for this EFI System. - EFI_INVALID_PARAMETER - Buffer is NULL. - EFI_UNSUPPORTED - The Buffer is not aligned for the given Width. - EFI_UNSUPPORTED - The address range specified by Address, Width, and - Count is not valid for this EFI System. - ---*/ -// TODO: This - add argument and description to function comment -{ - EFI_STATUS Status; - - if (!Buffer) { - return EFI_INVALID_PARAMETER; - } - - if ((Width < 0) || (Width >= EfiCpuIoWidthMaximum)) { - return EFI_INVALID_PARAMETER; - } - - Status = CpuIoCheckAddressRange (Width, Address, Count, Buffer, IA32_MAX_MEM_ADDRESS); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Do nothing for Nt32 version - // - return EFI_UNSUPPORTED; -} - -EFI_STATUS -EFIAPI -CpuIoServiceRead ( - IN EFI_CPU_IO2_PROTOCOL *This, - IN EFI_CPU_IO_PROTOCOL_WIDTH Width, - IN UINT64 UserAddress, - IN UINTN Count, - IN OUT VOID *UserBuffer - ) -/*++ - -Routine Description: - - This is the service that implements the I/O read - -Arguments: - - Pointer to an instance of the CPU I/O Protocol - Width of the Memory Access - Address of the I/O access - Count of the number of accesses to perform - Pointer to the buffer to read or write from I/O space - -Returns: - - Status - EFI_SUCCESS - The data was read from or written to the EFI System. - EFI_INVALID_PARAMETER - Width is invalid for this EFI System. - EFI_INVALID_PARAMETER - Buffer is NULL. - EFI_UNSUPPORTED - The Buffer is not aligned for the given Width. - EFI_UNSUPPORTED - The address range specified by Address, Width, and - Count is not valid for this EFI System. ---*/ -// TODO: This - add argument and description to function comment -// TODO: UserAddress - add argument and description to function comment -// TODO: UserBuffer - add argument and description to function comment -{ - UINTN Address; - EFI_STATUS Status; - - if (!UserBuffer) { - return EFI_INVALID_PARAMETER; - } - - Address = (UINTN) UserAddress; - - if ((Width < 0) || (Width >= EfiCpuIoWidthMaximum)) { - return EFI_INVALID_PARAMETER; - } - - Status = CpuIoCheckAddressRange (Width, Address, Count, UserBuffer, IA32_MAX_IO_ADDRESS); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Do nothing for Nt32 version - // - return EFI_UNSUPPORTED; -} - -EFI_STATUS -EFIAPI -CpuIoServiceWrite ( - IN EFI_CPU_IO2_PROTOCOL *This, - IN EFI_CPU_IO_PROTOCOL_WIDTH Width, - IN UINT64 UserAddress, - IN UINTN Count, - IN OUT VOID *UserBuffer - ) -/*++ - -Routine Description: - - - This is the service that implements the I/O Write - -Arguments: - - Pointer to an instance of the CPU I/O Protocol - Width of the Memory Access - Address of the I/O access - Count of the number of accesses to perform - Pointer to the buffer to read or write from I/O space - -Returns: - - Status - - Status - EFI_SUCCESS - The data was read from or written to the EFI System. - EFI_INVALID_PARAMETER - Width is invalid for this EFI System. - EFI_INVALID_PARAMETER - Buffer is NULL. - EFI_UNSUPPORTED - The Buffer is not aligned for the given Width. - EFI_UNSUPPORTED - The address range specified by Address, Width, and - Count is not valid for this EFI System. - ---*/ -// TODO: This - add argument and description to function comment -// TODO: UserAddress - add argument and description to function comment -// TODO: UserBuffer - add argument and description to function comment -{ - UINTN Address; - EFI_STATUS Status; - - if (!UserBuffer) { - return EFI_INVALID_PARAMETER; - } - - Address = (UINTN) UserAddress; - - if ((Width < 0) || (Width >= EfiCpuIoWidthMaximum)) { - return EFI_INVALID_PARAMETER; - } - - Status = CpuIoCheckAddressRange (Width, Address, Count, UserBuffer, IA32_MAX_IO_ADDRESS); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Do nothing for Nt32 version - // - return EFI_UNSUPPORTED; -} - - -EFI_STATUS -CpuIoCheckAddressRange ( - IN EFI_CPU_IO_PROTOCOL_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - IN VOID *Buffer, - IN UINT64 Limit - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - Width - TODO: add argument description - Address - TODO: add argument description - Count - TODO: add argument description - Buffer - TODO: add argument description - Limit - TODO: add argument description - -Returns: - - EFI_UNSUPPORTED - TODO: Add description for return value - EFI_UNSUPPORTED - TODO: Add description for return value - EFI_UNSUPPORTED - TODO: Add description for return value - EFI_SUCCESS - TODO: Add description for return value - ---*/ -{ - UINTN AlignMask; - - if (Address > Limit) { - return EFI_UNSUPPORTED; - } - - // - // For FiFo type, the target address won't increase during the access, so treat count as 1 - // - if (Width >= EfiCpuIoWidthFifoUint8 && Width <= EfiCpuIoWidthFifoUint64) { - Count = 1; - } - - Width = (EFI_CPU_IO_PROTOCOL_WIDTH)(Width & 0x03); - if (Address - 1 + ((UINTN)1 << Width) * Count > Limit) { - return EFI_UNSUPPORTED; - } - - AlignMask = ((UINTN)1 << Width) - 1; - if ((UINTN) Buffer & AlignMask) { - return EFI_UNSUPPORTED; - } - - return EFI_SUCCESS; -} - - diff --git a/Nt32Pkg/CpuRuntimeDxe/CpuRuntimeDxe.inf b/Nt32Pkg/CpuRuntimeDxe/CpuRuntimeDxe.inf deleted file mode 100644 index c55b628031..0000000000 --- a/Nt32Pkg/CpuRuntimeDxe/CpuRuntimeDxe.inf +++ /dev/null @@ -1,56 +0,0 @@ -## @file -# Component description file for Cpu module. -# -# This CPU module abstracts the interrupt subsystem of a platform and the CPU-specific setjump-long pair. -# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
-# -# SPDX-License-Identifier: BSD-2-Clause-Patent -# -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = Cpu - FILE_GUID = ee993080-5197-4d4e-b63c-f1f7413e33ce - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - - ENTRY_POINT = InitializeCpu - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 -# - -[Sources] - CpuIo.c - Cpu.c - CpuDriver.h - Strings.uni - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - Nt32Pkg/Nt32Pkg.dec - IntelFrameworkPkg/IntelFrameworkPkg.dec - -[LibraryClasses] - UefiBootServicesTableLib - MemoryAllocationLib - BaseMemoryLib - UefiDriverEntryPoint - DebugLib - HiiLib - WinNtLib - -[Protocols] - gEfiWinNtIoProtocolGuid # PROTOCOL_NOTIFY SOMETIMES_CONSUMED - gEfiSmbiosProtocolGuid # PROTOCOL SOMETIMES_CONSUMED - gEfiWinNtIoProtocolGuid # PROTOCOL ALWAYS_CONSUMED - gEfiCpuIo2ProtocolGuid # PROTOCOL ALWAYS_PRODUCED - gEfiCpuArchProtocolGuid # PROTOCOL ALWAYS_PRODUCED - -[Depex] - gEfiSmbiosProtocolGuid diff --git a/Nt32Pkg/CpuRuntimeDxe/Strings.uni b/Nt32Pkg/CpuRuntimeDxe/Strings.uni deleted file mode 100644 index 0b3a6120da..0000000000 --- a/Nt32Pkg/CpuRuntimeDxe/Strings.uni +++ /dev/null @@ -1,24 +0,0 @@ -// *++ -// -// Copyright (c) 2006, Intel Corporation. All rights reserved.
-// SPDX-License-Identifier: BSD-2-Clause-Patent -// -// Module Name: -// -// Strings.uni -// -// Abstract: -// -// String definition -// Revision History: -// -// --*/ - -/=# - -#langdef en-US "English" -#langdef fr-FR "Français" - - -#string STR_PROCESSOR_VERSION #language en-US "NT32 Emulated Processor" - #language fr-FR "Processeur Émulé par NT32" \ No newline at end of file diff --git a/Nt32Pkg/FvbServicesRuntimeDxe/FWBlockService.c b/Nt32Pkg/FvbServicesRuntimeDxe/FWBlockService.c deleted file mode 100644 index 4af535d925..0000000000 --- a/Nt32Pkg/FvbServicesRuntimeDxe/FWBlockService.c +++ /dev/null @@ -1,1372 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - FWBlockService.c - -Abstract: - -Revision History - -**/ - -// -// The package level header files this module uses -// -#include -#include -// -// The protocols, PPI and GUID defintions for this module -// -#include -#include -#include -// -// The Library classes this module consumes -// -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "FWBlockService.h" - -#define EFI_FVB2_STATUS (EFI_FVB2_READ_STATUS | EFI_FVB2_WRITE_STATUS | EFI_FVB2_LOCK_STATUS) - -ESAL_FWB_GLOBAL *mFvbModuleGlobal; - -FV_MEMMAP_DEVICE_PATH mFvMemmapDevicePathTemplate = { - { - { - HARDWARE_DEVICE_PATH, - HW_MEMMAP_DP, - { - (UINT8)(sizeof (MEMMAP_DEVICE_PATH)), - (UINT8)(sizeof (MEMMAP_DEVICE_PATH) >> 8) - } - }, - EfiMemoryMappedIO, - (EFI_PHYSICAL_ADDRESS) 0, - (EFI_PHYSICAL_ADDRESS) 0, - }, - { - END_DEVICE_PATH_TYPE, - END_ENTIRE_DEVICE_PATH_SUBTYPE, - { - END_DEVICE_PATH_LENGTH, - 0 - } - } -}; - -FV_PIWG_DEVICE_PATH mFvPIWGDevicePathTemplate = { - { - { - MEDIA_DEVICE_PATH, - MEDIA_PIWG_FW_VOL_DP, - { - (UINT8)(sizeof (MEDIA_FW_VOL_DEVICE_PATH)), - (UINT8)(sizeof (MEDIA_FW_VOL_DEVICE_PATH) >> 8) - } - }, - { 0 } - }, - { - END_DEVICE_PATH_TYPE, - END_ENTIRE_DEVICE_PATH_SUBTYPE, - { - END_DEVICE_PATH_LENGTH, - 0 - } - } -}; - -EFI_FW_VOL_BLOCK_DEVICE mFvbDeviceTemplate = { - FVB_DEVICE_SIGNATURE, - NULL, - 0, - { - FvbProtocolGetAttributes, - FvbProtocolSetAttributes, - FvbProtocolGetPhysicalAddress, - FvbProtocolGetBlockSize, - FvbProtocolRead, - FvbProtocolWrite, - FvbProtocolEraseBlocks, - NULL - } -}; - - - -VOID -EFIAPI -FvbVirtualddressChangeEvent ( - IN EFI_EVENT Event, - IN VOID *Context - ) -/*++ - -Routine Description: - - Fixup internal data so that EFI and SAL can be call in virtual mode. - Call the passed in Child Notify event and convert the mFvbModuleGlobal - date items to there virtual address. - - mFvbModuleGlobal->FvInstance[FVB_PHYSICAL] - Physical copy of instance data - mFvbModuleGlobal->FvInstance[FVB_VIRTUAL] - Virtual pointer to common - instance data. - -Arguments: - - (Standard EFI notify event - EFI_EVENT_NOTIFY) - -Returns: - - None - ---*/ -{ - EFI_FW_VOL_INSTANCE *FwhInstance; - UINTN Index; - - EfiConvertPointer (0x0, (VOID **) &mFvbModuleGlobal->FvInstance[FVB_VIRTUAL]); - - // - // Convert the base address of all the instances - // - Index = 0; - FwhInstance = mFvbModuleGlobal->FvInstance[FVB_PHYSICAL]; - while (Index < mFvbModuleGlobal->NumFv) { - EfiConvertPointer (0x0, (VOID **) &FwhInstance->FvBase[FVB_VIRTUAL]); - FwhInstance = (EFI_FW_VOL_INSTANCE *) - ( - (UINTN) ((UINT8 *) FwhInstance) + FwhInstance->VolumeHeader.HeaderLength + - (sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER)) - ); - Index++; - } - - EfiConvertPointer (0x0, (VOID **) &mFvbModuleGlobal->FvbScratchSpace[FVB_VIRTUAL]); - EfiConvertPointer (0x0, (VOID **) &mFvbModuleGlobal); -} - -EFI_STATUS -GetFvbInstance ( - IN UINTN Instance, - IN ESAL_FWB_GLOBAL *Global, - OUT EFI_FW_VOL_INSTANCE **FwhInstance, - IN BOOLEAN Virtual - ) -/*++ - -Routine Description: - Retrieves the physical address of a memory mapped FV - -Arguments: - Instance - The FV instance whose base address is going to be - returned - Global - Pointer to ESAL_FWB_GLOBAL that contains all - instance data - FwhInstance - The EFI_FW_VOL_INSTANCE fimrware instance structure - Virtual - Whether CPU is in virtual or physical mode - -Returns: - EFI_SUCCESS - Successfully returns - EFI_INVALID_PARAMETER - Instance not found - ---*/ -{ - EFI_FW_VOL_INSTANCE *FwhRecord; - - if (Instance >= Global->NumFv) { - return EFI_INVALID_PARAMETER; - } - // - // Find the right instance of the FVB private data - // - FwhRecord = Global->FvInstance[Virtual]; - while (Instance > 0) { - FwhRecord = (EFI_FW_VOL_INSTANCE *) - ( - (UINTN) ((UINT8 *) FwhRecord) + FwhRecord->VolumeHeader.HeaderLength + - (sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER)) - ); - Instance--; - } - - *FwhInstance = FwhRecord; - - return EFI_SUCCESS; -} - -EFI_STATUS -FvbGetPhysicalAddress ( - IN UINTN Instance, - OUT EFI_PHYSICAL_ADDRESS *Address, - IN ESAL_FWB_GLOBAL *Global, - IN BOOLEAN Virtual - ) -/*++ - -Routine Description: - Retrieves the physical address of a memory mapped FV - -Arguments: - Instance - The FV instance whose base address is going to be - returned - Address - Pointer to a caller allocated EFI_PHYSICAL_ADDRESS - that on successful return, contains the base address - of the firmware volume. - Global - Pointer to ESAL_FWB_GLOBAL that contains all - instance data - Virtual - Whether CPU is in virtual or physical mode - -Returns: - EFI_SUCCESS - Successfully returns - EFI_INVALID_PARAMETER - Instance not found - ---*/ -{ - EFI_FW_VOL_INSTANCE *FwhInstance; - EFI_STATUS Status; - - // - // Find the right instance of the FVB private data - // - Status = GetFvbInstance (Instance, Global, &FwhInstance, Virtual); - ASSERT_EFI_ERROR (Status); - *Address = FwhInstance->FvBase[Virtual]; - - return EFI_SUCCESS; -} - -EFI_STATUS -FvbGetVolumeAttributes ( - IN UINTN Instance, - OUT EFI_FVB_ATTRIBUTES_2 *Attributes, - IN ESAL_FWB_GLOBAL *Global, - IN BOOLEAN Virtual - ) -/*++ - -Routine Description: - Retrieves attributes, insures positive polarity of attribute bits, returns - resulting attributes in output parameter - -Arguments: - Instance - The FV instance whose attributes is going to be - returned - Attributes - Output buffer which contains attributes - Global - Pointer to ESAL_FWB_GLOBAL that contains all - instance data - Virtual - Whether CPU is in virtual or physical mode - -Returns: - EFI_SUCCESS - Successfully returns - EFI_INVALID_PARAMETER - Instance not found - ---*/ -{ - EFI_FW_VOL_INSTANCE *FwhInstance; - EFI_STATUS Status; - - // - // Find the right instance of the FVB private data - // - Status = GetFvbInstance (Instance, Global, &FwhInstance, Virtual); - ASSERT_EFI_ERROR (Status); - *Attributes = FwhInstance->VolumeHeader.Attributes; - - return EFI_SUCCESS; -} - -EFI_STATUS -FvbGetLbaAddress ( - IN UINTN Instance, - IN EFI_LBA Lba, - OUT UINTN *LbaAddress, - OUT UINTN *LbaLength, - OUT UINTN *NumOfBlocks, - IN ESAL_FWB_GLOBAL *Global, - IN BOOLEAN Virtual - ) -/*++ - -Routine Description: - Retrieves the starting address of an LBA in an FV - -Arguments: - Instance - The FV instance which the Lba belongs to - Lba - The logical block address - LbaAddress - On output, contains the physical starting address - of the Lba - LbaLength - On output, contains the length of the block - NumOfBlocks - A pointer to a caller allocated UINTN in which the - number of consecutive blocks starting with Lba is - returned. All blocks in this range have a size of - BlockSize - Global - Pointer to ESAL_FWB_GLOBAL that contains all - instance data - Virtual - Whether CPU is in virtual or physical mode - -Returns: - EFI_SUCCESS - Successfully returns - EFI_INVALID_PARAMETER - Instance not found - ---*/ -{ - UINT32 NumBlocks; - UINT32 BlockLength; - UINTN Offset; - EFI_LBA StartLba; - EFI_LBA NextLba; - EFI_FW_VOL_INSTANCE *FwhInstance; - EFI_FV_BLOCK_MAP_ENTRY *BlockMap; - EFI_STATUS Status; - - // - // Find the right instance of the FVB private data - // - Status = GetFvbInstance (Instance, Global, &FwhInstance, Virtual); - ASSERT_EFI_ERROR (Status); - - StartLba = 0; - Offset = 0; - BlockMap = &(FwhInstance->VolumeHeader.BlockMap[0]); - - // - // Parse the blockmap of the FV to find which map entry the Lba belongs to - // - while (TRUE) { - NumBlocks = BlockMap->NumBlocks; - BlockLength = BlockMap->Length; - - if (NumBlocks == 0 || BlockLength == 0) { - return EFI_INVALID_PARAMETER; - } - - NextLba = StartLba + NumBlocks; - - // - // The map entry found - // - if (Lba >= StartLba && Lba < NextLba) { - Offset = Offset + (UINTN) MultU64x32 ((Lba - StartLba), BlockLength); - if (LbaAddress != NULL) { - *LbaAddress = FwhInstance->FvBase[Virtual] + Offset; - } - - if (LbaLength != NULL) { - *LbaLength = BlockLength; - } - - if (NumOfBlocks != NULL) { - *NumOfBlocks = (UINTN) (NextLba - Lba); - } - - return EFI_SUCCESS; - } - - StartLba = NextLba; - Offset = Offset + NumBlocks * BlockLength; - BlockMap++; - } -} - -EFI_STATUS -FvbReadBlock ( - IN UINTN Instance, - IN EFI_LBA Lba, - IN UINTN BlockOffset, - IN OUT UINTN *NumBytes, - IN UINT8 *Buffer, - IN ESAL_FWB_GLOBAL *Global, - IN BOOLEAN Virtual - ) -/*++ - -Routine Description: - Reads specified number of bytes into a buffer from the specified block - -Arguments: - Instance - The FV instance to be read from - Lba - The logical block address to be read from - BlockOffset - Offset into the block at which to begin reading - NumBytes - Pointer that on input contains the total size of - the buffer. On output, it contains the total number - of bytes read - Buffer - Pointer to a caller allocated buffer that will be - used to hold the data read - Global - Pointer to ESAL_FWB_GLOBAL that contains all - instance data - Virtual - Whether CPU is in virtual or physical mode - -Returns: - EFI_SUCCESS - The firmware volume was read successfully and - contents are in Buffer - EFI_BAD_BUFFER_SIZE - Read attempted across a LBA boundary. On output, - NumBytes contains the total number of bytes returned - in Buffer - EFI_ACCESS_DENIED - The firmware volume is in the ReadDisabled state - EFI_DEVICE_ERROR - The block device is not functioning correctly and - could not be read - EFI_INVALID_PARAMETER - Instance not found, or NumBytes, Buffer are NULL - ---*/ -{ - EFI_FVB_ATTRIBUTES_2 Attributes; - UINTN LbaAddress; - UINTN LbaLength; - EFI_STATUS Status; - - // - // Check for invalid conditions - // - if ((NumBytes == NULL) || (Buffer == NULL)) { - return EFI_INVALID_PARAMETER; - } - - if (*NumBytes == 0) { - return EFI_INVALID_PARAMETER; - } - - Status = FvbGetLbaAddress (Instance, Lba, &LbaAddress, &LbaLength, NULL, Global, Virtual); - if (EFI_ERROR (Status)) { - return Status; - } - // - // Check if the FV is read enabled - // - FvbGetVolumeAttributes (Instance, &Attributes, Global, Virtual); - - if ((Attributes & EFI_FVB2_READ_STATUS) == 0) { - return EFI_ACCESS_DENIED; - } - // - // Perform boundary checks and adjust NumBytes - // - if (BlockOffset > LbaLength) { - return EFI_INVALID_PARAMETER; - } - - if (LbaLength < (*NumBytes + BlockOffset)) { - *NumBytes = (UINT32) (LbaLength - BlockOffset); - Status = EFI_BAD_BUFFER_SIZE; - } - - CopyMem (Buffer, (UINT8 *) (LbaAddress + BlockOffset), (UINTN) (*NumBytes)); - - return Status; -} - -EFI_STATUS -FvbWriteBlock ( - IN UINTN Instance, - IN EFI_LBA Lba, - IN UINTN BlockOffset, - IN OUT UINTN *NumBytes, - IN UINT8 *Buffer, - IN ESAL_FWB_GLOBAL *Global, - IN BOOLEAN Virtual - ) -/*++ - -Routine Description: - Writes specified number of bytes from the input buffer to the block - -Arguments: - Instance - The FV instance to be written to - Lba - The starting logical block index to write to - BlockOffset - Offset into the block at which to begin writing - NumBytes - Pointer that on input contains the total size of - the buffer. On output, it contains the total number - of bytes actually written - Buffer - Pointer to a caller allocated buffer that contains - the source for the write - Global - Pointer to ESAL_FWB_GLOBAL that contains all - instance data - Virtual - Whether CPU is in virtual or physical mode - -Returns: - EFI_SUCCESS - The firmware volume was written successfully - EFI_BAD_BUFFER_SIZE - Write attempted across a LBA boundary. On output, - NumBytes contains the total number of bytes - actually written - EFI_ACCESS_DENIED - The firmware volume is in the WriteDisabled state - EFI_DEVICE_ERROR - The block device is not functioning correctly and - could not be written - EFI_INVALID_PARAMETER - Instance not found, or NumBytes, Buffer are NULL - ---*/ -{ - EFI_FVB_ATTRIBUTES_2 Attributes; - UINTN LbaAddress; - UINTN LbaLength; - EFI_STATUS Status; - - // - // Check for invalid conditions - // - if ((NumBytes == NULL) || (Buffer == NULL)) { - return EFI_INVALID_PARAMETER; - } - - if (*NumBytes == 0) { - return EFI_INVALID_PARAMETER; - } - - Status = FvbGetLbaAddress (Instance, Lba, &LbaAddress, &LbaLength, NULL, Global, Virtual); - if (EFI_ERROR (Status)) { - return Status; - } - // - // Check if the FV is write enabled - // - FvbGetVolumeAttributes (Instance, &Attributes, Global, Virtual); - - if ((Attributes & EFI_FVB2_WRITE_STATUS) == 0) { - return EFI_ACCESS_DENIED; - } - // - // Perform boundary checks and adjust NumBytes - // - if (BlockOffset > LbaLength) { - return EFI_INVALID_PARAMETER; - } - - if (LbaLength < (*NumBytes + BlockOffset)) { - *NumBytes = (UINT32) (LbaLength - BlockOffset); - Status = EFI_BAD_BUFFER_SIZE; - } - // - // Write data - // - CopyMem ((UINT8 *) (LbaAddress + BlockOffset), Buffer, (UINTN) (*NumBytes)); - - return Status; -} - -EFI_STATUS -FvbEraseBlock ( - IN UINTN Instance, - IN EFI_LBA Lba, - IN ESAL_FWB_GLOBAL *Global, - IN BOOLEAN Virtual - ) -/*++ - -Routine Description: - Erases and initializes a firmware volume block - -Arguments: - Instance - The FV instance to be erased - Lba - The logical block index to be erased - Global - Pointer to ESAL_FWB_GLOBAL that contains all - instance data - Virtual - Whether CPU is in virtual or physical mode - -Returns: - EFI_SUCCESS - The erase request was successfully completed - EFI_ACCESS_DENIED - The firmware volume is in the WriteDisabled state - EFI_DEVICE_ERROR - The block device is not functioning correctly and - could not be written. Firmware device may have been - partially erased - EFI_INVALID_PARAMETER - Instance not found - ---*/ -{ - - EFI_FVB_ATTRIBUTES_2 Attributes; - UINTN LbaAddress; - UINTN LbaLength; - EFI_STATUS Status; - UINT8 Data; - - // - // Check if the FV is write enabled - // - FvbGetVolumeAttributes (Instance, &Attributes, Global, Virtual); - - if ((Attributes & EFI_FVB2_WRITE_STATUS) == 0) { - return EFI_ACCESS_DENIED; - } - // - // Get the starting address of the block for erase. - // - Status = FvbGetLbaAddress (Instance, Lba, &LbaAddress, &LbaLength, NULL, Global, Virtual); - - if (EFI_ERROR (Status)) { - return Status; - } - - if ((Attributes & EFI_FVB2_ERASE_POLARITY) != 0) { - Data = 0xFF; - } else { - Data = 0x0; - } - - SetMem ((UINT8 *) LbaAddress, LbaLength, Data); - - return EFI_SUCCESS; -} - -EFI_STATUS -FvbSetVolumeAttributes ( - IN UINTN Instance, - IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes, - IN ESAL_FWB_GLOBAL *Global, - IN BOOLEAN Virtual - ) -/*++ - -Routine Description: - Modifies the current settings of the firmware volume according to the - input parameter, and returns the new setting of the volume - -Arguments: - Instance - The FV instance whose attributes is going to be - modified - Attributes - On input, it is a pointer to EFI_FVB_ATTRIBUTES_2 - containing the desired firmware volume settings. - On successful return, it contains the new settings - of the firmware volume - Global - Pointer to ESAL_FWB_GLOBAL that contains all - instance data - Virtual - Whether CPU is in virtual or physical mode - -Returns: - EFI_SUCCESS - Successfully returns - EFI_ACCESS_DENIED - The volume setting is locked and cannot be modified - EFI_INVALID_PARAMETER - Instance not found, or The attributes requested are - in conflict with the capabilities as declared in the - firmware volume header - ---*/ -{ - EFI_FW_VOL_INSTANCE *FwhInstance; - EFI_FVB_ATTRIBUTES_2 OldAttributes; - EFI_FVB_ATTRIBUTES_2 *AttribPtr; - UINT32 Capabilities; - UINT32 OldStatus; - UINT32 NewStatus; - EFI_STATUS Status; - EFI_FVB_ATTRIBUTES_2 UnchangedAttributes; - - // - // Find the right instance of the FVB private data - // - Status = GetFvbInstance (Instance, Global, &FwhInstance, Virtual); - ASSERT_EFI_ERROR (Status); - - AttribPtr = (EFI_FVB_ATTRIBUTES_2 *) &(FwhInstance->VolumeHeader.Attributes); - OldAttributes = *AttribPtr; - Capabilities = OldAttributes & (EFI_FVB2_READ_DISABLED_CAP | \ - EFI_FVB2_READ_ENABLED_CAP | \ - EFI_FVB2_WRITE_DISABLED_CAP | \ - EFI_FVB2_WRITE_ENABLED_CAP | \ - EFI_FVB2_LOCK_CAP \ - ); - OldStatus = OldAttributes & EFI_FVB2_STATUS; - NewStatus = *Attributes & EFI_FVB2_STATUS; - - UnchangedAttributes = EFI_FVB2_READ_DISABLED_CAP | \ - EFI_FVB2_READ_ENABLED_CAP | \ - EFI_FVB2_WRITE_DISABLED_CAP | \ - EFI_FVB2_WRITE_ENABLED_CAP | \ - EFI_FVB2_LOCK_CAP | \ - EFI_FVB2_STICKY_WRITE | \ - EFI_FVB2_MEMORY_MAPPED | \ - EFI_FVB2_ERASE_POLARITY | \ - EFI_FVB2_READ_LOCK_CAP | \ - EFI_FVB2_WRITE_LOCK_CAP | \ - EFI_FVB2_ALIGNMENT; - - // - // Some attributes of FV is read only can *not* be set - // - if ((OldAttributes & UnchangedAttributes) ^ (*Attributes & UnchangedAttributes)) { - return EFI_INVALID_PARAMETER; - } - // - // If firmware volume is locked, no status bit can be updated - // - if (OldAttributes & EFI_FVB2_LOCK_STATUS) { - if (OldStatus ^ NewStatus) { - return EFI_ACCESS_DENIED; - } - } - // - // Test read disable - // - if ((Capabilities & EFI_FVB2_READ_DISABLED_CAP) == 0) { - if ((NewStatus & EFI_FVB2_READ_STATUS) == 0) { - return EFI_INVALID_PARAMETER; - } - } - // - // Test read enable - // - if ((Capabilities & EFI_FVB2_READ_ENABLED_CAP) == 0) { - if (NewStatus & EFI_FVB2_READ_STATUS) { - return EFI_INVALID_PARAMETER; - } - } - // - // Test write disable - // - if ((Capabilities & EFI_FVB2_WRITE_DISABLED_CAP) == 0) { - if ((NewStatus & EFI_FVB2_WRITE_STATUS) == 0) { - return EFI_INVALID_PARAMETER; - } - } - // - // Test write enable - // - if ((Capabilities & EFI_FVB2_WRITE_ENABLED_CAP) == 0) { - if (NewStatus & EFI_FVB2_WRITE_STATUS) { - return EFI_INVALID_PARAMETER; - } - } - // - // Test lock - // - if ((Capabilities & EFI_FVB2_LOCK_CAP) == 0) { - if (NewStatus & EFI_FVB2_LOCK_STATUS) { - return EFI_INVALID_PARAMETER; - } - } - - *AttribPtr = (*AttribPtr) & (0xFFFFFFFF & (~EFI_FVB2_STATUS)); - *AttribPtr = (*AttribPtr) | NewStatus; - *Attributes = *AttribPtr; - - return EFI_SUCCESS; -} -// -// FVB protocol APIs -// -EFI_STATUS -EFIAPI -FvbProtocolGetPhysicalAddress ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - OUT EFI_PHYSICAL_ADDRESS *Address - ) -/*++ - -Routine Description: - - Retrieves the physical address of the device. - -Arguments: - - This - Calling context - Address - Output buffer containing the address. - -Returns: - -Returns: - EFI_SUCCESS - Successfully returns - ---*/ -{ - EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; - - FvbDevice = FVB_DEVICE_FROM_THIS (This); - - return FvbGetPhysicalAddress (FvbDevice->Instance, Address, mFvbModuleGlobal, EfiGoneVirtual ()); -} - -EFI_STATUS -EFIAPI -FvbProtocolGetBlockSize ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - IN CONST EFI_LBA Lba, - OUT UINTN *BlockSize, - OUT UINTN *NumOfBlocks - ) -/*++ - -Routine Description: - Retrieve the size of a logical block - -Arguments: - This - Calling context - Lba - Indicates which block to return the size for. - BlockSize - A pointer to a caller allocated UINTN in which - the size of the block is returned - NumOfBlocks - a pointer to a caller allocated UINTN in which the - number of consecutive blocks starting with Lba is - returned. All blocks in this range have a size of - BlockSize - -Returns: - EFI_SUCCESS - The firmware volume was read successfully and - contents are in Buffer - ---*/ -{ - EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; - - FvbDevice = FVB_DEVICE_FROM_THIS (This); - - return FvbGetLbaAddress ( - FvbDevice->Instance, - Lba, - NULL, - BlockSize, - NumOfBlocks, - mFvbModuleGlobal, - EfiGoneVirtual () - ); -} - -EFI_STATUS -EFIAPI -FvbProtocolGetAttributes ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - OUT EFI_FVB_ATTRIBUTES_2 *Attributes - ) -/*++ - -Routine Description: - Retrieves Volume attributes. No polarity translations are done. - -Arguments: - This - Calling context - Attributes - output buffer which contains attributes - -Returns: - EFI_SUCCESS - Successfully returns - ---*/ -{ - EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; - - FvbDevice = FVB_DEVICE_FROM_THIS (This); - - return FvbGetVolumeAttributes (FvbDevice->Instance, Attributes, mFvbModuleGlobal, EfiGoneVirtual ()); -} - -EFI_STATUS -EFIAPI -FvbProtocolSetAttributes ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes - ) -/*++ - -Routine Description: - Sets Volume attributes. No polarity translations are done. - -Arguments: - This - Calling context - Attributes - output buffer which contains attributes - -Returns: - EFI_SUCCESS - Successfully returns - ---*/ -{ - EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; - - FvbDevice = FVB_DEVICE_FROM_THIS (This); - - return FvbSetVolumeAttributes (FvbDevice->Instance, Attributes, mFvbModuleGlobal, EfiGoneVirtual ()); -} - -EFI_STATUS -EFIAPI -FvbProtocolEraseBlocks ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - ... - ) -/*++ - -Routine Description: - - The EraseBlock() function erases one or more blocks as denoted by the - variable argument list. The entire parameter list of blocks must be verified - prior to erasing any blocks. If a block is requested that does not exist - within the associated firmware volume (it has a larger index than the last - block of the firmware volume), the EraseBlock() function must return - EFI_INVALID_PARAMETER without modifying the contents of the firmware volume. - -Arguments: - This - Calling context - ... - Starting LBA followed by Number of Lba to erase. - a -1 to terminate the list. - -Returns: - EFI_SUCCESS - The erase request was successfully completed - EFI_ACCESS_DENIED - The firmware volume is in the WriteDisabled state - EFI_DEVICE_ERROR - The block device is not functioning correctly and - could not be written. Firmware device may have been - partially erased - ---*/ -{ - EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; - EFI_FW_VOL_INSTANCE *FwhInstance; - UINTN NumOfBlocks; - VA_LIST args; - EFI_LBA StartingLba; - UINTN NumOfLba; - EFI_STATUS Status; - - FvbDevice = FVB_DEVICE_FROM_THIS (This); - - Status = GetFvbInstance (FvbDevice->Instance, mFvbModuleGlobal, &FwhInstance, EfiGoneVirtual ()); - ASSERT_EFI_ERROR (Status); - - NumOfBlocks = FwhInstance->NumOfBlocks; - - VA_START (args, This); - - do { - StartingLba = VA_ARG (args, EFI_LBA); - if (StartingLba == EFI_LBA_LIST_TERMINATOR) { - break; - } - - NumOfLba = VA_ARG (args, UINTN); - - // - // Check input parameters - // - if ((NumOfLba == 0) || ((StartingLba + NumOfLba) > NumOfBlocks)) { - VA_END (args); - return EFI_INVALID_PARAMETER; - } - } while (1); - - VA_END (args); - - VA_START (args, This); - do { - StartingLba = VA_ARG (args, EFI_LBA); - if (StartingLba == EFI_LBA_LIST_TERMINATOR) { - break; - } - - NumOfLba = VA_ARG (args, UINTN); - - while (NumOfLba > 0) { - Status = FvbEraseBlock (FvbDevice->Instance, StartingLba, mFvbModuleGlobal, EfiGoneVirtual ()); - if (EFI_ERROR (Status)) { - VA_END (args); - return Status; - } - - StartingLba++; - NumOfLba--; - } - - } while (1); - - VA_END (args); - - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -FvbProtocolWrite ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - IN EFI_LBA Lba, - IN UINTN Offset, - IN OUT UINTN *NumBytes, - IN UINT8 *Buffer - ) -/*++ - -Routine Description: - - Writes data beginning at Lba:Offset from FV. The write terminates either - when *NumBytes of data have been written, or when a block boundary is - reached. *NumBytes is updated to reflect the actual number of bytes - written. The write opertion does not include erase. This routine will - attempt to write only the specified bytes. If the writes do not stick, - it will return an error. - -Arguments: - This - Calling context - Lba - Block in which to begin write - Offset - Offset in the block at which to begin write - NumBytes - On input, indicates the requested write size. On - output, indicates the actual number of bytes written - Buffer - Buffer containing source data for the write. - -Returns: - EFI_SUCCESS - The firmware volume was written successfully - EFI_BAD_BUFFER_SIZE - Write attempted across a LBA boundary. On output, - NumBytes contains the total number of bytes - actually written - EFI_ACCESS_DENIED - The firmware volume is in the WriteDisabled state - EFI_DEVICE_ERROR - The block device is not functioning correctly and - could not be written - EFI_INVALID_PARAMETER - NumBytes or Buffer are NULL - ---*/ -{ - - EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; - - FvbDevice = FVB_DEVICE_FROM_THIS (This); - - return FvbWriteBlock (FvbDevice->Instance, (EFI_LBA)Lba, (UINTN)Offset, NumBytes, (UINT8 *)Buffer, mFvbModuleGlobal, EfiGoneVirtual ()); -} - -EFI_STATUS -EFIAPI -FvbProtocolRead ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - IN CONST EFI_LBA Lba, - IN CONST UINTN Offset, - IN OUT UINTN *NumBytes, - IN UINT8 *Buffer - ) -/*++ - -Routine Description: - - Reads data beginning at Lba:Offset from FV. The Read terminates either - when *NumBytes of data have been read, or when a block boundary is - reached. *NumBytes is updated to reflect the actual number of bytes - written. The write opertion does not include erase. This routine will - attempt to write only the specified bytes. If the writes do not stick, - it will return an error. - -Arguments: - This - Calling context - Lba - Block in which to begin Read - Offset - Offset in the block at which to begin Read - NumBytes - On input, indicates the requested write size. On - output, indicates the actual number of bytes Read - Buffer - Buffer containing source data for the Read. - -Returns: - EFI_SUCCESS - The firmware volume was read successfully and - contents are in Buffer - EFI_BAD_BUFFER_SIZE - Read attempted across a LBA boundary. On output, - NumBytes contains the total number of bytes returned - in Buffer - EFI_ACCESS_DENIED - The firmware volume is in the ReadDisabled state - EFI_DEVICE_ERROR - The block device is not functioning correctly and - could not be read - EFI_INVALID_PARAMETER - NumBytes or Buffer are NULL - ---*/ -{ - - EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; - - FvbDevice = FVB_DEVICE_FROM_THIS (This); - - return FvbReadBlock (FvbDevice->Instance, Lba, Offset, NumBytes, Buffer, mFvbModuleGlobal, EfiGoneVirtual ()); -} - -EFI_STATUS -ValidateFvHeader ( - EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader - ) -/*++ - -Routine Description: - Check the integrity of firmware volume header - -Arguments: - FwVolHeader - A pointer to a firmware volume header - -Returns: - EFI_SUCCESS - The firmware volume is consistent - EFI_NOT_FOUND - The firmware volume has corrupted. So it is not an FV - ---*/ -{ - // - // Verify the header revision, header signature, length - // Length of FvBlock cannot be 2**64-1 - // HeaderLength cannot be an odd number - // - if ((FwVolHeader->Revision != EFI_FVH_REVISION) || - (FwVolHeader->Signature != EFI_FVH_SIGNATURE) || - (FwVolHeader->FvLength == ((UINTN) -1)) || - ((FwVolHeader->HeaderLength & 0x01) != 0) - ) { - return EFI_NOT_FOUND; - } - - // - // Verify the header checksum - // - if (CalculateCheckSum16 ((UINT16 *) FwVolHeader, FwVolHeader->HeaderLength) != 0) { - return EFI_NOT_FOUND; - } - - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -FvbInitialize ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -/*++ - -Routine Description: - This function does common initialization for FVB services - -Arguments: - -Returns: - ---*/ -{ - EFI_STATUS Status; - EFI_FW_VOL_INSTANCE *FwhInstance; - EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader; - EFI_DXE_SERVICES *DxeServices; - EFI_GCD_MEMORY_SPACE_DESCRIPTOR Descriptor; - UINT32 BufferSize; - EFI_FV_BLOCK_MAP_ENTRY *PtrBlockMapEntry; - EFI_HANDLE FwbHandle; - EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; - EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *OldFwbInterface; - UINT32 MaxLbaSize; - EFI_PHYSICAL_ADDRESS BaseAddress; - UINT64 Length; - UINTN NumOfBlocks; - EFI_PEI_HOB_POINTERS FvHob; - - // - // Get the DXE services table - // - DxeServices = gDS; - - // - // Allocate runtime services data for global variable, which contains - // the private data of all firmware volume block instances - // - mFvbModuleGlobal = AllocateRuntimePool (sizeof (ESAL_FWB_GLOBAL)); - ASSERT (mFvbModuleGlobal != NULL); - - // - // Calculate the total size for all firmware volume block instances - // - BufferSize = 0; - - FvHob.Raw = GetHobList (); - while ((FvHob.Raw = GetNextHob (EFI_HOB_TYPE_FV, FvHob.Raw)) != NULL) { - BaseAddress = FvHob.FirmwareVolume->BaseAddress; - Length = FvHob.FirmwareVolume->Length; - // - // Check if it is a "real" flash - // - Status = DxeServices->GetMemorySpaceDescriptor ( - BaseAddress, - &Descriptor - ); - if (EFI_ERROR (Status)) { - break; - } - - if (Descriptor.GcdMemoryType != EfiGcdMemoryTypeMemoryMappedIo) { - FvHob.Raw = GET_NEXT_HOB (FvHob); - continue; - } - - FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) BaseAddress; - Status = ValidateFvHeader (FwVolHeader); - if (EFI_ERROR (Status)) { - // - // Get FvbInfo - // - Status = GetFvbInfo (Length, &FwVolHeader); - if (EFI_ERROR (Status)) { - FvHob.Raw = GET_NEXT_HOB (FvHob); - continue; - } - } - - BufferSize += (sizeof (EFI_FW_VOL_INSTANCE) + FwVolHeader->HeaderLength - sizeof (EFI_FIRMWARE_VOLUME_HEADER)); - FvHob.Raw = GET_NEXT_HOB (FvHob); - } - - // - // Only need to allocate once. There is only one copy of physical memory for - // the private data of each FV instance. But in virtual mode or in physical - // mode, the address of the the physical memory may be different. - // - mFvbModuleGlobal->FvInstance[FVB_PHYSICAL] = AllocateRuntimePool (BufferSize); - ASSERT (mFvbModuleGlobal->FvInstance[FVB_PHYSICAL] != NULL); - - // - // Make a virtual copy of the FvInstance pointer. - // - FwhInstance = mFvbModuleGlobal->FvInstance[FVB_PHYSICAL]; - mFvbModuleGlobal->FvInstance[FVB_VIRTUAL] = FwhInstance; - - mFvbModuleGlobal->NumFv = 0; - MaxLbaSize = 0; - - FvHob.Raw = GetHobList (); - while (NULL != (FvHob.Raw = GetNextHob (EFI_HOB_TYPE_FV, FvHob.Raw))) { - BaseAddress = FvHob.FirmwareVolume->BaseAddress; - Length = FvHob.FirmwareVolume->Length; - // - // Check if it is a "real" flash - // - Status = DxeServices->GetMemorySpaceDescriptor ( - BaseAddress, - &Descriptor - ); - if (EFI_ERROR (Status)) { - break; - } - - if (Descriptor.GcdMemoryType != EfiGcdMemoryTypeMemoryMappedIo) { - FvHob.Raw = GET_NEXT_HOB (FvHob); - continue; - } - - FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) BaseAddress; - Status = ValidateFvHeader (FwVolHeader); - if (EFI_ERROR (Status)) { - // - // Get FvbInfo to provide in FwhInstance. - // - Status = GetFvbInfo (Length, &FwVolHeader); - if (EFI_ERROR (Status)) { - FvHob.Raw = GET_NEXT_HOB (FvHob); - continue; - } - // - // Write healthy FV header back. - // - CopyMem ( - (VOID *) (UINTN) BaseAddress, - (VOID *) FwVolHeader, - FwVolHeader->HeaderLength - ); - } - - FwhInstance->FvBase[FVB_PHYSICAL] = (UINTN) BaseAddress; - FwhInstance->FvBase[FVB_VIRTUAL] = (UINTN) BaseAddress; - - CopyMem ((UINTN *) &(FwhInstance->VolumeHeader), (UINTN *) FwVolHeader, FwVolHeader->HeaderLength); - FwVolHeader = &(FwhInstance->VolumeHeader); - EfiInitializeLock (&(FwhInstance->FvbDevLock), TPL_HIGH_LEVEL); - - NumOfBlocks = 0; - - for (PtrBlockMapEntry = FwVolHeader->BlockMap; PtrBlockMapEntry->NumBlocks != 0; PtrBlockMapEntry++) { - // - // Get the maximum size of a block. - // - if (MaxLbaSize < PtrBlockMapEntry->Length) { - MaxLbaSize = PtrBlockMapEntry->Length; - } - - NumOfBlocks = NumOfBlocks + PtrBlockMapEntry->NumBlocks; - } - // - // The total number of blocks in the FV. - // - FwhInstance->NumOfBlocks = NumOfBlocks; - - // - // Add a FVB Protocol Instance - // - FvbDevice = AllocateRuntimePool (sizeof (EFI_FW_VOL_BLOCK_DEVICE)); - ASSERT (FvbDevice != NULL); - - CopyMem (FvbDevice, &mFvbDeviceTemplate, sizeof (EFI_FW_VOL_BLOCK_DEVICE)); - - FvbDevice->Instance = mFvbModuleGlobal->NumFv; - mFvbModuleGlobal->NumFv++; - - - // - // Set up the devicepath - // - if (FwVolHeader->ExtHeaderOffset == 0) { - // - // FV does not contains extension header, then produce MEMMAP_DEVICE_PATH - // - FvbDevice->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) AllocateCopyPool (sizeof (FV_MEMMAP_DEVICE_PATH), &mFvMemmapDevicePathTemplate); - ((FV_MEMMAP_DEVICE_PATH *) FvbDevice->DevicePath)->MemMapDevPath.StartingAddress = BaseAddress; - ((FV_MEMMAP_DEVICE_PATH *) FvbDevice->DevicePath)->MemMapDevPath.EndingAddress = BaseAddress + FwVolHeader->FvLength - 1; - } else { - FvbDevice->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) AllocateCopyPool (sizeof (FV_PIWG_DEVICE_PATH), &mFvPIWGDevicePathTemplate); - CopyGuid ( - &((FV_PIWG_DEVICE_PATH *)FvbDevice->DevicePath)->FvDevPath.FvName, - (GUID *)(UINTN)(BaseAddress + FwVolHeader->ExtHeaderOffset) - ); - } - // - // Find a handle with a matching device path that has supports FW Block protocol - // - Status = gBS->LocateDevicePath (&gEfiFirmwareVolumeBlockProtocolGuid, &FvbDevice->DevicePath, &FwbHandle); - if (EFI_ERROR (Status)) { - // - // LocateDevicePath fails so install a new interface and device path - // - FwbHandle = NULL; - Status = gBS->InstallMultipleProtocolInterfaces ( - &FwbHandle, - &gEfiFirmwareVolumeBlockProtocolGuid, - &FvbDevice->FwVolBlockInstance, - &gEfiDevicePathProtocolGuid, - FvbDevice->DevicePath, - NULL - ); - ASSERT_EFI_ERROR (Status); - } else if (IsDevicePathEnd (FvbDevice->DevicePath)) { - // - // Device allready exists, so reinstall the FVB protocol - // - Status = gBS->HandleProtocol ( - FwbHandle, - &gEfiFirmwareVolumeBlockProtocolGuid, - (VOID**)&OldFwbInterface - ); - ASSERT_EFI_ERROR (Status); - - Status = gBS->ReinstallProtocolInterface ( - FwbHandle, - &gEfiFirmwareVolumeBlockProtocolGuid, - OldFwbInterface, - &FvbDevice->FwVolBlockInstance - ); - ASSERT_EFI_ERROR (Status); - - } else { - // - // There was a FVB protocol on an End Device Path node - // - ASSERT (FALSE); - } - - FwhInstance = (EFI_FW_VOL_INSTANCE *) - ( - (UINTN) ((UINT8 *) FwhInstance) + FwVolHeader->HeaderLength + - (sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER)) - ); - - FvHob.Raw = GET_NEXT_HOB (FvHob); - } - - return EFI_SUCCESS; -} diff --git a/Nt32Pkg/FvbServicesRuntimeDxe/FvbInfo.c b/Nt32Pkg/FvbServicesRuntimeDxe/FvbInfo.c deleted file mode 100644 index 1b4d082828..0000000000 --- a/Nt32Pkg/FvbServicesRuntimeDxe/FvbInfo.c +++ /dev/null @@ -1,154 +0,0 @@ -/**@file - -Copyright (c) 2006, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - FvbInfo.c - -Abstract: - - Defines data structure that is the volume header found.These data is intent - to decouple FVB driver with FV header. - -**/ - -// -// The package level header files this module uses -// -#include -#include -// -// The protocols, PPI and GUID defintions for this module -// -#include -#include -#include -#include -#include -// -// The Library classes this module consumes -// -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -typedef struct { - UINT64 FvLength; - EFI_FIRMWARE_VOLUME_HEADER FvbInfo; - // - // EFI_FV_BLOCK_MAP_ENTRY ExtraBlockMap[n];//n=0 - // - EFI_FV_BLOCK_MAP_ENTRY End[1]; -} EFI_FVB_MEDIA_INFO; - -EFI_FVB_MEDIA_INFO mPlatformFvbMediaInfo[] = { - // - // Recovery BOIS FVB - // - { - FixedPcdGet32 (PcdWinNtFlashFvRecoverySize), - { - { - 0, - }, // ZeroVector[16] - EFI_FIRMWARE_FILE_SYSTEM2_GUID, - FixedPcdGet32 (PcdWinNtFlashFvRecoverySize), - EFI_FVH_SIGNATURE, - EFI_FVB2_MEMORY_MAPPED | - EFI_FVB2_READ_ENABLED_CAP | - EFI_FVB2_READ_STATUS | - EFI_FVB2_WRITE_ENABLED_CAP | - EFI_FVB2_WRITE_STATUS | - EFI_FVB2_ERASE_POLARITY | - EFI_FVB2_ALIGNMENT_16, - sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY), - 0xE947, // CheckSum - 0, // ExtHeaderOffset - { - 0, - }, // Reserved[1] - 2, // Revision - { - FixedPcdGet32 (PcdWinNtFlashFvRecoverySize)/FixedPcdGet32 (PcdWinNtFirmwareBlockSize), - FixedPcdGet32 (PcdWinNtFirmwareBlockSize), - } - }, - { - 0, - 0 - } - }, - // - // Systen NvStorage FVB - // - { - FixedPcdGet32 (PcdFlashNvStorageVariableSize) + - FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + - FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + - FixedPcdGet32 (PcdWinNtFlashNvStorageEventLogSize), - { - { - 0, - }, // ZeroVector[16] - EFI_SYSTEM_NV_DATA_FV_GUID, - FixedPcdGet32 (PcdFlashNvStorageVariableSize) + - FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + - FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + - FixedPcdGet32 (PcdWinNtFlashNvStorageEventLogSize), - EFI_FVH_SIGNATURE, - EFI_FVB2_MEMORY_MAPPED | - EFI_FVB2_READ_ENABLED_CAP | - EFI_FVB2_READ_STATUS | - EFI_FVB2_WRITE_ENABLED_CAP | - EFI_FVB2_WRITE_STATUS | - EFI_FVB2_ERASE_POLARITY | - EFI_FVB2_ALIGNMENT_16, - sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY), - 0xFBFF, // CheckSum - 0, // ExtHeaderOffset - { - 0, - }, // Reserved[1] - 2, // Revision - { - (FixedPcdGet32 (PcdFlashNvStorageVariableSize) + - FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + - FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + - FixedPcdGet32 (PcdWinNtFlashNvStorageEventLogSize)) / FixedPcdGet32 (PcdWinNtFirmwareBlockSize), - FixedPcdGet32 (PcdWinNtFirmwareBlockSize), - } - }, - { - 0, - 0 - } - } -}; - -EFI_STATUS -GetFvbInfo ( - IN UINT64 FvLength, - OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo - ) -{ - UINTN Index; - - for (Index = 0; Index < sizeof (mPlatformFvbMediaInfo) / sizeof (EFI_FVB_MEDIA_INFO); Index += 1) { - if (mPlatformFvbMediaInfo[Index].FvLength == FvLength) { - *FvbInfo = &mPlatformFvbMediaInfo[Index].FvbInfo; - return EFI_SUCCESS; - } - } - - return EFI_NOT_FOUND; -} diff --git a/Nt32Pkg/FvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf b/Nt32Pkg/FvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf deleted file mode 100644 index 1d7c86f9c7..0000000000 --- a/Nt32Pkg/FvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf +++ /dev/null @@ -1,75 +0,0 @@ -## @file -# Component description file for Nt32 Fimware Volume Block DXE driver module. -# -# This DXE runtime driver implements and produces the Fimware Volue Block Protocol on -# NT32 emulator. -# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
-# -# SPDX-License-Identifier: BSD-2-Clause-Patent -# -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = FvbServicesRuntimeDxe - FILE_GUID = BDFE5FAA-2A35-44bb-B17A-8084D4E2B9E9 - MODULE_TYPE = DXE_RUNTIME_DRIVER - VERSION_STRING = 1.0 - ENTRY_POINT = FvbInitialize - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 -# - -[Sources] - FvbInfo.c - FwBlockService.h - FWBlockService.c - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - Nt32Pkg/Nt32Pkg.dec - -[LibraryClasses] - UefiBootServicesTableLib - MemoryAllocationLib - BaseMemoryLib - HobLib - DebugLib - UefiRuntimeLib - DxeServicesTableLib - BaseLib - UefiDriverEntryPoint - UefiLib - PcdLib - -[Guids] - gEfiEventVirtualAddressChangeGuid # ALWAYS_CONSUMED Create Event: EVENT_GROUP_GUID - -[Protocols] - gEfiFirmwareVolumeBlockProtocolGuid # PROTOCOL ALWAYS_PRODUCED - gEfiDevicePathProtocolGuid # PROTOCOL SOMETIMES_PRODUCED - -[FixedPcd] - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize - gEfiNt32PkgTokenSpaceGuid.PcdWinNtFlashFvRecoverySize - gEfiNt32PkgTokenSpaceGuid.PcdWinNtFirmwareBlockSize - gEfiNt32PkgTokenSpaceGuid.PcdWinNtFlashNvStorageEventLogSize - -[Pcd] - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase - gEfiNt32PkgTokenSpaceGuid.PcdWinNtFirmwareFdSize - gEfiNt32PkgTokenSpaceGuid.PcdWinNtFlashFvRecoveryBase - gEfiNt32PkgTokenSpaceGuid.PcdWinNtFlashNvStorageEventLogBase - -[Depex] - TRUE - diff --git a/Nt32Pkg/FvbServicesRuntimeDxe/FwBlockService.h b/Nt32Pkg/FvbServicesRuntimeDxe/FwBlockService.h deleted file mode 100644 index cdf6b1f583..0000000000 --- a/Nt32Pkg/FvbServicesRuntimeDxe/FwBlockService.h +++ /dev/null @@ -1,208 +0,0 @@ -/**@file - -Copyright (c) 2006, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - FwBlockService.h - -Abstract: - - Firmware volume block driver for Intel Firmware Hub (FWH) device - -**/ - -#ifndef _FW_BLOCK_SERVICE_H -#define _FW_BLOCK_SERVICE_H - -// -// BugBug: Add documentation here for data structure!!!! -// -#define FVB_PHYSICAL 0 -#define FVB_VIRTUAL 1 - -typedef struct { - EFI_LOCK FvbDevLock; - UINTN FvBase[2]; - UINTN NumOfBlocks; - EFI_FIRMWARE_VOLUME_HEADER VolumeHeader; -} EFI_FW_VOL_INSTANCE; - -typedef struct { - UINT32 NumFv; - EFI_FW_VOL_INSTANCE *FvInstance[2]; - UINT8 *FvbScratchSpace[2]; -} ESAL_FWB_GLOBAL; - -// -// Fvb Protocol instance data -// -#define FVB_DEVICE_FROM_THIS(a) CR (a, EFI_FW_VOL_BLOCK_DEVICE, FwVolBlockInstance, FVB_DEVICE_SIGNATURE) -#define FVB_EXTEND_DEVICE_FROM_THIS(a) CR (a, EFI_FW_VOL_BLOCK_DEVICE, FvbExtension, FVB_DEVICE_SIGNATURE) -#define FVB_DEVICE_SIGNATURE SIGNATURE_32 ('F', 'V', 'B', 'N') - -typedef struct { - MEDIA_FW_VOL_DEVICE_PATH FvDevPath; - EFI_DEVICE_PATH_PROTOCOL EndDevPath; -} FV_PIWG_DEVICE_PATH; - -typedef struct { - MEMMAP_DEVICE_PATH MemMapDevPath; - EFI_DEVICE_PATH_PROTOCOL EndDevPath; -} FV_MEMMAP_DEVICE_PATH; - -typedef struct { - UINTN Signature; - EFI_DEVICE_PATH_PROTOCOL *DevicePath; - UINTN Instance; - EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL FwVolBlockInstance; -} EFI_FW_VOL_BLOCK_DEVICE; - -EFI_STATUS -GetFvbInfo ( - IN UINT64 FvLength, - OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo - ); - -EFI_STATUS -FvbReadBlock ( - IN UINTN Instance, - IN EFI_LBA Lba, - IN UINTN BlockOffset, - IN OUT UINTN *NumBytes, - IN UINT8 *Buffer, - IN ESAL_FWB_GLOBAL *Global, - IN BOOLEAN Virtual - ); - -EFI_STATUS -FvbWriteBlock ( - IN UINTN Instance, - IN CONST EFI_LBA Lba, - IN CONST UINTN BlockOffset, - IN OUT UINTN *NumBytes, - IN CONST UINT8 *Buffer, - IN ESAL_FWB_GLOBAL *Global, - IN BOOLEAN Virtual - ); - -EFI_STATUS -FvbEraseBlock ( - IN UINTN Instance, - IN EFI_LBA Lba, - IN ESAL_FWB_GLOBAL *Global, - IN BOOLEAN Virtual - ); - -EFI_STATUS -FvbSetVolumeAttributes ( - IN UINTN Instance, - IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes, - IN ESAL_FWB_GLOBAL *Global, - IN BOOLEAN Virtual - ); - -EFI_STATUS -FvbGetVolumeAttributes ( - IN UINTN Instance, - OUT EFI_FVB_ATTRIBUTES_2 *Attributes, - IN ESAL_FWB_GLOBAL *Global, - IN BOOLEAN Virtual - ); - -EFI_STATUS -FvbGetPhysicalAddress ( - IN UINTN Instance, - OUT EFI_PHYSICAL_ADDRESS *Address, - IN ESAL_FWB_GLOBAL *Global, - IN BOOLEAN Virtual - ); - -EFI_STATUS -EFIAPI -FvbInitialize ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ); - - -VOID -EFIAPI -FvbClassAddressChangeEvent ( - IN EFI_EVENT Event, - IN VOID *Context - ); - -EFI_STATUS -FvbGetLbaAddress ( - IN UINTN Instance, - IN EFI_LBA Lba, - OUT UINTN *LbaAddress, - OUT UINTN *LbaLength, - OUT UINTN *NumOfBlocks, - IN ESAL_FWB_GLOBAL *Global, - IN BOOLEAN Virtual - ); - -// -// Protocol APIs -// -EFI_STATUS -EFIAPI -FvbProtocolGetAttributes ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - OUT EFI_FVB_ATTRIBUTES_2 *Attributes - ); - -EFI_STATUS -EFIAPI -FvbProtocolSetAttributes ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes - ); - -EFI_STATUS -EFIAPI -FvbProtocolGetPhysicalAddress ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - OUT EFI_PHYSICAL_ADDRESS *Address - ); - -EFI_STATUS -EFIAPI -FvbProtocolGetBlockSize ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - IN CONST EFI_LBA Lba, - OUT UINTN *BlockSize, - OUT UINTN *NumOfBlocks - ); - -EFI_STATUS -EFIAPI -FvbProtocolRead ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - IN CONST EFI_LBA Lba, - IN CONST UINTN Offset, - IN OUT UINTN *NumBytes, - IN UINT8 *Buffer - ); - -EFI_STATUS -EFIAPI -FvbProtocolWrite ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - IN EFI_LBA Lba, - IN UINTN Offset, - IN OUT UINTN *NumBytes, - IN UINT8 *Buffer - ); - -EFI_STATUS -EFIAPI -FvbProtocolEraseBlocks ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - ... - ); - -#endif diff --git a/Nt32Pkg/Include/Common/WinNTInclude.h b/Nt32Pkg/Include/Common/WinNTInclude.h deleted file mode 100644 index 345d15d376..0000000000 --- a/Nt32Pkg/Include/Common/WinNTInclude.h +++ /dev/null @@ -1,74 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - WinNtLib.h - -Abstract: - Public include file for the WinNt Library - -**/ - -#ifndef __WIN_NT_INCLUDE_H__ -#define __WIN_NT_INCLUDE_H__ - -// -// Win32 include files do not compile clean with /W4, so we use the warning -// pragma to suppress the warnings for Win32 only. This way our code can stil -// compile at /W4 (highest warning level) with /WX (warnings cause build -// errors). -// -#pragma warning(disable : 4115) -#pragma warning(disable : 4201) -#pragma warning(disable : 4028) -#pragma warning(disable : 4133) - -#define GUID _WINNT_DUP_GUID_____ -#define _LIST_ENTRY _WINNT_DUP_LIST_ENTRY_FORWARD -#define LIST_ENTRY _WINNT_DUP_LIST_ENTRY -#if defined (MDE_CPU_IA32) && (_MSC_VER < 1800) -#define InterlockedIncrement _WINNT_DUP_InterlockedIncrement -#define InterlockedDecrement _WINNT_DUP_InterlockedDecrement -#define InterlockedCompareExchange64 _WINNT_DUP_InterlockedCompareExchange64 -#endif -#undef UNALIGNED -#undef CONST -#undef VOID -#undef DEBUG_EVENT - -// WQBugBug: This typedef is to make "windows.h" buildable. -// It should be removed after the root cause why -// size_t is undefined when go into the line below is found. -#if defined (MDE_CPU_IA32) -typedef UINT32 size_t ; -#endif - -#include "windows.h" - -#undef GUID -#undef _LIST_ENTRY -#undef LIST_ENTRY -#undef InterlockedIncrement -#undef InterlockedDecrement -#undef InterlockedCompareExchange64 -#undef InterlockedCompareExchangePointer -#undef CreateEventEx - -#define VOID void - -// -// Prevent collisions with Windows API name macros that deal with Unicode/Not issues -// -#undef LoadImage -#undef CreateEvent - -// -// Set the warnings back on as the EFI code must be /W4. -// -#pragma warning(default : 4115) -#pragma warning(default : 4201) - - -#endif diff --git a/Nt32Pkg/Include/Guid/WinNtSystemConfig.h b/Nt32Pkg/Include/Guid/WinNtSystemConfig.h deleted file mode 100644 index 975de36e42..0000000000 --- a/Nt32Pkg/Include/Guid/WinNtSystemConfig.h +++ /dev/null @@ -1,29 +0,0 @@ -/**@file - Setup Variable data structure for NT32 platform. - -Copyright (c) 2009, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - - -**/ - -#ifndef __WIN_NT_SYSTEM_CONFIGUE_H__ -#define __WIN_NT_SYSTEM_CONFIGUE_H__ - -#define EFI_WIN_NT_SYSTEM_CONFIG_GUID \ - { 0xb347f047, 0xaf8c, 0x490e, { 0xac, 0x07, 0x0a, 0xa9, 0xb7, 0xe5, 0x38, 0x58 }} - -#pragma pack(1) -typedef struct { - // - // Console output mode - // - UINT32 ConOutColumn; - UINT32 ConOutRow; -} WIN_NT_SYSTEM_CONFIGURATION; -#pragma pack() - - -extern EFI_GUID gEfiWinNtSystemConfigGuid; - -#endif diff --git a/Nt32Pkg/Include/Library/WinNtLib.h b/Nt32Pkg/Include/Library/WinNtLib.h deleted file mode 100644 index a3e3152b23..0000000000 --- a/Nt32Pkg/Include/Library/WinNtLib.h +++ /dev/null @@ -1,16 +0,0 @@ -/** @file - Public include file for the WinNt Library - -Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#ifndef __WIN_NT_LIB_H__ -#define __WIN_NT_LIB_H__ - -#include - -extern EFI_WIN_NT_THUNK_PROTOCOL *gWinNt; - -#endif diff --git a/Nt32Pkg/Include/Ppi/NtAutoscan.h b/Nt32Pkg/Include/Ppi/NtAutoscan.h deleted file mode 100644 index 130112ad13..0000000000 --- a/Nt32Pkg/Include/Ppi/NtAutoscan.h +++ /dev/null @@ -1,60 +0,0 @@ -/**@file - -Copyright (c) 2006, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - NtAutoscan.h - -Abstract: - -Nt Autoscan PPI - -**/ - -#ifndef __NT_PEI_AUTOSCAN_H__ -#define __NT_PEI_AUTOSCAN_H__ - -#include - -#define PEI_NT_AUTOSCAN_PPI_GUID \ - { \ - 0xdce384d, 0x7c, 0x4ba5, {0x94, 0xbd, 0xf, 0x6e, 0xb6, 0x4d, 0x2a, 0xa9 } \ - } - -typedef -EFI_STATUS -(EFIAPI *PEI_NT_AUTOSCAN) ( - IN UINTN Index, - OUT EFI_PHYSICAL_ADDRESS * MemoryBase, - OUT UINT64 *MemorySize - ); - -/*++ - -Routine Description: - This service is called from Index == 0 until it returns EFI_UNSUPPORTED. - It allows discontinuous memory regions to be supported by the emulator. - It uses gSystemMemory[] and gSystemMemoryCount that were created by - parsing the Windows environment variable EFI_MEMORY_SIZE. - The size comes from the varaible and the address comes from the call to - WinNtOpenFile. - -Arguments: - Index - Which memory region to use - MemoryBase - Return Base address of memory region - MemorySize - Return size in bytes of the memory region - -Returns: - EFI_SUCCESS - If memory region was mapped - EFI_UNSUPPORTED - If Index is not supported - ---*/ -typedef struct { - PEI_NT_AUTOSCAN NtAutoScan; -} PEI_NT_AUTOSCAN_PPI; - -extern EFI_GUID gPeiNtAutoScanPpiGuid; - -#endif diff --git a/Nt32Pkg/Include/Ppi/NtFwh.h b/Nt32Pkg/Include/Ppi/NtFwh.h deleted file mode 100644 index 711d44d694..0000000000 --- a/Nt32Pkg/Include/Ppi/NtFwh.h +++ /dev/null @@ -1,56 +0,0 @@ -/**@file - -Copyright (c) 2006, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - NtFwh.h - -Abstract: - - WinNt FWH PPI as defined in Tiano - -**/ - -#ifndef __NT_PEI_FWH_H__ -#define __NT_PEI_FWH_H__ - -#include - -#define NT_FWH_PPI_GUID \ - { \ - 0x4e76928f, 0x50ad, 0x4334, {0xb0, 0x6b, 0xa8, 0x42, 0x13, 0x10, 0x8a, 0x57 } \ - } - -typedef -EFI_STATUS -(EFIAPI *NT_FWH_INFORMATION) ( - IN UINTN Index, - IN OUT EFI_PHYSICAL_ADDRESS * FdBase, - IN OUT UINT64 *FdSize - ); - -/*++ - -Routine Description: - Return the FD Size and base address. Since the FD is loaded from a - file into Windows memory only the SEC will know it's address. - -Arguments: - Index - Which FD, starts at zero. - FdSize - Size of the FD in bytes - FdBase - Start address of the FD. Assume it points to an FV Header - -Returns: - EFI_SUCCESS - Return the Base address and size of the FV - EFI_UNSUPPORTED - Index does nto map to an FD in the system - ---*/ -typedef struct { - NT_FWH_INFORMATION NtFwh; -} NT_FWH_PPI; - -extern EFI_GUID gNtFwhPpiGuid; - -#endif diff --git a/Nt32Pkg/Include/Ppi/NtPeiLoadFile.h b/Nt32Pkg/Include/Ppi/NtPeiLoadFile.h deleted file mode 100644 index c961e35c4e..0000000000 --- a/Nt32Pkg/Include/Ppi/NtPeiLoadFile.h +++ /dev/null @@ -1,59 +0,0 @@ -/**@file - -Copyright (c) 2006, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - NtPeiLoadFile.h - -Abstract: - - WinNt Load File PPI. - - When the PEI core is done it calls the DXE IPL via PPI - -**/ - -#ifndef __NT_PEI_LOAD_FILE_H__ -#define __NT_PEI_LOAD_FILE_H__ - -#include - -#define NT_PEI_LOAD_FILE_GUID \ - { \ - 0xfd0c65eb, 0x405, 0x4cd2, {0x8a, 0xee, 0xf4, 0x0, 0xef, 0x13, 0xba, 0xc2 } \ - } - -typedef -EFI_STATUS -(EFIAPI *NT_PEI_LOAD_FILE) ( - VOID *Pe32Data, - EFI_PHYSICAL_ADDRESS *ImageAddress, - UINT64 *ImageSize, - EFI_PHYSICAL_ADDRESS *EntryPoint - ); - -/*++ - -Routine Description: - Loads and relocates a PE/COFF image into memory. - -Arguments: - Pe32Data - The base address of the PE/COFF file that is to be loaded and relocated - ImageAddress - The base address of the relocated PE/COFF image - ImageSize - The size of the relocated PE/COFF image - EntryPoint - The entry point of the relocated PE/COFF image - -Returns: - EFI_SUCCESS - The file was loaded and relocated - EFI_OUT_OF_RESOURCES - There was not enough memory to load and relocate the PE/COFF file - ---*/ -typedef struct { - NT_PEI_LOAD_FILE PeiLoadFileService; -} NT_PEI_LOAD_FILE_PPI; - -extern EFI_GUID gNtPeiLoadFilePpiGuid; - -#endif diff --git a/Nt32Pkg/Include/Ppi/NtThunk.h b/Nt32Pkg/Include/Ppi/NtThunk.h deleted file mode 100644 index a585bfb0b2..0000000000 --- a/Nt32Pkg/Include/Ppi/NtThunk.h +++ /dev/null @@ -1,50 +0,0 @@ -/**@file - -Copyright (c) 2006, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - NtThunk.h - -Abstract: - - WinNt Thunk interface PPI - -**/ - -#ifndef __NT_PEI_WIN_NT_THUNK_H__ -#define __NT_PEI_WIN_NT_THUNK_H__ - -#include - -#define PEI_NT_THUNK_PPI_GUID \ - { \ - 0x98c281e5, 0xf906, 0x43dd, {0xa9, 0x2b, 0xb0, 0x3, 0xbf, 0x27, 0x65, 0xda } \ - } - -typedef -VOID * -(EFIAPI *PEI_NT_THUNK_INTERFACE) ( - VOID - ); - -/*++ - -Routine Description: - Export of EFI_WIN_NT_THUNK_PROTOCOL from the Windows SEC. - -Arguments: - InterfaceBase - Address of the EFI_WIN_NT_THUNK_PROTOCOL - -Returns: - EFI_SUCCESS - Data returned - ---*/ -typedef struct { - PEI_NT_THUNK_INTERFACE NtThunk; -} PEI_NT_THUNK_PPI; - -extern EFI_GUID gPeiNtThunkPpiGuid; - -#endif diff --git a/Nt32Pkg/Include/Protocol/WinNtIo.h b/Nt32Pkg/Include/Protocol/WinNtIo.h deleted file mode 100644 index 00a71287c6..0000000000 --- a/Nt32Pkg/Include/Protocol/WinNtIo.h +++ /dev/null @@ -1,146 +0,0 @@ -/**@file - -Copyright (c) 2006, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - WinNtIo.h - -Abstract: - -**/ - -#ifndef __WIN_NT_IO_H__ -#define __WIN_NT_IO_H__ - -#include - -#define EFI_WIN_NT_IO_PROTOCOL_GUID \ - { 0x96eb4ad6, 0xa32a, 0x11d4, { 0xbc, 0xfd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } } - -extern EFI_GUID gEfiWinNtIoProtocolGuid; - -typedef struct { - EFI_WIN_NT_THUNK_PROTOCOL *WinNtThunk; - EFI_GUID *TypeGuid; - CHAR16 *EnvString; - UINT16 InstanceNumber; -} EFI_WIN_NT_IO_PROTOCOL; - -// -// The following GUIDs are used in EFI_WIN_NT_IO_PROTOCOL_GUID -// Device paths. They map 1:1 with NT envirnment variables. The variables -// define what virtual hardware the emulator/WinNtBusDriver will produce. -// -// -// EFI_WIN_NT_VIRTUAL_DISKS -// -#define EFI_WIN_NT_VIRTUAL_DISKS_GUID \ - { \ - 0xc95a928, 0xa006, 0x11d4, {0xbc, 0xfa, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \ - } - -extern EFI_GUID gEfiWinNtVirtualDisksGuid; - -// -// EFI_WIN_NT_PHYSICAL_DISKS -// -#define EFI_WIN_NT_PHYSICAL_DISKS_GUID \ - { \ - 0xc95a92f, 0xa006, 0x11d4, {0xbc, 0xfa, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \ - } - -extern EFI_GUID gEfiWinNtPhysicalDisksGuid; - -// -// EFI_WIN_NT_FILE_SYSTEM -// -#define EFI_WIN_NT_FILE_SYSTEM_GUID \ - { \ - 0xc95a935, 0xa006, 0x11d4, {0xbc, 0xfa, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \ - } - -extern EFI_GUID gEfiWinNtFileSystemGuid; - -// -// EFI_WIN_NT_SERIAL_PORT -// -#define EFI_WIN_NT_SERIAL_PORT_GUID \ - { \ - 0xc95a93d, 0xa006, 0x11d4, {0xbc, 0xfa, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \ - } - -extern EFI_GUID gEfiWinNtSerialPortGuid; - -// -// EFI_WIN_NT_UGA -// -#define EFI_WIN_NT_UGA_GUID \ - { \ - 0xab248e99, 0xabe1, 0x11d4, {0xbd, 0xd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \ - } - -extern EFI_GUID gEfiWinNtUgaGuid; - -// -// EFI_WIN_NT_GOP -// -#define EFI_WIN_NT_GOP_GUID \ - { \ - 0x4e11e955, 0xccca, 0x11d4, 0xbd, 0xd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \ - } - -extern EFI_GUID gEfiWinNtGopGuid; - -// -// EFI_WIN_NT_CONSOLE -// -#define EFI_WIN_NT_CONSOLE_GUID \ - { \ - 0xba73672c, 0xa5d3, 0x11d4, {0xbd, 0x0, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \ - } - -extern EFI_GUID gEfiWinNtConsoleGuid; - -// -// EFI_WIN_NT_MEMORY -// -#define EFI_WIN_NT_MEMORY_GUID \ - { \ - 0x99042912, 0x122a, 0x11d4, {0xbd, 0xd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \ - } - -extern EFI_GUID gEfiWinNtMemoryGuid; - -// -// EFI_WIN_NT_CPU_MODEL -// -#define EFI_WIN_NT_CPU_MODEL_GUID \ - { \ - 0xbee9b6ce, 0x2f8a, 0x11d4, {0xbd, 0xd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \ - } - -extern EFI_GUID gEfiWinNtCPUModelGuid; - -// -// EFI_WIN_NT_CPU_SPEED -// -#define EFI_WIN_NT_CPU_SPEED_GUID \ - { \ - 0xd4f29055, 0xe1fb, 0x11d4, {0xbd, 0xd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \ - } - -extern EFI_GUID gEfiWinNtCPUSpeedGuid; - -// -// EFI_WIN_NT_PASS_THROUGH -// -#define EFI_WIN_NT_PASS_THROUGH_GUID \ - { \ - 0xcc664eb8, 0x3c24, 0x4086, {0xb6, 0xf6, 0x34, 0xe8, 0x56, 0xbc, 0xe3, 0x6e } \ - } - -extern EFI_GUID gEfiWinNtPassThroughGuid; - -#endif diff --git a/Nt32Pkg/Include/Protocol/WinNtThunk.h b/Nt32Pkg/Include/Protocol/WinNtThunk.h deleted file mode 100644 index 847f67b21d..0000000000 --- a/Nt32Pkg/Include/Protocol/WinNtThunk.h +++ /dev/null @@ -1,1287 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - WinNtThunk.h - -Abstract: - - This protocol allows an EFI driver (DLL) in the NT emulation envirnment - to make Win32 API calls. - - NEVER make a Win32 call directly, always make the call via this protocol. - - There are no This pointers on the protocol member functions as they map - exactly into Win32 system calls. - - YOU MUST include EfiWinNT.h in place of Efi.h to make this file compile. - -**/ - -#ifndef __WIN_NT_THUNK_H__ -#define __WIN_NT_THUNK_H__ - -#include - -#define EFI_WIN_NT_THUNK_PROTOCOL_GUID \ - { 0x58c518b1, 0x76f3, 0x11d4, { 0xbc, 0xea, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } } - -typedef -WINBASEAPI -VOID -(WINAPI *WinNtSleep) ( - DWORD Milliseconds - ); - -typedef -WINBASEAPI -DWORD -(WINAPI *WinNtSuspendThread) ( - HANDLE hThread - ); - -typedef -WINBASEAPI -HANDLE -(WINAPI *WinNtGetCurrentThread) ( - VOID - ); - -typedef -WINBASEAPI -DWORD -(WINAPI *WinNtGetCurrentThreadId) ( - VOID - ); - -typedef -WINBASEAPI -HANDLE -(WINAPI *WinNtGetCurrentProcess) ( - VOID - ); - -typedef -WINBASEAPI -HANDLE -(WINAPI *WinNtCreateThread) ( - LPSECURITY_ATTRIBUTES lpThreadAttributes, - DWORD dwStackSize, - LPTHREAD_START_ROUTINE lpStartAddress, - LPVOID lpParameter, - DWORD dwCreationFlags, - LPDWORD lpThreadId - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtTerminateThread) ( - HANDLE hThread, - DWORD dwExitCode - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtSendMessage) ( - HWND hWnd, - UINT Msg, - WPARAM wParam, - LPARAM lParam - ); - -typedef -WINBASEAPI -VOID -(WINAPI *WinNtExitThread) ( - DWORD dwExitCode - ); - -typedef -WINBASEAPI -DWORD -(WINAPI *WinNtResumeThread) ( - HANDLE hThread - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtSetThreadPriority) ( - HANDLE hThread, - INTN nPriority - ); - -typedef -WINBASEAPI -VOID -(WINAPI *WinNtInitializeCriticalSection) ( - LPCRITICAL_SECTION lpCriticalSection - ); - -typedef -WINBASEAPI -VOID -(WINAPI *WinNtDeleteCriticalSection) ( - LPCRITICAL_SECTION lpCriticalSection - ); - -typedef -WINBASEAPI -VOID -(WINAPI *WinNtEnterCriticalSection) ( - LPCRITICAL_SECTION lpCriticalSection - ); - -typedef -WINBASEAPI -VOID -(WINAPI *WinNtLeaveCriticalSection) ( - LPCRITICAL_SECTION lpCriticalSection - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtTlsAlloc) ( - VOID - ); - -typedef -WINBASEAPI -LPVOID -(WINAPI *WinNtTlsGetValue) ( - DWORD dwTlsIndex - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtTlsSetValue) ( - DWORD dwTlsIndex, - LPVOID lpTlsValue - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtTlsFree) ( - DWORD dwTlsIndex - ); - -typedef -WINBASEAPI -HANDLE -(WINAPI *WinNtCreateSemaphore) ( - LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, - LONG lInitialCount, - LONG lMaximumCount, - LPCWSTR lpName - ); - -typedef -WINBASEAPI -DWORD -(WINAPI *WinNtWaitForSingleObject) ( - HANDLE hHandle, - DWORD dwMilliseconds - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtReleaseSemaphore) ( - HANDLE hSemaphore, - LONG lReleaseCount, - LPLONG lpPreviousCount - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtDuplicateHandle) ( - HANDLE hSourceProcessHandle, - HANDLE hSourceHandle, - HANDLE hTargetProcessHandle, - LPHANDLE lpTargetHandle, - DWORD dwDesiredAccess, - BOOL bInheritHandle, - DWORD dwOptions - ); - -typedef -WINBASEAPI -HANDLE -(WINAPI *WinNtCreateConsoleScreenBuffer) ( - DWORD DesiredAccess, - DWORD ShareMode, - CONST SECURITY_ATTRIBUTES *SecurityAttributes, - DWORD Flags, - LPVOID ScreenBufferData - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtSetConsoleScreenBufferSize) ( - HANDLE ConsoleOutput, - COORD Size - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtSetConsoleActiveScreenBuffer) ( - HANDLE ConsoleOutput - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtFillConsoleOutputAttribute) ( - HANDLE ConsoleOutput, - WORD Attribute, - DWORD Length, - COORD WriteCoord, - LPDWORD NumberOfAttrsWritten - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtFillConsoleOutputCharacter) ( - HANDLE ConsoleOutput, - TCHAR Character, - DWORD Length, - COORD WriteCoord, - LPDWORD NumberOfCharsWritten - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtWriteConsoleOutput) ( - HANDLE ConsoleOutput, - CONST CHAR_INFO *Buffer, - COORD BufferSize, - COORD BufferCoord, - PSMALL_RECT WriteRegion - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtScrollConsoleScreenBuffer) ( - HANDLE ConsoleOutput, - CONST SMALL_RECT *ScrollRectangle, - CONST SMALL_RECT *ClipRectangle, - COORD DestinationOrigin, - CONST CHAR_INFO *Fill - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtSetConsoleTitleW) ( - LPCTSTR ConsoleTitle - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtGetConsoleCursorInfo) ( - HANDLE ConsoleOutput, - PCONSOLE_CURSOR_INFO ConsoleCursorInfo - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtSetConsoleCursorInfo) ( - HANDLE ConsoleOutput, - CONST CONSOLE_CURSOR_INFO *ConsoleCursorInfo - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtSetPriorityClass) ( - HANDLE Process, - DWORD PriorityClass - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtWriteConsoleInput) ( - HANDLE ConsoleInput, - CONST INPUT_RECORD *Buffer, - DWORD Legnth, - LPDWORD NumberOfEventsWritten - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtGetNumberOfConsoleInputEvents) ( - HANDLE ConsoleInput, - LPDWORD NumberOfEvents - ); - -typedef -WINBASEAPI -HANDLE -(WINAPI *WinNtGetStdHandle) ( - DWORD StdHandle - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtReadConsoleInput) ( - HANDLE ConsoleInput, - PINPUT_RECORD Buffer, - DWORD Length, - LPDWORD NumberOfEventsRead - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtPeekConsoleInput) ( - HANDLE ConsoleInput, - PINPUT_RECORD Buffer, - DWORD Length, - LPDWORD NumberOfEventsRead - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtSetConsoleCursorPosition) ( - HANDLE ConsoleInput, - COORD CursorPosition - ); - -typedef -WINBASEAPI -HANDLE -(WINAPI *WinNtCreateFile) ( - LPCWSTR FileName, - DWORD DesiredAccess, - DWORD SharedMode, - LPSECURITY_ATTRIBUTES SecurityAttributes, - DWORD CreationDisposition, - DWORD FlagsAndAttributes, - HANDLE TemplateFile - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtDeviceIoControl) ( - HANDLE DeviceHandle, - DWORD IoControlCode, - LPVOID InBuffer, - DWORD InBufferSize, - LPVOID OutBuffer, - DWORD OutBufferSize, - LPDWORD BytesReturned, - LPOVERLAPPED Overlapped - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtCreateDirectory) ( - LPCWSTR PathName, - LPSECURITY_ATTRIBUTES SecurityAttributes - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtRemoveDirectory) ( - LPCWSTR PathName - ); - -typedef -WINBASEAPI -DWORD -(WINAPI *WinNtGetFileAttributes) ( - LPCWSTR FileName - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtSetFileAttributes) ( - LPCWSTR FileName, - DWORD FileAttributes - ); - -typedef -WINBASEAPI -HANDLE -(WINAPI *WinNtCreateFileMapping) ( - HANDLE FileHandle, - LPSECURITY_ATTRIBUTES Attributes, - DWORD Protect, - DWORD MaximumSizeHigh, - DWORD MaximumSizeLow, - LPCTSTR Name - ); - -typedef -WINBASEAPI -LPVOID -(WINAPI *WinNtMapViewOfFileEx) ( - HANDLE FileHandle, - DWORD DesiredAccess, - DWORD FileOffsetHigh, - DWORD FileOffsetLow, - DWORD NumberOfBytesToMap, - LPVOID BaseAddress - ); - -typedef -WINBASEAPI -DWORD -(WINAPI *WinNtGetEnvironmentVariable) ( - LPCTSTR Name, - LPTSTR Buffer, - DWORD Size - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtCloseHandle) ( - HANDLE Object - ); - -typedef -WINBASEAPI -DWORD -(WINAPI *WinNtSetFilePointer) ( - HANDLE FileHandle, - LONG DistanceToMove, - PLONG DistanceToHoveHigh, - DWORD MoveMethod - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtSetEndOfFile) ( - HANDLE FileHandle - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtReadFile) ( - HANDLE FileHandle, - LPVOID Buffer, - DWORD NumberOfBytesToRead, - LPDWORD NumberOfBytesRead, - LPOVERLAPPED Overlapped - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtWriteFile) ( - HANDLE FileHandle, - LPCVOID Buffer, - DWORD NumberOfBytesToWrite, - LPDWORD NumberOfBytesWritten, - LPOVERLAPPED Overlapped - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtGetFileInformationByHandle) ( - HANDLE FileHandle, - BY_HANDLE_FILE_INFORMATION *FileInfo - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtGetDiskFreeSpace) ( - LPCTSTR RootPathName, - LPDWORD SectorsPerCluster, - LPDWORD BytesPerSector, - LPDWORD NumberOfFreeClusters, - LPDWORD TotalNumberOfClusters - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtGetDiskFreeSpaceEx) ( - LPCTSTR DirectoryName, - PULARGE_INTEGER FreeBytesAvailable, - PULARGE_INTEGER TotalNumberOfBytes, - PULARGE_INTEGER TotoalNumberOfFreeBytes - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtMoveFile) ( - LPCTSTR ExistingFileName, - LPCTSTR NewFileName - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtSetFileTime) ( - HANDLE FileHandle, - FILETIME *CreationTime, - FILETIME *LastAccessTime, - FILETIME *LastWriteTime - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtSystemTimeToFileTime) ( - SYSTEMTIME * SystemTime, - FILETIME * FileTime - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtDeleteFile) ( - LPCTSTR FileName - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtFlushFileBuffers) ( - HANDLE - ); - -typedef -WINBASEAPI -DWORD -(WINAPI *WinNtGetLastError) ( - VOID - ); - -typedef -WINBASEAPI -UINT -(WINAPI *WinNtSetErrorMode) ( - UINT Mode - ); - -typedef -WINBASEAPI -DWORD -(WINAPI *WinNtGetTickCount) ( - VOID - ); - -typedef -WINBASEAPI -HMODULE -(WINAPI *WinNtLoadLibraryEx) ( - LPCTSTR LibFileName, - HANDLE FileHandle, - DWORD Flags - ); - -typedef -WINBASEAPI -FARPROC -(WINAPI *WinNtGetProcAddress) ( - HMODULE Module, - LPCSTR ProcName - ); - -typedef -WINBASEAPI -DWORD -(WINAPI *WinNtGetTimeZoneInformation) ( - LPTIME_ZONE_INFORMATION timeZoneInformation - ); - -typedef -WINBASEAPI -MMRESULT -(WINAPI *WinNttimeSetEvent) ( - UINT uDelay, - UINT uResolution, - LPTIMECALLBACK lpTimeProc, - DWORD_PTR dwUser, - UINT fuEvent - ); - -typedef -WINBASEAPI -MMRESULT -(WINAPI *WinNttimeKillEvent) ( - UINT uTimerID - ); - -typedef -WINBASEAPI -DWORD -(WINAPI *WinNtSetTimeZoneInformation) ( - LPTIME_ZONE_INFORMATION timeZoneInformation - ); - -typedef -WINBASEAPI -VOID -(WINAPI *WinNtGetSystemTime) ( - LPSYSTEMTIME SystemTime - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtSetSystemTime) ( - CONST SYSTEMTIME *SystemTime - ); - -typedef -WINBASEAPI -VOID -(WINAPI *WinNtGetLocalTime) ( - LPSYSTEMTIME SystemTime - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtSetLocalTime) ( - CONST SYSTEMTIME *SystemTime - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtLocalFileTimeToFileTime) ( - CONST FILETIME *LocalFileTime, - LPFILETIME FileTime - ); - - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtFileTimeToLocalFileTime) ( - CONST FILETIME *FileTime, - LPFILETIME LocalFileTime - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtFileTimeToSystemTime) ( - CONST FILETIME *FileTime, - LPSYSTEMTIME SystemTime - ); - -typedef -WINBASEAPI -HANDLE -(WINAPI *WinNtFindFirstFile) ( - LPCTSTR FileName, - LPWIN32_FIND_DATA FindFileData - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtFindNextFile) ( - HANDLE FindFile, - LPWIN32_FIND_DATA FindFileData - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtFindClose) ( - HANDLE FindFile - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtGetCommState) ( - HANDLE FileHandle, - LPDCB DCB - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtSetCommState) ( - HANDLE FileHandle, - LPDCB DCB - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtSetCommState) ( - HANDLE FileHandle, - LPDCB DCB - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtSetCommTimeouts) ( - HANDLE FileHandle, - LPCOMMTIMEOUTS CommTimeouts - ); - -typedef -WINBASEAPI -VOID -(WINAPI *WinNtExitProcess) ( - UINT uExitCode // exit code for all threads - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtPurgeComm) ( - HANDLE FileHandle, - DWORD Flags - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtEscapeCommFunction) ( - HANDLE FileHandle, - DWORD Func - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtGetCommModemStatus) ( - HANDLE FileHandle, - LPDWORD ModemStat - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtClearCommError) ( - HANDLE FileHandle, - LPDWORD Errors, - LPCOMSTAT Stat - ); - -typedef -WINUSERAPI -INT32 -(WINAPIV *WinNtSprintf) ( - LPWSTR Buffer, - size_t Count, - LPCWSTR String, - ... - ); - -typedef -WINUSERAPI -HWND -(WINAPI *WinNtGetDesktopWindow) ( - VOID - ); - -typedef -WINUSERAPI -HWND -(WINAPI *WinNtGetForegroundWindow) ( - VOID - ); - -typedef -WINUSERAPI -HWND -(WINAPI *WinNtCreateWindowEx) ( - DWORD dwExStyle, - LPCTSTR lpClassName, - LPCTSTR lpWindowName, - DWORD dwStyle, - INT32 x, - INT32 y, - INT32 nWidth, - INT32 nHeight, - HWND hWndParent, - HMENU hMenu, - HINSTANCE hInstance, - LPVOID *lpParam - ); - -typedef -WINUSERAPI -BOOL -(WINAPI *WinNtUpdateWindow) ( - HWND hWnd - ); - -typedef -WINUSERAPI -BOOL -(WINAPI *WinNtShowWindow) ( - HWND hWnd, - INT32 nCmdShow - ); - -typedef -WINGDIAPI -BOOL -(WINAPI *WinNtDestroyWindow) ( - HWND hWnd - ); - -typedef -WINUSERAPI -HDC -(WINAPI *WinNtGetWindowDC) ( - HWND hWnd - ); - -typedef -WINUSERAPI -BOOL -(WINAPI *WinNtGetClientRect) ( - HWND hWnd, - LPRECT lpRect - ); - -typedef -WINUSERAPI -BOOL -(WINAPI *WinNtAdjustWindowRect) ( - LPRECT lpRect, - DWORD dwStyle, - BOOL bMenu - ); - -typedef -WINGDIAPI -INT32 -(WINAPI *WinNtSetDIBitsToDevice) ( - HDC, - INT32, - INT32, - DWORD, - DWORD, - INT32, - INT32, - UINT, - UINT, - CONST VOID *, - CONST BITMAPINFO *, - UINT - ); - -typedef -WINGDIAPI -BOOL -(WINAPI *WinNtBitBlt) ( - HDC, - INT32, - INT32, - INT32, - INT32, - HDC, - INT32, - INT32, - DWORD - ); - -typedef -WINUSERAPI -BOOL -(WINAPI *WinNtInvalidateRect) ( - HWND hWnd, - CONST RECT *lpRect, - BOOL bErase - ); - -typedef -WINUSERAPI -HDC -(WINAPI *WinNtGetDC) ( - HWND hWnd - ); - -typedef -WINUSERAPI -INT32 -(WINAPI *WinNtReleaseDC) ( - HWND hWnd, - HDC hDC - ); - -typedef -WINUSERAPI -ATOM -(WINAPI *WinNtRegisterClassEx) ( - CONST WNDCLASSEX * - ); - -typedef -WINUSERAPI -BOOL -(WINAPI *WinNtUnregisterClass) ( - LPCTSTR lpClassName, - HINSTANCE hInstance - ); - -typedef -WINUSERAPI -HDC -(WINAPI *WinNtBeginPaint) ( - HWND hWnd, - LPPAINTSTRUCT lpPaint - ); - -typedef -WINUSERAPI -BOOL -(WINAPI *WinNtEndPaint) ( - HWND hWnd, - CONST PAINTSTRUCT *lpPaint - ); - -typedef -WINUSERAPI -VOID -(WINAPI *WinNtPostQuitMessage) ( - INT32 nExitCode - ); - -typedef -WINUSERAPI -LRESULT -(WINAPI *WinNtDefWindowProc) ( - HWND hWnd, - UINT Msg, - WPARAM wParam, - LPARAM lParam - ); - -typedef -WINUSERAPI -HICON -(WINAPI *WinNtLoadIcon) ( - HINSTANCE hInstance, - LPCTSTR lpIconName - ); - -typedef -WINUSERAPI -HCURSOR -(WINAPI *WinNtLoadCursor) ( - HINSTANCE hInstance, - LPCTSTR lpCursorName - ); - -typedef -WINGDIAPI -HGDIOBJ -(WINAPI *WinNtGetStockObject) ( - INT32 - ); - -typedef -WINGDIAPI -BOOL -(WINAPI *WinNtSetViewportOrgEx) ( - HDC, - INT32, - INT32, - LPPOINT - ); - -typedef -WINGDIAPI -BOOL -(WINAPI *WinNtSetWindowOrgEx) ( - HDC, - INT32, - INT32, - LPPOINT - ); -typedef -WINGDIAPI -BOOL -(WINAPI *WinNtMoveWindow) ( - HWND, - INT32, - INT32, - INT32, - INT32, - BOOL - ); - -typedef -WINGDIAPI -BOOL -(WINAPI *WinNtGetWindowRect) ( - HWND, - LPRECT - ); - -typedef -WINUSERAPI -BOOL -(WINAPI *WinNtGetMessage) ( - LPMSG lpMsg, - HWND hWnd, - UINT wMsgFilterMin, - UINT wMsgFilterMax - ); - -typedef -WINUSERAPI -BOOL -(WINAPI *WinNtTranslateMessage) ( - CONST MSG *lpMsg - ); - -typedef -WINUSERAPI -BOOL -(WINAPI *WinNtDispatchMessage) ( - CONST MSG *lpMsg - ); - -typedef -WINUSERAPI -HANDLE -(WINAPI *WinNtGetProcessHeap) (); - -typedef -WINUSERAPI -LPVOID -(WINAPI *WinNtHeapAlloc) ( - HANDLE hHeap, - DWORD dwFlags, - SIZE_T dwBytes - ); - -typedef -WINUSERAPI -BOOL -(WINAPI *WinNtHeapFree) ( - HANDLE hHeap, - DWORD dwFlags, - LPVOID lpMem - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtFreeLibrary) ( - HANDLE ModHandle - ); -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtQueryPerformanceCounter) ( - LARGE_INTEGER *PerformanceCount - ); - -typedef -WINBASEAPI -BOOL -(WINAPI *WinNtQueryPerformanceFrequency) ( - LARGE_INTEGER *Frequency - ); -// -// -// - -#define EFI_WIN_NT_THUNK_PROTOCOL_SIGNATURE SIGNATURE_32 ('N', 'T', 'T', 'T') - -typedef struct { - UINT64 Signature; - - // - // Win32 Process APIs - // - WinNtGetProcAddress GetProcAddress; - WinNtGetTickCount GetTickCount; - WinNtLoadLibraryEx LoadLibraryEx; - WinNtFreeLibrary FreeLibrary; - - WinNtSetPriorityClass SetPriorityClass; - WinNtSetThreadPriority SetThreadPriority; - WinNtSleep Sleep; - - WinNtSuspendThread SuspendThread; - WinNtGetCurrentThread GetCurrentThread; - WinNtGetCurrentThreadId GetCurrentThreadId; - WinNtGetCurrentProcess GetCurrentProcess; - WinNtCreateThread CreateThread; - WinNtTerminateThread TerminateThread; - WinNtSendMessage SendMessage; - WinNtExitThread ExitThread; - WinNtResumeThread ResumeThread; - WinNtDuplicateHandle DuplicateHandle; - - // - // Wint32 Mutex primitive - // - WinNtInitializeCriticalSection InitializeCriticalSection; - WinNtEnterCriticalSection EnterCriticalSection; - WinNtLeaveCriticalSection LeaveCriticalSection; - WinNtDeleteCriticalSection DeleteCriticalSection; - WinNtTlsAlloc TlsAlloc; - WinNtTlsFree TlsFree; - WinNtTlsSetValue TlsSetValue; - WinNtTlsGetValue TlsGetValue; - WinNtCreateSemaphore CreateSemaphore; - WinNtWaitForSingleObject WaitForSingleObject; - WinNtReleaseSemaphore ReleaseSemaphore; - - // - // Win32 Console APIs - // - WinNtCreateConsoleScreenBuffer CreateConsoleScreenBuffer; - WinNtFillConsoleOutputAttribute FillConsoleOutputAttribute; - WinNtFillConsoleOutputCharacter FillConsoleOutputCharacter; - WinNtGetConsoleCursorInfo GetConsoleCursorInfo; - WinNtGetNumberOfConsoleInputEvents GetNumberOfConsoleInputEvents; - WinNtPeekConsoleInput PeekConsoleInput; - WinNtScrollConsoleScreenBuffer ScrollConsoleScreenBuffer; - WinNtReadConsoleInput ReadConsoleInput; - - WinNtSetConsoleActiveScreenBuffer SetConsoleActiveScreenBuffer; - WinNtSetConsoleCursorInfo SetConsoleCursorInfo; - WinNtSetConsoleCursorPosition SetConsoleCursorPosition; - WinNtSetConsoleScreenBufferSize SetConsoleScreenBufferSize; - WinNtSetConsoleTitleW SetConsoleTitleW; - WinNtWriteConsoleInput WriteConsoleInput; - WinNtWriteConsoleOutput WriteConsoleOutput; - - // - // Win32 File APIs - // - WinNtCreateFile CreateFile; - WinNtDeviceIoControl DeviceIoControl; - WinNtCreateDirectory CreateDirectory; - WinNtRemoveDirectory RemoveDirectory; - WinNtGetFileAttributes GetFileAttributes; - WinNtSetFileAttributes SetFileAttributes; - WinNtCreateFileMapping CreateFileMapping; - WinNtCloseHandle CloseHandle; - WinNtDeleteFile DeleteFile; - WinNtFindFirstFile FindFirstFile; - WinNtFindNextFile FindNextFile; - WinNtFindClose FindClose; - WinNtFlushFileBuffers FlushFileBuffers; - WinNtGetEnvironmentVariable GetEnvironmentVariable; - WinNtGetLastError GetLastError; - WinNtSetErrorMode SetErrorMode; - WinNtGetStdHandle GetStdHandle; - WinNtMapViewOfFileEx MapViewOfFileEx; - WinNtReadFile ReadFile; - WinNtSetEndOfFile SetEndOfFile; - WinNtSetFilePointer SetFilePointer; - WinNtWriteFile WriteFile; - WinNtGetFileInformationByHandle GetFileInformationByHandle; - WinNtGetDiskFreeSpace GetDiskFreeSpace; - WinNtGetDiskFreeSpaceEx GetDiskFreeSpaceEx; - WinNtMoveFile MoveFile; - WinNtSetFileTime SetFileTime; - WinNtSystemTimeToFileTime SystemTimeToFileTime; - - // - // Win32 Time APIs - // - WinNtLocalFileTimeToFileTime LocalFileTimeToFileTime; - WinNtFileTimeToLocalFileTime FileTimeToLocalFileTime; - WinNtFileTimeToSystemTime FileTimeToSystemTime; - WinNtGetSystemTime GetSystemTime; - WinNtSetSystemTime SetSystemTime; - WinNtGetLocalTime GetLocalTime; - WinNtSetLocalTime SetLocalTime; - WinNtGetTimeZoneInformation GetTimeZoneInformation; - WinNtSetTimeZoneInformation SetTimeZoneInformation; - WinNttimeSetEvent timeSetEvent; - WinNttimeKillEvent timeKillEvent; - - // - // Win32 Serial APIs - // - WinNtClearCommError ClearCommError; - WinNtEscapeCommFunction EscapeCommFunction; - WinNtGetCommModemStatus GetCommModemStatus; - WinNtGetCommState GetCommState; - WinNtSetCommState SetCommState; - WinNtPurgeComm PurgeComm; - WinNtSetCommTimeouts SetCommTimeouts; - - WinNtExitProcess ExitProcess; - - WinNtSprintf SPrintf; - - WinNtGetDesktopWindow GetDesktopWindow; - WinNtGetForegroundWindow GetForegroundWindow; - WinNtCreateWindowEx CreateWindowEx; - WinNtShowWindow ShowWindow; - WinNtUpdateWindow UpdateWindow; - WinNtDestroyWindow DestroyWindow; - WinNtInvalidateRect InvalidateRect; - WinNtGetWindowDC GetWindowDC; - WinNtGetClientRect GetClientRect; - WinNtAdjustWindowRect AdjustWindowRect; - WinNtSetDIBitsToDevice SetDIBitsToDevice; - WinNtBitBlt BitBlt; - WinNtGetDC GetDC; - WinNtReleaseDC ReleaseDC; - WinNtRegisterClassEx RegisterClassEx; - WinNtUnregisterClass UnregisterClass; - - WinNtBeginPaint BeginPaint; - WinNtEndPaint EndPaint; - WinNtPostQuitMessage PostQuitMessage; - WinNtDefWindowProc DefWindowProc; - WinNtLoadIcon LoadIcon; - WinNtLoadCursor LoadCursor; - WinNtGetStockObject GetStockObject; - WinNtSetViewportOrgEx SetViewportOrgEx; - WinNtSetWindowOrgEx SetWindowOrgEx; - WinNtMoveWindow MoveWindow; - WinNtGetWindowRect GetWindowRect; - - WinNtGetMessage GetMessage; - WinNtTranslateMessage TranslateMessage; - WinNtDispatchMessage DispatchMessage; - - WinNtGetProcessHeap GetProcessHeap; - WinNtHeapAlloc HeapAlloc; - WinNtHeapFree HeapFree; - - WinNtQueryPerformanceCounter QueryPerformanceCounter; - WinNtQueryPerformanceFrequency QueryPerformanceFrequency; - -} EFI_WIN_NT_THUNK_PROTOCOL; - -extern EFI_GUID gEfiWinNtThunkProtocolGuid; - -#endif diff --git a/Nt32Pkg/Include/WinNtDxe.h b/Nt32Pkg/Include/WinNtDxe.h deleted file mode 100644 index c57ab93f68..0000000000 --- a/Nt32Pkg/Include/WinNtDxe.h +++ /dev/null @@ -1,23 +0,0 @@ -/**@file - -Copyright (c) 2006, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - WinNtLib.h - -Abstract: - Public include file for the WinNt Library - -**/ - -#ifndef __WIN_NT_DXE_H__ -#define __WIN_NT_DXE_H__ - -// -// This forces Windows.h WIN32 include file to be included -// it's needed for WinNtThunk.h -// WinNtIo.h depends on WinNtThunk.h -// -#include -#endif diff --git a/Nt32Pkg/Include/WinNtPeim.h b/Nt32Pkg/Include/WinNtPeim.h deleted file mode 100644 index 57d66a2629..0000000000 --- a/Nt32Pkg/Include/WinNtPeim.h +++ /dev/null @@ -1,25 +0,0 @@ -/**@file - -Copyright (c) 2006, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - WinNtLib.h - -Abstract: - Public include file for the WinNt Library - -**/ - -#ifndef __WIN_NT_PEIM_H__ -#define __WIN_NT_PEIM_H__ - -// -// This forces Windows.h WIN32 include file to be included -// it's needed for WinNtThunk.h -// -#include - -#include - -#endif diff --git a/Nt32Pkg/Library/DxeNt32OemHookStatusCodeLib/DxeNt32OemHookStatusCodeLib.inf b/Nt32Pkg/Library/DxeNt32OemHookStatusCodeLib/DxeNt32OemHookStatusCodeLib.inf deleted file mode 100644 index dd98ba1ede..0000000000 --- a/Nt32Pkg/Library/DxeNt32OemHookStatusCodeLib/DxeNt32OemHookStatusCodeLib.inf +++ /dev/null @@ -1,45 +0,0 @@ -## @file -# Memory Status Code Library for UEFI drivers -# -# Lib to provide memory journal status code reporting Routines -# -# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
-# SPDX-License-Identifier: BSD-2-Clause-Patent -# -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = DxeNt32OemHookStatusCodeLib - FILE_GUID = EF172A23-C7C5-47b7-B24E-D10DFE15540F - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - LIBRARY_CLASS = OemHookStatusCodeLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 -# -# HOB Guid C Name: gEfiWinNtThunkProtocolGuid Hob Type: GUID_EXTENSION -# - -[Sources] - Nt32OemHookStatusCodeLib.c - - -[Packages] - Nt32Pkg/Nt32Pkg.dec - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - -[LibraryClasses] - ReportStatusCodeLib - BaseMemoryLib - PrintLib - HobLib - DebugLib - -[Protocols] - gEfiWinNtThunkProtocolGuid # ALWAYS_CONSUMED diff --git a/Nt32Pkg/Library/DxeNt32OemHookStatusCodeLib/Nt32OemHookStatusCodeLib.c b/Nt32Pkg/Library/DxeNt32OemHookStatusCodeLib/Nt32OemHookStatusCodeLib.c deleted file mode 100644 index a69dc338b3..0000000000 --- a/Nt32Pkg/Library/DxeNt32OemHookStatusCodeLib/Nt32OemHookStatusCodeLib.c +++ /dev/null @@ -1,232 +0,0 @@ -/** @file - OEM hook status code library functions with no library constructor/destructor - - Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
- SPDX-License-Identifier: BSD-2-Clause-Patent - - Module Name: Nt32OemHookStatusCodeLib.c - -**/ - -// -// The package level header files this module uses -// -#include - -// -// The protocols, PPI and GUID defintions for this module -// -#include -#include -#include -// -// The Library classes this module consumes -// -#include -#include -#include -#include -#include -#include - -// -// Cache of WinNtThunk protocol -// -EFI_WIN_NT_THUNK_PROTOCOL *mWinNt; - -// -// Cache of standard output handle . -// -HANDLE mStdOut; - -/** - - Initialize OEM status code device . - - @return Always return EFI_SUCCESS. - -**/ -EFI_STATUS -EFIAPI -OemHookStatusCodeInitialize ( - VOID - ) -{ - EFI_HOB_GUID_TYPE *GuidHob; - - // - // Retrieve WinNtThunkProtocol from GUID'ed HOB - // - GuidHob = GetFirstGuidHob (&gEfiWinNtThunkProtocolGuid); - ASSERT (GuidHob != NULL); - mWinNt = (EFI_WIN_NT_THUNK_PROTOCOL *)(*(UINTN *)(GET_GUID_HOB_DATA (GuidHob))); - ASSERT (mWinNt != NULL); - - // - // Cache standard output handle. - // - mStdOut = mWinNt->GetStdHandle (STD_OUTPUT_HANDLE); - - return EFI_SUCCESS; -} - -/** - Report status code to OEM device. - - @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below. - - @param Value Describes the current status of a hardware or software entity. - This included information about the class and subclass that is used to classify the entity - as well as an operation. For progress codes, the operation is the current activity. - For error codes, it is the exception. For debug codes, it is not defined at this time. - Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below. - Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification. - - @param Instance The enumeration of a hardware or software entity within the system. - A system may contain multiple entities that match a class/subclass pairing. - The instance differentiates between them. An instance of 0 indicates that instance information is unavailable, - not meaningful, or not relevant. Valid instance numbers start with 1. - - - @param CallerId This optional parameter may be used to identify the caller. - This parameter allows the status code driver to apply different rules to different callers. - Type EFI_GUID is defined in InstallProtocolInterface() in the UEFI 2.0 Specification. - - - @param Data This optional parameter may be used to pass additional data - - @return The function always return EFI_SUCCESS. - -**/ -EFI_STATUS -EFIAPI -OemHookStatusCodeReport ( - IN EFI_STATUS_CODE_TYPE CodeType, - IN EFI_STATUS_CODE_VALUE Value, - IN UINT32 Instance, - IN EFI_GUID *CallerId, OPTIONAL - IN EFI_STATUS_CODE_DATA *Data OPTIONAL - ) -{ - CHAR8 *Filename; - CHAR8 *Description; - CHAR8 *Format; - CHAR8 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE]; - UINT32 ErrorLevel; - UINT32 LineNumber; - UINTN CharCount; - BASE_LIST Marker; - - Buffer[0] = '\0'; - - if (Data != NULL && - ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) { - // - // Print ASSERT() information into output buffer. - // - CharCount = AsciiSPrint ( - Buffer, - sizeof (Buffer), - "\n\rASSERT!: %a (%d): %a\n\r", - Filename, - LineNumber, - Description - ); - - // - // Callout to standard output. - // - mWinNt->WriteFile ( - mStdOut, - Buffer, - (DWORD)CharCount, - (LPDWORD)&CharCount, - NULL - ); - - return EFI_SUCCESS; - - } else if (Data != NULL && - ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) { - // - // Print DEBUG() information into output buffer. - // - CharCount = AsciiBSPrint ( - Buffer, - sizeof (Buffer), - Format, - Marker - ); - } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) { - // - // Print ERROR information into output buffer. - // - CharCount = AsciiSPrint ( - Buffer, - sizeof (Buffer), - "ERROR: C%x:V%x I%x", - CodeType, - Value, - Instance - ); - - // - // Make sure we don't try to print values that weren't intended to be printed, especially NULL GUID pointers. - // - - if (CallerId != NULL) { - CharCount += AsciiSPrint ( - &Buffer[CharCount - 1], - (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)), - " %g", - CallerId - ); - } - - if (Data != NULL) { - CharCount += AsciiSPrint ( - &Buffer[CharCount - 1], - (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)), - " %p", - Data - ); - } - - CharCount += AsciiSPrint ( - &Buffer[CharCount - 1], - (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)), - "\n\r" - ); - } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) { - CharCount = AsciiSPrint ( - Buffer, - sizeof (Buffer), - "PROGRESS CODE: V%x I%x\n\r", - Value, - Instance - ); - } else { - CharCount = AsciiSPrint ( - Buffer, - sizeof (Buffer), - "Undefined: C%x:V%x I%x\n\r", - CodeType, - Value, - Instance - ); - } - - // - // Callout to standard output. - // - mWinNt->WriteFile ( - mStdOut, - Buffer, - (DWORD)CharCount, - (LPDWORD)&CharCount, - NULL - ); - - return EFI_SUCCESS; -} - diff --git a/Nt32Pkg/Library/DxeNt32PeCoffExtraActionLib/DxeNt32PeCoffExtraActionLib.c b/Nt32Pkg/Library/DxeNt32PeCoffExtraActionLib/DxeNt32PeCoffExtraActionLib.c deleted file mode 100644 index 82bbbdef4c..0000000000 --- a/Nt32Pkg/Library/DxeNt32PeCoffExtraActionLib/DxeNt32PeCoffExtraActionLib.c +++ /dev/null @@ -1,402 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - PeiNt32PeCoffExtraActionLib.c - -Abstract: - - Provides services to perform additional actions to relocate and unload - PE/Coff image for NT32 environment specific purpose such as souce level debug. - This version only works for DXE phase - - -**/ -// -// The package level header files this module uses -// -#include - -// -// The protocols, PPI and GUID defintions for this module -// -#include - -#include - -#include -#include -#include -#include -#include - -#define MAX_PDB_NAME_TO_MOD_HANDLE_ARRAY_SIZE 0x100 - -typedef struct { - CHAR8 *PdbPointer; - VOID *ModHandle; -} PDB_NAME_TO_MOD_HANDLE; - - -// -// Cache of WinNtThunk protocol -// -EFI_WIN_NT_THUNK_PROTOCOL *mWinNt = NULL; - -// -// An Array to hold the ModHandle -// -PDB_NAME_TO_MOD_HANDLE *mPdbNameModHandleArray = NULL; -UINTN mPdbNameModHandleArraySize = 0; - - -/** - The constructor function gets the pointer of the WinNT thunk functions - It will ASSERT() if NT thunk protocol is not installed. - - @retval EFI_SUCCESS WinNT thunk protocol is found and cached. - -**/ -EFI_STATUS -EFIAPI -Nt32PeCoffGetWinNtThunkStucture ( - VOID - ) -{ - EFI_HOB_GUID_TYPE *GuidHob; - - // - // Retrieve WinNtThunkProtocol from GUID'ed HOB - // - GuidHob = GetFirstGuidHob (&gEfiWinNtThunkProtocolGuid); - ASSERT (GuidHob != NULL); - mWinNt = (EFI_WIN_NT_THUNK_PROTOCOL *)(*(UINTN *)(GET_GUID_HOB_DATA (GuidHob))); - ASSERT (mWinNt != NULL); - - - return EFI_SUCCESS; -} - -/** - Convert the passed in Ascii string to Unicode. - - This function Convert the passed in Ascii string to Unicode.Optionally return - the length of the strings.. - - @param AsciiString Pointer to an AscII string - @param StrLen Length of string - - @return Pointer to malloc'ed Unicode version of Ascii - -**/ -CHAR16 * -AsciiToUnicode ( - IN CHAR8 *Ascii, - IN UINTN *StrLen OPTIONAL - ) -{ - UINTN Index; - CHAR16 *Unicode; - - // - // Allocate a buffer for unicode string - // - for (Index = 0; Ascii[Index] != '\0'; Index++) - ; - Unicode = mWinNt->HeapAlloc ( mWinNt->GetProcessHeap (), - HEAP_ZERO_MEMORY, - ((Index + 1) * sizeof (CHAR16)) - ); - if (Unicode == NULL) { - return NULL; - } - - for (Index = 0; Ascii[Index] != '\0'; Index++) { - Unicode[Index] = (CHAR16) Ascii[Index]; - } - - Unicode[Index] = '\0'; - - if (StrLen != NULL) { - *StrLen = Index; - } - - return Unicode; -} -/** - Store the ModHandle in an array indexed by the Pdb File name. - The ModHandle is needed to unload the image. - - - @param ImageContext - Input data returned from PE Laoder Library. Used to find the - .PDB file name of the PE Image. - @param ModHandle - Returned from LoadLibraryEx() and stored for call to - FreeLibrary(). - - @return return EFI_SUCCESS when ModHandle was stored. - ---*/ -EFI_STATUS -AddModHandle ( - IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext, - IN VOID *ModHandle - ) - -{ - UINTN Index; - PDB_NAME_TO_MOD_HANDLE *Array; - UINTN PreviousSize; - PDB_NAME_TO_MOD_HANDLE *TempArray; - HANDLE Handle; - - // - // Return EFI_ALREADY_STARTED if this DLL has already been loaded - // - Array = mPdbNameModHandleArray; - for (Index = 0; Index < mPdbNameModHandleArraySize; Index++, Array++) { - if (Array->PdbPointer != NULL && Array->ModHandle == ModHandle) { - return EFI_ALREADY_STARTED; - } - } - - Array = mPdbNameModHandleArray; - for (Index = 0; Index < mPdbNameModHandleArraySize; Index++, Array++) { - if (Array->PdbPointer == NULL) { - // - // Make a copy of the stirng and store the ModHandle - // - Handle = mWinNt->GetProcessHeap (); - Array->PdbPointer = mWinNt->HeapAlloc ( Handle, - HEAP_ZERO_MEMORY, - AsciiStrLen (ImageContext->PdbPointer) + 1 - ); - - ASSERT (Array->PdbPointer != NULL); - - AsciiStrCpy (Array->PdbPointer, ImageContext->PdbPointer); - Array->ModHandle = ModHandle; - return EFI_SUCCESS; - } - } - - // - // No free space in mPdbNameModHandleArray so grow it by - // MAX_PDB_NAME_TO_MOD_HANDLE_ARRAY_SIZE entires. - // - PreviousSize = mPdbNameModHandleArraySize * sizeof (PDB_NAME_TO_MOD_HANDLE); - mPdbNameModHandleArraySize += MAX_PDB_NAME_TO_MOD_HANDLE_ARRAY_SIZE; - // - // re-allocate a new buffer and copy the old values to the new locaiton. - // - TempArray = mWinNt->HeapAlloc ( mWinNt->GetProcessHeap (), - HEAP_ZERO_MEMORY, - mPdbNameModHandleArraySize * sizeof (PDB_NAME_TO_MOD_HANDLE) - ); - - CopyMem ((VOID *) (UINTN) TempArray, (VOID *) (UINTN)mPdbNameModHandleArray, PreviousSize); - - mWinNt->HeapFree (mWinNt->GetProcessHeap (), 0, mPdbNameModHandleArray); - - mPdbNameModHandleArray = TempArray; - if (mPdbNameModHandleArray == NULL) { - ASSERT (FALSE); - return EFI_OUT_OF_RESOURCES; - } - - - return AddModHandle (ImageContext, ModHandle); -} -/** - Return the ModHandle and delete the entry in the array. - - - @param ImageContext - Input data returned from PE Laoder Library. Used to find the - .PDB file name of the PE Image. - - @return - ModHandle - ModHandle assoicated with ImageContext is returned - NULL - No ModHandle associated with ImageContext - -**/ -VOID * -RemoveModeHandle ( - IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext - ) -{ - UINTN Index; - PDB_NAME_TO_MOD_HANDLE *Array; - - if (ImageContext->PdbPointer == NULL) { - // - // If no PDB pointer there is no ModHandle so return NULL - // - return NULL; - } - - Array = mPdbNameModHandleArray; - for (Index = 0; Index < mPdbNameModHandleArraySize; Index++, Array++) { - if ((Array->PdbPointer != NULL) && (AsciiStrCmp(Array->PdbPointer, ImageContext->PdbPointer) == 0)) { - // - // If you find a match return it and delete the entry - // - mWinNt->HeapFree (mWinNt->GetProcessHeap (), 0, Array->PdbPointer); - Array->PdbPointer = NULL; - return Array->ModHandle; - } - } - - return NULL; -} - -/** - Performs additional actions after a PE/COFF image has been loaded and relocated. - - For NT32, this function load symbols to support source level debugging. - - If ImageContext is NULL, then ASSERT(). - - @param ImageContext Pointer to the image context structure that describes the - PE/COFF image that has already been loaded and relocated. - -**/ -VOID -EFIAPI -PeCoffLoaderRelocateImageExtraAction ( - IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext - ) -{ - EFI_STATUS Status; - VOID *DllEntryPoint; - CHAR16 *DllFileName; - HMODULE Library; - UINTN Index; - - ASSERT (ImageContext != NULL); - - if (mWinNt == NULL) { - Nt32PeCoffGetWinNtThunkStucture (); - } - - // - // If we load our own PE COFF images the Windows debugger can not source - // level debug our code. If a valid PDB pointer exists usw it to load - // the *.dll file as a library using Windows* APIs. This allows - // source level debug. The image is still loaded and relocated - // in the Framework memory space like on a real system (by the code above), - // but the entry point points into the DLL loaded by the code bellow. - // - - DllEntryPoint = NULL; - - // - // Load the DLL if it's not an EBC image. - // - if ((ImageContext->PdbPointer != NULL) && - (ImageContext->Machine != EFI_IMAGE_MACHINE_EBC)) { - // - // Convert filename from ASCII to Unicode - // - DllFileName = AsciiToUnicode (ImageContext->PdbPointer, &Index); - - // - // Check that we have a valid filename - // - if (Index < 5 || DllFileName[Index - 4] != '.') { - mWinNt->HeapFree (mWinNt->GetProcessHeap (), 0, DllFileName); - - // - // Never return an error if PeCoffLoaderRelocateImage() succeeded. - // The image will run, but we just can't source level debug. If we - // return an error the image will not run. - // - return; - } - // - // Replace .PDB with .DLL on the filename - // - DllFileName[Index - 3] = 'D'; - DllFileName[Index - 2] = 'L'; - DllFileName[Index - 1] = 'L'; - - // - // Load the .DLL file into the user process's address space for source - // level debug - // - Library = mWinNt->LoadLibraryEx (DllFileName, NULL, DONT_RESOLVE_DLL_REFERENCES); - if (Library != NULL) { - // - // InitializeDriver is the entry point we put in all our EFI DLL's. The - // DONT_RESOLVE_DLL_REFERENCES argument to LoadLIbraryEx() suppresses the - // normal DLL entry point of DllMain, and prevents other modules that are - // referenced in side the DllFileName from being loaded. There is no error - // checking as the we can point to the PE32 image loaded by Tiano. This - // step is only needed for source level debugging - // - DllEntryPoint = (VOID *) (UINTN) mWinNt->GetProcAddress (Library, "InitializeDriver"); - - } - - if ((Library != NULL) && (DllEntryPoint != NULL)) { - Status = AddModHandle (ImageContext, Library); - if (Status == EFI_ALREADY_STARTED) { - // - // If the DLL has already been loaded before, then this instance of the DLL can not be debugged. - // - ImageContext->PdbPointer = NULL; - DEBUG ((EFI_D_ERROR, "WARNING: DLL already loaded. No source level debug %s. \n", DllFileName)); - } else { - // - // This DLL is not already loaded, so source level debugging is supported. - // - ImageContext->EntryPoint = (EFI_PHYSICAL_ADDRESS) (UINTN) DllEntryPoint; - DEBUG ((EFI_D_INFO, "LoadLibraryEx (%s,\n NULL, DONT_RESOLVE_DLL_REFERENCES)\n", DllFileName)); - } - } else { - // - // This DLL does not support source level debugging at all. - // - DEBUG ((EFI_D_ERROR, "WARNING: No source level debug %s. \n", DllFileName)); - } - - mWinNt->HeapFree (mWinNt->GetProcessHeap (), 0, DllFileName); - } - - // - // Never return an error if PeCoffLoaderRelocateImage() succeeded. - // The image will run, but we just can't source level debug. If we - // return an error the image will not run. - // - return; -} - -/** - Performs additional actions just before a PE/COFF image is unloaded. Any resources - that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed. - - For NT32, this function unloads symbols for source level debugging. - - If ImageContext is NULL, then ASSERT(). - - @param ImageContext Pointer to the image context structure that describes the - PE/COFF image that is being unloaded. - -**/ -VOID -EFIAPI -PeCoffLoaderUnloadImageExtraAction ( - IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext - ) -{ - VOID *ModHandle; - - ASSERT (ImageContext != NULL); - - ModHandle = RemoveModeHandle (ImageContext); - if (ModHandle != NULL) { - mWinNt->FreeLibrary (ModHandle); - } - return; -} diff --git a/Nt32Pkg/Library/DxeNt32PeCoffExtraActionLib/DxeNt32PeCoffExtraActionLib.inf b/Nt32Pkg/Library/DxeNt32PeCoffExtraActionLib/DxeNt32PeCoffExtraActionLib.inf deleted file mode 100644 index d81517a4a2..0000000000 --- a/Nt32Pkg/Library/DxeNt32PeCoffExtraActionLib/DxeNt32PeCoffExtraActionLib.inf +++ /dev/null @@ -1,40 +0,0 @@ -## @file -# PeCoff extra action libary for DXE phase that run NT32 emulator. -# -# Lib to provide memory journal status code reporting Routines -# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
-# SPDX-License-Identifier: BSD-2-Clause-Patent - -# -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = DxeNt32PeCoffExtraActionLib - FILE_GUID = 23AF9A54-3D7C-444d-8318-E9CF752DA349 - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - LIBRARY_CLASS = PeCoffExtraActionLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_DRIVER - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 -# - -[Sources] - DxeNt32PeCoffExtraActionLib.c - -[Packages] - Nt32Pkg/Nt32Pkg.dec - MdePkg/MdePkg.dec - -[LibraryClasses] - DebugLib - HobLib - BaseMemoryLib - -[Protocols] - gEfiWinNtThunkProtocolGuid # ALWAYS_CONSUMED - diff --git a/Nt32Pkg/Library/DxeWinNtLib/DxeWinNtLib.inf b/Nt32Pkg/Library/DxeWinNtLib/DxeWinNtLib.inf deleted file mode 100644 index 47430e86b9..0000000000 --- a/Nt32Pkg/Library/DxeWinNtLib/DxeWinNtLib.inf +++ /dev/null @@ -1,42 +0,0 @@ -## @file -# A library to produce the global variable 'gWinNt' -# -# This library contains a single global variable 'gWinNt' along with a constructor to initialize that global. -# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
-# -# SPDX-License-Identifier: BSD-2-Clause-Patent -# -# -## -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = DxeWinNtLib - FILE_GUID = f6b5871d-5226-41b3-a569-3ff893fdc7bc - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - LIBRARY_CLASS = WinNtLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER - - CONSTRUCTOR = WinNtLibConstructor - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 -# -# HOB Guid C Name: gEfiWinNtThunkProtocolGuid Hob Type: GUID_EXTENSION -# - -[Sources] - WinNtLib.c - -[Packages] - MdePkg/MdePkg.dec - Nt32Pkg/Nt32Pkg.dec - -[LibraryClasses] - HobLib - DebugLib - -[Protocols] - gEfiWinNtThunkProtocolGuid # Used as HOB in the code. - diff --git a/Nt32Pkg/Library/DxeWinNtLib/WinNtLib.c b/Nt32Pkg/Library/DxeWinNtLib/WinNtLib.c deleted file mode 100644 index 55d6f9c231..0000000000 --- a/Nt32Pkg/Library/DxeWinNtLib/WinNtLib.c +++ /dev/null @@ -1,47 +0,0 @@ -/**@file - -Copyright (c) 2006, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - WinNtLib.c - -Abstract: - - WinNt Library - -**/ - -#include -#include -#include -#include -#include - - -EFI_WIN_NT_THUNK_PROTOCOL *gWinNt; - -EFI_STATUS -WinNtLibConstructor ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -/*++ - -Routine Description: - -Arguments: - -Returns: - ---*/ -{ - EFI_HOB_GUID_TYPE *GuidHob; - - GuidHob = GetFirstGuidHob (&gEfiWinNtThunkProtocolGuid); - ASSERT (GuidHob != NULL); - gWinNt = (EFI_WIN_NT_THUNK_PROTOCOL *)(*(UINTN *)(GET_GUID_HOB_DATA (GuidHob))); - ASSERT (gWinNt != NULL); - return EFI_SUCCESS; -} diff --git a/Nt32Pkg/Library/Nt32PeiPeCoffGetEntryPointLib/Nt32PeiPeCoffGetEntryPointLib.inf b/Nt32Pkg/Library/Nt32PeiPeCoffGetEntryPointLib/Nt32PeiPeCoffGetEntryPointLib.inf deleted file mode 100644 index 011c9d64ed..0000000000 --- a/Nt32Pkg/Library/Nt32PeiPeCoffGetEntryPointLib/Nt32PeiPeCoffGetEntryPointLib.inf +++ /dev/null @@ -1,38 +0,0 @@ -## @file -# Component description file for the EdkNt32PeiPeCoffGetEntryPointLib library. -# -# PeCoffGetEntryPointLib library class for NT32 instance implemented by use NTPeiLoadFile PPI. -# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
-# -# SPDX-License-Identifier: BSD-2-Clause-Patent -# -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = EdkNt32PeiPeCoffGetEntryPointLib - FILE_GUID = 434b164e-5fa6-4a3d-bc04-02da2a4eeb26 - MODULE_TYPE = PEIM - VERSION_STRING = 1.0 - LIBRARY_CLASS = PeCoffGetEntryPointLib|PEI_CORE PEIM SEC - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 -# - -[Sources] - PeCoffGetEntryPoint.c - -[Packages] - MdePkg/MdePkg.dec - Nt32Pkg/Nt32Pkg.dec - -[LibraryClasses] - PeiServicesLib - -[Ppis] - gNtPeiLoadFilePpiGuid # PPI ALWAYS_CONSUMED - diff --git a/Nt32Pkg/Library/Nt32PeiPeCoffGetEntryPointLib/PeCoffGetEntryPoint.c b/Nt32Pkg/Library/Nt32PeiPeCoffGetEntryPointLib/PeCoffGetEntryPoint.c deleted file mode 100644 index 58a88a4569..0000000000 --- a/Nt32Pkg/Library/Nt32PeiPeCoffGetEntryPointLib/PeCoffGetEntryPoint.c +++ /dev/null @@ -1,318 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - PeCoffGetEntryPoint.c - -Abstract: - - Tiano PE/COFF loader - -Revision History - -**/ - -#include -#include -#include -#include -#include -#include -#include - - -RETURN_STATUS -EFIAPI -PeCoffLoaderGetEntryPoint ( - IN VOID *Pe32Data, - IN OUT VOID **EntryPoint - ) -/*++ - -Routine Description: - - Loads a PE/COFF image into memory, this is not follow the original purpose of - PeCoffGetEntryPoint library class. But it's ok that Unix package not run on a real - platform and this is for source level debug. - -Arguments: - - Pe32Data - Pointer to a PE/COFF Image - - EntryPoint - Pointer to the entry point of the PE/COFF image - -Returns: - - EFI_SUCCESS if the EntryPoint was returned - EFI_INVALID_PARAMETER if the EntryPoint could not be found from Pe32Data - ---*/ -{ - EFI_STATUS Status; - EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor; - NT_PEI_LOAD_FILE_PPI *PeiNtService; - EFI_PHYSICAL_ADDRESS ImageAddress; - UINT64 ImageSize; - EFI_PHYSICAL_ADDRESS ImageEntryPoint; - - ASSERT (Pe32Data != NULL); - ASSERT (EntryPoint != NULL); - - Status = PeiServicesLocatePpi ( - &gNtPeiLoadFilePpiGuid, - 0, - &PpiDescriptor, - (VOID**)&PeiNtService - ); - ASSERT_EFI_ERROR (Status); - - Status = PeiNtService->PeiLoadFileService ( - Pe32Data, - &ImageAddress, - &ImageSize, - &ImageEntryPoint - ); - if (EFI_ERROR (Status)) { - return Status; - } - - *EntryPoint = (VOID*)(UINTN)ImageEntryPoint; - return Status; -} - -/** - Returns the machine type of PE/COFF image. - This is copied from MDE BasePeCoffGetEntryPointLib, the code should be sync with it. - The reason is NT32 package needs to load the image to memory to support source - level debug. - - - @param Pe32Data Pointer to a PE/COFF header - - @return Machine type or zero if not a valid iamge - -**/ -UINT16 -EFIAPI -PeCoffLoaderGetMachineType ( - IN VOID *Pe32Data - ) -{ - EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr; - EFI_IMAGE_DOS_HEADER *DosHdr; - - ASSERT (Pe32Data != NULL); - - DosHdr = (EFI_IMAGE_DOS_HEADER *)Pe32Data; - if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) { - // - // 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)); - } else { - // - // DOS image header is not present, so PE header is at the image base. - // - Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)Pe32Data; - } - - if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) { - return Hdr.Te->Machine; - } else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) { - return Hdr.Pe32->FileHeader.Machine; - } - - return 0x0000; -} - -/** - Returns a pointer to the PDB file name for a PE/COFF image that has been - loaded into system memory with the PE/COFF Loader Library functions. - - Returns the PDB file name for the PE/COFF image specified by Pe32Data. If - the PE/COFF image specified by Pe32Data is not a valid, then NULL is - returned. If the PE/COFF image specified by Pe32Data does not contain a - debug directory entry, then NULL is returned. If the debug directory entry - in the PE/COFF image specified by Pe32Data does not contain a PDB file name, - then NULL is returned. - If Pe32Data is NULL, then ASSERT(). - - @param Pe32Data Pointer to the PE/COFF image that is loaded in system - memory. - - @return The PDB file name for the PE/COFF image specified by Pe32Data or NULL - if it cannot be retrieved. - -**/ -VOID * -EFIAPI -PeCoffLoaderGetPdbPointer ( - IN VOID *Pe32Data - ) -{ - EFI_IMAGE_DOS_HEADER *DosHdr; - EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr; - EFI_IMAGE_DATA_DIRECTORY *DirectoryEntry; - EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *DebugEntry; - UINTN DirCount; - VOID *CodeViewEntryPointer; - INTN TEImageAdjust; - UINT32 NumberOfRvaAndSizes; - UINT16 Magic; - - ASSERT (Pe32Data != NULL); - - TEImageAdjust = 0; - DirectoryEntry = NULL; - DebugEntry = NULL; - NumberOfRvaAndSizes = 0; - - DosHdr = (EFI_IMAGE_DOS_HEADER *)Pe32Data; - if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) { - // - // 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)); - } else { - // - // DOS image header is not present, so PE header is at the image base. - // - Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)Pe32Data; - } - - if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) { - if (Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress != 0) { - DirectoryEntry = &Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG]; - TEImageAdjust = sizeof (EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize; - DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)((UINTN) Hdr.Te + - Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress + - TEImageAdjust); - } - } else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) { - // - // NOTE: We use Machine field to identify PE32/PE32+, instead of Magic. - // It is due to backward-compatibility, for some system might - // generate PE32+ image with PE32 Magic. - // - switch (Hdr.Pe32->FileHeader.Machine) { - case IMAGE_FILE_MACHINE_I386: - // - // Assume PE32 image with IA32 Machine field. - // - Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC; - break; - case IMAGE_FILE_MACHINE_X64: - case IMAGE_FILE_MACHINE_IA64: - // - // Assume PE32+ image with X64 or IA64 Machine field - // - Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC; - break; - default: - // - // For unknow Machine field, use Magic in optional Header - // - Magic = Hdr.Pe32->OptionalHeader.Magic; - } - - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { - // - // Use PE32 offset get Debug Directory Entry - // - NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes; - DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]); - DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) Pe32Data + DirectoryEntry->VirtualAddress); - } else if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) { - // - // Use PE32+ offset get Debug Directory Entry - // - NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes; - DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]); - DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) Pe32Data + DirectoryEntry->VirtualAddress); - } - - if (NumberOfRvaAndSizes <= EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) { - DirectoryEntry = NULL; - DebugEntry = NULL; - } - } else { - return NULL; - } - - if (DebugEntry == NULL || DirectoryEntry == NULL) { - return NULL; - } - - for (DirCount = 0; DirCount < DirectoryEntry->Size; DirCount += sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY), DebugEntry++) { - if (DebugEntry->Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) { - if (DebugEntry->SizeOfData > 0) { - CodeViewEntryPointer = (VOID *) ((UINTN) DebugEntry->RVA + ((UINTN)Pe32Data) + (UINTN)TEImageAdjust); - switch (* (UINT32 *) CodeViewEntryPointer) { - case CODEVIEW_SIGNATURE_NB10: - return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY)); - case CODEVIEW_SIGNATURE_RSDS: - return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY)); - case CODEVIEW_SIGNATURE_MTOC: - return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY)); - break; - default: - break; - } - } - } - } - - return NULL; -} - -/** - Returns the size of the PE/COFF headers - - Returns the size of the PE/COFF header specified by Pe32Data. - If Pe32Data is NULL, then ASSERT(). - - @param Pe32Data Pointer to the PE/COFF image that is loaded in system - memory. - - @return Size of PE/COFF header in bytes or zero if not a valid image. - -**/ -UINT32 -EFIAPI -PeCoffGetSizeOfHeaders ( - IN VOID *Pe32Data - ) -{ - EFI_IMAGE_DOS_HEADER *DosHdr; - EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr; - UINTN SizeOfHeaders; - - ASSERT (Pe32Data != NULL); - - DosHdr = (EFI_IMAGE_DOS_HEADER *)Pe32Data; - if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) { - // - // 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)); - } else { - // - // DOS image header is not present, so PE header is at the image base. - // - Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)Pe32Data; - } - - if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) { - SizeOfHeaders = sizeof (EFI_TE_IMAGE_HEADER) + (UINTN)Hdr.Te->BaseOfCode - (UINTN)Hdr.Te->StrippedSize; - } else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) { - SizeOfHeaders = Hdr.Pe32->OptionalHeader.SizeOfHeaders; - } else { - SizeOfHeaders = 0; - } - - return (UINT32) SizeOfHeaders; -} - diff --git a/Nt32Pkg/Library/PeiNt32OemHookStatusCodeLib/Nt32OemHookStatusCodeLib.c b/Nt32Pkg/Library/PeiNt32OemHookStatusCodeLib/Nt32OemHookStatusCodeLib.c deleted file mode 100644 index e7c2df046a..0000000000 --- a/Nt32Pkg/Library/PeiNt32OemHookStatusCodeLib/Nt32OemHookStatusCodeLib.c +++ /dev/null @@ -1,241 +0,0 @@ -/** @file - OEM hook status code library functions with no library constructor/destructor - - Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
- SPDX-License-Identifier: BSD-2-Clause-Patent - - Module Name: Nt32OemHookStatusCodeLib.c - -**/ - -// -// The package level header files this module uses -// -#include - -// -// The protocols, PPI and GUID defintions for this module -// -#include -#include -#include -// -// The Library classes this module consumes -// -#include -#include -#include -#include -#include -#include - -// -// Cache of WinNtThunk protocol -// -EFI_WIN_NT_THUNK_PROTOCOL *mWinNt; - -// -// Cache of standard output handle . -// -HANDLE mStdOut; - -/** - - Initialize OEM status code device . - - @return Always return EFI_SUCCESS. - -**/ -EFI_STATUS -EFIAPI -OemHookStatusCodeInitialize ( - VOID - ) -{ - PEI_NT_THUNK_PPI *NtThunkPpi; - EFI_STATUS Status; - - - // - // Locate NtThunkPpi for retrieving standard output handle - // - Status = PeiServicesLocatePpi ( - &gPeiNtThunkPpiGuid, - 0, - NULL, - (VOID **) &NtThunkPpi - ); - - ASSERT_EFI_ERROR (Status); - - mWinNt = (EFI_WIN_NT_THUNK_PROTOCOL *) NtThunkPpi->NtThunk (); - - - // - // Cache standard output handle. - // - mStdOut = mWinNt->GetStdHandle (STD_OUTPUT_HANDLE); - - return EFI_SUCCESS; -} - -/** - Report status code to OEM device. - - @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below. - - @param Value Describes the current status of a hardware or software entity. - This included information about the class and subclass that is used to classify the entity - as well as an operation. For progress codes, the operation is the current activity. - For error codes, it is the exception. For debug codes, it is not defined at this time. - Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below. - Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification. - - @param Instance The enumeration of a hardware or software entity within the system. - A system may contain multiple entities that match a class/subclass pairing. - The instance differentiates between them. An instance of 0 indicates that instance information is unavailable, - not meaningful, or not relevant. Valid instance numbers start with 1. - - - @param CallerId This optional parameter may be used to identify the caller. - This parameter allows the status code driver to apply different rules to different callers. - Type EFI_GUID is defined in InstallProtocolInterface() in the UEFI 2.0 Specification. - - - @param Data This optional parameter may be used to pass additional data - - @return The function always return EFI_SUCCESS. - -**/ -EFI_STATUS -EFIAPI -OemHookStatusCodeReport ( - IN EFI_STATUS_CODE_TYPE CodeType, - IN EFI_STATUS_CODE_VALUE Value, - IN UINT32 Instance, - IN EFI_GUID *CallerId, OPTIONAL - IN EFI_STATUS_CODE_DATA *Data OPTIONAL - ) -{ - CHAR8 *Filename; - CHAR8 *Description; - CHAR8 *Format; - CHAR8 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE]; - UINT32 ErrorLevel; - UINT32 LineNumber; - UINTN CharCount; - BASE_LIST Marker; - - Buffer[0] = '\0'; - - if (Data != NULL && - ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) { - // - // Print ASSERT() information into output buffer. - // - CharCount = AsciiSPrint ( - Buffer, - sizeof (Buffer), - "\n\rASSERT!: %a (%d): %a\n\r", - Filename, - LineNumber, - Description - ); - - // - // Callout to standard output. - // - mWinNt->WriteFile ( - mStdOut, - Buffer, - (DWORD)CharCount, - (LPDWORD)&CharCount, - NULL - ); - - return EFI_SUCCESS; - - } else if (Data != NULL && - ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) { - // - // Print DEBUG() information into output buffer. - // - CharCount = AsciiBSPrint ( - Buffer, - sizeof (Buffer), - Format, - Marker - ); - } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) { - // - // Print ERROR information into output buffer. - // - CharCount = AsciiSPrint ( - Buffer, - sizeof (Buffer), - "ERROR: C%x:V%x I%x", - CodeType, - Value, - Instance - ); - - // - // Make sure we don't try to print values that weren't intended to be printed, especially NULL GUID pointers. - // - - if (CallerId != NULL) { - CharCount += AsciiSPrint ( - &Buffer[CharCount - 1], - (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)), - " %g", - CallerId - ); - } - - if (Data != NULL) { - CharCount += AsciiSPrint ( - &Buffer[CharCount - 1], - (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)), - " %p", - Data - ); - } - - CharCount += AsciiSPrint ( - &Buffer[CharCount - 1], - (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)), - "\n\r" - ); - } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) { - CharCount = AsciiSPrint ( - Buffer, - sizeof (Buffer), - "PROGRESS CODE: V%x I%x\n\r", - Value, - Instance - ); - } else { - CharCount = AsciiSPrint ( - Buffer, - sizeof (Buffer), - "Undefined: C%x:V%x I%x\n\r", - CodeType, - Value, - Instance - ); - } - - // - // Callout to standard output. - // - mWinNt->WriteFile ( - mStdOut, - Buffer, - (DWORD)CharCount, - (LPDWORD)&CharCount, - NULL - ); - - return EFI_SUCCESS; -} - diff --git a/Nt32Pkg/Library/PeiNt32OemHookStatusCodeLib/PeiNt32OemHookStatusCodeLib.inf b/Nt32Pkg/Library/PeiNt32OemHookStatusCodeLib/PeiNt32OemHookStatusCodeLib.inf deleted file mode 100644 index 5df74af95f..0000000000 --- a/Nt32Pkg/Library/PeiNt32OemHookStatusCodeLib/PeiNt32OemHookStatusCodeLib.inf +++ /dev/null @@ -1,44 +0,0 @@ -## @file -# Memory Status Code Library for UEFI drivers -# -# Lib to provide memory journal status code reporting Routines -# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
-# SPDX-License-Identifier: BSD-2-Clause-Patent - -# -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = PeiNt32OemHookStatusCodeLib - FILE_GUID = 0C2070F9-02A7-4e8e-B584-84EA922363FB - MODULE_TYPE = PEIM - VERSION_STRING = 1.0 - LIBRARY_CLASS = OemHookStatusCodeLib|PEIM - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 -# - -[Sources] - Nt32OemHookStatusCodeLib.c - - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - Nt32Pkg/Nt32Pkg.dec - -[LibraryClasses] - PeiServicesLib - ReportStatusCodeLib - BaseMemoryLib - PrintLib - DebugLib - -[Ppis] - gPeiNtThunkPpiGuid # PPI ALWAYS_CONSUMED - diff --git a/Nt32Pkg/Library/PeiNt32PeCoffExtraActionLib/PeiNt32PeCoffExtraActionLib.c b/Nt32Pkg/Library/PeiNt32PeCoffExtraActionLib/PeiNt32PeCoffExtraActionLib.c deleted file mode 100644 index 1035b92a10..0000000000 --- a/Nt32Pkg/Library/PeiNt32PeCoffExtraActionLib/PeiNt32PeCoffExtraActionLib.c +++ /dev/null @@ -1,244 +0,0 @@ -/**@file - -Copyright (c) 2006, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - PeiNt32PeCoffExtraActionLib.c - -Abstract: - - Provides services to perform additional actions to relocate and unload - PE/Coff image for NT32 environment specific purpose such as souce level debug. - This version only works for PEI phase - - -**/ -// -// The package level header files this module uses -// -#include -#include - -// -// The protocols, PPI and GUID defintions for this module -// -#include - -#include -#include -#include -#include -#include -#include - -// -// Cache of WinNtThunk protocol -// -EFI_WIN_NT_THUNK_PROTOCOL *mWinNt = NULL; - -/** - The function caches the pointer of the WinNT thunk functions - It will ASSERT() if NT thunk ppi is not installed. - - @retval EFI_SUCCESS WinNT thunk protocol is found and cached. - -**/ -EFI_STATUS -EFIAPI -Nt32PeCoffGetWinNtThunkStucture ( - ) -{ - PEI_NT_THUNK_PPI *NtThunkPpi; - EFI_STATUS Status; - - - // - // Locate NtThunkPpi for retrieving standard output handle - // - Status = PeiServicesLocatePpi ( - &gPeiNtThunkPpiGuid, - 0, - NULL, - (VOID **) &NtThunkPpi - ); - - ASSERT_EFI_ERROR (Status); - - mWinNt = (EFI_WIN_NT_THUNK_PROTOCOL *) NtThunkPpi->NtThunk (); - - return EFI_SUCCESS; -} - -/** - Convert the passed in Ascii string to Unicode. - - This function Convert the passed in Ascii string to Unicode.Optionally return - the length of the strings.. - - @param AsciiString Pointer to an AscII string - @param StrLen Length of string - - @return Pointer to malloc'ed Unicode version of Ascii - -**/ -CHAR16 * -AsciiToUnicode ( - IN CHAR8 *Ascii, - IN UINTN *StrLen OPTIONAL - ) -{ - UINTN Index; - CHAR16 *Unicode; - - // - // Allocate a buffer for unicode string - // - for (Index = 0; Ascii[Index] != '\0'; Index++) - ; - Unicode = mWinNt->HeapAlloc ( mWinNt->GetProcessHeap (), - HEAP_ZERO_MEMORY, - ((Index + 1) * sizeof (CHAR16)) - ); - if (Unicode == NULL) { - return NULL; - } - - for (Index = 0; Ascii[Index] != '\0'; Index++) { - Unicode[Index] = (CHAR16) Ascii[Index]; - } - - Unicode[Index] = '\0'; - - if (StrLen != NULL) { - *StrLen = Index; - } - - return Unicode; -} - -/** - Performs additional actions after a PE/COFF image has been loaded and relocated. - - For NT32, this function load symbols to support source level debugging. - - If ImageContext is NULL, then ASSERT(). - - @param ImageContext Pointer to the image context structure that describes the - PE/COFF image that has already been loaded and relocated. - -**/ -VOID -EFIAPI -PeCoffLoaderRelocateImageExtraAction ( - IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext - ) -{ - VOID *DllEntryPoint; - CHAR16 *DllFileName; - HMODULE Library; - UINTN Index; - - ASSERT (ImageContext != NULL); - - if (mWinNt == NULL) { - Nt32PeCoffGetWinNtThunkStucture (); - } - // - // If we load our own PE COFF images the Windows debugger can not source - // level debug our code. If a valid PDB pointer exists usw it to load - // the *.dll file as a library using Windows* APIs. This allows - // source level debug. The image is still loaded and relocated - // in the Framework memory space like on a real system (by the code above), - // but the entry point points into the DLL loaded by the code bellow. - // - - DllEntryPoint = NULL; - - // - // Load the DLL if it's not an EBC image. - // - if ((ImageContext->PdbPointer != NULL) && - (ImageContext->Machine != EFI_IMAGE_MACHINE_EBC)) { - // - // Convert filename from ASCII to Unicode - // - DllFileName = AsciiToUnicode (ImageContext->PdbPointer, &Index); - - // - // Check that we have a valid filename - // - if (Index < 5 || DllFileName[Index - 4] != '.') { - mWinNt->HeapFree (mWinNt->GetProcessHeap (), 0, DllFileName); - - // - // Never return an error if PeCoffLoaderRelocateImage() succeeded. - // The image will run, but we just can't source level debug. If we - // return an error the image will not run. - // - return; - } - // - // Replace .PDB with .DLL on the filename - // - DllFileName[Index - 3] = 'D'; - DllFileName[Index - 2] = 'L'; - DllFileName[Index - 1] = 'L'; - - // - // Load the .DLL file into the user process's address space for source - // level debug - // - Library = mWinNt->LoadLibraryEx (DllFileName, NULL, DONT_RESOLVE_DLL_REFERENCES); - if (Library != NULL) { - // - // InitializeDriver is the entry point we put in all our EFI DLL's. The - // DONT_RESOLVE_DLL_REFERENCES argument to LoadLIbraryEx() suppresses the - // normal DLL entry point of DllMain, and prevents other modules that are - // referenced in side the DllFileName from being loaded. There is no error - // checking as the we can point to the PE32 image loaded by Tiano. This - // step is only needed for source level debugging - // - DllEntryPoint = (VOID *) (UINTN) mWinNt->GetProcAddress (Library, "InitializeDriver"); - - } - - if ((Library != NULL) && (DllEntryPoint != NULL)) { - ImageContext->EntryPoint = (EFI_PHYSICAL_ADDRESS) (UINTN) DllEntryPoint; - DEBUG ((EFI_D_INFO, "LoadLibraryEx (%s,\n NULL, DONT_RESOLVE_DLL_REFERENCES)\n", DllFileName)); - } else { - DEBUG ((EFI_D_ERROR, "WARNING: No source level debug %s. \n", DllFileName)); - } - - mWinNt->HeapFree (mWinNt->GetProcessHeap (), 0, DllFileName); - } - - // - // Never return an error if PeCoffLoaderRelocateImage() succeeded. - // The image will run, but we just can't source level debug. If we - // return an error the image will not run. - // - return; -} - -/** - Performs additional actions just before a PE/COFF image is unloaded. Any resources - that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed. - - For NT32, this function unloads symbols for source level debugging. - - If ImageContext is NULL, then ASSERT(). - - @param ImageContext Pointer to the image context structure that describes the - PE/COFF image that is being unloaded. - -**/ -VOID -EFIAPI -PeCoffLoaderUnloadImageExtraAction ( - IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext - ) -{ - ASSERT (ImageContext != NULL); -} diff --git a/Nt32Pkg/Library/PeiNt32PeCoffExtraActionLib/PeiNt32PeCoffExtraActionLib.inf b/Nt32Pkg/Library/PeiNt32PeCoffExtraActionLib/PeiNt32PeCoffExtraActionLib.inf deleted file mode 100644 index 8b6bd91a86..0000000000 --- a/Nt32Pkg/Library/PeiNt32PeCoffExtraActionLib/PeiNt32PeCoffExtraActionLib.inf +++ /dev/null @@ -1,39 +0,0 @@ -## @file -# PeCoff extra action libary for Pei phase that run NT32 emulator. -# -# Lib to provide memory journal status code reporting Routines -# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
-# SPDX-License-Identifier: BSD-2-Clause-Patent - -# -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = PeiNt32PeCoffExtraActionLib - FILE_GUID = 057C712A-84F0-4f4a-94CB-713EEF002E2F - MODULE_TYPE = PEIM - VERSION_STRING = 1.0 - LIBRARY_CLASS = PeCoffExtraActionLib|PEI_CORE PEIM - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 -# - -[Sources] - PeiNt32PeCoffExtraActionLib.c - -[Packages] - MdePkg/MdePkg.dec - Nt32Pkg/Nt32Pkg.dec - -[LibraryClasses] - BaseLib - PeiServicesLib - DebugLib - -[Ppis] - gPeiNtThunkPpiGuid # PPI ALWAYS_CONSUMED diff --git a/Nt32Pkg/Library/PlatformBootManagerLib/MemoryTest.c b/Nt32Pkg/Library/PlatformBootManagerLib/MemoryTest.c deleted file mode 100644 index df0d56a369..0000000000 --- a/Nt32Pkg/Library/PlatformBootManagerLib/MemoryTest.c +++ /dev/null @@ -1,253 +0,0 @@ -/** @file - Perform the platform memory test - -Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#include "PlatformBootManager.h" - -EFI_HII_HANDLE gStringPackHandle = NULL; -EFI_GUID mPlatformBootManagerStringPackGuid = { - 0x154dd51, 0x9079, 0x4a10, { 0x89, 0x5c, 0x9c, 0x7, 0x72, 0x81, 0x57, 0x88 } - }; -// extern UINT8 BdsDxeStrings[]; - -// -// BDS Platform Functions -// - -/** - Perform the memory test base on the memory test intensive level, - and update the memory resource. - - @param Level The memory test intensive level. - - @retval EFI_STATUS Success test all the system memory and update - the memory resource - -**/ -EFI_STATUS -PlatformBootManagerMemoryTest ( - IN EXTENDMEM_COVERAGE_LEVEL Level - ) -{ - EFI_STATUS Status; - EFI_STATUS KeyStatus; - EFI_STATUS InitStatus; - EFI_STATUS ReturnStatus; - BOOLEAN RequireSoftECCInit; - EFI_GENERIC_MEMORY_TEST_PROTOCOL *GenMemoryTest; - UINT64 TestedMemorySize; - UINT64 TotalMemorySize; - UINTN TestPercent; - UINT64 PreviousValue; - BOOLEAN ErrorOut; - BOOLEAN TestAbort; - EFI_INPUT_KEY Key; - CHAR16 StrPercent[80]; - CHAR16 *StrTotalMemory; - CHAR16 *Pos; - CHAR16 *TmpStr; - EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground; - EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background; - EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color; - UINT32 TempData; - UINTN StrTotalMemorySize; - - ReturnStatus = EFI_SUCCESS; - ZeroMem (&Key, sizeof (EFI_INPUT_KEY)); - - StrTotalMemorySize = 128; - Pos = AllocateZeroPool (StrTotalMemorySize); - ASSERT (Pos != NULL); - - if (gStringPackHandle == NULL) { - gStringPackHandle = HiiAddPackages ( - &mPlatformBootManagerStringPackGuid, - gImageHandle, - PlatformBootManagerLibStrings, - NULL - ); - ASSERT (gStringPackHandle != NULL); - } - - StrTotalMemory = Pos; - - TestedMemorySize = 0; - TotalMemorySize = 0; - PreviousValue = 0; - ErrorOut = FALSE; - TestAbort = FALSE; - - SetMem (&Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff); - SetMem (&Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0x0); - SetMem (&Color, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff); - - RequireSoftECCInit = FALSE; - - Status = gBS->LocateProtocol ( - &gEfiGenericMemTestProtocolGuid, - NULL, - (VOID **) &GenMemoryTest - ); - if (EFI_ERROR (Status)) { - FreePool (Pos); - return EFI_SUCCESS; - } - - InitStatus = GenMemoryTest->MemoryTestInit ( - GenMemoryTest, - Level, - &RequireSoftECCInit - ); - if (InitStatus == EFI_NO_MEDIA) { - // - // The PEI codes also have the relevant memory test code to check the memory, - // it can select to test some range of the memory or all of them. If PEI code - // checks all the memory, this BDS memory test will has no not-test memory to - // do the test, and then the status of EFI_NO_MEDIA will be returned by - // "MemoryTestInit". So it does not need to test memory again, just return. - // - FreePool (Pos); - return EFI_SUCCESS; - } - - if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) { - TmpStr = HiiGetString (gStringPackHandle, STRING_TOKEN (STR_ESC_TO_SKIP_MEM_TEST), NULL); - - if (TmpStr != NULL) { - PrintXY (10, 10, NULL, NULL, TmpStr); - FreePool (TmpStr); - } - } else { - DEBUG ((EFI_D_INFO, "Enter memory test.\n")); - } - do { - Status = GenMemoryTest->PerformMemoryTest ( - GenMemoryTest, - &TestedMemorySize, - &TotalMemorySize, - &ErrorOut, - TestAbort - ); - if (ErrorOut && (Status == EFI_DEVICE_ERROR)) { - TmpStr = HiiGetString (gStringPackHandle, STRING_TOKEN (STR_SYSTEM_MEM_ERROR), NULL); - if (TmpStr != NULL) { - PrintXY (10, 10, NULL, NULL, TmpStr); - FreePool (TmpStr); - } - - ASSERT (0); - } - - if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) { - TempData = (UINT32) DivU64x32 (TotalMemorySize, 16); - TestPercent = (UINTN) DivU64x32 ( - DivU64x32 (MultU64x32 (TestedMemorySize, 100), 16), - TempData - ); - if (TestPercent != PreviousValue) { - UnicodeValueToStringS (StrPercent, sizeof (StrPercent), 0, TestPercent, 0); - TmpStr = HiiGetString (gStringPackHandle, STRING_TOKEN (STR_MEMORY_TEST_PERCENT), NULL); - if (TmpStr != NULL) { - // - // TmpStr size is 64, StrPercent is reserved to 16. - // - StrnCatS ( - StrPercent, - sizeof (StrPercent) / sizeof (CHAR16), - TmpStr, - sizeof (StrPercent) / sizeof (CHAR16) - StrLen (StrPercent) - 1 - ); - PrintXY (10, 10, NULL, NULL, StrPercent); - FreePool (TmpStr); - } - - TmpStr = HiiGetString (gStringPackHandle, STRING_TOKEN (STR_PERFORM_MEM_TEST), NULL); - if (TmpStr != NULL) { - BootLogoUpdateProgress ( - Foreground, - Background, - TmpStr, - Color, - TestPercent, - (UINTN) PreviousValue - ); - FreePool (TmpStr); - } - } - - PreviousValue = TestPercent; - } else { - DEBUG ((EFI_D_INFO, "Perform memory test (ESC to skip).\n")); - } - - if (!PcdGetBool (PcdConInConnectOnDemand)) { - KeyStatus = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key); - if (!EFI_ERROR (KeyStatus) && (Key.ScanCode == SCAN_ESC)) { - if (!RequireSoftECCInit) { - if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) { - TmpStr = HiiGetString (gStringPackHandle, STRING_TOKEN (STR_PERFORM_MEM_TEST), NULL); - if (TmpStr != NULL) { - BootLogoUpdateProgress ( - Foreground, - Background, - TmpStr, - Color, - 100, - (UINTN) PreviousValue - ); - FreePool (TmpStr); - } - - PrintXY (10, 10, NULL, NULL, L"100"); - } - Status = GenMemoryTest->Finished (GenMemoryTest); - goto Done; - } - - TestAbort = TRUE; - } - } - } while (Status != EFI_NOT_FOUND); - - Status = GenMemoryTest->Finished (GenMemoryTest); - -Done: - if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) { - UnicodeValueToStringS (StrTotalMemory, StrTotalMemorySize, COMMA_TYPE, TotalMemorySize, 0); - if (StrTotalMemory[0] == L',') { - StrTotalMemory++; - StrTotalMemorySize -= sizeof (CHAR16); - } - - TmpStr = HiiGetString (gStringPackHandle, STRING_TOKEN (STR_MEM_TEST_COMPLETED), NULL); - if (TmpStr != NULL) { - StrnCatS ( - StrTotalMemory, - StrTotalMemorySize / sizeof (CHAR16), - TmpStr, - StrTotalMemorySize / sizeof (CHAR16) - StrLen (StrTotalMemory) - 1 - ); - FreePool (TmpStr); - } - - PrintXY (10, 10, NULL, NULL, StrTotalMemory); - BootLogoUpdateProgress ( - Foreground, - Background, - StrTotalMemory, - Color, - 100, - (UINTN) PreviousValue - ); - - } else { - DEBUG ((EFI_D_INFO, "%d bytes of system memory tested OK\r\n", TotalMemorySize)); - } - - FreePool (Pos); - return ReturnStatus; -} diff --git a/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c b/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c deleted file mode 100644 index 5967db1391..0000000000 --- a/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c +++ /dev/null @@ -1,416 +0,0 @@ -/** @file - This file include all platform action which can be customized - by IBV/OEM. - -Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
-(C) Copyright 2016 Hewlett Packard Enterprise Development LP
-SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#include "PlatformBootManager.h" - -EFI_GUID mBootMenuFile = { - 0xEEC25BDC, 0x67F2, 0x4D95, { 0xB1, 0xD5, 0xF8, 0x1B, 0x20, 0x39, 0xD1, 0x1D } -}; - -/** - Perform the platform diagnostic, such like test memory. OEM/IBV also - can customize this function to support specific platform diagnostic. - - @param MemoryTestLevel The memory test intensive level - @param QuietBoot Indicate if need to enable the quiet boot - -**/ -VOID -PlatformBootManagerDiagnostics ( - IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel, - IN BOOLEAN QuietBoot - ) -{ - EFI_STATUS Status; - - // - // Here we can decide if we need to show - // the diagnostics screen - // Notes: this quiet boot code should be remove - // from the graphic lib - // - if (QuietBoot) { - BootLogoEnableLogo (); - - // - // Perform system diagnostic - // - Status = PlatformBootManagerMemoryTest (MemoryTestLevel); - if (EFI_ERROR (Status)) { - BootLogoDisableLogo (); - } - - return; - } - - // - // Perform system diagnostic - // - Status = PlatformBootManagerMemoryTest (MemoryTestLevel); -} - -/** - Do the platform specific action before the console is connected. - - Such as: - Update console variable; - Register new Driver#### or Boot####; - Signal ReadyToLock event. -**/ -VOID -EFIAPI -PlatformBootManagerBeforeConsole ( - VOID - ) -{ - UINTN Index; - EFI_STATUS Status; - WIN_NT_SYSTEM_CONFIGURATION *Configuration; - - GetVariable2 (L"Setup", &gEfiWinNtSystemConfigGuid, (VOID **) &Configuration, NULL); - if (Configuration != NULL) { - // - // SetupVariable is corrupt - // - Configuration->ConOutRow = PcdGet32 (PcdConOutColumn); - Configuration->ConOutColumn = PcdGet32 (PcdConOutRow); - - Status = gRT->SetVariable ( - L"Setup", - &gEfiWinNtSystemConfigGuid, - EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, - sizeof (WIN_NT_SYSTEM_CONFIGURATION), - Configuration - ); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "Failed to save Setup Variable to non-volatile storage, Status = %r\n", Status)); - } - FreePool (Configuration); - } - - // - // Update the ocnsole variables. - // - for (Index = 0; gPlatformConsole[Index].DevicePath != NULL; Index++) { - if ((gPlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) { - EfiBootManagerUpdateConsoleVariable (ConIn, gPlatformConsole[Index].DevicePath, NULL); - } - - if ((gPlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) { - EfiBootManagerUpdateConsoleVariable (ConOut, gPlatformConsole[Index].DevicePath, NULL); - } - - if ((gPlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) { - EfiBootManagerUpdateConsoleVariable (ErrOut, gPlatformConsole[Index].DevicePath, NULL); - } - } - - // - // From PI spec vol2: - // Prior to invoking any UEFI drivers, applications, or connecting consoles, - // the platform should signal the event EFI_END_OF_DXE_EVENT_GUID - // - EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid); - - // - // Dispatch deferred images after EndOfDxe event. - // - EfiBootManagerDispatchDeferredImages (); -} - -/** - Returns the priority number. - - @param BootOption -**/ -UINTN -BootOptionPriority ( - CONST EFI_BOOT_MANAGER_LOAD_OPTION *BootOption - ) -{ - // - // Make sure Shell is first - // - if (StrCmp (BootOption->Description, L"UEFI Shell") == 0) { - return 0; - } - return 100; -} - -INTN -EFIAPI -CompareBootOption ( - CONST EFI_BOOT_MANAGER_LOAD_OPTION *Left, - CONST EFI_BOOT_MANAGER_LOAD_OPTION *Right - ) -{ - return BootOptionPriority (Left) - BootOptionPriority (Right); -} - -/** - Generate device path include the input file guid info. - - @param FileGuid Input file guid for the BootManagerMenuApp. - - @retval DevicePath for BootManagerMenuApp. -**/ -EFI_DEVICE_PATH * -FvFilePath ( - EFI_GUID *FileGuid - ) -{ - - EFI_STATUS Status; - EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; - MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode; - - EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid); - - Status = gBS->HandleProtocol ( - gImageHandle, - &gEfiLoadedImageProtocolGuid, - (VOID **) &LoadedImage - ); - ASSERT_EFI_ERROR (Status); - - return AppendDevicePathNode ( - DevicePathFromHandle (LoadedImage->DeviceHandle), - (EFI_DEVICE_PATH_PROTOCOL *) &FileNode - ); -} - -/** - Create one boot option for BootManagerMenuApp. - - @param FileGuid Input file guid for the BootManagerMenuApp. - @param Description Description of the BootManagerMenuApp boot option. - @param Position Position of the new load option to put in the ****Order variable. - @param IsBootCategory Whether this is a boot category. - - - @retval OptionNumber Return the option number info. - -**/ -UINTN -RegisterBootManagerMenuAppBootOption ( - EFI_GUID *FileGuid, - CHAR16 *Description, - UINTN Position, - BOOLEAN IsBootCategory - ) -{ - EFI_STATUS Status; - EFI_BOOT_MANAGER_LOAD_OPTION NewOption; - EFI_DEVICE_PATH_PROTOCOL *DevicePath; - UINTN OptionNumber; - - DevicePath = FvFilePath (FileGuid); - Status = EfiBootManagerInitializeLoadOption ( - &NewOption, - LoadOptionNumberUnassigned, - LoadOptionTypeBoot, - IsBootCategory ? LOAD_OPTION_ACTIVE : LOAD_OPTION_CATEGORY_APP, - Description, - DevicePath, - NULL, - 0 - ); - ASSERT_EFI_ERROR (Status); - FreePool (DevicePath); - - Status = EfiBootManagerAddLoadOptionVariable (&NewOption, Position); - ASSERT_EFI_ERROR (Status); - - OptionNumber = NewOption.OptionNumber; - - EfiBootManagerFreeLoadOption (&NewOption); - - return OptionNumber; -} - -/** - Check if it's a Device Path pointing to BootManagerMenuApp. - - @param DevicePath Input device path. - - @retval TRUE The device path is BootManagerMenuApp File Device Path. - @retval FALSE The device path is NOT BootManagerMenuApp File Device Path. -**/ -BOOLEAN -IsBootManagerMenuAppFilePath ( - EFI_DEVICE_PATH_PROTOCOL *DevicePath -) -{ - EFI_HANDLE FvHandle; - VOID *NameGuid; - EFI_STATUS Status; - - Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &DevicePath, &FvHandle); - if (!EFI_ERROR (Status)) { - NameGuid = EfiGetNameGuidFromFwVolDevicePathNode ((CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) DevicePath); - if (NameGuid != NULL) { - return CompareGuid (NameGuid, &mBootMenuFile); - } - } - - return FALSE; -} - -/** - Return the boot option number to the BootManagerMenuApp. - - If not found it in the current boot option, create a new one. - - @retval OptionNumber Return the boot option number to the BootManagerMenuApp. - -**/ -UINTN -GetBootManagerMenuAppOption ( - VOID - ) -{ - UINTN BootOptionCount; - EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions; - UINTN Index; - UINTN OptionNumber; - - OptionNumber = 0; - - BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot); - - for (Index = 0; Index < BootOptionCount; Index++) { - if (IsBootManagerMenuAppFilePath (BootOptions[Index].FilePath)) { - OptionNumber = BootOptions[Index].OptionNumber; - break; - } - } - - EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount); - - if (Index >= BootOptionCount) { - // - // If not found the BootManagerMenuApp, create it. - // - OptionNumber = (UINT16) RegisterBootManagerMenuAppBootOption (&mBootMenuFile, L"UEFI BootManagerMenuApp", (UINTN) -1, FALSE); - } - - return OptionNumber; -} - -/** - Do the platform specific action after the console is connected. - - Such as: - Dynamically switch output mode; - Signal console ready platform customized event; - Run diagnostics like memory testing; - Connect certain devices; - Dispatch aditional option roms. -**/ -VOID -EFIAPI -PlatformBootManagerAfterConsole ( - VOID - ) -{ - EFI_GRAPHICS_OUTPUT_BLT_PIXEL Black; - EFI_GRAPHICS_OUTPUT_BLT_PIXEL White; - EFI_INPUT_KEY Enter; - EFI_INPUT_KEY F2; - EFI_INPUT_KEY F7; - EFI_BOOT_MANAGER_LOAD_OPTION BootOption; - UINTN OptionNumber; - - Black.Blue = Black.Green = Black.Red = Black.Reserved = 0; - White.Blue = White.Green = White.Red = White.Reserved = 0xFF; - - EfiBootManagerConnectAll (); - EfiBootManagerRefreshAllBootOption (); - - // - // Register ENTER as CONTINUE key - // - Enter.ScanCode = SCAN_NULL; - Enter.UnicodeChar = CHAR_CARRIAGE_RETURN; - EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL); - // - // Map F2 to Boot Manager Menu - // - F2.ScanCode = SCAN_F2; - F2.UnicodeChar = CHAR_NULL; - EfiBootManagerGetBootManagerMenu (&BootOption); - EfiBootManagerAddKeyOptionVariable (NULL, (UINT16) BootOption.OptionNumber, 0, &F2, NULL); - - // - // 3. Boot Device List menu - // - F7.ScanCode = SCAN_F7; - F7.UnicodeChar = CHAR_NULL; - OptionNumber = GetBootManagerMenuAppOption (); - EfiBootManagerAddKeyOptionVariable (NULL, (UINT16)OptionNumber, 0, &F7, NULL); - - // - // Make Shell as the first boot option - // - EfiBootManagerSortLoadOptionVariable (LoadOptionTypeBoot, (SORT_COMPARE) CompareBootOption); - - PlatformBootManagerDiagnostics (QUICK, TRUE); - - PrintXY (10, 10, &White, &Black, L"F2 to enter Setup. "); - PrintXY (10, 30, &White, &Black, L"F7 to enter Boot Manager Menu."); - PrintXY (10, 50, &White, &Black, L"Enter to boot directly."); -} - -/** - This function is called each second during the boot manager waits the timeout. - - @param TimeoutRemain The remaining timeout. -**/ -VOID -EFIAPI -PlatformBootManagerWaitCallback ( - UINT16 TimeoutRemain - ) -{ - EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black; - EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION White; - UINT16 Timeout; - - Timeout = PcdGet16 (PcdPlatformBootTimeOut); - - Black.Raw = 0x00000000; - White.Raw = 0x00FFFFFF; - - BootLogoUpdateProgress ( - White.Pixel, - Black.Pixel, - L"Start boot option", - White.Pixel, - (Timeout - TimeoutRemain) * 100 / Timeout, - 0 - ); -} - -/** - The function is called when no boot option could be launched, - including platform recovery options and options pointing to applications - built into firmware volumes. - - If this function returns, BDS attempts to enter an infinite loop. -**/ -VOID -EFIAPI -PlatformBootManagerUnableToBoot ( - VOID - ) -{ - return; -} - diff --git a/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.h b/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.h deleted file mode 100644 index 06822d104f..0000000000 --- a/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.h +++ /dev/null @@ -1,144 +0,0 @@ -/**@file - Head file for BDS Platform specific code - -Copyright (c) 2015, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent -**/ - -#ifndef _PLATFORM_BOOT_MANAGER_H -#define _PLATFORM_BOOT_MANAGER_H - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -typedef struct { - EFI_DEVICE_PATH_PROTOCOL *DevicePath; - UINTN ConnectType; -} PLATFORM_CONSOLE_CONNECT_ENTRY; - -extern PLATFORM_CONSOLE_CONNECT_ENTRY gPlatformConsole[]; - -#define gEndEntire \ - { \ - END_DEVICE_PATH_TYPE,\ - END_ENTIRE_DEVICE_PATH_SUBTYPE,\ - END_DEVICE_PATH_LENGTH,\ - 0\ - } - -#define CONSOLE_OUT BIT0 -#define CONSOLE_IN BIT1 -#define STD_ERROR BIT2 - -typedef struct { - VENDOR_DEVICE_PATH VendorDevicePath; - UINT32 Instance; -} WIN_NT_VENDOR_DEVICE_PATH_NODE; - -// -// Below is the platform console device path -// -typedef struct { - VENDOR_DEVICE_PATH NtBus; - WIN_NT_VENDOR_DEVICE_PATH_NODE SerialDevice; - UART_DEVICE_PATH Uart; - VENDOR_DEVICE_PATH TerminalType; - EFI_DEVICE_PATH_PROTOCOL End; -} NT_ISA_SERIAL_DEVICE_PATH; - -typedef struct { - VENDOR_DEVICE_PATH NtBus; - WIN_NT_VENDOR_DEVICE_PATH_NODE NtGopDevice; - EFI_DEVICE_PATH_PROTOCOL End; -} NT_PLATFORM_GOP_DEVICE_PATH; - -/** - Use SystemTable Conout to stop video based Simple Text Out consoles from going - to the video device. Put up LogoFile on every video device that is a console. - - @param[in] LogoFile File name of logo to display on the center of the screen. - - @retval EFI_SUCCESS ConsoleControl has been flipped to graphics and logo displayed. - @retval EFI_UNSUPPORTED Logo not found - -**/ -EFI_STATUS -PlatformBootManagerEnableQuietBoot ( - IN EFI_GUID *LogoFile - ); - -/** - Use SystemTable Conout to turn on video based Simple Text Out consoles. The - Simple Text Out screens will now be synced up with all non video output devices - - @retval EFI_SUCCESS UGA devices are back in text mode and synced up. - -**/ -EFI_STATUS -PlatformBootManagerDisableQuietBoot ( - VOID - ); - -/** - Perform the memory test base on the memory test intensive level, - and update the memory resource. - - @param Level The memory test intensive level. - - @retval EFI_STATUS Success test all the system memory and update - the memory resource - -**/ -EFI_STATUS -PlatformBootManagerMemoryTest ( - IN EXTENDMEM_COVERAGE_LEVEL Level - ); - -/** - - Show progress bar with title above it. It only works in Graphics mode. - - - @param TitleForeground Foreground color for Title. - @param TitleBackground Background color for Title. - @param Title Title above progress bar. - @param ProgressColor Progress bar color. - @param Progress Progress (0-100) - @param PreviousValue The previous value of the progress. - - @retval EFI_STATUS Success update the progress bar - -**/ -EFI_STATUS -PlatformBootManagerShowProgress ( - IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleForeground, - IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleBackground, - IN CHAR16 *Title, - IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL ProgressColor, - IN UINTN Progress, - IN UINTN PreviousValue - ); - -#endif // _PLATFORM_BOOT_MANAGER_H diff --git a/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf deleted file mode 100644 index 343bd7864b..0000000000 --- a/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf +++ /dev/null @@ -1,69 +0,0 @@ -## @file -# Include all platform action which can be customized by IBV/OEM. -# -# Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.
-# (C) Copyright 2016 Hewlett Packard Enterprise Development LP
-# SPDX-License-Identifier: BSD-2-Clause-Patent -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = PlatformBootManagerLib - FILE_GUID = F0D9063A-DADB-4185-85E2-D7ACDA93F7A6 - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - LIBRARY_CLASS = PlatformBootManagerLib|DXE_DRIVER - - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 EBC -# - -[Sources] - PlatformData.c - PlatformBootManager.c - PlatformBootManager.h - MemoryTest.c - Strings.uni - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec - Nt32Pkg/Nt32Pkg.dec - -[LibraryClasses] - BaseLib - UefiBootServicesTableLib - UefiRuntimeServicesTableLib - UefiLib - UefiBootManagerLib - PcdLib - DxeServicesLib - MemoryAllocationLib - DevicePathLib - HiiLib - PrintLib - BootLogoLib - -[Guids] - gEfiWinNtSystemConfigGuid - gEfiEndOfDxeEventGroupGuid - -[Protocols] - gEfiGenericMemTestProtocolGuid ## CONSUMES - gEfiGraphicsOutputProtocolGuid ## CONSUMES - gEfiUgaDrawProtocolGuid ## CONSUMES - gEfiBootLogoProtocolGuid ## CONSUMES - gEfiFirmwareVolume2ProtocolGuid ## CONSUMES - -[Pcd] - gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut - gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport - gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow - gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn - gEfiMdeModulePkgTokenSpaceGuid.PcdConInConnectOnDemand - gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdBootlogoOnlyEnable diff --git a/Nt32Pkg/Library/PlatformBootManagerLib/PlatformData.c b/Nt32Pkg/Library/PlatformBootManagerLib/PlatformData.c deleted file mode 100644 index 8ab53b4e39..0000000000 --- a/Nt32Pkg/Library/PlatformBootManagerLib/PlatformData.c +++ /dev/null @@ -1,152 +0,0 @@ -/**@file - Defined the platform specific device path which will be filled to - ConIn/ConOut variables. - -Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent -**/ - -#include "PlatformBootManager.h" - -// -// Platform specific keyboard device path -// -NT_PLATFORM_GOP_DEVICE_PATH gGopDevicePath0 = { - { - HARDWARE_DEVICE_PATH, - HW_VENDOR_DP, - (UINT8) (sizeof (VENDOR_DEVICE_PATH)), - (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8), - EFI_WIN_NT_THUNK_PROTOCOL_GUID - }, - { - HARDWARE_DEVICE_PATH, - HW_VENDOR_DP, - (UINT8) (sizeof (WIN_NT_VENDOR_DEVICE_PATH_NODE)), - (UINT8) ((sizeof (WIN_NT_VENDOR_DEVICE_PATH_NODE)) >> 8), - EFI_WIN_NT_GOP_GUID, - 0 - }, - gEndEntire -}; - -NT_PLATFORM_GOP_DEVICE_PATH gGopDevicePath1 = { - { - HARDWARE_DEVICE_PATH, - HW_VENDOR_DP, - (UINT8) (sizeof (VENDOR_DEVICE_PATH)), - (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8), - EFI_WIN_NT_THUNK_PROTOCOL_GUID - }, - { - HARDWARE_DEVICE_PATH, - HW_VENDOR_DP, - (UINT8) (sizeof (WIN_NT_VENDOR_DEVICE_PATH_NODE)), - (UINT8) ((sizeof (WIN_NT_VENDOR_DEVICE_PATH_NODE)) >> 8), - EFI_WIN_NT_GOP_GUID, - 1 - }, - gEndEntire -}; - -// -// Platform specific serial device path -// -NT_ISA_SERIAL_DEVICE_PATH gNtSerialDevicePath0 = { - { - HARDWARE_DEVICE_PATH, - HW_VENDOR_DP, - (UINT8) (sizeof (VENDOR_DEVICE_PATH)), - (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8), - EFI_WIN_NT_THUNK_PROTOCOL_GUID - }, - { - HARDWARE_DEVICE_PATH, - HW_VENDOR_DP, - (UINT8) (sizeof (WIN_NT_VENDOR_DEVICE_PATH_NODE)), - (UINT8) ((sizeof (WIN_NT_VENDOR_DEVICE_PATH_NODE)) >> 8), - EFI_WIN_NT_SERIAL_PORT_GUID - }, - { - MESSAGING_DEVICE_PATH, - MSG_UART_DP, - (UINT8) (sizeof (UART_DEVICE_PATH)), - (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8), - 0, - 115200, - 8, - 1, - 1 - }, - { - MESSAGING_DEVICE_PATH, - MSG_VENDOR_DP, - (UINT8) (sizeof (VENDOR_DEVICE_PATH)), - (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8), - DEVICE_PATH_MESSAGING_PC_ANSI - }, - gEndEntire -}; - -NT_ISA_SERIAL_DEVICE_PATH gNtSerialDevicePath1 = { - { - HARDWARE_DEVICE_PATH, - HW_VENDOR_DP, - (UINT8) (sizeof (VENDOR_DEVICE_PATH)), - (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8), - EFI_WIN_NT_THUNK_PROTOCOL_GUID - }, - { - HARDWARE_DEVICE_PATH, - HW_VENDOR_DP, - (UINT8) (sizeof (WIN_NT_VENDOR_DEVICE_PATH_NODE)), - (UINT8) ((sizeof (WIN_NT_VENDOR_DEVICE_PATH_NODE)) >> 8), - EFI_WIN_NT_SERIAL_PORT_GUID, - 1 - }, - { - MESSAGING_DEVICE_PATH, - MSG_UART_DP, - (UINT8) (sizeof (UART_DEVICE_PATH)), - (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8), - 0, - 115200, - 8, - 1, - 1 - }, - { - MESSAGING_DEVICE_PATH, - MSG_VENDOR_DP, - (UINT8) (sizeof (VENDOR_DEVICE_PATH)), - (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8), - DEVICE_PATH_MESSAGING_PC_ANSI - }, - gEndEntire -}; - -// -// Predefined platform default console device path -// -PLATFORM_CONSOLE_CONNECT_ENTRY gPlatformConsole[] = { - { - (EFI_DEVICE_PATH_PROTOCOL *) &gNtSerialDevicePath0, - (CONSOLE_OUT | CONSOLE_IN | STD_ERROR) - }, - { - (EFI_DEVICE_PATH_PROTOCOL *) &gNtSerialDevicePath1, - (CONSOLE_OUT | CONSOLE_IN | STD_ERROR) - }, - { - (EFI_DEVICE_PATH_PROTOCOL *) &gGopDevicePath0, - (CONSOLE_OUT | CONSOLE_IN | STD_ERROR) - }, - { - (EFI_DEVICE_PATH_PROTOCOL *) &gGopDevicePath1, - (CONSOLE_OUT | CONSOLE_IN | STD_ERROR) - }, - { - NULL, - 0 - } -}; diff --git a/Nt32Pkg/Library/PlatformBootManagerLib/Strings.uni b/Nt32Pkg/Library/PlatformBootManagerLib/Strings.uni deleted file mode 100644 index d5a28e0ad5..0000000000 --- a/Nt32Pkg/Library/PlatformBootManagerLib/Strings.uni +++ /dev/null @@ -1,27 +0,0 @@ -///** @file -// -// String definitions for PlatformBootManagerLib. -// -// Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.
-// SPDX-License-Identifier: BSD-2-Clause-Patent -// -//**/ - -/=# - -#langdef en-US "English" -#langdef fr-FR "Français" - -#string STR_PERFORM_MEM_TEST #language en-US "Perform memory test (ESC to skip)" - #language fr-FR "Exécute l'examen de mémoire (ESC pour sauter)" -#string STR_MEMORY_TEST_PERCENT #language en-US "% of the system memory tested OK" - #language fr-FR "% de la mémoire de système essayée D'ACCORD" -#string STR_ESC_TO_SKIP_MEM_TEST #language en-US "Press ESC key to skip memory test" - #language fr-FR "Appuie sur ESC sauter examen de mémoire" -#string STR_MEM_TEST_COMPLETED #language en-US " bytes of system memory tested OK\r\n" - #language fr-FR "octets dela mémoire de système essayée D'ACCORD\r\n" -#string STR_SYSTEM_MEM_ERROR #language en-US "System encounters memory errors" - #language fr-FR "le Système rencontre les erreurs de mémoire" -#string STR_START_BOOT_OPTION #language en-US "Start boot option" - #language fr-FR "l'option de botte de Début" - \ No newline at end of file diff --git a/Nt32Pkg/Library/PlatformSecureLib/PlatformSecureLib.c b/Nt32Pkg/Library/PlatformSecureLib/PlatformSecureLib.c deleted file mode 100644 index 8a37099be5..0000000000 --- a/Nt32Pkg/Library/PlatformSecureLib/PlatformSecureLib.c +++ /dev/null @@ -1,35 +0,0 @@ -/** @file - Provides a platform-specific method to enable Secure Boot Custom Mode setup. - - Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
- SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ -#include - - -/** - - This function provides a platform-specific method to detect whether the platform - is operating by a physically present user. - - Programmatic changing of platform security policy (such as disable Secure Boot, - or switch between Standard/Custom Secure Boot mode) MUST NOT be possible during - Boot Services or after exiting EFI Boot Services. Only a physically present user - is allowed to perform these operations. - - NOTE THAT: This function cannot depend on any EFI Variable Service since they are - not available when this function is called in AuthenticateVariable driver. - - @retval TRUE The platform is operated by a physically present user. - @retval FALSE The platform is NOT operated by a physically present user. - -**/ -BOOLEAN -EFIAPI -UserPhysicalPresent ( - VOID - ) -{ - return TRUE; -} diff --git a/Nt32Pkg/Library/PlatformSecureLib/PlatformSecureLib.inf b/Nt32Pkg/Library/PlatformSecureLib/PlatformSecureLib.inf deleted file mode 100644 index 0e5fb1468d..0000000000 --- a/Nt32Pkg/Library/PlatformSecureLib/PlatformSecureLib.inf +++ /dev/null @@ -1,28 +0,0 @@ -## @file -# Provides a platform-specific method to enable Secure Boot Custom Mode setup. -# -# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
-# -# SPDX-License-Identifier: BSD-2-Clause-Patent -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = PlatformSecureLib - FILE_GUID = F263EC2A-F0DB-4640-8B12-4ED22A506FB1 - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - LIBRARY_CLASS = PlatformSecureLib|DXE_RUNTIME_DRIVER DXE_SMM_DRIVER DXE_DRIVER - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 EBC -# - -[Sources] - PlatformSecureLib.c - -[Packages] - MdePkg/MdePkg.dec diff --git a/Nt32Pkg/Library/ResetSystemLib/ResetSystemLib.c b/Nt32Pkg/Library/ResetSystemLib/ResetSystemLib.c deleted file mode 100644 index f8f9aa409f..0000000000 --- a/Nt32Pkg/Library/ResetSystemLib/ResetSystemLib.c +++ /dev/null @@ -1,135 +0,0 @@ -/** @file - - Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
- SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ -#include -#include -#include - -/** - This function causes a system-wide reset (cold reset), in which - all circuitry within the system returns to its initial state. This type of reset - is asynchronous to system operation and operates without regard to - cycle boundaries. - - If this function returns, it means that the system does not support cold reset. -**/ -VOID -EFIAPI -ResetCold ( - VOID - ) -{ - gWinNt->ExitProcess (0); - ASSERT (FALSE); -} - -/** - This function causes a system-wide initialization (warm reset), in which all processors - are set to their initial state. Pending cycles are not corrupted. - - If this function returns, it means that the system does not support warm reset. -**/ -VOID -EFIAPI -ResetWarm ( - VOID - ) -{ - ResetCold (); -} - -/** - This function causes the system to enter a power state equivalent - to the ACPI G2/S5 or G3 states. - - If this function returns, it means that the system does not support shut down reset. -**/ -VOID -EFIAPI -ResetShutdown ( - VOID - ) -{ - ResetCold (); -} - -/** - This function causes the system to enter S3 and then wake up immediately. - - If this function returns, it means that the system does not support S3 feature. -**/ -VOID -EFIAPI -EnterS3WithImmediateWake ( - VOID - ) -{ - ResetCold (); -} - -/** - This function causes a systemwide reset. The exact type of the reset is - defined by the EFI_GUID that follows the Null-terminated Unicode string passed - into ResetData. If the platform does not recognize the EFI_GUID in ResetData - the platform must pick a supported reset type to perform.The platform may - optionally log the parameters from any non-normal reset that occurs. - - @param[in] DataSize The size, in bytes, of ResetData. - @param[in] ResetData The data buffer starts with a Null-terminated string, - followed by the EFI_GUID. -**/ -VOID -EFIAPI -ResetPlatformSpecific ( - IN UINTN DataSize, - IN VOID *ResetData - ) -{ - ResetCold (); -} - -/** - The ResetSystem function resets the entire platform. - - @param[in] ResetType The type of reset to perform. - @param[in] ResetStatus The status code for the reset. - @param[in] DataSize The size, in bytes, of ResetData. - @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown - the data buffer starts with a Null-terminated string, optionally - followed by additional binary data. The string is a description - that the caller may use to further indicate the reason for the - system reset. -**/ -VOID -EFIAPI -ResetSystem ( - IN EFI_RESET_TYPE ResetType, - IN EFI_STATUS ResetStatus, - IN UINTN DataSize, - IN VOID *ResetData OPTIONAL - ) -{ - switch (ResetType) { - case EfiResetWarm: - ResetWarm (); - break; - - case EfiResetCold: - ResetCold (); - break; - - case EfiResetShutdown: - ResetShutdown (); - return; - - case EfiResetPlatformSpecific: - ResetPlatformSpecific (DataSize, ResetData); - return; - - default: - return; - } -} diff --git a/Nt32Pkg/Library/ResetSystemLib/ResetSystemLib.inf b/Nt32Pkg/Library/ResetSystemLib/ResetSystemLib.inf deleted file mode 100644 index f93fe8a636..0000000000 --- a/Nt32Pkg/Library/ResetSystemLib/ResetSystemLib.inf +++ /dev/null @@ -1,32 +0,0 @@ -## @file -# -# Copyright (c) 2017, Intel Corporation. All rights reserved.
-# -# SPDX-License-Identifier: BSD-2-Clause-Patent -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = Nt32ResetSystemLib - FILE_GUID = A7EBA1F6-5505-4fba-8895-386EE02B2FAC - MODULE_TYPE = BASE - VERSION_STRING = 1.0 - LIBRARY_CLASS = ResetSystemLib - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 -# - -[Sources] - ResetSystemLib.c - -[Packages] - MdePkg/MdePkg.dec - Nt32Pkg/Nt32Pkg.dec - -[LibraryClasses] - WinNtLib - DebugLib diff --git a/Nt32Pkg/MetronomeDxe/Metronome.c b/Nt32Pkg/MetronomeDxe/Metronome.c deleted file mode 100644 index aeb346990c..0000000000 --- a/Nt32Pkg/MetronomeDxe/Metronome.c +++ /dev/null @@ -1,123 +0,0 @@ -/**@file - -Copyright (c) 2006, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - Metronome.c - -Abstract: - - NT Emulation Metronome Architectural Protocol Driver as defined in DXE CIS - -**/ - -#include "Metronome.h" - -// -// Global Variables -// -EFI_METRONOME_ARCH_PROTOCOL mMetronome = { - WinNtMetronomeDriverWaitForTick, - TICK_PERIOD -}; - -// -// Worker Functions -// - -EFI_STATUS -EFIAPI -WinNtMetronomeDriverWaitForTick ( - IN EFI_METRONOME_ARCH_PROTOCOL *This, - IN UINT32 TickNumber - ) -/*++ - -Routine Description: - - The WaitForTick() function waits for the number of ticks specified by - TickNumber from a known time source in the platform. If TickNumber of - ticks are detected, then EFI_SUCCESS is returned. The actual time passed - between entry of this function and the first tick is between 0 and - TickPeriod 100 nS units. If you want to guarantee that at least TickPeriod - time has elapsed, wait for two ticks. This function waits for a hardware - event to determine when a tick occurs. It is possible for interrupt - processing, or exception processing to interrupt the execution of the - WaitForTick() function. Depending on the hardware source for the ticks, it - is possible for a tick to be missed. This function cannot guarantee that - ticks will not be missed. If a timeout occurs waiting for the specified - number of ticks, then EFI_TIMEOUT is returned. - -Arguments: - - This - The EFI_METRONOME_ARCH_PROTOCOL instance. - TickNumber - Number of ticks to wait. - -Returns: - - EFI_SUCCESS - The wait for the number of ticks specified by TickNumber - succeeded. - ---*/ -{ - UINT64 SleepTime; - - // - // Calculate the time to sleep. Win API smallest unit to sleep is 1 millisec - // Tick Period is in 100ns units, divide by 10000 to convert to ms - // - SleepTime = DivU64x32 (MultU64x32 ((UINT64) TickNumber, TICK_PERIOD) + 9999, 10000); - gWinNt->Sleep ((UINT32) SleepTime); - - return EFI_SUCCESS; -} - - -EFI_STATUS -EFIAPI -WinNtMetronomeDriverInitialize ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -/*++ - -Routine Description: - - Initialize the Metronome Architectural Protocol driver - -Arguments: - - ImageHandle - ImageHandle of the loaded driver - - - SystemTable - Pointer to the System Table - -Returns: - - EFI_SUCCESS - Metronome Architectural Protocol created - - EFI_OUT_OF_RESOURCES - Not enough resources available to initialize driver. - - EFI_DEVICE_ERROR - A device error occured attempting to initialize the driver. - ---*/ -{ - EFI_STATUS Status; - EFI_HANDLE Handle; - - - // - // Install the Metronome Architectural Protocol onto a new handle - // - Handle = NULL; - Status = gBS->InstallProtocolInterface ( - &Handle, - &gEfiMetronomeArchProtocolGuid, - EFI_NATIVE_INTERFACE, - &mMetronome - ); - - return Status; -} diff --git a/Nt32Pkg/MetronomeDxe/Metronome.h b/Nt32Pkg/MetronomeDxe/Metronome.h deleted file mode 100644 index 4a1a58c5d9..0000000000 --- a/Nt32Pkg/MetronomeDxe/Metronome.h +++ /dev/null @@ -1,85 +0,0 @@ -/**@file - -Copyright (c) 2006, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - Metronome.h - -Abstract: - - NT Emulation Metronome Architectural Protocol Driver as defined in DXE CIS - -**/ - -#ifndef _NT_THUNK_METRONOME_H_ -#define _NT_THUNK_METRONOME_H_ - -#include -#include -#include -#include -#include -#include -#include - - -// -// Period of on tick in 100 nanosecond units -// -#define TICK_PERIOD 2000 - -// -// Function Prototypes -// - -EFI_STATUS -EFIAPI -WinNtMetronomeDriverInitialize ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - ImageHandle - TODO: add argument description - SystemTable - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -EFIAPI -WinNtMetronomeDriverWaitForTick ( - IN EFI_METRONOME_ARCH_PROTOCOL *This, - IN UINT32 TickNumber - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - This - TODO: add argument description - TickNumber - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -#endif diff --git a/Nt32Pkg/MetronomeDxe/MetronomeDxe.inf b/Nt32Pkg/MetronomeDxe/MetronomeDxe.inf deleted file mode 100644 index d7a4065bae..0000000000 --- a/Nt32Pkg/MetronomeDxe/MetronomeDxe.inf +++ /dev/null @@ -1,46 +0,0 @@ -## @file -# NT Emulation Metronome Architectural Protocol Driver as defined in DXE CIS -# -# This metronome module simulates metronome by Sleep WinAPI. -# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
-# -# SPDX-License-Identifier: BSD-2-Clause-Patent -# -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = Metronome - FILE_GUID = 154CAB4A-52B5-46CD-99C3-4368ABBACFFD - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - - ENTRY_POINT = WinNtMetronomeDriverInitialize - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 -# - -[Sources] - Metronome.h - Metronome.c - -[Packages] - MdePkg/MdePkg.dec - Nt32Pkg/Nt32Pkg.dec - -[LibraryClasses] - UefiBootServicesTableLib - WinNtLib - UefiDriverEntryPoint - BaseLib - -[Protocols] - gEfiMetronomeArchProtocolGuid # PROTOCOL ALWAYS_PRODUCED - -[Depex] - TRUE - diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerData.c b/Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerData.c deleted file mode 100644 index ab88a9207a..0000000000 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerData.c +++ /dev/null @@ -1,51 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - MiscBaseBoardManufacturerData.c - -Abstract: - - This driver parses the mMiscSubclassDataTable structure and reports - any generated data to the DataHub. - -**/ - -#include "MiscSubclassDriver.h" - -// -// Static (possibly build generated) Bios Vendor data. -// -MISC_SMBIOS_TABLE_DATA(EFI_MISC_BASE_BOARD_MANUFACTURER_DATA, MiscBaseBoardManufacturer) = { - STRING_TOKEN(STR_MISC_BASE_BOARD_MANUFACTURER), - STRING_TOKEN(STR_MISC_BASE_BOARD_PRODUCT_NAME), - STRING_TOKEN(STR_MISC_BASE_BOARD_VERSION), - STRING_TOKEN(STR_MISC_BASE_BOARD_SERIAL_NUMBER), - STRING_TOKEN(STR_MISC_BASE_BOARD_ASSET_TAG), - STRING_TOKEN(STR_MISC_BASE_BOARD_CHASSIS_LOCATION), - { // BaseBoardFeatureFlags - 1, // Motherboard - 0, // RequiresDaughterCard - 0, // Removable - 1, // Replaceable, - 0, // HotSwappable - 0, // Reserved - }, - EfiBaseBoardTypeUnknown, // BaseBoardType - { // BaseBoardChassisLink - EFI_MISC_SUBCLASS_GUID, // ProducerName - 1, // Instance - 1, // SubInstance - }, - 0, // BaseBoardNumberLinks - { // LinkN - EFI_MISC_SUBCLASS_GUID, // ProducerName - 1, // Instance - 1, // SubInstance - }, -}; - -/* eof - MiscBaseBoardManufacturerData.c */ diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c b/Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c deleted file mode 100644 index c414cf6531..0000000000 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c +++ /dev/null @@ -1,161 +0,0 @@ -/** @file - BaseBoard manufacturer information boot time changes. - SMBIOS type 2. - -Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
-(C) Copyright 2017 Hewlett Packard Enterprise Development LP
-SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#include "MiscSubclassDriver.h" -/** - This function makes boot time changes to the contents of the - MiscBaseBoardManufacturer (Type 2). - - @param RecordData Pointer to copy of RecordData from the Data Table. - - @retval EFI_SUCCESS All parameters were valid. - @retval EFI_UNSUPPORTED Unexpected RecordType value. - @retval EFI_INVALID_PARAMETER Invalid parameter was found. - -**/ -MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer) -{ - CHAR8 *OptionalStrStart; - UINTN ManuStrLen; - UINTN ProductStrLen; - UINTN VerStrLen; - UINTN AssetTagStrLen; - UINTN SerialNumStrLen; - UINTN ChassisStrLen; - EFI_STATUS Status; - EFI_STRING Manufacturer; - EFI_STRING Product; - EFI_STRING Version; - EFI_STRING SerialNumber; - EFI_STRING AssetTag; - EFI_STRING Chassis; - STRING_REF TokenToGet; - EFI_SMBIOS_HANDLE SmbiosHandle; - SMBIOS_TABLE_TYPE2 *SmbiosRecord; - EFI_MISC_BASE_BOARD_MANUFACTURER *ForType2InputData; - - ForType2InputData = (EFI_MISC_BASE_BOARD_MANUFACTURER *)RecordData; - - // - // First check for invalid parameters. - // - if (RecordData == NULL) { - return EFI_INVALID_PARAMETER; - } - - TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_MANUFACTURER); - Manufacturer = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL); - ManuStrLen = StrLen(Manufacturer); - if (ManuStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - - TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_PRODUCT_NAME); - Product = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL); - ProductStrLen = StrLen(Product); - if (ProductStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - - TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_VERSION); - Version = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL); - VerStrLen = StrLen(Version); - if (VerStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - - TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_SERIAL_NUMBER); - SerialNumber = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL); - SerialNumStrLen = StrLen(SerialNumber); - if (SerialNumStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - - TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_ASSET_TAG); - AssetTag = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL); - AssetTagStrLen = StrLen(AssetTag); - if (AssetTagStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - - TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_CHASSIS_LOCATION); - Chassis = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL); - ChassisStrLen = StrLen(Chassis); - if (ChassisStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - - - // - // Two zeros following the last string. - // - // Since we fill NumberOfContainedObjectHandles = 0, remove sizeof (UINT16) bytes for ContainedObjectHandles[1] - // - SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE2) - sizeof (UINT16) + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssetTagStrLen + 1 + ChassisStrLen + 1 + 1); - ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE2) - sizeof (UINT16) + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssetTagStrLen + 1 + ChassisStrLen + 1 + 1); - - SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION; - // - // Since we fill NumberOfContainedObjectHandles = 0, remove sizeof (UINT16) bytes for ContainedObjectHandles[1] - // - SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE2) - sizeof (UINT16); - // - // Make handle chosen by smbios protocol.add automatically. - // - SmbiosRecord->Hdr.Handle = 0; - // - // Manu will be the 1st optional string following the formatted structure. - // - SmbiosRecord->Manufacturer = 1; - // - // ProductName will be the 2st optional string following the formatted structure. - // - SmbiosRecord->ProductName = 2; - // - // Version will be the 3rd optional string following the formatted structure. - // - SmbiosRecord->Version = 3; - // - // SerialNumber will be the 4th optional string following the formatted structure. - // - SmbiosRecord->SerialNumber = 4; - // - // AssetTag will be the 5th optional string following the formatted structure. - // - SmbiosRecord->AssetTag = 5; - - // - // LocationInChassis will be the 6th optional string following the formatted structure. - // - SmbiosRecord->LocationInChassis = 6; - SmbiosRecord->FeatureFlag = (*(BASE_BOARD_FEATURE_FLAGS*)&(ForType2InputData->BaseBoardFeatureFlags)); - SmbiosRecord->ChassisHandle = 0; - SmbiosRecord->BoardType = (UINT8)ForType2InputData->BaseBoardType; - SmbiosRecord->NumberOfContainedObjectHandles = 0; - - OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1); - // - // Since we fill NumberOfContainedObjectHandles = 0, just after this field to fill string - // - OptionalStrStart -= sizeof (UINT16); - UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart); - UnicodeStrToAsciiStr(Product, OptionalStrStart + ManuStrLen + 1); - UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1); - UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1); - UnicodeStrToAsciiStr(AssetTag, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1); - UnicodeStrToAsciiStr(Chassis, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssetTagStrLen + 1); - // - // Now we have got the full smbios record, call smbios protocol to add this record. - // - Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord); - - FreePool(SmbiosRecord); - return Status; -} diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscBiosVendorData.c b/Nt32Pkg/MiscSubClassPlatformDxe/MiscBiosVendorData.c deleted file mode 100644 index a9f33b49b6..0000000000 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscBiosVendorData.c +++ /dev/null @@ -1,82 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - MiscBiosVendorData.c - -Abstract: - - This driver parses the mMiscSubclassDataTable structure and reports - any generated data to the DataHub. - -**/ - -#include "MiscSubclassDriver.h" - -// -// Static (possibly build generated) Bios Vendor data. -// -MISC_SMBIOS_TABLE_DATA(EFI_MISC_BIOS_VENDOR_DATA, MiscBiosVendor) = { - STRING_TOKEN(STR_MISC_BIOS_VENDOR), // BiosVendor - STRING_TOKEN(STR_MISC_BIOS_VERSION), // BiosVersion - STRING_TOKEN(STR_MISC_BIOS_RELEASE_DATE), // BiosReleaseDate - 0xBABE, // BiosStartingAddress - { // BiosPhysicalDeviceSize - 2, // Value - 3, // Exponent - }, - { // BiosCharacteristics1 - 0, // Reserved1 :2 - 0, // Unknown :1 - 1, // BiosCharacteristicsNotSupported :1 - 0, // IsaIsSupported :1 - 0, // McaIsSupported :1 - 0, // EisaIsSupported :1 - 0, // PciIsSupported :1 - 0, // PcmciaIsSupported :1 - 0, // PlugAndPlayIsSupported :1 - 0, // ApmIsSupported :1 - 0, // BiosIsUpgradable :1 - 0, // BiosShadowingAllowed :1 - 0, // VlVesaIsSupported :1 - 0, // EscdSupportIsAvailable :1 - 0, // BootFromCdIsSupported :1 - 0, // SelectableBootIsSupported :1 - 0, // RomBiosIsSocketed :1 - 0, // BootFromPcmciaIsSupported :1 - 0, // EDDSpecificationIsSupported :1 - 0, // JapaneseNecFloppyIsSupported :1 - 0, // JapaneseToshibaFloppyIsSupported :1 - 0, // Floppy525_360IsSupported :1 - 0, // Floppy525_12IsSupported :1 - 0, // Floppy35_720IsSupported :1 - 0, // Floppy35_288IsSupported :1 - 0, // PrintScreenIsSupported :1 - 0, // Keyboard8042IsSupported :1 - 0, // SerialIsSupported :1 - 0, // PrinterIsSupported :1 - 0, // CgaMonoIsSupported :1 - 0, // NecPc98 :1 - 0, // AcpiIsSupported :1 - 0, // UsbLegacyIsSupported :1 - 0, // AgpIsSupported :1 - 0, // I20BootIsSupported :1 - 0, // Ls120BootIsSupported :1 - 0, // AtapiZipDriveBootIsSupported :1 - 0, // Boot1394IsSupported :1 - 0, // SmartBatteryIsSupported :1 - 0, // BiosBootSpecIsSupported :1 - 0, // FunctionKeyNetworkBootIsSupported :1 - 0 // Reserved :22 - }, - { // BiosCharacteristics2 - 0, // BiosReserved :16 - 0, // SystemReserved :16 - 0 // Reserved :32 - }, -}; - -/* eof - MiscBiosVendorData.c */ diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscBiosVendorFunction.c b/Nt32Pkg/MiscSubClassPlatformDxe/MiscBiosVendorFunction.c deleted file mode 100644 index 5bb75614cc..0000000000 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscBiosVendorFunction.c +++ /dev/null @@ -1,190 +0,0 @@ -/** @file - BIOS vendor information boot time changes. - Misc. subclass type 2. - SMBIOS type 0. - -Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#include "MiscSubclassDriver.h" - -/** - This function returns the value & exponent to Base2 for a given - Hex value. This is used to calculate the BiosPhysicalDeviceSize. - - @param Value The hex value which is to be converted into value-exponent form - @param Exponent The exponent out of the conversion - - @retval EFI_SUCCESS All parameters were valid and *Value & *Exponent have been set. - @retval EFI_INVALID_PARAMETER Invalid parameter was found. - -**/ -EFI_STATUS -GetValueExponentBase2( - IN OUT UINTN *Value, - OUT UINTN *Exponent - ) -{ - if ((Value == NULL) || (Exponent == NULL)) { - return EFI_INVALID_PARAMETER; - } - - while ((*Value % 2) == 0) { - *Value=*Value/2; - (*Exponent)++; - } - - return EFI_SUCCESS; -} - -/** - Field Filling Function. Transform an EFI_EXP_BASE2_DATA to a byte, with '64k' - as the unit. - - @param Base2Data Pointer to Base2_Data - - @retval EFI_SUCCESS Transform successfully. - @retval EFI_INVALID_PARAMETER Invalid parameter was found. - -**/ -UINT16 -Base2ToByteWith64KUnit ( - IN EFI_EXP_BASE2_DATA *Base2Data - ) -{ - UINT16 Value; - UINT16 Exponent; - - Value = Base2Data->Value; - Exponent = Base2Data->Exponent; - Exponent -= 16; - Value <<= Exponent; - - return Value; -} - - -/** - This function makes boot time changes to the contents of the - MiscBiosVendor (Type 0). - - @param RecordData Pointer to copy of RecordData from the Data Table. - - @retval EFI_SUCCESS All parameters were valid. - @retval EFI_UNSUPPORTED Unexpected RecordType value. - @retval EFI_INVALID_PARAMETER Invalid parameter was found. - -**/ -MISC_SMBIOS_TABLE_FUNCTION(MiscBiosVendor) -{ - CHAR8 *OptionalStrStart; - UINTN VendorStrLen; - UINTN VerStrLen; - UINTN DateStrLen; - CHAR16 *Version; - CHAR16 *ReleaseDate; - EFI_STATUS Status; - EFI_STRING Char16String; - STRING_REF TokenToGet; - STRING_REF TokenToUpdate; - SMBIOS_TABLE_TYPE0 *SmbiosRecord; - EFI_SMBIOS_HANDLE SmbiosHandle; - EFI_MISC_BIOS_VENDOR *ForType0InputData; - - ForType0InputData = (EFI_MISC_BIOS_VENDOR *)RecordData; - - // - // First check for invalid parameters. - // - if (RecordData == NULL) { - return EFI_INVALID_PARAMETER; - } - - Version = (CHAR16 *) PcdGetPtr (PcdFirmwareVersionString); - if (StrLen (Version) > 0) { - TokenToUpdate = STRING_TOKEN (STR_MISC_BIOS_VERSION); - HiiSetString (mHiiHandle, TokenToUpdate, Version, NULL); - } - - ReleaseDate = (CHAR16 *) PcdGetPtr (PcdFirmwareReleaseDateString); - if (StrLen(ReleaseDate) > 0) { - TokenToUpdate = STRING_TOKEN (STR_MISC_BIOS_RELEASE_DATE); - HiiSetString (mHiiHandle, TokenToUpdate, ReleaseDate, NULL); - } - - TokenToGet = STRING_TOKEN (STR_MISC_BIOS_VENDOR); - Char16String = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL); - VendorStrLen = StrLen(Char16String); - if (VendorStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - - TokenToGet = STRING_TOKEN (STR_MISC_BIOS_VERSION); - Version = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL); - VerStrLen = StrLen(Version); - if (VerStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - - TokenToGet = STRING_TOKEN (STR_MISC_BIOS_RELEASE_DATE); - ReleaseDate = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL); - DateStrLen = StrLen(ReleaseDate); - if (DateStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - - // - // Two zeros following the last string. - // - SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE0) + VendorStrLen + 1 + VerStrLen + 1 + DateStrLen + 1 + 1); - ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE0) + VendorStrLen + 1 + VerStrLen + 1 + DateStrLen + 1 + 1); - - SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_BIOS_INFORMATION; - SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE0); - // - // Make handle chosen by smbios protocol.add automatically. - // - SmbiosRecord->Hdr.Handle = 0; - // - // Vendor will be the 1st optional string following the formatted structure. - // - SmbiosRecord->Vendor = 1; - // - // Version will be the 2nd optional string following the formatted structure. - // - SmbiosRecord->BiosVersion = 2; - SmbiosRecord->BiosSegment = (UINT16)ForType0InputData->BiosStartingAddress; - // - // ReleaseDate will be the 3rd optional string following the formatted structure. - // - SmbiosRecord->BiosReleaseDate = 3; - // - // Nt32 has no PCD value to indicate BIOS Size, just fill 0 for simply. - // - SmbiosRecord->BiosSize = 0; - SmbiosRecord->BiosCharacteristics = *(MISC_BIOS_CHARACTERISTICS*)(&ForType0InputData->BiosCharacteristics1); - // - // CharacterExtensionBytes also store in ForType0InputData->BiosCharacteristics1 later two bytes to save size. - // - SmbiosRecord->BIOSCharacteristicsExtensionBytes[0] = *((UINT8 *) &ForType0InputData->BiosCharacteristics1 + 4); - SmbiosRecord->BIOSCharacteristicsExtensionBytes[1] = *((UINT8 *) &ForType0InputData->BiosCharacteristics1 + 5); - - SmbiosRecord->SystemBiosMajorRelease = ForType0InputData->BiosMajorRelease; - SmbiosRecord->SystemBiosMinorRelease = ForType0InputData->BiosMinorRelease; - SmbiosRecord->EmbeddedControllerFirmwareMajorRelease = ForType0InputData->BiosEmbeddedFirmwareMajorRelease; - SmbiosRecord->EmbeddedControllerFirmwareMinorRelease = ForType0InputData->BiosEmbeddedFirmwareMinorRelease; - - OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1); - UnicodeStrToAsciiStr(Char16String, OptionalStrStart); - UnicodeStrToAsciiStr(Version, OptionalStrStart + VendorStrLen + 1); - UnicodeStrToAsciiStr(ReleaseDate, OptionalStrStart + VendorStrLen + 1 + VerStrLen + 1); - // - // Now we have got the full smbios record, call smbios protocol to add this record. - // - Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord); - - FreePool(SmbiosRecord); - return Status; -} diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscBootInformationData.c b/Nt32Pkg/MiscSubClassPlatformDxe/MiscBootInformationData.c deleted file mode 100644 index 83ade64f69..0000000000 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscBootInformationData.c +++ /dev/null @@ -1,27 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - MiscBootInformationData.c - -Abstract: - - This driver parses the mMiscSubclassDataTable structure and reports - any generated data to the DataHub. - -**/ - -#include "MiscSubclassDriver.h" - -// -// Static (possibly build generated) Bios Vendor data. -// -MISC_SMBIOS_TABLE_DATA(EFI_MISC_BOOT_INFORMATION_STATUS_DATA, BootInformationStatus) = { - EfiBootInformationStatusNoError, // BootInformationStatus - 0 // BootInformationData -}; - -/* eof - MiscBootInformationData.c */ diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscBootInformationFunction.c b/Nt32Pkg/MiscSubClassPlatformDxe/MiscBootInformationFunction.c deleted file mode 100644 index 5f4ffc5ec2..0000000000 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscBootInformationFunction.c +++ /dev/null @@ -1,62 +0,0 @@ -/** @file - boot information boot time changes. - SMBIOS type 32. - -Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#include "MiscSubclassDriver.h" - - -/** - This function makes boot time changes to the contents of the - MiscBootInformation (Type 32). - - @param RecordData Pointer to copy of RecordData from the Data Table. - - @retval EFI_SUCCESS All parameters were valid. - @retval EFI_UNSUPPORTED Unexpected RecordType value. - @retval EFI_INVALID_PARAMETER Invalid parameter was found. - -**/ - -MISC_SMBIOS_TABLE_FUNCTION(BootInformationStatus) -{ - EFI_STATUS Status; - EFI_SMBIOS_HANDLE SmbiosHandle; - SMBIOS_TABLE_TYPE32 *SmbiosRecord; - EFI_MISC_BOOT_INFORMATION_STATUS* ForType32InputData; - - ForType32InputData = (EFI_MISC_BOOT_INFORMATION_STATUS *)RecordData; - - // - // First check for invalid parameters. - // - if (RecordData == NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // Two zeros following the last string. - // - SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE32) + 1 + 1); - ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE32) + 1 + 1); - - SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_BOOT_INFORMATION; - SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE32); - // - // Make handle chosen by smbios protocol.add automatically. - // - SmbiosRecord->Hdr.Handle = 0; - SmbiosRecord->BootStatus = (UINT8)ForType32InputData->BootInformationStatus; - - // - // Now we have got the full smbios record, call smbios protocol to add this record. - // - Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord); - - FreePool(SmbiosRecord); - return Status; -} diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscChassisManufacturerData.c b/Nt32Pkg/MiscSubClassPlatformDxe/MiscChassisManufacturerData.c deleted file mode 100644 index 7de39b676c..0000000000 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscChassisManufacturerData.c +++ /dev/null @@ -1,42 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
-(C) Copyright 2017 Hewlett Packard Enterprise Development LP
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - MiscChassisManufacturerData.c - -Abstract: - - This driver parses the mMiscSubclassDataTable structure and reports - any generated data to the DataHub. - -**/ - -#include "MiscSubclassDriver.h" - -// -// Static (possibly build generated) Chassis Manufacturer data. -// -MISC_SMBIOS_TABLE_DATA(EFI_MISC_CHASSIS_MANUFACTURER_DATA, MiscChassisManufacturer) = { - STRING_TOKEN(STR_MISC_CHASSIS_MANUFACTURER), // ChassisManufactrurer - STRING_TOKEN(STR_MISC_CHASSIS_VERSION), // ChassisVersion - STRING_TOKEN(STR_MISC_CHASSIS_SERIAL_NUMBER), // ChassisSerialNumber - STRING_TOKEN(STR_MISC_CHASSIS_ASSET_TAG), // ChassisAssetTag - { // ChassisTypeStatus - EfiMiscChassisTypeOther, // ChassisType - 0, // ChassisLockPresent - 0 // Reserved - }, - EfiChassisStateOther, // ChassisBootupState - EfiChassisStateOther, // ChassisPowerSupplyState - EfiChassisStateOther, // ChassisThermalState - EfiChassisSecurityStatusOther, // ChassisSecurityState - 0, // ChassisOemDefined - 1, // Height - 1 // NumberofPowerCords -}; - -/* eof - MiscChassisManufacaturerData.c */ diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscChassisManufacturerFunction.c b/Nt32Pkg/MiscSubClassPlatformDxe/MiscChassisManufacturerFunction.c deleted file mode 100644 index 238b62fb66..0000000000 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscChassisManufacturerFunction.c +++ /dev/null @@ -1,171 +0,0 @@ -/** @file - Chassis manufacturer information boot time changes. - SMBIOS type 3. - -Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
-(C) Copyright 2017 Hewlett Packard Enterprise Development LP
-SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#include "MiscSubclassDriver.h" - -/** - This function makes boot time changes to the contents of the - MiscChassisManufacturer (Type 3). - - @param RecordData Pointer to copy of RecordData from the Data Table. - - @retval EFI_SUCCESS All parameters were valid. - @retval EFI_UNSUPPORTED Unexpected RecordType value. - @retval EFI_INVALID_PARAMETER Invalid parameter was found. - -**/ -MISC_SMBIOS_TABLE_FUNCTION(MiscChassisManufacturer) -{ - CHAR8 *OptionalStrStart; - UINTN ManuStrLen; - UINTN VerStrLen; - UINTN AssetTagStrLen; - UINTN SerialNumStrLen; - UINTN SkuNumberStrLen; - EFI_STATUS Status; - EFI_STRING Manufacturer; - EFI_STRING Version; - EFI_STRING SerialNumber; - EFI_STRING AssetTag; - EFI_STRING SkuNumber; - STRING_REF TokenToGet; - EFI_SMBIOS_HANDLE SmbiosHandle; - SMBIOS_TABLE_TYPE3 *SmbiosRecord; - EFI_MISC_CHASSIS_MANUFACTURER *ForType3InputData; - UINT8 *Buffer; - - ForType3InputData = (EFI_MISC_CHASSIS_MANUFACTURER *)RecordData; - - // - // First check for invalid parameters. - // - if (RecordData == NULL) { - return EFI_INVALID_PARAMETER; - } - - TokenToGet = STRING_TOKEN (STR_MISC_CHASSIS_MANUFACTURER); - Manufacturer = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL); - ManuStrLen = StrLen(Manufacturer); - if (ManuStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - - TokenToGet = STRING_TOKEN (STR_MISC_CHASSIS_VERSION); - Version = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL); - VerStrLen = StrLen(Version); - if (VerStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - - TokenToGet = STRING_TOKEN (STR_MISC_CHASSIS_SERIAL_NUMBER); - SerialNumber = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL); - SerialNumStrLen = StrLen(SerialNumber); - if (SerialNumStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - - TokenToGet = STRING_TOKEN (STR_MISC_CHASSIS_ASSET_TAG); - AssetTag = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL); - AssetTagStrLen = StrLen(AssetTag); - if (AssetTagStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - - TokenToGet = STRING_TOKEN (STR_MISC_CHASSIS_SKU_NUMBER); - SkuNumber = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL); - SkuNumberStrLen = StrLen(SkuNumber); - if (SkuNumberStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - - // - // Two zeros following the last string. - // - // Since we set ContainedElementCount = 0 and ContainedElementRecordLength = 0, - // remove sizeof (CONTAINED_ELEMENT) for ContainedElements[1]. - // - // Add sizeof (SMBIOS_TABLE_STRING) for SKU Number, since not contained in SMBIOS_TABLE_TYPE3. - // - SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE3) - sizeof (CONTAINED_ELEMENT) + sizeof (SMBIOS_TABLE_STRING) + ManuStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssetTagStrLen + 1 + SkuNumberStrLen + 1 + 1); - ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE3) - sizeof (CONTAINED_ELEMENT) + sizeof (SMBIOS_TABLE_STRING) + ManuStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssetTagStrLen + 1 + SkuNumberStrLen + 1 + 1); - - Buffer = (UINT8 *) SmbiosRecord; - - SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_ENCLOSURE; - // - // Since we set ContainedElementCount = 0 and ContainedElementRecordLength = 0, - // remove sizeof (CONTAINED_ELEMENT) for ContainedElements[1]. - // - // Add sizeof (SMBIOS_TABLE_STRING) for SKU Number, since not contained in SMBIOS_TABLE_TYPE3. - // - SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE3) - sizeof (CONTAINED_ELEMENT) + sizeof (SMBIOS_TABLE_STRING); - // - // Make handle chosen by smbios protocol.add automatically. - // - SmbiosRecord->Hdr.Handle = 0; - // - // Manu will be the 1st optional string following the formatted structure. - // - SmbiosRecord->Manufacturer = 1; - SmbiosRecord->Type = (UINT8)ForType3InputData->ChassisType.ChassisType; - // - // Version will be the 2nd optional string following the formatted structure. - // - SmbiosRecord->Version = 2; - // - // SerialNumber will be the 3rd optional string following the formatted structure. - // - SmbiosRecord->SerialNumber = 3; - // - // AssetTag will be the 4th optional string following the formatted structure. - // - SmbiosRecord->AssetTag = 4; - - SmbiosRecord->BootupState = (UINT8)ForType3InputData->ChassisBootupState; - SmbiosRecord->PowerSupplyState = (UINT8)ForType3InputData->ChassisPowerSupplyState; - SmbiosRecord->ThermalState = (UINT8)ForType3InputData->ChassisThermalState; - SmbiosRecord->SecurityStatus = (UINT8)ForType3InputData->ChassisSecurityState; - CopyMem (SmbiosRecord->OemDefined,(UINT8*)&ForType3InputData->ChassisOemDefined, 4); - SmbiosRecord->Height = (UINT8)ForType3InputData->ChassisHeight; - SmbiosRecord->NumberofPowerCords = (UINT8)ForType3InputData->ChassisNumberPowerCords; - SmbiosRecord->ContainedElementCount = 0; - SmbiosRecord->ContainedElementRecordLength = 0; - - // - // SKU Number will be the 5th optional string following the formatted structure. - // - // Since SKU Number is not in SMBIOS_TABLE_TYPE3 structure, must locate it after ContainedElementRecordLength. - // - Buffer[sizeof (SMBIOS_TABLE_TYPE3) - sizeof (CONTAINED_ELEMENT)] = 5; - - OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1); - // - // Since we set ContainedElementCount = 0 and ContainedElementRecordLength = 0, - // remove sizeof (CONTAINED_ELEMENT) for ContainedElements[1]. - // - OptionalStrStart -= sizeof (CONTAINED_ELEMENT); - // - // Add sizeof (SMBIOS_TABLE_STRING) for SKU Number, since not contained in SMBIOS_TABLE_TYPE3. - // - OptionalStrStart += sizeof (SMBIOS_TABLE_STRING); - UnicodeStrToAsciiStr (Manufacturer, OptionalStrStart); - UnicodeStrToAsciiStr (Version, OptionalStrStart + ManuStrLen + 1); - UnicodeStrToAsciiStr (SerialNumber, OptionalStrStart + ManuStrLen + 1 + VerStrLen + 1); - UnicodeStrToAsciiStr (AssetTag, OptionalStrStart + ManuStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1); - UnicodeStrToAsciiStr (SkuNumber, OptionalStrStart + ManuStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssetTagStrLen + 1); - - // - // Now we have got the full smbios record, call smbios protocol to add this record. - // - Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord); - - FreePool(SmbiosRecord); - return Status; -} diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscDevicePath.h b/Nt32Pkg/MiscSubClassPlatformDxe/MiscDevicePath.h deleted file mode 100644 index 875507b33d..0000000000 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscDevicePath.h +++ /dev/null @@ -1,169 +0,0 @@ -/**@file - -Copyright (c) 2006, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - MiscDevicePath.h - -Abstract: - - Misc class required EFI Device Path definitions (Ports, slots & - onboard devices) - -**/ - -#ifndef _MISC_DEVICE_PATH_H -#define _MISC_DEVICE_PATH_H - - -#pragma pack(1) -// -// USB -// - -/* For reference: -#define USB1_1_STR "ACPI(PNP0A03,0)/PCI(1D,0)." -#define USB1_2_STR "ACPI(PNP0A03,0)/PCI(1D,1)." -#define USB1_3_STR "ACPI(PNP0A03,0)/PCI(1D,2)." -#define USB2_1_STR "ACPI(PNP0A03,0)/PCI(1D,7)." -*/ - -// -// #define acpi { 0x02, 0x01, 0x00, 0x0C, 0x0a0341d0, 0x00000000 } -// #define pci( device,function) { 0x01, 0x01, 0x00, 0x06, device, function } -// #define end { 0xFF, 0xFF, 0x00, 0x04 } -// -#define DP_ACPI \ - { \ - ACPI_DEVICE_PATH, ACPI_DP, (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), (UINT8) \ - ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8), EISA_PNP_ID (0x0A03), 0 \ - } -#define DP_PCI(device, function) \ - { \ - HARDWARE_DEVICE_PATH, HW_PCI_DP, (UINT8) (sizeof (PCI_DEVICE_PATH)), (UINT8) \ - ((sizeof (PCI_DEVICE_PATH)) >> 8), function, device \ - } -#define DP_END \ - { \ - END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, END_DEVICE_PATH_LENGTH, 0 \ - } - -#define DP_LPC(eisaid, function) \ - { \ - ACPI_DEVICE_PATH, ACPI_DP, (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), (UINT8) \ - ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8), EISA_PNP_ID (eisaid), function \ - } - -// -// Shanmu >> moved to TianoDevicePath.h -// - -/* -typedef struct _USB_PORT_DEVICE_PATH -{ - ACPI_HID_DEVICE_PATH PciRootBridgeDevicePath; - PCI_DEVICE_PATH PciBusDevicePath; - EFI_DEVICE_PATH_PROTOCOL EndDevicePath; -} USB_PORT_DEVICE_PATH; - - -//IDE ??I am not sure. Should this be ATAPI_DEVICE_PATH -typedef struct _IDE_DEVICE_PATH -{ - ACPI_HID_DEVICE_PATH PciRootBridgeDevicePath; - PCI_DEVICE_PATH PciBusDevicePath; - EFI_DEVICE_PATH_PROTOCOL EndDevicePath; -} IDE_DEVICE_PATH; - -//RMC Connector -typedef struct _RMC_CONN_DEVICE_PATH -{ - ACPI_HID_DEVICE_PATH PciRootBridgeDevicePath; - PCI_DEVICE_PATH PciBridgeDevicePath; - PCI_DEVICE_PATH PciBusDevicePath; - EFI_DEVICE_PATH_PROTOCOL EndDevicePath; -} RMC_CONN_DEVICE_PATH; - -//static RMC_CONN_DEVICE_PATH mRmcConnDevicePath = { acpi, pci( 0x1E,0x00 ),pci( 0x0A,0x00 ), end }; - -//RIDE -typedef struct _RIDE_DEVICE_PATH -{ - ACPI_HID_DEVICE_PATH PciRootBridgeDevicePath; - PCI_DEVICE_PATH PciBridgeDevicePath; - PCI_DEVICE_PATH PciBusDevicePath; - EFI_DEVICE_PATH_PROTOCOL EndDevicePath; -} RIDE_DEVICE_PATH; - -//static RIDE_DEVICE_PATH mRideDevicePath = { acpi, pci( 0x1E,0x00 ),pci( 0x02,0x00 ), end }; - -//Gigabit NIC -//typedef struct _GB_NIC_DEVICE_PATH -//{ -// ACPI_HID_DEVICE_PATH PciRootBridgeDevicePath; -// PCI_DEVICE_PATH PciBridgeDevicePath; -// PCI_DEVICE_PATH PciXBridgeDevicePath; -// PCI_DEVICE_PATH PciXBusDevicePath; -// EFI_DEVICE_PATH_PROTOCOL EndDevicePath; -//} GB_NIC_DEVICE_PATH; - -//static GB_NIC_DEVICE_PATH mGbNicDevicePath = { acpi, pci( 0x03,0x00 ),pci( 0x1F,0x00 ),pci( 0x07,0x00 ), end }; - - -//P/S2 Connector -typedef struct _PS2_CONN_DEVICE_PATH -{ - ACPI_HID_DEVICE_PATH PciRootBridgeDevicePath; - PCI_DEVICE_PATH LpcBridgeDevicePath; - ACPI_HID_DEVICE_PATH LpcBusDevicePath; - EFI_DEVICE_PATH_PROTOCOL EndDevicePath; -} PS2_CONN_DEVICE_PATH; - -//static PS2_CONN_DEVICE_PATH mPs2KeyboardDevicePath = { acpi, pci( 0x1F,0x00 ),lpc( 0x0303,0 ), end }; -//static PS2_CONN_DEVICE_PATH mPs2MouseDevicePath = { acpi, pci( 0x1F,0x00 ),lpc( 0x0303,1 ), end }; - -//Serial Port Connector -typedef struct _SERIAL_CONN_DEVICE_PATH -{ - ACPI_HID_DEVICE_PATH PciRootBridgeDevicePath; - PCI_DEVICE_PATH LpcBridgeDevicePath; - ACPI_HID_DEVICE_PATH LpcBusDevicePath; - EFI_DEVICE_PATH_PROTOCOL EndDevicePath; -} SERIAL_CONN_DEVICE_PATH; - -//static SERIAL_CONN_DEVICE_PATH mCom1DevicePath = { acpi, pci( 0x1F,0x00 ),lpc( 0x0501,0 ), end }; -//static SERIAL_CONN_DEVICE_PATH mCom2DevicePath = { acpi, pci( 0x1F,0x00 ),lpc( 0x0501,1 ), end }; - -//Parallel Port Connector -typedef struct _PARALLEL_CONN_DEVICE_PATH -{ - ACPI_HID_DEVICE_PATH PciRootBridgeDevicePath; - PCI_DEVICE_PATH LpcBridgeDevicePath; - ACPI_HID_DEVICE_PATH LpcBusDevicePath; - EFI_DEVICE_PATH_PROTOCOL EndDevicePath; -} PARALLEL_CONN_DEVICE_PATH; - -//static PARALLEL_CONN_DEVICE_PATH mLpt1DevicePath = { acpi, pci( 0x1F,0x00 ),lpc( 0x0401,0 ), end }; - -//Floopy Connector -typedef struct _FLOOPY_CONN_DEVICE_PATH -{ - ACPI_HID_DEVICE_PATH PciRootBridgeDevicePath; - PCI_DEVICE_PATH LpcBridgeDevicePath; - ACPI_HID_DEVICE_PATH LpcBusDevicePath; - EFI_DEVICE_PATH_PROTOCOL EndDevicePath; -} FLOOPY_CONN_DEVICE_PATH; - -//static FLOOPY_CONN_DEVICE_PATH mFloopyADevicePath = { acpi, pci( 0x1F,0x00 ),lpc( 0x0604,0 ), end }; -//static FLOOPY_CONN_DEVICE_PATH mFloopyBDevicePath = { acpi, pci( 0x1F,0x00 ),lpc( 0x0604,1 ), end }; - -*/ - -// -// End Shanmu -// -#pragma pack() - -#endif diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscNumberOfInstallableLanguagesData.c b/Nt32Pkg/MiscSubClassPlatformDxe/MiscNumberOfInstallableLanguagesData.c deleted file mode 100644 index 3532001415..0000000000 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscNumberOfInstallableLanguagesData.c +++ /dev/null @@ -1,32 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - MiscNumberOfInstallableLanguagesData.c - -Abstract: - - This driver parses the mMiscSubclassDataTable structure and reports - any generated data to the DataHub. - -**/ - -#include "MiscSubclassDriver.h" - -// -// Static (possibly build generated) Bios Vendor data. -// -MISC_SMBIOS_TABLE_DATA(EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES_DATA, NumberOfInstallableLanguages) -= { - 1, // NumberOfInstallableLanguages - { // LanguageFlags - 0, // AbbreviatedLanguageFormat - 0 // Reserved - }, - 0, // CurrentLanguageNumber -}; - -/* eof - MiscNumberOfInstallableLanguagesData.c */ diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscNumberOfInstallableLanguagesFunction.c b/Nt32Pkg/MiscSubClassPlatformDxe/MiscNumberOfInstallableLanguagesFunction.c deleted file mode 100644 index 58c0b692f6..0000000000 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscNumberOfInstallableLanguagesFunction.c +++ /dev/null @@ -1,225 +0,0 @@ -/** @file - -Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#include "MiscSubclassDriver.h" -/*++ - Check whether the language is supported for given HII handle - - @param HiiHandle The HII package list handle. - @param Offset The offest of current lanague in the supported languages. - @param CurrentLang The language code. - - @retval TRUE Supported. - @retval FALSE Not Supported. - ---*/ -VOID -EFIAPI -CurrentLanguageMatch ( - IN EFI_HII_HANDLE HiiHandle, - OUT UINT16 *Offset, - OUT CHAR8 *CurrentLang - ) -{ - CHAR8 *DefaultLang; - CHAR8 *BestLanguage; - CHAR8 *Languages; - CHAR8 *MatchLang; - CHAR8 *EndMatchLang; - UINTN CompareLength; - - Languages = HiiGetSupportedLanguages (HiiHandle); - if (Languages == NULL) { - return; - } - - GetEfiGlobalVariable2 (L"PlatformLang", (VOID**)&CurrentLang, NULL); - DefaultLang = (CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLang); - BestLanguage = GetBestLanguage ( - Languages, - FALSE, - (CurrentLang != NULL) ? CurrentLang : "", - DefaultLang, - NULL - ); - if (BestLanguage != NULL) { - // - // Find the best matching RFC 4646 language, compute the offset. - // - CompareLength = AsciiStrLen (BestLanguage); - for (MatchLang = Languages, (*Offset) = 0; MatchLang != '\0'; (*Offset)++) { - // - // Seek to the end of current match language. - // - for (EndMatchLang = MatchLang; *EndMatchLang != '\0' && *EndMatchLang != ';'; EndMatchLang++); - - if ((EndMatchLang == MatchLang + CompareLength) && AsciiStrnCmp(MatchLang, BestLanguage, CompareLength) == 0) { - // - // Find the current best Language in the supported languages - // - break; - } - // - // best language match be in the supported language. - // - ASSERT (*EndMatchLang == ';'); - MatchLang = EndMatchLang + 1; - } - FreePool (BestLanguage); - } - - FreePool (Languages); - if (CurrentLang != NULL) { - FreePool (CurrentLang); - } - return ; -} - - -/** - Get next language from language code list (with separator ';'). - - @param LangCode Input: point to first language in the list. On - Otput: point to next language in the list, or - NULL if no more language in the list. - @param Lang The first language in the list. - -**/ -VOID -EFIAPI -GetNextLanguage ( - IN OUT CHAR8 **LangCode, - OUT CHAR8 *Lang - ) -{ - UINTN Index; - CHAR8 *StringPtr; - - ASSERT (LangCode != NULL); - ASSERT (*LangCode != NULL); - ASSERT (Lang != NULL); - - Index = 0; - StringPtr = *LangCode; - while (StringPtr[Index] != 0 && StringPtr[Index] != ';') { - Index++; - } - - CopyMem (Lang, StringPtr, Index); - Lang[Index] = 0; - - if (StringPtr[Index] == ';') { - Index++; - } - *LangCode = StringPtr + Index; -} - -/** - This function returns the number of supported languages on HiiHandle. - - @param HiiHandle The HII package list handle. - - @retval The number of supported languages. - -**/ -UINT16 -EFIAPI -GetSupportedLanguageNumber ( - IN EFI_HII_HANDLE HiiHandle - ) -{ - CHAR8 *Lang; - CHAR8 *Languages; - CHAR8 *LanguageString; - UINT16 LangNumber; - - Languages = HiiGetSupportedLanguages (HiiHandle); - if (Languages == NULL) { - return 0; - } - - LangNumber = 0; - Lang = AllocatePool (AsciiStrSize (Languages)); - if (Lang != NULL) { - LanguageString = Languages; - while (*LanguageString != 0) { - GetNextLanguage (&LanguageString, Lang); - LangNumber++; - } - FreePool (Lang); - } - FreePool (Languages); - return LangNumber; -} - - -/** - This function makes boot time changes to the contents of the - MiscNumberOfInstallableLanguages (Type 13). - - @param RecordData Pointer to copy of RecordData from the Data Table. - - @retval EFI_SUCCESS All parameters were valid. - @retval EFI_UNSUPPORTED Unexpected RecordType value. - @retval EFI_INVALID_PARAMETER Invalid parameter was found. - -**/ -MISC_SMBIOS_TABLE_FUNCTION(NumberOfInstallableLanguages) -{ - UINTN LangStrLen; - CHAR8 CurrentLang[SMBIOS_STRING_MAX_LENGTH + 1]; - CHAR8 *OptionalStrStart; - UINT16 Offset; - EFI_STATUS Status; - EFI_SMBIOS_HANDLE SmbiosHandle; - SMBIOS_TABLE_TYPE13 *SmbiosRecord; - EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES *ForType13InputData; - - ForType13InputData = (EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES *)RecordData; - - // - // First check for invalid parameters. - // - if (RecordData == NULL) { - return EFI_INVALID_PARAMETER; - } - - ForType13InputData->NumberOfInstallableLanguages = GetSupportedLanguageNumber (mHiiHandle); - - // - // Try to check if current langcode matches with the langcodes in installed languages - // - ZeroMem(CurrentLang, SMBIOS_STRING_MAX_LENGTH + 1); - CurrentLanguageMatch (mHiiHandle, &Offset, CurrentLang); - LangStrLen = AsciiStrLen(CurrentLang); - - // - // Two zeros following the last string. - // - SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE13) + LangStrLen + 1 + 1); - ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE13) + LangStrLen + 1 + 1); - - SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_BIOS_LANGUAGE_INFORMATION; - SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE13); - // - // Make handle chosen by smbios protocol.add automatically. - // - SmbiosRecord->Hdr.Handle = 0; - - SmbiosRecord->InstallableLanguages = (UINT8)ForType13InputData->NumberOfInstallableLanguages; - SmbiosRecord->Flags = (UINT8)ForType13InputData->LanguageFlags.AbbreviatedLanguageFormat; - SmbiosRecord->CurrentLanguages = 1; - OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1); - AsciiStrCpy(OptionalStrStart, CurrentLang); - // - // Now we have got the full smbios record, call smbios protocol to add this record. - // - Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord); - - FreePool(SmbiosRecord); - return Status; -} diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscOemStringData.c b/Nt32Pkg/MiscSubClassPlatformDxe/MiscOemStringData.c deleted file mode 100644 index 64a3e79c7f..0000000000 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscOemStringData.c +++ /dev/null @@ -1,26 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - MiscOemStringData.c - -Abstract: - - This driver parses the mMiscSubclassDataTable structure and reports - any generated data to the DataHub. - -**/ - -#include "MiscSubclassDriver.h" - -// -// Static (possibly build generated) Bios Vendor data. -// -MISC_SMBIOS_TABLE_DATA(EFI_MISC_OEM_STRING_DATA, OemString) = { - STRING_TOKEN(STR_MISC_OEM_STRING) -}; - -/* eof - MiscOemStringData.c */ diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscOemStringFunction.c b/Nt32Pkg/MiscSubClassPlatformDxe/MiscOemStringFunction.c deleted file mode 100644 index 3c2d326815..0000000000 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscOemStringFunction.c +++ /dev/null @@ -1,70 +0,0 @@ -/** @file - boot information boot time changes. - SMBIOS type 11. - -Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - - -#include "MiscSubclassDriver.h" -/** - This function makes boot time changes to the contents of the - MiscOemString (Type 11). - - @param RecordData Pointer to copy of RecordData from the Data Table. - - @retval EFI_SUCCESS All parameters were valid. - @retval EFI_UNSUPPORTED Unexpected RecordType value. - @retval EFI_INVALID_PARAMETER Invalid parameter was found. - -**/ -MISC_SMBIOS_TABLE_FUNCTION(OemString) -{ - UINTN OemStrLen; - CHAR8 *OptionalStrStart; - EFI_STATUS Status; - EFI_STRING OemStr; - STRING_REF TokenToGet; - EFI_SMBIOS_HANDLE SmbiosHandle; - SMBIOS_TABLE_TYPE11 *SmbiosRecord; - - // - // First check for invalid parameters. - // - if (RecordData == NULL) { - return EFI_INVALID_PARAMETER; - } - - TokenToGet = STRING_TOKEN (STR_MISC_OEM_STRING); - OemStr = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL); - OemStrLen = StrLen(OemStr); - if (OemStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - - // - // Two zeros following the last string. - // - SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE11) + OemStrLen + 1 + 1); - ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE11) + OemStrLen + 1 + 1); - - SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_OEM_STRINGS; - SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE11); - // - // Make handle chosen by smbios protocol.add automatically. - // - SmbiosRecord->Hdr.Handle = 0; - SmbiosRecord->StringCount = 1; - OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1); - UnicodeStrToAsciiStr(OemStr, OptionalStrStart); - - // - // Now we have got the full smbios record, call smbios protocol to add this record. - // - Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord); - - FreePool(SmbiosRecord); - return Status; -} diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignatorData.c b/Nt32Pkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignatorData.c deleted file mode 100644 index 4e9117a29c..0000000000 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignatorData.c +++ /dev/null @@ -1,93 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - MiscPortInternalConnectorDesignatorData.c - -Abstract: - - This driver parses the mMiscSubclassDataTable structure and reports - any generated data to the DataHub. - -**/ - -#include "MiscSubclassDriver.h" - -// -// Static (possibly build generated) Bios Vendor data. -// -MISC_SMBIOS_TABLE_DATA(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortInternalConnectorDesignator) = { - STRING_TOKEN(STR_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR), // PortInternalConnectorDesignator - STRING_TOKEN(STR_MISC_PORT_EXTERNAL_CONNECTOR_DESIGNATOR), // PortExternalConnectorDesignator - EfiPortConnectorTypeOther, // PortInternalConnectorType - EfiPortConnectorTypeOther, // PortExternalConnectorType - EfiPortTypeNone, // PortType - 0 // PortPath -}; - -// -// Static (possibly build generated) Bios Vendor data. -// -MISC_SMBIOS_TABLE_DATA(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortKeyboard) = { - STRING_TOKEN (STR_MISC_PORT_INTERNAL_KEYBOARD), // PortInternalConnectorDesignator - STRING_TOKEN (STR_MISC_PORT_EXTERNAL_KEYBOARD), // PortExternalConnectorDesignator - EfiPortConnectorTypeNone, // PortInternalConnectorType - EfiPortConnectorTypePS2, // PortExternalConnectorType - EfiPortTypeKeyboard, // PortType - // mPs2KbyboardDevicePath // PortPath - // - 0 -}; - -MISC_SMBIOS_TABLE_DATA(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortMouse) = { - STRING_TOKEN (STR_MISC_PORT_INTERNAL_MOUSE), // PortInternalConnectorDesignator - STRING_TOKEN (STR_MISC_PORT_EXTERNAL_MOUSE), // PortExternalConnectorDesignator - EfiPortConnectorTypeNone, // PortInternalConnectorType - EfiPortConnectorTypePS2, // PortExternalConnectorType - EfiPortTypeMouse, // PortType - // mPs2MouseDevicePath // PortPath - // - 0 -}; - - -MISC_SMBIOS_TABLE_DATA(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortCom1) = { - STRING_TOKEN(STR_MISC_PORT_INTERNAL_COM1), - STRING_TOKEN(STR_MISC_PORT_EXTERNAL_COM1), - EfiPortConnectorTypeNone, - EfiPortConnectorTypeDB9Female, - EfiPortTypeSerial16550ACompatible, - 0 -}; - -MISC_SMBIOS_TABLE_DATA(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortCom2) = { - STRING_TOKEN(STR_MISC_PORT_INTERNAL_COM2), - STRING_TOKEN(STR_MISC_PORT_EXTERNAL_COM2), - EfiPortConnectorTypeNone, - EfiPortConnectorTypeDB9Female, - EfiPortTypeSerial16550ACompatible, - 0 -}; - -MISC_SMBIOS_TABLE_DATA(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortExtensionPower) = { - STRING_TOKEN(STR_MISC_PORT_INTERNAL_EXTENSION_POWER), - STRING_TOKEN(STR_MISC_PORT_EXTERNAL_EXTENSION_POWER), - EfiPortConnectorTypeOther, - EfiPortConnectorTypeNone, - EfiPortTypeOther, - 0 -}; - -MISC_SMBIOS_TABLE_DATA(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortFloppy) = { - STRING_TOKEN(STR_MISC_PORT_INTERNAL_FLOPPY), - STRING_TOKEN(STR_MISC_PORT_EXTERNAL_FLOPPY), - EfiPortConnectorTypeOnboardFloppy, - EfiPortConnectorTypeNone, - EfiPortTypeOther, - 0 -}; - -/* eof - MiscPortInternalConnectorDesignatorData.c */ diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignatorFunction.c b/Nt32Pkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignatorFunction.c deleted file mode 100644 index 8de657cb6a..0000000000 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignatorFunction.c +++ /dev/null @@ -1,166 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - MiscPortInternalConnectorDesignatorFunction.c - -Abstract: - - This driver parses the mMiscSubclassDataTable structure and reports - any generated data to the DataHub. - -**/ - -#include "MiscSubclassDriver.h" - - -MISC_SMBIOS_TABLE_FUNCTION ( - MiscPortInternalConnectorDesignator - ) -/*++ -Description: - - This function makes boot time changes to the contents of the - MiscPortConnectorInformation (Type 8). - -Parameters: - - RecordType - Type of record to be processed from the Data Table. - mMiscSubclassDataTable[].RecordType - - RecordLen - Size of static RecordData from the Data Table. - mMiscSubclassDataTable[].RecordLen - - RecordData - Pointer to copy of RecordData from the Data Table. Changes made - to this copy will be written to the Data Hub but will not alter - the contents of the static Data Table. - - LogRecordData - Set *LogRecordData to TRUE to log RecordData to Data Hub. - Set *LogRecordData to FALSE when there is no more data to log. - -Returns: - - EFI_SUCCESS - All parameters were valid and *RecordData and *LogRecordData have - been set. - - EFI_UNSUPPORTED - Unexpected RecordType value. - - EFI_INVALID_PARAMETER - One of the following parameter conditions was true: - RecordLen was zero. - RecordData was NULL. - LogRecordData was NULL. ---*/ -{ - CHAR8 *OptionalStrStart; - UINTN InternalRefStrLen; - UINTN ExternalRefStrLen; - EFI_STRING InternalRef; - EFI_STRING ExternalRef; - STRING_REF TokenForInternal; - STRING_REF TokenForExternal; - EFI_STATUS Status; - SMBIOS_TABLE_TYPE8 *SmbiosRecord; - EFI_SMBIOS_HANDLE SmbiosHandle; - EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR *ForType8InputData; - - ForType8InputData = (EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR *)RecordData; - // - // First check for invalid parameters. - // - if (RecordData == NULL) { - return EFI_INVALID_PARAMETER; - } - - TokenForInternal = 0; - TokenForExternal = 0; - - switch (ForType8InputData->PortInternalConnectorDesignator) { - - case STR_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR: - TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR); - TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_CONNECTOR_DESIGNATOR); - break; - case STR_MISC_PORT_INTERNAL_KEYBOARD: - TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_KEYBOARD); - TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_KEYBOARD); - break; - case STR_MISC_PORT_INTERNAL_MOUSE: - TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_MOUSE); - TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_MOUSE); - break; - case STR_MISC_PORT_INTERNAL_COM1: - TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_COM1); - TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_COM1); - break; - case STR_MISC_PORT_INTERNAL_COM2: - TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_COM2); - TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_COM2); - break; - case STR_MISC_PORT_INTERNAL_EXTENSION_POWER: - TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_EXTENSION_POWER); - TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_EXTENSION_POWER); - break; - case STR_MISC_PORT_INTERNAL_FLOPPY: - TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_FLOPPY); - TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_FLOPPY); - break; - default: - break; - } - - InternalRef = HiiGetPackageString(&gEfiCallerIdGuid, TokenForInternal, NULL); - InternalRefStrLen = StrLen(InternalRef); - if (InternalRefStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - - ExternalRef = HiiGetPackageString(&gEfiCallerIdGuid, TokenForExternal, NULL); - ExternalRefStrLen = StrLen(ExternalRef); - if (ExternalRefStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - - // - // Two zeros following the last string. - // - SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE8) + InternalRefStrLen + 1 + ExternalRefStrLen + 1 + 1); - ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE8) + InternalRefStrLen + 1 + ExternalRefStrLen + 1 + 1); - - SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_PORT_CONNECTOR_INFORMATION; - SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE8); - // - // Make handle chosen by smbios protocol.add automatically. - // - SmbiosRecord->Hdr.Handle = 0; - SmbiosRecord->InternalReferenceDesignator = 1; - SmbiosRecord->InternalConnectorType = (UINT8)ForType8InputData->PortInternalConnectorType; - SmbiosRecord->ExternalReferenceDesignator = 2; - SmbiosRecord->ExternalConnectorType = (UINT8)ForType8InputData->PortExternalConnectorType; - SmbiosRecord->PortType = (UINT8)ForType8InputData->PortType; - - OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1); - UnicodeStrToAsciiStr(InternalRef, OptionalStrStart); - UnicodeStrToAsciiStr(ExternalRef, OptionalStrStart + InternalRefStrLen + 1); - - // - // Now we have got the full smbios record, call smbios protocol to add this record. - // - Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord); - - FreePool(SmbiosRecord); - return Status; -} - - - -/* eof - MiscSystemManufacturerFunction.c */ diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscResetCapabilitiesData.c b/Nt32Pkg/MiscSubClassPlatformDxe/MiscResetCapabilitiesData.c deleted file mode 100644 index e8a66bf068..0000000000 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscResetCapabilitiesData.c +++ /dev/null @@ -1,36 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - MiscResetCapabilitiesData.c - -Abstract: - - This driver parses the mMiscSubclassDataTable structure and reports - any generated data to the DataHub. - -**/ - -#include "MiscSubclassDriver.h" - -// -// Static (possibly build generated) Bios Vendor data. -// -MISC_SMBIOS_TABLE_DATA(EFI_MISC_RESET_CAPABILITIES, MiscResetCapabilities) = { - { // ResetCapabilities - 0, // Status - 0, // BootOption - 0, // BootOptionOnLimit - 0, // WatchdogTimerPresent - 0 // Reserved - }, - 0, // ResetCount - 0, // ResetLimit - 0, // ResetTimerInterval - 0 // ResetTimeout -}; - -/* eof - MiscResetCapabilities.c */ diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscResetCapabilitiesFunction.c b/Nt32Pkg/MiscSubClassPlatformDxe/MiscResetCapabilitiesFunction.c deleted file mode 100644 index 0cf894d6e3..0000000000 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscResetCapabilitiesFunction.c +++ /dev/null @@ -1,66 +0,0 @@ -/** @file - ResetCapabilities. - SMBIOS type 23. - -Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - - -#include "MiscSubclassDriver.h" -/** - This function makes boot time changes to the contents of the - MiscOemString (Type 11). - - @param RecordData Pointer to copy of RecordData from the Data Table. - - @retval EFI_SUCCESS All parameters were valid. - @retval EFI_UNSUPPORTED Unexpected RecordType value. - @retval EFI_INVALID_PARAMETER Invalid parameter was found. - -**/ -MISC_SMBIOS_TABLE_FUNCTION(MiscResetCapabilities) -{ - EFI_STATUS Status; - EFI_SMBIOS_HANDLE SmbiosHandle; - SMBIOS_TABLE_TYPE23 *SmbiosRecord; - EFI_MISC_RESET_CAPABILITIES *ForType23InputData; - - ForType23InputData = (EFI_MISC_RESET_CAPABILITIES *)RecordData; - - // - // First check for invalid parameters. - // - if (RecordData == NULL) { - return EFI_INVALID_PARAMETER; - } - - - // - // Two zeros following the last string. - // - SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE23) + 1 + 1); - ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE23) + 1 + 1); - - SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_RESET; - SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE23); - // - // Make handle chosen by smbios protocol.add automatically. - // - SmbiosRecord->Hdr.Handle = 0; - SmbiosRecord->Capabilities = *(UINT8*)&(ForType23InputData->ResetCapabilities); - SmbiosRecord->ResetCount = (UINT16)ForType23InputData->ResetCount; - SmbiosRecord->ResetLimit = (UINT16)ForType23InputData->ResetLimit; - SmbiosRecord->TimerInterval = (UINT16)ForType23InputData->ResetTimerInterval; - SmbiosRecord->Timeout = (UINT16)ForType23InputData->ResetTimeout; - - // - // Now we have got the full smbios record, call smbios protocol to add this record. - // - Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord); - - FreePool(SmbiosRecord); - return Status; -} - diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscSubClassPlatformDxe.inf b/Nt32Pkg/MiscSubClassPlatformDxe/MiscSubClassPlatformDxe.inf deleted file mode 100644 index 2850598f29..0000000000 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscSubClassPlatformDxe.inf +++ /dev/null @@ -1,89 +0,0 @@ -## @file -# Misc Sub class driver -# -# Parses the MiscSubclassDataTable and reports any generated data to the DataHub. -# All .uni file who tagged with "ToolCode="DUMMY"" in following file list is included by -# MiscSubclassDriver.uni file, the StrGather tool will expand MiscSubclassDriver.uni file -# and parse all .uni file. -# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
-# -# SPDX-License-Identifier: BSD-2-Clause-Patent -# -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = MiscSubclass - FILE_GUID = 4A9B9DB8-EC62-4A92-818F-8AA0246D246E - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - ENTRY_POINT = MiscSubclassDriverEntryPoint - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 -# - -[Sources] - MiscBaseBoardManufacturerData.c - MiscBaseBoardManufacturerFunction.c - MiscBiosVendorData.c - MiscBiosVendorFunction.c - MiscBootInformationData.c - MiscBootInformationFunction.c - MiscChassisManufacturerData.c - MiscChassisManufacturerFunction.c - MiscNumberOfInstallableLanguagesData.c - MiscNumberOfInstallableLanguagesFunction.c - MiscOemStringData.c - MiscOemStringFunction.c - MiscPortInternalConnectorDesignatorData.c - MiscPortInternalConnectorDesignatorFunction.c - MiscResetCapabilitiesData.c - MiscResetCapabilitiesFunction.c - MiscSystemLanguageStringData.c - MiscSystemLanguageStringFunction.c - MiscSystemManufacturerData.c - MiscSystemManufacturerFunction.c - MiscSystemOptionStringData.c - MiscSystemOptionStringFunction.c - MiscSystemSlotDesignationData.c - MiscSystemSlotDesignationFunction.c - MiscDevicePath.h - MiscSubclassDriver.h - MiscSubclassDriver.uni - MiscSubclassDriverDataTable.c - MiscSubclassDriverEntryPoint.c - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - IntelFrameworkPkg/IntelFrameworkPkg.dec - Nt32Pkg/Nt32Pkg.dec - -[LibraryClasses] - DevicePathLib - UefiBootServicesTableLib - BaseMemoryLib - UefiDriverEntryPoint - UefiLib - HiiLib - DebugLib - BaseLib - MemoryAllocationLib - PcdLib - -[Protocols] - gEfiWinNtIoProtocolGuid # PROTOCOL_NOTIFY SOMETIMES_CONSUMED - gEfiSmbiosProtocolGuid # PROTOCOL ALWAYS_CONSUMED - -[Pcd] - gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareReleaseDateString - gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString - gEfiNt32PkgTokenSpaceGuid.PcdWinNtMemorySize - gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLang - -[Depex] - gEfiSmbiosProtocolGuid diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscSubclassDriver.h b/Nt32Pkg/MiscSubClassPlatformDxe/MiscSubclassDriver.h deleted file mode 100644 index fbd29d7092..0000000000 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscSubclassDriver.h +++ /dev/null @@ -1,123 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - MiscSubclassDriver.h - -Abstract: - - Header file for MiscSubclass Driver. - -**/ - -#ifndef _MISC_SUBCLASS_DRIVER_H -#define _MISC_SUBCLASS_DRIVER_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -// -// Data table entry update function. -// -typedef EFI_STATUS (EFIAPI EFI_MISC_SMBIOS_DATA_FUNCTION) ( - IN VOID *RecordData, - IN EFI_SMBIOS_PROTOCOL *Smbios - ); - -// -// Data table entry definition. -// -typedef struct { - // - // intermediat input data for SMBIOS record - // - VOID *RecordData; - EFI_MISC_SMBIOS_DATA_FUNCTION *Function; -} EFI_MISC_SMBIOS_DATA_TABLE; - -// -// Data Table extern definitions. -// -#define MISC_SMBIOS_TABLE_EXTERNS(NAME1, NAME2, NAME3) \ -extern NAME1 NAME2 ## Data; \ -extern EFI_MISC_SMBIOS_DATA_FUNCTION NAME3 ## Function - - -// -// Data Table entries -// -#define MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION(NAME1, NAME2) \ -{ \ - & NAME1 ## Data, \ - & NAME2 ## Function \ -} - -// -// Global definition macros. -// -#define MISC_SMBIOS_TABLE_DATA(NAME1, NAME2) \ - NAME1 NAME2 ## Data - -#define MISC_SMBIOS_TABLE_FUNCTION(NAME2) \ - EFI_STATUS EFIAPI NAME2 ## Function( \ - IN VOID *RecordData, \ - IN EFI_SMBIOS_PROTOCOL *Smbios \ - ) - - -// -// Data Table Array -// -extern EFI_MISC_SMBIOS_DATA_TABLE mMiscSubclassDataTable[]; - -// -// Data Table Array Entries -// -extern UINTN mMiscSubclassDataTableEntries; -extern UINT8 MiscSubclassStrings[]; -extern EFI_HII_HANDLE mHiiHandle; - - -/** - Add an SMBIOS record. - - @param Smbios The EFI_SMBIOS_PROTOCOL instance. - @param SmbiosHandle A unique handle will be assigned to the SMBIOS record. - @param Record The data for the fixed portion of the SMBIOS record. The format of the record is - determined by EFI_SMBIOS_TABLE_HEADER.Type. The size of the formatted area is defined - by EFI_SMBIOS_TABLE_HEADER.Length and either followed by a double-null (0x0000) or - a set of null terminated strings and a null. - - @retval EFI_SUCCESS Record was added. - @retval EFI_OUT_OF_RESOURCES Record was not added due to lack of system resources. - -**/ -EFI_STATUS -AddSmbiosRecord ( - IN EFI_SMBIOS_PROTOCOL *Smbios, - OUT EFI_SMBIOS_HANDLE *SmbiosHandle, - IN EFI_SMBIOS_TABLE_HEADER *Record - ); - -#endif /* _MISC_SUBCLASS_DRIVER_H */ - -/* eof - MiscSubclassDriver.h */ diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscSubclassDriver.uni b/Nt32Pkg/MiscSubClassPlatformDxe/MiscSubclassDriver.uni deleted file mode 100644 index 8d11a497b8..0000000000 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscSubclassDriver.uni +++ /dev/null @@ -1,114 +0,0 @@ -// *++ -// -// Copyright (c) 2006, Intel Corporation. All rights reserved.
-// (C) Copyright 2017 Hewlett Packard Enterprise Development LP
-// SPDX-License-Identifier: BSD-2-Clause-Patent -// -// Module Name: -// -// MiscSubclassStrings.Vfr -// -// Abstract: -// -// Misc. Subclass formset. -// -// Revision History: -// -// --*/ - -/=# - -#langdef en-US "English" -#langdef fr-FR "Français" - - -#string STR_MISC_SUBCLASS_DRIVER_TITLE #language en-US "Not used" - -#string STR_MISC_BASE_BOARD_MANUFACTURER #language en-US "Base Board Manufacturer" -#string STR_MISC_BASE_BOARD_PRODUCT_NAME #language en-US "Base Board Product Name" -#string STR_MISC_BASE_BOARD_VERSION #language en-US "Base Board Version" -#string STR_MISC_BASE_BOARD_SERIAL_NUMBER #language en-US "Base Board Serial Number" -#string STR_MISC_BASE_BOARD_ASSET_TAG #language en-US "Base Board Asset Tag" -#string STR_MISC_BASE_BOARD_CHASSIS_LOCATION #language en-US "Base Board Chassis Location" - -#string STR_MISC_BIOS_VENDOR #language en-US "Bios Vendor" -#string STR_MISC_BIOS_VERSION #language en-US "R9 Prime" - #language fr-FR "Perfection R9" -#string STR_MISC_BIOS_RELEASE_DATE #language en-US "Bios Release Date" - -#string STR_MISC_CHASSIS_MANUFACTURER #language en-US "Chassis Manufacturer" -#string STR_MISC_CHASSIS_VERSION #language en-US "Chassis Version" -#string STR_MISC_CHASSIS_SERIAL_NUMBER #language en-US "Chassis Serial Number" -#string STR_MISC_CHASSIS_ASSET_TAG #language en-US "Chassis Asset Tag" -#string STR_MISC_CHASSIS_SKU_NUMBER #language en-US "Chassis SKU Number" - -#string STR_MISC_OEM_STRING #language en-US "System Language String" - -#string STR_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR #language en-US "Port Internal Connector" -#string STR_MISC_PORT_EXTERNAL_CONNECTOR_DESIGNATOR #language en-US "Port External Connector" -#string STR_MISC_PORT_INTERNAL_KEYBOARD #language en-US "J1A1" -#string STR_MISC_PORT_EXTERNAL_KEYBOARD #language en-US "Keyboard" -#string STR_MISC_PORT_INTERNAL_MOUSE #language en-US "J1A1" -#string STR_MISC_PORT_EXTERNAL_MOUSE #language en-US "Mouse" -#string STR_MISC_PORT_INTERNAL_COM1 #language en-US "J2A1" -#string STR_MISC_PORT_EXTERNAL_COM1 #language en-US "COM 1" -#string STR_MISC_PORT_INTERNAL_LPT1 #language en-US "J4A2" -#string STR_MISC_PORT_EXTERNAL_LPT1 #language en-US "LPT 1" -#string STR_MISC_PORT_INTERNAL_EXTENSION_POWER #language en-US "J5C1" -#string STR_MISC_PORT_EXTERNAL_EXTENSION_POWER #language en-US "Extension Power Header" -#string STR_MISC_PORT_INTERNAL_USB1 #language en-US "JA5A1" -#string STR_MISC_PORT_EXTERNAL_USB1 #language en-US "USB" -#string STR_MISC_PORT_INTERNAL_USB2 #language en-US "J2A2" -#string STR_MISC_PORT_EXTERNAL_USB2 #language en-US "USB" -#string STR_MISC_PORT_INTERNAL_NETWORK #language en-US "JA5A1" -#string STR_MISC_PORT_EXTERNAL_NETWORK #language en-US "RJ-45 Type" -#string STR_MISC_PORT_INTERNAL_MIC #language en-US "J6A1" -#string STR_MISC_PORT_EXTERNAL_MIC #language en-US "Audio Mic In" -#string STR_MISC_PORT_INTERNAL_LINE_IN #language en-US "J6A1" -#string STR_MISC_PORT_EXTERNAL_LINE_IN #language en-US "Audio Line In" -#string STR_MISC_PORT_INTERNAL_LINE_OUT #language en-US "J6A1" -#string STR_MISC_PORT_EXTERNAL_LINE_OUT #language en-US "Audio Line Out" -#string STR_MISC_PORT_INTERNAL_FLOPPY #language en-US "J4H1" -#string STR_MISC_PORT_EXTERNAL_FLOPPY #language en-US "OnBoard Floppy Type" -#string STR_MISC_PORT_INTERNAL_IDE1 #language en-US "J6H2" -#string STR_MISC_PORT_EXTERNAL_IDE1 #language en-US "OnBoard Primary IDE" -#string STR_MISC_PORT_INTERNAL_IDE2 #language en-US "J6H1" -#string STR_MISC_PORT_EXTERNAL_IDE2 #language en-US "OnBoard Secondary IDE" -#string STR_MISC_PORT_INTERNAL_SOUND_IN1 #language en-US "J8B1" -#string STR_MISC_PORT_EXTERNAL_SOUND_IN1 #language en-US "OnBoard Sound Input Type" -#string STR_MISC_PORT_INTERNAL_SOUND_IN2 #language en-US "J6B1" -#string STR_MISC_PORT_EXTERNAL_SOUND_IN2 #language en-US "OnBoard Sound Input Type" -#string STR_MISC_PORT_INTERNAL_FRONT_PANEL #language en-US "J9G1" -#string STR_MISC_PORT_EXTERNAL_FRONT_PANEL #language en-US "Front Panel Header Type" -#string STR_MISC_PORT_INTERNAL_CPU_FAN #language en-US "J2F1" -#string STR_MISC_PORT_EXTERNAL_CPU_FAN #language en-US "CPU Fan Header" -#string STR_MISC_PORT_INTERNAL_FRONT_FAN #language en-US "J9H3" -#string STR_MISC_PORT_EXTERNAL_FRONT_FAN #language en-US "Front Chassis Fan" -#string STR_MISC_PORT_INTERNAL_REAR_FAN #language en-US "J1B1" -#string STR_MISC_PORT_EXTERNAL_REAR_FAN #language en-US "Rear Chassis Fan" -#string STR_MISC_PORT_INTERNAL_CONFIG_JUMPER #language en-US "J9H2" -#string STR_MISC_PORT_EXTERNAL_CONFIG_JUMPER #language en-US "Configuration Jumper" -#string STR_MISC_PORT_INTERNAL_AUDIO_PANEL #language en-US "J8A1" -#string STR_MISC_PORT_EXTERNAL_AUDIO_PANEL #language en-US "Audio Front Panel Header" -#string STR_MISC_PORT_INTERNAL_USB_PANEL #language en-US "J9F1" -#string STR_MISC_PORT_EXTERNAL_USB_PANEL #language en-US "USB Front Panel Header" -#string STR_MISC_PORT_INTERNAL_ATX_POWER #language en-US "J2H1" -#string STR_MISC_PORT_EXTERNAL_ATX_POWER #language en-US "ATX Power Header" -#string STR_MISC_PORT_INTERNAL_COM2 #language en-US "J5A1" -#string STR_MISC_PORT_EXTERNAL_COM2 #language en-US "COM 2" -#string STR_MISC_PORT_INTERNAL_USB3 #language en-US "J1D3" -#string STR_MISC_PORT_EXTERNAL_USB3 #language en-US "USB" - -#string STR_MISC_SYSTEM_LANGUAGE_STRING #language en-US "System Language String" - -#string STR_MISC_SYSTEM_MANUFACTURER #language en-US "System Manufacturer" -#string STR_MISC_SYSTEM_PRODUCT_NAME #language en-US "NT32 Emulation Environment" - #language fr-FR "Environnement De l'Émulation NT32" - -#string STR_MISC_SYSTEM_VERSION #language en-US "System Version" -#string STR_MISC_SYSTEM_SERIAL_NUMBER #language en-US "System Serial Number" - -#string STR_MISC_SYSTEM_OPTION_STRING #language en-US "System Option String" - -#string STR_MISC_SYSTEM_SLOT_DESIGNATION #language en-US "System Slot Designation" - diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscSubclassDriverDataTable.c b/Nt32Pkg/MiscSubClassPlatformDxe/MiscSubclassDriverDataTable.c deleted file mode 100644 index ceecbe977d..0000000000 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscSubclassDriverDataTable.c +++ /dev/null @@ -1,72 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - MiscSubclassDriverDataTable.c - -Abstract: - - This driver parses the mMiscSubclassDataTable structure and reports - any generated data to the DataHub. - -**/ - -#include "MiscSubclassDriver.h" - - -// -// External definitions referenced by Data Table entries. -// -MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_BASE_BOARD_MANUFACTURER_DATA, MiscBaseBoardManufacturer, MiscBaseBoardManufacturer); -MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_BIOS_VENDOR_DATA, MiscBiosVendor,MiscBiosVendor ); -MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_BOOT_INFORMATION_STATUS_DATA, BootInformationStatus, BootInformationStatus); -MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_CHASSIS_MANUFACTURER_DATA, MiscChassisManufacturer, MiscChassisManufacturer); -MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES_DATA,NumberOfInstallableLanguages, NumberOfInstallableLanguages); -MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_OEM_STRING_DATA,OemString, OemString); -MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortInternalConnectorDesignator, MiscPortInternalConnectorDesignator); -MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortKeyboard, MiscPortInternalConnectorDesignator); -MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortMouse, MiscPortInternalConnectorDesignator); -MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortCom1, MiscPortInternalConnectorDesignator); -MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortCom2, MiscPortInternalConnectorDesignator); -MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortExtensionPower, MiscPortInternalConnectorDesignator); -MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortFloppy, MiscPortInternalConnectorDesignator); -MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_RESET_CAPABILITIES, MiscResetCapabilities, MiscResetCapabilities); -MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_SYSTEM_LANGUAGE_STRING_DATA,SystemLanguageString, SystemLanguageString); -MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_SYSTEM_MANUFACTURER_DATA, MiscSystemManufacturer, MiscSystemManufacturer); -MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_SYSTEM_OPTION_STRING_DATA, SystemOptionString, SystemOptionString); -MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_SYSTEM_SLOT_DESIGNATION_DATA, MiscSystemSlotDesignation, MiscSystemSlotDesignation); - - -// -// Data Table. -// -EFI_MISC_SMBIOS_DATA_TABLE mMiscSubclassDataTable[] = { - MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscBaseBoardManufacturer, MiscBaseBoardManufacturer), - MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscBiosVendor,MiscBiosVendor ), - MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( BootInformationStatus, BootInformationStatus), - MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscChassisManufacturer, MiscChassisManufacturer), - MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION(NumberOfInstallableLanguages, NumberOfInstallableLanguages), - MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION(OemString, OemString), - MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscPortInternalConnectorDesignator, MiscPortInternalConnectorDesignator), - MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscPortKeyboard, MiscPortInternalConnectorDesignator), - MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscPortMouse, MiscPortInternalConnectorDesignator), - MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscPortCom1, MiscPortInternalConnectorDesignator), - MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscPortCom2, MiscPortInternalConnectorDesignator), - MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscPortExtensionPower, MiscPortInternalConnectorDesignator), - MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscPortFloppy, MiscPortInternalConnectorDesignator), - MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscResetCapabilities, MiscResetCapabilities), - MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION(SystemLanguageString, SystemLanguageString), - MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscSystemManufacturer, MiscSystemManufacturer), - MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( SystemOptionString, SystemOptionString), - MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscSystemSlotDesignation, MiscSystemSlotDesignation), - }; - -// -// Number of Data Table entries. -// -UINTN mMiscSubclassDataTableEntries = (sizeof mMiscSubclassDataTable) / sizeof (EFI_MISC_SMBIOS_DATA_TABLE); - -/* eof - MiscSubclassDriverDataTable.c */ diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscSubclassDriverEntryPoint.c b/Nt32Pkg/MiscSubClassPlatformDxe/MiscSubclassDriverEntryPoint.c deleted file mode 100644 index b7098e9b02..0000000000 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscSubclassDriverEntryPoint.c +++ /dev/null @@ -1,194 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - MiscSubclassDriverEntryPoint.c - -Abstract: - - This driver parses the mMiscSubclassDataTable structure and reports - any generated data to the DataHub. - -**/ - -#include "MiscSubclassDriver.h" - -EFI_HII_HANDLE mHiiHandle; - -/** - This is the standard EFI driver point that detects whether there is a - MemoryConfigurationData Variable and, if so, reports memory configuration info - to the DataHub. - - @param ImageHandle Handle for the image of this driver - @param SystemTable Pointer to the EFI System Table - - @return EFI_SUCCESS if the data is successfully reported - @return EFI_NOT_FOUND if the HOB list could not be located. - -**/ -EFI_STATUS -LogMemorySmbiosRecord ( - VOID - ) -{ - EFI_STATUS Status; - UINT64 TotalMemorySize; - UINT8 NumSlots; - SMBIOS_TABLE_TYPE19 *Type19Record; - EFI_SMBIOS_HANDLE MemArrayMappedAddrSmbiosHandle; - EFI_SMBIOS_PROTOCOL *Smbios; - CHAR16 *Nt32MemString; - - Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID**)&Smbios); - ASSERT_EFI_ERROR (Status); - - NumSlots = 1; - - // - // Process Memory String in form size!size ... - // So 64!64 is 128 MB - // - Nt32MemString = PcdGetPtr (PcdWinNtMemorySize); - for (TotalMemorySize = 0; *Nt32MemString != '\0';) { - TotalMemorySize += StrDecimalToUint64 (Nt32MemString); - while (*Nt32MemString != '\0') { - if (*Nt32MemString == '!') { - Nt32MemString++; - break; - } - Nt32MemString++; - } - } - - // - // Convert Total Memory Size to based on KiloByte - // - TotalMemorySize = LShiftU64 (TotalMemorySize, 20); - // - // Generate Memory Array Mapped Address info - // - Type19Record = AllocateZeroPool(sizeof (SMBIOS_TABLE_TYPE19) + 2); - Type19Record->Hdr.Type = EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS; - Type19Record->Hdr.Length = sizeof(SMBIOS_TABLE_TYPE19); - Type19Record->Hdr.Handle = 0; - Type19Record->StartingAddress = 0; - Type19Record->EndingAddress = (UINT32)RShiftU64(TotalMemorySize, 10) - 1; - Type19Record->MemoryArrayHandle = 0; - Type19Record->PartitionWidth = (UINT8)(NumSlots); - - // - // Generate Memory Array Mapped Address info (TYPE 19) - // - Status = AddSmbiosRecord (Smbios, &MemArrayMappedAddrSmbiosHandle, (EFI_SMBIOS_TABLE_HEADER*) Type19Record); - - FreePool(Type19Record); - ASSERT_EFI_ERROR (Status); - - return Status; -} - - -EFI_STATUS -EFIAPI -MiscSubclassDriverEntryPoint ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -/*++ -Description: - - Standard EFI driver point. This driver parses the mMiscSubclassDataTable - structure and reports any generated data to the DataHub. - -Arguments: - - ImageHandle - Handle for the image of this driver - - SystemTable - Pointer to the EFI System Table - -Returns: - - EFI_SUCCESS - The data was successfully reported to the Data Hub. - ---*/ -{ - UINTN Index; - EFI_STATUS EfiStatus; - EFI_SMBIOS_PROTOCOL *Smbios; - - EfiStatus = gBS->LocateProtocol(&gEfiSmbiosProtocolGuid, NULL, (VOID**)&Smbios); - - if (EFI_ERROR(EfiStatus)) { - DEBUG((EFI_D_ERROR, "Could not locate SMBIOS protocol. %r\n", EfiStatus)); - return EfiStatus; - } - - mHiiHandle = HiiAddPackages ( - &gEfiCallerIdGuid, - NULL, - MiscSubclassStrings, - NULL - ); - ASSERT (mHiiHandle != NULL); - - for (Index = 0; Index < mMiscSubclassDataTableEntries; ++Index) { - // - // If the entry have a function pointer, just log the data. - // - if (mMiscSubclassDataTable[Index].Function != NULL) { - EfiStatus = (*mMiscSubclassDataTable[Index].Function)( - mMiscSubclassDataTable[Index].RecordData, - Smbios - ); - - if (EFI_ERROR(EfiStatus)) { - DEBUG((EFI_D_ERROR, "Misc smbios store error. Index=%d, ReturnStatus=%r\n", Index, EfiStatus)); - return EfiStatus; - } - } - } - - // - // Log Memory SMBIOS Record - // - EfiStatus = LogMemorySmbiosRecord(); - return EfiStatus; -} - -/** - Add an SMBIOS record. - - @param Smbios The EFI_SMBIOS_PROTOCOL instance. - @param SmbiosHandle A unique handle will be assigned to the SMBIOS record. - @param Record The data for the fixed portion of the SMBIOS record. The format of the record is - determined by EFI_SMBIOS_TABLE_HEADER.Type. The size of the formatted area is defined - by EFI_SMBIOS_TABLE_HEADER.Length and either followed by a double-null (0x0000) or - a set of null terminated strings and a null. - - @retval EFI_SUCCESS Record was added. - @retval EFI_OUT_OF_RESOURCES Record was not added due to lack of system resources. - -**/ -EFI_STATUS -AddSmbiosRecord ( - IN EFI_SMBIOS_PROTOCOL *Smbios, - OUT EFI_SMBIOS_HANDLE *SmbiosHandle, - IN EFI_SMBIOS_TABLE_HEADER *Record - ) -{ - *SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED; - return Smbios->Add ( - Smbios, - NULL, - SmbiosHandle, - Record - ); -} - diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscSystemLanguageStringData.c b/Nt32Pkg/MiscSubClassPlatformDxe/MiscSystemLanguageStringData.c deleted file mode 100644 index dd432e3002..0000000000 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscSystemLanguageStringData.c +++ /dev/null @@ -1,27 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - MiscSystemLanguageStringData.c - -Abstract: - - This driver parses the mMiscSubclassDataTable structure and reports - any generated data to the DataHub. - -**/ - -#include "MiscSubclassDriver.h" - -// -// Static (possibly build generated) Bios Vendor data. -// -MISC_SMBIOS_TABLE_DATA(EFI_MISC_SYSTEM_LANGUAGE_STRING_DATA, SystemLanguageString) = { - 0, - STRING_TOKEN(STR_MISC_SYSTEM_LANGUAGE_STRING) -}; - -/* eof - MiscSystemLanguageStringData.c */ diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscSystemLanguageStringFunction.c b/Nt32Pkg/MiscSubClassPlatformDxe/MiscSystemLanguageStringFunction.c deleted file mode 100644 index 45d2279c2a..0000000000 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscSystemLanguageStringFunction.c +++ /dev/null @@ -1,72 +0,0 @@ -/** @file - -Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#include "MiscSubclassDriver.h" -/** - This function makes boot time changes to the contents of the - MiscOemString (Type 11). - - @param RecordData Pointer to copy of RecordData from the Data Table. - - @retval EFI_SUCCESS All parameters were valid. - @retval EFI_UNSUPPORTED Unexpected RecordType value. - @retval EFI_INVALID_PARAMETER Invalid parameter was found. - -**/ -MISC_SMBIOS_TABLE_FUNCTION(SystemLanguageString) -{ - EFI_STATUS Status; - EFI_SMBIOS_HANDLE SmbiosHandle; - SMBIOS_TABLE_TYPE13 *SmbiosRecord; - UINTN StrLeng; - CHAR8 *OptionalStrStart; - EFI_STRING Str; - STRING_REF TokenToGet; - - - // - // First check for invalid parameters. - // - if (RecordData == NULL) { - return EFI_INVALID_PARAMETER; - } - - TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_LANGUAGE_STRING); - Str = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL); - StrLeng = StrLen(Str); - if (StrLeng > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - - // - // Two zeros following the last string. - // - SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE13) + StrLeng + 1 + 1); - ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE13) + StrLeng + 1 + 1); - - SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_BIOS_LANGUAGE_INFORMATION; - SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE13); - // - // Make handle chosen by smbios protocol.add automatically. - // - SmbiosRecord->Hdr.Handle = 0; - SmbiosRecord->InstallableLanguages = 1; - SmbiosRecord->Flags = 1; - SmbiosRecord->CurrentLanguages = 1; - OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1); - UnicodeStrToAsciiStr(Str, OptionalStrStart); - - - // - // Now we have got the full smbios record, call smbios protocol to add this record. - // - Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord); - - FreePool(SmbiosRecord); - return Status; -} - diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscSystemManufacturerData.c b/Nt32Pkg/MiscSubClassPlatformDxe/MiscSystemManufacturerData.c deleted file mode 100644 index bc44ca5f89..0000000000 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscSystemManufacturerData.c +++ /dev/null @@ -1,49 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - MiscSystemManufacturerData.c - -Abstract: - - This driver parses the mMiscSubclassDataTable structure and reports - any generated data to the DataHub. - -**/ - -#include "MiscSubclassDriver.h" - -// -// Static (possibly build generated) System Manufacturer data. -// -MISC_SMBIOS_TABLE_DATA(EFI_MISC_SYSTEM_MANUFACTURER_DATA, MiscSystemManufacturer) -= { - STRING_TOKEN(STR_MISC_SYSTEM_MANUFACTURER), - // SystemManufactrurer - STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), - // SystemProductName - STRING_TOKEN(STR_MISC_SYSTEM_VERSION), - // SystemVersion - STRING_TOKEN(STR_MISC_SYSTEM_SERIAL_NUMBER), - // SystemSerialNumber - { - 0xbadfaced, - 0xdead, - 0xbeef, - 0x13, - 0x13, - 0x13, - 0x13, - 0x13, - 0x13, - 0x13, - 0x13 - }, - // SystemUuid - EfiSystemWakeupTypePowerSwitch // SystemWakeupType -}; - -/* eof - MiscSystemManufacturerData.c */ diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscSystemManufacturerFunction.c b/Nt32Pkg/MiscSubClassPlatformDxe/MiscSystemManufacturerFunction.c deleted file mode 100644 index f0719f6caf..0000000000 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscSystemManufacturerFunction.c +++ /dev/null @@ -1,129 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - MiscSystemManufacturerFunction.c - -Abstract: - - This driver parses the mMiscSubclassDataTable structure and reports - any generated data to the DataHub. - -**/ - -#include "MiscSubclassDriver.h" - -/** - This function makes boot time changes to the contents of the - MiscSystemManufacturer (Type 1). - - @param RecordData Pointer to copy of RecordData from the Data Table. - - @retval EFI_SUCCESS All parameters were valid. - @retval EFI_UNSUPPORTED Unexpected RecordType value. - @retval EFI_INVALID_PARAMETER Invalid parameter was found. - -**/ -MISC_SMBIOS_TABLE_FUNCTION(MiscSystemManufacturer) -{ - CHAR8 *OptionalStrStart; - UINTN ManuStrLen; - UINTN VerStrLen; - UINTN PdNameStrLen; - UINTN SerialNumStrLen; - EFI_STATUS Status; - EFI_STRING Manufacturer; - EFI_STRING ProductName; - EFI_STRING Version; - EFI_STRING SerialNumber; - STRING_REF TokenToGet; - EFI_SMBIOS_HANDLE SmbiosHandle; - SMBIOS_TABLE_TYPE1 *SmbiosRecord; - EFI_MISC_SYSTEM_MANUFACTURER *ForType1InputData; - - ForType1InputData = (EFI_MISC_SYSTEM_MANUFACTURER *)RecordData; - - // - // First check for invalid parameters. - // - if (RecordData == NULL) { - return EFI_INVALID_PARAMETER; - } - - TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_MANUFACTURER); - Manufacturer = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL); - ManuStrLen = StrLen(Manufacturer); - if (ManuStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - - TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_PRODUCT_NAME); - ProductName = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL); - PdNameStrLen = StrLen(ProductName); - if (PdNameStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - - TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_VERSION); - Version = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL); - VerStrLen = StrLen(Version); - if (VerStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - - TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_SERIAL_NUMBER); - SerialNumber = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL); - SerialNumStrLen = StrLen(SerialNumber); - if (SerialNumStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - // - // Two zeros following the last string. - // - SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE1) + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + 1); - ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE1) + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + 1); - - SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_INFORMATION; - SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE1); - // - // Make handle chosen by smbios protocol.add automatically. - // - SmbiosRecord->Hdr.Handle = 0; - // - // Manu will be the 1st optional string following the formatted structure. - // - SmbiosRecord->Manufacturer = 1; - // - // ProductName will be the 2nd optional string following the formatted structure. - // - SmbiosRecord->ProductName = 2; - // - // Version will be the 3rd optional string following the formatted structure. - // - SmbiosRecord->Version = 3; - // - // Version will be the 4th optional string following the formatted structure. - // - SmbiosRecord->SerialNumber = 4; - CopyMem ((UINT8 *) (&SmbiosRecord->Uuid),&ForType1InputData->SystemUuid,16); - SmbiosRecord->WakeUpType = (UINT8)ForType1InputData->SystemWakeupType; - - OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1); - UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart); - UnicodeStrToAsciiStr(ProductName, OptionalStrStart + ManuStrLen + 1); - UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1); - UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1); - - // - // Now we have got the full smbios record, call smbios protocol to add this record. - // - Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord); - - FreePool(SmbiosRecord); - return Status; -} - -/* eof - MiscSystemManufacturerFunction.c */ diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscSystemOptionStringData.c b/Nt32Pkg/MiscSubClassPlatformDxe/MiscSystemOptionStringData.c deleted file mode 100644 index b027354390..0000000000 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscSystemOptionStringData.c +++ /dev/null @@ -1,26 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - MiscSystemOptionStringData.c - -Abstract: - - This driver parses the mMiscSubclassDataTable structure and reports - any generated data to the DataHub. - -**/ - -#include "MiscSubclassDriver.h" - -// -// Static (possibly build generated) Bios Vendor data. -// -MISC_SMBIOS_TABLE_DATA(EFI_MISC_SYSTEM_OPTION_STRING_DATA, SystemOptionString) = { - STRING_TOKEN(STR_MISC_SYSTEM_OPTION_STRING) -}; - -/* eof - MiscSystemOptionStringData.c */ diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscSystemOptionStringFunction.c b/Nt32Pkg/MiscSubClassPlatformDxe/MiscSystemOptionStringFunction.c deleted file mode 100644 index e3abc4f2cf..0000000000 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscSystemOptionStringFunction.c +++ /dev/null @@ -1,71 +0,0 @@ -/** @file - BIOS system option string boot time changes. - SMBIOS type 12. - -Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#include "MiscSubclassDriver.h" - - -/** - This function makes boot time changes to the contents of the - MiscSystemOptionString (Type 12). - - @param RecordData Pointer to copy of RecordData from the Data Table. - - @retval EFI_SUCCESS All parameters were valid. - @retval EFI_UNSUPPORTED Unexpected RecordType value. - @retval EFI_INVALID_PARAMETER Invalid parameter was found. - -**/ -MISC_SMBIOS_TABLE_FUNCTION(SystemOptionString) -{ - CHAR8 *OptionalStrStart; - UINTN OptStrLen; - EFI_STRING OptionString; - EFI_STATUS Status; - STRING_REF TokenToGet; - EFI_SMBIOS_HANDLE SmbiosHandle; - SMBIOS_TABLE_TYPE12 *SmbiosRecord; - - // - // First check for invalid parameters. - // - if (RecordData == NULL) { - return EFI_INVALID_PARAMETER; - } - - TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_OPTION_STRING); - OptionString = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL); - OptStrLen = StrLen(OptionString); - if (OptStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - - // - // Two zeros following the last string. - // - SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE12) + OptStrLen + 1 + 1); - ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE12) + OptStrLen + 1 + 1); - - SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_CONFIGURATION_OPTIONS; - SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE12); - // - // Make handle chosen by smbios protocol.add automatically. - // - SmbiosRecord->Hdr.Handle = 0; - - SmbiosRecord->StringCount = 1; - OptionalStrStart = (CHAR8*) (SmbiosRecord + 1); - UnicodeStrToAsciiStr(OptionString, OptionalStrStart); - // - // Now we have got the full smbios record, call smbios protocol to add this record. - // - Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord); - - FreePool(SmbiosRecord); - return Status; -} diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignationData.c b/Nt32Pkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignationData.c deleted file mode 100644 index be70130415..0000000000 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignationData.c +++ /dev/null @@ -1,46 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - MiscSystemSlotDesignationData.c - -Abstract: - - This driver parses the mMiscSubclassDataTable structure and reports - any generated data to the DataHub. - -**/ - -#include "MiscSubclassDriver.h" - -// -// Static (possibly build generated) Bios Vendor data. -// -MISC_SMBIOS_TABLE_DATA(EFI_MISC_SYSTEM_SLOT_DESIGNATION_DATA, MiscSystemSlotDesignation) = { - STRING_TOKEN(STR_MISC_SYSTEM_SLOT_DESIGNATION), // SlotDesignation - EfiSlotTypeOther, // SlotType - EfiSlotDataBusWidthOther, // SlotDataBusWidth - EfiSlotUsageOther, // SlotUsage - EfiSlotLengthOther, // SlotLength - 0, // SlotId - { // SlotCharacteristics - 0, // CharacteristicsUnknown :1; - 0, // Provides50Volts :1; - 0, // Provides33Volts :1; - 0, // SharedSlot :1; - 0, // PcCard16Supported :1; - 0, // CardBusSupported :1; - 0, // ZoomVideoSupported :1; - 0, // ModemRingResumeSupported:1; - 0, // PmeSignalSupported :1; - 0, // HotPlugDevicesSupported :1; - 0, // SmbusSignalSupported :1; - 0 // Reserved :21; - }, - 0 // SlotDevicePath -}; - -/* eof - MiscSystemSlotsData.c */ diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignationFunction.c b/Nt32Pkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignationFunction.c deleted file mode 100644 index f62600352e..0000000000 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignationFunction.c +++ /dev/null @@ -1,86 +0,0 @@ -/** @file - BIOS system slot designator information boot time changes. - SMBIOS type 9. - -Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#include "MiscSubclassDriver.h" -/** - This function makes boot time changes to the contents of the - MiscSystemSlotDesignator structure (Type 9). - - @param RecordData Pointer to copy of RecordData from the Data Table. - - @retval EFI_SUCCESS All parameters were valid. - @retval EFI_UNSUPPORTED Unexpected RecordType value. - @retval EFI_INVALID_PARAMETER Invalid parameter was found. - -**/ -MISC_SMBIOS_TABLE_FUNCTION(MiscSystemSlotDesignation) -{ - CHAR8 *OptionalStrStart; - UINTN SlotDesignationStrLen; - EFI_STATUS Status; - EFI_STRING SlotDesignation; - STRING_REF TokenToGet; - SMBIOS_TABLE_TYPE9 *SmbiosRecord; - EFI_SMBIOS_HANDLE SmbiosHandle; - EFI_MISC_SYSTEM_SLOT_DESIGNATION* ForType9InputData; - - ForType9InputData = (EFI_MISC_SYSTEM_SLOT_DESIGNATION *)RecordData; - - // - // First check for invalid parameters. - // - if (RecordData == NULL) { - return EFI_INVALID_PARAMETER; - } - - TokenToGet = 0; - switch (ForType9InputData->SlotDesignation) { - case STR_MISC_SYSTEM_SLOT_DESIGNATION: - TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_SLOT_DESIGNATION); - break; - default: - break; - } - - SlotDesignation = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL); - SlotDesignationStrLen = StrLen(SlotDesignation); - if (SlotDesignationStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - - // - // Two zeros following the last string. - // - SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE9) + SlotDesignationStrLen + 1 + 1); - ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE9) +SlotDesignationStrLen + 1 + 1); - - SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_SLOTS; - SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE9); - SmbiosRecord->Hdr.Handle = 0; - SmbiosRecord->SlotDesignation = 1; - SmbiosRecord->SlotType = (UINT8)ForType9InputData->SlotType; - SmbiosRecord->SlotDataBusWidth = (UINT8)ForType9InputData->SlotDataBusWidth; - SmbiosRecord->CurrentUsage = (UINT8)ForType9InputData->SlotUsage; - SmbiosRecord->SlotLength = (UINT8)ForType9InputData->SlotLength; - SmbiosRecord->SlotID = ForType9InputData->SlotId; - - // - // Slot Characteristics - // - CopyMem ((UINT8 *) &SmbiosRecord->SlotCharacteristics1,(UINT8 *) &ForType9InputData->SlotCharacteristics,2); - OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1); - UnicodeStrToAsciiStr(SlotDesignation, OptionalStrStart); - // - // Now we have got the full smbios record, call smbios protocol to add this record. - // - Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord); - - FreePool(SmbiosRecord); - return Status; -} diff --git a/Nt32Pkg/Nt32Pkg.dec b/Nt32Pkg/Nt32Pkg.dec deleted file mode 100644 index 158e896389..0000000000 --- a/Nt32Pkg/Nt32Pkg.dec +++ /dev/null @@ -1,90 +0,0 @@ -## @file -# This package is a platform package that provide platform module/library -# required by NT32 platform. -# -# File/Directory Orignazation: -# |- Sec : Emulation SecCore for Nt32 platform -# |- *Pei : PEIM drivers -# |- *Dxe : DXE drivers -# |- Nt32Pkg.dec : This file -# |- Nt32Pkg.dsc : Nt32 platform DSC file -# |- Nt32Pkg.fdf : Flash description file for Nt32Pkg. It is used for creating FD file. -# |- Include : Include files for Nt32Pkg -# -# -# Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.
-# -# SPDX-License-Identifier: BSD-2-Clause-Patent -# -# - -[Defines] - DEC_SPECIFICATION = 0x00010005 - PACKAGE_NAME = Nt32Pkg - PACKAGE_GUID = 0fb2aa2d-10d5-40a5-a9dc-060c12a4a3f3 - PACKAGE_VERSION = 0.4 - -[Includes] - Include - -[LibraryClasses] - ## - # Expose EFI_WIN_NT_THUNK_PROTOCOL's interface, this protocol wrapper all - # necessary Window API used by Nt32 enumlation environment. - WinNtLib|Include/Library/WinNtLib.h - -[Guids] - gEfiWinNtPassThroughGuid = { 0xCC664EB8, 0x3C24, 0x4086, { 0xB6, 0xF6, 0x34, 0xE8, 0x56, 0xBC, 0xE3, 0x6E }} - gEfiWinNtConsoleGuid = { 0xBA73672C, 0xA5D3, 0x11D4, { 0xBD, 0x00, 0x00, 0x80, 0xC7, 0x3C, 0x88, 0x81 }} - gEfiWinNtUgaGuid = { 0xAB248E99, 0xABE1, 0x11D4, { 0xBD, 0x0D, 0x00, 0x80, 0xC7, 0x3C, 0x88, 0x81 }} - gEfiWinNtGopGuid = { 0x4e11e955, 0xccca, 0x11d4, { 0xbd, 0x0d, 0x00, 0x80, 0xc7, 0x3c, 0x88, 0x81 }} - gEfiWinNtSerialPortGuid = { 0x0C95A93D, 0xA006, 0x11D4, { 0xBC, 0xFA, 0x00, 0x80, 0xC7, 0x3C, 0x88, 0x81 }} - gEfiWinNtFileSystemGuid = { 0x0C95A935, 0xA006, 0x11D4, { 0xBC, 0xFA, 0x00, 0x80, 0xC7, 0x3C, 0x88, 0x81 }} - gEfiWinNtPhysicalDisksGuid = { 0x0C95A92F, 0xA006, 0x11D4, { 0xBC, 0xFA, 0x00, 0x80, 0xC7, 0x3C, 0x88, 0x81 }} - gEfiWinNtVirtualDisksGuid = { 0x0C95A928, 0xA006, 0x11D4, { 0xBC, 0xFA, 0x00, 0x80, 0xC7, 0x3C, 0x88, 0x81 }} - gEfiNt32PkgTokenSpaceGuid = { 0x0D79A645, 0x1D91, 0x40a6, { 0xA8, 0x1F, 0x61, 0xE6, 0x98, 0x2B, 0x32, 0xB4 }} - gEfiWinNtSystemConfigGuid = { 0xb347f047, 0xaf8c, 0x490e, { 0xac, 0x07, 0x0a, 0xa9, 0xb7, 0xe5, 0x38, 0x58 }} - -[Ppis] - ## This PPI wrapper all necessary windows API used by PEI driver in NT32 environment. - gPeiNtThunkPpiGuid = { 0x98c281e5, 0xf906, 0x43dd, { 0xa9, 0x2b, 0xb0, 0x03, 0xbf, 0x27, 0x65, 0xda }} - ## This PPI provide system memory scan interface which simulate real platform perform - # memory's auto scan. - gPeiNtAutoScanPpiGuid = { 0x0dce384d, 0x007c, 0x4ba5, { 0x94, 0xbd, 0x0f, 0x6e, 0xb6, 0x4d, 0x2a, 0xa9 }} - ## This PPI provide interace to loads and relocates a PE/COFF image into memory. - gNtPeiLoadFilePpiGuid = { 0xfd0c65eb, 0x0405, 0x4cd2, { 0x8a, 0xee, 0xf4, 0x0, 0xef, 0x13, 0xba, 0xc2 }} - ## This PPI instance hold information for an simulated firmware device. - gNtFwhPpiGuid = { 0x4e76928f, 0x50ad, 0x4334, {0xb0, 0x6b, 0xa8, 0x42, 0x13, 0x10, 0x8a, 0x57 }} - -[Protocols] - gWinNtBusDriverGuid = { 0x0419f582, 0x0625, 0x4531, { 0x8a, 0x33, 0x85, 0xa9, 0x96, 0x5c, 0x95, 0xbc }} - gEfiWinNtThunkProtocolGuid = { 0x58C518B1, 0x76F3, 0x11D4, { 0xBC, 0xEA, 0x00, 0x80, 0xC7, 0x3C, 0x88, 0x81 }} - gEfiWinNtIoProtocolGuid = { 0x96EB4AD6, 0xA32A, 0x11D4, { 0xBC, 0xFD, 0x00, 0x80, 0xC7, 0x3C, 0x88, 0x81 }} - -[PcdsFixedAtBuild] - gEfiNt32PkgTokenSpaceGuid.PcdWinNtFlashNvStorageEventLogBase|0x0|UINT32|0x0000100e - gEfiNt32PkgTokenSpaceGuid.PcdWinNtFlashNvStorageEventLogSize|0x0|UINT32|0x0000100f - gEfiNt32PkgTokenSpaceGuid.PcdWinNtFlashFvRecoveryBase|0x0|UINT32|0x00001010 - gEfiNt32PkgTokenSpaceGuid.PcdWinNtFlashFvRecoverySize|0x0|UINT32|0x00001011 - gEfiNt32PkgTokenSpaceGuid.PcdWinNtFirmwareFdSize|0x0|UINT32|0x00001012 - gEfiNt32PkgTokenSpaceGuid.PcdWinNtFirmwareBlockSize|0|UINT32|0x00001013 - gEfiNt32PkgTokenSpaceGuid.PcdWinNtFlashNvStorageVariableBase|0x0|UINT32|0x00001014 - gEfiNt32PkgTokenSpaceGuid.PcdWinNtFlashNvStorageFtwSpareBase|0x0|UINT32|0x00001015 - gEfiNt32PkgTokenSpaceGuid.PcdWinNtFlashNvStorageFtwWorkingBase|0x0|UINT32|0x00001016 - gEfiNt32PkgTokenSpaceGuid.PcdWinNtFdBaseAddress|0x0|UINT32|0x00001017 - -[PcdsFixedAtBuild, PcdsPatchableInModule] - gEfiNt32PkgTokenSpaceGuid.PcdWinNtBootMode|1|UINT32|0x00001006 - gEfiNt32PkgTokenSpaceGuid.PcdWinNtFirmwareVolume|L"..\\Fv\\Fv_Recovery.fd"|VOID*|0x00001009 - gEfiNt32PkgTokenSpaceGuid.PcdWinNtMemorySizeForSecMain|L"64!64"|VOID*|0x0000100c - -[PcdsDynamic, PcdsDynamicEx] - gEfiNt32PkgTokenSpaceGuid.PcdWinNtPhysicalDisk|L"E:RW;245760;512"|VOID*|0x00001000 - gEfiNt32PkgTokenSpaceGuid.PcdWinNtVirtualDisk|L"FW;40960;512"|VOID*|0x00001001 - gEfiNt32PkgTokenSpaceGuid.PcdWinNtSerialPort|L"COM1!COM2"|VOID*|0x00001002 - gEfiNt32PkgTokenSpaceGuid.PcdWinNtUga|L"UGA Window 1!UGA Window 2"|VOID*|0x00001003 - gEfiNt32PkgTokenSpaceGuid.PcdWinNtFileSystem|L"."|VOID*|0x00001004 - gEfiNt32PkgTokenSpaceGuid.PcdWinNtMemorySize|L"64!64"|VOID*|0x00001005 - gEfiNt32PkgTokenSpaceGuid.PcdWinNtConsole|L"Bus Driver Console Window"|VOID*|0x0000100a - gEfiNt32PkgTokenSpaceGuid.PcdWinNtGop|L"UGA Window 1!UGA Window 2"|VOID*|0x0000100d - diff --git a/Nt32Pkg/Nt32Pkg.dsc b/Nt32Pkg/Nt32Pkg.dsc deleted file mode 100644 index 990d5ee0bf..0000000000 --- a/Nt32Pkg/Nt32Pkg.dsc +++ /dev/null @@ -1,483 +0,0 @@ -## @file -# EFI/Framework Emulation Platform with UEFI HII interface supported. -# -# The Emulation Platform can be used to debug individual modules, prior to creating -# a real platform. This also provides an example for how an DSC is created. -# -# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
-# Copyright (c) 2015, Hewlett-Packard Development Company, L.P.
-# (C) Copyright 2016 Hewlett Packard Enterprise Development LP
-# -# SPDX-License-Identifier: BSD-2-Clause-Patent -# -## - -################################################################################ -# -# Defines Section - statements that will be processed to create a Makefile. -# -################################################################################ -[Defines] - PLATFORM_NAME = NT32 - PLATFORM_GUID = EB216561-961F-47EE-9EF9-CA426EF547C2 - PLATFORM_VERSION = 0.4 - DSC_SPECIFICATION = 0x00010005 - OUTPUT_DIRECTORY = Build/NT32$(ARCH) - SUPPORTED_ARCHITECTURES = IA32|X64 - BUILD_TARGETS = DEBUG|RELEASE|NOOPT - SKUID_IDENTIFIER = DEFAULT - FLASH_DEFINITION = Nt32Pkg/Nt32Pkg.fdf - # - # This flag is to control tool to generate PCD info for dynamic(ex) PCD, - # then enable or disable PCD info feature. TRUE is enable, and FLASE is disable. - # If the flag is absent, it will be same as FALSE. - # - PCD_INFO_GENERATION = TRUE - - # - # Defines for default states. These can be changed on the command line. - # -D FLAG=VALUE - # - # Note: Secure Boot feature highly depends on the OpenSSL building. To enable this - # feature, please follow the instructions found in the file "Patch-HOWTO.txt" - # located in CryptoPkg\Library\OpensslLib to enable the OpenSSL building first. - # - DEFINE SECURE_BOOT_ENABLE = FALSE - - # - # Network definition - # SnpNt32Dxe.inf will be used. - # - DEFINE NETWORK_TLS_ENABLE = FALSE - DEFINE NETWORK_IP6_ENABLE = FALSE - DEFINE NETWORK_SNP_ENABLE = FALSE - DEFINE NETWORK_ALLOW_HTTP_CONNECTIONS = TRUE - -################################################################################ -# -# SKU Identification section - list of all SKU IDs supported by this -# Platform. -# -################################################################################ -[SkuIds] - 0|DEFAULT # The entry: 0|DEFAULT is reserved and always required. - -################################################################################ -# -# Library Class section - list of all Library Classes needed by this Platform. -# -################################################################################ -[LibraryClasses] - # - # Entry point - # - PeiCoreEntryPoint|MdePkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoint.inf - PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf - DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf - UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf - UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf - # - # Basic - # - BaseLib|MdePkg/Library/BaseLib/BaseLib.inf - SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf - PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf - CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf - IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf - PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf - PciCf8Lib|MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf - PciExpressLib|MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf - CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf - PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf - PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf - SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf - # - # UEFI & PI - # - UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf - UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf - UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf - UefiLib|MdePkg/Library/UefiLib/UefiLib.inf - UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf - HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf - DevicePathLib|MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLibDevicePathProtocol.inf - UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiTianoCustomDecompressLib.inf - PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf - PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf - DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf - DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf - UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf - FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf - - # - # Generic Modules - # - UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf - UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf - OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf - GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf - CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf - SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf - TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf - SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf - CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf - BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf - # - # Platform - # - PlatformBootManagerLib|Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf - # - # Misc - # - DebugLib|MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf - DebugPrintErrorLevelLib|MdeModulePkg/Library/DxeDebugPrintErrorLevelLib/DxeDebugPrintErrorLevelLib.inf - PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf - DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf - CpuExceptionHandlerLib|MdeModulePkg/Library/CpuExceptionHandlerLibNull/CpuExceptionHandlerLibNull.inf - LockBoxLib|MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.inf - IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf - ResetSystemLib|Nt32Pkg/Library/ResetSystemLib/ResetSystemLib.inf -!if $(NETWORK_TLS_ENABLE) == TRUE - OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf -!else - OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf -!endif - -!if $(SECURE_BOOT_ENABLE) == TRUE - PlatformSecureLib|Nt32Pkg/Library/PlatformSecureLib/PlatformSecureLib.inf - TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf - AuthVariableLib|SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf -!else - TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf - AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf -!endif - VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf - -[LibraryClasses.common.USER_DEFINED] - DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf - PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf - ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf - OemHookStatusCodeLib|Nt32Pkg/Library/PeiNt32OemHookStatusCodeLib/PeiNt32OemHookStatusCodeLib.inf - MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf - PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf - -[LibraryClasses.common.PEIM,LibraryClasses.common.PEI_CORE] - # - # PEI phase common - # - HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf - MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf - ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf - ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf - BaseMemoryLib|MdePkg/Library/BaseMemoryLibOptPei/BaseMemoryLibOptPei.inf - IoLib|MdePkg/Library/PeiIoLibCpuIo/PeiIoLibCpuIo.inf - PeCoffGetEntryPointLib|Nt32Pkg/Library/Nt32PeiPeCoffGetEntryPointLib/Nt32PeiPeCoffGetEntryPointLib.inf - PeCoffExtraActionLib|Nt32Pkg/Library/PeiNt32PeCoffExtraActionLib/PeiNt32PeCoffExtraActionLib.inf - DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf - -[LibraryClasses.common.PEI_CORE] - PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf - OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf - -[LibraryClasses.common.PEIM] - PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf - OemHookStatusCodeLib|Nt32Pkg/Library/PeiNt32OemHookStatusCodeLib/PeiNt32OemHookStatusCodeLib.inf - BaseCryptLib|CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf - -[LibraryClasses.common] - # - # DXE phase common - # - BaseMemoryLib|MdePkg/Library/BaseMemoryLibOptDxe/BaseMemoryLibOptDxe.inf - HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf - ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf - OemHookStatusCodeLib|Nt32Pkg/Library/DxeNt32OemHookStatusCodeLib/DxeNt32OemHookStatusCodeLib.inf - PeCoffExtraActionLib|Nt32Pkg/Library/DxeNt32PeCoffExtraActionLib/DxeNt32PeCoffExtraActionLib.inf - ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf - WinNtLib|Nt32Pkg/Library/DxeWinNtLib/DxeWinNtLib.inf - BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf - TlsLib|CryptoPkg/Library/TlsLib/TlsLib.inf - -[LibraryClasses.common.DXE_CORE] - HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf - MemoryAllocationLib|MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationLib.inf - PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf - -[LibraryClasses.common.DXE_SMM_DRIVER] - DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf - -[LibraryClasses.common.UEFI_DRIVER] - PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf - -[LibraryClasses.common.UEFI_APPLICATION] - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - PrintLib|MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLibPrint2Protocol.inf - -[LibraryClasses.common.DXE_RUNTIME_DRIVER] - # - # Runtime - # - BaseCryptLib|CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf - -################################################################################ -# -# Pcd Section - list of all EDK II PCD Entries defined by this Platform -# -################################################################################ -[PcdsFeatureFlag] - gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial|FALSE - gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|FALSE - gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplBuildPageTables|FALSE - gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreImageLoaderSearchTeSectionFirst|FALSE - gEfiMdeModulePkgTokenSpaceGuid.PcdVariableCollectStatistics|TRUE - -[PcdsFixedAtBuild] - gEfiMdeModulePkgTokenSpaceGuid.PcdImageProtectionPolicy|0x00000000 - gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizeNonPopulateCapsule|0x0 - gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizePopulateCapsule|0x0 - gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000040 - gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x1f - gEfiNt32PkgTokenSpaceGuid.PcdWinNtFirmwareVolume|L"..\\Fv\\Nt32.fd" - gEfiNt32PkgTokenSpaceGuid.PcdWinNtFirmwareBlockSize|0x10000 - gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x0f - gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE - gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000 - -!if $(SECURE_BOOT_ENABLE) == TRUE - # override the default values from SecurityPkg to ensure images from all sources are verified in secure boot - gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy|0x04 - gEfiSecurityPkgTokenSpaceGuid.PcdFixedMediaImageVerificationPolicy|0x04 - gEfiSecurityPkgTokenSpaceGuid.PcdRemovableMediaImageVerificationPolicy|0x04 -!endif - - gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0x31 } - - -################################################################################ -# -# Pcd Dynamic Section - list of all EDK II PCD Entries defined by this Platform -# -################################################################################ -[PcdsDynamicDefault.common.DEFAULT] - gEfiNt32PkgTokenSpaceGuid.PcdWinNtSerialPort|L"COM1!COM2"|VOID*|20 - gEfiNt32PkgTokenSpaceGuid.PcdWinNtGop|L"UGA Window 1!UGA Window 2"|VOID*|52 - gEfiNt32PkgTokenSpaceGuid.PcdWinNtConsole|L"Bus Driver Console Window"|VOID*|52 - gEfiNt32PkgTokenSpaceGuid.PcdWinNtVirtualDisk|L"FW;40960;512"|VOID*|26 - gEfiNt32PkgTokenSpaceGuid.PcdWinNtMemorySize|L"64!64"|VOID*|12 - gEfiNt32PkgTokenSpaceGuid.PcdWinNtPhysicalDisk|L"a:RW;2880;512!d:RO;307200;2048!j:RW;262144;512"|VOID*|100 - gEfiNt32PkgTokenSpaceGuid.PcdWinNtUga|L"UGA Window 1!UGA Window 2"|VOID*|52 - - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0 - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0 - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase|0 - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64|0 - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64|0 - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0 - -[PcdsDynamicDefault.Ia32] - gEfiNt32PkgTokenSpaceGuid.PcdWinNtFileSystem|L"."|VOID*|106 - -[PcdsDynamicDefault.x64] - gEfiNt32PkgTokenSpaceGuid.PcdWinNtFileSystem|L"."|VOID*|106 - -[PcdsDynamicHii.common.DEFAULT] - gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutColumn|L"SetupConsoleConfig"|gEfiNt32PkgTokenSpaceGuid|0x0|80 - gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutRow|L"SetupConsoleConfig"|gEfiNt32PkgTokenSpaceGuid|0x4|25 - gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|L"Timeout"|gEfiGlobalVariableGuid|0x0|10 - gEfiMdePkgTokenSpaceGuid.PcdHardwareErrorRecordLevel|L"HwErrRecSupport"|gEfiGlobalVariableGuid|0x0|1 - -################################################################################################### -# -# Components Section - list of the modules and components that will be processed by compilation -# tools and the EDK II tools to generate PE32/PE32+/Coff image files. -# -# Note: The EDK II DSC file is not used to specify how compiled binary images get placed -# into firmware volume images. This section is just a list of modules to compile from -# source into UEFI-compliant binaries. -# It is the FDF file that contains information on combining binary files into firmware -# volume images, whose concept is beyond UEFI and is described in PI specification. -# Binary modules do not need to be listed in this section, as they should be -# specified in the FDF file. For example: Shell binary (Shell_Full.efi), FAT binary (Fat.efi), -# Logo (Logo.bmp), and etc. -# There may also be modules listed in this section that are not required in the FDF file, -# When a module listed here is excluded from FDF file, then UEFI-compliant binary will be -# generated for it, but the binary will not be put into any firmware volume. -# -################################################################################################### -[Components] - ## - # SEC Phase modules - ## - Nt32Pkg/Sec/SecMain.inf - - ## - # PEI Phase modules - ## - MdeModulePkg/Core/Pei/PeiMain.inf - MdeModulePkg/Universal/PCD/Pei/Pcd.inf { - - PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf - } - MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf - MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf - Nt32Pkg/WinNtOemHookStatusCodeHandlerPei/WinNtOemHookStatusCodeHandlerPei.inf - Nt32Pkg/BootModePei/BootModePei.inf - Nt32Pkg/StallPei/StallPei.inf - Nt32Pkg/WinNtFlashMapPei/WinNtFlashMapPei.inf - - MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.inf - MdeModulePkg/Universal/Variable/Pei/VariablePei.inf - - Nt32Pkg/WinNtAutoScanPei/WinNtAutoScanPei.inf - Nt32Pkg/WinNtFirmwareVolumePei/WinNtFirmwareVolumePei.inf - Nt32Pkg/WinNtThunkPPIToProtocolPei/WinNtThunkPPIToProtocolPei.inf - MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf - ## - # DXE Phase modules - ## - MdeModulePkg/Core/Dxe/DxeMain.inf { - - NULL|MdeModulePkg/Library/DxeCrc32GuidedSectionExtractLib/DxeCrc32GuidedSectionExtractLib.inf - DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf - - *_*_*_CC_FLAGS = - } - - MdeModulePkg/Universal/PCD/Dxe/Pcd.inf { - - PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf - } - Nt32Pkg/MetronomeDxe/MetronomeDxe.inf - Nt32Pkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf - MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf - MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf - Nt32Pkg/FvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf - MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf { - -!if $(SECURE_BOOT_ENABLE) == TRUE - NULL|SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.inf -!endif - } - MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf - MdeModulePkg/Universal/EbcDxe/EbcDxe.inf - MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf - Nt32Pkg/WinNtThunkDxe/WinNtThunkDxe.inf - Nt32Pkg/CpuRuntimeDxe/CpuRuntimeDxe.inf - MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf - Nt32Pkg/MiscSubClassPlatformDxe/MiscSubClassPlatformDxe.inf - Nt32Pkg/TimerDxe/TimerDxe.inf - MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf - MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf - Nt32Pkg/WinNtOemHookStatusCodeHandlerDxe/WinNtOemHookStatusCodeHandlerDxe.inf - MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf { - - NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf - } -!if $(SECURE_BOOT_ENABLE) == TRUE - SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf -!endif - MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf - MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf - MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf - MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf - MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf { - - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - } - MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf { - - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - } - MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf { - - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - } - MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf { - - DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf - } - MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf - MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf - MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf - FatPkg/EnhancedFatDxe/Fat.inf - MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf - MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf - MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf ##This driver follows UEFI specification definition - MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf ##This driver follows UEFI specification definition - IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxe.inf - Nt32Pkg/WinNtBusDriverDxe/WinNtBusDriverDxe.inf { - - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - } - Nt32Pkg/WinNtBlockIoDxe/WinNtBlockIoDxe.inf - Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIoDxe.inf - Nt32Pkg/WinNtGopDxe/WinNtGopDxe.inf - Nt32Pkg/WinNtSimpleFileSystemDxe/WinNtSimpleFileSystemDxe.inf - MdeModulePkg/Application/HelloWorld/HelloWorld.inf - - # - # Network SNP drivers - # To test network drivers, need network Io driver(SnpNt32Io.dll), please refer to NETWORK-IO Subproject. - # -!include NetworkPkg/Network.dsc.inc - Nt32Pkg/SnpNt32Dxe/SnpNt32Dxe.inf - MdeModulePkg/Universal/BdsDxe/BdsDxe.inf - MdeModulePkg/Application/UiApp/UiApp.inf{ - - NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf - NULL|MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf - NULL|MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerUiLib.inf - } - MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf - MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf - MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf - MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf - MdeModulePkg/Universal/PrintDxe/PrintDxe.inf - MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf { - - PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf - } - MdeModulePkg/Application/VariableInfo/VariableInfo.inf - - MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverrideDxe.inf - MdeModulePkg/Universal/LoadFileOnFv2/LoadFileOnFv2.inf - MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf { - - NULL|IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBootManagerLib.inf - } - MdeModulePkg/Logo/LogoDxe.inf - ShellPkg/Application/Shell/Shell.inf { - - gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE - - NULL|ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.inf - NULL|ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.inf - NULL|ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.inf - NULL|ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.inf - NULL|ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1CommandsLib.inf - NULL|ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf - NULL|ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf - NULL|ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.inf - ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf - ShellCommandLib|ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf - HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf - BcfgCommandLib|ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.inf - FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf - } - -################################################################################################### -# -# BuildOptions Section - Define the module specific tool chain flags that should be used as -# the default flags for a module. These flags are appended to any -# standard flags that are defined by the build process. They can be -# applied for any modules or only those modules with the specific -# module style (EDK or EDKII) specified in [Components] section. -# -################################################################################################### -[BuildOptions] - DEBUG_*_*_DLINK_FLAGS = /EXPORT:InitializeDriver=$(IMAGE_ENTRY_POINT) /BASE:0x10000 /ALIGN:4096 /FILEALIGN:4096 /SUBSYSTEM:CONSOLE - NOOPT_*_*_DLINK_FLAGS = /EXPORT:InitializeDriver=$(IMAGE_ENTRY_POINT) /BASE:0x10000 /ALIGN:4096 /FILEALIGN:4096 /SUBSYSTEM:CONSOLE - RELEASE_*_*_DLINK_FLAGS = /ALIGN:4096 /FILEALIGN:4096 - diff --git a/Nt32Pkg/Nt32Pkg.fdf b/Nt32Pkg/Nt32Pkg.fdf deleted file mode 100644 index 7798d17923..0000000000 --- a/Nt32Pkg/Nt32Pkg.fdf +++ /dev/null @@ -1,395 +0,0 @@ -## @file -# This is NT32 FDF file with UEFI HII features enabled -# -# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
-# (C) Copyright 2016 Hewlett Packard Enterprise Development LP
-# -# SPDX-License-Identifier: BSD-2-Clause-Patent -# - -################################################################################ -# -# FD Section -# The [FD] Section is made up of the definition statements and a -# description of what goes into the Flash Device Image. Each FD section -# defines one flash "device" image. A flash device image may be one of -# the following: Removable media bootable image (like a boot floppy -# image,) an Option ROM image (that would be "flashed" into an add-in -# card,) a System "Flash" image (that would be burned into a system's -# flash) or an Update ("Capsule") image that will be used to update and -# existing system flash. -# -################################################################################ -[FD.Nt32] -BaseAddress = 0x0|gEfiNt32PkgTokenSpaceGuid.PcdWinNtFdBaseAddress #The base address of the FLASH Device. -Size = 0x00480000|gEfiNt32PkgTokenSpaceGuid.PcdWinNtFirmwareFdSize #The size in bytes of the FLASH Device -ErasePolarity = 1 -BlockSize = 0x10000 -NumBlocks = 0x48 - -################################################################################ -# -# Following are lists of FD Region layout which correspond to the locations of different -# images within the flash device. -# -# Regions must be defined in ascending order and may not overlap. -# -# A Layout Region start with a eight digit hex offset (leading "0x" required) followed by -# the pipe "|" character, followed by the size of the region, also in hex with the leading -# "0x" characters. Like: -# Offset|Size -# PcdOffsetCName|PcdSizeCName -# RegionType -# -################################################################################ -0x00000000|0x00460000 -gEfiNt32PkgTokenSpaceGuid.PcdWinNtFlashFvRecoveryBase|gEfiNt32PkgTokenSpaceGuid.PcdWinNtFlashFvRecoverySize -FV = FvRecovery - -0x00460000|0x0000c000 -gEfiNt32PkgTokenSpaceGuid.PcdWinNtFlashNvStorageVariableBase|gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize -#NV_VARIABLE_STORE -DATA = { - ## This is the EFI_FIRMWARE_VOLUME_HEADER - # ZeroVector [] - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - # FileSystemGuid: gEfiSystemNvDataFvGuid = - # { 0xFFF12B8D, 0x7696, 0x4C8B, { 0xA9, 0x85, 0x27, 0x47, 0x07, 0x5B, 0x4F, 0x50 }} - 0x8D, 0x2B, 0xF1, 0xFF, 0x96, 0x76, 0x8B, 0x4C, - 0xA9, 0x85, 0x27, 0x47, 0x07, 0x5B, 0x4F, 0x50, - # FvLength: 0x20000 - 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, - #Signature "_FVH" #Attributes - 0x5f, 0x46, 0x56, 0x48, 0xff, 0xfe, 0x04, 0x00, - #HeaderLength #CheckSum #ExtHeaderOffset #Reserved #Revision - 0x48, 0x00, 0x36, 0x09, 0x00, 0x00, 0x00, 0x02, - #Blockmap[0]: 2 Blocks * 0x10000 Bytes / Block - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, - #Blockmap[1]: End - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ## This is the VARIABLE_STORE_HEADER -!if $(SECURE_BOOT_ENABLE) == TRUE - #Signature: gEfiAuthenticatedVariableGuid = - # { 0xaaf32c78, 0x947b, 0x439a, { 0xa1, 0x80, 0x2e, 0x14, 0x4e, 0xc3, 0x77, 0x92 }} - 0x78, 0x2c, 0xf3, 0xaa, 0x7b, 0x94, 0x9a, 0x43, - 0xa1, 0x80, 0x2e, 0x14, 0x4e, 0xc3, 0x77, 0x92, -!else - #Signature: gEfiVariableGuid = - # { 0xddcf3616, 0x3275, 0x4164, { 0x98, 0xb6, 0xfe, 0x85, 0x70, 0x7f, 0xfe, 0x7d }} - 0x16, 0x36, 0xcf, 0xdd, 0x75, 0x32, 0x64, 0x41, - 0x98, 0xb6, 0xfe, 0x85, 0x70, 0x7f, 0xfe, 0x7d, -!endif - #Size: 0xc000 (gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize) - 0x48 (size of EFI_FIRMWARE_VOLUME_HEADER) = 0xBFB8 - # This can speed up the Variable Dispatch a bit. - 0xB8, 0xBF, 0x00, 0x00, - #FORMATTED: 0x5A #HEALTHY: 0xFE #Reserved: UINT16 #Reserved1: UINT32 - 0x5A, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -} - -0x0046c000|0x00002000 -#NV_EVENT_LOG -gEfiNt32PkgTokenSpaceGuid.PcdWinNtFlashNvStorageEventLogBase|gEfiNt32PkgTokenSpaceGuid.PcdWinNtFlashNvStorageEventLogSize - -0x0046e000|0x00002000 -gEfiNt32PkgTokenSpaceGuid.PcdWinNtFlashNvStorageFtwWorkingBase|gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize -#NV_FTW_WORKING -DATA = { - # EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER->Signature = gEdkiiWorkingBlockSignatureGuid = - # { 0x9e58292b, 0x7c68, 0x497d, { 0xa0, 0xce, 0x65, 0x0, 0xfd, 0x9f, 0x1b, 0x95 }} - 0x2b, 0x29, 0x58, 0x9e, 0x68, 0x7c, 0x7d, 0x49, - 0xa0, 0xce, 0x65, 0x0, 0xfd, 0x9f, 0x1b, 0x95, - # Crc:UINT32 #WorkingBlockValid:1, WorkingBlockInvalid:1, Reserved - 0xE2, 0x33, 0xF2, 0x03, 0xFE, 0xFF, 0xFF, 0xFF, - # WriteQueueSize: UINT64 - 0xE0, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -} - -0x00470000|0x00010000 -#NV_FTW_SPARE -gEfiNt32PkgTokenSpaceGuid.PcdWinNtFlashNvStorageFtwSpareBase|gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize - -################################################################################ -# -# FV Section -# -# [FV] section is used to define what components or modules are placed within a flash -# device file. This section also defines order the components and modules are positioned -# within the image. The [FV] section consists of define statements, set statements and -# module statements. -# -################################################################################ -[FV.FvRecovery] -FvAlignment = 16 #FV alignment and FV attributes setting. -ERASE_POLARITY = 1 -MEMORY_MAPPED = TRUE -STICKY_WRITE = TRUE -LOCK_CAP = TRUE -LOCK_STATUS = TRUE -WRITE_DISABLED_CAP = TRUE -WRITE_ENABLED_CAP = TRUE -WRITE_STATUS = TRUE -WRITE_LOCK_CAP = TRUE -WRITE_LOCK_STATUS = TRUE -READ_DISABLED_CAP = TRUE -READ_ENABLED_CAP = TRUE -READ_STATUS = TRUE -READ_LOCK_CAP = TRUE -READ_LOCK_STATUS = TRUE -FvNameGuid = 6D99E806-3D38-42c2-A095-5F4300BFD7DC - -################################################################################ -# -# The INF statements point to EDK component and EDK II module INF files, which will be placed into this FV image. -# Parsing tools will scan the INF file to determine the type of component or module. -# The component or module type is used to reference the standard rules -# defined elsewhere in the FDF file. -# -# The format for INF statements is: -# INF $(PathAndInfFileName) -# -################################################################################ - ## - # PEI Phase modules - ## - ## - # PEI Apriori file example, more PEIM module added later. - ## -APRIORI PEI { - INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf - INF MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf - INF MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf - INF Nt32Pkg/WinNtOemHookStatusCodeHandlerPei/WinNtOemHookStatusCodeHandlerPei.inf - } -APRIORI DXE { - INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf - INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf - INF Nt32Pkg/MetronomeDxe/MetronomeDxe.inf - INF MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf - INF MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf - INF Nt32Pkg/WinNtOemHookStatusCodeHandlerDxe/WinNtOemHookStatusCodeHandlerDxe.inf - } - -INF MdeModulePkg/Core/Pei/PeiMain.inf -INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf -INF MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf -INF MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf -INF Nt32Pkg/WinNtOemHookStatusCodeHandlerPei/WinNtOemHookStatusCodeHandlerPei.inf -INF Nt32Pkg/BootModePei/BootModePei.inf -INF Nt32Pkg/StallPei/StallPei.inf -INF Nt32Pkg/WinNtFlashMapPei/WinNtFlashMapPei.inf -INF Nt32Pkg/WinNtAutoScanPei/WinNtAutoScanPei.inf -INF Nt32Pkg/WinNtFirmwareVolumePei/WinNtFirmwareVolumePei.inf - -INF MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.inf -INF MdeModulePkg/Universal/Variable/Pei/VariablePei.inf - -INF Nt32Pkg/WinNtThunkPPIToProtocolPei/WinNtThunkPPIToProtocolPei.inf -INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf - - ## - # DXE Phase modules - ## -INF MdeModulePkg/Core/Dxe/DxeMain.inf -INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf -INF Nt32Pkg/MetronomeDxe/MetronomeDxe.inf -INF Nt32Pkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf -INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf -INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf -INF Nt32Pkg/FvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf -INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf -INF MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf -INF MdeModulePkg/Universal/EbcDxe/EbcDxe.inf -INF MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf -INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf -INF Nt32Pkg/WinNtThunkDxe/WinNtThunkDxe.inf -INF Nt32Pkg/CpuRuntimeDxe/CpuRuntimeDxe.inf -INF MdeModulePkg/Universal/BdsDxe/BdsDxe.inf -INF MdeModulePkg/Application/UiApp/UiApp.inf -INF MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf -INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf -INF Nt32Pkg/MiscSubClassPlatformDxe/MiscSubClassPlatformDxe.inf -INF Nt32Pkg/TimerDxe/TimerDxe.inf -INF MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf -INF MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf -INF Nt32Pkg/WinNtOemHookStatusCodeHandlerDxe/WinNtOemHookStatusCodeHandlerDxe.inf -INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf -!if $(SECURE_BOOT_ENABLE) == TRUE -INF SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf -!endif -INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf -INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf -INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf -INF MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf -INF MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf -INF MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf -INF MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf -INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf -INF MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf -INF MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf -INF MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf -INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf -INF MdeModulePkg/Universal/PrintDxe/PrintDxe.inf -INF RuleOverride = TIANOCOMPRESSED MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf -INF MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf -INF MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf -INF MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf -INF IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxe.inf -INF Nt32Pkg/WinNtBusDriverDxe/WinNtBusDriverDxe.inf -INF Nt32Pkg/WinNtBlockIoDxe/WinNtBlockIoDxe.inf -INF Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIoDxe.inf -INF Nt32Pkg/WinNtGopDxe/WinNtGopDxe.inf -INF Nt32Pkg/WinNtSimpleFileSystemDxe/WinNtSimpleFileSystemDxe.inf -INF MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverrideDxe.inf -INF MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf - -INF Nt32Pkg/SnpNt32Dxe/SnpNt32Dxe.inf -!include NetworkPkg/Network.fdf.inc - -INF MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf -################################################################################ -# -# FILE statements are provided so that a platform integrator can include -# complete EFI FFS files, as well as a method for constructing FFS files -# using curly "{}" brace scoping. The following three FILEs are -# for binary shell, binary fat and logo module. -# -################################################################################ -INF ShellPkg/Application/Shell/Shell.inf - -INF FatPkg/EnhancedFatDxe/Fat.inf -INF MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf - -INF MdeModulePkg/Logo/LogoDxe.inf -INF MdeModulePkg/Universal/LoadFileOnFv2/LoadFileOnFv2.inf -################################################################################ -# -# Rules are use with the [FV] section's module INF type to define -# how an FFS file is created for a given INF file. The following Rule are the default -# rules for the different module type. User can add the customized rules to define the -# content of the FFS file. -# -################################################################################ - - -############################################################################ -# Example of a DXE_DRIVER FFS file with a Checksum encapsulation section # -############################################################################ -# -#[Rule.Common.DXE_DRIVER] -# FILE DRIVER = $(NAMED_GUID) { -# DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex -# COMPRESS PI_STD { -# GUIDED { -# PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi -# UI STRING="$(MODULE_NAME)" Optional -# VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) -# } -# } -# } -# -############################################################################ - -[Rule.Common.PEI_CORE] - FILE PEI_CORE = $(NAMED_GUID) { - PE32 PE32 Align=4K $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING ="$(MODULE_NAME)" Optional - VERSION STRING ="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } - -[Rule.Common.PEIM] - FILE PEIM = $(NAMED_GUID) { - PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex - PE32 PE32 Align=4K $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING="$(MODULE_NAME)" Optional - VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } - -[Rule.Common.DXE_CORE] - FILE DXE_CORE = $(NAMED_GUID) { - COMPRESS PI_STD { - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING="$(MODULE_NAME)" Optional - VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } - } - -[Rule.Common.UEFI_DRIVER] - FILE DRIVER = $(NAMED_GUID) { - DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex - COMPRESS PI_STD { - GUIDED { - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING="$(MODULE_NAME)" Optional - VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } - } - } - -[Rule.Common.UEFI_DRIVER.TIANOCOMPRESSED] - FILE DRIVER = $(NAMED_GUID) { - DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex - GUIDED A31280AD-481E-41B6-95E8-127F4C984779 PROCESSING_REQUIRED = TRUE { - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING="$(MODULE_NAME)" Optional - VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } - } - -[Rule.Common.DXE_DRIVER] - FILE DRIVER = $(NAMED_GUID) { - DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex - COMPRESS PI_STD { - GUIDED { - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING="$(MODULE_NAME)" Optional - VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } - } - } - -[Rule.Common.DXE_RUNTIME_DRIVER] - FILE DRIVER = $(NAMED_GUID) { - DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex - COMPRESS PI_STD { - GUIDED { - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING="$(MODULE_NAME)" Optional - VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } - } - } - -[Rule.Common.UEFI_APPLICATION] - FILE APPLICATION = $(NAMED_GUID) { - COMPRESS PI_STD { - GUIDED { - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING="$(MODULE_NAME)" Optional - VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } - } - } - -[Rule.Common.UEFI_APPLICATION.BINARY] - FILE APPLICATION = $(NAMED_GUID) { - COMPRESS PI_STD { - GUIDED { - PE32 PE32 |.efi - UI STRING="$(MODULE_NAME)" Optional - VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } - } - } - -[Rule.Common.UEFI_DRIVER.BINARY] - FILE DRIVER = $(NAMED_GUID) { - DXE_DEPEX DXE_DEPEX Optional |.depex - COMPRESS PI_STD { - GUIDED { - PE32 PE32 |.efi - UI STRING="$(MODULE_NAME)" Optional - VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } - } - } diff --git a/Nt32Pkg/RealTimeClockRuntimeDxe/RealTimeClock.c b/Nt32Pkg/RealTimeClockRuntimeDxe/RealTimeClock.c deleted file mode 100644 index 8a623019da..0000000000 --- a/Nt32Pkg/RealTimeClockRuntimeDxe/RealTimeClock.c +++ /dev/null @@ -1,391 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - RealTimeClock.c - -Abstract: - - NT Emulation Architectural Protocol Driver as defined in Tiano - -**/ - -#include -#include -#include -#include -#include -#include -#include - - -BOOLEAN -DayValid ( - IN EFI_TIME *Time - ); - -BOOLEAN -IsLeapYear ( - IN EFI_TIME *Time - ); - -EFI_STATUS -RtcTimeFieldsValid ( - IN EFI_TIME *Time - ); - -EFI_STATUS -EFIAPI -InitializeRealTimeClock ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ); - -EFI_STATUS -EFIAPI -WinNtGetTime ( - OUT EFI_TIME *Time, - OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL - ) -/*++ - -Routine Description: - Service routine for RealTimeClockInstance->GetTime - -Arguments: - - Time - A pointer to storage that will receive a snapshot of the current time. - - Capabilities - A pointer to storage that will receive the capabilities of the real time clock - in the platform. This includes the real time clock's resolution and accuracy. - All reported device capabilities are rounded up. This is an OPTIONAL argument. - -Returns: - - EFI_SUCEESS - The underlying GetSystemTime call occurred and returned - Note that in the NT32 emulation, the GetSystemTime call has no return value - thus you will always receive a EFI_SUCCESS on this. - ---*/ -// TODO: EFI_INVALID_PARAMETER - add return value to function comment -{ - SYSTEMTIME SystemTime; - TIME_ZONE_INFORMATION TimeZone; - - // - // Check parameter for null pointer - // - if (Time == NULL) { - return EFI_INVALID_PARAMETER; - - } - - gWinNt->GetLocalTime (&SystemTime); - gWinNt->GetTimeZoneInformation (&TimeZone); - - Time->Year = (UINT16) SystemTime.wYear; - Time->Month = (UINT8) SystemTime.wMonth; - Time->Day = (UINT8) SystemTime.wDay; - Time->Hour = (UINT8) SystemTime.wHour; - Time->Minute = (UINT8) SystemTime.wMinute; - Time->Second = (UINT8) SystemTime.wSecond; - Time->Nanosecond = (UINT32) (SystemTime.wMilliseconds * 1000000); - Time->TimeZone = (INT16) TimeZone.Bias; - - if (Capabilities != NULL) { - Capabilities->Resolution = 1; - Capabilities->Accuracy = 50000000; - Capabilities->SetsToZero = FALSE; - } - - Time->Daylight = 0; - if (TimeZone.StandardDate.wMonth) { - Time->Daylight = (UINT8) TimeZone.StandardDate.wMonth; - } - - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -WinNtSetTime ( - IN EFI_TIME *Time - ) -/*++ - -Routine Description: - Service routine for RealTimeClockInstance->SetTime - -Arguments: - - Time - A pointer to storage containing the time and date information to - program into the real time clock. - -Returns: - - EFI_SUCEESS - The operation completed successfully. - - EFI_INVALID_PARAMETER - One of the fields in Time is out of range. - - EFI_DEVICE_ERROR - The operation could not be complete due to a device error. - ---*/ -// TODO: EFI_SUCCESS - add return value to function comment -{ - TIME_ZONE_INFORMATION TimeZone; - EFI_STATUS Status; - SYSTEMTIME SystemTime; - BOOL Flag; - - if (Time == NULL) { - return EFI_INVALID_PARAMETER; - } - // - // Make sure that the time fields are valid - // - Status = RtcTimeFieldsValid (Time); - if (EFI_ERROR (Status)) { - return Status; - } - // - // Set Daylight savings time information and Time Zone - // - gWinNt->GetTimeZoneInformation (&TimeZone); - TimeZone.StandardDate.wMonth = Time->Daylight; - TimeZone.Bias = Time->TimeZone; - Flag = gWinNt->SetTimeZoneInformation (&TimeZone); - if (!Flag) { - return EFI_DEVICE_ERROR; - } - - SystemTime.wYear = Time->Year; - SystemTime.wMonth = Time->Month; - SystemTime.wDay = Time->Day; - SystemTime.wHour = Time->Hour; - SystemTime.wMinute = Time->Minute; - SystemTime.wSecond = Time->Second; - SystemTime.wMilliseconds = (INT16) (Time->Nanosecond / 1000000); - - Flag = gWinNt->SetLocalTime (&SystemTime); - - if (!Flag) { - return EFI_DEVICE_ERROR; - } else { - return EFI_SUCCESS; - } -} - -EFI_STATUS -EFIAPI -WinNtGetWakeupTime ( - OUT BOOLEAN *Enabled, - OUT BOOLEAN *Pending, - OUT EFI_TIME *Time - ) -/*++ - -Routine Description: - Service routine for RealTimeClockInstance->GetWakeupTime - -Arguments: - This - Indicates the protocol instance structure. - - Enabled - Indicates if the alarm is currently enabled or disabled. - - Pending - Indicates if the alarm signal is pending and requires - acknowledgement. - - Time - The current alarm setting. - -Returns: - - EFI_SUCEESS - The operation completed successfully. - - EFI_DEVICE_ERROR - The operation could not be complete due to a device error. - - EFI_UNSUPPORTED - The operation is not supported on this platform. - ---*/ -{ - return EFI_UNSUPPORTED; -} - -EFI_STATUS -EFIAPI -WinNtSetWakeupTime ( - IN BOOLEAN Enable, - OUT EFI_TIME *Time - ) -/*++ - -Routine Description: - Service routine for RealTimeClockInstance->SetWakeupTime - -Arguments: - - Enabled - Enable or disable the wakeup alarm. - - Time - If enable is TRUE, the time to set the wakup alarm for. - If enable is FALSE, then this parameter is optional, and - may be NULL. - -Returns: - - EFI_SUCEESS - The operation completed successfully. - - EFI_DEVICE_ERROR - The operation could not be complete due to a device error. - - EFI_INVALID_PARAMETER - A field in Time is out of range. - - EFI_UNSUPPORTED - The operation is not supported on this platform. - ---*/ -{ - return EFI_UNSUPPORTED; -} - -EFI_STATUS -EFIAPI -InitializeRealTimeClock ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -/*++ - -Routine Description: - Install Real Time Clock Protocol - -Arguments: - (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT) - -Returns: - - EFI_SUCEESS - Real Time Clock Services are installed into the Runtime Services Table - ---*/ -// TODO: ImageHandle - add argument and description to function comment -// TODO: SystemTable - add argument and description to function comment -{ - EFI_STATUS Status; - EFI_HANDLE Handle; - - - SystemTable->RuntimeServices->GetTime = WinNtGetTime; - SystemTable->RuntimeServices->SetTime = WinNtSetTime; - SystemTable->RuntimeServices->GetWakeupTime = WinNtGetWakeupTime; - SystemTable->RuntimeServices->SetWakeupTime = WinNtSetWakeupTime; - - Handle = NULL; - Status = gBS->InstallMultipleProtocolInterfaces ( - &Handle, - &gEfiRealTimeClockArchProtocolGuid, - NULL, - NULL - ); - return Status; -} - -EFI_STATUS -RtcTimeFieldsValid ( - IN EFI_TIME *Time - ) -/*++ - -Routine Description: - - Arguments: - - Returns: ---*/ -// TODO: Time - add argument and description to function comment -// TODO: EFI_INVALID_PARAMETER - add return value to function comment -// TODO: EFI_SUCCESS - add return value to function comment -{ - if (Time->Year < 1998 || - Time->Year > 2099 || - Time->Month < 1 || - Time->Month > 12 || - (!DayValid (Time)) || - Time->Hour > 23 || - Time->Minute > 59 || - Time->Second > 59 || - Time->Nanosecond > 999999999 || - (!(Time->TimeZone == EFI_UNSPECIFIED_TIMEZONE || (Time->TimeZone >= -1440 && Time->TimeZone <= 1440))) || - (Time->Daylight & (~(EFI_TIME_ADJUST_DAYLIGHT | EFI_TIME_IN_DAYLIGHT))) - ) { - return EFI_INVALID_PARAMETER; - } - - return EFI_SUCCESS; -} - -BOOLEAN -DayValid ( - IN EFI_TIME *Time - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - Time - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -{ - - INTN DayOfMonth[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; - - if (Time->Day < 1 || - Time->Day > DayOfMonth[Time->Month - 1] || - (Time->Month == 2 && (!IsLeapYear (Time) && Time->Day > 28)) - ) { - return FALSE; - } - - return TRUE; -} - -BOOLEAN -IsLeapYear ( - IN EFI_TIME *Time - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - Time - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -{ - if (Time->Year % 4 == 0) { - if (Time->Year % 100 == 0) { - if (Time->Year % 400 == 0) { - return TRUE; - } else { - return FALSE; - } - } else { - return TRUE; - } - } else { - return FALSE; - } -} diff --git a/Nt32Pkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf b/Nt32Pkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf deleted file mode 100644 index 2cd9bf85fa..0000000000 --- a/Nt32Pkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf +++ /dev/null @@ -1,45 +0,0 @@ -## @file -# NT Emulation Real time clock Architectural Protocol Driver as defined in TIANO -# -# This real time clock module simulates virtual device by time WinAPI. -# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
-# -# SPDX-License-Identifier: BSD-2-Clause-Patent -# -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = RealTimeClock - FILE_GUID = 27F05AF5-1644-4EF4-8944-48C4F75675A0 - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - - ENTRY_POINT = InitializeRealTimeClock - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 -# - -[Sources] - RealTimeClock.c - -[Packages] - MdePkg/MdePkg.dec - Nt32Pkg/Nt32Pkg.dec - -[LibraryClasses] - UefiBootServicesTableLib - WinNtLib - UefiDriverEntryPoint - DebugLib - -[Protocols] - gEfiRealTimeClockArchProtocolGuid # PROTOCOL ALWAYS_PRODUCED - -[depex] - TRUE - diff --git a/Nt32Pkg/Sec/FwVol.c b/Nt32Pkg/Sec/FwVol.c deleted file mode 100644 index c7c647e0e5..0000000000 --- a/Nt32Pkg/Sec/FwVol.c +++ /dev/null @@ -1,308 +0,0 @@ -/**@file - -Copyright (c) 2006, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - FwVol.c - -Abstract: - A simple FV stack so the SEC can extract the SEC Core from an - FV. - -**/ - -#include "SecMain.h" - -#define GET_OCCUPIED_SIZE(ActualSize, Alignment) \ - (ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1)) - -EFI_FFS_FILE_STATE -GetFileState ( - IN UINT8 ErasePolarity, - IN EFI_FFS_FILE_HEADER *FfsHeader - ) -/*++ - -Routine Description: - Returns the highest bit set of the State field - -Arguments: - ErasePolarity - Erase Polarity as defined by EFI_FVB_ERASE_POLARITY - in the Attributes field. - FfsHeader - Pointer to FFS File Header. - -Returns: - Returns the highest bit in the State field - ---*/ -{ - EFI_FFS_FILE_STATE FileState; - EFI_FFS_FILE_STATE HighestBit; - - FileState = FfsHeader->State; - - if (ErasePolarity != 0) { - FileState = (EFI_FFS_FILE_STATE)~FileState; - } - - HighestBit = 0x80; - while (HighestBit != 0 && (HighestBit & FileState) == 0) { - HighestBit >>= 1; - } - - return HighestBit; -} - -UINT8 -CalculateHeaderChecksum ( - IN EFI_FFS_FILE_HEADER *FileHeader - ) -/*++ - -Routine Description: - Calculates the checksum of the header of a file. - -Arguments: - FileHeader - Pointer to FFS File Header. - -Returns: - Checksum of the header. - ---*/ -{ - UINT8 *ptr; - UINTN Index; - UINT8 Sum; - - Sum = 0; - ptr = (UINT8 *) FileHeader; - - for (Index = 0; Index < sizeof (EFI_FFS_FILE_HEADER) - 3; Index += 4) { - Sum = (UINT8) (Sum + ptr[Index]); - Sum = (UINT8) (Sum + ptr[Index + 1]); - Sum = (UINT8) (Sum + ptr[Index + 2]); - Sum = (UINT8) (Sum + ptr[Index + 3]); - } - - for (; Index < sizeof (EFI_FFS_FILE_HEADER); Index++) { - Sum = (UINT8) (Sum + ptr[Index]); - } - // - // State field (since this indicates the different state of file). - // - Sum = (UINT8) (Sum - FileHeader->State); - // - // Checksum field of the file is not part of the header checksum. - // - Sum = (UINT8) (Sum - FileHeader->IntegrityCheck.Checksum.File); - - return Sum; -} - -EFI_STATUS -SecFfsFindNextFile ( - IN EFI_FV_FILETYPE SearchType, - IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader, - IN OUT EFI_FFS_FILE_HEADER **FileHeader - ) -/*++ - -Routine Description: - Given the input file pointer, search for the next matching file in the - FFS volume as defined by SearchType. The search starts from FileHeader inside - the Firmware Volume defined by FwVolHeader. - -Arguments: - SearchType - Filter to find only files of this type. - Type EFI_FV_FILETYPE_ALL causes no filtering to be done. - FwVolHeader - Pointer to the FV header of the volume to search. - This parameter must point to a valid FFS volume. - FileHeader - Pointer to the current file from which to begin searching. - This pointer will be updated upon return to reflect the file - found. - -Returns: - EFI_NOT_FOUND - No files matching the search criteria were found - EFI_SUCCESS - ---*/ -{ - EFI_FFS_FILE_HEADER *FfsFileHeader; - UINT32 FileLength; - UINT32 FileOccupiedSize; - UINT32 FileOffset; - UINT64 FvLength; - UINT8 ErasePolarity; - UINT8 FileState; - - FvLength = FwVolHeader->FvLength; - if (FwVolHeader->Attributes & EFI_FVB2_ERASE_POLARITY) { - ErasePolarity = 1; - } else { - ErasePolarity = 0; - } - // - // If FileHeader is not specified (NULL) start with the first file in the - // firmware volume. Otherwise, start from the FileHeader. - // - if (*FileHeader == NULL) { - FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FwVolHeader + FwVolHeader->HeaderLength); - } else { - // - // Length is 24 bits wide so mask upper 8 bits - // FileLength is adjusted to FileOccupiedSize as it is 8 byte aligned. - // - FileLength = *(UINT32 *) (*FileHeader)->Size & 0x00FFFFFF; - FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8); - FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) *FileHeader + FileOccupiedSize); - } - - FileOffset = (UINT32) ((UINT8 *) FfsFileHeader - (UINT8 *) FwVolHeader); - - while (FileOffset < (FvLength - sizeof (EFI_FFS_FILE_HEADER))) { - // - // Get FileState which is the highest bit of the State - // - FileState = GetFileState (ErasePolarity, FfsFileHeader); - - switch (FileState) { - - case EFI_FILE_HEADER_INVALID: - FileOffset += sizeof (EFI_FFS_FILE_HEADER); - FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + sizeof (EFI_FFS_FILE_HEADER)); - break; - - case EFI_FILE_DATA_VALID: - case EFI_FILE_MARKED_FOR_UPDATE: - if (CalculateHeaderChecksum (FfsFileHeader) == 0) { - FileLength = *(UINT32 *) (FfsFileHeader->Size) & 0x00FFFFFF; - FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8); - - if ((SearchType == FfsFileHeader->Type) || (SearchType == EFI_FV_FILETYPE_ALL)) { - - *FileHeader = FfsFileHeader; - - return EFI_SUCCESS; - } - - FileOffset += FileOccupiedSize; - FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + FileOccupiedSize); - } else { - return EFI_NOT_FOUND; - } - break; - - case EFI_FILE_DELETED: - FileLength = *(UINT32 *) (FfsFileHeader->Size) & 0x00FFFFFF; - FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8); - FileOffset += FileOccupiedSize; - FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + FileOccupiedSize); - break; - - default: - return EFI_NOT_FOUND; - - } - } - - return EFI_NOT_FOUND; -} - -EFI_STATUS -SecFfsFindSectionData ( - IN EFI_SECTION_TYPE SectionType, - IN EFI_FFS_FILE_HEADER *FfsFileHeader, - IN OUT VOID **SectionData - ) -/*++ - -Routine Description: - Given the input file pointer, search for the next matching section in the - FFS volume. - -Arguments: - SearchType - Filter to find only sections of this type. - FfsFileHeader - Pointer to the current file to search. - SectionData - Pointer to the Section matching SectionType in FfsFileHeader. - NULL if section not found - -Returns: - EFI_NOT_FOUND - No files matching the search criteria were found - EFI_SUCCESS - ---*/ -{ - UINT32 FileSize; - EFI_COMMON_SECTION_HEADER *Section; - UINT32 SectionLength; - UINT32 ParsedLength; - - // - // Size is 24 bits wide so mask upper 8 bits. - // Does not include FfsFileHeader header size - // FileSize is adjusted to FileOccupiedSize as it is 8 byte aligned. - // - Section = (EFI_COMMON_SECTION_HEADER *) (FfsFileHeader + 1); - FileSize = *(UINT32 *) (FfsFileHeader->Size) & 0x00FFFFFF; - FileSize -= sizeof (EFI_FFS_FILE_HEADER); - - *SectionData = NULL; - ParsedLength = 0; - while (ParsedLength < FileSize) { - if (Section->Type == SectionType) { - *SectionData = (VOID *) (Section + 1); - return EFI_SUCCESS; - } - // - // Size is 24 bits wide so mask upper 8 bits. - // SectionLength is adjusted it is 4 byte aligned. - // Go to the next section - // - SectionLength = *(UINT32 *) Section->Size & 0x00FFFFFF; - SectionLength = GET_OCCUPIED_SIZE (SectionLength, 4); - - ParsedLength += SectionLength; - Section = (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) Section + SectionLength); - } - - return EFI_NOT_FOUND; -} - -EFI_STATUS -SecFfsFindPeiCore ( - IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader, - OUT VOID **Pe32Data - ) -/*++ - -Routine Description: - Given the pointer to the Firmware Volume Header find the SEC - core and return it's PE32 image. - -Arguments: - FwVolHeader - Pointer to memory mapped FV - Pe32Data - Pointer to SEC PE32 iamge. - -Returns: - EFI_SUCCESS - Pe32Data is valid - other - Failure - ---*/ -{ - EFI_STATUS Status; - EFI_FFS_FILE_HEADER *FileHeader; - EFI_FV_FILETYPE SearchType; - - SearchType = EFI_FV_FILETYPE_PEI_CORE; - FileHeader = NULL; - do { - Status = SecFfsFindNextFile (SearchType, FwVolHeader, &FileHeader); - if (!EFI_ERROR (Status)) { - Status = SecFfsFindSectionData (EFI_SECTION_PE32, FileHeader, Pe32Data); - return Status; - } - } while (!EFI_ERROR (Status)); - - return Status; -} diff --git a/Nt32Pkg/Sec/SecMain.c b/Nt32Pkg/Sec/SecMain.c deleted file mode 100644 index c3bfe47024..0000000000 --- a/Nt32Pkg/Sec/SecMain.c +++ /dev/null @@ -1,1130 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
-(C) Copyright 2016 Hewlett Packard Enterprise Development LP
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - SecMain.c - -Abstract: - WinNt emulator of SEC phase. It's really a Win32 application, but this is - Ok since all the other modules for NT32 are NOT Win32 applications. - - This program gets NT32 PCD setting and figures out what the memory layout - will be, how may FD's will be loaded and also what the boot mode is. - - The SEC registers a set of services with the SEC core. gPrivateDispatchTable - is a list of PPI's produced by the SEC that are available for usage in PEI. - - This code produces 128 K of temporary memory for the PEI stack by directly - allocate memory space with ReadWrite and Execute attribute. - -**/ - -#include "SecMain.h" - -#ifndef SE_TIME_ZONE_NAME -#define SE_TIME_ZONE_NAME TEXT("SeTimeZonePrivilege") -#endif - -NT_PEI_LOAD_FILE_PPI mSecNtLoadFilePpi = { SecWinNtPeiLoadFile }; - -PEI_NT_AUTOSCAN_PPI mSecNtAutoScanPpi = { SecWinNtPeiAutoScan }; - -PEI_NT_THUNK_PPI mSecWinNtThunkPpi = { SecWinNtWinNtThunkAddress }; - -EFI_PEI_PROGRESS_CODE_PPI mSecStatusCodePpi = { SecPeiReportStatusCode }; - -NT_FWH_PPI mSecFwhInformationPpi = { SecWinNtFdAddress }; - -EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI mSecTemporaryRamSupportPpi = {SecTemporaryRamSupport}; - -EFI_PEI_PPI_DESCRIPTOR gPrivateDispatchTable[] = { - { - EFI_PEI_PPI_DESCRIPTOR_PPI, - &gNtPeiLoadFilePpiGuid, - &mSecNtLoadFilePpi - }, - { - EFI_PEI_PPI_DESCRIPTOR_PPI, - &gPeiNtAutoScanPpiGuid, - &mSecNtAutoScanPpi - }, - { - EFI_PEI_PPI_DESCRIPTOR_PPI, - &gPeiNtThunkPpiGuid, - &mSecWinNtThunkPpi - }, - { - EFI_PEI_PPI_DESCRIPTOR_PPI, - &gEfiPeiStatusCodePpiGuid, - &mSecStatusCodePpi - }, - { - EFI_PEI_PPI_DESCRIPTOR_PPI, - &gEfiTemporaryRamSupportPpiGuid, - &mSecTemporaryRamSupportPpi - }, - { - EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST, - &gNtFwhPpiGuid, - &mSecFwhInformationPpi - } -}; - - -// -// Default information about where the FD is located. -// This array gets filled in with information from PcdWinNtFirmwareVolume -// The number of array elements is allocated base on parsing -// PcdWinNtFirmwareVolume and the memory is never freed. -// -UINTN gFdInfoCount = 0; -NT_FD_INFO *gFdInfo; - -// -// Array that supports seperate memory rantes. -// The memory ranges are set by PcdWinNtMemorySizeForSecMain. -// The number of array elements is allocated base on parsing -// PcdWinNtMemorySizeForSecMain value and the memory is never freed. -// -UINTN gSystemMemoryCount = 0; -NT_SYSTEM_MEMORY *gSystemMemory; - -VOID -EFIAPI -SecSwitchStack ( - UINT32 TemporaryMemoryBase, - UINT32 PermenentMemoryBase - ); -EFI_STATUS -SecNt32PeCoffRelocateImage ( - IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext - ); - -VOID -EFIAPI -PeiSwitchStacks ( - IN SWITCH_STACK_ENTRY_POINT EntryPoint, - IN VOID *Context1, OPTIONAL - IN VOID *Context2, OPTIONAL - IN VOID *Context3, OPTIONAL - IN VOID *NewStack - ); - -VOID -SecPrint ( - CHAR8 *Format, - ... - ) -{ - va_list Marker; - UINTN CharCount; - CHAR8 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE]; - - va_start (Marker, Format); - - _vsnprintf (Buffer, sizeof (Buffer), Format, Marker); - - va_end (Marker); - - CharCount = strlen (Buffer); - WriteFile ( - GetStdHandle (STD_OUTPUT_HANDLE), - Buffer, - (DWORD)CharCount, - (LPDWORD)&CharCount, - NULL - ); -} - -INTN -EFIAPI -main ( - IN INTN Argc, - IN CHAR8 **Argv, - IN CHAR8 **Envp - ) -/*++ - -Routine Description: - Main entry point to SEC for WinNt. This is a Windows program - -Arguments: - Argc - Number of command line arguments - Argv - Array of command line argument strings - Envp - Array of environment variable strings - -Returns: - 0 - Normal exit - 1 - Abnormal exit - ---*/ -{ - EFI_STATUS Status; - HANDLE Token; - TOKEN_PRIVILEGES TokenPrivileges; - EFI_PHYSICAL_ADDRESS InitialStackMemory; - UINT64 InitialStackMemorySize; - UINTN Index; - UINTN Index1; - UINTN Index2; - CHAR16 *FileName; - CHAR16 *FileNamePtr; - BOOLEAN Done; - VOID *PeiCoreFile; - CHAR16 *MemorySizeStr; - CHAR16 *FirmwareVolumesStr; - UINTN *StackPointer; - UINT32 ProcessAffinityMask; - UINT32 SystemAffinityMask; - INT32 LowBit; - - - // - // Enable the privilege so that RTC driver can successfully run SetTime() - // - OpenProcessToken (GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &Token); - if (LookupPrivilegeValue(NULL, SE_TIME_ZONE_NAME, &TokenPrivileges.Privileges[0].Luid)) { - TokenPrivileges.PrivilegeCount = 1; - TokenPrivileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; - AdjustTokenPrivileges(Token, FALSE, &TokenPrivileges, 0, (PTOKEN_PRIVILEGES) NULL, 0); - } - - MemorySizeStr = (CHAR16 *) PcdGetPtr (PcdWinNtMemorySizeForSecMain); - FirmwareVolumesStr = (CHAR16 *) PcdGetPtr (PcdWinNtFirmwareVolume); - - SecPrint ("\nEDK II SEC Main NT Emulation Environment from www.TianoCore.org\n"); - - // - // Determine the first thread available to this process. - // - if (GetProcessAffinityMask (GetCurrentProcess (), &ProcessAffinityMask, &SystemAffinityMask)) { - LowBit = (INT32)LowBitSet32 (ProcessAffinityMask); - if (LowBit != -1) { - // - // Force the system to bind the process to a single thread to work - // around odd semaphore type crashes. - // - SetProcessAffinityMask (GetCurrentProcess (), (INTN)(BIT0 << LowBit)); - } - } - - // - // Make some Windows calls to Set the process to the highest priority in the - // idle class. We need this to have good performance. - // - SetPriorityClass (GetCurrentProcess (), IDLE_PRIORITY_CLASS); - SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_HIGHEST); - - // - // Allocate space for gSystemMemory Array - // - gSystemMemoryCount = CountSeparatorsInString (MemorySizeStr, '!') + 1; - gSystemMemory = calloc (gSystemMemoryCount, sizeof (NT_SYSTEM_MEMORY)); - if (gSystemMemory == NULL) { - SecPrint ("ERROR : Can not allocate memory for %S. Exiting.\n", MemorySizeStr); - exit (1); - } - // - // Allocate space for gSystemMemory Array - // - gFdInfoCount = CountSeparatorsInString (FirmwareVolumesStr, '!') + 1; - gFdInfo = calloc (gFdInfoCount, sizeof (NT_FD_INFO)); - if (gFdInfo == NULL) { - SecPrint ("ERROR : Can not allocate memory for %S. Exiting.\n", FirmwareVolumesStr); - exit (1); - } - // - // Setup Boot Mode. If BootModeStr == "" then BootMode = 0 (BOOT_WITH_FULL_CONFIGURATION) - // - SecPrint (" BootMode 0x%02x\n", PcdGet32 (PcdWinNtBootMode)); - - // - // Allocate 128K memory to emulate temp memory for PEI. - // on a real platform this would be SRAM, or using the cache as RAM. - // Set InitialStackMemory to zero so WinNtOpenFile will allocate a new mapping - // - InitialStackMemorySize = STACK_SIZE; - InitialStackMemory = (EFI_PHYSICAL_ADDRESS) (UINTN) VirtualAlloc (NULL, (SIZE_T) (InitialStackMemorySize), MEM_COMMIT, PAGE_EXECUTE_READWRITE); - if (InitialStackMemory == 0) { - SecPrint ("ERROR : Can not allocate enough space for SecStack\n"); - exit (1); - } - - for (StackPointer = (UINTN*) (UINTN) InitialStackMemory; - StackPointer < (UINTN*) ((UINTN)InitialStackMemory + (SIZE_T) InitialStackMemorySize); - StackPointer ++) { - *StackPointer = PcdGet32 (PcdInitValueInTempStack); - } - - SecPrint (" SEC passing in %d bytes of temp RAM to PEI\n", InitialStackMemorySize); - - // - // Open All the firmware volumes and remember the info in the gFdInfo global - // - FileNamePtr = (CHAR16 *)malloc (StrLen ((CHAR16 *)FirmwareVolumesStr) * sizeof(CHAR16)); - if (FileNamePtr == NULL) { - SecPrint ("ERROR : Can not allocate memory for firmware volume string\n"); - exit (1); - } - - StrCpy (FileNamePtr, (CHAR16*)FirmwareVolumesStr); - - for (Done = FALSE, Index = 0, PeiCoreFile = NULL; !Done; Index++) { - FileName = FileNamePtr; - for (Index1 = 0; (FileNamePtr[Index1] != '!') && (FileNamePtr[Index1] != 0); Index1++) - ; - if (FileNamePtr[Index1] == 0) { - Done = TRUE; - } else { - FileNamePtr[Index1] = '\0'; - FileNamePtr = FileNamePtr + Index1 + 1; - } - - // - // Open the FD and remember where it got mapped into our processes address space - // - Status = WinNtOpenFile ( - FileName, - 0, - OPEN_EXISTING, - &gFdInfo[Index].Address, - &gFdInfo[Index].Size - ); - if (EFI_ERROR (Status)) { - SecPrint ("ERROR : Can not open Firmware Device File %S (0x%X). Exiting.\n", FileName, Status); - exit (1); - } - - SecPrint (" FD loaded from"); - // - // printf can't print filenames directly as the \ gets interpreted as an - // escape character. - // - for (Index2 = 0; FileName[Index2] != '\0'; Index2++) { - SecPrint ("%c", FileName[Index2]); - } - - if (PeiCoreFile == NULL) { - // - // Assume the beginning of the FD is an FV and look for the PEI Core. - // Load the first one we find. - // - Status = SecFfsFindPeiCore ((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) gFdInfo[Index].Address, &PeiCoreFile); - if (!EFI_ERROR (Status)) { - SecPrint (" contains SEC Core"); - } - } - - SecPrint ("\n"); - } - // - // Calculate memory regions and store the information in the gSystemMemory - // global for later use. The autosizing code will use this data to - // map this memory into the SEC process memory space. - // - for (Index = 0, Done = FALSE; !Done; Index++) { - // - // Save the size of the memory and make a Unicode filename SystemMemory00, ... - // - gSystemMemory[Index].Size = _wtoi (MemorySizeStr) * 0x100000; - - // - // Find the next region - // - for (Index1 = 0; MemorySizeStr[Index1] != '!' && MemorySizeStr[Index1] != 0; Index1++) - ; - if (MemorySizeStr[Index1] == 0) { - Done = TRUE; - } - - MemorySizeStr = MemorySizeStr + Index1 + 1; - } - - SecPrint ("\n"); - - // - // Hand off to PEI Core - // - SecLoadFromCore ((UINTN) InitialStackMemory, (UINTN) InitialStackMemorySize, (UINTN) gFdInfo[0].Address, PeiCoreFile); - - // - // If we get here, then the PEI Core returned. This is an error as PEI should - // always hand off to DXE. - // - SecPrint ("ERROR : PEI Core returned\n"); - exit (1); -} - -EFI_STATUS -WinNtOpenFile ( - IN CHAR16 *FileName, - IN UINT32 MapSize, - IN DWORD CreationDisposition, - IN OUT EFI_PHYSICAL_ADDRESS *BaseAddress, - OUT UINT64 *Length - ) -/*++ - -Routine Description: - Opens and memory maps a file using WinNt services. If BaseAddress is non zero - the process will try and allocate the memory starting at BaseAddress. - -Arguments: - FileName - The name of the file to open and map - MapSize - The amount of the file to map in bytes - CreationDisposition - The flags to pass to CreateFile(). Use to create new files for - memory emulation, and exiting files for firmware volume emulation - BaseAddress - The base address of the mapped file in the user address space. - If passed in as NULL the new memory region is used. - If passed in as non NULL the request memory region is used for - the mapping of the file into the process space. - Length - The size of the mapped region in bytes - -Returns: - EFI_SUCCESS - The file was opened and mapped. - EFI_NOT_FOUND - FileName was not found in the current directory - EFI_DEVICE_ERROR - An error occured attempting to map the opened file - ---*/ -{ - HANDLE NtFileHandle; - HANDLE NtMapHandle; - VOID *VirtualAddress; - UINTN FileSize; - - // - // Use Win API to open/create a file - // - NtFileHandle = CreateFile ( - FileName, - GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE, - FILE_SHARE_READ, - NULL, - CreationDisposition, - FILE_ATTRIBUTE_NORMAL, - NULL - ); - if (NtFileHandle == INVALID_HANDLE_VALUE) { - return EFI_NOT_FOUND; - } - // - // Map the open file into a memory range - // - NtMapHandle = CreateFileMapping ( - NtFileHandle, - NULL, - PAGE_EXECUTE_READWRITE, - 0, - MapSize, - NULL - ); - if (NtMapHandle == NULL) { - return EFI_DEVICE_ERROR; - } - // - // Get the virtual address (address in the emulator) of the mapped file - // - VirtualAddress = MapViewOfFileEx ( - NtMapHandle, - FILE_MAP_EXECUTE | FILE_MAP_ALL_ACCESS, - 0, - 0, - MapSize, - (LPVOID) (UINTN) *BaseAddress - ); - if (VirtualAddress == NULL) { - return EFI_DEVICE_ERROR; - } - - if (MapSize == 0) { - // - // Seek to the end of the file to figure out the true file size. - // - FileSize = SetFilePointer ( - NtFileHandle, - 0, - NULL, - FILE_END - ); - if (FileSize == -1) { - return EFI_DEVICE_ERROR; - } - - *Length = (UINT64) FileSize; - } else { - *Length = (UINT64) MapSize; - } - - *BaseAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) VirtualAddress; - - return EFI_SUCCESS; -} - - -#define BYTES_PER_RECORD 512 - -EFI_STATUS -EFIAPI -SecPeiReportStatusCode ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN EFI_STATUS_CODE_TYPE CodeType, - IN EFI_STATUS_CODE_VALUE Value, - IN UINT32 Instance, - IN CONST EFI_GUID *CallerId, - IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL - ) -/*++ - -Routine Description: - - This routine produces the ReportStatusCode PEI service. It's passed - up to the PEI Core via a PPI. T - - This code currently uses the NT clib printf. This does not work the same way - as the EFI Print (), as %t, %g, %s as Unicode are not supported. - -Arguments: - (see EFI_PEI_REPORT_STATUS_CODE) - -Returns: - EFI_SUCCESS - Always return success - ---*/ -// TODO: PeiServices - add argument and description to function comment -// TODO: CodeType - add argument and description to function comment -// TODO: Value - add argument and description to function comment -// TODO: Instance - add argument and description to function comment -// TODO: CallerId - add argument and description to function comment -// TODO: Data - add argument and description to function comment -{ - CHAR8 *Format; - BASE_LIST Marker; - CHAR8 PrintBuffer[BYTES_PER_RECORD * 2]; - CHAR8 *Filename; - CHAR8 *Description; - UINT32 LineNumber; - UINT32 ErrorLevel; - - - if (Data == NULL) { - } else if (ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) { - // - // Processes ASSERT () - // - SecPrint ("ASSERT %s(%d): %s\n", Filename, (int)LineNumber, Description); - - } else if (ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) { - // - // Process DEBUG () macro - // - AsciiBSPrint (PrintBuffer, BYTES_PER_RECORD, Format, Marker); - SecPrint (PrintBuffer); - } - - return EFI_SUCCESS; -} - -#if defined (MDE_CPU_IA32) -/** - Transfers control to a function starting with a new stack. - - Transfers control to the function specified by EntryPoint using the new stack - specified by NewStack and passing in the parameters specified by Context1 and - Context2. Context1 and Context2 are optional and may be NULL. The function - EntryPoint must never return. - - If EntryPoint is NULL, then ASSERT(). - If NewStack is NULL, then ASSERT(). - - @param EntryPoint A pointer to function to call with the new stack. - @param Context1 A pointer to the context to pass into the EntryPoint - function. - @param Context2 A pointer to the context to pass into the EntryPoint - function. - @param NewStack A pointer to the new stack to use for the EntryPoint - function. - @param NewBsp A pointer to the new BSP for the EntryPoint on IPF. It's - Reserved on other architectures. - -**/ -VOID -EFIAPI -PeiSwitchStacks ( - IN SWITCH_STACK_ENTRY_POINT EntryPoint, - IN VOID *Context1, OPTIONAL - IN VOID *Context2, OPTIONAL - IN VOID *Context3, OPTIONAL - IN VOID *NewStack - ) -{ - BASE_LIBRARY_JUMP_BUFFER JumpBuffer; - - ASSERT (EntryPoint != NULL); - ASSERT (NewStack != NULL); - - // - // Stack should be aligned with CPU_STACK_ALIGNMENT - // - ASSERT (((UINTN)NewStack & (CPU_STACK_ALIGNMENT - 1)) == 0); - - JumpBuffer.Eip = (UINTN)EntryPoint; - JumpBuffer.Esp = (UINTN)NewStack - sizeof (VOID*); - JumpBuffer.Esp -= sizeof (Context1) + sizeof (Context2) + sizeof(Context3); - ((VOID**)JumpBuffer.Esp)[1] = Context1; - ((VOID**)JumpBuffer.Esp)[2] = Context2; - ((VOID**)JumpBuffer.Esp)[3] = Context3; - - LongJump (&JumpBuffer, (UINTN)-1); - - - // - // InternalSwitchStack () will never return - // - ASSERT (FALSE); -} -#endif - -VOID -SecLoadFromCore ( - IN UINTN LargestRegion, - IN UINTN LargestRegionSize, - IN UINTN BootFirmwareVolumeBase, - IN VOID *PeiCorePe32File - ) -/*++ - -Routine Description: - This is the service to load the PEI Core from the Firmware Volume - -Arguments: - LargestRegion - Memory to use for PEI. - LargestRegionSize - Size of Memory to use for PEI - BootFirmwareVolumeBase - Start of the Boot FV - PeiCorePe32File - PEI Core PE32 - -Returns: - Success means control is transfered and thus we should never return - ---*/ -{ - EFI_STATUS Status; - VOID *TopOfStack; - UINT64 PeiCoreSize; - EFI_PHYSICAL_ADDRESS PeiCoreEntryPoint; - EFI_PHYSICAL_ADDRESS PeiImageAddress; - EFI_SEC_PEI_HAND_OFF *SecCoreData; - UINTN PeiStackSize; - - // - // Compute Top Of Memory for Stack and PEI Core Allocations - // - PeiStackSize = (UINTN)RShiftU64((UINT64)STACK_SIZE,1); - - // - // |-----------| <---- TemporaryRamBase + TemporaryRamSize - // | Heap | - // | | - // |-----------| <---- StackBase / PeiTemporaryMemoryBase - // | | - // | Stack | - // |-----------| <---- TemporaryRamBase - // - TopOfStack = (VOID *)(LargestRegion + PeiStackSize); - - // - // Reservet space for storing PeiCore's parament in stack. - // - TopOfStack = (VOID *)((UINTN)TopOfStack - sizeof (EFI_SEC_PEI_HAND_OFF) - CPU_STACK_ALIGNMENT); - TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT); - - // - // Bind this information into the SEC hand-off state - // - SecCoreData = (EFI_SEC_PEI_HAND_OFF*)(UINTN) TopOfStack; - SecCoreData->DataSize = sizeof(EFI_SEC_PEI_HAND_OFF); - SecCoreData->BootFirmwareVolumeBase = (VOID*)BootFirmwareVolumeBase; - SecCoreData->BootFirmwareVolumeSize = PcdGet32(PcdWinNtFirmwareFdSize); - SecCoreData->TemporaryRamBase = (VOID*)(UINTN)LargestRegion; - SecCoreData->TemporaryRamSize = STACK_SIZE; - SecCoreData->StackBase = SecCoreData->TemporaryRamBase; - SecCoreData->StackSize = PeiStackSize; - SecCoreData->PeiTemporaryRamBase = (VOID*) ((UINTN) SecCoreData->TemporaryRamBase + PeiStackSize); - SecCoreData->PeiTemporaryRamSize = STACK_SIZE - PeiStackSize; - - // - // Load the PEI Core from a Firmware Volume - // - Status = SecWinNtPeiLoadFile ( - PeiCorePe32File, - &PeiImageAddress, - &PeiCoreSize, - &PeiCoreEntryPoint - ); - if (EFI_ERROR (Status)) { - return ; - } - - // - // Transfer control to the PEI Core - // - PeiSwitchStacks ( - (SWITCH_STACK_ENTRY_POINT) (UINTN) PeiCoreEntryPoint, - SecCoreData, - (VOID *) (UINTN) ((EFI_PEI_PPI_DESCRIPTOR *) &gPrivateDispatchTable), - NULL, - TopOfStack - ); - // - // If we get here, then the PEI Core returned. This is an error - // - return ; -} - -EFI_STATUS -EFIAPI -SecWinNtPeiAutoScan ( - IN UINTN Index, - OUT EFI_PHYSICAL_ADDRESS *MemoryBase, - OUT UINT64 *MemorySize - ) -/*++ - -Routine Description: - This service is called from Index == 0 until it returns EFI_UNSUPPORTED. - It allows discontinuous memory regions to be supported by the emulator. - It uses gSystemMemory[] and gSystemMemoryCount that were created by - parsing PcdWinNtMemorySizeForSecMain value. - The size comes from the Pcd value and the address comes from the memory space - with ReadWrite and Execute attributes allocated by VirtualAlloc() API. - -Arguments: - Index - Which memory region to use - MemoryBase - Return Base address of memory region - MemorySize - Return size in bytes of the memory region - -Returns: - EFI_SUCCESS - If memory region was mapped - EFI_UNSUPPORTED - If Index is not supported - ---*/ -{ - if (Index >= gSystemMemoryCount) { - return EFI_UNSUPPORTED; - } - - // - // Allocate enough memory space for emulator - // - gSystemMemory[Index].Memory = (EFI_PHYSICAL_ADDRESS) (UINTN) VirtualAlloc (NULL, (SIZE_T) (gSystemMemory[Index].Size), MEM_COMMIT, PAGE_EXECUTE_READWRITE); - if (gSystemMemory[Index].Memory == 0) { - return EFI_OUT_OF_RESOURCES; - } - - *MemoryBase = gSystemMemory[Index].Memory; - *MemorySize = gSystemMemory[Index].Size; - - return EFI_SUCCESS; -} - -VOID * -EFIAPI -SecWinNtWinNtThunkAddress ( - VOID - ) -/*++ - -Routine Description: - Since the SEC is the only Windows program in stack it must export - an interface to do Win API calls. That's what the WinNtThunk address - is for. gWinNt is initialized in WinNtThunk.c. - -Arguments: - InterfaceSize - sizeof (EFI_WIN_NT_THUNK_PROTOCOL); - InterfaceBase - Address of the gWinNt global - -Returns: - EFI_SUCCESS - Data returned - ---*/ -{ - return gWinNt; -} - - -EFI_STATUS -EFIAPI -SecWinNtPeiLoadFile ( - IN VOID *Pe32Data, - IN EFI_PHYSICAL_ADDRESS *ImageAddress, - IN UINT64 *ImageSize, - IN EFI_PHYSICAL_ADDRESS *EntryPoint - ) -/*++ - -Routine Description: - Loads and relocates a PE/COFF image into memory. - -Arguments: - Pe32Data - The base address of the PE/COFF file that is to be loaded and relocated - ImageAddress - The base address of the relocated PE/COFF image - ImageSize - The size of the relocated PE/COFF image - EntryPoint - The entry point of the relocated PE/COFF image - -Returns: - EFI_SUCCESS - The file was loaded and relocated - EFI_OUT_OF_RESOURCES - There was not enough memory to load and relocate the PE/COFF file - ---*/ -{ - EFI_STATUS Status; - PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; - - ZeroMem (&ImageContext, sizeof (ImageContext)); - ImageContext.Handle = Pe32Data; - - ImageContext.ImageRead = (PE_COFF_LOADER_READ_FILE) SecImageRead; - - Status = PeCoffLoaderGetImageInfo (&ImageContext); - if (EFI_ERROR (Status)) { - return Status; - } - // - // Allocate space in NT (not emulator) memory with ReadWrite and Execute attribute. - // Extra space is for alignment - // - ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) VirtualAlloc (NULL, (SIZE_T) (ImageContext.ImageSize + (ImageContext.SectionAlignment * 2)), MEM_COMMIT, PAGE_EXECUTE_READWRITE); - if (ImageContext.ImageAddress == 0) { - return EFI_OUT_OF_RESOURCES; - } - // - // Align buffer on section boundary - // - ImageContext.ImageAddress += ImageContext.SectionAlignment - 1; - ImageContext.ImageAddress &= ~((EFI_PHYSICAL_ADDRESS)ImageContext.SectionAlignment - 1); - - Status = PeCoffLoaderLoadImage (&ImageContext); - if (EFI_ERROR (Status)) { - return Status; - } - - Status = SecNt32PeCoffRelocateImage (&ImageContext); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // BugBug: Flush Instruction Cache Here when CPU Lib is ready - // - - *ImageAddress = ImageContext.ImageAddress; - *ImageSize = ImageContext.ImageSize; - *EntryPoint = ImageContext.EntryPoint; - - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -SecWinNtFdAddress ( - IN UINTN Index, - IN OUT EFI_PHYSICAL_ADDRESS *FdBase, - IN OUT UINT64 *FdSize - ) -/*++ - -Routine Description: - Return the FD Size and base address. Since the FD is loaded from a - file into Windows memory only the SEC will know it's address. - -Arguments: - Index - Which FD, starts at zero. - FdSize - Size of the FD in bytes - FdBase - Start address of the FD. Assume it points to an FV Header - -Returns: - EFI_SUCCESS - Return the Base address and size of the FV - EFI_UNSUPPORTED - Index does not map to an FD in the system - ---*/ -{ - if (Index >= gFdInfoCount) { - return EFI_UNSUPPORTED; - } - - *FdBase = gFdInfo[Index].Address; - *FdSize = gFdInfo[Index].Size; - - if (*FdBase == 0 && *FdSize == 0) { - return EFI_UNSUPPORTED; - } - - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -SecImageRead ( - IN VOID *FileHandle, - IN UINTN FileOffset, - IN OUT UINTN *ReadSize, - OUT VOID *Buffer - ) -/*++ - -Routine Description: - Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file - -Arguments: - FileHandle - The handle to the PE/COFF file - FileOffset - The offset, in bytes, into the file to read - ReadSize - The number of bytes to read from the file starting at FileOffset - Buffer - A pointer to the buffer to read the data into. - -Returns: - EFI_SUCCESS - ReadSize bytes of data were read into Buffer from the PE/COFF file starting at FileOffset - ---*/ -{ - CHAR8 *Destination8; - CHAR8 *Source8; - UINTN Length; - - Destination8 = Buffer; - Source8 = (CHAR8 *) ((UINTN) FileHandle + FileOffset); - Length = *ReadSize; - while (Length--) { - *(Destination8++) = *(Source8++); - } - - return EFI_SUCCESS; -} - -CHAR16 * -AsciiToUnicode ( - IN CHAR8 *Ascii, - IN UINTN *StrLen OPTIONAL - ) -/*++ - -Routine Description: - Convert the passed in Ascii string to Unicode. - Optionally return the length of the strings. - -Arguments: - Ascii - Ascii string to convert - StrLen - Length of string - -Returns: - Pointer to malloc'ed Unicode version of Ascii - ---*/ -{ - UINTN Index; - CHAR16 *Unicode; - - // - // Allocate a buffer for unicode string - // - for (Index = 0; Ascii[Index] != '\0'; Index++) - ; - Unicode = malloc ((Index + 1) * sizeof (CHAR16)); - if (Unicode == NULL) { - return NULL; - } - - for (Index = 0; Ascii[Index] != '\0'; Index++) { - Unicode[Index] = (CHAR16) Ascii[Index]; - } - - Unicode[Index] = '\0'; - - if (StrLen != NULL) { - *StrLen = Index; - } - - return Unicode; -} - -UINTN -CountSeparatorsInString ( - IN CONST CHAR16 *String, - IN CHAR16 Separator - ) -/*++ - -Routine Description: - Count the number of separators in String - -Arguments: - String - String to process - Separator - Item to count - -Returns: - Number of Separator in String - ---*/ -{ - UINTN Count; - - for (Count = 0; *String != '\0'; String++) { - if (*String == Separator) { - Count++; - } - } - - return Count; -} - - -EFI_STATUS -SecNt32PeCoffRelocateImage ( - IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext - ) -{ - EFI_STATUS Status; - VOID *DllEntryPoint; - CHAR16 *DllFileName; - HMODULE Library; - UINTN Index; - - - Status = PeCoffLoaderRelocateImage (ImageContext); - if (EFI_ERROR (Status)) { - // - // We could not relocated the image in memory properly - // - return Status; - } - - // - // If we load our own PE COFF images the Windows debugger can not source - // level debug our code. If a valid PDB pointer exists usw it to load - // the *.dll file as a library using Windows* APIs. This allows - // source level debug. The image is still loaded and relocated - // in the Framework memory space like on a real system (by the code above), - // but the entry point points into the DLL loaded by the code bellow. - // - - DllEntryPoint = NULL; - - // - // Load the DLL if it's not an EBC image. - // - if ((ImageContext->PdbPointer != NULL) && - (ImageContext->Machine != EFI_IMAGE_MACHINE_EBC)) { - // - // Convert filename from ASCII to Unicode - // - DllFileName = AsciiToUnicode (ImageContext->PdbPointer, &Index); - - // - // Check that we have a valid filename - // - if (Index < 5 || DllFileName[Index - 4] != '.') { - free (DllFileName); - - // - // Never return an error if PeCoffLoaderRelocateImage() succeeded. - // The image will run, but we just can't source level debug. If we - // return an error the image will not run. - // - return EFI_SUCCESS; - } - // - // Replace .PDB with .DLL on the filename - // - DllFileName[Index - 3] = 'D'; - DllFileName[Index - 2] = 'L'; - DllFileName[Index - 1] = 'L'; - - // - // Load the .DLL file into the user process's address space for source - // level debug - // - Library = LoadLibraryEx (DllFileName, NULL, DONT_RESOLVE_DLL_REFERENCES); - if (Library != NULL) { - // - // InitializeDriver is the entry point we put in all our EFI DLL's. The - // DONT_RESOLVE_DLL_REFERENCES argument to LoadLIbraryEx() suppresses the - // normal DLL entry point of DllMain, and prevents other modules that are - // referenced in side the DllFileName from being loaded. There is no error - // checking as the we can point to the PE32 image loaded by Tiano. This - // step is only needed for source level debugging - // - DllEntryPoint = (VOID *) (UINTN) GetProcAddress (Library, "InitializeDriver"); - - } - - if ((Library != NULL) && (DllEntryPoint != NULL)) { - ImageContext->EntryPoint = (EFI_PHYSICAL_ADDRESS) (UINTN) DllEntryPoint; - SecPrint ("LoadLibraryEx (%S,\n NULL, DONT_RESOLVE_DLL_REFERENCES)\n", DllFileName); - } else { - SecPrint ("WARNING: No source level debug %S. \n", DllFileName); - } - - free (DllFileName); - } - - // - // Never return an error if PeCoffLoaderRelocateImage() succeeded. - // The image will run, but we just can't source level debug. If we - // return an error the image will not run. - // - return EFI_SUCCESS; -} - - - - -VOID -_ModuleEntryPoint ( - VOID - ) -{ -} - -EFI_STATUS -EFIAPI -SecTemporaryRamSupport ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase, - IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase, - IN UINTN CopySize - ) -{ - // - // Migrate the whole temporary memory to permanent memory. - // - CopyMem ( - (VOID*)(UINTN)PermanentMemoryBase, - (VOID*)(UINTN)TemporaryMemoryBase, - CopySize - ); - - // - // SecSwitchStack function must be invoked after the memory migration - // immediately, also we need fixup the stack change caused by new call into - // permanent memory. - // - SecSwitchStack ( - (UINT32) TemporaryMemoryBase, - (UINT32) PermanentMemoryBase - ); - - // - // We need *not* fix the return address because currently, - // The PeiCore is executed in flash. - // - - // - // Simulate to invalid temporary memory, terminate temporary memory - // - //ZeroMem ((VOID*)(UINTN)TemporaryMemoryBase, CopySize); - - return EFI_SUCCESS; -} - diff --git a/Nt32Pkg/Sec/SecMain.h b/Nt32Pkg/Sec/SecMain.h deleted file mode 100644 index 09d4e367f6..0000000000 --- a/Nt32Pkg/Sec/SecMain.h +++ /dev/null @@ -1,553 +0,0 @@ -/**@file - -Copyright (c) 2006, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - - -Module Name: - SecMain.h - -Abstract: - Include file for Windows API based SEC - -**/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#define STACK_SIZE 0x20000 - -typedef struct { - EFI_PHYSICAL_ADDRESS Address; - UINT64 Size; -} NT_FD_INFO; - -typedef struct { - EFI_PHYSICAL_ADDRESS Memory; - UINT64 Size; -} NT_SYSTEM_MEMORY; - -#define MAX_PDB_NAME_TO_MOD_HANDLE_ARRAY_SIZE 0x100 - -typedef struct { - CHAR8 *PdbPointer; - VOID *ModHandle; -} PDB_NAME_TO_MOD_HANDLE; - - - - -EFI_STATUS -EFIAPI -SecWinNtPeiLoadFile ( - VOID *Pe32Data, // TODO: add IN/OUT modifier to Pe32Data - EFI_PHYSICAL_ADDRESS *ImageAddress, // TODO: add IN/OUT modifier to ImageAddress - UINT64 *ImageSize, // TODO: add IN/OUT modifier to ImageSize - EFI_PHYSICAL_ADDRESS *EntryPoint // TODO: add IN/OUT modifier to EntryPoint - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - Pe32Data - TODO: add argument description - ImageAddress - TODO: add argument description - ImageSize - TODO: add argument description - EntryPoint - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -EFIAPI -SecWinNtPeiAutoScan ( - IN UINTN Index, - OUT EFI_PHYSICAL_ADDRESS *MemoryBase, - OUT UINT64 *MemorySize - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - Index - TODO: add argument description - MemoryBase - TODO: add argument description - MemorySize - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -VOID * -EFIAPI -SecWinNtWinNtThunkAddress ( - VOID - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - InterfaceSize - TODO: add argument description - InterfaceBase - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -EFIAPI -SecWinNtWinNtFwhAddress ( - IN OUT UINT64 *FwhSize, - IN OUT EFI_PHYSICAL_ADDRESS *FwhBase - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - FwhSize - TODO: add argument description - FwhBase - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -EFIAPI -SecPeiReportStatusCode ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN EFI_STATUS_CODE_TYPE CodeType, - IN EFI_STATUS_CODE_VALUE Value, - IN UINT32 Instance, - IN CONST EFI_GUID * CallerId, - IN CONST EFI_STATUS_CODE_DATA * Data OPTIONAL - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - PeiServices - TODO: add argument description - CodeType - TODO: add argument description - Value - TODO: add argument description - Instance - TODO: add argument description - CallerId - TODO: add argument description - Data - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -INTN -EFIAPI -main ( - IN INTN Argc, - IN CHAR8 **Argv, - IN CHAR8 **Envp - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - Argc - TODO: add argument description - Argv - TODO: add argument description - Envp - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -WinNtOpenFile ( - CHAR16 *FileName, - UINT32 MapSize, - DWORD CreationDispostion, - EFI_PHYSICAL_ADDRESS *BaseAddress, - UINT64 *Length - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - FileName - TODO: add argument description - MapSize - TODO: add argument description - CreationDispostion - TODO: add argument description - BaseAddress - TODO: add argument description - Length - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -VOID -SecLoadFromCore ( - IN UINTN LargestRegion, - IN UINTN LargestRegionSize, - IN UINTN BootFirmwareVolumeBase, - IN VOID *PeiCoreFile - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - LargestRegion - TODO: add argument description - LargestRegionSize - TODO: add argument description - BootFirmwareVolumeBase - TODO: add argument description - PeiCoreFile - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -SecLoadFile ( - IN VOID *Pe32Data, - IN EFI_PHYSICAL_ADDRESS *ImageAddress, - IN UINT64 *ImageSize, - IN EFI_PHYSICAL_ADDRESS *EntryPoint - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - Pe32Data - TODO: add argument description - ImageAddress - TODO: add argument description - ImageSize - TODO: add argument description - EntryPoint - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -SecFfsFindPeiCore ( - IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader, - OUT VOID **Pe32Data - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - FwVolHeader - TODO: add argument description - Pe32Data - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -SecFfsFindNextFile ( - IN EFI_FV_FILETYPE SearchType, - IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader, - IN OUT EFI_FFS_FILE_HEADER **FileHeader - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - SearchType - TODO: add argument description - FwVolHeader - TODO: add argument description - FileHeader - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -SecFfsFindSectionData ( - IN EFI_SECTION_TYPE SectionType, - IN EFI_FFS_FILE_HEADER *FfsFileHeader, - IN OUT VOID **SectionData - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - SectionType - TODO: add argument description - FfsFileHeader - TODO: add argument description - SectionData - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -EFIAPI -SecWinNtPeCoffLoaderLoadAsDll ( - IN CHAR8 *PdbFileName, - IN VOID **ImageEntryPoint, - OUT VOID **ModHandle - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - PdbFileName - TODO: add argument description - ImageEntryPoint - TODO: add argument description - ModHandle - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -EFIAPI -SecWinNtPeCoffLoaderFreeLibrary ( - OUT VOID *ModHandle - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - ModHandle - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -EFIAPI -SecWinNtFdAddress ( - IN UINTN Index, - IN OUT EFI_PHYSICAL_ADDRESS *FdBase, - IN OUT UINT64 *FdSize - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - Index - TODO: add argument description - FdBase - TODO: add argument description - FdSize - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -GetImageReadFunction ( - IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext, - IN EFI_PHYSICAL_ADDRESS *TopOfMemory - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - ImageContext - TODO: add argument description - TopOfMemory - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -EFIAPI -SecImageRead ( - IN VOID *FileHandle, - IN UINTN FileOffset, - IN OUT UINTN *ReadSize, - OUT VOID *Buffer - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - FileHandle - TODO: add argument description - FileOffset - TODO: add argument description - ReadSize - TODO: add argument description - Buffer - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -CHAR16 * -AsciiToUnicode ( - IN CHAR8 *Ascii, - IN UINTN *StrLen OPTIONAL - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - Ascii - TODO: add argument description - StrLen - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -UINTN -CountSeparatorsInString ( - IN CONST CHAR16 *String, - IN CHAR16 Separator - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - String - TODO: add argument description - Separator - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -EFIAPI -SecTemporaryRamSupport ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase, - IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase, - IN UINTN CopySize - ); - - -extern EFI_WIN_NT_THUNK_PROTOCOL *gWinNt; diff --git a/Nt32Pkg/Sec/SecMain.inf b/Nt32Pkg/Sec/SecMain.inf deleted file mode 100644 index 2a68284ef8..0000000000 --- a/Nt32Pkg/Sec/SecMain.inf +++ /dev/null @@ -1,88 +0,0 @@ -## @file -# Entry Point of NT32 Emulator -# -# Main executable file of NT32 Emulator that loads PEI core after initialization finished. -# -# Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.
-# SPDX-License-Identifier: BSD-2-Clause-Patent -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = SecMain - FILE_GUID = 4b837b03-6587-4d19-b82b-edfad836c0a0 - MODULE_TYPE = USER_DEFINED - VERSION_STRING = 1.0 - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 -# - -[Sources] - SecMain.h - WinNtThunk.c - FwVol.c - SecMain.c - -[Sources.ia32] - Stack.asm - -[Sources.x64] - StackX64.asm - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - Nt32Pkg/Nt32Pkg.dec - -[LibraryClasses] - DebugLib - PcdLib - PrintLib - BaseMemoryLib - BaseLib - PeCoffLib - ReportStatusCodeLib - -[Ppis] - gNtPeiLoadFilePpiGuid # PPI ALWAYS_PRODUCED - gEfiPeiStatusCodePpiGuid # PPI ALWAYS_PRODUCED - gNtFwhPpiGuid # PPI ALWAYS_PRODUCED - gPeiNtAutoScanPpiGuid # PPI ALWAYS_PRODUCED - gPeiNtThunkPpiGuid # PPI ALWAYS_PRODUCED - gEfiTemporaryRamSupportPpiGuid - -[Pcd] - gEfiNt32PkgTokenSpaceGuid.PcdWinNtBootMode - gEfiNt32PkgTokenSpaceGuid.PcdWinNtFirmwareFdSize - gEfiNt32PkgTokenSpaceGuid.PcdWinNtMemorySizeForSecMain - gEfiNt32PkgTokenSpaceGuid.PcdWinNtFirmwareVolume - gEfiMdeModulePkgTokenSpaceGuid.PcdInitValueInTempStack - -[BuildOptions] - MSFT:*_*_IA32_DLINK_FLAGS == /out:"$(BIN_DIR)\SecMain.exe" /base:0x10000000 /pdb:"$(BIN_DIR)\SecMain.pdb" /LIBPATH:"$(VCINSTALLDIR)\Lib" /LIBPATH:"$(VCINSTALLDIR)\PlatformSdk\Lib" /LIBPATH:"%UniversalCRTSdkDir%lib\%UCRTVersion%\ucrt\x86" /LIBPATH:"%WindowsSdkDir%lib\%WindowsSDKLibVersion%\um\x86" /NOLOGO /SUBSYSTEM:CONSOLE /NODEFAULTLIB /IGNORE:4086 /MAP /OPT:REF /DEBUG /MACHINE:I386 /LTCG Kernel32.lib MSVCRTD.lib Gdi32.lib User32.lib Winmm.lib Advapi32.lib - MSFT:*_VS2015_IA32_DLINK_FLAGS == /out:"$(BIN_DIR)\SecMain.exe" /base:0x10000000 /pdb:"$(BIN_DIR)\SecMain.pdb" /LIBPATH:"$(VCINSTALLDIR)\Lib" /LIBPATH:"$(VCINSTALLDIR)\PlatformSdk\Lib" /LIBPATH:"%UniversalCRTSdkDir%lib\%UCRTVersion%\ucrt\x86" /LIBPATH:"%WindowsSdkDir%lib\%WindowsSDKLibVersion%\um\x86" /NOLOGO /SUBSYSTEM:CONSOLE /NODEFAULTLIB /IGNORE:4086 /MAP /OPT:REF /DEBUG /MACHINE:I386 /LTCG Kernel32.lib MSVCRTD.lib vcruntimed.lib ucrtd.lib Gdi32.lib User32.lib Winmm.lib Advapi32.lib - MSFT:*_VS2015x86_IA32_DLINK_FLAGS == /out:"$(BIN_DIR)\SecMain.exe" /base:0x10000000 /pdb:"$(BIN_DIR)\SecMain.pdb" /LIBPATH:"$(VCINSTALLDIR)\Lib" /LIBPATH:"$(VCINSTALLDIR)\PlatformSdk\Lib" /LIBPATH:"%UniversalCRTSdkDir%lib\%UCRTVersion%\ucrt\x86" /LIBPATH:"%WindowsSdkDir%lib\%WindowsSDKLibVersion%\um\x86" /NOLOGO /SUBSYSTEM:CONSOLE /NODEFAULTLIB /IGNORE:4086 /MAP /OPT:REF /DEBUG /MACHINE:I386 /LTCG Kernel32.lib MSVCRTD.lib vcruntimed.lib ucrtd.lib Gdi32.lib User32.lib Winmm.lib Advapi32.lib - MSFT:*_VS2017_IA32_DLINK_FLAGS == /out:"$(BIN_DIR)\SecMain.exe" /base:0x10000000 /pdb:"$(BIN_DIR)\SecMain.pdb" /LIBPATH:"%VCToolsInstallDir%lib\x86" /LIBPATH:"%UniversalCRTSdkDir%lib\%UCRTVersion%\ucrt\x86" /LIBPATH:"%WindowsSdkDir%lib\%WindowsSDKLibVersion%\um\x86" /NOLOGO /SUBSYSTEM:CONSOLE /NODEFAULTLIB /IGNORE:4086 /MAP /OPT:REF /DEBUG /MACHINE:I386 /LTCG Kernel32.lib MSVCRTD.lib vcruntimed.lib ucrtd.lib Gdi32.lib User32.lib Winmm.lib Advapi32.lib - MSFT:*_*_IA32_CC_FLAGS == /nologo /W4 /WX /Gy /c /D UNICODE /Od /FIAutoGen.h /EHs-c- /GF /Gs8192 /Zi /Gm /D _CRT_SECURE_NO_WARNINGS /D _CRT_SECURE_NO_DEPRECATE - MSFT:*_*_IA32_PP_FLAGS == /nologo /E /TC /FIAutoGen.h - MSFT:*_*_IA32_ASM_FLAGS == /nologo /W3 /WX /c /coff /Cx /Zd /W0 /Zi - MSFT:*_*_IA32_ASMLINK_FLAGS == /link /nologo /tiny - - MSFT:*_*_X64_DLINK_FLAGS == /out:"$(BIN_DIR)\SecMain.exe" /base:0x10000000 /pdb:"$(BIN_DIR)\SecMain.pdb" /LIBPATH:"$(VCINSTALLDIR)\Lib\AMD64" /LIBPATH:"%UniversalCRTSdkDir%lib\%UCRTVersion%\ucrt\x64" /LIBPATH:"%WindowsSdkDir%lib\%WindowsSDKLibVersion%\um\x64" /NOLOGO /SUBSYSTEM:CONSOLE /NODEFAULTLIB /IGNORE:4086 /MAP /OPT:REF /DEBUG /MACHINE:AMD64 /LTCG Kernel32.lib MSVCRTD.lib Gdi32.lib User32.lib Winmm.lib Advapi32.lib - MSFT:*_VS2015_X64_DLINK_FLAGS == /out:"$(BIN_DIR)\SecMain.exe" /base:0x10000000 /pdb:"$(BIN_DIR)\SecMain.pdb" /LIBPATH:"$(VCINSTALLDIR)\Lib\AMD64" /LIBPATH:"%UniversalCRTSdkDir%lib\%UCRTVersion%\ucrt\x64" /LIBPATH:"%WindowsSdkDir%lib\%WindowsSDKLibVersion%\um\x64" /NOLOGO /SUBSYSTEM:CONSOLE /NODEFAULTLIB /IGNORE:4086 /MAP /OPT:REF /DEBUG /MACHINE:AMD64 /LTCG Kernel32.lib MSVCRTD.lib vcruntimed.lib ucrtd.lib Gdi32.lib User32.lib Winmm.lib Advapi32.lib - MSFT:*_VS2015x86_X64_DLINK_FLAGS == /out:"$(BIN_DIR)\SecMain.exe" /base:0x10000000 /pdb:"$(BIN_DIR)\SecMain.pdb" /LIBPATH:"$(VCINSTALLDIR)\Lib\AMD64" /LIBPATH:"%UniversalCRTSdkDir%lib\%UCRTVersion%\ucrt\x64" /LIBPATH:"%WindowsSdkDir%lib\%WindowsSDKLibVersion%\um\x64" /NOLOGO /SUBSYSTEM:CONSOLE /NODEFAULTLIB /IGNORE:4086 /MAP /OPT:REF /DEBUG /MACHINE:AMD64 /LTCG Kernel32.lib MSVCRTD.lib vcruntimed.lib ucrtd.lib Gdi32.lib User32.lib Winmm.lib Advapi32.lib - MSFT:*_VS2017_X64_DLINK_FLAGS == /out:"$(BIN_DIR)\SecMain.exe" /base:0x10000000 /pdb:"$(BIN_DIR)\SecMain.pdb" /LIBPATH:"%VCToolsInstallDir%lib\x64" /LIBPATH:"%UniversalCRTSdkDir%lib\%UCRTVersion%\ucrt\x64" /LIBPATH:"%WindowsSdkDir%lib\%WindowsSDKLibVersion%\um\x64" /NOLOGO /SUBSYSTEM:CONSOLE /NODEFAULTLIB /IGNORE:4086 /MAP /OPT:REF /DEBUG /MACHINE:AMD64 /LTCG Kernel32.lib MSVCRTD.lib vcruntimed.lib ucrtd.lib Gdi32.lib User32.lib Winmm.lib Advapi32.lib - MSFT:*_*_X64_CC_FLAGS == /nologo /W4 /WX /Gy /c /D UNICODE /Od /FIAutoGen.h /EHs-c- /GF /Gs8192 /Zi /Gm /D _CRT_SECURE_NO_WARNINGS /D _CRT_SECURE_NO_DEPRECATE - MSFT:*_*_X64_PP_FLAGS == /nologo /E /TC /FIAutoGen.h - MSFT:*_*_X64_ASM_FLAGS == /nologo /W3 /WX /c /Cx /Zd /W0 /Zi - MSFT:*_*_X64_ASMLINK_FLAGS == /link /nologo - - INTEL:*_*_IA32_DLINK_FLAGS == /out:"$(BIN_DIR)\SecMain.exe" /base:0x10000000 /pdb:"$(BIN_DIR)\SecMain.pdb" /LIBPATH:"C:\Program Files\Intel\Compiler\C++\9.1\IA32\Lib" /LIBPATH:"$(VCINSTALLDIR)\Lib" /LIBPATH:"$(VCINSTALLDIR)\PlatformSdk\Lib" /NOLOGO /SUBSYSTEM:CONSOLE /NODEFAULTLIB /IGNORE:4086 /MAP /OPT:REF /DEBUG /MACHINE:I386 /LTCG Kernel32.lib MSVCRTD.lib Gdi32.lib User32.lib Winmm.lib - INTEL:*_*_IA32_CC_FLAGS == /nologo /W4 /WX /Gy /c /D UNICODE /Od /FIAutoGen.h /EHs-c- /GF /Gs8192 /Zi /Gm /D _CRT_SECURE_NO_WARNINGS /D _CRT_SECURE_NO_DEPRECATE - INTEL:*_*_IA32_PP_FLAGS == /nologo /E /TC /FIAutoGen.h - INTEL:*_*_IA32_ASM_FLAGS == /nologo /W3 /WX /c /coff /Cx /Zd /W0 /Zi - INTEL:*_*_IA32_ASMLINK_FLAGS == /link /nologo /tiny diff --git a/Nt32Pkg/Sec/Stack.asm b/Nt32Pkg/Sec/Stack.asm deleted file mode 100644 index 90fa2b2e82..0000000000 --- a/Nt32Pkg/Sec/Stack.asm +++ /dev/null @@ -1,88 +0,0 @@ -;------------------------------------------------------------------------------ -; -; Copyright (c) 2007, Intel Corporation. All rights reserved.
-; SPDX-License-Identifier: BSD-2-Clause-Patent -; -; Module Name: -; -; Stack.asm -; -; Abstract: -; -; Switch the stack from temporary memory to permenent memory. -; -;------------------------------------------------------------------------------ - - .586p - .model flat,C - .code - -;------------------------------------------------------------------------------ -; VOID -; EFIAPI -; SecSwitchStack ( -; UINT32 TemporaryMemoryBase, -; UINT32 PermenentMemoryBase -; ); -;------------------------------------------------------------------------------ -SecSwitchStack PROC - ; - ; Save three register: eax, ebx, ecx - ; - push eax - push ebx - push ecx - push edx - - ; - ; !!CAUTION!! this function address's is pushed into stack after - ; migration of whole temporary memory, so need save it to permenent - ; memory at first! - ; - - mov ebx, [esp + 20] ; Save the first parameter - mov ecx, [esp + 24] ; Save the second parameter - - ; - ; Save this function's return address into permenent memory at first. - ; Then, Fixup the esp point to permenent memory - ; - mov eax, esp - sub eax, ebx - add eax, ecx - mov edx, dword ptr [esp] ; copy pushed register's value to permenent memory - mov dword ptr [eax], edx - mov edx, dword ptr [esp + 4] - mov dword ptr [eax + 4], edx - mov edx, dword ptr [esp + 8] - mov dword ptr [eax + 8], edx - mov edx, dword ptr [esp + 12] - mov dword ptr [eax + 12], edx - mov edx, dword ptr [esp + 16] ; Update this function's return address into permenent memory - mov dword ptr [eax + 16], edx - mov esp, eax ; From now, esp is pointed to permenent memory - - ; - ; Fixup the ebp point to permenent memory - ; - mov eax, ebp - sub eax, ebx - add eax, ecx - mov ebp, eax ; From now, ebp is pointed to permenent memory - - ; - ; Fixup callee's ebp point for PeiDispatch - ; - mov eax, dword ptr [ebp] - sub eax, ebx - add eax, ecx - mov dword ptr [ebp], eax ; From now, Temporary's PPI caller's stack is in permenent memory - - pop edx - pop ecx - pop ebx - pop eax - ret -SecSwitchStack ENDP - - END diff --git a/Nt32Pkg/Sec/StackX64.asm b/Nt32Pkg/Sec/StackX64.asm deleted file mode 100644 index 565acfa8b6..0000000000 --- a/Nt32Pkg/Sec/StackX64.asm +++ /dev/null @@ -1,104 +0,0 @@ -;------------------------------------------------------------------------------ -; -; Copyright (c) 2013, Intel Corporation. All rights reserved.
-; SPDX-License-Identifier: BSD-2-Clause-Patent -; -; Module Name: -; -; Stack.asm -; -; Abstract: -; -; Switch the stack from temporary memory to permenent memory. -; -;------------------------------------------------------------------------------ - - .code - -;------------------------------------------------------------------------------ -; VOID -; EFIAPI -; SecSwitchStack ( -; UINT32 TemporaryMemoryBase, -; UINT32 PermenentMemoryBase -; ); -;------------------------------------------------------------------------------ -SecSwitchStack PROC - mov [rsp + 08h], rcx - mov [rsp + 10h], rdx - - ; - ; Save three register: eax, ebx, ecx - ; - push rax - push rbx - push rcx - push rdx - - ; - ; !!CAUTION!! this function address's is pushed into stack after - ; migration of whole temporary memory, so need save it to permenent - ; memory at first! - ; - - mov rbx, [rsp + 28h] ; Save the first parameter - mov rcx, [rsp + 30h] ; Save the second parameter - - ; - ; Save this function's return address into permenent memory at first. - ; Then, Fixup the esp point to permenent memory - ; - mov rax, rsp - sub rax, rbx - add rax, rcx - mov rdx, qword ptr [rsp] ; copy pushed register's value to permenent memory - mov qword ptr [rax], rdx - mov rdx, qword ptr [rsp + 8] - mov qword ptr [rax + 8], rdx - mov rdx, qword ptr [rsp + 10h] - mov qword ptr [rax + 10h], rdx - mov rdx, qword ptr [rsp + 18h] - mov qword ptr [rax + 18h], rdx - mov rdx, qword ptr [rsp + 20h] ; Update this function's return address into permenent memory - mov qword ptr [rax + 20h], rdx - mov rsp, rax ; From now, esp is pointed to permenent memory - - ; - ; Fixup the ebp point to permenent memory - ; - mov rax, rbp - sub rax, rbx - add rax, rcx - mov rbp, rax ; From now, ebp is pointed to permenent memory - - pop rdx - pop rcx - pop rbx - pop rax - ret -SecSwitchStack ENDP - -;------------------------------------------------------------------------------ -; VOID -; EFIAPI -; PeiSwitchStacks ( -; IN SWITCH_STACK_ENTRY_POINT EntryPoint, -; IN VOID *Context1, OPTIONAL -; IN VOID *Context2, OPTIONAL -; IN VOID *Context3, OPTIONAL -; IN VOID *NewStack -; ) -;------------------------------------------------------------------------------ -PeiSwitchStacks PROC - mov rax, rcx - mov rcx, rdx - mov rdx, r8 - mov r8, r9 - mov rsp, [rsp + 28h] - sub rsp, 20h - call rax - jmp $ - ret -PeiSwitchStacks ENDP - - END diff --git a/Nt32Pkg/Sec/WinNtThunk.c b/Nt32Pkg/Sec/WinNtThunk.c deleted file mode 100644 index c65b906292..0000000000 --- a/Nt32Pkg/Sec/WinNtThunk.c +++ /dev/null @@ -1,181 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - WinNtThunk.c - -Abstract: - - Since the SEC is the only windows program in our emulation we - must use a Tiano mechanism to export Win32 APIs to other modules. - This is the role of the EFI_WIN_NT_THUNK_PROTOCOL. - - The mWinNtThunkTable exists so that a change to EFI_WIN_NT_THUNK_PROTOCOL - will cause an error in initializing the array if all the member functions - are not added. It looks like adding a element to end and not initializing - it may cause the table to be initaliized with the members at the end being - set to zero. This is bad as jumping to zero will case the NT32 to crash. - - All the member functions in mWinNtThunkTable are Win32 - API calls, so please reference Microsoft documentation. - - - gWinNt is a a public exported global that contains the initialized - data. - -**/ - -#include "SecMain.h" - -// -// This pragma is needed for all the DLL entry points to be asigned to the array. -// if warning 4232 is not dissabled a warning will be generated as a DLL entry -// point could be modified dynamically. The SEC does not do that, so we must -// disable the warning so we can compile the SEC. The previous method was to -// asign each element in code. The disadvantage to that approach is it's harder -// to tell if all the elements have been initialized properly. -// -#pragma warning(disable : 4232) -#pragma warning(disable : 4996) - -#if __INTEL_COMPILER -#pragma warning ( disable : 144 ) -#endif - -EFI_WIN_NT_THUNK_PROTOCOL mWinNtThunkTable = { - EFI_WIN_NT_THUNK_PROTOCOL_SIGNATURE, - GetProcAddress, - GetTickCount, - LoadLibraryEx, - FreeLibrary, - SetPriorityClass, - SetThreadPriority, - Sleep, - SuspendThread, - GetCurrentThread, - GetCurrentThreadId, - GetCurrentProcess, - CreateThread, - TerminateThread, - SendMessage, - ExitThread, - ResumeThread, - DuplicateHandle, - InitializeCriticalSection, - EnterCriticalSection, - LeaveCriticalSection, - DeleteCriticalSection, - TlsAlloc, - TlsFree, - TlsSetValue, - TlsGetValue, - CreateSemaphore, - WaitForSingleObject, - ReleaseSemaphore, - CreateConsoleScreenBuffer, - FillConsoleOutputAttribute, - FillConsoleOutputCharacter, - GetConsoleCursorInfo, - GetNumberOfConsoleInputEvents, - PeekConsoleInput, - ScrollConsoleScreenBuffer, - ReadConsoleInput, - SetConsoleActiveScreenBuffer, - SetConsoleCursorInfo, - SetConsoleCursorPosition, - SetConsoleScreenBufferSize, - SetConsoleTitleW, - WriteConsoleInput, - WriteConsoleOutput, - CreateFile, - DeviceIoControl, - CreateDirectory, - RemoveDirectory, - GetFileAttributes, - SetFileAttributes, - CreateFileMapping, - CloseHandle, - DeleteFile, - FindFirstFile, - FindNextFile, - FindClose, - FlushFileBuffers, - GetEnvironmentVariable, - GetLastError, - SetErrorMode, - GetStdHandle, - MapViewOfFileEx, - ReadFile, - SetEndOfFile, - SetFilePointer, - WriteFile, - GetFileInformationByHandle, - GetDiskFreeSpace, - GetDiskFreeSpaceEx, - MoveFile, - SetFileTime, - SystemTimeToFileTime, - LocalFileTimeToFileTime, - FileTimeToLocalFileTime, - FileTimeToSystemTime, - GetSystemTime, - SetSystemTime, - GetLocalTime, - SetLocalTime, - GetTimeZoneInformation, - SetTimeZoneInformation, - timeSetEvent, - timeKillEvent, - ClearCommError, - EscapeCommFunction, - GetCommModemStatus, - GetCommState, - SetCommState, - PurgeComm, - SetCommTimeouts, - ExitProcess, - _snwprintf, - GetDesktopWindow, - GetForegroundWindow, - CreateWindowEx, - ShowWindow, - UpdateWindow, - DestroyWindow, - InvalidateRect, - GetWindowDC, - GetClientRect, - AdjustWindowRect, - SetDIBitsToDevice, - BitBlt, - GetDC, - ReleaseDC, - RegisterClassEx, - UnregisterClass, - BeginPaint, - EndPaint, - PostQuitMessage, - DefWindowProc, - LoadIcon, - LoadCursor, - GetStockObject, - SetViewportOrgEx, - SetWindowOrgEx, - MoveWindow, - GetWindowRect, - GetMessage, - TranslateMessage, - DispatchMessage, - GetProcessHeap, - HeapAlloc, - HeapFree, - QueryPerformanceCounter, - QueryPerformanceFrequency -}; - -#pragma warning(default : 4996) -#pragma warning(default : 4232) - -EFI_WIN_NT_THUNK_PROTOCOL *gWinNt = &mWinNtThunkTable; diff --git a/Nt32Pkg/SnpNt32Dxe/ComponentName.c b/Nt32Pkg/SnpNt32Dxe/ComponentName.c deleted file mode 100644 index 2f4efd0066..0000000000 --- a/Nt32Pkg/SnpNt32Dxe/ComponentName.c +++ /dev/null @@ -1,312 +0,0 @@ -/** @file - -Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - ComponentName.c - -Abstract: - - -**/ - -#include "SnpNt32.h" - -// -// EFI Component Name Functions -// -/** - Retrieves a Unicode string that is the user readable name of the driver. - - This function retrieves the user readable name of a driver in the form of a - Unicode string. If the driver specified by This has a user readable name in - the language specified by Language, then a pointer to the driver name is - returned in DriverName, and EFI_SUCCESS is returned. If the driver specified - by This does not support the language specified by Language, - then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified - in RFC 4646 or ISO 639-2 language code format. - - @param DriverName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - driver specified by This in the language - specified by Language. - - @retval EFI_SUCCESS The Unicode string for the Driver specified by - This and the language specified by Language was - returned in DriverName. - - @retval EFI_INVALID_PARAMETER Language is NULL. - - @retval EFI_INVALID_PARAMETER DriverName is NULL. - - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -SnpNt32DriverComponentNameGetDriverName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName - ); - - -/** - Retrieves a Unicode string that is the user readable name of the controller - that is being managed by a driver. - - This function retrieves the user readable name of the controller specified by - ControllerHandle and ChildHandle in the form of a Unicode string. If the - driver specified by This has a user readable name in the language specified by - Language, then a pointer to the controller name is returned in ControllerName, - and EFI_SUCCESS is returned. If the driver specified by This is not currently - managing the controller specified by ControllerHandle and ChildHandle, - then EFI_UNSUPPORTED is returned. If the driver specified by This does not - support the language specified by Language, then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - - @param ControllerHandle[in] The handle of a controller that the driver - specified by This is managing. This handle - specifies the controller whose name is to be - returned. - - @param ChildHandle[in] The handle of the child controller to retrieve - the name of. This is an optional parameter that - may be NULL. It will be NULL for device - drivers. It will also be NULL for a bus drivers - that wish to retrieve the name of the bus - controller. It will not be NULL for a bus - driver that wishes to retrieve the name of a - child controller. - - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified in - RFC 4646 or ISO 639-2 language code format. - - @param ControllerName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - controller specified by ControllerHandle and - ChildHandle in the language specified by - Language from the point of view of the driver - specified by This. - - @retval EFI_SUCCESS The Unicode string for the user readable name in - the language specified by Language for the - driver specified by This was returned in - DriverName. - - @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. - - @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid - EFI_HANDLE. - - @retval EFI_INVALID_PARAMETER Language is NULL. - - @retval EFI_INVALID_PARAMETER ControllerName is NULL. - - @retval EFI_UNSUPPORTED The driver specified by This is not currently - managing the controller specified by - ControllerHandle and ChildHandle. - - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -SnpNt32DriverComponentNameGetControllerName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName - ); - - -// -// EFI Component Name Protocol -// -GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gSnpNt32DriverComponentName = { - SnpNt32DriverComponentNameGetDriverName, - SnpNt32DriverComponentNameGetControllerName, - "eng" -}; - -// -// EFI Component Name 2 Protocol -// -GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gSnpNt32DriverComponentName2 = { - (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) SnpNt32DriverComponentNameGetDriverName, - (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) SnpNt32DriverComponentNameGetControllerName, - "en" -}; - - -GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mSnpNt32DriverNameTable[] = { - { - "eng;en", - L"SNP NT32 Driver" - }, - { - NULL, - NULL - } -}; - -/** - Retrieves a Unicode string that is the user readable name of the driver. - - This function retrieves the user readable name of a driver in the form of a - Unicode string. If the driver specified by This has a user readable name in - the language specified by Language, then a pointer to the driver name is - returned in DriverName, and EFI_SUCCESS is returned. If the driver specified - by This does not support the language specified by Language, - then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified - in RFC 4646 or ISO 639-2 language code format. - - @param DriverName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - driver specified by This in the language - specified by Language. - - @retval EFI_SUCCESS The Unicode string for the Driver specified by - This and the language specified by Language was - returned in DriverName. - - @retval EFI_INVALID_PARAMETER Language is NULL. - - @retval EFI_INVALID_PARAMETER DriverName is NULL. - - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -SnpNt32DriverComponentNameGetDriverName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName - ) -{ - return LookupUnicodeString2 ( - Language, - This->SupportedLanguages, - mSnpNt32DriverNameTable, - DriverName, - (BOOLEAN)(This == &gSnpNt32DriverComponentName) - ); -} - -/** - Retrieves a Unicode string that is the user readable name of the controller - that is being managed by a driver. - - This function retrieves the user readable name of the controller specified by - ControllerHandle and ChildHandle in the form of a Unicode string. If the - driver specified by This has a user readable name in the language specified by - Language, then a pointer to the controller name is returned in ControllerName, - and EFI_SUCCESS is returned. If the driver specified by This is not currently - managing the controller specified by ControllerHandle and ChildHandle, - then EFI_UNSUPPORTED is returned. If the driver specified by This does not - support the language specified by Language, then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - - @param ControllerHandle[in] The handle of a controller that the driver - specified by This is managing. This handle - specifies the controller whose name is to be - returned. - - @param ChildHandle[in] The handle of the child controller to retrieve - the name of. This is an optional parameter that - may be NULL. It will be NULL for device - drivers. It will also be NULL for a bus drivers - that wish to retrieve the name of the bus - controller. It will not be NULL for a bus - driver that wishes to retrieve the name of a - child controller. - - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified in - RFC 4646 or ISO 639-2 language code format. - - @param ControllerName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - controller specified by ControllerHandle and - ChildHandle in the language specified by - Language from the point of view of the driver - specified by This. - - @retval EFI_SUCCESS The Unicode string for the user readable name in - the language specified by Language for the - driver specified by This was returned in - DriverName. - - @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. - - @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid - EFI_HANDLE. - - @retval EFI_INVALID_PARAMETER Language is NULL. - - @retval EFI_INVALID_PARAMETER ControllerName is NULL. - - @retval EFI_UNSUPPORTED The driver specified by This is not currently - managing the controller specified by - ControllerHandle and ChildHandle. - - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -SnpNt32DriverComponentNameGetControllerName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName - ) -{ - return EFI_UNSUPPORTED; -} diff --git a/Nt32Pkg/SnpNt32Dxe/SnpNt32.c b/Nt32Pkg/SnpNt32Dxe/SnpNt32.c deleted file mode 100644 index 88c2e22bad..0000000000 --- a/Nt32Pkg/SnpNt32Dxe/SnpNt32.c +++ /dev/null @@ -1,1480 +0,0 @@ -/** @file - -Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - SnpNt32.c - -Abstract: - --**/ - -#include "SnpNt32.h" - -EFI_DRIVER_BINDING_PROTOCOL gSnpNt32DriverBinding = { - SnpNt32DriverBindingSupported, - SnpNt32DriverBindingStart, - SnpNt32DriverBindingStop, - 0xa, - NULL, - NULL -}; - -SNPNT32_GLOBAL_DATA gSnpNt32GlobalData = { - SNP_NT32_DRIVER_SIGNATURE, // Signature - { - NULL, - NULL - }, // InstanceList - NULL, // WinNtThunk - NULL, // NetworkLibraryHandle - { - 0 - }, // NtNetUtilityTable - { - 0, - 0, - EfiLockUninitialized - }, // Lock - // - // Private functions - // - SnpNt32InitializeGlobalData, // InitializeGlobalData - SnpNt32InitializeInstanceData, // InitializeInstanceData - SnpNt32CloseInstance // CloseInstance -}; - -/** - Changes the state of a network interface from "stopped" to "started". - - @param This Protocol instance pointer. - - @retval EFI_SUCCESS Always succeeds. - -**/ -EFI_STATUS -EFIAPI -SnpNt32Start ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This - ); - -/** - Changes the state of a network interface from "started" to "stopped". - - @param This Protocol instance pointer. - - @retval EFI_SUCCESS Always succeeds. - -**/ -EFI_STATUS -EFIAPI -SnpNt32Stop ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This - ); - -/** - Resets a network adapter and allocates the transmit and receive buffers - required by the network interface; optionally, also requests allocation - of additional transmit and receive buffers. - - @param This Protocol instance pointer. - @param ExtraRxBufferSize The size, in bytes, of the extra receive buffer space - that the driver should allocate for the network interface. - Some network interfaces will not be able to use the extra - buffer, and the caller will not know if it is actually - being used. - @param ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space - that the driver should allocate for the network interface. - Some network interfaces will not be able to use the extra - buffer, and the caller will not know if it is actually - being used. - - @retval EFI_SUCCESS Always succeeds. - -**/ -EFI_STATUS -EFIAPI -SnpNt32Initialize ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - IN UINTN ExtraRxBufferSize OPTIONAL, - IN UINTN ExtraTxBufferSize OPTIONAL - ); - -/** - Resets a network adapter and re-initializes it with the parameters that were - provided in the previous call to Initialize(). - - @param This Protocol instance pointer. - @param ExtendedVerification Indicates that the driver may perform a more - exhaustive verification operation of the device - during reset. - - @retval EFI_SUCCESS Always succeeds. - -**/ -EFI_STATUS -EFIAPI -SnpNt32Reset ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - IN BOOLEAN ExtendedVerification - ); - -/** - Resets a network adapter and leaves it in a state that is safe for - another driver to initialize. - - @param This Protocol instance pointer. - - @retval EFI_SUCCESS Always succeeds. - -**/ -EFI_STATUS -EFIAPI -SnpNt32Shutdown ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This - ); - -/** - Manages the multicast receive filters of a network interface. - - @param This Protocol instance pointer. - @param EnableBits A bit mask of receive filters to enable on the network interface. - @param DisableBits A bit mask of receive filters to disable on the network interface. - @param ResetMcastFilter Set to TRUE to reset the contents of the multicast receive - filters on the network interface to their default values. - @param McastFilterCount Number of multicast HW MAC addresses in the new - MCastFilter list. This value must be less than or equal to - the MCastFilterCnt field of EFI_SIMPLE_NETWORK_MODE. This - field is optional if ResetMCastFilter is TRUE. - @param McastFilter A pointer to a list of new multicast receive filter HW MAC - addresses. This list will replace any existing multicast - HW MAC address list. This field is optional if - ResetMCastFilter is TRUE. - - @retval EFI_SUCCESS The multicast receive filter list was updated. - @retval EFI_DEVICE_ERROR The command could not be sent to the network interface. - -**/ -EFI_STATUS -EFIAPI -SnpNt32ReceiveFilters ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - IN UINT32 EnableBits, - IN UINT32 DisableBits, - IN BOOLEAN ResetMcastFilter, - IN UINTN McastFilterCount OPTIONAL, - IN EFI_MAC_ADDRESS *McastFilter OPTIONAL - ); - -/** - Modifies or resets the current station address, if supported. - - @param This Protocol instance pointer. - @param Reset Flag used to reset the station address to the network interfaces - permanent address. - @param NewMacAddr New station address to be used for the network interface. - - @retval EFI_UNSUPPORTED Not supported yet. - -**/ -EFI_STATUS -EFIAPI -SnpNt32StationAddress ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - IN BOOLEAN Reset, - IN EFI_MAC_ADDRESS *NewMacAddr OPTIONAL - ); - -/** - Resets or collects the statistics on a network interface. - - @param This Protocol instance pointer. - @param Reset Set to TRUE to reset the statistics for the network interface. - @param StatisticsSize On input the size, in bytes, of StatisticsTable. On - output the size, in bytes, of the resulting table of - statistics. - @param StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that - contains the statistics. - - @retval EFI_SUCCESS The statistics were collected from the network interface. - @retval EFI_NOT_STARTED The network interface has not been started. - @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer - size needed to hold the statistics is returned in - StatisticsSize. - @retval EFI_UNSUPPORTED Not supported yet. - -**/ -EFI_STATUS -EFIAPI -SnpNt32Statistics ( - IN EFI_SIMPLE_NETWORK_PROTOCOL * This, - IN BOOLEAN Reset, - IN OUT UINTN *StatisticsSize OPTIONAL, - OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL - ); - -/** - Converts a multicast IP address to a multicast HW MAC address. - - @param This Protocol instance pointer. - @param Ipv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set - to FALSE if the multicast IP address is IPv4 [RFC 791]. - @param Ip The multicast IP address that is to be converted to a multicast - HW MAC address. - @param Mac The multicast HW MAC address that is to be generated from IP. - - @retval EFI_SUCCESS The multicast IP address was mapped to the multicast - HW MAC address. - @retval EFI_NOT_STARTED The network interface has not been started. - @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer - size needed to hold the statistics is returned in - StatisticsSize. - @retval EFI_UNSUPPORTED Not supported yet. - -**/ -EFI_STATUS -EFIAPI -SnpNt32McastIptoMac ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - IN BOOLEAN Ipv6, - IN EFI_IP_ADDRESS *Ip, - OUT EFI_MAC_ADDRESS *Mac - ); - -/** - Performs read and write operations on the NVRAM device attached to a - network interface. - - @param This Protocol instance pointer. - @param ReadOrWrite TRUE for read operations, FALSE for write operations. - @param Offset Byte offset in the NVRAM device at which to start the read or - write operation. This must be a multiple of NvRamAccessSize and - less than NvRamSize. - @param BufferSize The number of bytes to read or write from the NVRAM device. - This must also be a multiple of NvramAccessSize. - @param Buffer A pointer to the data buffer. - - @retval EFI_UNSUPPORTED Not supported yet. - -**/ -EFI_STATUS -EFIAPI -SnpNt32Nvdata ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - IN BOOLEAN ReadOrWrite, - IN UINTN Offset, - IN UINTN BufferSize, - IN OUT VOID *Buffer - ); - -/** - Reads the current interrupt status and recycled transmit buffer status from - a network interface. - - @param This Protocol instance pointer. - @param InterruptStatus A pointer to the bit mask of the currently active interrupts - If this is NULL, the interrupt status will not be read from - the device. If this is not NULL, the interrupt status will - be read from the device. When the interrupt status is read, - it will also be cleared. Clearing the transmit interrupt - does not empty the recycled transmit buffer array. - @param TxBuffer Recycled transmit buffer address. The network interface will - not transmit if its internal recycled transmit buffer array - is full. Reading the transmit buffer does not clear the - transmit interrupt. If this is NULL, then the transmit buffer - status will not be read. If there are no transmit buffers to - recycle and TxBuf is not NULL, * TxBuf will be set to NULL. - - @retval EFI_SUCCESS Always succeeds. - -**/ -EFI_STATUS -EFIAPI -SnpNt32GetStatus ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - OUT UINT32 *InterruptStatus, - OUT VOID **TxBuffer - ); - -/** - Places a packet in the transmit queue of a network interface. - - @param This Protocol instance pointer. - @param HeaderSize The size, in bytes, of the media header to be filled in by - the Transmit() function. If HeaderSize is non-zero, then it - must be equal to This->Mode->MediaHeaderSize and the DestAddr - and Protocol parameters must not be NULL. - @param BufferSize The size, in bytes, of the entire packet (media header and - data) to be transmitted through the network interface. - @param Buffer A pointer to the packet (media header followed by data) to be - transmitted. This parameter cannot be NULL. If HeaderSize is zero, - then the media header in Buffer must already be filled in by the - caller. If HeaderSize is non-zero, then the media header will be - filled in by the Transmit() function. - @param SrcAddr The source HW MAC address. If HeaderSize is zero, then this parameter - is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then - This->Mode->CurrentAddress is used for the source HW MAC address. - @param DestAddr The destination HW MAC address. If HeaderSize is zero, then this - parameter is ignored. - @param Protocol The type of header to build. If HeaderSize is zero, then this - parameter is ignored. See RFC 1700, section "Ether Types", for - examples. - - @retval EFI_SUCCESS The packet was placed on the transmit queue. - @retval EFI_DEVICE_ERROR The command could not be sent to the network interface. - @retval EFI_ACCESS_DENIED Error acquire global lock for operation. - -**/ -EFI_STATUS -EFIAPI -SnpNt32Transmit ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - IN UINTN HeaderSize, - IN UINTN BufferSize, - IN VOID *Buffer, - IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL, - IN EFI_MAC_ADDRESS *DestAddr OPTIONAL, - IN UINT16 *Protocol OPTIONAL - ); - -/** - Receives a packet from a network interface. - - @param This Protocol instance pointer. - @param HeaderSize The size, in bytes, of the media header received on the network - interface. If this parameter is NULL, then the media header size - will not be returned. - @param BuffSize On entry, the size, in bytes, of Buffer. On exit, the size, in - bytes, of the packet that was received on the network interface. - @param Buffer A pointer to the data buffer to receive both the media header and - the data. - @param SourceAddr The source HW MAC address. If this parameter is NULL, the - HW MAC source address will not be extracted from the media - header. - @param DestinationAddr The destination HW MAC address. If this parameter is NULL, - the HW MAC destination address will not be extracted from the - media header. - @param Protocol The media header type. If this parameter is NULL, then the - protocol will not be extracted from the media header. See - RFC 1700 section "Ether Types" for examples. - - @retval EFI_SUCCESS The received data was stored in Buffer, and BufferSize has - been updated to the number of bytes received. - @retval EFI_NOT_READY The network interface is too busy to accept this transmit - request. - @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small. - @retval EFI_DEVICE_ERROR The command could not be sent to the network interface. - @retval EFI_ACCESS_DENIED Error acquire global lock for operation. - -**/ -EFI_STATUS -EFIAPI -SnpNt32Receive ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - OUT UINTN *HeaderSize, - IN OUT UINTN *BuffSize, - OUT VOID *Buffer, - OUT EFI_MAC_ADDRESS *SourceAddr, - OUT EFI_MAC_ADDRESS *DestinationAddr, - OUT UINT16 *Protocol - ); - -SNPNT32_INSTANCE_DATA gSnpNt32InstanceTemplate = { - SNP_NT32_INSTANCE_SIGNATURE, // Signature - { - NULL, - NULL - }, // Entry - NULL, // RecycledTxBuf - 0, // RecycledTxBufCount - 32, // MaxRecycledTxBuf - NULL, // GlobalData - NULL, // DeviceHandle - NULL, // DevicePath - { // Snp - EFI_SIMPLE_NETWORK_PROTOCOL_REVISION, // Revision - SnpNt32Start, // Start - SnpNt32Stop, // Stop - SnpNt32Initialize, // Initialize - SnpNt32Reset, // Reset - SnpNt32Shutdown, // Shutdown - SnpNt32ReceiveFilters, // ReceiveFilters - SnpNt32StationAddress, // StationAddress - SnpNt32Statistics, // Statistics - SnpNt32McastIptoMac, // MCastIpToMac - SnpNt32Nvdata, // NvData - SnpNt32GetStatus, // GetStatus - SnpNt32Transmit, // Transmit - SnpNt32Receive, // Receive - NULL, // WaitForPacket - NULL // Mode - }, - { // Mode - EfiSimpleNetworkInitialized, // State - NET_ETHER_ADDR_LEN, // HwAddressSize - NET_ETHER_HEADER_SIZE, // MediaHeaderSize - 1500, // MaxPacketSize - 0, // NvRamSize - 0, // NvRamAccessSize - 0, // ReceiveFilterMask - 0, // ReceiveFilterSetting - MAX_MCAST_FILTER_CNT, // MaxMCastFilterCount - 0, // MCastFilterCount - { - 0 - }, // MCastFilter - { - 0 - }, // CurrentAddress - { - 0 - }, // BroadcastAddress - { - 0 - }, // PermanentAddress - NET_IFTYPE_ETHERNET, // IfType - FALSE, // MacAddressChangeable - FALSE, // MultipleTxSupported - TRUE, // MediaPresentSupported - TRUE // MediaPresent - }, - { - 0 - } // InterfaceInfo -}; - -/** - Test to see if this driver supports ControllerHandle. This service - is called by the EFI boot service ConnectController(). In - order to make drivers as small as possible, there are a few calling - restrictions for this service. ConnectController() must - follow these calling restrictions. If any other agent wishes to call - Supported() it must also follow these calling restrictions. - - @param This Protocol instance pointer. - @param ControllerHandle Handle of device to test - @param RemainingDevicePath Optional parameter use to pick a specific child - device to start. - - @retval EFI_SUCCESS This driver supports this device - @retval EFI_UNSUPPORTED This driver does not support this device - -**/ -EFI_STATUS -EFIAPI -SnpNt32DriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL * This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL - ) -{ - - SNPNT32_GLOBAL_DATA *GlobalData; - LIST_ENTRY *Entry; - SNPNT32_INSTANCE_DATA *Instance; - - GlobalData = &gSnpNt32GlobalData; - - NET_LIST_FOR_EACH (Entry, &GlobalData->InstanceList) { - - Instance = NET_LIST_USER_STRUCT_S (Entry, SNPNT32_INSTANCE_DATA, Entry, SNP_NT32_INSTANCE_SIGNATURE); - - if (Instance->DeviceHandle == ControllerHandle) { - return EFI_SUCCESS; - } - - } - - return EFI_UNSUPPORTED; -} - - -/** - Start this driver on ControllerHandle. This service is called by the - EFI boot service ConnectController(). In order to make - drivers as small as possible, there are a few calling restrictions for - this service. ConnectController() must follow these - calling restrictions. If any other agent wishes to call Start() it - must also follow these calling restrictions. - - @param This Protocol instance pointer. - @param ControllerHandle Handle of device to bind driver to - @param RemainingDevicePath Optional parameter use to pick a specific child - device to start. - - @retval EFI_SUCCESS Always succeeds. - -**/ -EFI_STATUS -EFIAPI -SnpNt32DriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL * This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL - ) -{ - return EFI_SUCCESS; -} - -/** - Stop this driver on ControllerHandle. This service is called by the - EFI boot service DisconnectController(). In order to - make drivers as small as possible, there are a few calling - restrictions for this service. DisconnectController() - must follow these calling restrictions. If any other agent wishes - to call Stop() it must also follow these calling restrictions. - - @param This Protocol instance pointer. - @param ControllerHandle Handle of device to stop driver on - @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of - children is zero stop the entire bus driver. - @param ChildHandleBuffer List of Child Handles to Stop. - - @retval EFI_SUCCESS Always succeeds. - -**/ -EFI_STATUS -EFIAPI -SnpNt32DriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer - ) -{ - return EFI_SUCCESS; -} - - -/** - Changes the state of a network interface from "stopped" to "started". - - @param This Protocol instance pointer. - - @retval EFI_SUCCESS Always succeeds. - -**/ -EFI_STATUS -EFIAPI -SnpNt32Start ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This - ) -{ - return EFI_SUCCESS; -} - - -/** - Changes the state of a network interface from "started" to "stopped". - - @param This Protocol instance pointer. - - @retval EFI_SUCCESS Always succeeds. - -**/ -EFI_STATUS -EFIAPI -SnpNt32Stop ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This - ) -{ - return EFI_SUCCESS; -} - -/** - Resets a network adapter and allocates the transmit and receive buffers - required by the network interface; optionally, also requests allocation - of additional transmit and receive buffers. - - @param This Protocol instance pointer. - @param ExtraRxBufferSize The size, in bytes, of the extra receive buffer space - that the driver should allocate for the network interface. - Some network interfaces will not be able to use the extra - buffer, and the caller will not know if it is actually - being used. - @param ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space - that the driver should allocate for the network interface. - Some network interfaces will not be able to use the extra - buffer, and the caller will not know if it is actually - being used. - - @retval EFI_SUCCESS Always succeeds. - -**/ -EFI_STATUS -EFIAPI -SnpNt32Initialize ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - IN UINTN ExtraRxBufferSize OPTIONAL, - IN UINTN ExtraTxBufferSize OPTIONAL - ) -{ - return EFI_SUCCESS; -} - -/** - Resets a network adapter and re-initializes it with the parameters that were - provided in the previous call to Initialize(). - - @param This Protocol instance pointer. - @param ExtendedVerification Indicates that the driver may perform a more - exhaustive verification operation of the device - during reset. - - @retval EFI_SUCCESS Always succeeds. - -**/ -EFI_STATUS -EFIAPI -SnpNt32Reset ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - IN BOOLEAN ExtendedVerification - ) -{ - return EFI_SUCCESS; -} - -/** - Resets a network adapter and leaves it in a state that is safe for - another driver to initialize. - - @param This Protocol instance pointer. - - @retval EFI_SUCCESS Always succeeds. - -**/ -EFI_STATUS -EFIAPI -SnpNt32Shutdown ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This - ) -{ - return EFI_SUCCESS; -} - -/** - Manages the multicast receive filters of a network interface. - - @param This Protocol instance pointer. - @param EnableBits A bit mask of receive filters to enable on the network interface. - @param DisableBits A bit mask of receive filters to disable on the network interface. - @param ResetMcastFilter Set to TRUE to reset the contents of the multicast receive - filters on the network interface to their default values. - @param McastFilterCount Number of multicast HW MAC addresses in the new - MCastFilter list. This value must be less than or equal to - the MCastFilterCnt field of EFI_SIMPLE_NETWORK_MODE. This - field is optional if ResetMCastFilter is TRUE. - @param McastFilter A pointer to a list of new multicast receive filter HW MAC - addresses. This list will replace any existing multicast - HW MAC address list. This field is optional if - ResetMCastFilter is TRUE. - - @retval EFI_SUCCESS The multicast receive filter list was updated. - @retval EFI_DEVICE_ERROR The command could not be sent to the network interface. - -**/ -EFI_STATUS -EFIAPI -SnpNt32ReceiveFilters ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - IN UINT32 EnableBits, - IN UINT32 DisableBits, - IN BOOLEAN ResetMcastFilter, - IN UINTN McastFilterCount OPTIONAL, - IN EFI_MAC_ADDRESS *McastFilter OPTIONAL - ) -{ - SNPNT32_INSTANCE_DATA *Instance; - SNPNT32_GLOBAL_DATA *GlobalData; - INT32 ReturnValue; - - Instance = SNP_NT32_INSTANCE_DATA_FROM_SNP_THIS (This); - - GlobalData = Instance->GlobalData; - - if (EFI_ERROR (EfiAcquireLockOrFail (&GlobalData->Lock))) { - return EFI_ACCESS_DENIED; - } - - ReturnValue = GlobalData->NtNetUtilityTable.SetReceiveFilter ( - Instance->InterfaceInfo.InterfaceIndex, - EnableBits, - (UINT32)McastFilterCount, - McastFilter - ); - - EfiReleaseLock (&GlobalData->Lock); - - if (ReturnValue <= 0) { - return EFI_DEVICE_ERROR; - } - - return EFI_SUCCESS; -} - -/** - Modifies or resets the current station address, if supported. - - @param This Protocol instance pointer. - @param Reset Flag used to reset the station address to the network interfaces - permanent address. - @param NewMacAddr New station address to be used for the network interface. - - @retval EFI_UNSUPPORTED Not supported yet. - -**/ -EFI_STATUS -EFIAPI -SnpNt32StationAddress ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - IN BOOLEAN Reset, - IN EFI_MAC_ADDRESS *NewMacAddr OPTIONAL - ) -{ - return EFI_UNSUPPORTED; -} - -/** - Resets or collects the statistics on a network interface. - - @param This Protocol instance pointer. - @param Reset Set to TRUE to reset the statistics for the network interface. - @param StatisticsSize On input the size, in bytes, of StatisticsTable. On - output the size, in bytes, of the resulting table of - statistics. - @param StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that - contains the statistics. - - @retval EFI_SUCCESS The statistics were collected from the network interface. - @retval EFI_NOT_STARTED The network interface has not been started. - @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer - size needed to hold the statistics is returned in - StatisticsSize. - @retval EFI_UNSUPPORTED Not supported yet. - -**/ -EFI_STATUS -EFIAPI -SnpNt32Statistics ( - IN EFI_SIMPLE_NETWORK_PROTOCOL * This, - IN BOOLEAN Reset, - IN OUT UINTN *StatisticsSize OPTIONAL, - OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL - ) -{ - return EFI_UNSUPPORTED; -} - -/** - Converts a multicast IP address to a multicast HW MAC address. - - @param This Protocol instance pointer. - @param Ipv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set - to FALSE if the multicast IP address is IPv4 [RFC 791]. - @param Ip The multicast IP address that is to be converted to a multicast - HW MAC address. - @param Mac The multicast HW MAC address that is to be generated from IP. - - @retval EFI_SUCCESS The multicast IP address was mapped to the multicast - HW MAC address. - @retval EFI_NOT_STARTED The network interface has not been started. - @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer - size needed to hold the statistics is returned in - StatisticsSize. - @retval EFI_UNSUPPORTED Not supported yet. - -**/ -EFI_STATUS -EFIAPI -SnpNt32McastIptoMac ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - IN BOOLEAN Ipv6, - IN EFI_IP_ADDRESS *Ip, - OUT EFI_MAC_ADDRESS *Mac - ) -{ - return EFI_UNSUPPORTED; -} - - -/** - Performs read and write operations on the NVRAM device attached to a - network interface. - - @param This Protocol instance pointer. - @param ReadOrWrite TRUE for read operations, FALSE for write operations. - @param Offset Byte offset in the NVRAM device at which to start the read or - write operation. This must be a multiple of NvRamAccessSize and - less than NvRamSize. - @param BufferSize The number of bytes to read or write from the NVRAM device. - This must also be a multiple of NvramAccessSize. - @param Buffer A pointer to the data buffer. - - @retval EFI_UNSUPPORTED Not supported yet. - -**/ -EFI_STATUS -EFIAPI -SnpNt32Nvdata ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - IN BOOLEAN ReadOrWrite, - IN UINTN Offset, - IN UINTN BufferSize, - IN OUT VOID *Buffer - ) -{ - return EFI_UNSUPPORTED; -} - - -/** - Reads the current interrupt status and recycled transmit buffer status from - a network interface. - - @param This Protocol instance pointer. - @param InterruptStatus A pointer to the bit mask of the currently active interrupts - If this is NULL, the interrupt status will not be read from - the device. If this is not NULL, the interrupt status will - be read from the device. When the interrupt status is read, - it will also be cleared. Clearing the transmit interrupt - does not empty the recycled transmit buffer array. - @param TxBuffer Recycled transmit buffer address. The network interface will - not transmit if its internal recycled transmit buffer array - is full. Reading the transmit buffer does not clear the - transmit interrupt. If this is NULL, then the transmit buffer - status will not be read. If there are no transmit buffers to - recycle and TxBuf is not NULL, * TxBuf will be set to NULL. - - @retval EFI_SUCCESS Always succeeds. - -**/ -EFI_STATUS -EFIAPI -SnpNt32GetStatus ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - OUT UINT32 *InterruptStatus, - OUT VOID **TxBuffer - ) -{ - SNPNT32_INSTANCE_DATA *Instance; - - Instance = SNP_NT32_INSTANCE_DATA_FROM_SNP_THIS (This); - - if (TxBuffer != NULL) { - if (Instance->RecycledTxBufCount != 0) { - Instance->RecycledTxBufCount --; - *((UINT8 **) TxBuffer) = (UINT8 *) (UINTN)Instance->RecycledTxBuf[Instance->RecycledTxBufCount]; - } else { - *((UINT8 **) TxBuffer) = NULL; - } - } - - if (InterruptStatus != NULL) { - *InterruptStatus = EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT; - } - - return EFI_SUCCESS; -} - - -/** - Places a packet in the transmit queue of a network interface. - - @param This Protocol instance pointer. - @param HeaderSize The size, in bytes, of the media header to be filled in by - the Transmit() function. If HeaderSize is non-zero, then it - must be equal to This->Mode->MediaHeaderSize and the DestAddr - and Protocol parameters must not be NULL. - @param BufferSize The size, in bytes, of the entire packet (media header and - data) to be transmitted through the network interface. - @param Buffer A pointer to the packet (media header followed by data) to be - transmitted. This parameter cannot be NULL. If HeaderSize is zero, - then the media header in Buffer must already be filled in by the - caller. If HeaderSize is non-zero, then the media header will be - filled in by the Transmit() function. - @param SrcAddr The source HW MAC address. If HeaderSize is zero, then this parameter - is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then - This->Mode->CurrentAddress is used for the source HW MAC address. - @param DestAddr The destination HW MAC address. If HeaderSize is zero, then this - parameter is ignored. - @param Protocol The type of header to build. If HeaderSize is zero, then this - parameter is ignored. See RFC 1700, section "Ether Types", for - examples. - - @retval EFI_SUCCESS The packet was placed on the transmit queue. - @retval EFI_DEVICE_ERROR The command could not be sent to the network interface. - @retval EFI_ACCESS_DENIED Error acquire global lock for operation. - -**/ -EFI_STATUS -EFIAPI -SnpNt32Transmit ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - IN UINTN HeaderSize, - IN UINTN BufferSize, - IN VOID *Buffer, - IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL, - IN EFI_MAC_ADDRESS *DestAddr OPTIONAL, - IN UINT16 *Protocol OPTIONAL - ) -{ - SNPNT32_INSTANCE_DATA *Instance; - SNPNT32_GLOBAL_DATA *GlobalData; - INT32 ReturnValue; - UINT64 *Tmp; - - Instance = SNP_NT32_INSTANCE_DATA_FROM_SNP_THIS (This); - - GlobalData = Instance->GlobalData; - - if ((HeaderSize != 0) && (SrcAddr == NULL)) { - SrcAddr = &Instance->Mode.CurrentAddress; - } - - if (EFI_ERROR (EfiAcquireLockOrFail (&GlobalData->Lock))) { - return EFI_ACCESS_DENIED; - } - - ReturnValue = GlobalData->NtNetUtilityTable.Transmit ( - Instance->InterfaceInfo.InterfaceIndex, - (UINT32)HeaderSize, - (UINT32)BufferSize, - Buffer, - SrcAddr, - DestAddr, - Protocol - ); - - EfiReleaseLock (&GlobalData->Lock); - - if (ReturnValue < 0) { - return EFI_DEVICE_ERROR; - } else { - if ((Instance->MaxRecycledTxBuf + SNP_TX_BUFFER_INCREASEMENT) >= SNP_MAX_TX_BUFFER_NUM) { - return EFI_NOT_READY; - } - - if (Instance->RecycledTxBufCount < Instance->MaxRecycledTxBuf) { - Instance->RecycledTxBuf[Instance->RecycledTxBufCount] = (UINT64) Buffer; - Instance->RecycledTxBufCount ++; - } else { - Tmp = AllocatePool (sizeof (UINT64) * (Instance->MaxRecycledTxBuf + SNP_TX_BUFFER_INCREASEMENT)); - if (Tmp == NULL) { - return EFI_DEVICE_ERROR; - } - CopyMem (Tmp, Instance->RecycledTxBuf, sizeof (UINT64) * Instance->RecycledTxBufCount); - FreePool (Instance->RecycledTxBuf); - Instance->RecycledTxBuf = Tmp; - Instance->MaxRecycledTxBuf += SNP_TX_BUFFER_INCREASEMENT; - } - } - - return EFI_SUCCESS; -} - -/** - Receives a packet from a network interface. - - @param This Protocol instance pointer. - @param HeaderSize The size, in bytes, of the media header received on the network - interface. If this parameter is NULL, then the media header size - will not be returned. - @param BuffSize On entry, the size, in bytes, of Buffer. On exit, the size, in - bytes, of the packet that was received on the network interface. - @param Buffer A pointer to the data buffer to receive both the media header and - the data. - @param SourceAddr The source HW MAC address. If this parameter is NULL, the - HW MAC source address will not be extracted from the media - header. - @param DestinationAddr The destination HW MAC address. If this parameter is NULL, - the HW MAC destination address will not be extracted from the - media header. - @param Protocol The media header type. If this parameter is NULL, then the - protocol will not be extracted from the media header. See - RFC 1700 section "Ether Types" for examples. - - @retval EFI_SUCCESS The received data was stored in Buffer, and BufferSize has - been updated to the number of bytes received. - @retval EFI_NOT_READY The network interface is too busy to accept this transmit - request. - @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small. - @retval EFI_DEVICE_ERROR The command could not be sent to the network interface. - @retval EFI_ACCESS_DENIED Error acquire global lock for operation. - -**/ -EFI_STATUS -EFIAPI -SnpNt32Receive ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - OUT UINTN *HeaderSize, - IN OUT UINTN *BuffSize, - OUT VOID *Buffer, - OUT EFI_MAC_ADDRESS *SourceAddr, - OUT EFI_MAC_ADDRESS *DestinationAddr, - OUT UINT16 *Protocol - ) -{ - SNPNT32_INSTANCE_DATA *Instance; - SNPNT32_GLOBAL_DATA *GlobalData; - INT32 ReturnValue; - UINTN BufSize; - - BufSize = *BuffSize; - - Instance = SNP_NT32_INSTANCE_DATA_FROM_SNP_THIS (This); - - GlobalData = Instance->GlobalData; - - ASSERT (GlobalData->NtNetUtilityTable.Receive != NULL); - - if (EFI_ERROR (EfiAcquireLockOrFail (&GlobalData->Lock))) { - return EFI_ACCESS_DENIED; - } - - ReturnValue = GlobalData->NtNetUtilityTable.Receive ( - Instance->InterfaceInfo.InterfaceIndex, - BuffSize, - Buffer - ); - - EfiReleaseLock (&GlobalData->Lock); - - if (ReturnValue < 0) { - if (ReturnValue == -100) { - return EFI_BUFFER_TOO_SMALL; - } - - return EFI_DEVICE_ERROR; - } else if (ReturnValue == 0) { - return EFI_NOT_READY; - } - - if (HeaderSize != NULL) { - *HeaderSize = 14; - } - - if (SourceAddr != NULL) { - ZeroMem (SourceAddr, sizeof (EFI_MAC_ADDRESS)); - CopyMem (SourceAddr, ((UINT8 *) Buffer) + 6, 6); - } - - if (DestinationAddr != NULL) { - ZeroMem (DestinationAddr, sizeof (EFI_MAC_ADDRESS)); - CopyMem (DestinationAddr, ((UINT8 *) Buffer), 6); - } - - if (Protocol != NULL) { - *Protocol = NTOHS (*((UINT16 *) (((UINT8 *) Buffer) + 12))); - } - - return (*BuffSize <= BufSize) ? EFI_SUCCESS : EFI_BUFFER_TOO_SMALL; -} - -/** - Initialize the driver's global data. - - @param This Pointer to the global context data. - - @retval EFI_SUCCESS The global data is initialized. - @retval EFI_NOT_FOUND The required DLL is not found. - @retval EFI_DEVICE_ERROR Error initialize network utility library. - @retval EFI_OUT_OF_RESOURCES Out of resource. - @retval other Other errors. - -**/ -EFI_STATUS -SnpNt32InitializeGlobalData ( - IN OUT SNPNT32_GLOBAL_DATA *This - ) -{ - EFI_STATUS Status; - CHAR16 *DllFileNameU; - UINT32 Index; - INT32 ReturnValue; - BOOLEAN NetUtilityLibInitDone; - NT_NET_INTERFACE_INFO NetInterfaceInfoBuffer[MAX_INTERFACE_INFO_NUMBER]; - SNPNT32_INSTANCE_DATA *Instance; - LIST_ENTRY *Entry; - UINT32 InterfaceCount; - - ASSERT (This != NULL); - - NetUtilityLibInitDone = FALSE; - InterfaceCount = MAX_INTERFACE_INFO_NUMBER; - - InitializeListHead (&This->InstanceList); - EfiInitializeLock (&This->Lock, TPL_CALLBACK); - - // - // Get the WinNT thunk - // - Status = gBS->LocateProtocol (&gEfiWinNtThunkProtocolGuid, NULL, (VOID **)&This->WinNtThunk); - - if (EFI_ERROR (Status)) { - return Status; - } - - ASSERT (This->WinNtThunk != NULL); - - DllFileNameU = NETWORK_LIBRARY_NAME_U; - - // - // Load network utility library - // - This->NetworkLibraryHandle = This->WinNtThunk->LoadLibraryEx (DllFileNameU, NULL, 0); - - if (NULL == This->NetworkLibraryHandle) { - return EFI_NOT_FOUND; - } - - This->NtNetUtilityTable.Initialize = (NT_NET_INITIALIZE) This->WinNtThunk->GetProcAddress ( - This->NetworkLibraryHandle, - NETWORK_LIBRARY_INITIALIZE - ); - - if (NULL == This->NtNetUtilityTable.Initialize) { - Status = EFI_NOT_FOUND; - goto ErrorReturn; - } - - This->NtNetUtilityTable.Finalize = (NT_NET_FINALIZE) This->WinNtThunk->GetProcAddress ( - This->NetworkLibraryHandle, - NETWORK_LIBRARY_FINALIZE - ); - - if (NULL == This->NtNetUtilityTable.Finalize) { - Status = EFI_NOT_FOUND; - goto ErrorReturn; - } - - This->NtNetUtilityTable.SetReceiveFilter = (NT_NET_SET_RECEIVE_FILTER) This->WinNtThunk->GetProcAddress ( - This->NetworkLibraryHandle, - NETWORK_LIBRARY_SET_RCV_FILTER - ); - - if (NULL == This->NtNetUtilityTable.SetReceiveFilter) { - Status = EFI_NOT_FOUND; - goto ErrorReturn; - } - - This->NtNetUtilityTable.Receive = (NT_NET_RECEIVE) This->WinNtThunk->GetProcAddress ( - This->NetworkLibraryHandle, - NETWORK_LIBRARY_RECEIVE - ); - - if (NULL == This->NtNetUtilityTable.Receive) { - Status = EFI_NOT_FOUND; - goto ErrorReturn; - } - - This->NtNetUtilityTable.Transmit = (NT_NET_TRANSMIT) This->WinNtThunk->GetProcAddress ( - This->NetworkLibraryHandle, - NETWORK_LIBRARY_TRANSMIT - ); - - if (NULL == This->NtNetUtilityTable.Transmit) { - Status = EFI_NOT_FOUND; - goto ErrorReturn; - } - // - // Initialize the network utility library - // And enumerate the interfaces in NT32 host - // - ReturnValue = This->NtNetUtilityTable.Initialize (&InterfaceCount, &NetInterfaceInfoBuffer[0]); - if (ReturnValue <= 0) { - Status = EFI_DEVICE_ERROR; - goto ErrorReturn; - } - - NetUtilityLibInitDone = TRUE; - - if (InterfaceCount == 0) { - Status = EFI_NOT_FOUND; - goto ErrorReturn; - } - // - // Create fake SNP instances - // - for (Index = 0; Index < InterfaceCount; Index++) { - - Instance = AllocateZeroPool (sizeof (SNPNT32_INSTANCE_DATA)); - - if (NULL == Instance) { - Status = EFI_OUT_OF_RESOURCES; - goto ErrorReturn; - } - // - // Copy the content from a template - // - CopyMem (Instance, &gSnpNt32InstanceTemplate, sizeof (SNPNT32_INSTANCE_DATA)); - - // - // Allocate the RecycledTxBuf. - // - Instance->RecycledTxBuf = AllocatePool (sizeof (UINT64) * Instance->MaxRecycledTxBuf); - if (Instance->RecycledTxBuf == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - // - // Set the interface information. - // - CopyMem (&Instance->InterfaceInfo, &NetInterfaceInfoBuffer[Index], sizeof(Instance->InterfaceInfo)); - // - // Initialize this instance - // - Status = This->InitializeInstanceData (This, Instance); - if (EFI_ERROR (Status)) { - - gBS->FreePool (Instance); - goto ErrorReturn; - } - // - // Insert this instance into the instance list - // - InsertTailList (&This->InstanceList, &Instance->Entry); - } - - return EFI_SUCCESS; - -ErrorReturn: - - while (!IsListEmpty (&This->InstanceList)) { - - Entry = This->InstanceList.ForwardLink; - - Instance = NET_LIST_USER_STRUCT_S (Entry, SNPNT32_INSTANCE_DATA, Entry, SNP_NT32_INSTANCE_SIGNATURE); - - RemoveEntryList (Entry); - - This->CloseInstance (This, Instance); - gBS->FreePool (Instance); - } - - if (NetUtilityLibInitDone) { - - ASSERT (This->WinNtThunk != NULL); - - if (This->NtNetUtilityTable.Finalize != NULL) { - This->NtNetUtilityTable.Finalize (); - This->NtNetUtilityTable.Finalize = NULL; - } - } - - return Status; -} - - -/** - Initialize the snpnt32 driver instance. - - @param This Pointer to the SnpNt32 global data. - @param Instance Pointer to the instance context data. - - @retval EFI_SUCCESS The driver instance is initialized. - @retval other Initialization errors. - -**/ -EFI_STATUS -SnpNt32InitializeInstanceData ( - IN SNPNT32_GLOBAL_DATA *This, - IN OUT SNPNT32_INSTANCE_DATA *Instance - ) -{ - EFI_STATUS Status; - EFI_DEV_PATH EndNode; - EFI_DEV_PATH Node; - - Instance->GlobalData = This; - Instance->Snp.Mode = &Instance->Mode; - // - // Set broadcast address - // - SetMem (&Instance->Mode.BroadcastAddress, sizeof (EFI_MAC_ADDRESS), 0xFF); - - // - // Copy Current/PermanentAddress MAC address - // - CopyMem (&Instance->Mode.CurrentAddress, &Instance->InterfaceInfo.MacAddr, sizeof(Instance->Mode.CurrentAddress)); - CopyMem (&Instance->Mode.PermanentAddress, &Instance->InterfaceInfo.MacAddr, sizeof(Instance->Mode.PermanentAddress)); - - // - // Since the fake SNP is based on a real NIC, to avoid conflict with the host - // NIC network stack, we use a different MAC address. - // So just change the last byte of the MAC address for the real NIC. - // - Instance->Mode.CurrentAddress.Addr[NET_ETHER_ADDR_LEN - 1]++; - - // - // Create a fake device path for the instance - // - ZeroMem (&Node, sizeof (Node)); - - Node.DevPath.Type = MESSAGING_DEVICE_PATH; - Node.DevPath.SubType = MSG_MAC_ADDR_DP; - SetDevicePathNodeLength (&Node.DevPath, sizeof (MAC_ADDR_DEVICE_PATH)); - - CopyMem ( - &Node.MacAddr.MacAddress, - &Instance->Mode.CurrentAddress, - NET_ETHER_ADDR_LEN - ); - - Node.MacAddr.IfType = Instance->Mode.IfType; - - SetDevicePathEndNode (&EndNode.DevPath); - - Instance->DevicePath = AppendDevicePathNode ( - &EndNode.DevPath, - &Node.DevPath - ); - - // - // Create a fake device handle for the fake SNP - // - Status = gBS->InstallMultipleProtocolInterfaces ( - &Instance->DeviceHandle, - &gEfiSimpleNetworkProtocolGuid, - &Instance->Snp, - &gEfiDevicePathProtocolGuid, - Instance->DevicePath, - NULL - ); - return Status; -} - - -/** - Close the SnpNt32 driver instance. - - @param This Pointer to the SnpNt32 global data. - @param Instance Pointer to the instance context data. - - @retval EFI_SUCCESS The instance is closed. - -**/ -EFI_STATUS -SnpNt32CloseInstance ( - IN SNPNT32_GLOBAL_DATA *This, - IN OUT SNPNT32_INSTANCE_DATA *Instance - ) -{ - ASSERT (This != NULL); - ASSERT (Instance != NULL); - - gBS->UninstallMultipleProtocolInterfaces ( - Instance->DeviceHandle, - &gEfiSimpleNetworkProtocolGuid, - &Instance->Snp, - &gEfiDevicePathProtocolGuid, - Instance->DevicePath, - NULL - ); - - if (Instance->DevicePath != NULL) { - gBS->FreePool (Instance->DevicePath); - } - - return EFI_SUCCESS; -} - -/** - Unloads an image. - - @param ImageHandle Handle that identifies the image to be unloaded. - - @retval EFI_SUCCESS The image has been unloaded. - @return Exit code from the image's unload handler - -**/ -EFI_STATUS -EFIAPI -SnpNt32Unload ( - IN EFI_HANDLE ImageHandle - ) -{ - EFI_STATUS Status; - SNPNT32_GLOBAL_DATA *This; - LIST_ENTRY *Entry; - SNPNT32_INSTANCE_DATA *Instance; - - This = &gSnpNt32GlobalData; - - Status = NetLibDefaultUnload (ImageHandle); - - if (EFI_ERROR (Status)) { - return Status; - } - - while (!IsListEmpty (&This->InstanceList)) { - // - // Walkthrough the interfaces and remove all the SNP instance - // - Entry = This->InstanceList.ForwardLink; - - Instance = NET_LIST_USER_STRUCT_S (Entry, SNPNT32_INSTANCE_DATA, Entry, SNP_NT32_INSTANCE_SIGNATURE); - - RemoveEntryList (Entry); - - This->CloseInstance (This, Instance); - gBS->FreePool (Instance); - } - - if (This->NtNetUtilityTable.Finalize != NULL) { - This->NtNetUtilityTable.Finalize (); - } - - This->WinNtThunk->FreeLibrary (This->NetworkLibraryHandle); - - return EFI_SUCCESS; -} - -/** - 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 - both device drivers and bus drivers. - - @param ImageHandle The firmware allocated handle for the UEFI image. - @param SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS The operation completed successfully. - @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. - -**/ -EFI_STATUS -InitializeSnpNt32Driver ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - - EFI_STATUS Status; - - // - // Install the Driver Protocols - // - - Status = EfiLibInstallDriverBindingComponentName2 ( - ImageHandle, - SystemTable, - &gSnpNt32DriverBinding, - ImageHandle, - &gSnpNt32DriverComponentName, - &gSnpNt32DriverComponentName2 - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Initialize the global data - // - Status = SnpNt32InitializeGlobalData (&gSnpNt32GlobalData); - if (EFI_ERROR (Status)) { - SnpNt32Unload (ImageHandle); - } - - return Status; -} diff --git a/Nt32Pkg/SnpNt32Dxe/SnpNt32.h b/Nt32Pkg/SnpNt32Dxe/SnpNt32.h deleted file mode 100644 index 9939c6bd64..0000000000 --- a/Nt32Pkg/SnpNt32Dxe/SnpNt32.h +++ /dev/null @@ -1,343 +0,0 @@ -/** @file - -Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - SnpNt32.h - -Abstract: - --**/ - -#ifndef _SNP_NT32_H_ -#define _SNP_NT32_H_ - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -typedef struct _SNPNT32_GLOBAL_DATA SNPNT32_GLOBAL_DATA; -typedef struct _SNPNT32_INSTANCE_DATA SNPNT32_INSTANCE_DATA; - -#define NETWORK_LIBRARY_NAME_U L"SnpNt32Io.dll" - -#define NETWORK_LIBRARY_INITIALIZE "SnpInitialize" -#define NETWORK_LIBRARY_FINALIZE "SnpFinalize" -#define NETWORK_LIBRARY_SET_RCV_FILTER "SnpSetReceiveFilter" -#define NETWORK_LIBRARY_RECEIVE "SnpReceive" -#define NETWORK_LIBRARY_TRANSMIT "SnpTransmit" - -#pragma pack(1) -typedef struct _NT_NET_INTERFACE_INFO { - UINT32 InterfaceIndex; - EFI_MAC_ADDRESS MacAddr; -} NT_NET_INTERFACE_INFO; -#pragma pack() - -#define NET_ETHER_HEADER_SIZE 14 - -#define MAX_INTERFACE_INFO_NUMBER 16 -#define MAX_FILE_NAME_LENGTH 280 - -#define SNP_MAX_TX_BUFFER_NUM 65536 -#define SNP_TX_BUFFER_INCREASEMENT 32 - - - - -// -// Functions in Net Library -// -typedef -INT32 -(*NT_NET_INITIALIZE) ( - IN OUT UINT32 *InterfaceCount, - IN OUT NT_NET_INTERFACE_INFO * InterfaceInfoBuffer - ); - -typedef -INT32 -(*NT_NET_FINALIZE) ( - VOID - ); - -typedef -INT32 -(*NT_NET_SET_RECEIVE_FILTER) ( - IN UINT32 Index, - IN UINT32 EnableFilter, - IN UINT32 MCastFilterCnt, - IN EFI_MAC_ADDRESS * MCastFilter - ); - -typedef -INT32 -(*NT_NET_RECEIVE) ( - IN UINT32 Index, - IN OUT UINT32 *BufferSize, - OUT VOID *Buffer - ); - -typedef -INT32 -(*NT_NET_TRANSMIT) ( - IN UINT32 Index, - IN UINT32 HeaderSize, - IN UINT32 BufferSize, - IN VOID *Buffer, - IN EFI_MAC_ADDRESS * SrcAddr, - IN EFI_MAC_ADDRESS * DestAddr, - IN UINT16 *Protocol - ); - -typedef struct _NT_NET_UTILITY_TABLE { - NT_NET_INITIALIZE Initialize; - NT_NET_FINALIZE Finalize; - NT_NET_SET_RECEIVE_FILTER SetReceiveFilter; - NT_NET_RECEIVE Receive; - NT_NET_TRANSMIT Transmit; -} NT_NET_UTILITY_TABLE; - -// -// Private functions -// -typedef -EFI_STATUS -(*SNPNT32_INITIALIZE_GLOBAL_DATA) ( - IN SNPNT32_GLOBAL_DATA * This - ); - -typedef -EFI_STATUS -(*SNPNT32_INITIALIZE_INSTANCE_DATA) ( - IN SNPNT32_GLOBAL_DATA * This, - IN SNPNT32_INSTANCE_DATA * Instance - ); - -typedef -EFI_STATUS -(*SNPNT32_CLOSE_INSTANCE) ( - IN SNPNT32_GLOBAL_DATA * This, - IN SNPNT32_INSTANCE_DATA * Instance - ); - -// -// Global data for this driver -// -#define SNP_NT32_DRIVER_SIGNATURE SIGNATURE_32 ('W', 'S', 'N', 'P') - -struct _SNPNT32_GLOBAL_DATA { - UINT32 Signature; - - // - // List for all the fake SNP instance - // - LIST_ENTRY InstanceList; - - EFI_WIN_NT_THUNK_PROTOCOL *WinNtThunk; - HMODULE NetworkLibraryHandle; - - NT_NET_UTILITY_TABLE NtNetUtilityTable; - - EFI_LOCK Lock; - - // - // Private functions - // - SNPNT32_INITIALIZE_GLOBAL_DATA InitializeGlobalData; - SNPNT32_INITIALIZE_INSTANCE_DATA InitializeInstanceData; - SNPNT32_CLOSE_INSTANCE CloseInstance; -}; - -// -// Instance data for each fake SNP instance -// -#define SNP_NT32_INSTANCE_SIGNATURE SIGNATURE_32 ('w', 'S', 'N', 'P') - -struct _SNPNT32_INSTANCE_DATA { - UINT32 Signature; - - // - // List entry use for linking with other instance - // - LIST_ENTRY Entry; - - // - // Array of the recycled transmit buffer address. - // - UINT64 *RecycledTxBuf; - - // - // Current number of recycled buffer pointers in RecycledTxBuf. - // - UINT32 RecycledTxBufCount; - - // - // The maximum number of recycled buffer pointers in RecycledTxBuf. - // - UINT32 MaxRecycledTxBuf; - - SNPNT32_GLOBAL_DATA *GlobalData; - - EFI_HANDLE DeviceHandle; - EFI_DEVICE_PATH_PROTOCOL *DevicePath; - - EFI_SIMPLE_NETWORK_PROTOCOL Snp; - EFI_SIMPLE_NETWORK_MODE Mode; - - NT_NET_INTERFACE_INFO InterfaceInfo; - - // - // Private functions - // -}; - -#define SNP_NT32_INSTANCE_DATA_FROM_SNP_THIS(a) \ - CR ( \ - a, \ - SNPNT32_INSTANCE_DATA, \ - Snp, \ - SNP_NT32_INSTANCE_SIGNATURE \ - ) - -extern EFI_DRIVER_BINDING_PROTOCOL gSnpNt32DriverBinding; -extern EFI_COMPONENT_NAME_PROTOCOL gSnpNt32DriverComponentName; -extern EFI_COMPONENT_NAME2_PROTOCOL gSnpNt32DriverComponentName2; - -/** - Test to see if this driver supports ControllerHandle. This service - is called by the EFI boot service ConnectController(). In - order to make drivers as small as possible, there are a few calling - restrictions for this service. ConnectController() must - follow these calling restrictions. If any other agent wishes to call - Supported() it must also follow these calling restrictions. - - @param This Protocol instance pointer. - @param ControllerHandle Handle of device to test - @param RemainingDevicePath Optional parameter use to pick a specific child - device to start. - - @retval EFI_SUCCESS This driver supports this device - @retval EFI_UNSUPPORTED This driver does not support this device - -**/ -EFI_STATUS -EFIAPI -SnpNt32DriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL * This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL - ); - -/** - Start this driver on ControllerHandle. This service is called by the - EFI boot service ConnectController(). In order to make - drivers as small as possible, there are a few calling restrictions for - this service. ConnectController() must follow these - calling restrictions. If any other agent wishes to call Start() it - must also follow these calling restrictions. - - @param This Protocol instance pointer. - @param ControllerHandle Handle of device to bind driver to - @param RemainingDevicePath Optional parameter use to pick a specific child - device to start. - - @retval EFI_SUCCESS Always succeeds. - -**/ -EFI_STATUS -EFIAPI -SnpNt32DriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL * This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL - ); - -/** - Stop this driver on ControllerHandle. This service is called by the - EFI boot service DisconnectController(). In order to - make drivers as small as possible, there are a few calling - restrictions for this service. DisconnectController() - must follow these calling restrictions. If any other agent wishes - to call Stop() it must also follow these calling restrictions. - - @param This Protocol instance pointer. - @param ControllerHandle Handle of device to stop driver on - @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of - children is zero stop the entire bus driver. - @param ChildHandleBuffer List of Child Handles to Stop. - - @retval EFI_SUCCESS Always succeeds. - -**/ -EFI_STATUS -EFIAPI -SnpNt32DriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer - ); - -/** - Initialize the driver's global data. - - @param This Pointer to the global context data. - - @retval EFI_SUCCESS The global data is initialized. - @retval EFI_NOT_FOUND The required DLL is not found. - @retval EFI_DEVICE_ERROR Error initialize network utility library. - @retval EFI_OUT_OF_RESOURCES Out of resource. - @retval other Other errors. - -**/ -EFI_STATUS -SnpNt32InitializeGlobalData ( - IN OUT SNPNT32_GLOBAL_DATA *This - ); - -/** - Initialize the snpnt32 driver instance. - - @param This Pointer to the SnpNt32 global data. - @param Instance Pointer to the instance context data. - - @retval EFI_SUCCESS The driver instance is initialized. - @retval other Initialization errors. - -**/ -EFI_STATUS -SnpNt32InitializeInstanceData ( - IN SNPNT32_GLOBAL_DATA *This, - IN OUT SNPNT32_INSTANCE_DATA *Instance - ); - -/** - Close the SnpNt32 driver instance. - - @param This Pointer to the SnpNt32 global data. - @param Instance Pointer to the instance context data. - - @retval EFI_SUCCESS The instance is closed. - -**/ -EFI_STATUS -SnpNt32CloseInstance ( - IN SNPNT32_GLOBAL_DATA *This, - IN OUT SNPNT32_INSTANCE_DATA *Instance - ); - -#endif diff --git a/Nt32Pkg/SnpNt32Dxe/SnpNt32Dxe.inf b/Nt32Pkg/SnpNt32Dxe/SnpNt32Dxe.inf deleted file mode 100644 index 38758b1de8..0000000000 --- a/Nt32Pkg/SnpNt32Dxe/SnpNt32Dxe.inf +++ /dev/null @@ -1,48 +0,0 @@ -## @file -# Component name for module SnpNt32Dxe -# -# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
-# -# SPDX-License-Identifier: BSD-2-Clause-Patent -# -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = SnpNt32Dxe - FILE_GUID = D0893F05-B06D-4161-B947-9BE9B85AC3A1 - MODULE_TYPE = UEFI_DRIVER - VERSION_STRING = 1.0 - - ENTRY_POINT = InitializeSnpNt32Driver - UNLOAD_IMAGE = SnpNt32Unload -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 EBC -# - -[Sources] - ComponentName.c - SnpNt32.h - SnpNt32.c - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - Nt32Pkg/Nt32Pkg.dec - -[LibraryClasses] - DevicePathLib - UefiLib - UefiBootServicesTableLib - BaseMemoryLib - DebugLib - UefiDriverEntryPoint - NetLib - -[Protocols] - gEfiSimpleNetworkProtocolGuid # PROTOCOL ALWAYS_CONSUMED - gEfiDevicePathProtocolGuid # PROTOCOL ALWAYS_CONSUMED - gEfiWinNtThunkProtocolGuid # PROTOCOL ALWAYS_CONSUMED diff --git a/Nt32Pkg/StallPei/Stall.c b/Nt32Pkg/StallPei/Stall.c deleted file mode 100644 index 69b99cc5d4..0000000000 --- a/Nt32Pkg/StallPei/Stall.c +++ /dev/null @@ -1,100 +0,0 @@ -/**@file - EFI_PEI_STALL implementation for NT32 simulation environment. - -Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ -#include "WinNtPeim.h" - -#include -#include -#include - -EFI_STATUS -EFIAPI -Stall ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_STALL_PPI *This, - IN UINTN Microseconds - ); - -EFI_PEI_STALL_PPI mStallPpi = {1000, Stall}; - -EFI_PEI_PPI_DESCRIPTOR mPpiListStall[1] = { - { - (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), - &gEfiPeiStallPpiGuid, - &mStallPpi - } -}; - - -/** - PEIM's entry point. - - This routine installs the simulation instance of EFI_PEI_STALL_PPI based - on Win API Sleep(). - - @param FileHandle Handle of the file being invoked. - @param PeiServices Describes the list of possible PEI Services. - - @retval EFI_SUCCESS The PEIM executed normally. - @retval !EFI_SUCCESS The PEIM failed to execute normally. -**/ -EFI_STATUS -EFIAPI -InitializeStall ( - IN EFI_PEI_FILE_HANDLE FileHandle, - IN CONST EFI_PEI_SERVICES **PeiServices - ) -{ - EFI_STATUS Status; - Status = (*PeiServices)->InstallPpi (PeiServices, &mPpiListStall[0]); - ASSERT_EFI_ERROR (Status); - - return Status; -} - -/** - The Stall() function provides a blocking stall for at least the number - of microseconds stipulated in the final argument of the API. - - @param PeiServices An indirect pointer to the PEI Services Table - published by the PEI Foundation. - @param This Pointer to the local data for the interface. - @param Microseconds Number of microseconds for which to stall. - - @retval EFI_SUCCESS The service provided at least the required delay. - -**/ -EFI_STATUS -EFIAPI -Stall ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_STALL_PPI *This, - IN UINTN Microseconds - ) -{ - EFI_STATUS Status; - PEI_NT_THUNK_PPI *PeiNtService; - EFI_WIN_NT_THUNK_PROTOCOL *NtThunk; - - Status = (**PeiServices).LocatePpi ( - (const EFI_PEI_SERVICES **)PeiServices, - &gPeiNtThunkPpiGuid, - 0, - NULL, - (VOID**)&PeiNtService - ); - ASSERT_EFI_ERROR (Status); - - // - // Calculate the time to sleep. Win API smallest unit to sleep is 1 millisec - // so micro second units need be divided by 1000 to convert to ms - // - NtThunk = (EFI_WIN_NT_THUNK_PROTOCOL*) PeiNtService->NtThunk(); - NtThunk->Sleep ((DWORD)((Microseconds + 999) / 1000)); - - return EFI_SUCCESS; -} diff --git a/Nt32Pkg/StallPei/StallPei.inf b/Nt32Pkg/StallPei/StallPei.inf deleted file mode 100644 index 7fb083dec0..0000000000 --- a/Nt32Pkg/StallPei/StallPei.inf +++ /dev/null @@ -1,43 +0,0 @@ -## @file -# EFI_PEI_STALL implementation for NT32 simulation environment. -# -# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
-# -# SPDX-License-Identifier: BSD-2-Clause-Patent -# -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = Stall - FILE_GUID = 6807217E-E8DE-42d0-91D9-60AECED7420D - MODULE_TYPE = PEIM - VERSION_STRING = 1.0 - - ENTRY_POINT = InitializeStall - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 EBC -# - -[Sources] - Stall.c - -[Packages] - MdePkg/MdePkg.dec - Nt32Pkg/Nt32Pkg.dec - -[LibraryClasses] - PeimEntryPoint - DebugLib - -[Ppis] - gEfiPeiStallPpiGuid ## PRODUCES - gPeiNtThunkPpiGuid ## CONSUMES - -[Depex] - TRUE - diff --git a/Nt32Pkg/TimerDxe/Timer.c b/Nt32Pkg/TimerDxe/Timer.c deleted file mode 100644 index f3e1e32d08..0000000000 --- a/Nt32Pkg/TimerDxe/Timer.c +++ /dev/null @@ -1,601 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - Timer.c - -Abstract: - - NT Emulation Timer Architectural Protocol Driver as defined in DXE CIS - - This Timer module uses an NT Thread to simulate the timer-tick driven - timer service. In the future, the Thread creation should possibly be - abstracted by the CPU architectural protocol - -**/ - -#include "Timer.h" - -// -// Pointer to the CPU Architectural Protocol instance -// -EFI_CPU_ARCH_PROTOCOL *mCpu; - -// -// The Timer Architectural Protocol that this driver produces -// -EFI_TIMER_ARCH_PROTOCOL mTimer = { - WinNtTimerDriverRegisterHandler, - WinNtTimerDriverSetTimerPeriod, - WinNtTimerDriverGetTimerPeriod, - WinNtTimerDriverGenerateSoftInterrupt -}; - -// -// Define a global that we can use to shut down the NT timer thread when -// the timer is canceled. -// -BOOLEAN mCancelTimerThread = FALSE; - -// -// The notification function to call on every timer interrupt -// -EFI_TIMER_NOTIFY mTimerNotifyFunction = NULL; - -// -// The current period of the timer interrupt -// -UINT64 mTimerPeriod; - -// -// The thread handle for this driver -// -HANDLE mNtMainThreadHandle; - -// -// The timer value from the last timer interrupt -// -UINT32 mNtLastTick; - -// -// Critical section used to update varibles shared between the main thread and -// the timer interrupt thread. -// -CRITICAL_SECTION mNtCriticalSection; - -// -// Worker Functions -// -UINT mMMTimerThreadID = 0; - -VOID -CALLBACK -MMTimerThread ( - UINT wTimerID, - UINT msg, - DWORD dwUser, - DWORD dw1, - DWORD dw2 - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - wTimerID - TODO: add argument description - msg - TODO: add argument description - dwUser - TODO: add argument description - dw1 - TODO: add argument description - dw2 - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -{ - EFI_TPL OriginalTPL; - UINT32 CurrentTick; - UINT32 Delta; - EFI_TIMER_NOTIFY CallbackFunction; - BOOLEAN InterruptState; - - if (!mCancelTimerThread) { - - // - // Suspend the main thread until we are done. - // Enter the critical section before suspending - // and leave the critical section after resuming - // to avoid deadlock between main and timer thread. - // - gWinNt->EnterCriticalSection (&mNtCriticalSection); - gWinNt->SuspendThread (mNtMainThreadHandle); - - // - // If the timer thread is being canceled, then bail immediately. - // We check again here because there's a small window of time from when - // this thread was kicked off and when we suspended the main thread above. - // - if (mCancelTimerThread) { - gWinNt->ResumeThread (mNtMainThreadHandle); - gWinNt->LeaveCriticalSection (&mNtCriticalSection); - gWinNt->timeKillEvent (wTimerID); - mMMTimerThreadID = 0; - return ; - } - - mCpu->GetInterruptState (mCpu, &InterruptState); - while (!InterruptState) { - // - // Resume the main thread - // - gWinNt->ResumeThread (mNtMainThreadHandle); - gWinNt->LeaveCriticalSection (&mNtCriticalSection); - - // - // Wait for interrupts to be enabled. - // - mCpu->GetInterruptState (mCpu, &InterruptState); - while (!InterruptState) { - gWinNt->Sleep (1); - mCpu->GetInterruptState (mCpu, &InterruptState); - } - - // - // Suspend the main thread until we are done - // - gWinNt->EnterCriticalSection (&mNtCriticalSection); - gWinNt->SuspendThread (mNtMainThreadHandle); - mCpu->GetInterruptState (mCpu, &InterruptState); - } - - // - // Get the current system tick - // - CurrentTick = gWinNt->GetTickCount (); - Delta = CurrentTick - mNtLastTick; - mNtLastTick = CurrentTick; - - // - // If delay was more then 1 second, ignore it (probably debugging case) - // - if (Delta < 1000) { - - OriginalTPL = gBS->RaiseTPL (TPL_HIGH_LEVEL); - - // - // Inform the firmware of an "timer interrupt". The time - // expired since the last call is 10,000 times the number - // of ms. (or 100ns units) - // - CallbackFunction = mTimerNotifyFunction; - - // - // Only invoke the callback function if a Non-NULL handler has been - // registered. Assume all other handlers are legal. - // - if (CallbackFunction != NULL) { - CallbackFunction ((UINT64) (Delta * 10000)); - } - - gBS->RestoreTPL (OriginalTPL); - - } - - // - // Resume the main thread - // - gWinNt->ResumeThread (mNtMainThreadHandle); - gWinNt->LeaveCriticalSection (&mNtCriticalSection); - } else { - gWinNt->timeKillEvent (wTimerID); - mMMTimerThreadID = 0; - } - -} - -UINT -CreateNtTimer ( - VOID - ) -/*++ - -Routine Description: - - It is used to emulate a platform - timer-driver interrupt handler. - -Returns: - - Timer ID - ---*/ -// TODO: function comment is missing 'Arguments:' -{ - UINT32 SleepCount; - - // - // Set our thread priority higher than the "main" thread. - // - gWinNt->SetThreadPriority ( - gWinNt->GetCurrentThread (), - THREAD_PRIORITY_HIGHEST - ); - - // - // Calc the appropriate interval - // - gWinNt->EnterCriticalSection (&mNtCriticalSection); - SleepCount = (UINT32) (mTimerPeriod + 5000) / 10000; - gWinNt->LeaveCriticalSection (&mNtCriticalSection); - - return gWinNt->timeSetEvent ( - SleepCount, - 0, - MMTimerThread, - (DWORD_PTR) NULL, - TIME_PERIODIC | TIME_KILL_SYNCHRONOUS | TIME_CALLBACK_FUNCTION - ); - -} - -EFI_STATUS -EFIAPI -WinNtTimerDriverRegisterHandler ( - IN EFI_TIMER_ARCH_PROTOCOL *This, - IN EFI_TIMER_NOTIFY NotifyFunction - ) -/*++ - -Routine Description: - - This function registers the handler NotifyFunction so it is called every time - the timer interrupt fires. It also passes the amount of time since the last - handler call to the NotifyFunction. If NotifyFunction is NULL, then the - handler is unregistered. If the handler is registered, then EFI_SUCCESS is - returned. If the CPU does not support registering a timer interrupt handler, - then EFI_UNSUPPORTED is returned. If an attempt is made to register a handler - when a handler is already registered, then EFI_ALREADY_STARTED is returned. - If an attempt is made to unregister a handler when a handler is not registered, - then EFI_INVALID_PARAMETER is returned. If an error occurs attempting to - register the NotifyFunction with the timer interrupt, then EFI_DEVICE_ERROR - is returned. - -Arguments: - - This - The EFI_TIMER_ARCH_PROTOCOL instance. - - NotifyFunction - The function to call when a timer interrupt fires. This - function executes at TPL_HIGH_LEVEL. The DXE Core will - register a handler for the timer interrupt, so it can know - how much time has passed. This information is used to - signal timer based events. NULL will unregister the handler. - -Returns: - - EFI_SUCCESS - The timer handler was registered. - - EFI_UNSUPPORTED - The platform does not support timer interrupts. - - EFI_ALREADY_STARTED - NotifyFunction is not NULL, and a handler is already - registered. - - EFI_INVALID_PARAMETER - NotifyFunction is NULL, and a handler was not - previously registered. - - EFI_DEVICE_ERROR - The timer handler could not be registered. - ---*/ -{ - // - // Check for invalid parameters - // - if (NotifyFunction == NULL && mTimerNotifyFunction == NULL) { - return EFI_INVALID_PARAMETER; - } - - if (NotifyFunction != NULL && mTimerNotifyFunction != NULL) { - return EFI_ALREADY_STARTED; - } - - // - // Use Critical Section to update the notification function that is - // used from the timer interrupt thread. - // - gWinNt->EnterCriticalSection (&mNtCriticalSection); - - mTimerNotifyFunction = NotifyFunction; - - gWinNt->LeaveCriticalSection (&mNtCriticalSection); - - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -WinNtTimerDriverSetTimerPeriod ( - IN EFI_TIMER_ARCH_PROTOCOL *This, - IN UINT64 TimerPeriod - ) -/*++ - -Routine Description: - - This function adjusts the period of timer interrupts to the value specified - by TimerPeriod. If the timer period is updated, then the selected timer - period is stored in EFI_TIMER.TimerPeriod, and EFI_SUCCESS is returned. If - the timer hardware is not programmable, then EFI_UNSUPPORTED is returned. - If an error occurs while attempting to update the timer period, then the - timer hardware will be put back in its state prior to this call, and - EFI_DEVICE_ERROR is returned. If TimerPeriod is 0, then the timer interrupt - is disabled. This is not the same as disabling the CPU's interrupts. - Instead, it must either turn off the timer hardware, or it must adjust the - interrupt controller so that a CPU interrupt is not generated when the timer - interrupt fires. - -Arguments: - - This - The EFI_TIMER_ARCH_PROTOCOL instance. - - TimerPeriod - The rate to program the timer interrupt in 100 nS units. If - the timer hardware is not programmable, then EFI_UNSUPPORTED is - returned. If the timer is programmable, then the timer period - will be rounded up to the nearest timer period that is supported - by the timer hardware. If TimerPeriod is set to 0, then the - timer interrupts will be disabled. - -Returns: - - EFI_SUCCESS - The timer period was changed. - - EFI_UNSUPPORTED - The platform cannot change the period of the timer interrupt. - - EFI_DEVICE_ERROR - The timer period could not be changed due to a device error. - ---*/ -{ - - // - // If TimerPeriod is 0, then the timer thread should be canceled - // - if (TimerPeriod == 0) { - // - // Cancel the timer thread - // - gWinNt->EnterCriticalSection (&mNtCriticalSection); - - mCancelTimerThread = TRUE; - - gWinNt->LeaveCriticalSection (&mNtCriticalSection); - - // - // Wait for the timer thread to exit - // - - if (mMMTimerThreadID) { - gWinNt->timeKillEvent (mMMTimerThreadID); - } - - mMMTimerThreadID = 0; - - // - // Update the timer period - // - gWinNt->EnterCriticalSection (&mNtCriticalSection); - - mTimerPeriod = TimerPeriod; - - gWinNt->LeaveCriticalSection (&mNtCriticalSection); - - // - // NULL out the thread handle so it will be re-created if the timer is enabled again - // - - } else if ((TimerPeriod > TIMER_MINIMUM_VALUE) && (TimerPeriod < TIMER_MAXIMUM_VALUE)) { - // - // If the TimerPeriod is valid, then create and/or adjust the period of the timer thread - // - gWinNt->EnterCriticalSection (&mNtCriticalSection); - - mTimerPeriod = TimerPeriod; - - mCancelTimerThread = FALSE; - - gWinNt->LeaveCriticalSection (&mNtCriticalSection); - - // - // Get the starting tick location if we are just starting the timer thread - // - mNtLastTick = gWinNt->GetTickCount (); - - if (mMMTimerThreadID) { - gWinNt->timeKillEvent (mMMTimerThreadID); - } - - mMMTimerThreadID = 0; - - mMMTimerThreadID = CreateNtTimer (); - - } - - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -WinNtTimerDriverGetTimerPeriod ( - IN EFI_TIMER_ARCH_PROTOCOL *This, - OUT UINT64 *TimerPeriod - ) -/*++ - -Routine Description: - - This function retrieves the period of timer interrupts in 100 ns units, - returns that value in TimerPeriod, and returns EFI_SUCCESS. If TimerPeriod - is NULL, then EFI_INVALID_PARAMETER is returned. If a TimerPeriod of 0 is - returned, then the timer is currently disabled. - -Arguments: - - This - The EFI_TIMER_ARCH_PROTOCOL instance. - - TimerPeriod - A pointer to the timer period to retrieve in 100 ns units. If - 0 is returned, then the timer is currently disabled. - -Returns: - - EFI_SUCCESS - The timer period was returned in TimerPeriod. - - EFI_INVALID_PARAMETER - TimerPeriod is NULL. - ---*/ -{ - if (TimerPeriod == NULL) { - return EFI_INVALID_PARAMETER; - } - - *TimerPeriod = mTimerPeriod; - - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -WinNtTimerDriverGenerateSoftInterrupt ( - IN EFI_TIMER_ARCH_PROTOCOL *This - ) -/*++ - -Routine Description: - - This function generates a soft timer interrupt. If the platform does not support soft - timer interrupts, then EFI_UNSUPPORTED is returned. Otherwise, EFI_SUCCESS is returned. - If a handler has been registered through the EFI_TIMER_ARCH_PROTOCOL.RegisterHandler() - service, then a soft timer interrupt will be generated. If the timer interrupt is - enabled when this service is called, then the registered handler will be invoked. The - registered handler should not be able to distinguish a hardware-generated timer - interrupt from a software-generated timer interrupt. - -Arguments: - - This - The EFI_TIMER_ARCH_PROTOCOL instance. - -Returns: - - EFI_SUCCESS - The soft timer interrupt was generated. - - EFI_UNSUPPORTED - The platform does not support the generation of soft timer interrupts. - ---*/ -{ - return EFI_UNSUPPORTED; -} - - -EFI_STATUS -EFIAPI -WinNtTimerDriverInitialize ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -/*++ - -Routine Description: - - Initialize the Timer Architectural Protocol driver - -Arguments: - - ImageHandle - ImageHandle of the loaded driver - - SystemTable - Pointer to the System Table - -Returns: - - EFI_SUCCESS - Timer Architectural Protocol created - - EFI_OUT_OF_RESOURCES - Not enough resources available to initialize driver. - - EFI_DEVICE_ERROR - A device error occured attempting to initialize the driver. - ---*/ -{ - EFI_STATUS Status; - UINTN Result; - EFI_HANDLE Handle; - EFI_HANDLE hSourceProcessHandle; - EFI_HANDLE hSourceHandle; - EFI_HANDLE hTargetProcessHandle; - // - // Make sure the Timer Architectural Protocol is not already installed in the system - // - ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiTimerArchProtocolGuid); - - // - // Get the CPU Architectural Protocol instance - // - Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID**)&mCpu); - ASSERT_EFI_ERROR (Status); - - // - // Get our handle so the timer tick thread can suspend - // - hSourceProcessHandle = gWinNt->GetCurrentProcess (); - hSourceHandle = gWinNt->GetCurrentThread (); - hTargetProcessHandle = gWinNt->GetCurrentProcess (); - Result = gWinNt->DuplicateHandle ( - hSourceProcessHandle, - hSourceHandle, - hTargetProcessHandle, - &mNtMainThreadHandle, - 0, - FALSE, - DUPLICATE_SAME_ACCESS - ); - if (Result == 0) { - return EFI_DEVICE_ERROR; - } - - // - // Initialize Critical Section used to update variables shared between the main - // thread and the timer interrupt thread. - // - gWinNt->InitializeCriticalSection (&mNtCriticalSection); - - // - // Start the timer thread at the default timer period - // - Status = mTimer.SetTimerPeriod (&mTimer, DEFAULT_TIMER_TICK_DURATION); - if (EFI_ERROR (Status)) { - gWinNt->DeleteCriticalSection (&mNtCriticalSection); - return Status; - } - - // - // Install the Timer Architectural Protocol onto a new handle - // - Handle = NULL; - Status = gBS->InstallProtocolInterface ( - &Handle, - &gEfiTimerArchProtocolGuid, - EFI_NATIVE_INTERFACE, - &mTimer - ); - if (EFI_ERROR (Status)) { - // - // Cancel the timer - // - mTimer.SetTimerPeriod (&mTimer, 0); - gWinNt->DeleteCriticalSection (&mNtCriticalSection); - return Status; - } - - return EFI_SUCCESS; -} diff --git a/Nt32Pkg/TimerDxe/Timer.h b/Nt32Pkg/TimerDxe/Timer.h deleted file mode 100644 index 71af11947d..0000000000 --- a/Nt32Pkg/TimerDxe/Timer.h +++ /dev/null @@ -1,164 +0,0 @@ -/**@file - -Copyright (c) 2006, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - Timer.h - -Abstract: - - NT Emulation Architectural Protocol Driver as defined in Tiano. - This Timer module uses an NT Thread to simulate the timer-tick driven - timer service. - -**/ - -#ifndef _TIMER_H_ -#define _TIMER_H_ - - -#include -#include -#include -#include -#include -#include -#include -#include - - -// -// Legal timer value range in 100 ns units -// -#define TIMER_MINIMUM_VALUE 0 -#define TIMER_MAXIMUM_VALUE (0x100000000 - 1) - -// -// Default timer value in 100 ns units (10 ms) -// -#define DEFAULT_TIMER_TICK_DURATION 100000 - -// -// Function Prototypes -// -EFI_STATUS -EFIAPI -WinNtTimerDriverInitialize ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - ImageHandle - TODO: add argument description - SystemTable - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -EFIAPI -WinNtTimerDriverRegisterHandler ( - IN EFI_TIMER_ARCH_PROTOCOL *This, - IN EFI_TIMER_NOTIFY NotifyFunction - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - This - TODO: add argument description - NotifyFunction - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -EFIAPI -WinNtTimerDriverSetTimerPeriod ( - IN EFI_TIMER_ARCH_PROTOCOL *This, - IN UINT64 TimerPeriod - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - This - TODO: add argument description - TimerPeriod - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -EFIAPI -WinNtTimerDriverGetTimerPeriod ( - IN EFI_TIMER_ARCH_PROTOCOL *This, - OUT UINT64 *TimerPeriod - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - This - TODO: add argument description - TimerPeriod - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -EFIAPI -WinNtTimerDriverGenerateSoftInterrupt ( - IN EFI_TIMER_ARCH_PROTOCOL *This - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - This - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -#endif diff --git a/Nt32Pkg/TimerDxe/TimerDxe.inf b/Nt32Pkg/TimerDxe/TimerDxe.inf deleted file mode 100644 index 9c5aaa10e6..0000000000 --- a/Nt32Pkg/TimerDxe/TimerDxe.inf +++ /dev/null @@ -1,49 +0,0 @@ -## @file -# NT Emulation Timer Architectural Protocol Driver as defined in DXE CIS -# -# This Timer module uses an NT Thread to simulate the timer-tick driven -# timer service. In the future, the Thread creation should possibly be -# abstracted by the CPU architectural protocol -# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
-# -# SPDX-License-Identifier: BSD-2-Clause-Patent -# -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = Timer - FILE_GUID = C3811036-710B-4E39-8CF1-0AF9BE3A8198 - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - - ENTRY_POINT = WinNtTimerDriverInitialize - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 -# - -[Sources] - Timer.c - Timer.h - -[Packages] - MdePkg/MdePkg.dec - Nt32Pkg/Nt32Pkg.dec - -[LibraryClasses] - UefiBootServicesTableLib - WinNtLib - UefiDriverEntryPoint - DebugLib - -[Protocols] - gEfiCpuArchProtocolGuid # PROTOCOL ALWAYS_CONSUMED - gEfiTimerArchProtocolGuid # PROTOCOL ALWAYS_PRODUCED - -[Depex] - gEfiCpuArchProtocolGuid - \ No newline at end of file diff --git a/Nt32Pkg/WinNtAutoScanPei/WinNtAutoScan.c b/Nt32Pkg/WinNtAutoScanPei/WinNtAutoScan.c deleted file mode 100644 index cd3777ab2b..0000000000 --- a/Nt32Pkg/WinNtAutoScanPei/WinNtAutoScan.c +++ /dev/null @@ -1,219 +0,0 @@ -/**@file - -Copyright (c) 2006, Intel Corporation. All rights reserved.
-(C) Copyright 2016 Hewlett Packard Enterprise Development LP
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - WinNtAutoscan.c - -Abstract: - This PEIM to abstract memory auto-scan in a Windows NT environment. - -Revision History - -**/ - -// -// The package level header files this module uses -// -#include -#include -// -// The protocols, PPI and GUID defintions for this module -// -#include -#include - -#include - -// -// The Library classes this module consumes -// -#include -#include -#include -#include - -EFI_MEMORY_TYPE_INFORMATION mDefaultMemoryTypeInformation[] = { - { EfiReservedMemoryType, 0x0004 }, - { EfiRuntimeServicesCode, 0x0040 }, - { EfiRuntimeServicesData, 0x0040 }, - { EfiBootServicesCode, 0x0300 }, - { EfiBootServicesData, 0x1000 }, - { EfiMaxMemoryType, 0 } -}; - -/** - Validate variable data for the MemoryTypeInformation. - - @param MemoryData Variable data. - @param MemoryDataSize Variable data length. - - @return TRUE The variable data is valid. - @return FALSE The variable data is invalid. - -**/ -BOOLEAN -ValidateMemoryTypeInfoVariable ( - IN EFI_MEMORY_TYPE_INFORMATION *MemoryData, - IN UINTN MemoryDataSize - ) -{ - UINTN Count; - UINTN Index; - - // Check the input parameter. - if (MemoryData == NULL) { - return FALSE; - } - - // Get Count - Count = MemoryDataSize / sizeof (*MemoryData); - - // Check Size - if (Count * sizeof(*MemoryData) != MemoryDataSize) { - return FALSE; - } - - // Check last entry type filed. - if (MemoryData[Count - 1].Type != EfiMaxMemoryType) { - return FALSE; - } - - // Check the type filed. - for (Index = 0; Index < Count - 1; Index++) { - if (MemoryData[Index].Type >= EfiMaxMemoryType) { - return FALSE; - } - } - - return TRUE; -} - -EFI_STATUS -EFIAPI -PeimInitializeWinNtAutoScan ( - IN EFI_PEI_FILE_HANDLE FileHandle, - IN CONST EFI_PEI_SERVICES **PeiServices - ) -/*++ - -Routine Description: - Perform a call-back into the SEC simulator to get a memory value - -Arguments: - FfsHeader - General purpose data available to every PEIM - PeiServices - General purpose services available to every PEIM. - -Returns: - None - ---*/ -{ - EFI_STATUS Status; - EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor; - PEI_NT_AUTOSCAN_PPI *PeiNtService; - UINT64 MemorySize; - EFI_PHYSICAL_ADDRESS MemoryBase; - UINTN Index; - EFI_RESOURCE_ATTRIBUTE_TYPE Attributes; - EFI_PEI_READ_ONLY_VARIABLE2_PPI *Variable; - UINTN DataSize; - EFI_MEMORY_TYPE_INFORMATION MemoryData [EfiMaxMemoryType + 1]; - - - DEBUG ((EFI_D_ERROR, "NT 32 Autoscan PEIM Loaded\n")); - - // - // Get the PEI NT Autoscan PPI - // - Status = PeiServicesLocatePpi ( - &gPeiNtAutoScanPpiGuid, // GUID - 0, // INSTANCE - &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR - (VOID**)&PeiNtService // PPI - ); - ASSERT_EFI_ERROR (Status); - - Index = 0; - do { - Status = PeiNtService->NtAutoScan (Index, &MemoryBase, &MemorySize); - if (!EFI_ERROR (Status)) { - Attributes = - ( - EFI_RESOURCE_ATTRIBUTE_PRESENT | - EFI_RESOURCE_ATTRIBUTE_INITIALIZED | - EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE | - EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE | - EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE | - EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE - ); - - if (Index == 0) { - // - // Register the memory with the PEI Core - // - Status = PeiServicesInstallPeiMemory (MemoryBase, MemorySize); - ASSERT_EFI_ERROR (Status); - - Attributes |= EFI_RESOURCE_ATTRIBUTE_TESTED; - } - - BuildResourceDescriptorHob ( - EFI_RESOURCE_SYSTEM_MEMORY, - Attributes, - MemoryBase, - MemorySize - ); - } - Index++; - } while (!EFI_ERROR (Status)); - - // - // Build the CPU hob with 52-bit addressing and 16-bits of IO space. - // - BuildCpuHob (52, 16); - - // - // Build GUIDed Hob that contains the Memory Type Information array - // - Status = PeiServicesLocatePpi ( - &gEfiPeiReadOnlyVariable2PpiGuid, - 0, - NULL, - (VOID **)&Variable - ); - ASSERT_EFI_ERROR (Status); - - DataSize = sizeof (MemoryData); - Status = Variable->GetVariable ( - Variable, - EFI_MEMORY_TYPE_INFORMATION_VARIABLE_NAME, - &gEfiMemoryTypeInformationGuid, - NULL, - &DataSize, - &MemoryData - ); - if (EFI_ERROR (Status) || !ValidateMemoryTypeInfoVariable(MemoryData, DataSize)) { - // - // Create Memory Type Information HOB - // - BuildGuidDataHob ( - &gEfiMemoryTypeInformationGuid, - mDefaultMemoryTypeInformation, - sizeof(mDefaultMemoryTypeInformation) - ); - } else { - // - // Create Memory Type Information HOB - // - BuildGuidDataHob ( - &gEfiMemoryTypeInformationGuid, - MemoryData, - DataSize - ); - } - - return Status; -} diff --git a/Nt32Pkg/WinNtAutoScanPei/WinNtAutoScanPei.inf b/Nt32Pkg/WinNtAutoScanPei/WinNtAutoScanPei.inf deleted file mode 100644 index 30d67c038d..0000000000 --- a/Nt32Pkg/WinNtAutoScanPei/WinNtAutoScanPei.inf +++ /dev/null @@ -1,50 +0,0 @@ -## @file -# Component description file for WinNtAutoScan module -# -# This module abstracts memory auto-scan in a Windows NT environment. -# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
-# -# SPDX-License-Identifier: BSD-2-Clause-Patent -# -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = WinNtAutoScan - FILE_GUID = BE0FEABA-3443-4919-9F3A-2D4216329EA9 - MODULE_TYPE = PEIM - VERSION_STRING = 1.0 - - ENTRY_POINT = PeimInitializeWinNtAutoScan - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 -# - -[Sources] - WinNtAutoScan.c - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - Nt32Pkg/Nt32Pkg.dec - - -[LibraryClasses] - HobLib - PeimEntryPoint - DebugLib - PeiServicesLib - -[Ppis] - gPeiNtAutoScanPpiGuid # PPI ALWAYS_CONSUMED - gEfiPeiReadOnlyVariable2PpiGuid # PPI ALWAYS_CONSUMED - -[Guids] - gEfiMemoryTypeInformationGuid - -[Depex] - gPeiNtAutoScanPpiGuid AND gEfiPeiMasterBootModePpiGuid AND gEfiPeiReadOnlyVariable2PpiGuid diff --git a/Nt32Pkg/WinNtBlockIoDxe/ComponentName.c b/Nt32Pkg/WinNtBlockIoDxe/ComponentName.c deleted file mode 100644 index 5c28e328c5..0000000000 --- a/Nt32Pkg/WinNtBlockIoDxe/ComponentName.c +++ /dev/null @@ -1,353 +0,0 @@ -/**@file - -Copyright (c) 2006, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - ComponentName.c - -Abstract: - -**/ -#include -#include -#include -#include - -#include "WinNtBlockIo.h" - -// -// EFI Component Name Functions -// -/** - Retrieves a Unicode string that is the user readable name of the driver. - - This function retrieves the user readable name of a driver in the form of a - Unicode string. If the driver specified by This has a user readable name in - the language specified by Language, then a pointer to the driver name is - returned in DriverName, and EFI_SUCCESS is returned. If the driver specified - by This does not support the language specified by Language, - then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified - in RFC 4646 or ISO 639-2 language code format. - - @param DriverName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - driver specified by This in the language - specified by Language. - - @retval EFI_SUCCESS The Unicode string for the Driver specified by - This and the language specified by Language was - returned in DriverName. - - @retval EFI_INVALID_PARAMETER Language is NULL. - - @retval EFI_INVALID_PARAMETER DriverName is NULL. - - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -WinNtBlockIoComponentNameGetDriverName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName - ); - - -/** - Retrieves a Unicode string that is the user readable name of the controller - that is being managed by a driver. - - This function retrieves the user readable name of the controller specified by - ControllerHandle and ChildHandle in the form of a Unicode string. If the - driver specified by This has a user readable name in the language specified by - Language, then a pointer to the controller name is returned in ControllerName, - and EFI_SUCCESS is returned. If the driver specified by This is not currently - managing the controller specified by ControllerHandle and ChildHandle, - then EFI_UNSUPPORTED is returned. If the driver specified by This does not - support the language specified by Language, then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - - @param ControllerHandle[in] The handle of a controller that the driver - specified by This is managing. This handle - specifies the controller whose name is to be - returned. - - @param ChildHandle[in] The handle of the child controller to retrieve - the name of. This is an optional parameter that - may be NULL. It will be NULL for device - drivers. It will also be NULL for a bus drivers - that wish to retrieve the name of the bus - controller. It will not be NULL for a bus - driver that wishes to retrieve the name of a - child controller. - - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified in - RFC 4646 or ISO 639-2 language code format. - - @param ControllerName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - controller specified by ControllerHandle and - ChildHandle in the language specified by - Language from the point of view of the driver - specified by This. - - @retval EFI_SUCCESS The Unicode string for the user readable name in - the language specified by Language for the - driver specified by This was returned in - DriverName. - - @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. - - @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid - EFI_HANDLE. - - @retval EFI_INVALID_PARAMETER Language is NULL. - - @retval EFI_INVALID_PARAMETER ControllerName is NULL. - - @retval EFI_UNSUPPORTED The driver specified by This is not currently - managing the controller specified by - ControllerHandle and ChildHandle. - - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -WinNtBlockIoComponentNameGetControllerName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName - ); - - -// -// EFI Component Name Protocol -// -GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gWinNtBlockIoComponentName = { - WinNtBlockIoComponentNameGetDriverName, - WinNtBlockIoComponentNameGetControllerName, - "eng" -}; - -// -// EFI Component Name 2 Protocol -// -GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gWinNtBlockIoComponentName2 = { - (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) WinNtBlockIoComponentNameGetDriverName, - (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) WinNtBlockIoComponentNameGetControllerName, - "en" -}; - - -GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mWinNtBlockIoDriverNameTable[] = { - { "eng;en", L"Windows Block I/O Driver" }, - { NULL , NULL } -}; - -/** - Retrieves a Unicode string that is the user readable name of the driver. - - This function retrieves the user readable name of a driver in the form of a - Unicode string. If the driver specified by This has a user readable name in - the language specified by Language, then a pointer to the driver name is - returned in DriverName, and EFI_SUCCESS is returned. If the driver specified - by This does not support the language specified by Language, - then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified - in RFC 4646 or ISO 639-2 language code format. - - @param DriverName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - driver specified by This in the language - specified by Language. - - @retval EFI_SUCCESS The Unicode string for the Driver specified by - This and the language specified by Language was - returned in DriverName. - - @retval EFI_INVALID_PARAMETER Language is NULL. - - @retval EFI_INVALID_PARAMETER DriverName is NULL. - - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -WinNtBlockIoComponentNameGetDriverName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName - ) -{ - return LookupUnicodeString2 ( - Language, - This->SupportedLanguages, - mWinNtBlockIoDriverNameTable, - DriverName, - (BOOLEAN)(This == &gWinNtBlockIoComponentName) - ); -} - -/** - Retrieves a Unicode string that is the user readable name of the controller - that is being managed by a driver. - - This function retrieves the user readable name of the controller specified by - ControllerHandle and ChildHandle in the form of a Unicode string. If the - driver specified by This has a user readable name in the language specified by - Language, then a pointer to the controller name is returned in ControllerName, - and EFI_SUCCESS is returned. If the driver specified by This is not currently - managing the controller specified by ControllerHandle and ChildHandle, - then EFI_UNSUPPORTED is returned. If the driver specified by This does not - support the language specified by Language, then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - - @param ControllerHandle[in] The handle of a controller that the driver - specified by This is managing. This handle - specifies the controller whose name is to be - returned. - - @param ChildHandle[in] The handle of the child controller to retrieve - the name of. This is an optional parameter that - may be NULL. It will be NULL for device - drivers. It will also be NULL for a bus drivers - that wish to retrieve the name of the bus - controller. It will not be NULL for a bus - driver that wishes to retrieve the name of a - child controller. - - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified in - RFC 4646 or ISO 639-2 language code format. - - @param ControllerName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - controller specified by ControllerHandle and - ChildHandle in the language specified by - Language from the point of view of the driver - specified by This. - - @retval EFI_SUCCESS The Unicode string for the user readable name in - the language specified by Language for the - driver specified by This was returned in - DriverName. - - @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. - - @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid - EFI_HANDLE. - - @retval EFI_INVALID_PARAMETER Language is NULL. - - @retval EFI_INVALID_PARAMETER ControllerName is NULL. - - @retval EFI_UNSUPPORTED The driver specified by This is not currently - managing the controller specified by - ControllerHandle and ChildHandle. - - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -WinNtBlockIoComponentNameGetControllerName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName - ) -{ - EFI_STATUS Status; - EFI_BLOCK_IO_PROTOCOL *BlockIo; - WIN_NT_BLOCK_IO_PRIVATE *Private; - - // - // This is a device driver, so ChildHandle must be NULL. - // - if (ChildHandle != NULL) { - return EFI_UNSUPPORTED; - } - // - // Make sure this driver is currently managing ControllerHandle - // - Status = EfiTestManagedDevice ( - ControllerHandle, - gWinNtBlockIoDriverBinding.DriverBindingHandle, - &gEfiWinNtIoProtocolGuid - ); - if (EFI_ERROR (Status)) { - return EFI_UNSUPPORTED; - } - // - // Get our context back - // - Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiBlockIoProtocolGuid, - (VOID **) &BlockIo, - gWinNtBlockIoDriverBinding.DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - if (EFI_ERROR (Status)) { - return EFI_UNSUPPORTED; - } - - Private = WIN_NT_BLOCK_IO_PRIVATE_DATA_FROM_THIS (BlockIo); - - return LookupUnicodeString2 ( - Language, - This->SupportedLanguages, - Private->ControllerNameTable, - ControllerName, - (BOOLEAN)(This == &gWinNtBlockIoComponentName) - ); -} diff --git a/Nt32Pkg/WinNtBlockIoDxe/DriverConfiguration.c b/Nt32Pkg/WinNtBlockIoDxe/DriverConfiguration.c deleted file mode 100644 index 8969e5e198..0000000000 --- a/Nt32Pkg/WinNtBlockIoDxe/DriverConfiguration.c +++ /dev/null @@ -1,337 +0,0 @@ -/**@file - -Copyright (c) 2006, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - DriverConfiguration.c - -Abstract: - -**/ -#include -#include -#include -#include -#include - -#include "WinNtBlockIo.h" - -// -// EFI Driver Configuration Functions -// -EFI_STATUS -EFIAPI -WinNtBlockIoDriverConfigurationSetOptions ( - IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired - ); - -EFI_STATUS -EFIAPI -WinNtBlockIoDriverConfigurationOptionsValid ( - IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL - ); - -EFI_STATUS -EFIAPI -WinNtBlockIoDriverConfigurationForceDefaults ( - IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN UINT32 DefaultType, - OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired - ); - -// -// EFI Driver Configuration Protocol -// -EFI_DRIVER_CONFIGURATION_PROTOCOL gWinNtBlockIoDriverConfiguration = { - WinNtBlockIoDriverConfigurationSetOptions, - WinNtBlockIoDriverConfigurationOptionsValid, - WinNtBlockIoDriverConfigurationForceDefaults, - LANGUAGESUPPORTED -}; - -EFI_STATUS -EFIAPI -WinNtBlockIoDriverConfigurationSetOptions ( - IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired - ) -/*++ - - Routine Description: - Allows the user to set controller specific options for a controller that a - driver is currently managing. - - Arguments: - This - A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance. - ControllerHandle - The handle of the controller to set options on. - ChildHandle - The handle of the child controller to set options on. This - is an optional parameter that may be NULL. It will be NULL - for device drivers, and for a bus drivers that wish to set - options for the bus controller. It will not be NULL for a - bus driver that wishes to set options for one of its child - controllers. - Language - A pointer to a three character ISO 639-2 language identifier. - This is the language of the user interface that should be - presented to the user, and it must match one of the languages - specified in SupportedLanguages. The number of languages - supported by a driver is up to the driver writer. - ActionRequired - A pointer to the action that the calling agent is required - to perform when this function returns. See "Related - Definitions" for a list of the actions that the calling - agent is required to perform prior to accessing - ControllerHandle again. - - Returns: - EFI_SUCCESS - The driver specified by This successfully set the - configuration options for the controller specified - by ControllerHandle.. - EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE. - EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE. - EFI_INVALID_PARAMETER - ActionRequired is NULL. - EFI_UNSUPPORTED - The driver specified by This does not support setting - configuration options for the controller specified by - ControllerHandle and ChildHandle. - EFI_UNSUPPORTED - The driver specified by This does not support the - language specified by Language. - EFI_DEVICE_ERROR - A device error occurred while attempt to set the - configuration options for the controller specified - by ControllerHandle and ChildHandle. - EFI_OUT_RESOURCES - There are not enough resources available to set the - configuration options for the controller specified - by ControllerHandle and ChildHandle. - ---*/ -{ - EFI_STATUS Status; - EFI_BLOCK_IO_PROTOCOL *BlockIo; - CHAR8 *SupportedLanguage; - - SupportedLanguage = This->SupportedLanguages; - - Status = EFI_UNSUPPORTED; - while (*SupportedLanguage != 0) { - if (AsciiStrnCmp (Language, SupportedLanguage, 3) == 0) { - Status = EFI_SUCCESS; - } - - SupportedLanguage += 3; - } - - if (EFI_ERROR (Status)) { - return Status; - } - - if (ActionRequired == NULL || ControllerHandle == NULL) { - return EFI_INVALID_PARAMETER; - } - - if (ChildHandle != NULL) { - return EFI_UNSUPPORTED; - } - - // - // Validate controller handle - // - Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiWinNtIoProtocolGuid, - (VOID **) &BlockIo, - gWinNtBlockIoDriverBinding.DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - - if (!EFI_ERROR (Status)) { - gBS->CloseProtocol ( - ControllerHandle, - &gEfiWinNtIoProtocolGuid, - gWinNtBlockIoDriverBinding.DriverBindingHandle, - ControllerHandle - ); - - return EFI_UNSUPPORTED; - } - - if (Status == EFI_UNSUPPORTED) { - return Status; - } else if (Status != EFI_ALREADY_STARTED) { - return EFI_INVALID_PARAMETER; - } - - *ActionRequired = EfiDriverConfigurationActionNone; - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -WinNtBlockIoDriverConfigurationOptionsValid ( - IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL - ) -/*++ - - Routine Description: - Tests to see if a controller's current configuration options are valid. - - Arguments: - This - A pointer to the EFI_DRIVER_CONFIGURATION_PROTOCOL instance. - ControllerHandle - The handle of the controller to test if it's current - configuration options are valid. - ChildHandle - The handle of the child controller to test if it's current - configuration options are valid. This is an optional - parameter that may be NULL. It will be NULL for device - drivers. It will also be NULL for a bus drivers that wish - to test the configuration options for the bus controller. - It will not be NULL for a bus driver that wishes to test - configuration options for one of its child controllers. - - Returns: - EFI_SUCCESS - The controller specified by ControllerHandle and - ChildHandle that is being managed by the driver - specified by This has a valid set of configuration - options. - EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE. - EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE. - EFI_UNSUPPORTED - The driver specified by This is not currently - managing the controller specified by ControllerHandle - and ChildHandle. - EFI_DEVICE_ERROR - The controller specified by ControllerHandle and - ChildHandle that is being managed by the driver - specified by This has an invalid set of configuration - options. - ---*/ -{ - EFI_STATUS Status; - EFI_BLOCK_IO_PROTOCOL *BlockIo; - - if (ChildHandle != NULL) { - return EFI_UNSUPPORTED; - } - - if (ControllerHandle == NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // Validate controller handle - // - Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiWinNtIoProtocolGuid, - (VOID **) &BlockIo, - gWinNtBlockIoDriverBinding.DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - - if (!EFI_ERROR (Status)) { - gBS->CloseProtocol ( - ControllerHandle, - &gEfiWinNtIoProtocolGuid, - gWinNtBlockIoDriverBinding.DriverBindingHandle, - ControllerHandle - ); - - return EFI_UNSUPPORTED; - } - - if (Status == EFI_UNSUPPORTED) { - return Status; - } else if (Status != EFI_ALREADY_STARTED) { - return EFI_INVALID_PARAMETER; - } - - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -WinNtBlockIoDriverConfigurationForceDefaults ( - IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN UINT32 DefaultType, - OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired - ) -/*++ - - Routine Description: - Forces a driver to set the default configuration options for a controller. - - Arguments: - This - A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance. - ControllerHandle - The handle of the controller to force default configuration options on. - ChildHandle - The handle of the child controller to force default configuration options on This is an optional parameter that may be NULL. It will be NULL for device drivers. It will also be NULL for a bus drivers that wish to force default configuration options for the bus controller. It will not be NULL for a bus driver that wishes to force default configuration options for one of its child controllers. - DefaultType - The type of default configuration options to force on the controller specified by ControllerHandle and ChildHandle. See Table 9-1 for legal values. A DefaultType of 0x00000000 must be supported by this protocol. - ActionRequired - A pointer to the action that the calling agent is required to perform when this function returns. See "Related Definitions" in Section 9.1for a list of the actions that the calling agent is required to perform prior to accessing ControllerHandle again. - - Returns: - EFI_SUCCESS - The driver specified by This successfully forced the default configuration options on the controller specified by ControllerHandle and ChildHandle. - EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE. - EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE. - EFI_INVALID_PARAMETER - ActionRequired is NULL. - EFI_UNSUPPORTED - The driver specified by This does not support forcing the default configuration options on the controller specified by ControllerHandle and ChildHandle. - EFI_UNSUPPORTED - The driver specified by This does not support the configuration type specified by DefaultType. - EFI_DEVICE_ERROR - A device error occurred while attempt to force the default configuration options on the controller specified by ControllerHandle and ChildHandle. - EFI_OUT_RESOURCES - There are not enough resources available to force the default configuration options on the controller specified by ControllerHandle and ChildHandle. - ---*/ -{ - EFI_STATUS Status; - EFI_BLOCK_IO_PROTOCOL *BlockIo; - - if (ChildHandle != NULL) { - return EFI_UNSUPPORTED; - } - - if (ActionRequired == NULL || ControllerHandle == NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // Validate controller handle - // - Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiWinNtIoProtocolGuid, - (VOID **) &BlockIo, - gWinNtBlockIoDriverBinding.DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - - if (!EFI_ERROR (Status)) { - gBS->CloseProtocol ( - ControllerHandle, - &gEfiWinNtIoProtocolGuid, - gWinNtBlockIoDriverBinding.DriverBindingHandle, - ControllerHandle - ); - - return EFI_UNSUPPORTED; - } - - if (Status == EFI_UNSUPPORTED) { - return Status; - } else if (Status != EFI_ALREADY_STARTED) { - return EFI_INVALID_PARAMETER; - } - - *ActionRequired = EfiDriverConfigurationActionNone; - return EFI_SUCCESS; -} diff --git a/Nt32Pkg/WinNtBlockIoDxe/DriverDiagnostics.c b/Nt32Pkg/WinNtBlockIoDxe/DriverDiagnostics.c deleted file mode 100644 index aebb744400..0000000000 --- a/Nt32Pkg/WinNtBlockIoDxe/DriverDiagnostics.c +++ /dev/null @@ -1,219 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - DriverDiagnostics.c - -Abstract: - -**/ -#include -#include -#include -#include -#include - -#include "WinNtBlockIo.h" - -// -// EFI Driver Diagnostics Functions -// -EFI_STATUS -EFIAPI -WinNtBlockIoDriverDiagnosticsRunDiagnostics ( - IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN EFI_DRIVER_DIAGNOSTIC_TYPE DiagnosticType, - IN CHAR8 *Language, - OUT EFI_GUID **ErrorType, - OUT UINTN *BufferSize, - OUT CHAR16 **Buffer - ); - -// -// EFI Driver Diagnostics Protocol -// -GLOBAL_REMOVE_IF_UNREFERENCED EFI_DRIVER_DIAGNOSTICS_PROTOCOL gWinNtBlockIoDriverDiagnostics = { - WinNtBlockIoDriverDiagnosticsRunDiagnostics, - "eng" -}; - -// -// EFI Driver Diagnostics 2 Protocol -// -GLOBAL_REMOVE_IF_UNREFERENCED EFI_DRIVER_DIAGNOSTICS2_PROTOCOL gWinNtBlockIoDriverDiagnostics2 = { - (EFI_DRIVER_DIAGNOSTICS2_RUN_DIAGNOSTICS) WinNtBlockIoDriverDiagnosticsRunDiagnostics, - "en" -}; - -EFI_STATUS -EFIAPI -WinNtBlockIoDriverDiagnosticsRunDiagnostics ( - IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN EFI_DRIVER_DIAGNOSTIC_TYPE DiagnosticType, - IN CHAR8 *Language, - OUT EFI_GUID **ErrorType, - OUT UINTN *BufferSize, - OUT CHAR16 **Buffer - ) -/*++ - - Routine Description: - Runs diagnostics on a controller. - - Arguments: - This - A pointer to the EFI_DRIVER_DIAGNOSTICS_PROTOCOL instance. - ControllerHandle - The handle of the controller to run diagnostics on. - ChildHandle - The handle of the child controller to run diagnostics on - This is an optional parameter that may be NULL. It will - be NULL for device drivers. It will also be NULL for a - bus drivers that wish to run diagnostics on the bus - controller. It will not be NULL for a bus driver that - wishes to run diagnostics on one of its child controllers. - DiagnosticType - Indicates type of diagnostics to perform on the controller - specified by ControllerHandle and ChildHandle. See - "Related Definitions" for the list of supported types. - Language - A pointer to a three character ISO 639-2 language - identifier or a Null-terminated ASCII string array indicating - the language. This is the language in which the optional - error message should be returned in Buffer, and it must - match one of the languages specified in SupportedLanguages. - The number of languages supported by a driver is up to - the driver writer. - ErrorType - A GUID that defines the format of the data returned in - Buffer. - BufferSize - The size, in bytes, of the data returned in Buffer. - Buffer - A buffer that contains a Null-terminated Unicode string - plus some additional data whose format is defined by - ErrorType. Buffer is allocated by this function with - AllocatePool(), and it is the caller's responsibility - to free it with a call to FreePool(). - - Returns: - EFI_SUCCESS - The controller specified by ControllerHandle and - ChildHandle passed the diagnostic. - EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE. - EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid - EFI_HANDLE. - EFI_INVALID_PARAMETER - Language is NULL. - EFI_INVALID_PARAMETER - ErrorType is NULL. - EFI_INVALID_PARAMETER - BufferType is NULL. - EFI_INVALID_PARAMETER - Buffer is NULL. - EFI_UNSUPPORTED - The driver specified by This does not support - running diagnostics for the controller specified - by ControllerHandle and ChildHandle. - EFI_UNSUPPORTED - The driver specified by This does not support the - type of diagnostic specified by DiagnosticType. - EFI_UNSUPPORTED - The driver specified by This does not support the - language specified by Language. - EFI_OUT_OF_RESOURCES - There are not enough resources available to complete - the diagnostics. - EFI_OUT_OF_RESOURCES - There are not enough resources available to return - the status information in ErrorType, BufferSize, - and Buffer. - EFI_DEVICE_ERROR - The controller specified by ControllerHandle and - ChildHandle did not pass the diagnostic. - ---*/ -{ - EFI_STATUS Status; - EFI_BLOCK_IO_PROTOCOL *BlockIo; - CHAR8 *SupportedLanguages; - BOOLEAN Iso639Language; - BOOLEAN Found; - UINTN Index; - - if (Language == NULL || - ErrorType == NULL || - Buffer == NULL || - ControllerHandle == NULL || - BufferSize == NULL) { - - return EFI_INVALID_PARAMETER; - } - - SupportedLanguages = This->SupportedLanguages; - Iso639Language = (BOOLEAN)(This == &gWinNtBlockIoDriverDiagnostics); - // - // Make sure Language is in the set of Supported Languages - // - Found = FALSE; - while (*SupportedLanguages != 0) { - if (Iso639Language) { - if (CompareMem (Language, SupportedLanguages, 3) == 0) { - Found = TRUE; - break; - } - SupportedLanguages += 3; - } else { - for (Index = 0; SupportedLanguages[Index] != 0 && SupportedLanguages[Index] != ';'; Index++); - if ((AsciiStrnCmp(SupportedLanguages, Language, Index) == 0) && (Language[Index] == 0)) { - Found = TRUE; - break; - } - SupportedLanguages += Index; - for (; *SupportedLanguages != 0 && *SupportedLanguages == ';'; SupportedLanguages++); - } - } - // - // If Language is not a member of SupportedLanguages, then return EFI_UNSUPPORTED - // - if (!Found) { - return EFI_UNSUPPORTED; - } - - *ErrorType = NULL; - *BufferSize = 0; - if (DiagnosticType != EfiDriverDiagnosticTypeStandard) { - *ErrorType = &gEfiBlockIoProtocolGuid; - *BufferSize = 0x60; - *Buffer = AllocatePool ((UINTN) (*BufferSize)); - CopyMem (*Buffer, L"Windows Block I/O Driver Diagnostics Failed\n", *BufferSize); - return EFI_DEVICE_ERROR; - } - - // - // This is a device driver, so ChildHandle must be NULL. - // - if (ChildHandle != NULL) { - return EFI_UNSUPPORTED; - } - - // - // Validate controller handle - // - Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiWinNtIoProtocolGuid, - (VOID **) &BlockIo, - gWinNtBlockIoDriverBinding.DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - - if (!EFI_ERROR (Status)) { - gBS->CloseProtocol ( - ControllerHandle, - &gEfiWinNtIoProtocolGuid, - gWinNtBlockIoDriverBinding.DriverBindingHandle, - ControllerHandle - ); - - return EFI_UNSUPPORTED; - } - - - if (Status == EFI_UNSUPPORTED) { - return Status; - } else if (Status != EFI_ALREADY_STARTED) { - return EFI_INVALID_PARAMETER; - } - - return EFI_SUCCESS; -} diff --git a/Nt32Pkg/WinNtBlockIoDxe/WinNtBlockIo.c b/Nt32Pkg/WinNtBlockIoDxe/WinNtBlockIo.c deleted file mode 100644 index 3eb9bee79e..0000000000 --- a/Nt32Pkg/WinNtBlockIoDxe/WinNtBlockIo.c +++ /dev/null @@ -1,1125 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - WinNtBlockIo.c - -Abstract: - - Produce block IO abstractions for real devices on your PC using Win32 APIs. - The configuration of what devices to mount or emulate comes from NT - environment variables. The variables must be visible to the Microsoft* - Developer Studio for them to work. - - ixed - Fixed disk like a hard drive. - emovable - Removable media like a floppy or CD-ROM. - Read nly - Write protected device. - Read rite - Read write device. - - Decimal number of blocks a device supports. - - Decimal number of bytes per block. - - NT envirnonment variable contents. '<' and '>' are not part of the variable, - they are just used to make this help more readable. There should be no - spaces between the ';'. Extra spaces will break the variable. A '!' is - used to seperate multiple devices in a variable. - - EFI_WIN_NT_VIRTUAL_DISKS = - ;;[!...] - - EFI_WIN_NT_PHYSICAL_DISKS = - :;;[!...] - - Virtual Disks: These devices use a file to emulate a hard disk or removable - media device. - - Thus a 20 MB emulated hard drive would look like: - EFI_WIN_NT_VIRTUAL_DISKS=FW;40960;512 - - A 1.44MB emulated floppy with a block size of 1024 would look like: - EFI_WIN_NT_VIRTUAL_DISKS=RW;1440;1024 - - Physical Disks: These devices use NT to open a real device in your system - - Thus a 120 MB floppy would look like: - EFI_WIN_NT_PHYSICAL_DISKS=B:RW;245760;512 - - Thus a standard CD-ROM floppy would look like: - EFI_WIN_NT_PHYSICAL_DISKS=Z:RO;307200;2048 - - - * Other names and brands may be claimed as the property of others. - -**/ -#include -#include -#include -#include -#include -#include -#include -// -// The Library classes this module consumes -// -#include -#include -#include -#include -#include -#include -#include - -#include "WinNtBlockIo.h" - -EFI_DRIVER_BINDING_PROTOCOL gWinNtBlockIoDriverBinding = { - WinNtBlockIoDriverBindingSupported, - WinNtBlockIoDriverBindingStart, - WinNtBlockIoDriverBindingStop, - 0xa, - NULL, - NULL -}; - -/** - The user Entry Point for module WinNtBlockIo. The user code starts with this function. - - @param[in] ImageHandle The firmware allocated handle for the EFI image. - @param[in] SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS The entry point is executed successfully. - @retval other Some error occurs when executing this entry point. - -**/ -EFI_STATUS -EFIAPI -InitializeWinNtBlockIo( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - - // - // Install driver model protocol(s). - // - Status = EfiLibInstallAllDriverProtocols2 ( - ImageHandle, - SystemTable, - &gWinNtBlockIoDriverBinding, - ImageHandle, - &gWinNtBlockIoComponentName, - &gWinNtBlockIoComponentName2, - NULL, - NULL, - &gWinNtBlockIoDriverDiagnostics, - &gWinNtBlockIoDriverDiagnostics2 - ); - ASSERT_EFI_ERROR (Status); - - - return Status; -} - -EFI_STATUS -EFIAPI -WinNtBlockIoDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Handle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -/*++ - -Routine Description: - -Arguments: - -Returns: - - None - ---*/ -// TODO: This - add argument and description to function comment -// TODO: Handle - add argument and description to function comment -// TODO: RemainingDevicePath - add argument and description to function comment -{ - EFI_STATUS Status; - EFI_WIN_NT_IO_PROTOCOL *WinNtIo; - - // - // Open the IO Abstraction(s) needed to perform the supported test - // - Status = gBS->OpenProtocol ( - Handle, - &gEfiWinNtIoProtocolGuid, - (VOID **) &WinNtIo, - This->DriverBindingHandle, - Handle, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Make sure the WinNtThunkProtocol is valid - // - Status = EFI_UNSUPPORTED; - if (WinNtIo->WinNtThunk->Signature == EFI_WIN_NT_THUNK_PROTOCOL_SIGNATURE) { - - // - // Check the GUID to see if this is a handle type the driver supports - // - if (CompareGuid (WinNtIo->TypeGuid, &gEfiWinNtVirtualDisksGuid) || - CompareGuid (WinNtIo->TypeGuid, &gEfiWinNtPhysicalDisksGuid) ) { - Status = EFI_SUCCESS; - } - } - - // - // Close the I/O Abstraction(s) used to perform the supported test - // - gBS->CloseProtocol ( - Handle, - &gEfiWinNtIoProtocolGuid, - This->DriverBindingHandle, - Handle - ); - - return Status; -} - -EFI_STATUS -EFIAPI -WinNtBlockIoDriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Handle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -/*++ - -Routine Description: - -Arguments: - -Returns: - - None - ---*/ -// TODO: This - add argument and description to function comment -// TODO: Handle - add argument and description to function comment -// TODO: RemainingDevicePath - add argument and description to function comment -{ - EFI_STATUS Status; - EFI_WIN_NT_IO_PROTOCOL *WinNtIo; - WIN_NT_RAW_DISK_DEVICE_TYPE DiskType; - UINT16 Buffer[FILENAME_BUFFER_SIZE]; - CHAR16 *Str; - BOOLEAN RemovableMedia; - BOOLEAN WriteProtected; - UINTN NumberOfBlocks; - UINTN BlockSize; - - // - // Grab the protocols we need - // - Status = gBS->OpenProtocol ( - Handle, - &gEfiWinNtIoProtocolGuid, - (VOID **) &WinNtIo, - This->DriverBindingHandle, - Handle, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Set DiskType - // - if (CompareGuid (WinNtIo->TypeGuid, &gEfiWinNtVirtualDisksGuid)) { - DiskType = EfiWinNtVirtualDisks; - } else if (CompareGuid (WinNtIo->TypeGuid, &gEfiWinNtPhysicalDisksGuid)) { - DiskType = EfiWinNtPhysicalDisks; - } else { - Status = EFI_UNSUPPORTED; - goto Done; - } - - Status = EFI_NOT_FOUND; - Str = WinNtIo->EnvString; - if (DiskType == EfiWinNtVirtualDisks) { - WinNtIo->WinNtThunk->SPrintf ( - Buffer, - sizeof (Buffer), - L"Diskfile%d", - WinNtIo->InstanceNumber - ); - } else { - if (*Str >= 'A' && *Str <= 'Z' || *Str >= 'a' && *Str <= 'z') { - WinNtIo->WinNtThunk->SPrintf (Buffer, sizeof (Buffer), L"\\\\.\\%c:", *Str); - } else { - WinNtIo->WinNtThunk->SPrintf (Buffer, sizeof (Buffer), L"\\\\.\\PHYSICALDRIVE%c", *Str); - } - - Str++; - if (*Str != ':') { - Status = EFI_NOT_FOUND; - goto Done; - } - - Str++; - } - - if (*Str == 'R' || *Str == 'F') { - RemovableMedia = (BOOLEAN) (*Str == 'R'); - Str++; - if (*Str == 'O' || *Str == 'W') { - WriteProtected = (BOOLEAN) (*Str == 'O'); - Str = GetNextElementPastTerminator (Str, ';'); - - NumberOfBlocks = StrDecimalToUintn (Str); - if (NumberOfBlocks != 0) { - Str = GetNextElementPastTerminator (Str, ';'); - BlockSize = StrDecimalToUintn (Str); - if (BlockSize != 0) { - // - // If we get here the variable is valid so do the work. - // - Status = WinNtBlockIoCreateMapping ( - WinNtIo, - Handle, - Buffer, - WriteProtected, - RemovableMedia, - NumberOfBlocks, - BlockSize, - DiskType - ); - - } - } - } - } - -Done: - if (EFI_ERROR (Status)) { - gBS->CloseProtocol ( - Handle, - &gEfiWinNtIoProtocolGuid, - This->DriverBindingHandle, - Handle - ); - } - - return Status; -} - -EFI_STATUS -EFIAPI -WinNtBlockIoDriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Handle, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - This - TODO: add argument description - Handle - TODO: add argument description - NumberOfChildren - TODO: add argument description - ChildHandleBuffer - TODO: add argument description - -Returns: - - EFI_UNSUPPORTED - TODO: Add description for return value - ---*/ -{ - EFI_BLOCK_IO_PROTOCOL *BlockIo; - EFI_STATUS Status; - WIN_NT_BLOCK_IO_PRIVATE *Private; - - // - // Get our context back - // - Status = gBS->OpenProtocol ( - Handle, - &gEfiBlockIoProtocolGuid, - (VOID **) &BlockIo, - This->DriverBindingHandle, - Handle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - if (EFI_ERROR (Status)) { - return EFI_UNSUPPORTED; - } - - Private = WIN_NT_BLOCK_IO_PRIVATE_DATA_FROM_THIS (BlockIo); - - // - // BugBug: If we need to kick people off, we need to make Uninstall Close the handles. - // We could pass in our image handle or FLAG our open to be closed via - // Unistall (== to saying any CloseProtocol will close our open) - // - Status = gBS->UninstallMultipleProtocolInterfaces ( - Private->EfiHandle, - &gEfiBlockIoProtocolGuid, - &Private->BlockIo, - NULL - ); - if (!EFI_ERROR (Status)) { - - Status = gBS->CloseProtocol ( - Handle, - &gEfiWinNtIoProtocolGuid, - This->DriverBindingHandle, - Handle - ); - - // - // Shut down our device - // - Private->WinNtThunk->CloseHandle (Private->NtHandle); - - // - // Free our instance data - // - FreeUnicodeStringTable (Private->ControllerNameTable); - - FreePool (Private); - } - - return Status; -} - -CHAR16 * -GetNextElementPastTerminator ( - IN CHAR16 *EnvironmentVariable, - IN CHAR16 Terminator - ) -/*++ - -Routine Description: - - Worker function to parse environment variables. - -Arguments: - EnvironmentVariable - Envirnment variable to parse. - - Terminator - Terminator to parse for. - -Returns: - - Pointer to next eliment past the first occurence of Terminator or the '\0' - at the end of the string. - ---*/ -{ - CHAR16 *Ptr; - - for (Ptr = EnvironmentVariable; *Ptr != '\0'; Ptr++) { - if (*Ptr == Terminator) { - Ptr++; - break; - } - } - - return Ptr; -} - -EFI_STATUS -WinNtBlockIoCreateMapping ( - IN EFI_WIN_NT_IO_PROTOCOL *WinNtIo, - IN EFI_HANDLE EfiDeviceHandle, - IN CHAR16 *Filename, - IN BOOLEAN ReadOnly, - IN BOOLEAN RemovableMedia, - IN UINTN NumberOfBlocks, - IN UINTN BlockSize, - IN WIN_NT_RAW_DISK_DEVICE_TYPE DeviceType - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - WinNtIo - TODO: add argument description - EfiDeviceHandle - TODO: add argument description - Filename - TODO: add argument description - ReadOnly - TODO: add argument description - RemovableMedia - TODO: add argument description - NumberOfBlocks - TODO: add argument description - BlockSize - TODO: add argument description - DeviceType - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -{ - EFI_STATUS Status; - EFI_BLOCK_IO_PROTOCOL *BlockIo; - WIN_NT_BLOCK_IO_PRIVATE *Private; - UINTN Index; - - WinNtIo->WinNtThunk->SetErrorMode (SEM_FAILCRITICALERRORS); - - Private = AllocatePool (sizeof (WIN_NT_BLOCK_IO_PRIVATE)); - ASSERT (Private != NULL); - - EfiInitializeLock (&Private->Lock, TPL_NOTIFY); - - Private->WinNtThunk = WinNtIo->WinNtThunk; - - Private->Signature = WIN_NT_BLOCK_IO_PRIVATE_SIGNATURE; - Private->LastBlock = NumberOfBlocks - 1; - Private->BlockSize = BlockSize; - - for (Index = 0; Filename[Index] != 0; Index++) { - Private->Filename[Index] = Filename[Index]; - } - - Private->Filename[Index] = 0; - - Private->ReadMode = GENERIC_READ | (ReadOnly ? 0 : GENERIC_WRITE); - Private->ShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; - - Private->NumberOfBlocks = NumberOfBlocks; - Private->DeviceType = DeviceType; - Private->NtHandle = INVALID_HANDLE_VALUE; - - Private->ControllerNameTable = NULL; - - AddUnicodeString2 ( - "eng", - gWinNtBlockIoComponentName.SupportedLanguages, - &Private->ControllerNameTable, - Private->Filename, - TRUE - ); - AddUnicodeString2 ( - "en", - gWinNtBlockIoComponentName2.SupportedLanguages, - &Private->ControllerNameTable, - Private->Filename, - FALSE - ); - - - BlockIo = &Private->BlockIo; - BlockIo->Revision = EFI_BLOCK_IO_PROTOCOL_REVISION; - BlockIo->Media = &Private->Media; - BlockIo->Media->BlockSize = (UINT32)Private->BlockSize; - BlockIo->Media->LastBlock = Private->NumberOfBlocks - 1; - BlockIo->Media->MediaId = 0;; - - BlockIo->Reset = WinNtBlockIoResetBlock; - BlockIo->ReadBlocks = WinNtBlockIoReadBlocks; - BlockIo->WriteBlocks = WinNtBlockIoWriteBlocks; - BlockIo->FlushBlocks = WinNtBlockIoFlushBlocks; - - BlockIo->Media->ReadOnly = ReadOnly; - BlockIo->Media->RemovableMedia = RemovableMedia; - BlockIo->Media->LogicalPartition = FALSE; - BlockIo->Media->MediaPresent = TRUE; - BlockIo->Media->WriteCaching = FALSE; - - if (DeviceType == EfiWinNtVirtualDisks) { - BlockIo->Media->IoAlign = 1; - - // - // Create a file to use for a virtual disk even if it does not exist. - // - Private->OpenMode = OPEN_ALWAYS; - } else if (DeviceType == EfiWinNtPhysicalDisks) { - // - // Physical disk and floppy devices require 4 byte alignment. - // - BlockIo->Media->IoAlign = 4; - - // - // You can only open a physical device if it exists. - // - Private->OpenMode = OPEN_EXISTING; - } else { - ASSERT (FALSE); - } - - Private->EfiHandle = EfiDeviceHandle; - Status = WinNtBlockIoOpenDevice (Private); - if (!EFI_ERROR (Status)) { - - Status = gBS->InstallMultipleProtocolInterfaces ( - &Private->EfiHandle, - &gEfiBlockIoProtocolGuid, - &Private->BlockIo, - NULL - ); - if (EFI_ERROR (Status)) { - FreeUnicodeStringTable (Private->ControllerNameTable); - FreePool (Private); - } - - DEBUG ((EFI_D_INIT, "BlockDevice added: %s\n", Filename)); - } - - return Status; -} - -EFI_STATUS -WinNtBlockIoOpenDevice ( - WIN_NT_BLOCK_IO_PRIVATE *Private - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - Private - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -{ - EFI_STATUS Status; - UINT64 FileSize; - UINT64 EndOfFile; - EFI_BLOCK_IO_PROTOCOL *BlockIo; - - BlockIo = &Private->BlockIo; - EfiAcquireLock (&Private->Lock); - - // - // If the device is already opened, close it - // - if (Private->NtHandle != INVALID_HANDLE_VALUE) { - BlockIo->Reset (BlockIo, FALSE); - } - - // - // Open the device - // - Private->NtHandle = Private->WinNtThunk->CreateFile ( - Private->Filename, - (DWORD)Private->ReadMode, - (DWORD)Private->ShareMode, - NULL, - (DWORD)Private->OpenMode, - 0, - NULL - ); - - Status = Private->WinNtThunk->GetLastError (); - - if (Private->NtHandle == INVALID_HANDLE_VALUE) { - DEBUG ((EFI_D_INFO, "PlOpenBlock: Could not open %s, %x\n", Private->Filename, Private->WinNtThunk->GetLastError ())); - BlockIo->Media->MediaPresent = FALSE; - Status = EFI_NO_MEDIA; - goto Done; - } - - if (!BlockIo->Media->MediaPresent) { - // - // BugBug: try to emulate if a CD appears - notify drivers to check it out - // - BlockIo->Media->MediaPresent = TRUE; - EfiReleaseLock (&Private->Lock); - EfiAcquireLock (&Private->Lock); - } - - // - // get the size of the file - // - Status = SetFilePointer64 (Private, 0, &FileSize, FILE_END); - - if (EFI_ERROR (Status)) { - FileSize = MultU64x32 (Private->NumberOfBlocks, (UINT32)Private->BlockSize); - if (Private->DeviceType == EfiWinNtVirtualDisks) { - DEBUG ((EFI_D_ERROR, "PlOpenBlock: Could not get filesize of %s\n", Private->Filename)); - Status = EFI_UNSUPPORTED; - goto Done; - } - } - - if (Private->NumberOfBlocks == 0) { - Private->NumberOfBlocks = DivU64x32 (FileSize, (UINT32)Private->BlockSize); - } - - EndOfFile = MultU64x32 (Private->NumberOfBlocks, (UINT32)Private->BlockSize); - - if (FileSize != EndOfFile) { - // - // file is not the proper size, change it - // - DEBUG ((EFI_D_INIT, "PlOpenBlock: Initializing block device: %hs\n", Private->Filename)); - - // - // first set it to 0 - // - SetFilePointer64 (Private, 0, NULL, FILE_BEGIN); - Private->WinNtThunk->SetEndOfFile (Private->NtHandle); - - // - // then set it to the needed file size (OS will zero fill it) - // - SetFilePointer64 (Private, EndOfFile, NULL, FILE_BEGIN); - Private->WinNtThunk->SetEndOfFile (Private->NtHandle); - } - - DEBUG ((EFI_D_INIT, "%HPlOpenBlock: opened %s%N\n", Private->Filename)); - Status = EFI_SUCCESS; - -Done: - if (EFI_ERROR (Status)) { - if (Private->NtHandle != INVALID_HANDLE_VALUE) { - BlockIo->Reset (BlockIo, FALSE); - } - } - - EfiReleaseLock (&Private->Lock); - return Status; -} - -EFI_STATUS -WinNtBlockIoError ( - IN WIN_NT_BLOCK_IO_PRIVATE *Private - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - Private - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -{ - EFI_BLOCK_IO_PROTOCOL *BlockIo; - EFI_STATUS Status; - BOOLEAN ReinstallBlockIoFlag; - - BlockIo = &Private->BlockIo; - - switch (Private->WinNtThunk->GetLastError ()) { - - case ERROR_NOT_READY: - Status = EFI_NO_MEDIA; - BlockIo->Media->ReadOnly = FALSE; - BlockIo->Media->MediaPresent = FALSE; - ReinstallBlockIoFlag = FALSE; - break; - - case ERROR_WRONG_DISK: - BlockIo->Media->ReadOnly = FALSE; - BlockIo->Media->MediaPresent = TRUE; - BlockIo->Media->MediaId += 1; - ReinstallBlockIoFlag = TRUE; - Status = EFI_MEDIA_CHANGED; - break; - - case ERROR_WRITE_PROTECT: - BlockIo->Media->ReadOnly = TRUE; - ReinstallBlockIoFlag = FALSE; - Status = EFI_WRITE_PROTECTED; - break; - - default: - ReinstallBlockIoFlag = FALSE; - Status = EFI_DEVICE_ERROR; - break; - } - - if (ReinstallBlockIoFlag) { - BlockIo->Reset (BlockIo, FALSE); - - gBS->ReinstallProtocolInterface ( - Private->EfiHandle, - &gEfiBlockIoProtocolGuid, - BlockIo, - BlockIo - ); - } - - return Status; -} - -EFI_STATUS -WinNtBlockIoReadWriteCommon ( - IN WIN_NT_BLOCK_IO_PRIVATE *Private, - IN UINT32 MediaId, - IN EFI_LBA Lba, - IN UINTN BufferSize, - IN VOID *Buffer, - IN CHAR8 *CallerName - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - Private - TODO: add argument description - MediaId - TODO: add argument description - Lba - TODO: add argument description - BufferSize - TODO: add argument description - Buffer - TODO: add argument description - CallerName - TODO: add argument description - -Returns: - - EFI_NO_MEDIA - TODO: Add description for return value - EFI_MEDIA_CHANGED - TODO: Add description for return value - EFI_INVALID_PARAMETER - TODO: Add description for return value - EFI_SUCCESS - TODO: Add description for return value - EFI_BAD_BUFFER_SIZE - TODO: Add description for return value - EFI_INVALID_PARAMETER - TODO: Add description for return value - EFI_SUCCESS - TODO: Add description for return value - ---*/ -{ - EFI_STATUS Status; - UINTN BlockSize; - UINT64 LastBlock; - INT64 DistanceToMove; - UINT64 DistanceMoved; - - if (Private->NtHandle == INVALID_HANDLE_VALUE) { - Status = WinNtBlockIoOpenDevice (Private); - if (EFI_ERROR (Status)) { - return Status; - } - } - - if (!Private->Media.MediaPresent) { - DEBUG ((EFI_D_INIT, "%s: No Media\n", CallerName)); - return EFI_NO_MEDIA; - } - - if (Private->Media.MediaId != MediaId) { - return EFI_MEDIA_CHANGED; - } - - if ((UINTN) Buffer % Private->Media.IoAlign != 0) { - return EFI_INVALID_PARAMETER; - } - - // - // Verify buffer size - // - BlockSize = Private->BlockSize; - if (BufferSize == 0) { - DEBUG ((EFI_D_INIT, "%s: Zero length read\n", CallerName)); - return EFI_SUCCESS; - } - - if ((BufferSize % BlockSize) != 0) { - DEBUG ((EFI_D_INIT, "%s: Invalid read size\n", CallerName)); - return EFI_BAD_BUFFER_SIZE; - } - - LastBlock = Lba + (BufferSize / BlockSize) - 1; - if (LastBlock > Private->LastBlock) { - DEBUG ((EFI_D_INIT, "ReadBlocks: Attempted to read off end of device\n")); - return EFI_INVALID_PARAMETER; - } - // - // Seek to End of File - // - DistanceToMove = MultU64x32 (Lba, (UINT32)BlockSize); - Status = SetFilePointer64 (Private, DistanceToMove, &DistanceMoved, FILE_BEGIN); - - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_INIT, "WriteBlocks: SetFilePointer failed\n")); - return WinNtBlockIoError (Private); - } - - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -WinNtBlockIoReadBlocks ( - IN EFI_BLOCK_IO_PROTOCOL *This, - IN UINT32 MediaId, - IN EFI_LBA Lba, - IN UINTN BufferSize, - OUT VOID *Buffer - ) -/*++ - - Routine Description: - Read BufferSize bytes from Lba into Buffer. - - Arguments: - This - Protocol instance pointer. - MediaId - Id of the media, changes every time the media is replaced. - Lba - The starting Logical Block Address to read from - BufferSize - Size of Buffer, must be a multiple of device block size. - Buffer - Buffer containing read data - - Returns: - EFI_SUCCESS - The data was read correctly from the device. - EFI_DEVICE_ERROR - The device reported an error while performing the read. - EFI_NO_MEDIA - There is no media in the device. - EFI_MEDIA_CHANGED - The MediaId does not matched the current device. - EFI_BAD_BUFFER_SIZE - The Buffer was not a multiple of the block size of the - device. - EFI_INVALID_PARAMETER - The read request contains device addresses that are not - valid for the device. - ---*/ -{ - WIN_NT_BLOCK_IO_PRIVATE *Private; - BOOL Flag; - EFI_STATUS Status; - DWORD BytesRead; - EFI_TPL OldTpl; - - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - - Private = WIN_NT_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This); - - Status = WinNtBlockIoReadWriteCommon (Private, MediaId, Lba, BufferSize, Buffer, "WinNtReadBlocks"); - if (EFI_ERROR (Status)) { - goto Done; - } - - Flag = Private->WinNtThunk->ReadFile (Private->NtHandle, Buffer, (DWORD) BufferSize, (LPDWORD) &BytesRead, NULL); - if (!Flag || (BytesRead != BufferSize)) { - DEBUG ((EFI_D_INIT, "ReadBlocks: ReadFile failed. (%d)\n", Private->WinNtThunk->GetLastError ())); - Status = WinNtBlockIoError (Private); - goto Done; - } - - // - // If we wrote then media is present. - // - This->Media->MediaPresent = TRUE; - Status = EFI_SUCCESS; - -Done: - gBS->RestoreTPL (OldTpl); - return Status; -} - -EFI_STATUS -EFIAPI -WinNtBlockIoWriteBlocks ( - IN EFI_BLOCK_IO_PROTOCOL *This, - IN UINT32 MediaId, - IN EFI_LBA Lba, - IN UINTN BufferSize, - IN VOID *Buffer - ) -/*++ - - Routine Description: - Write BufferSize bytes from Lba into Buffer. - - Arguments: - This - Protocol instance pointer. - MediaId - Id of the media, changes every time the media is replaced. - Lba - The starting Logical Block Address to read from - BufferSize - Size of Buffer, must be a multiple of device block size. - Buffer - Buffer containing read data - - Returns: - EFI_SUCCESS - The data was written correctly to the device. - EFI_WRITE_PROTECTED - The device can not be written to. - EFI_DEVICE_ERROR - The device reported an error while performing the write. - EFI_NO_MEDIA - There is no media in the device. - EFI_MEDIA_CHNAGED - The MediaId does not matched the current device. - EFI_BAD_BUFFER_SIZE - The Buffer was not a multiple of the block size of the - device. - EFI_INVALID_PARAMETER - The write request contains a LBA that is not - valid for the device. - ---*/ -{ - WIN_NT_BLOCK_IO_PRIVATE *Private; - UINTN BytesWritten; - BOOL Flag; - BOOL Locked; - EFI_STATUS Status; - EFI_TPL OldTpl; - UINTN BytesReturned; - - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - - Private = WIN_NT_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This); - - Status = WinNtBlockIoReadWriteCommon (Private, MediaId, Lba, BufferSize, Buffer, "WinNtWriteBlocks"); - if (EFI_ERROR (Status)) { - goto Done; - } - - // - // According the Windows requirement, first need to lock the volume before - // write to it. - // - if (Private->DeviceType == EfiWinNtPhysicalDisks) { - Locked = Private->WinNtThunk->DeviceIoControl (Private->NtHandle, FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0, &BytesReturned, NULL); - if (Locked == 0) { - DEBUG ((EFI_D_INIT, "ReadBlocks: Lock volume failed. (%d)\n", Private->WinNtThunk->GetLastError ())); - Status = WinNtBlockIoError (Private); - goto Done; - } - } else { - Locked = 0; - } - Flag = Private->WinNtThunk->WriteFile (Private->NtHandle, Buffer, (DWORD) BufferSize, (LPDWORD) &BytesWritten, NULL); - if (Locked != 0) { - Private->WinNtThunk->DeviceIoControl (Private->NtHandle, FSCTL_UNLOCK_VOLUME, NULL, 0, NULL, 0, &BytesReturned, NULL); - } - if (!Flag || (BytesWritten != BufferSize)) { - DEBUG ((EFI_D_INIT, "ReadBlocks: WriteFile failed. (%d)\n", Private->WinNtThunk->GetLastError ())); - Status = WinNtBlockIoError (Private); - goto Done; - } - - // - // If the write succeeded, we are not write protected and media is present. - // - This->Media->MediaPresent = TRUE; - This->Media->ReadOnly = FALSE; - Status = EFI_SUCCESS; - -Done: - gBS->RestoreTPL (OldTpl); - return Status; - -} - -EFI_STATUS -EFIAPI -WinNtBlockIoFlushBlocks ( - IN EFI_BLOCK_IO_PROTOCOL *This - ) -/*++ - - Routine Description: - Flush the Block Device. - - Arguments: - This - Protocol instance pointer. - - Returns: - EFI_SUCCESS - All outstanding data was written to the device - EFI_DEVICE_ERROR - The device reported an error while writting back the data - EFI_NO_MEDIA - There is no media in the device. - ---*/ -{ - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -WinNtBlockIoResetBlock ( - IN EFI_BLOCK_IO_PROTOCOL *This, - IN BOOLEAN ExtendedVerification - ) -/*++ - - Routine Description: - Reset the Block Device. - - Arguments: - This - Protocol instance pointer. - ExtendedVerification - Driver may perform diagnostics on reset. - - Returns: - EFI_SUCCESS - The device was reset. - EFI_DEVICE_ERROR - The device is not functioning properly and could - not be reset. - ---*/ -{ - WIN_NT_BLOCK_IO_PRIVATE *Private; - EFI_TPL OldTpl; - - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - - Private = WIN_NT_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This); - - if (Private->NtHandle != INVALID_HANDLE_VALUE) { - Private->WinNtThunk->CloseHandle (Private->NtHandle); - Private->NtHandle = INVALID_HANDLE_VALUE; - } - - gBS->RestoreTPL (OldTpl); - - return EFI_SUCCESS; -} - - -EFI_STATUS -SetFilePointer64 ( - IN WIN_NT_BLOCK_IO_PRIVATE *Private, - IN INT64 DistanceToMove, - OUT UINT64 *NewFilePointer, - IN DWORD MoveMethod - ) -/*++ - -This function extends the capability of SetFilePointer to accept 64 bit parameters - ---*/ -// TODO: function comment is missing 'Routine Description:' -// TODO: function comment is missing 'Arguments:' -// TODO: function comment is missing 'Returns:' -// TODO: Private - add argument and description to function comment -// TODO: DistanceToMove - add argument and description to function comment -// TODO: NewFilePointer - add argument and description to function comment -// TODO: MoveMethod - add argument and description to function comment -{ - EFI_STATUS Status; - LARGE_INTEGER LargeInt; - - LargeInt.QuadPart = DistanceToMove; - Status = EFI_SUCCESS; - - LargeInt.LowPart = Private->WinNtThunk->SetFilePointer ( - Private->NtHandle, - LargeInt.LowPart, - &LargeInt.HighPart, - MoveMethod - ); - - if (LargeInt.LowPart == -1 && Private->WinNtThunk->GetLastError () != NO_ERROR) { - Status = EFI_INVALID_PARAMETER; - } - - if (NewFilePointer != NULL) { - *NewFilePointer = LargeInt.QuadPart; - } - - return Status; -} diff --git a/Nt32Pkg/WinNtBlockIoDxe/WinNtBlockIo.h b/Nt32Pkg/WinNtBlockIoDxe/WinNtBlockIo.h deleted file mode 100644 index b0fd31aa75..0000000000 --- a/Nt32Pkg/WinNtBlockIoDxe/WinNtBlockIo.h +++ /dev/null @@ -1,474 +0,0 @@ -/**@file - -Copyright (c) 2006, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - WinNtBlockIo.h - -Abstract: - - Produce block IO abstractions for real devices on your PC using Win32 APIs. - The configuration of what devices to mount or emulate comes from NT - environment variables. The variables must be visible to the Microsoft* - Developer Studio for them to work. - - * Other names and brands may be claimed as the property of others. - -**/ - -#ifndef _WIN_NT_BLOCK_IO_H_ -#define _WIN_NT_BLOCK_IO_H_ - -#include -#include -#include -#include -#include -#include -#include -// -// The Library classes this module consumes -// -#include -#include -#include -#include -#include -#include -#include - -#define FILENAME_BUFFER_SIZE 80 - -// -// Language supported for driverconfiguration protocol -// -#define LANGUAGESUPPORTED "eng" - -typedef enum { - EfiWinNtVirtualDisks, - EfiWinNtPhysicalDisks, - EifWinNtMaxTypeDisks -} WIN_NT_RAW_DISK_DEVICE_TYPE; - -#define WIN_NT_BLOCK_IO_PRIVATE_SIGNATURE SIGNATURE_32 ('N', 'T', 'b', 'k') -typedef struct { - UINTN Signature; - - EFI_LOCK Lock; - - CHAR16 Filename[FILENAME_BUFFER_SIZE]; - UINTN ReadMode; - UINTN ShareMode; - UINTN OpenMode; - - HANDLE NtHandle; - WIN_NT_RAW_DISK_DEVICE_TYPE DeviceType; - - UINT64 LastBlock; - UINTN BlockSize; - UINT64 NumberOfBlocks; - - EFI_HANDLE EfiHandle; - EFI_BLOCK_IO_PROTOCOL BlockIo; - EFI_BLOCK_IO_MEDIA Media; - - EFI_UNICODE_STRING_TABLE *ControllerNameTable; - - EFI_WIN_NT_THUNK_PROTOCOL *WinNtThunk; - -} WIN_NT_BLOCK_IO_PRIVATE; - -#define WIN_NT_BLOCK_IO_PRIVATE_DATA_FROM_THIS(a) \ - CR(a, WIN_NT_BLOCK_IO_PRIVATE, BlockIo, WIN_NT_BLOCK_IO_PRIVATE_SIGNATURE) - -#define LIST_BUFFER_SIZE 512 - -// -// Block I/O Global Variables -// -extern EFI_DRIVER_BINDING_PROTOCOL gWinNtBlockIoDriverBinding; -extern EFI_COMPONENT_NAME_PROTOCOL gWinNtBlockIoComponentName; -extern EFI_COMPONENT_NAME2_PROTOCOL gWinNtBlockIoComponentName2; -extern EFI_DRIVER_CONFIGURATION_PROTOCOL gWinNtBlockIoDriverConfiguration; -extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL gWinNtBlockIoDriverDiagnostics; -extern EFI_DRIVER_DIAGNOSTICS2_PROTOCOL gWinNtBlockIoDriverDiagnostics2; - -// -// EFI Driver Binding Functions -// -EFI_STATUS -EFIAPI -WinNtBlockIoDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Handle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - This - TODO: add argument description - Handle - TODO: add argument description - RemainingDevicePath - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -EFIAPI -WinNtBlockIoDriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Handle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - This - TODO: add argument description - Handle - TODO: add argument description - RemainingDevicePath - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -EFIAPI -WinNtBlockIoDriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Handle, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - This - TODO: add argument description - Handle - TODO: add argument description - NumberOfChildren - TODO: add argument description - ChildHandleBuffer - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -// -// Block IO protocol member functions -// -EFI_STATUS -EFIAPI -WinNtBlockIoReadBlocks ( - IN EFI_BLOCK_IO_PROTOCOL *This, - IN UINT32 MediaId, - IN EFI_LBA Lba, - IN UINTN BufferSize, - OUT VOID *Buffer - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - This - TODO: add argument description - MediaId - TODO: add argument description - Lba - TODO: add argument description - BufferSize - TODO: add argument description - Buffer - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -EFIAPI -WinNtBlockIoWriteBlocks ( - IN EFI_BLOCK_IO_PROTOCOL *This, - IN UINT32 MediaId, - IN EFI_LBA Lba, - IN UINTN BufferSize, - IN VOID *Buffer - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - This - TODO: add argument description - MediaId - TODO: add argument description - Lba - TODO: add argument description - BufferSize - TODO: add argument description - Buffer - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -EFIAPI -WinNtBlockIoFlushBlocks ( - IN EFI_BLOCK_IO_PROTOCOL *This - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - This - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -EFIAPI -WinNtBlockIoResetBlock ( - IN EFI_BLOCK_IO_PROTOCOL *This, - IN BOOLEAN ExtendedVerification - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - This - TODO: add argument description - ExtendedVerification - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -// -// Private Worker functions -// -EFI_STATUS -WinNtBlockIoCreateMapping ( - IN EFI_WIN_NT_IO_PROTOCOL *WinNtIo, - IN EFI_HANDLE EfiDeviceHandle, - IN CHAR16 *Filename, - IN BOOLEAN ReadOnly, - IN BOOLEAN RemovableMedia, - IN UINTN NumberOfBlocks, - IN UINTN BlockSize, - IN WIN_NT_RAW_DISK_DEVICE_TYPE DeviceType - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - WinNtIo - TODO: add argument description - EfiDeviceHandle - TODO: add argument description - Filename - TODO: add argument description - ReadOnly - TODO: add argument description - RemovableMedia - TODO: add argument description - NumberOfBlocks - TODO: add argument description - BlockSize - TODO: add argument description - DeviceType - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -WinNtBlockIoReadWriteCommon ( - IN WIN_NT_BLOCK_IO_PRIVATE *Private, - IN UINT32 MediaId, - IN EFI_LBA Lba, - IN UINTN BufferSize, - IN VOID *Buffer, - IN CHAR8 *CallerName - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - Private - TODO: add argument description - MediaId - TODO: add argument description - Lba - TODO: add argument description - BufferSize - TODO: add argument description - Buffer - TODO: add argument description - CallerName - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -WinNtBlockIoError ( - IN WIN_NT_BLOCK_IO_PRIVATE *Private - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - Private - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -WinNtBlockIoOpenDevice ( - WIN_NT_BLOCK_IO_PRIVATE *Private - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - Private - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -CHAR16 * -GetNextElementPastTerminator ( - IN CHAR16 *EnvironmentVariable, - IN CHAR16 Terminator - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - EnvironmentVariable - TODO: add argument description - Terminator - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - - - -EFI_STATUS -SetFilePointer64 ( - IN WIN_NT_BLOCK_IO_PRIVATE *Private, - IN INT64 DistanceToMove, - OUT UINT64 *NewFilePointer, - IN DWORD MoveMethod - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - Private - TODO: add argument description - DistanceToMove - TODO: add argument description - NewFilePointer - TODO: add argument description - MoveMethod - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -UINTN -Atoi ( - CHAR16 *String - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - String - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -#endif diff --git a/Nt32Pkg/WinNtBlockIoDxe/WinNtBlockIoDxe.inf b/Nt32Pkg/WinNtBlockIoDxe/WinNtBlockIoDxe.inf deleted file mode 100644 index b7ba6659e8..0000000000 --- a/Nt32Pkg/WinNtBlockIoDxe/WinNtBlockIoDxe.inf +++ /dev/null @@ -1,65 +0,0 @@ -## @file -# Block Io driver -# -# Produce block IO abstractions for real devices on your PC using Win32 APIs. -# The configuration of what devices to mount or emulate comes from NT -# environment variables. The variables must be visible to the Microsoft* -# Developer Studio for them to work. -# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
-# -# SPDX-License-Identifier: BSD-2-Clause-Patent -# -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = WinNtBlockIo - FILE_GUID = F479E147-A125-11d4-BCFC-0080C73C8881 - MODULE_TYPE = UEFI_DRIVER - VERSION_STRING = 1.0 - - ENTRY_POINT = InitializeWinNtBlockIo - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 -# -# DRIVER_BINDING = gWinNtBlockIoDriverBinding -# COMPONENT_NAME = gWinNtBlockIoComponentName -# DRIVER_DIAG = gWinNtBlockIoDriverDiagnostics -# - -[Sources] - DriverDiagnostics.c - DriverConfiguration.c - ComponentName.c - WinNtBlockIo.c - WinNtBlockIo.h - - -[Packages] - MdePkg/MdePkg.dec - Nt32Pkg/Nt32Pkg.dec - - -[LibraryClasses] - MemoryAllocationLib - UefiBootServicesTableLib - BaseMemoryLib - UefiLib - UefiDriverEntryPoint - BaseLib - DebugLib - - -[Guids] - gEfiWinNtPhysicalDisksGuid # SOMETIMES_CONSUMED - gEfiWinNtVirtualDisksGuid # ALWAYS_CONSUMED - - -[Protocols] - gEfiBlockIoProtocolGuid # PROTOCOL BY_START - gEfiWinNtIoProtocolGuid # PROTOCOL TO_START - diff --git a/Nt32Pkg/WinNtBusDriverDxe/ComponentName.c b/Nt32Pkg/WinNtBusDriverDxe/ComponentName.c deleted file mode 100644 index 70e9545de5..0000000000 --- a/Nt32Pkg/WinNtBusDriverDxe/ComponentName.c +++ /dev/null @@ -1,375 +0,0 @@ -/**@file - -Copyright (c) 2006, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - ComponentName.c - -Abstract: - -**/ - -// -// The package level header files this module uses -// -#include -#include -// -// The protocols, PPI and GUID defintions for this module -// -#include -#include -#include -#include -#include - - -#include "WinNtBusDriver.h" - -// -// EFI Component Name Functions -// -/** - Retrieves a Unicode string that is the user readable name of the driver. - - This function retrieves the user readable name of a driver in the form of a - Unicode string. If the driver specified by This has a user readable name in - the language specified by Language, then a pointer to the driver name is - returned in DriverName, and EFI_SUCCESS is returned. If the driver specified - by This does not support the language specified by Language, - then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified - in RFC 4646 or ISO 639-2 language code format. - - @param DriverName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - driver specified by This in the language - specified by Language. - - @retval EFI_SUCCESS The Unicode string for the Driver specified by - This and the language specified by Language was - returned in DriverName. - - @retval EFI_INVALID_PARAMETER Language is NULL. - - @retval EFI_INVALID_PARAMETER DriverName is NULL. - - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -WinNtBusDriverComponentNameGetDriverName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName - ); - - -/** - Retrieves a Unicode string that is the user readable name of the controller - that is being managed by a driver. - - This function retrieves the user readable name of the controller specified by - ControllerHandle and ChildHandle in the form of a Unicode string. If the - driver specified by This has a user readable name in the language specified by - Language, then a pointer to the controller name is returned in ControllerName, - and EFI_SUCCESS is returned. If the driver specified by This is not currently - managing the controller specified by ControllerHandle and ChildHandle, - then EFI_UNSUPPORTED is returned. If the driver specified by This does not - support the language specified by Language, then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - - @param ControllerHandle[in] The handle of a controller that the driver - specified by This is managing. This handle - specifies the controller whose name is to be - returned. - - @param ChildHandle[in] The handle of the child controller to retrieve - the name of. This is an optional parameter that - may be NULL. It will be NULL for device - drivers. It will also be NULL for a bus drivers - that wish to retrieve the name of the bus - controller. It will not be NULL for a bus - driver that wishes to retrieve the name of a - child controller. - - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified in - RFC 4646 or ISO 639-2 language code format. - - @param ControllerName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - controller specified by ControllerHandle and - ChildHandle in the language specified by - Language from the point of view of the driver - specified by This. - - @retval EFI_SUCCESS The Unicode string for the user readable name in - the language specified by Language for the - driver specified by This was returned in - DriverName. - - @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. - - @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid - EFI_HANDLE. - - @retval EFI_INVALID_PARAMETER Language is NULL. - - @retval EFI_INVALID_PARAMETER ControllerName is NULL. - - @retval EFI_UNSUPPORTED The driver specified by This is not currently - managing the controller specified by - ControllerHandle and ChildHandle. - - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -WinNtBusDriverComponentNameGetControllerName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName - ); - - -// -// EFI Component Name Protocol -// -GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gWinNtBusDriverComponentName = { - WinNtBusDriverComponentNameGetDriverName, - WinNtBusDriverComponentNameGetControllerName, - "eng" -}; - -// -// EFI Component Name 2 Protocol -// -GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gWinNtBusDriverComponentName2 = { - (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) WinNtBusDriverComponentNameGetDriverName, - (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) WinNtBusDriverComponentNameGetControllerName, - "en" -}; - - -GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mWinNtBusDriverNameTable[] = { - { "eng;en", L"Windows Bus Driver" }, - { NULL , NULL } -}; - -/** - Retrieves a Unicode string that is the user readable name of the driver. - - This function retrieves the user readable name of a driver in the form of a - Unicode string. If the driver specified by This has a user readable name in - the language specified by Language, then a pointer to the driver name is - returned in DriverName, and EFI_SUCCESS is returned. If the driver specified - by This does not support the language specified by Language, - then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified - in RFC 4646 or ISO 639-2 language code format. - - @param DriverName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - driver specified by This in the language - specified by Language. - - @retval EFI_SUCCESS The Unicode string for the Driver specified by - This and the language specified by Language was - returned in DriverName. - - @retval EFI_INVALID_PARAMETER Language is NULL. - - @retval EFI_INVALID_PARAMETER DriverName is NULL. - - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -WinNtBusDriverComponentNameGetDriverName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName - ) -{ - return LookupUnicodeString2 ( - Language, - This->SupportedLanguages, - mWinNtBusDriverNameTable, - DriverName, - (BOOLEAN)(This == &gWinNtBusDriverComponentName) - ); -} - -/** - Retrieves a Unicode string that is the user readable name of the controller - that is being managed by a driver. - - This function retrieves the user readable name of the controller specified by - ControllerHandle and ChildHandle in the form of a Unicode string. If the - driver specified by This has a user readable name in the language specified by - Language, then a pointer to the controller name is returned in ControllerName, - and EFI_SUCCESS is returned. If the driver specified by This is not currently - managing the controller specified by ControllerHandle and ChildHandle, - then EFI_UNSUPPORTED is returned. If the driver specified by This does not - support the language specified by Language, then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - - @param ControllerHandle[in] The handle of a controller that the driver - specified by This is managing. This handle - specifies the controller whose name is to be - returned. - - @param ChildHandle[in] The handle of the child controller to retrieve - the name of. This is an optional parameter that - may be NULL. It will be NULL for device - drivers. It will also be NULL for a bus drivers - that wish to retrieve the name of the bus - controller. It will not be NULL for a bus - driver that wishes to retrieve the name of a - child controller. - - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified in - RFC 4646 or ISO 639-2 language code format. - - @param ControllerName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - controller specified by ControllerHandle and - ChildHandle in the language specified by - Language from the point of view of the driver - specified by This. - - @retval EFI_SUCCESS The Unicode string for the user readable name in - the language specified by Language for the - driver specified by This was returned in - DriverName. - - @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. - - @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid - EFI_HANDLE. - - @retval EFI_INVALID_PARAMETER Language is NULL. - - @retval EFI_INVALID_PARAMETER ControllerName is NULL. - - @retval EFI_UNSUPPORTED The driver specified by This is not currently - managing the controller specified by - ControllerHandle and ChildHandle. - - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -WinNtBusDriverComponentNameGetControllerName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName - ) -{ - EFI_STATUS Status; - EFI_WIN_NT_IO_PROTOCOL *WinNtIo; - WIN_NT_IO_DEVICE *Private; - - // - // Make sure this driver is currently managing ControllHandle - // - Status = EfiTestManagedDevice ( - ControllerHandle, - gWinNtBusDriverBinding.DriverBindingHandle, - &gEfiWinNtThunkProtocolGuid - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // This is a bus driver, so ChildHandle can not be NULL. - // - if (ChildHandle == NULL) { - return EFI_UNSUPPORTED; - } - - Status = EfiTestChildHandle ( - ControllerHandle, - ChildHandle, - &gEfiWinNtThunkProtocolGuid - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Get our context back - // - Status = gBS->OpenProtocol ( - ChildHandle, - &gEfiWinNtIoProtocolGuid, - (VOID **) &WinNtIo, - gWinNtBusDriverBinding.DriverBindingHandle, - ChildHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - if (EFI_ERROR (Status)) { - return EFI_UNSUPPORTED; - } - - Private = WIN_NT_IO_DEVICE_FROM_THIS (WinNtIo); - - return LookupUnicodeString2 ( - Language, - This->SupportedLanguages, - Private->ControllerNameTable, - ControllerName, - (BOOLEAN)(This == &gWinNtBusDriverComponentName) - ); -} diff --git a/Nt32Pkg/WinNtBusDriverDxe/WinNtBusDriver.c b/Nt32Pkg/WinNtBusDriverDxe/WinNtBusDriver.c deleted file mode 100644 index f4b7e1ba15..0000000000 --- a/Nt32Pkg/WinNtBusDriverDxe/WinNtBusDriver.c +++ /dev/null @@ -1,799 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
-(C) Copyright 2018 Hewlett Packard Enterprise Development LP
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - WinNtBusDriver.c - -Abstract: - -This following section documents the envirnoment variables for the Win NT -build. These variables are used to define the (virtual) hardware -configuration of the NT environment - -A ! can be used to seperate multiple instances in a variable. Each -instance represents a seperate hardware device. - -EFI_WIN_NT_PHYSICAL_DISKS - maps to drives on your system -EFI_WIN_NT_VIRTUAL_DISKS - maps to a device emulated by a file -EFI_WIN_NT_FILE_SYSTEM - mouts a directory as a file system -EFI_WIN_NT_CONSOLE - make a logical comand line window (only one!) -EFI_WIN_NT_GOP - Builds GOP Windows of Width and Height -EFI_WIN_NT_SERIAL_PORT - maps physical serial ports - - ixed - Fixed disk like a hard drive. - emovable - Removable media like a floppy or CD-ROM. - Read nly - Write protected device. - Read rite - Read write device. - - Decimal number of blocks a device supports. - - Decimal number of bytes per block. - - NT envirnonment variable contents. '<' and '>' are not part of the variable, - they are just used to make this help more readable. There should be no - spaces between the ';'. Extra spaces will break the variable. A '!' is - used to seperate multiple devices in a variable. - - EFI_WIN_NT_VIRTUAL_DISKS = - ;;[!...] - - EFI_WIN_NT_PHYSICAL_DISKS = - :;;[!...] - - Virtual Disks: These devices use a file to emulate a hard disk or removable - media device. - - Thus a 20 MB emulated hard drive would look like: - EFI_WIN_NT_VIRTUAL_DISKS=FW;40960;512 - - A 1.44MB emulated floppy with a block size of 1024 would look like: - EFI_WIN_NT_VIRTUAL_DISKS=RW;1440;1024 - - Physical Disks: These devices use NT to open a real device in your system - - Thus a 120 MB floppy would look like: - EFI_WIN_NT_PHYSICAL_DISKS=B:RW;245760;512 - - Thus a standard CD-ROM floppy would look like: - EFI_WIN_NT_PHYSICAL_DISKS=Z:RO;307200;2048 - - EFI_WIN_NT_FILE_SYSTEM = - [!...] - - Mounting the two directories C:\FOO and C:\BAR would look like: - EFI_WIN_NT_FILE_SYSTEM=c:\foo!c:\bar - - EFI_WIN_NT_CONSOLE = - - - Declaring a text console window with the title "My EFI Console" woild look like: - EFI_WIN_NT_CONSOLE=My EFI Console - - EFI_WIN_NT_GOP = - [!...] - - Declaring a two GOP windows with resolutions of 800x600 and 1024x768 would look like: - Example : EFI_WIN_NT_GOP=800 600!1024 768 - - EFI_WIN_NT_SERIAL_PORT = - [!...] - - Declaring two serial ports on COM1 and COM2 would look like: - Example : EFI_WIN_NT_SERIAL_PORT=COM1!COM2 - - EFI_WIN_NT_PASS_THROUGH = - ;;; - - Declaring a base address of 0xE0000000 (used for PCI Express devices) - and having NT32 talk to a device located at bus 0, device 1, function 0: - Example : EFI_WIN_NT_PASS_THROUGH=E000000;0;1;0 - ----*/ - -// -// The package level header files this module uses -// -#include -#include -// -// The protocols, PPI and GUID defintions for this module -// -#include -#include -#include -#include -#include -// -// The Library classes this module consumes -// -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "WinNtBusDriver.h" - -extern EFI_GUID gWinNtBusDriverGuid; -// -// DriverBinding protocol global -// -EFI_DRIVER_BINDING_PROTOCOL gWinNtBusDriverBinding = { - WinNtBusDriverBindingSupported, - WinNtBusDriverBindingStart, - WinNtBusDriverBindingStop, - 0xa, - NULL, - NULL -}; - -#define NT_PCD_ARRAY_SIZE (sizeof(mPcdEnvironment)/sizeof(NT_PCD_ENTRY)) - -// -// Table to map NT Environment variable to the GUID that should be in -// device path. -// -NT_PCD_ENTRY mPcdEnvironment[] = { - PcdToken(PcdWinNtConsole), &gEfiWinNtConsoleGuid, - PcdToken(PcdWinNtGop), &gEfiWinNtGopGuid, - PcdToken(PcdWinNtSerialPort), &gEfiWinNtSerialPortGuid, - PcdToken(PcdWinNtFileSystem), &gEfiWinNtFileSystemGuid, - PcdToken(PcdWinNtVirtualDisk), &gEfiWinNtVirtualDisksGuid, - PcdToken(PcdWinNtPhysicalDisk), &gEfiWinNtPhysicalDisksGuid -}; - -/** - The user Entry Point for module WinNtBusDriver. The user code starts with this function. - - @param[in] ImageHandle The firmware allocated handle for the EFI image. - @param[in] SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS The entry point is executed successfully. - @retval other Some error occurs when executing this entry point. - -**/ -EFI_STATUS -EFIAPI -InitializeWinNtBusDriver( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - - // - // Install driver model protocol(s). - // - Status = EfiLibInstallDriverBindingComponentName2 ( - ImageHandle, - SystemTable, - &gWinNtBusDriverBinding, - ImageHandle, - &gWinNtBusDriverComponentName, - &gWinNtBusDriverComponentName2 - ); - ASSERT_EFI_ERROR (Status); - - - return Status; -} - -VOID * -AllocateMemory ( - IN UINTN Size - ) -{ - VOID *Buffer; - - Buffer = AllocatePool (Size); - ASSERT (Buffer != NULL); - - return Buffer; -} - - -EFI_STATUS -EFIAPI -WinNtBusDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -/*++ - -Routine Description: - -Arguments: - -Returns: - - None - -**/ -// TODO: This - add argument and description to function comment -// TODO: ControllerHandle - add argument and description to function comment -// TODO: RemainingDevicePath - add argument and description to function comment -// TODO: EFI_UNSUPPORTED - add return value to function comment -// TODO: EFI_UNSUPPORTED - add return value to function comment -// TODO: EFI_SUCCESS - add return value to function comment -// TODO: EFI_SUCCESS - add return value to function comment -{ - EFI_STATUS Status; - EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath; - EFI_WIN_NT_THUNK_PROTOCOL *WinNtThunk; - UINTN Index; - - // - // Check the contents of the first Device Path Node of RemainingDevicePath to make sure - // it is a legal Device Path Node for this bus driver's children. - // - if (RemainingDevicePath != NULL) { - // - // Check if RemainingDevicePath is the End of Device Path Node, - // if yes, go on checking other conditions - // - if (!IsDevicePathEnd (RemainingDevicePath)) { - // - // If RemainingDevicePath isn't the End of Device Path Node, - // check its validation - // - if (RemainingDevicePath->Type != HARDWARE_DEVICE_PATH || - RemainingDevicePath->SubType != HW_VENDOR_DP || - DevicePathNodeLength(RemainingDevicePath) != sizeof(WIN_NT_VENDOR_DEVICE_PATH_NODE)) { - return EFI_UNSUPPORTED; - } - - for (Index = 0; Index < NT_PCD_ARRAY_SIZE; Index++) { - if (CompareGuid (&((VENDOR_DEVICE_PATH *) RemainingDevicePath)->Guid, mPcdEnvironment[Index].DevicePathGuid)) { - break; - } - } - - if (Index >= NT_PCD_ARRAY_SIZE) { - return EFI_UNSUPPORTED; - } - } - } - - // - // Open the IO Abstraction(s) needed to perform the supported test - // - Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiWinNtThunkProtocolGuid, - (VOID **) &WinNtThunk, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - if (Status == EFI_ALREADY_STARTED) { - return EFI_SUCCESS; - } - - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Close the I/O Abstraction(s) used to perform the supported test - // - gBS->CloseProtocol ( - ControllerHandle, - &gEfiWinNtThunkProtocolGuid, - This->DriverBindingHandle, - ControllerHandle - ); - - // - // Open the EFI Device Path protocol needed to perform the supported test - // - Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiDevicePathProtocolGuid, - (VOID **) &ParentDevicePath, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - if (Status == EFI_ALREADY_STARTED) { - return EFI_SUCCESS; - } - - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Since we call through WinNtThunk we need to make sure it's valid - // - Status = EFI_SUCCESS; - if (WinNtThunk->Signature != EFI_WIN_NT_THUNK_PROTOCOL_SIGNATURE) { - Status = EFI_UNSUPPORTED; - } - - // - // Close protocol, don't use device path protocol in the Support() function - // - gBS->CloseProtocol ( - ControllerHandle, - &gEfiDevicePathProtocolGuid, - This->DriverBindingHandle, - ControllerHandle - ); - - return Status; -} - -EFI_STATUS -EFIAPI -WinNtBusDriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -/*++ - -Routine Description: - -Arguments: - -Returns: - - None - ---*/ -// TODO: This - add argument and description to function comment -// TODO: ControllerHandle - add argument and description to function comment -// TODO: RemainingDevicePath - add argument and description to function comment -// TODO: EFI_OUT_OF_RESOURCES - add return value to function comment -// TODO: EFI_OUT_OF_RESOURCES - add return value to function comment -// TODO: EFI_SUCCESS - add return value to function comment -{ - EFI_STATUS Status; - EFI_WIN_NT_THUNK_PROTOCOL *WinNtThunk; - EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath; - WIN_NT_BUS_DEVICE *WinNtBusDevice; - WIN_NT_IO_DEVICE *WinNtDevice; - UINTN Index; - CHAR16 *StartString; - CHAR16 *SubString; - UINT16 Count; - UINTN StringSize; - UINT16 ComponentName[MAX_NT_ENVIRNMENT_VARIABLE_LENGTH]; - WIN_NT_VENDOR_DEVICE_PATH_NODE *Node; - BOOLEAN CreateDevice; - CHAR16 *TempStr; - CHAR16 *PcdTempStr; - UINTN TempStrSize; - - Status = EFI_UNSUPPORTED; - - // - // Grab the protocols we need - // - Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiDevicePathProtocolGuid, - (VOID **) &ParentDevicePath, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) { - return Status; - } - - Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiWinNtThunkProtocolGuid, - (VOID **) &WinNtThunk, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) { - return Status; - } - - if (Status != EFI_ALREADY_STARTED) { - WinNtBusDevice = AllocatePool (sizeof (WIN_NT_BUS_DEVICE)); - if (WinNtBusDevice == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - WinNtBusDevice->Signature = WIN_NT_BUS_DEVICE_SIGNATURE; - WinNtBusDevice->ControllerNameTable = NULL; - - AddUnicodeString2 ( - "eng", - gWinNtBusDriverComponentName.SupportedLanguages, - &WinNtBusDevice->ControllerNameTable, - L"Windows Bus Controller", - TRUE - ); - AddUnicodeString2 ( - "en", - gWinNtBusDriverComponentName2.SupportedLanguages, - &WinNtBusDevice->ControllerNameTable, - L"Windows Bus Controller", - FALSE - ); - - - Status = gBS->InstallMultipleProtocolInterfaces ( - &ControllerHandle, - &gWinNtBusDriverGuid, - WinNtBusDevice, - NULL - ); - if (EFI_ERROR (Status)) { - FreeUnicodeStringTable (WinNtBusDevice->ControllerNameTable); - FreePool (WinNtBusDevice); - return Status; - } - } - - // - // Loop on the Variable list. Parse each variable to produce a set of handles that - // represent virtual hardware devices. - // - for (Index = 0; Index < NT_PCD_ARRAY_SIZE; Index++) { - PcdTempStr = (VOID *)LibPcdGetPtr (mPcdEnvironment[Index].Token); - ASSERT (PcdTempStr != NULL); - - TempStrSize = StrLen (PcdTempStr); - TempStr = AllocateMemory (((TempStrSize + 1) * sizeof (CHAR16))); - StrCpy (TempStr, PcdTempStr); - - StartString = TempStr; - - // - // Parse the envirnment variable into sub strings using '!' as a delimator. - // Each substring needs it's own handle to be added to the system. This code - // does not understand the sub string. Thats the device drivers job. - // - Count = 0; - while (*StartString != '\0') { - - // - // Find the end of the sub string - // - SubString = StartString; - while (*SubString != '\0' && *SubString != '!') { - SubString++; - } - - if (*SubString == '!') { - // - // Replace token with '\0' to make sub strings. If this is the end - // of the string SubString will already point to NULL. - // - *SubString = '\0'; - SubString++; - } - - CreateDevice = TRUE; - if (RemainingDevicePath != NULL) { - CreateDevice = FALSE; - // - // Check if RemainingDevicePath is the End of Device Path Node, - // if yes, don't create any child device - // - if (!IsDevicePathEnd (RemainingDevicePath)) { - // - // If RemainingDevicePath isn't the End of Device Path Node, - // check its validation - // - Node = (WIN_NT_VENDOR_DEVICE_PATH_NODE *) RemainingDevicePath; - if (Node->VendorDevicePath.Header.Type == HARDWARE_DEVICE_PATH && - Node->VendorDevicePath.Header.SubType == HW_VENDOR_DP && - DevicePathNodeLength (&Node->VendorDevicePath.Header) == sizeof (WIN_NT_VENDOR_DEVICE_PATH_NODE) - ) { - if (CompareGuid (&Node->VendorDevicePath.Guid, mPcdEnvironment[Index].DevicePathGuid) && - Node->Instance == Count - ) { - CreateDevice = TRUE; - } - } - } - } - - if (CreateDevice) { - - // - // Allocate instance structure, and fill in parent information. - // - WinNtDevice = AllocateMemory (sizeof (WIN_NT_IO_DEVICE)); - if (WinNtDevice == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - WinNtDevice->Handle = NULL; - WinNtDevice->ControllerHandle = ControllerHandle; - WinNtDevice->ParentDevicePath = ParentDevicePath; - - WinNtDevice->WinNtIo.WinNtThunk = WinNtThunk; - - // - // Plus 2 to account for the NULL at the end of the Unicode string - // - StringSize = (UINTN) ((UINT8 *) SubString - (UINT8 *) StartString) + sizeof (CHAR16); - WinNtDevice->WinNtIo.EnvString = AllocateMemory (StringSize); - if (WinNtDevice->WinNtIo.EnvString != NULL) { - CopyMem (WinNtDevice->WinNtIo.EnvString, StartString, StringSize); - } - - WinNtDevice->ControllerNameTable = NULL; - - WinNtThunk->SPrintf (ComponentName, sizeof (ComponentName), L"%s", WinNtDevice->WinNtIo.EnvString); - - WinNtDevice->DevicePath = WinNtBusCreateDevicePath ( - ParentDevicePath, - mPcdEnvironment[Index].DevicePathGuid, - Count - ); - if (WinNtDevice->DevicePath == NULL) { - FreePool (WinNtDevice); - return EFI_OUT_OF_RESOURCES; - } - - AddUnicodeString2 ( - "eng", - gWinNtBusDriverComponentName.SupportedLanguages, - &WinNtDevice->ControllerNameTable, - ComponentName, - TRUE - ); - AddUnicodeString2 ( - "en", - gWinNtBusDriverComponentName2.SupportedLanguages, - &WinNtDevice->ControllerNameTable, - ComponentName, - FALSE - ); - - - WinNtDevice->WinNtIo.TypeGuid = mPcdEnvironment[Index].DevicePathGuid; - WinNtDevice->WinNtIo.InstanceNumber = Count; - - WinNtDevice->Signature = WIN_NT_IO_DEVICE_SIGNATURE; - - Status = gBS->InstallMultipleProtocolInterfaces ( - &WinNtDevice->Handle, - &gEfiDevicePathProtocolGuid, - WinNtDevice->DevicePath, - &gEfiWinNtIoProtocolGuid, - &WinNtDevice->WinNtIo, - NULL - ); - if (EFI_ERROR (Status)) { - FreeUnicodeStringTable (WinNtDevice->ControllerNameTable); - FreePool (WinNtDevice); - } else { - // - // Open For Child Device - // - Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiWinNtThunkProtocolGuid, - (VOID **) &WinNtThunk, - This->DriverBindingHandle, - WinNtDevice->Handle, - EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER - ); - } - } - - // - // Parse Next sub string. This will point to '\0' if we are at the end. - // - Count++; - StartString = SubString; - } - - FreePool (TempStr); - } - - return EFI_SUCCESS; -} - - -EFI_STATUS -EFIAPI -WinNtBusDriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer - ) -/*++ - -Routine Description: - -Arguments: - -Returns: - - None - ---*/ -// TODO: This - add argument and description to function comment -// TODO: ControllerHandle - add argument and description to function comment -// TODO: NumberOfChildren - add argument and description to function comment -// TODO: ChildHandleBuffer - add argument and description to function comment -// TODO: EFI_SUCCESS - add return value to function comment -// TODO: EFI_DEVICE_ERROR - add return value to function comment -// TODO: EFI_SUCCESS - add return value to function comment -{ - EFI_STATUS Status; - UINTN Index; - BOOLEAN AllChildrenStopped; - EFI_WIN_NT_IO_PROTOCOL *WinNtIo; - WIN_NT_BUS_DEVICE *WinNtBusDevice; - WIN_NT_IO_DEVICE *WinNtDevice; - EFI_WIN_NT_THUNK_PROTOCOL *WinNtThunk; - - // - // Complete all outstanding transactions to Controller. - // Don't allow any new transaction to Controller to be started. - // - - if (NumberOfChildren == 0) { - // - // Close the bus driver - // - Status = gBS->OpenProtocol ( - ControllerHandle, - &gWinNtBusDriverGuid, - (VOID **) &WinNtBusDevice, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - if (EFI_ERROR (Status)) { - return Status; - } - - gBS->UninstallMultipleProtocolInterfaces ( - ControllerHandle, - &gWinNtBusDriverGuid, - WinNtBusDevice, - NULL - ); - - FreeUnicodeStringTable (WinNtBusDevice->ControllerNameTable); - - FreePool (WinNtBusDevice); - - gBS->CloseProtocol ( - ControllerHandle, - &gEfiWinNtThunkProtocolGuid, - This->DriverBindingHandle, - ControllerHandle - ); - - gBS->CloseProtocol ( - ControllerHandle, - &gEfiDevicePathProtocolGuid, - This->DriverBindingHandle, - ControllerHandle - ); - return EFI_SUCCESS; - } - - AllChildrenStopped = TRUE; - - for (Index = 0; Index < NumberOfChildren; Index++) { - - Status = gBS->OpenProtocol ( - ChildHandleBuffer[Index], - &gEfiWinNtIoProtocolGuid, - (VOID **) &WinNtIo, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - if (!EFI_ERROR (Status)) { - - WinNtDevice = WIN_NT_IO_DEVICE_FROM_THIS (WinNtIo); - - Status = gBS->CloseProtocol ( - ControllerHandle, - &gEfiWinNtThunkProtocolGuid, - This->DriverBindingHandle, - WinNtDevice->Handle - ); - - Status = gBS->UninstallMultipleProtocolInterfaces ( - WinNtDevice->Handle, - &gEfiDevicePathProtocolGuid, - WinNtDevice->DevicePath, - &gEfiWinNtIoProtocolGuid, - &WinNtDevice->WinNtIo, - NULL - ); - - if (EFI_ERROR (Status)) { - gBS->OpenProtocol ( - ControllerHandle, - &gEfiWinNtThunkProtocolGuid, - (VOID **) &WinNtThunk, - This->DriverBindingHandle, - WinNtDevice->Handle, - EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER - ); - } else { - // - // Close the child handle - // - FreeUnicodeStringTable (WinNtDevice->ControllerNameTable); - FreePool (WinNtDevice); - } - } - - if (EFI_ERROR (Status)) { - AllChildrenStopped = FALSE; - } - } - - if (!AllChildrenStopped) { - return EFI_DEVICE_ERROR; - } - - return EFI_SUCCESS; -} - -EFI_DEVICE_PATH_PROTOCOL * -WinNtBusCreateDevicePath ( - IN EFI_DEVICE_PATH_PROTOCOL *RootDevicePath, - IN EFI_GUID *Guid, - IN UINT16 InstanceNumber - ) -/*++ - -Routine Description: - Create a device path node using Guid and InstanceNumber and append it to - the passed in RootDevicePath - -Arguments: - RootDevicePath - Root of the device path to return. - - Guid - GUID to use in vendor device path node. - - InstanceNumber - Instance number to use in the vendor device path. This - argument is needed to make sure each device path is unique. - -Returns: - - EFI_DEVICE_PATH_PROTOCOL - ---*/ -{ - WIN_NT_VENDOR_DEVICE_PATH_NODE DevicePath; - - DevicePath.VendorDevicePath.Header.Type = HARDWARE_DEVICE_PATH; - DevicePath.VendorDevicePath.Header.SubType = HW_VENDOR_DP; - SetDevicePathNodeLength (&DevicePath.VendorDevicePath.Header, sizeof (WIN_NT_VENDOR_DEVICE_PATH_NODE)); - - // - // The GUID defines the Class - // - CopyMem (&DevicePath.VendorDevicePath.Guid, Guid, sizeof (EFI_GUID)); - - // - // Add an instance number so we can make sure there are no Device Path - // duplication. - // - DevicePath.Instance = InstanceNumber; - - return AppendDevicePathNode ( - RootDevicePath, - (EFI_DEVICE_PATH_PROTOCOL *) &DevicePath - ); -} diff --git a/Nt32Pkg/WinNtBusDriverDxe/WinNtBusDriver.h b/Nt32Pkg/WinNtBusDriverDxe/WinNtBusDriver.h deleted file mode 100644 index dac61a66a9..0000000000 --- a/Nt32Pkg/WinNtBusDriverDxe/WinNtBusDriver.h +++ /dev/null @@ -1,317 +0,0 @@ -/**@file - -Copyright (c) 2006, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - WinNtBusDriver.h - -Abstract: - -This following section documents the envirnoment variables for the Win NT -build. These variables are used to define the (virtual) hardware -configuration of the NT environment - -A ! can be used to seperate multiple instances in a variable. Each -instance represents a seperate hardware device. - -EFI_WIN_NT_PHYSICAL_DISKS - maps to drives on your system -EFI_WIN_NT_VIRTUAL_DISKS - maps to a device emulated by a file -EFI_WIN_NT_FILE_SYSTEM - mouts a directory as a file system -EFI_WIN_NT_CONSOLE - make a logical comand line window (only one!) -EFI_WIN_NT_GOP - Builds GOP Windows of Width and Height -EFI_WIN_NT_SERIAL_PORT - maps physical serial ports -EFI_WIN_NT_PASS_THRU - associates a device with our PCI support - - ixed - Fixed disk like a hard drive. - emovable - Removable media like a floppy or CD-ROM. - Read nly - Write protected device. - Read rite - Read write device. - - Decimal number of blocks a device supports. - - Decimal number of bytes per block. - - NT envirnonment variable contents. '<' and '>' are not part of the variable, - they are just used to make this help more readable. There should be no - spaces between the ';'. Extra spaces will break the variable. A '!' is - used to seperate multiple devices in a variable. - - EFI_WIN_NT_VIRTUAL_DISKS = - ;;[!...] - - EFI_WIN_NT_PHYSICAL_DISKS = - :;;[!...] - - Virtual Disks: These devices use a file to emulate a hard disk or removable - media device. - - Thus a 20 MB emulated hard drive would look like: - EFI_WIN_NT_VIRTUAL_DISKS=FW;40960;512 - - A 1.44MB emulated floppy with a block size of 1024 would look like: - EFI_WIN_NT_VIRTUAL_DISKS=RW;1440;1024 - - Physical Disks: These devices use NT to open a real device in your system - - Thus a 120 MB floppy would look like: - EFI_WIN_NT_PHYSICAL_DISKS=B:RW;245760;512 - - Thus a standard CD-ROM floppy would look like: - EFI_WIN_NT_PHYSICAL_DISKS=Z:RO;307200;2048 - - EFI_WIN_NT_FILE_SYSTEM = - [!...] - - Mounting the two directories C:\FOO and C:\BAR would look like: - EFI_WIN_NT_FILE_SYSTEM=c:\foo!c:\bar - - EFI_WIN_NT_CONSOLE = - - - Declaring a text console window with the title "My EFI Console" woild look like: - EFI_WIN_NT_CONSOLE=My EFI Console - - EFI_WIN_NT_GOP = - [!...] - - Declaring a two GOP windows with resolutions of 800x600 and 1024x768 would look like: - Example : EFI_WIN_NT_GOP=800 600!1024 768 - - EFI_WIN_NT_SERIAL_PORT = - [!...] - - Declaring two serial ports on COM1 and COM2 would look like: - Example : EFI_WIN_NT_SERIAL_PORT=COM1!COM2 - - EFI_WIN_NT_PASS_THROUGH = - ;;; - - Declaring a base address of 0xE0000000 (used for PCI Express devices) - and having NT32 talk to a device located at bus 0, device 1, function 0: - Example : EFI_WIN_NT_PASS_THROUGH=E000000;0;1;0 - ----*/ - -#ifndef __NT_BUS_DRIVER_H__ -#define __NT_BUS_DRIVER_H__ - - -// -// The package level header files this module uses -// -#include -#include -// -// The protocols, PPI and GUID defintions for this module -// -#include -#include -#include -#include -#include -// -// The Library classes this module consumes -// -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// -// WinNt Bus Driver Global Variables -// -extern EFI_DRIVER_BINDING_PROTOCOL gWinNtBusDriverBinding; -extern EFI_COMPONENT_NAME_PROTOCOL gWinNtBusDriverComponentName; -extern EFI_COMPONENT_NAME2_PROTOCOL gWinNtBusDriverComponentName2; - -// -// WinNt Bus Controller Structure -// -#define WIN_NT_BUS_DEVICE_SIGNATURE SIGNATURE_32 ('N', 'T', 'B', 'D') - -typedef struct { - UINT64 Signature; - EFI_UNICODE_STRING_TABLE *ControllerNameTable; -} WIN_NT_BUS_DEVICE; - -// -// WinNt Child Device Controller Structure -// -#define WIN_NT_IO_DEVICE_SIGNATURE SIGNATURE_32 ('N', 'T', 'V', 'D') - -typedef struct { - UINT64 Signature; - EFI_HANDLE Handle; - EFI_WIN_NT_IO_PROTOCOL WinNtIo; - EFI_DEVICE_PATH_PROTOCOL *DevicePath; - - // - // Private data about the parent - // - EFI_HANDLE ControllerHandle; - EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath; - - EFI_UNICODE_STRING_TABLE *ControllerNameTable; - -} WIN_NT_IO_DEVICE; - -#define WIN_NT_IO_DEVICE_FROM_THIS(a) \ - CR(a, WIN_NT_IO_DEVICE, WinNtIo, WIN_NT_IO_DEVICE_SIGNATURE) - -// -// This is the largest env variable we can parse -// -#define MAX_NT_ENVIRNMENT_VARIABLE_LENGTH 512 - -typedef struct { - UINTN Token; - EFI_GUID *DevicePathGuid; -} NT_PCD_ENTRY; - -typedef struct { - VENDOR_DEVICE_PATH VendorDevicePath; - UINT32 Instance; -} WIN_NT_VENDOR_DEVICE_PATH_NODE; - -EFI_STATUS -EFIAPI -CpuIoInitialize ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - ImageHandle - TODO: add argument description - SystemTable - TODO: add argument description - -Returns: - - TODO: add return values - -**/ -; - -// -// Driver Binding Protocol function prototypes -// -EFI_STATUS -EFIAPI -WinNtBusDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Handle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - This - TODO: add argument description - Handle - TODO: add argument description - RemainingDevicePath - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -EFIAPI -WinNtBusDriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ParentHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - This - TODO: add argument description - ParentHandle - TODO: add argument description - RemainingDevicePath - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -EFIAPI -WinNtBusDriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Handle, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - This - TODO: add argument description - Handle - TODO: add argument description - NumberOfChildren - TODO: add argument description - ChildHandleBuffer - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -// -// WinNt Bus Driver private worker functions -// -EFI_DEVICE_PATH_PROTOCOL * -WinNtBusCreateDevicePath ( - IN EFI_DEVICE_PATH_PROTOCOL *RootDevicePath, - IN EFI_GUID *Guid, - IN UINT16 InstanceNumber - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - RootDevicePath - TODO: add argument description - Guid - TODO: add argument description - InstanceNumber - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - - -#endif diff --git a/Nt32Pkg/WinNtBusDriverDxe/WinNtBusDriverDxe.inf b/Nt32Pkg/WinNtBusDriverDxe/WinNtBusDriverDxe.inf deleted file mode 100644 index a39ee30c5b..0000000000 --- a/Nt32Pkg/WinNtBusDriverDxe/WinNtBusDriverDxe.inf +++ /dev/null @@ -1,80 +0,0 @@ -## @file -# Win NT Bus driver -# -# This following section documents the envirnoment variables for the Win NT -# build. These variables are used to define the (virtual) hardware -# configuration of the NT environment -# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
-# -# SPDX-License-Identifier: BSD-2-Clause-Patent -# -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = WinNtBusDriverDxe - FILE_GUID = BD7E9A27-D6C5-416a-B245-5F507D95B2BD - MODULE_TYPE = UEFI_DRIVER - VERSION_STRING = 1.0 - - ENTRY_POINT = InitializeWinNtBusDriver - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 -# -# DRIVER_BINDING = gWinNtBusDriverBinding -# COMPONENT_NAME = gWinNtBusDriverComponentName -# - -[Sources] - ComponentName.c - WinNtBusDriver.c - WinNtBusDriver.h - - -[Packages] - MdePkg/MdePkg.dec - Nt32Pkg/Nt32Pkg.dec - - -[LibraryClasses] - MemoryAllocationLib - DevicePathLib - UefiBootServicesTableLib - BaseMemoryLib - PcdLib - UefiLib - UefiDriverEntryPoint - BaseLib - DebugLib - - -[Guids] - gEfiWinNtConsoleGuid # ALWAYS_CONSUMED - gEfiWinNtGopGuid # ALWAYS_CONSUMED - gEfiWinNtSerialPortGuid # ALWAYS_CONSUMED - gEfiWinNtFileSystemGuid # ALWAYS_CONSUMED - gEfiWinNtPhysicalDisksGuid # ALWAYS_CONSUMED - gEfiWinNtVirtualDisksGuid # ALWAYS_CONSUMED - - -[Protocols] - gWinNtBusDriverGuid # PROTOCOL BY_START - gEfiDevicePathProtocolGuid # PROTOCOL BY_START - gEfiWinNtThunkProtocolGuid # PROTOCOL TO_START - gEfiWinNtIoProtocolGuid # PROTOCOL BY_START - - -[Pcd] - gEfiNt32PkgTokenSpaceGuid.PcdWinNtMemorySize - gEfiNt32PkgTokenSpaceGuid.PcdWinNtPhysicalDisk - gEfiNt32PkgTokenSpaceGuid.PcdWinNtVirtualDisk - gEfiNt32PkgTokenSpaceGuid.PcdWinNtFileSystem - gEfiNt32PkgTokenSpaceGuid.PcdWinNtSerialPort - gEfiNt32PkgTokenSpaceGuid.PcdWinNtGop - gEfiNt32PkgTokenSpaceGuid.PcdWinNtUga - gEfiNt32PkgTokenSpaceGuid.PcdWinNtConsole - diff --git a/Nt32Pkg/WinNtFirmwareVolumePei/WinNtFirmwareVolumePei.inf b/Nt32Pkg/WinNtFirmwareVolumePei/WinNtFirmwareVolumePei.inf deleted file mode 100644 index 9e0ae24e3d..0000000000 --- a/Nt32Pkg/WinNtFirmwareVolumePei/WinNtFirmwareVolumePei.inf +++ /dev/null @@ -1,56 +0,0 @@ -## @file -# Component description file for WinNtFwh module -# -# This PEIM will produce the HOB to describe Firmware Volume, Firmware Devices -# on the NT32 emulator. -# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
-# -# SPDX-License-Identifier: BSD-2-Clause-Patent -# -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = WinNtFirmwareVolumePei - FILE_GUID = F0384FFD-8633-452f-9010-F6B7D2EAE2F1 - MODULE_TYPE = PEIM - VERSION_STRING = 1.0 - ENTRY_POINT = PeimInitializeWinNtFwh - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 EBC -# - -[Sources] - WinntFwh.c - -[Packages] - Nt32Pkg/Nt32Pkg.dec - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - -[LibraryClasses] - HobLib - PeimEntryPoint - DebugLib - PcdLib - -[Ppis] - gNtFwhPpiGuid # PPI ALWAYS_CONSUMED - -[Pcd] - gEfiNt32PkgTokenSpaceGuid.PcdWinNtFlashFvRecoveryBase - gEfiNt32PkgTokenSpaceGuid.PcdWinNtFlashFvRecoverySize - gEfiNt32PkgTokenSpaceGuid.PcdWinNtFlashNvStorageEventLogBase - gEfiNt32PkgTokenSpaceGuid.PcdWinNtFlashNvStorageEventLogSize - gEfiNt32PkgTokenSpaceGuid.PcdWinNtFlashNvStorageVariableBase - gEfiNt32PkgTokenSpaceGuid.PcdWinNtFlashNvStorageFtwSpareBase - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize - -[Depex] - gNtFwhPpiGuid AND gEfiPeiMemoryDiscoveredPpiGuid diff --git a/Nt32Pkg/WinNtFirmwareVolumePei/WinntFwh.c b/Nt32Pkg/WinNtFirmwareVolumePei/WinntFwh.c deleted file mode 100644 index f489bb7194..0000000000 --- a/Nt32Pkg/WinNtFirmwareVolumePei/WinntFwh.c +++ /dev/null @@ -1,138 +0,0 @@ -/**@file - -Copyright (c) 2006, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - WinNtFwh.c - -Abstract: - PEIM to abstract construction of firmware volume in a Windows NT environment. - -Revision History - -**/ - -// -// The package level header files this module uses -// -#include -#include -// -// The protocols, PPI and GUID defintions for this module -// -#include -// -// The Library classes this module consumes -// -#include -#include -#include -#include - -EFI_STATUS -EFIAPI -PeimInitializeWinNtFwh ( - IN EFI_FFS_FILE_HEADER *FfsHeader, - IN EFI_PEI_SERVICES **PeiServices - ) -/*++ - -Routine Description: - Perform a call-back into the SEC simulator to get address of the Firmware Hub - -Arguments: - FfsHeader - Ffs Header available to every PEIM - PeiServices - General purpose services available to every PEIM. - -Returns: - None - ---*/ -{ - EFI_STATUS Status; - EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor; - NT_FWH_PPI *FwhPpi; - EFI_PHYSICAL_ADDRESS FdBase; - EFI_FIRMWARE_VOLUME_HEADER *FvHeader; - UINT64 FdSize; - UINTN Index; - - DEBUG ((EFI_D_ERROR, "NT 32 Firmware Volume PEIM Loaded\n")); - - // - // Get the Fwh Information PPI - // - Status = (**PeiServices).LocatePpi ( - (const EFI_PEI_SERVICES **)PeiServices, - &gNtFwhPpiGuid, // GUID - 0, // INSTANCE - &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR - (VOID**)&FwhPpi // PPI - ); - ASSERT_EFI_ERROR (Status); - - Index = 0; - do { - // - // Get information about all the FD's in the system - // - Status = FwhPpi->NtFwh (Index, &FdBase, &FdSize); - if (!EFI_ERROR (Status)) { - // - // Assume the FD starts with an FV header - // - FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) FdBase; - - // - // Make an FV Hob for the first FV in the FD - // - BuildFvHob (FdBase, FvHeader->FvLength); - - if (Index == 0) { - // - // Assume the first FD was produced by the NT32.DSC - // All these strange offests are needed to keep in - // sync with the FlashMap and NT32.dsc file - // - BuildResourceDescriptorHob ( - EFI_RESOURCE_FIRMWARE_DEVICE, - (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE), - FdBase, - ( - FvHeader->FvLength + - PcdGet32 (PcdFlashNvStorageVariableSize) + - PcdGet32 (PcdFlashNvStorageFtwWorkingSize) + - PcdGet32 (PcdFlashNvStorageFtwSpareSize) + - PcdGet32 (PcdWinNtFlashNvStorageEventLogSize) - ) - ); - // - // Hard code the address of the spare block and variable services. - // Assume it's a hard coded offset from FV0 in FD0. - // - FdSize = - PcdGet32 (PcdFlashNvStorageVariableSize) + - PcdGet32 (PcdFlashNvStorageFtwWorkingSize) + - PcdGet32 (PcdFlashNvStorageFtwSpareSize) + - PcdGet32 (PcdWinNtFlashNvStorageEventLogSize); - - BuildFvHob (FdBase + PcdGet32 (PcdWinNtFlashNvStorageVariableBase), FdSize); - } else { - // - // For other FD's just map them in. - // - BuildResourceDescriptorHob ( - EFI_RESOURCE_FIRMWARE_DEVICE, - (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE), - FdBase, - FdSize - ); - } - } - - Index++; - } while (!EFI_ERROR (Status)); - - return Status; -} diff --git a/Nt32Pkg/WinNtFlashMapPei/FlashMap.c b/Nt32Pkg/WinNtFlashMapPei/FlashMap.c deleted file mode 100644 index cbb92a8e05..0000000000 --- a/Nt32Pkg/WinNtFlashMapPei/FlashMap.c +++ /dev/null @@ -1,95 +0,0 @@ -/**@file - -Copyright (c) 2006, Intel Corporation. All rights reserved.
-(C) Copyright 2016 Hewlett Packard Enterprise Development LP
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - FlashMap.c - -Abstract: - - PEIM to build GUIDed HOBs for platform specific flash map - -**/ - -// -// The package level header files this module uses -// -#include - -#include -// -// The protocols, PPI and GUID defintions for this module -// -#include - -#include -#include -#include - -EFI_STATUS -EFIAPI -PeimInitializeFlashMap ( - IN EFI_FFS_FILE_HEADER *FfsHeader, - IN EFI_PEI_SERVICES **PeiServices - ) -/*++ - -Routine Description: - Build GUIDed HOBs for platform specific flash map - -Arguments: - FfsHeader - A pointer to the EFI_FFS_FILE_HEADER structure. - PeiServices - General purpose services available to every PEIM. - -Returns: - EFI_STATUS - ---*/ -// TODO: EFI_SUCCESS - add return value to function comment -{ - EFI_STATUS Status; - NT_FWH_PPI *NtFwhPpi; - EFI_PHYSICAL_ADDRESS FdBase; - UINT64 FdSize; - EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor; - - DEBUG ((EFI_D_ERROR, "NT 32 Flash Map PEIM Loaded\n")); - - // - // Get the Fwh Information PPI - // - Status = PeiServicesLocatePpi ( - &gNtFwhPpiGuid, // GUID - 0, // INSTANCE - &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR - (VOID**)&NtFwhPpi // PPI - ); - ASSERT_EFI_ERROR (Status); - - // - // Assume that FD0 contains the Flash map. - // - Status = NtFwhPpi->NtFwh (0, &FdBase, &FdSize); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Relocate the base of FV region - // - if (FdBase >= BASE_4GB) { - PcdSet64 (PcdFlashNvStorageVariableBase64, PcdGet32 (PcdWinNtFlashNvStorageVariableBase) + (UINT64) FdBase); - PcdSet64 (PcdFlashNvStorageFtwWorkingBase64, PcdGet32 (PcdWinNtFlashNvStorageFtwWorkingBase) + (UINT64) FdBase); - PcdSet64 (PcdFlashNvStorageFtwSpareBase64, PcdGet32 (PcdWinNtFlashNvStorageFtwSpareBase) + (UINT64) FdBase); - } else { - PcdSet32 (PcdFlashNvStorageVariableBase, PcdGet32 (PcdWinNtFlashNvStorageVariableBase) + (UINT32) FdBase); - PcdSet32 (PcdFlashNvStorageFtwWorkingBase, PcdGet32 (PcdWinNtFlashNvStorageFtwWorkingBase) + (UINT32) FdBase); - PcdSet32 (PcdFlashNvStorageFtwSpareBase, PcdGet32 (PcdWinNtFlashNvStorageFtwSpareBase) + (UINT32) FdBase); - } - - return EFI_SUCCESS; -} - diff --git a/Nt32Pkg/WinNtFlashMapPei/WinNtFlashMapPei.inf b/Nt32Pkg/WinNtFlashMapPei/WinNtFlashMapPei.inf deleted file mode 100644 index b52438eaf7..0000000000 --- a/Nt32Pkg/WinNtFlashMapPei/WinNtFlashMapPei.inf +++ /dev/null @@ -1,61 +0,0 @@ -## @file -# Component description file for FlashMap PEI module -# -# This module installs FlashMap PPI which is used to get flash layout information. -# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
-# (C) Copyright 2016 Hewlett Packard Enterprise Development LP
-# -# SPDX-License-Identifier: BSD-2-Clause-Patent -# -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = WinNtFlashMapPei - FILE_GUID = 681F3771-6F1D-42DE-9AA2-F82BBCDBC5F9 - MODULE_TYPE = PEIM - VERSION_STRING = 1.0 - - ENTRY_POINT = PeimInitializeFlashMap - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 EBC -# - -[Sources] - FlashMap.c - -[Packages] - Nt32Pkg/Nt32Pkg.dec - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - -[LibraryClasses] - PcdLib - PeiServicesLib - PeimEntryPoint - DebugLib - -[Ppis] - gNtFwhPpiGuid # PPI ALWAYS_CONSUMED - -[Pcd] - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64 - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64 - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64 - - gEfiNt32PkgTokenSpaceGuid.PcdWinNtFlashNvStorageFtwWorkingBase - gEfiNt32PkgTokenSpaceGuid.PcdWinNtFlashNvStorageFtwSpareBase - gEfiNt32PkgTokenSpaceGuid.PcdWinNtFlashNvStorageVariableBase - -[Depex] - gNtFwhPpiGuid diff --git a/Nt32Pkg/WinNtGopDxe/ComponentName.c b/Nt32Pkg/WinNtGopDxe/ComponentName.c deleted file mode 100644 index 873b88b138..0000000000 --- a/Nt32Pkg/WinNtGopDxe/ComponentName.c +++ /dev/null @@ -1,377 +0,0 @@ -/** @file - -Copyright (c) 2006, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - ComponentName.c - -Abstract: - - -**/ - -// -// The package level header files this module uses -// -#include -#include -// -// The protocols, PPI and GUID defintions for this module -// -#include -#include -#include -#include -#include -#include -// -// The Library classes this module consumes -// -#include -#include -#include -#include -#include -#include -#include - -#include "WinNtGop.h" - -// -// EFI Component Name Functions -// -/** - Retrieves a Unicode string that is the user readable name of the driver. - - This function retrieves the user readable name of a driver in the form of a - Unicode string. If the driver specified by This has a user readable name in - the language specified by Language, then a pointer to the driver name is - returned in DriverName, and EFI_SUCCESS is returned. If the driver specified - by This does not support the language specified by Language, - then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified - in RFC 4646 or ISO 639-2 language code format. - - @param DriverName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - driver specified by This in the language - specified by Language. - - @retval EFI_SUCCESS The Unicode string for the Driver specified by - This and the language specified by Language was - returned in DriverName. - - @retval EFI_INVALID_PARAMETER Language is NULL. - - @retval EFI_INVALID_PARAMETER DriverName is NULL. - - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -WinNtGopComponentNameGetDriverName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName - ); - - -/** - Retrieves a Unicode string that is the user readable name of the controller - that is being managed by a driver. - - This function retrieves the user readable name of the controller specified by - ControllerHandle and ChildHandle in the form of a Unicode string. If the - driver specified by This has a user readable name in the language specified by - Language, then a pointer to the controller name is returned in ControllerName, - and EFI_SUCCESS is returned. If the driver specified by This is not currently - managing the controller specified by ControllerHandle and ChildHandle, - then EFI_UNSUPPORTED is returned. If the driver specified by This does not - support the language specified by Language, then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - - @param ControllerHandle[in] The handle of a controller that the driver - specified by This is managing. This handle - specifies the controller whose name is to be - returned. - - @param ChildHandle[in] The handle of the child controller to retrieve - the name of. This is an optional parameter that - may be NULL. It will be NULL for device - drivers. It will also be NULL for a bus drivers - that wish to retrieve the name of the bus - controller. It will not be NULL for a bus - driver that wishes to retrieve the name of a - child controller. - - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified in - RFC 4646 or ISO 639-2 language code format. - - @param ControllerName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - controller specified by ControllerHandle and - ChildHandle in the language specified by - Language from the point of view of the driver - specified by This. - - @retval EFI_SUCCESS The Unicode string for the user readable name in - the language specified by Language for the - driver specified by This was returned in - DriverName. - - @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. - - @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid - EFI_HANDLE. - - @retval EFI_INVALID_PARAMETER Language is NULL. - - @retval EFI_INVALID_PARAMETER ControllerName is NULL. - - @retval EFI_UNSUPPORTED The driver specified by This is not currently - managing the controller specified by - ControllerHandle and ChildHandle. - - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -WinNtGopComponentNameGetControllerName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName - ); - - -// -// EFI Component Name Protocol -// -GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gWinNtGopComponentName = { - WinNtGopComponentNameGetDriverName, - WinNtGopComponentNameGetControllerName, - "eng" -}; - -// -// EFI Component Name 2 Protocol -// -GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gWinNtGopComponentName2 = { - (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) WinNtGopComponentNameGetDriverName, - (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) WinNtGopComponentNameGetControllerName, - "en" -}; - - -GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mWinNtGopDriverNameTable[] = { - { "eng;en", L"Windows GOP Driver" }, - { NULL , NULL } -}; - - -/** - Retrieves a Unicode string that is the user readable name of the driver. - - This function retrieves the user readable name of a driver in the form of a - Unicode string. If the driver specified by This has a user readable name in - the language specified by Language, then a pointer to the driver name is - returned in DriverName, and EFI_SUCCESS is returned. If the driver specified - by This does not support the language specified by Language, - then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified - in RFC 4646 or ISO 639-2 language code format. - - @param DriverName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - driver specified by This in the language - specified by Language. - - @retval EFI_SUCCESS The Unicode string for the Driver specified by - This and the language specified by Language was - returned in DriverName. - - @retval EFI_INVALID_PARAMETER Language is NULL. - - @retval EFI_INVALID_PARAMETER DriverName is NULL. - - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -WinNtGopComponentNameGetDriverName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName - ) -{ - return LookupUnicodeString2 ( - Language, - This->SupportedLanguages, - mWinNtGopDriverNameTable, - DriverName, - (BOOLEAN)(This == &gWinNtGopComponentName) - ); -} - - -/** - Retrieves a Unicode string that is the user readable name of the controller - that is being managed by a driver. - - This function retrieves the user readable name of the controller specified by - ControllerHandle and ChildHandle in the form of a Unicode string. If the - driver specified by This has a user readable name in the language specified by - Language, then a pointer to the controller name is returned in ControllerName, - and EFI_SUCCESS is returned. If the driver specified by This is not currently - managing the controller specified by ControllerHandle and ChildHandle, - then EFI_UNSUPPORTED is returned. If the driver specified by This does not - support the language specified by Language, then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - - @param ControllerHandle[in] The handle of a controller that the driver - specified by This is managing. This handle - specifies the controller whose name is to be - returned. - - @param ChildHandle[in] The handle of the child controller to retrieve - the name of. This is an optional parameter that - may be NULL. It will be NULL for device - drivers. It will also be NULL for a bus drivers - that wish to retrieve the name of the bus - controller. It will not be NULL for a bus - driver that wishes to retrieve the name of a - child controller. - - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified in - RFC 4646 or ISO 639-2 language code format. - - @param ControllerName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - controller specified by ControllerHandle and - ChildHandle in the language specified by - Language from the point of view of the driver - specified by This. - - @retval EFI_SUCCESS The Unicode string for the user readable name in - the language specified by Language for the - driver specified by This was returned in - DriverName. - - @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. - - @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid - EFI_HANDLE. - - @retval EFI_INVALID_PARAMETER Language is NULL. - - @retval EFI_INVALID_PARAMETER ControllerName is NULL. - - @retval EFI_UNSUPPORTED The driver specified by This is not currently - managing the controller specified by - ControllerHandle and ChildHandle. - - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -WinNtGopComponentNameGetControllerName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName - ) -{ - EFI_STATUS Status; - EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput; - GOP_PRIVATE_DATA *Private; - - // - // This is a device driver, so ChildHandle must be NULL. - // - if (ChildHandle != NULL) { - return EFI_UNSUPPORTED; - } - // - // Make sure this driver is currently managing ControllerHandle - // - Status = EfiTestManagedDevice ( - ControllerHandle, - gWinNtGopDriverBinding.DriverBindingHandle, - &gEfiWinNtIoProtocolGuid - ); - if (EFI_ERROR (Status)) { - return EFI_UNSUPPORTED; - } - // - // Get our context back - // - Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiGraphicsOutputProtocolGuid, - (VOID **) &GraphicsOutput, - gWinNtGopDriverBinding.DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - if (EFI_ERROR (Status)) { - return EFI_UNSUPPORTED; - } - - Private = GOP_PRIVATE_DATA_FROM_THIS (GraphicsOutput); - - return LookupUnicodeString2 ( - Language, - This->SupportedLanguages, - Private->ControllerNameTable, - ControllerName, - (BOOLEAN)(This == &gWinNtGopComponentName) - ); -} diff --git a/Nt32Pkg/WinNtGopDxe/WinNtGop.h b/Nt32Pkg/WinNtGopDxe/WinNtGop.h deleted file mode 100644 index fbf1e0beca..0000000000 --- a/Nt32Pkg/WinNtGopDxe/WinNtGop.h +++ /dev/null @@ -1,343 +0,0 @@ -/** @file - -Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - WinNtGop.h - -Abstract: - - Private data for the Gop driver that is bound to the WinNt Thunk protocol - - -**/ - -#ifndef _WIN_NT_GOP_H_ -#define _WIN_NT_GOP_H_ - - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -// -// WM_SYSKEYDOWN/WM_SYSKEYUP Notification -// lParam -// bit 24: Specifies whether the key is an extended key, -// such as the right-hand ALT and CTRL keys that appear on -// an enhanced 101- or 102-key keyboard. -// The value is 1 if it is an extended key; otherwise, it is 0. -// bit 29:Specifies the context code. -// The value is 1 if the ALT key is down while the key is pressed/released; -// it is 0 if the WM_SYSKEYDOWN message is posted to the active window -// because no window has the keyboard focus. -#define GOP_EXTENDED_KEY (0x1 << 24) -#define GOP_ALT_KEY_PRESSED (0x1 << 29) - -#define KEYBOARD_TIMER_INTERVAL 200000 // 0.02s - -#define MAX_Q 256 - -typedef struct { - UINTN Front; - UINTN Rear; - EFI_KEY_DATA Q[MAX_Q]; - CRITICAL_SECTION Cs; -} GOP_QUEUE_FIXED; - -#define WIN_NT_GOP_CLASS_NAME L"WinNtGopWindow" - -#define GOP_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('S', 'g', 'o', 'N') - -#define WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('W', 'g', 'S', 'n') - -typedef struct _WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY { - UINTN Signature; - EFI_KEY_DATA KeyData; - EFI_KEY_NOTIFY_FUNCTION KeyNotificationFn; - LIST_ENTRY NotifyEntry; -} WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY; - -#define GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER 0xffff - -typedef struct { - UINT32 HorizontalResolution; - UINT32 VerticalResolution; - UINT32 ColorDepth; - UINT32 RefreshRate; -} GOP_MODE_DATA; - -typedef struct { - UINT64 Signature; - - EFI_HANDLE Handle; - EFI_GRAPHICS_OUTPUT_PROTOCOL GraphicsOutput; - EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleTextIn; - - EFI_WIN_NT_THUNK_PROTOCOL *WinNtThunk; - - EFI_UNICODE_STRING_TABLE *ControllerNameTable; - - // - // GOP Private Data for QueryMode () - // - GOP_MODE_DATA *ModeData; - - // - // GOP Private Data knowing when to start hardware - // - BOOLEAN HardwareNeedsStarting; - - CHAR16 *WindowName; - CHAR16 Buffer[160]; - - HANDLE ThreadInited; // Semaphore - HANDLE ThreadHandle; // Thread - DWORD ThreadId; - - HWND WindowHandle; - WNDCLASSEX WindowsClass; - - // - // This screen is used to redraw the scree when windows events happen. It's - // updated in the main thread and displayed in the windows thread. - // - BITMAPV4HEADER *VirtualScreenInfo; - RGBQUAD *VirtualScreen; - - EFI_GRAPHICS_OUTPUT_BLT_PIXEL *FillLine; - - // - // Keyboard Queue used by Simple Text In. - // QueueForRead: WinProc thread adds, and main thread removes. - // QueueForNotify: WinProc thread adds, and timer thread removes. - // - GOP_QUEUE_FIXED QueueForRead; - GOP_QUEUE_FIXED QueueForNotify; - - EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleTextInEx; - EFI_KEY_STATE KeyState; - LIST_ENTRY NotifyList; - BOOLEAN LeftShift; - BOOLEAN RightShift; - BOOLEAN LeftAlt; - BOOLEAN RightAlt; - BOOLEAN LeftCtrl; - BOOLEAN RightCtrl; - BOOLEAN LeftLogo; - BOOLEAN RightLogo; - BOOLEAN Menu; - BOOLEAN SysReq; - BOOLEAN NumLock; - BOOLEAN ScrollLock; - BOOLEAN CapsLock; - BOOLEAN IsPartialKeySupport; - EFI_EVENT TimerEvent; -} GOP_PRIVATE_DATA; - -#define GOP_PRIVATE_DATA_FROM_THIS(a) \ - CR(a, GOP_PRIVATE_DATA, GraphicsOutput, GOP_PRIVATE_DATA_SIGNATURE) - -#define GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS(a) \ - CR(a, GOP_PRIVATE_DATA, SimpleTextIn, GOP_PRIVATE_DATA_SIGNATURE) - -#define GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS(a) \ - CR(a, GOP_PRIVATE_DATA, SimpleTextInEx, GOP_PRIVATE_DATA_SIGNATURE) - -// -// Global Protocol Variables -// -extern EFI_DRIVER_BINDING_PROTOCOL gWinNtGopDriverBinding; -extern EFI_COMPONENT_NAME_PROTOCOL gWinNtGopComponentName; -extern EFI_COMPONENT_NAME2_PROTOCOL gWinNtGopComponentName2; - - -// -// Gop Hardware abstraction internal worker functions -// - -/** - TODO: Add function description - - @param WinNtIo TODO: add argument description - - @return TODO: add return values - -**/ -EFI_STATUS -WinNtGopSupported ( - IN EFI_WIN_NT_IO_PROTOCOL *WinNtIo - ); - - -/** - TODO: Add function description - - @param Private TODO: add argument description - - @return TODO: add return values - -**/ -EFI_STATUS -WinNtGopConstructor ( - IN GOP_PRIVATE_DATA *Private - ); - - -/** - TODO: Add function description - - @param Private TODO: add argument description - - @return TODO: add return values - -**/ -EFI_STATUS -WinNtGopDestructor ( - IN GOP_PRIVATE_DATA *Private - ); - -// -// UEFI 2.0 driver model prototypes for Win NT GOP -// - - -/** - TODO: Add function description - - @param ImageHandle TODO: add argument description - @param SystemTable TODO: add argument description - - @return TODO: add return values - -**/ -EFI_STATUS -EFIAPI -WinNtGopInitialize ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ); - - -/** - TODO: Add function description - - @param This TODO: add argument description - @param Handle TODO: add argument description - @param RemainingDevicePath TODO: add argument description - - @return TODO: add return values - -**/ -EFI_STATUS -EFIAPI -WinNtGopDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Handle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ); - - -/** - TODO: Add function description - - @param This TODO: add argument description - @param Handle TODO: add argument description - @param RemainingDevicePath TODO: add argument description - - @return TODO: add return values - -**/ -EFI_STATUS -EFIAPI -WinNtGopDriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Handle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ); - - -/** - TODO: Add function description - - @param This TODO: add argument description - @param Handle TODO: add argument description - @param NumberOfChildren TODO: add argument description - @param ChildHandleBuffer TODO: add argument description - - @return TODO: add return values - -**/ -EFI_STATUS -EFIAPI -WinNtGopDriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Handle, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer - ); - - -/** - TODO: Add function description - - @param Private TODO: add argument description - @param Key TODO: add argument description - - @return TODO: add return values - -**/ -EFI_STATUS -GopPrivateAddKey ( - IN GOP_PRIVATE_DATA *Private, - IN EFI_INPUT_KEY Key - ); - - -/** - TODO: Add function description - - @param Private TODO: add argument description - - @return TODO: add return values - -**/ -EFI_STATUS -WinNtGopInitializeSimpleTextInForWindow ( - IN GOP_PRIVATE_DATA *Private - ); - - -/** - TODO: Add function description - - @param Private TODO: add argument description - - @return TODO: add return values - -**/ -EFI_STATUS -WinNtGopDestroySimpleTextInForWindow ( - IN GOP_PRIVATE_DATA *Private - ); - - - -#endif diff --git a/Nt32Pkg/WinNtGopDxe/WinNtGopDriver.c b/Nt32Pkg/WinNtGopDxe/WinNtGopDriver.c deleted file mode 100644 index a2138d0ee9..0000000000 --- a/Nt32Pkg/WinNtGopDxe/WinNtGopDriver.c +++ /dev/null @@ -1,368 +0,0 @@ -/** @file - -Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - WinNtGopDriver.c - -Abstract: - - This file implements the UEFI Device Driver model requirements for GOP - - GOP is short hand for Graphics Output Protocol. - - -**/ -#include "WinNtGop.h" - -EFI_STATUS -FreeNotifyList ( - IN OUT LIST_ENTRY *ListHead - ) -/*++ - -Routine Description: - -Arguments: - - ListHead - The list head - -Returns: - - EFI_SUCCESS - Free the notify list successfully - EFI_INVALID_PARAMETER - ListHead is invalid. - ---*/ -{ - WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY *NotifyNode; - - if (ListHead == NULL) { - return EFI_INVALID_PARAMETER; - } - while (!IsListEmpty (ListHead)) { - NotifyNode = CR ( - ListHead->ForwardLink, - WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY, - NotifyEntry, - WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE - ); - RemoveEntryList (ListHead->ForwardLink); - gBS->FreePool (NotifyNode); - } - - return EFI_SUCCESS; -} - -EFI_DRIVER_BINDING_PROTOCOL gWinNtGopDriverBinding = { - WinNtGopDriverBindingSupported, - WinNtGopDriverBindingStart, - WinNtGopDriverBindingStop, - 0xa, - NULL, - NULL -}; - -/** - The user Entry Point for module WinNtGop. The user code starts with this function. - - @param[in] ImageHandle The firmware allocated handle for the EFI image. - @param[in] SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS The entry point is executed successfully. - @retval other Some error occurs when executing this entry point. - -**/ -EFI_STATUS -EFIAPI -InitializeWinNtGop( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - - // - // Install driver model protocol(s). - // - Status = EfiLibInstallDriverBindingComponentName2 ( - ImageHandle, - SystemTable, - &gWinNtGopDriverBinding, - ImageHandle, - &gWinNtGopComponentName, - &gWinNtGopComponentName2 - ); - ASSERT_EFI_ERROR (Status); - - - return Status; -} - -/** - - - @return None - -**/ -// TODO: This - add argument and description to function comment -// TODO: Handle - add argument and description to function comment -// TODO: RemainingDevicePath - add argument and description to function comment -EFI_STATUS -EFIAPI -WinNtGopDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Handle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -{ - EFI_STATUS Status; - EFI_WIN_NT_IO_PROTOCOL *WinNtIo; - - // - // Open the IO Abstraction(s) needed to perform the supported test - // - Status = gBS->OpenProtocol ( - Handle, - &gEfiWinNtIoProtocolGuid, - (VOID **) &WinNtIo, - This->DriverBindingHandle, - Handle, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - if (EFI_ERROR (Status)) { - return Status; - } - - Status = WinNtGopSupported (WinNtIo); - - // - // Close the I/O Abstraction(s) used to perform the supported test - // - gBS->CloseProtocol ( - Handle, - &gEfiWinNtIoProtocolGuid, - This->DriverBindingHandle, - Handle - ); - - return Status; -} - - -/** - - - @return None - -**/ -// TODO: This - add argument and description to function comment -// TODO: Handle - add argument and description to function comment -// TODO: RemainingDevicePath - add argument and description to function comment -// TODO: EFI_UNSUPPORTED - add return value to function comment -EFI_STATUS -EFIAPI -WinNtGopDriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Handle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -{ - EFI_WIN_NT_IO_PROTOCOL *WinNtIo; - EFI_STATUS Status; - GOP_PRIVATE_DATA *Private; - - // - // Grab the protocols we need - // - Status = gBS->OpenProtocol ( - Handle, - &gEfiWinNtIoProtocolGuid, - (VOID **) &WinNtIo, - This->DriverBindingHandle, - Handle, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - if (EFI_ERROR (Status)) { - return EFI_UNSUPPORTED; - } - - // - // Allocate Private context data for SGO inteface. - // - Private = NULL; - Private = AllocatePool (sizeof (GOP_PRIVATE_DATA)); - if (Private == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto Done; - } - // - // Set up context record - // - Private->Signature = GOP_PRIVATE_DATA_SIGNATURE; - Private->Handle = Handle; - Private->WinNtThunk = WinNtIo->WinNtThunk; - - Private->ControllerNameTable = NULL; - - AddUnicodeString2 ( - "eng", - gWinNtGopComponentName.SupportedLanguages, - &Private->ControllerNameTable, - WinNtIo->EnvString, - TRUE - ); - AddUnicodeString2 ( - "en", - gWinNtGopComponentName2.SupportedLanguages, - &Private->ControllerNameTable, - WinNtIo->EnvString, - FALSE - ); - - - Private->WindowName = WinNtIo->EnvString; - - Status = WinNtGopConstructor (Private); - if (EFI_ERROR (Status)) { - goto Done; - } - // - // Publish the Gop interface to the world - // - Status = gBS->InstallMultipleProtocolInterfaces ( - &Private->Handle, - &gEfiGraphicsOutputProtocolGuid, - &Private->GraphicsOutput, - &gEfiSimpleTextInProtocolGuid, - &Private->SimpleTextIn, - &gEfiSimpleTextInputExProtocolGuid, - &Private->SimpleTextInEx, - NULL - ); - -Done: - if (EFI_ERROR (Status)) { - - gBS->CloseProtocol ( - Handle, - &gEfiWinNtIoProtocolGuid, - This->DriverBindingHandle, - Handle - ); - - if (Private != NULL) { - // - // On Error Free back private data - // - if (Private->ControllerNameTable != NULL) { - FreeUnicodeStringTable (Private->ControllerNameTable); - } - - if (Private->SimpleTextIn.WaitForKey != NULL) { - gBS->CloseEvent (Private->SimpleTextIn.WaitForKey); - } - if (Private->SimpleTextInEx.WaitForKeyEx != NULL) { - gBS->CloseEvent (Private->SimpleTextInEx.WaitForKeyEx); - } - FreeNotifyList (&Private->NotifyList); - FreePool (Private); - } - } - - return Status; -} - - -/** - - - @return None - -**/ -// TODO: This - add argument and description to function comment -// TODO: Handle - add argument and description to function comment -// TODO: NumberOfChildren - add argument and description to function comment -// TODO: ChildHandleBuffer - add argument and description to function comment -// TODO: EFI_NOT_STARTED - add return value to function comment -// TODO: EFI_DEVICE_ERROR - add return value to function comment -EFI_STATUS -EFIAPI -WinNtGopDriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Handle, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer - ) -{ - EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput; - EFI_STATUS Status; - GOP_PRIVATE_DATA *Private; - - Status = gBS->OpenProtocol ( - Handle, - &gEfiGraphicsOutputProtocolGuid, - (VOID **) &GraphicsOutput, - This->DriverBindingHandle, - Handle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - if (EFI_ERROR (Status)) { - // - // If the GOP interface does not exist the driver is not started - // - return EFI_NOT_STARTED; - } - - // - // Get our private context information - // - Private = GOP_PRIVATE_DATA_FROM_THIS (GraphicsOutput); - - // - // Remove the SGO interface from the system - // - Status = gBS->UninstallMultipleProtocolInterfaces ( - Private->Handle, - &gEfiGraphicsOutputProtocolGuid, - &Private->GraphicsOutput, - &gEfiSimpleTextInProtocolGuid, - &Private->SimpleTextIn, - &gEfiSimpleTextInputExProtocolGuid, - &Private->SimpleTextInEx, - NULL - ); - if (!EFI_ERROR (Status)) { - // - // Shutdown the hardware - // - Status = WinNtGopDestructor (Private); - if (EFI_ERROR (Status)) { - return EFI_DEVICE_ERROR; - } - - gBS->CloseProtocol ( - Handle, - &gEfiWinNtIoProtocolGuid, - This->DriverBindingHandle, - Handle - ); - - // - // Free our instance data - // - FreeUnicodeStringTable (Private->ControllerNameTable); - Status = gBS->CloseEvent (Private->SimpleTextIn.WaitForKey); - ASSERT_EFI_ERROR (Status); - Status = gBS->CloseEvent (Private->SimpleTextInEx.WaitForKeyEx); - ASSERT_EFI_ERROR (Status); - FreeNotifyList (&Private->NotifyList); - - gBS->FreePool (Private); - - } - - return Status; -} - diff --git a/Nt32Pkg/WinNtGopDxe/WinNtGopDxe.inf b/Nt32Pkg/WinNtGopDxe/WinNtGopDxe.inf deleted file mode 100644 index 3218f9c2ce..0000000000 --- a/Nt32Pkg/WinNtGopDxe/WinNtGopDxe.inf +++ /dev/null @@ -1,63 +0,0 @@ -## @file -# Gop Driver -# -# GOP is short hand for UEFI Graphics Output protocol. -# This file is a verision of GopIo the uses WinNtThunk system calls as an IO -# abstraction. For a PCI device WinNtIo would be replaced with -# a PCI IO abstraction that abstracted a specific PCI device. -# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
-# -# SPDX-License-Identifier: BSD-2-Clause-Patent -# -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = WinNtGopDxe - FILE_GUID = 29b3c4c6-e5aa-49e4-8ce0-2772f782ddc2 - MODULE_TYPE = UEFI_DRIVER - VERSION_STRING = 1.0 - - ENTRY_POINT = InitializeWinNtGop - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 -# -# DRIVER_BINDING = gWinNtGopDriverBinding -# COMPONENT_NAME = gWinNtGopComponentName -# - -[Sources] - WinNtGopDriver.c - ComponentName.c - WinNtGop.h - WinNtGopInput.c - WinNtGopScreen.c - -[Packages] - MdePkg/MdePkg.dec - Nt32Pkg/Nt32Pkg.dec - - -[LibraryClasses] - MemoryAllocationLib - UefiBootServicesTableLib - BaseMemoryLib - UefiLib - UefiDriverEntryPoint - BaseLib - DebugLib - - -[Guids] - gEfiEventExitBootServicesGuid # SOMETIMES_CONSUMED Create Event: EVENT_GROUP_GUID - gEfiWinNtGopGuid # ALWAYS_CONSUMED - -[Protocols] - gEfiGraphicsOutputProtocolGuid # PROTOCOL BY_START - gEfiSimpleTextInProtocolGuid # PROTOCOL BY_START - gEfiSimpleTextInputExProtocolGuid # PROTOCOL BY_START - gEfiWinNtIoProtocolGuid # PROTOCOL TO_START diff --git a/Nt32Pkg/WinNtGopDxe/WinNtGopInput.c b/Nt32Pkg/WinNtGopDxe/WinNtGopInput.c deleted file mode 100644 index 2e11ac1144..0000000000 --- a/Nt32Pkg/WinNtGopDxe/WinNtGopInput.c +++ /dev/null @@ -1,1057 +0,0 @@ -/** @file - -Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - WinNtGopInput.c - -Abstract: - - This file produces the Simple Text In for an Gop window. - - This stuff is linked at the hip to the Window, since the window - processing is done in a thread kicked off in WinNtGopImplementation.c - - Since the window information is processed in an other thread we need - a keyboard Queue to pass data about. The Simple Text In code just - takes data off the Queue. The WinProc message loop takes keyboard input - and places it in the Queue. - - -**/ - - -#include "WinNtGop.h" - - -/** - TODO: Add function description - - @param Private TODO: add argument description - - @retval EFI_SUCCESS TODO: Add description for return value - -**/ -EFI_STATUS -GopPrivateCreateQ ( - IN GOP_PRIVATE_DATA *Private, - IN GOP_QUEUE_FIXED *Queue - ) -{ - Private->WinNtThunk->InitializeCriticalSection (&Queue->Cs); - Queue->Front = 0; - Queue->Rear = 0; - return EFI_SUCCESS; -} - - -/** - TODO: Add function description - - @param Private TODO: add argument description - - @retval EFI_SUCCESS TODO: Add description for return value - -**/ -EFI_STATUS -GopPrivateDestroyQ ( - IN GOP_PRIVATE_DATA *Private, - IN GOP_QUEUE_FIXED *Queue - ) -{ - Queue->Front = 0; - Queue->Rear = 0; - Private->WinNtThunk->DeleteCriticalSection (&Queue->Cs); - return EFI_SUCCESS; -} - - -/** - TODO: Add function description - - @param Private TODO: add argument description - @param Key TODO: add argument description - - @retval EFI_NOT_READY TODO: Add description for return value - @retval EFI_SUCCESS TODO: Add description for return value - -**/ -EFI_STATUS -GopPrivateAddQ ( - IN GOP_PRIVATE_DATA *Private, - IN GOP_QUEUE_FIXED *Queue, - IN EFI_KEY_DATA *KeyData - ) -{ - Private->WinNtThunk->EnterCriticalSection (&Queue->Cs); - - if ((Queue->Rear + 1) % MAX_Q == Queue->Front) { - Private->WinNtThunk->LeaveCriticalSection (&Queue->Cs); - return EFI_NOT_READY; - } - - CopyMem (&Queue->Q[Queue->Rear], KeyData, sizeof (EFI_KEY_DATA)); - Queue->Rear = (Queue->Rear + 1) % MAX_Q; - - Private->WinNtThunk->LeaveCriticalSection (&Queue->Cs); - return EFI_SUCCESS; -} - - -/** - TODO: Add function description - - @param Private TODO: add argument description - @param Key TODO: add argument description - - @retval EFI_NOT_READY TODO: Add description for return value - @retval EFI_SUCCESS TODO: Add description for return value - -**/ -EFI_STATUS -GopPrivateDeleteQ ( - IN GOP_PRIVATE_DATA *Private, - IN GOP_QUEUE_FIXED *Queue, - OUT EFI_KEY_DATA *Key - ) -{ - Private->WinNtThunk->EnterCriticalSection (&Queue->Cs); - - if (Queue->Front == Queue->Rear) { - Private->WinNtThunk->LeaveCriticalSection (&Queue->Cs); - return EFI_NOT_READY; - } - - CopyMem (Key, &Queue->Q[Queue->Front], sizeof (EFI_KEY_DATA)); - Queue->Front = (Queue->Front + 1) % MAX_Q; - - if (Key->Key.ScanCode == SCAN_NULL && Key->Key.UnicodeChar == CHAR_NULL) { - if (!Private->IsPartialKeySupport) { - // - // If partial keystrok is not enabled, don't return the partial keystroke. - // - Private->WinNtThunk->LeaveCriticalSection (&Queue->Cs); - ZeroMem (Key, sizeof (EFI_KEY_DATA)); - return EFI_NOT_READY; - } - } - Private->WinNtThunk->LeaveCriticalSection (&Queue->Cs); - return EFI_SUCCESS; -} - - -/** - TODO: Add function description - - @param Private TODO: add argument description - - @retval EFI_NOT_READY TODO: Add description for return value - @retval EFI_SUCCESS TODO: Add description for return value - -**/ -EFI_STATUS -GopPrivateCheckQ ( - IN GOP_QUEUE_FIXED *Queue - ) -{ - if (Queue->Front == Queue->Rear) { - return EFI_NOT_READY; - } - - return EFI_SUCCESS; -} - -BOOLEAN -GopPrivateIsKeyRegistered ( - IN EFI_KEY_DATA *RegsiteredData, - IN EFI_KEY_DATA *InputData - ) -/*++ - -Routine Description: - -Arguments: - - RegsiteredData - A pointer to a buffer that is filled in with the keystroke - state data for the key that was registered. - InputData - A pointer to a buffer that is filled in with the keystroke - state data for the key that was pressed. - -Returns: - TRUE - Key be pressed matches a registered key. - FLASE - Match failed. - ---*/ -{ - ASSERT (RegsiteredData != NULL && InputData != NULL); - - if ((RegsiteredData->Key.ScanCode != InputData->Key.ScanCode) || - (RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar)) { - return FALSE; - } - - // - // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored. - // - if (RegsiteredData->KeyState.KeyShiftState != 0 && - RegsiteredData->KeyState.KeyShiftState != InputData->KeyState.KeyShiftState) { - return FALSE; - } - if (RegsiteredData->KeyState.KeyToggleState != 0 && - RegsiteredData->KeyState.KeyToggleState != InputData->KeyState.KeyToggleState) { - return FALSE; - } - - return TRUE; - -} - - -VOID -GopPrivateInvokeRegisteredFunction ( - IN GOP_PRIVATE_DATA *Private, - IN EFI_KEY_DATA *KeyData - ) -/*++ - -Routine Description: - - This function updates the status light of NumLock, ScrollLock and CapsLock. - -Arguments: - - Private - The private structure of WinNt Gop device. - KeyData - A pointer to a buffer that is filled in with the keystroke - state data for the key that was pressed. - -Returns: - - EFI_SUCCESS - The status light is updated successfully. - ---*/ -{ - LIST_ENTRY *Link; - WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY *CurrentNotify; - - for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) { - CurrentNotify = CR ( - Link, - WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY, - NotifyEntry, - WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE - ); - if (GopPrivateIsKeyRegistered (&CurrentNotify->KeyData, KeyData)) { - CurrentNotify->KeyNotificationFn (KeyData); - } - } -} - -VOID -WinNtGopSimpleTextInTimerHandler ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - GOP_PRIVATE_DATA *Private; - EFI_KEY_DATA KeyData; - - Private = (GOP_PRIVATE_DATA *)Context; - while (GopPrivateDeleteQ (Private, &Private->QueueForNotify, &KeyData) == EFI_SUCCESS) { - GopPrivateInvokeRegisteredFunction (Private, &KeyData); - } -} - -/** - Initialize the key state. - - @param Private The GOP_PRIVATE_DATA instance. - @param KeyState A pointer to receive the key state information. -**/ -VOID -InitializeKeyState ( - IN GOP_PRIVATE_DATA *Private, - IN EFI_KEY_STATE *KeyState - ) -{ - KeyState->KeyShiftState = EFI_SHIFT_STATE_VALID; - KeyState->KeyToggleState = EFI_TOGGLE_STATE_VALID; - - // - // Record Key shift state and toggle state - // - if (Private->LeftCtrl) { - KeyState->KeyShiftState |= EFI_LEFT_CONTROL_PRESSED; - } - if (Private->RightCtrl) { - KeyState->KeyShiftState |= EFI_RIGHT_CONTROL_PRESSED; - } - if (Private->LeftAlt) { - KeyState->KeyShiftState |= EFI_LEFT_ALT_PRESSED; - } - if (Private->RightAlt) { - KeyState->KeyShiftState |= EFI_RIGHT_ALT_PRESSED; - } - if (Private->LeftShift) { - KeyState->KeyShiftState |= EFI_LEFT_SHIFT_PRESSED; - } - if (Private->RightShift) { - KeyState->KeyShiftState |= EFI_RIGHT_SHIFT_PRESSED; - } - if (Private->LeftLogo) { - KeyState->KeyShiftState |= EFI_LEFT_LOGO_PRESSED; - } - if (Private->RightLogo) { - KeyState->KeyShiftState |= EFI_RIGHT_LOGO_PRESSED; - } - if (Private->Menu) { - KeyState->KeyShiftState |= EFI_MENU_KEY_PRESSED; - } - if (Private->SysReq) { - KeyState->KeyShiftState |= EFI_SYS_REQ_PRESSED; - } - if (Private->CapsLock) { - KeyState->KeyToggleState |= EFI_CAPS_LOCK_ACTIVE; - } - if (Private->NumLock) { - KeyState->KeyToggleState |= EFI_NUM_LOCK_ACTIVE; - } - if (Private->ScrollLock) { - KeyState->KeyToggleState |= EFI_SCROLL_LOCK_ACTIVE; - } - if (Private->IsPartialKeySupport) { - KeyState->KeyToggleState |= EFI_KEY_STATE_EXPOSED; - } -} - -/** - TODO: Add function description - - @param Private TODO: add argument description - @param Key TODO: add argument description - - @retval EFI_NOT_READY TODO: Add description for return value - @retval EFI_SUCCESS TODO: Add description for return value - -**/ -EFI_STATUS -GopPrivateAddKey ( - IN GOP_PRIVATE_DATA *Private, - IN EFI_INPUT_KEY Key - ) -{ - EFI_KEY_DATA KeyData; - - KeyData.Key = Key; - InitializeKeyState (Private, &KeyData.KeyState); - - // - // Convert Ctrl+[1-26] to Ctrl+[A-Z] - // - if ((Private->LeftCtrl || Private->RightCtrl) && - (KeyData.Key.UnicodeChar >= 1) && (KeyData.Key.UnicodeChar <= 26) - ) { - if ((Private->LeftShift || Private->RightShift) == Private->CapsLock) { - KeyData.Key.UnicodeChar = (CHAR16)(KeyData.Key.UnicodeChar + L'a' - 1); - } else { - KeyData.Key.UnicodeChar = (CHAR16)(KeyData.Key.UnicodeChar + L'A' - 1); - } - } - - // - // Unmask the Shift bit for printable char - // - if (((KeyData.Key.UnicodeChar >= L'a') && (KeyData.Key.UnicodeChar <= L'z')) || - ((KeyData.Key.UnicodeChar >= L'A') && (KeyData.Key.UnicodeChar <= L'Z')) - ) { - KeyData.KeyState.KeyShiftState &= ~(EFI_LEFT_SHIFT_PRESSED | EFI_RIGHT_SHIFT_PRESSED); - } - - GopPrivateAddQ (Private, &Private->QueueForNotify, &KeyData); - - GopPrivateAddQ (Private, &Private->QueueForRead, &KeyData); - - return EFI_SUCCESS; -} - -EFI_STATUS -GopPrivateUpdateStatusLight ( - IN GOP_PRIVATE_DATA *Private - ) -/*++ - -Routine Description: - - This function updates the status light of NumLock, ScrollLock and CapsLock. - -Arguments: - - Private - The private structure of WinNt console In/Out. - -Returns: - - EFI_SUCCESS - The status light is updated successfully. - ---*/ -{ - // - // BUGBUG:Only SendInput/keybd_event function can toggle - // NumLock, CapsLock and ScrollLock keys. - // Neither of these functions is included in EFI_WIN_NT_THUNK_PROTOCOL. - // Thus, return immediately without operation. - // - return EFI_SUCCESS; - -} - - -EFI_STATUS -GopPrivateResetWorker ( - IN GOP_PRIVATE_DATA *Private - ) -/*++ - -Routine Description: - - This function is a worker function for SimpleTextIn/SimpleTextInEx.Reset(). - -Arguments: - - Private - WinNT GOP private structure - -Returns: - - EFI_SUCCESS - Reset successfully - ---*/ -{ - EFI_KEY_DATA KeyData; - EFI_TPL OldTpl; - - // - // Enter critical section - // - OldTpl = gBS->RaiseTPL (TPL_NOTIFY); - - // - // A reset is draining the Queue - // - while (GopPrivateDeleteQ (Private, &Private->QueueForRead, &KeyData) == EFI_SUCCESS) - ; - while (GopPrivateDeleteQ (Private, &Private->QueueForNotify, &KeyData) == EFI_SUCCESS) - ; - - Private->LeftShift = FALSE; - Private->RightShift = FALSE; - Private->LeftAlt = FALSE; - Private->RightAlt = FALSE; - Private->LeftCtrl = FALSE; - Private->RightCtrl = FALSE; - Private->LeftLogo = FALSE; - Private->RightLogo = FALSE; - Private->Menu = FALSE; - Private->SysReq = FALSE; - - Private->CapsLock = FALSE; - Private->NumLock = FALSE; - Private->ScrollLock = FALSE; - Private->IsPartialKeySupport = FALSE; - - Private->KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID; - Private->KeyState.KeyToggleState = EFI_TOGGLE_STATE_VALID; - - // - // Leave critical section and return - // - gBS->RestoreTPL (OldTpl); - - return EFI_SUCCESS; -} - -EFI_STATUS -GopPrivateReadKeyStrokeWorker ( - IN GOP_PRIVATE_DATA *Private, - OUT EFI_KEY_DATA *KeyData - ) -/*++ - - Routine Description: - Reads the next keystroke from the input device. The WaitForKey Event can - be used to test for existance of a keystroke via WaitForEvent () call. - - Arguments: - Private - The private structure of WinNt Gop device. - KeyData - A pointer to a buffer that is filled in with the keystroke - state data for the key that was pressed. - - Returns: - EFI_SUCCESS - The keystroke information was returned. - EFI_NOT_READY - There was no keystroke data availiable. - EFI_DEVICE_ERROR - The keystroke information was not returned due to - hardware errors. - EFI_INVALID_PARAMETER - KeyData is NULL. - ---*/ -{ - EFI_STATUS Status; - EFI_TPL OldTpl; - - if (KeyData == NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // Enter critical section - // - OldTpl = gBS->RaiseTPL (TPL_NOTIFY); - - // - // Call hot key callback before telling caller there is a key available - // - WinNtGopSimpleTextInTimerHandler (NULL, Private); - - ZeroMem (&KeyData->Key, sizeof (KeyData->Key)); - InitializeKeyState (Private, &KeyData->KeyState); - - Status = GopPrivateCheckQ (&Private->QueueForRead); - if (!EFI_ERROR (Status)) { - // - // If a Key press exists try and read it. - // - Status = GopPrivateDeleteQ (Private, &Private->QueueForRead, KeyData); - if (!EFI_ERROR (Status)) { - // - // If partial keystroke is not enabled, check whether it is value key. If not return - // EFI_NOT_READY. - // - if (!Private->IsPartialKeySupport) { - if (KeyData->Key.ScanCode == SCAN_NULL && KeyData->Key.UnicodeChar == CHAR_NULL) { - Status = EFI_NOT_READY; - } - } - } - } - - // - // Leave critical section and return - // - gBS->RestoreTPL (OldTpl); - - return Status; - -} - - -// -// Simple Text In implementation. -// - - -/** - TODO: Add function description - - @param This TODO: add argument description - @param ExtendedVerification TODO: add argument description - - @retval EFI_SUCCESS TODO: Add description for return value - -**/ -EFI_STATUS -EFIAPI -WinNtGopSimpleTextInReset ( - IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This, - IN BOOLEAN ExtendedVerification - ) -{ - GOP_PRIVATE_DATA *Private; - - Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS (This); - - return GopPrivateResetWorker (Private); -} - - -/** - TODO: Add function description - - @param This TODO: add argument description - @param Key TODO: add argument description - - @return TODO: add return values - -**/ -EFI_STATUS -EFIAPI -WinNtGopSimpleTextInReadKeyStroke ( - IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This, - OUT EFI_INPUT_KEY *Key - ) -{ - GOP_PRIVATE_DATA *Private; - EFI_STATUS Status; - EFI_KEY_DATA KeyData; - - Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS (This); - // - // Considering if the partial keystroke is enabled, there maybe a partial - // keystroke in the queue, so here skip the partial keystroke and get the - // next key from the queue - // - while (1) { - Status = GopPrivateReadKeyStrokeWorker (Private, &KeyData); - if (EFI_ERROR (Status)) { - return Status; - } - if (KeyData.Key.ScanCode == SCAN_NULL && KeyData.Key.UnicodeChar == CHAR_NULL) { - continue; - } - // - // Convert Ctrl+[A-Z] to Ctrl+[1-26] - // - if ((KeyData.KeyState.KeyShiftState & (EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) != 0) { - if ((KeyData.Key.UnicodeChar >= L'a') && (KeyData.Key.UnicodeChar <= L'z')) { - KeyData.Key.UnicodeChar = (CHAR16) (KeyData.Key.UnicodeChar - L'a' + 1); - } else if ((KeyData.Key.UnicodeChar >= L'A') && (KeyData.Key.UnicodeChar <= L'Z')) { - KeyData.Key.UnicodeChar = (CHAR16) (KeyData.Key.UnicodeChar - L'A' + 1); - } - } - CopyMem (Key, &KeyData.Key, sizeof (EFI_INPUT_KEY)); - return EFI_SUCCESS; - } -} - - -/** - TODO: Add function description - - @param Event TODO: add argument description - @param Context TODO: add argument description - - @return TODO: add return values - -**/ -VOID -EFIAPI -WinNtGopSimpleTextInWaitForKey ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - GOP_PRIVATE_DATA *Private; - EFI_STATUS Status; - EFI_TPL OldTpl; - EFI_KEY_DATA KeyData; - - Private = (GOP_PRIVATE_DATA *) Context; - - // - // Enter critical section - // - OldTpl = gBS->RaiseTPL (TPL_NOTIFY); - - // - // Call hot key callback before telling caller there is a key available - // - WinNtGopSimpleTextInTimerHandler (NULL, Private); - - // - // WaitforKey doesn't suppor the partial key. - // Considering if the partial keystroke is enabled, there maybe a partial - // keystroke in the queue, so here skip the partial keystroke and get the - // next key from the queue - // - while (1) { - Status = GopPrivateCheckQ (&Private->QueueForRead); - if (!EFI_ERROR (Status)) { - // - // If a there is a key in the queue and it is not partial keystroke, signal event. - // - if (Private->QueueForRead.Q[Private->QueueForRead.Front].Key.ScanCode == SCAN_NULL && - Private->QueueForRead.Q[Private->QueueForRead.Front].Key.UnicodeChar == CHAR_NULL) { - GopPrivateDeleteQ (Private,&Private->QueueForRead,&KeyData); - continue; - } - gBS->SignalEvent (Event); - } else { - // - // We need to sleep or NT will schedule this thread with such high - // priority that WinProc thread will never run and we will not see - // keyboard input. This Sleep makes the syste run 10x faster, so don't - // remove it. - // - Private->WinNtThunk->Sleep (1); - } - break; - } - - // - // Leave critical section and return - // - gBS->RestoreTPL (OldTpl); -} - -// -// Simple Text Input Ex protocol functions -// - -EFI_STATUS -EFIAPI -WinNtGopSimpleTextInExResetEx ( - IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, - IN BOOLEAN ExtendedVerification - ) -/*++ - - Routine Description: - Reset the input device and optionaly run diagnostics - - Arguments: - This - Protocol instance pointer. - ExtendedVerification - Driver may perform diagnostics on reset. - - Returns: - EFI_SUCCESS - The device was reset. - ---*/ -{ - GOP_PRIVATE_DATA *Private; - - Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This); - - return GopPrivateResetWorker (Private); -} - -EFI_STATUS -EFIAPI -WinNtGopSimpleTextInExReadKeyStrokeEx ( - IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, - OUT EFI_KEY_DATA *KeyData - ) -/*++ - - Routine Description: - Reads the next keystroke from the input device. The WaitForKey Event can - be used to test for existance of a keystroke via WaitForEvent () call. - - Arguments: - This - Protocol instance pointer. - KeyData - A pointer to a buffer that is filled in with the keystroke - state data for the key that was pressed. - - Returns: - EFI_SUCCESS - The keystroke information was returned. - EFI_NOT_READY - There was no keystroke data availiable. - EFI_DEVICE_ERROR - The keystroke information was not returned due to - hardware errors. - EFI_INVALID_PARAMETER - KeyData is NULL. - ---*/ -{ - GOP_PRIVATE_DATA *Private; - - if (KeyData == NULL) { - return EFI_INVALID_PARAMETER; - } - - Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This); - - return GopPrivateReadKeyStrokeWorker (Private, KeyData); - -} - -EFI_STATUS -EFIAPI -WinNtGopSimpleTextInExSetState ( - IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, - IN EFI_KEY_TOGGLE_STATE *KeyToggleState - ) -/*++ - - Routine Description: - Set certain state for the input device. - - Arguments: - This - Protocol instance pointer. - KeyToggleState - A pointer to the EFI_KEY_TOGGLE_STATE to set the - state for the input device. - - Returns: - EFI_SUCCESS - The device state was set successfully. - EFI_DEVICE_ERROR - The device is not functioning correctly and could - not have the setting adjusted. - EFI_UNSUPPORTED - The device does not have the ability to set its state. - EFI_INVALID_PARAMETER - KeyToggleState is NULL. - ---*/ -{ - EFI_STATUS Status; - GOP_PRIVATE_DATA *Private; - - if (KeyToggleState == NULL) { - return EFI_INVALID_PARAMETER; - } - - Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This); - - if (((Private->KeyState.KeyToggleState & EFI_TOGGLE_STATE_VALID) != EFI_TOGGLE_STATE_VALID) || - ((*KeyToggleState & EFI_TOGGLE_STATE_VALID) != EFI_TOGGLE_STATE_VALID)) { - return EFI_UNSUPPORTED; - } - - Private->ScrollLock = FALSE; - Private->NumLock = FALSE; - Private->CapsLock = FALSE; - Private->IsPartialKeySupport = FALSE; - - if ((*KeyToggleState & EFI_SCROLL_LOCK_ACTIVE) == EFI_SCROLL_LOCK_ACTIVE) { - Private->ScrollLock = TRUE; - } - if ((*KeyToggleState & EFI_NUM_LOCK_ACTIVE) == EFI_NUM_LOCK_ACTIVE) { - Private->NumLock = TRUE; - } - if ((*KeyToggleState & EFI_CAPS_LOCK_ACTIVE) == EFI_CAPS_LOCK_ACTIVE) { - Private->CapsLock = TRUE; - } - if ((*KeyToggleState & EFI_KEY_STATE_EXPOSED) == EFI_KEY_STATE_EXPOSED) { - Private->IsPartialKeySupport = TRUE; - } - - Status = GopPrivateUpdateStatusLight (Private); - if (EFI_ERROR (Status)) { - return EFI_DEVICE_ERROR; - } - - Private->KeyState.KeyToggleState = *KeyToggleState; - return EFI_SUCCESS; - -} - -EFI_STATUS -EFIAPI -WinNtGopSimpleTextInExRegisterKeyNotify ( - IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, - IN EFI_KEY_DATA *KeyData, - IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction, - OUT VOID **NotifyHandle - ) -/*++ - - Routine Description: - Register a notification function for a particular keystroke for the input device. - - Arguments: - This - Protocol instance pointer. - KeyData - A pointer to a buffer that is filled in with the keystroke - information data for the key that was pressed. - KeyNotificationFunction - Points to the function to be called when the key - sequence is typed specified by KeyData. - NotifyHandle - Points to the unique handle assigned to the registered notification. - - Returns: - EFI_SUCCESS - The notification function was registered successfully. - EFI_OUT_OF_RESOURCES - Unable to allocate resources for necesssary data structures. - EFI_INVALID_PARAMETER - KeyData or NotifyHandle is NULL. - ---*/ -{ - GOP_PRIVATE_DATA *Private; - WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY *CurrentNotify; - LIST_ENTRY *Link; - WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY *NewNotify; - - if (KeyData == NULL || KeyNotificationFunction == NULL || NotifyHandle == NULL) { - return EFI_INVALID_PARAMETER; - } - - Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This); - - // - // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered. - // - for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) { - CurrentNotify = CR ( - Link, - WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY, - NotifyEntry, - WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE - ); - if (GopPrivateIsKeyRegistered (&CurrentNotify->KeyData, KeyData)) { - if (CurrentNotify->KeyNotificationFn == KeyNotificationFunction) { - *NotifyHandle = CurrentNotify; - return EFI_SUCCESS; - } - } - } - - // - // Allocate resource to save the notification function - // - NewNotify = (WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY *) AllocateZeroPool (sizeof (WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY)); - if (NewNotify == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - NewNotify->Signature = WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE; - NewNotify->KeyNotificationFn = KeyNotificationFunction; - CopyMem (&NewNotify->KeyData, KeyData, sizeof (EFI_KEY_DATA)); - InsertTailList (&Private->NotifyList, &NewNotify->NotifyEntry); - - *NotifyHandle = NewNotify; - - return EFI_SUCCESS; - -} - -EFI_STATUS -EFIAPI -WinNtGopSimpleTextInExUnregisterKeyNotify ( - IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, - IN VOID *NotificationHandle - ) -/*++ - - Routine Description: - Remove a registered notification function from a particular keystroke. - - Arguments: - This - Protocol instance pointer. - NotificationHandle - The handle of the notification function being unregistered. - - Returns: - EFI_SUCCESS - The notification function was unregistered successfully. - EFI_INVALID_PARAMETER - The NotificationHandle is invalid. - ---*/ -{ - GOP_PRIVATE_DATA *Private; - LIST_ENTRY *Link; - WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY *CurrentNotify; - - if (NotificationHandle == NULL) { - return EFI_INVALID_PARAMETER; - } - - Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This); - - for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) { - CurrentNotify = CR ( - Link, - WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY, - NotifyEntry, - WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE - ); - if (CurrentNotify == NotificationHandle) { - // - // Remove the notification function from NotifyList and free resources - // - RemoveEntryList (&CurrentNotify->NotifyEntry); - - gBS->FreePool (CurrentNotify); - return EFI_SUCCESS; - } - } - - // - // Can not find the specified Notification Handle - // - return EFI_INVALID_PARAMETER; -} - - -/** - TODO: Add function description - - @param Private TODO: add argument description - - @return TODO: add return values - -**/ -EFI_STATUS -WinNtGopInitializeSimpleTextInForWindow ( - IN GOP_PRIVATE_DATA *Private - ) -{ - EFI_STATUS Status; - - GopPrivateCreateQ (Private, &Private->QueueForRead); - GopPrivateCreateQ (Private, &Private->QueueForNotify); - - // - // Initialize Simple Text In protoocol - // - Private->SimpleTextIn.Reset = WinNtGopSimpleTextInReset; - Private->SimpleTextIn.ReadKeyStroke = WinNtGopSimpleTextInReadKeyStroke; - - Status = gBS->CreateEvent ( - EVT_NOTIFY_WAIT, - TPL_NOTIFY, - WinNtGopSimpleTextInWaitForKey, - Private, - &Private->SimpleTextIn.WaitForKey - ); - - - Private->SimpleTextInEx.Reset = WinNtGopSimpleTextInExResetEx; - Private->SimpleTextInEx.ReadKeyStrokeEx = WinNtGopSimpleTextInExReadKeyStrokeEx; - Private->SimpleTextInEx.SetState = WinNtGopSimpleTextInExSetState; - Private->SimpleTextInEx.RegisterKeyNotify = WinNtGopSimpleTextInExRegisterKeyNotify; - Private->SimpleTextInEx.UnregisterKeyNotify = WinNtGopSimpleTextInExUnregisterKeyNotify; - - Private->SimpleTextInEx.Reset (&Private->SimpleTextInEx, FALSE); - - InitializeListHead (&Private->NotifyList); - - Status = gBS->CreateEvent ( - EVT_NOTIFY_WAIT, - TPL_NOTIFY, - WinNtGopSimpleTextInWaitForKey, - Private, - &Private->SimpleTextInEx.WaitForKeyEx - ); - ASSERT_EFI_ERROR (Status); - - // - // Create the Timer to trigger hot key notifications - // - Status = gBS->CreateEvent ( - EVT_TIMER | EVT_NOTIFY_SIGNAL, - TPL_NOTIFY, - WinNtGopSimpleTextInTimerHandler, - Private, - &Private->TimerEvent - ); - ASSERT_EFI_ERROR (Status); - - Status = gBS->SetTimer ( - Private->TimerEvent, - TimerPeriodic, - KEYBOARD_TIMER_INTERVAL - ); - ASSERT_EFI_ERROR (Status); - - return Status; -} - - - -/** - TODO: Add function description - - @param Private TODO: add argument description - - @retval EFI_SUCCESS TODO: Add description for return value - -**/ -EFI_STATUS -WinNtGopDestroySimpleTextInForWindow ( - IN GOP_PRIVATE_DATA *Private - ) -{ - gBS->CloseEvent (Private->TimerEvent); - - GopPrivateDestroyQ (Private, &Private->QueueForRead); - GopPrivateDestroyQ (Private, &Private->QueueForNotify); - - return EFI_SUCCESS; -} diff --git a/Nt32Pkg/WinNtGopDxe/WinNtGopScreen.c b/Nt32Pkg/WinNtGopDxe/WinNtGopScreen.c deleted file mode 100644 index 992a1b225a..0000000000 --- a/Nt32Pkg/WinNtGopDxe/WinNtGopScreen.c +++ /dev/null @@ -1,1163 +0,0 @@ -/** @file - -Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - WinNtGopScreen.c - -Abstract: - - This file produces the graphics abstration of GOP. It is called by - WinNtGopDriver.c file which deals with the UEFI 2.0 driver model. - This file just does graphics. - - -**/ - -#include "WinNtGop.h" - -EFI_WIN_NT_THUNK_PROTOCOL *mWinNt; -DWORD mTlsIndex = TLS_OUT_OF_INDEXES; -DWORD mTlsIndexUseCount = 0; // lets us know when we can free mTlsIndex. -EFI_EVENT mGopScreenExitBootServicesEvent; -GOP_MODE_DATA mGopModeData[] = { - {800, 600, 0, 0}, - {640, 480, 0, 0}, - {720, 400, 0, 0}, - {1024, 768, 0, 0}, - {1280, 1024, 0, 0} - }; - -EFI_STATUS -WinNtGopStartWindow ( - IN GOP_PRIVATE_DATA *Private, - IN UINT32 HorizontalResolution, - IN UINT32 VerticalResolution, - IN UINT32 ColorDepth, - IN UINT32 RefreshRate - ); - -VOID -EFIAPI -KillNtGopThread ( - IN EFI_EVENT Event, - IN VOID *Context - ); - -BOOLEAN -WinNtGopConvertParamToEfiKeyShiftState ( - IN GOP_PRIVATE_DATA *Private, - IN WPARAM *wParam, - IN LPARAM *lParam, - IN BOOLEAN Flag - ) -{ - switch (*wParam) { - // - // BUGBUG: Only GetAsyncKeyState() and GetKeyState() can distinguish - // left and right Ctrl, and Shift key. - // Neither of the two is defined in EFI_WIN_NT_THUNK_PROTOCOL. - // Therefor, we can not set the correct Shift state here. - // - case VK_SHIFT: - if ((*lParam & GOP_EXTENDED_KEY) == GOP_EXTENDED_KEY) { - Private->RightShift = Flag; - } else { - Private->LeftShift = Flag; - } - return TRUE; - - case VK_LSHIFT: - Private->LeftShift = Flag; - return TRUE; - - case VK_RSHIFT: - Private->RightShift = Flag; - return TRUE; - - case VK_CONTROL: - if ((*lParam & GOP_EXTENDED_KEY) == GOP_EXTENDED_KEY) { - Private->RightCtrl= Flag; - } else { - Private->LeftCtrl = Flag; - } - return TRUE; - - case VK_LCONTROL: - Private->LeftCtrl = Flag; - return TRUE; - - case VK_RCONTROL: - Private->RightCtrl = Flag; - return TRUE; - - case VK_LWIN: - Private->LeftLogo = Flag; - return TRUE; - - case VK_RWIN: - Private->RightLogo = Flag; - return TRUE; - - case VK_APPS: - Private->Menu = Flag; - return TRUE; - // - // BUGBUG: PrintScreen/SysRq can not trigger WM_KEYDOWN message, - // so SySReq shift state is not supported here. - // - case VK_PRINT: - Private->SysReq = Flag; - return TRUE; - // - // For Alt Keystroke. - // - case VK_MENU: - if ((*lParam & GOP_EXTENDED_KEY) == GOP_EXTENDED_KEY) { - Private->RightAlt = Flag; - } else { - Private->LeftAlt = Flag; - } - return TRUE; - - default: - return FALSE; - } -} - -BOOLEAN -WinNtGopConvertParamToEfiKey ( - IN GOP_PRIVATE_DATA *Private, - IN WPARAM *wParam, - IN LPARAM *lParam, - IN EFI_INPUT_KEY *Key - ) -{ - BOOLEAN Flag; - Flag = FALSE; - switch (*wParam) { - case VK_HOME: Key->ScanCode = SCAN_HOME; Flag = TRUE; break; - case VK_END: Key->ScanCode = SCAN_END; Flag = TRUE; break; - case VK_LEFT: Key->ScanCode = SCAN_LEFT; Flag = TRUE; break; - case VK_RIGHT: Key->ScanCode = SCAN_RIGHT; Flag = TRUE; break; - case VK_UP: Key->ScanCode = SCAN_UP; Flag = TRUE; break; - case VK_DOWN: Key->ScanCode = SCAN_DOWN; Flag = TRUE; break; - case VK_DELETE: Key->ScanCode = SCAN_DELETE; Flag = TRUE; break; - case VK_INSERT: Key->ScanCode = SCAN_INSERT; Flag = TRUE; break; - case VK_PRIOR: Key->ScanCode = SCAN_PAGE_UP; Flag = TRUE; break; - case VK_NEXT: Key->ScanCode = SCAN_PAGE_DOWN; Flag = TRUE; break; - case VK_ESCAPE: Key->ScanCode = SCAN_ESC; Flag = TRUE; break; - - case VK_F1: Key->ScanCode = SCAN_F1; Flag = TRUE; break; - case VK_F2: Key->ScanCode = SCAN_F2; Flag = TRUE; break; - case VK_F3: Key->ScanCode = SCAN_F3; Flag = TRUE; break; - case VK_F4: Key->ScanCode = SCAN_F4; Flag = TRUE; break; - case VK_F5: Key->ScanCode = SCAN_F5; Flag = TRUE; break; - case VK_F6: Key->ScanCode = SCAN_F6; Flag = TRUE; break; - case VK_F7: Key->ScanCode = SCAN_F7; Flag = TRUE; break; - case VK_F8: Key->ScanCode = SCAN_F8; Flag = TRUE; break; - case VK_F9: Key->ScanCode = SCAN_F9; Flag = TRUE; break; - case VK_F11: Key->ScanCode = SCAN_F11; Flag = TRUE; break; - case VK_F12: Key->ScanCode = SCAN_F12; Flag = TRUE; break; - - case VK_F13: Key->ScanCode = SCAN_F13; Flag = TRUE; break; - case VK_F14: Key->ScanCode = SCAN_F14; Flag = TRUE; break; - case VK_F15: Key->ScanCode = SCAN_F15; Flag = TRUE; break; - case VK_F16: Key->ScanCode = SCAN_F16; Flag = TRUE; break; - case VK_F17: Key->ScanCode = SCAN_F17; Flag = TRUE; break; - case VK_F18: Key->ScanCode = SCAN_F18; Flag = TRUE; break; - case VK_F19: Key->ScanCode = SCAN_F19; Flag = TRUE; break; - case VK_F20: Key->ScanCode = SCAN_F20; Flag = TRUE; break; - case VK_F21: Key->ScanCode = SCAN_F21; Flag = TRUE; break; - case VK_F22: Key->ScanCode = SCAN_F22; Flag = TRUE; break; - case VK_F23: Key->ScanCode = SCAN_F23; Flag = TRUE; break; - case VK_F24: Key->ScanCode = SCAN_F24; Flag = TRUE; break; - case VK_PAUSE: Key->ScanCode = SCAN_PAUSE; Flag = TRUE; break; - - // - // Set toggle state - // - case VK_NUMLOCK: - Private->NumLock = (BOOLEAN)(!Private->NumLock); - Flag = TRUE; - break; - case VK_SCROLL: - Private->ScrollLock = (BOOLEAN)(!Private->ScrollLock); - Flag = TRUE; - break; - case VK_CAPITAL: - Private->CapsLock = (BOOLEAN)(!Private->CapsLock); - Flag = TRUE; - break; - } - - return (WinNtGopConvertParamToEfiKeyShiftState (Private, wParam, lParam, TRUE)) == TRUE ? TRUE : Flag; -} - - -// -// GOP Protocol Member Functions -// - - -/** - Graphics Output protocol interface to get video mode - - @param This Protocol instance pointer. - @param ModeNumber The mode number to return information on. - @param Info Caller allocated buffer that returns information - about ModeNumber. - @param SizeOfInfo A pointer to the size, in bytes, of the Info - buffer. - - @retval EFI_SUCCESS Mode information returned. - @retval EFI_BUFFER_TOO_SMALL The Info buffer was too small. - @retval EFI_DEVICE_ERROR A hardware error occurred trying to retrieve the - video mode. - @retval EFI_NOT_STARTED Video display is not initialized. Call SetMode () - @retval EFI_INVALID_PARAMETER One of the input args was NULL. - -**/ -EFI_STATUS -EFIAPI -WinNtGopQuerytMode ( - IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This, - IN UINT32 ModeNumber, - OUT UINTN *SizeOfInfo, - OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info - ) -{ - GOP_PRIVATE_DATA *Private; - - Private = GOP_PRIVATE_DATA_FROM_THIS (This); - - if (Info == NULL || SizeOfInfo == NULL || (UINTN) ModeNumber >= This->Mode->MaxMode) { - return EFI_INVALID_PARAMETER; - } - - *Info = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION)); - if (*Info == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - *SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION); - - (*Info)->Version = 0; - (*Info)->HorizontalResolution = Private->ModeData[ModeNumber].HorizontalResolution; - (*Info)->VerticalResolution = Private->ModeData[ModeNumber].VerticalResolution; - (*Info)->PixelFormat = PixelBltOnly; - (*Info)->PixelsPerScanLine = (*Info)->HorizontalResolution; - - return EFI_SUCCESS; -} - - -/** - Graphics Output protocol interface to set video mode - - @param This Protocol instance pointer. - @param ModeNumber The mode number to be set. - - @retval EFI_SUCCESS Graphics mode was changed. - @retval EFI_DEVICE_ERROR The device had an error and could not complete the - request. - @retval EFI_UNSUPPORTED ModeNumber is not supported by this device. - -**/ -EFI_STATUS -EFIAPI -WinNtGopSetMode ( - IN EFI_GRAPHICS_OUTPUT_PROTOCOL * This, - IN UINT32 ModeNumber - ) -{ - EFI_STATUS Status; - GOP_PRIVATE_DATA *Private; - GOP_MODE_DATA *ModeData; - EFI_GRAPHICS_OUTPUT_BLT_PIXEL Fill; - EFI_GRAPHICS_OUTPUT_BLT_PIXEL *NewFillLine; - RECT Rect; - UINTN Size; - UINTN Width; - UINTN Height; - - Private = GOP_PRIVATE_DATA_FROM_THIS (This); - - if (ModeNumber >= This->Mode->MaxMode) { - return EFI_UNSUPPORTED; - } - - ModeData = &Private->ModeData[ModeNumber]; - This->Mode->Mode = ModeNumber; - Private->GraphicsOutput.Mode->Info->HorizontalResolution = ModeData->HorizontalResolution; - Private->GraphicsOutput.Mode->Info->VerticalResolution = ModeData->VerticalResolution; - Private->GraphicsOutput.Mode->Info->PixelsPerScanLine = ModeData->HorizontalResolution; - - if (Private->HardwareNeedsStarting) { - Status = WinNtGopStartWindow ( - Private, - ModeData->HorizontalResolution, - ModeData->VerticalResolution, - ModeData->ColorDepth, - ModeData->RefreshRate - ); - if (EFI_ERROR (Status)) { - return EFI_DEVICE_ERROR; - } - - Private->HardwareNeedsStarting = FALSE; - } else { - // - // Change the resolution and resize of the window - // - - // - // Free the old buffer. We do not save the content of the old buffer since the - // screen is to be cleared anyway. Clearing the screen is required by the EFI spec. - // See UEFI spec -EFI_GRAPHICS_OUTPUT_PROTOCOL.SetMode() - // - Private->WinNtThunk->HeapFree (Private->WinNtThunk->GetProcessHeap (), 0, Private->VirtualScreenInfo); - - // - // Allocate DIB frame buffer directly from NT for performance enhancement - // This buffer is the virtual screen/frame buffer. This buffer is not the - // same a a frame buffer. The first row of this buffer will be the bottom - // line of the image. This is an artifact of the way we draw to the screen. - // - Size = ModeData->HorizontalResolution * ModeData->VerticalResolution * sizeof (RGBQUAD) + sizeof (BITMAPV4HEADER); - Private->VirtualScreenInfo = Private->WinNtThunk->HeapAlloc ( - Private->WinNtThunk->GetProcessHeap (), - HEAP_ZERO_MEMORY, - Size - ); - - // - // Update the virtual screen info data structure - // - Private->VirtualScreenInfo->bV4Size = sizeof (BITMAPV4HEADER); - Private->VirtualScreenInfo->bV4Width = ModeData->HorizontalResolution; - Private->VirtualScreenInfo->bV4Height = ModeData->VerticalResolution; - Private->VirtualScreenInfo->bV4Planes = 1; - Private->VirtualScreenInfo->bV4BitCount = 32; - // - // uncompressed - // - Private->VirtualScreenInfo->bV4V4Compression = BI_RGB; - - // - // The rest of the allocated memory block is the virtual screen buffer - // - Private->VirtualScreen = (RGBQUAD *) (Private->VirtualScreenInfo + 1); - - // - // Use the AdjuctWindowRect fuction to calculate the real width and height - // of the new window including the border and caption - // - Rect.left = 0; - Rect.top = 0; - Rect.right = ModeData->HorizontalResolution; - Rect.bottom = ModeData->VerticalResolution; - - Private->WinNtThunk->AdjustWindowRect (&Rect, WS_OVERLAPPEDWINDOW, 0); - - Width = Rect.right - Rect.left; - Height = Rect.bottom - Rect.top; - - // - // Retrieve the original window position information - // - Private->WinNtThunk->GetWindowRect (Private->WindowHandle, &Rect); - - // - // Adjust the window size - // - Private->WinNtThunk->MoveWindow (Private->WindowHandle, Rect.left, Rect.top, (INT32)Width, (INT32)Height, TRUE); - - } - - NewFillLine = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * ModeData->HorizontalResolution); - if (NewFillLine == NULL) { - return EFI_DEVICE_ERROR; - } - - if (Private->FillLine != NULL) { - FreePool (Private->FillLine); - } - - Private->FillLine = NewFillLine; - - Fill.Red = 0x00; - Fill.Green = 0x00; - Fill.Blue = 0x00; - This->Blt ( - This, - &Fill, - EfiBltVideoFill, - 0, - 0, - 0, - 0, - ModeData->HorizontalResolution, - ModeData->VerticalResolution, - ModeData->HorizontalResolution * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) - ); - return EFI_SUCCESS; -} - - -/** - Blt pixels from the rectangle (Width X Height) formed by the BltBuffer - onto the graphics screen starting a location (X, Y). (0, 0) is defined as - the upper left hand side of the screen. (X, Y) can be outside of the - current screen geometry and the BltBuffer will be cliped when it is - displayed. X and Y can be negative or positive. If Width or Height is - bigger than the current video screen the image will be clipped. - - @param This Protocol instance pointer. - @param X X location on graphics screen. - @param Y Y location on the graphics screen. - @param Width Width of BltBuffer. - @param Height Hight of BltBuffer - @param BltOperation Operation to perform on BltBuffer and video memory - @param BltBuffer Buffer containing data to blt into video buffer. - This buffer has a size of - Width*Height*sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL) - @param SourceX If the BltOperation is a EfiCopyBlt this is the - source of the copy. For other BLT operations this - argument is not used. - @param SourceX If the BltOperation is a EfiCopyBlt this is the - source of the copy. For other BLT operations this - argument is not used. - - @retval EFI_SUCCESS The palette is updated with PaletteArray. - @retval EFI_INVALID_PARAMETER BltOperation is not valid. - @retval EFI_DEVICE_ERROR A hardware error occured writting to the video - buffer. - -**/ -// TODO: SourceY - add argument and description to function comment -// TODO: DestinationX - add argument and description to function comment -// TODO: DestinationY - add argument and description to function comment -// TODO: Delta - add argument and description to function comment -EFI_STATUS -EFIAPI -WinNtGopBlt ( - IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This, - IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL - IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation, - IN UINTN SourceX, - IN UINTN SourceY, - IN UINTN DestinationX, - IN UINTN DestinationY, - IN UINTN Width, - IN UINTN Height, - IN UINTN Delta OPTIONAL - ) -{ - GOP_PRIVATE_DATA *Private; - EFI_TPL OriginalTPL; - UINTN DstY; - UINTN SrcY; - RGBQUAD *VScreen; - RGBQUAD *VScreenSrc; - EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt; - UINTN Index; - RECT Rect; - EFI_GRAPHICS_OUTPUT_BLT_PIXEL *FillPixel; - UINT32 VerticalResolution; - UINT32 HorizontalResolution; - - Private = GOP_PRIVATE_DATA_FROM_THIS (This); - - if ((BltOperation < 0) || (BltOperation >= EfiGraphicsOutputBltOperationMax)) { - return EFI_INVALID_PARAMETER; - } - - if (Width == 0 || Height == 0) { - return EFI_INVALID_PARAMETER; - } - // - // If Delta is zero, then the entire BltBuffer is being used, so Delta - // is the number of bytes in each row of BltBuffer. Since BltBuffer is Width pixels size, - // the number of bytes in each row can be computed. - // - if (Delta == 0) { - Delta = Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL); - } - - // - // We need to fill the Virtual Screen buffer with the blt data. - // The virtual screen is upside down, as the first row is the bootom row of - // the image. - // - VerticalResolution = This->Mode->Info->VerticalResolution; - HorizontalResolution = This->Mode->Info->HorizontalResolution; - if (BltOperation == EfiBltVideoToBltBuffer) { - - // - // Video to BltBuffer: Source is Video, destination is BltBuffer - // - if (SourceY + Height > VerticalResolution) { - return EFI_INVALID_PARAMETER; - } - - if (SourceX + Width > HorizontalResolution) { - return EFI_INVALID_PARAMETER; - } - // - // We have to raise to TPL Notify, so we make an atomic write the frame buffer. - // We would not want a timer based event (Cursor, ...) to come in while we are - // doing this operation. - // - OriginalTPL = gBS->RaiseTPL (TPL_NOTIFY); - - for (SrcY = SourceY, DstY = DestinationY; DstY < (Height + DestinationY); SrcY++, DstY++) { - Blt = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) ((UINT8 *) BltBuffer + (DstY * Delta) + DestinationX * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)); - VScreen = &Private->VirtualScreen[(VerticalResolution - SrcY - 1) * HorizontalResolution + SourceX]; - CopyMem (Blt, VScreen, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * Width); - } - } else { - // - // BltBuffer to Video: Source is BltBuffer, destination is Video - // - if (DestinationY + Height > VerticalResolution) { - return EFI_INVALID_PARAMETER; - } - - if (DestinationX + Width > HorizontalResolution) { - return EFI_INVALID_PARAMETER; - } - - // - // We have to raise to TPL Notify, so we make an atomic write the frame buffer. - // We would not want a timer based event (Cursor, ...) to come in while we are - // doing this operation. - // - OriginalTPL = gBS->RaiseTPL (TPL_NOTIFY); - - if (BltOperation == EfiBltVideoFill) { - FillPixel = BltBuffer; - for (Index = 0; Index < Width; Index++) { - Private->FillLine[Index] = *FillPixel; - } - } - - for (Index = 0; Index < Height; Index++) { - if (DestinationY <= SourceY) { - SrcY = SourceY + Index; - DstY = DestinationY + Index; - } else { - SrcY = SourceY + Height - Index - 1; - DstY = DestinationY + Height - Index - 1; - } - - VScreen = &Private->VirtualScreen[(VerticalResolution - DstY - 1) * HorizontalResolution + DestinationX]; - switch (BltOperation) { - case EfiBltBufferToVideo: - Blt = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) ((UINT8 *) BltBuffer + (SrcY * Delta) + SourceX * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)); - CopyMem (VScreen, Blt, Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)); - break; - - case EfiBltVideoToVideo: - VScreenSrc = &Private->VirtualScreen[(VerticalResolution - SrcY - 1) * HorizontalResolution + SourceX]; - CopyMem (VScreen, VScreenSrc, Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)); - break; - - case EfiBltVideoFill: - CopyMem (VScreen, Private->FillLine, Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)); - break; - } - } - } - - if (BltOperation != EfiBltVideoToBltBuffer) { - // - // Mark the area we just blted as Invalid so WM_PAINT will update. - // - Rect.left = (LONG)DestinationX; - Rect.top = (LONG)DestinationY; - Rect.right = (LONG)(DestinationX + Width); - Rect.bottom = (LONG)(DestinationY + Height); - Private->WinNtThunk->InvalidateRect (Private->WindowHandle, &Rect, FALSE); - - // - // Send the WM_PAINT message to the thread that is drawing the window. We - // are in the main thread and the window drawing is in a child thread. - // There is a child thread per window. We have no CriticalSection or Mutex - // since we write the data and the other thread displays the data. While - // we may miss some data for a short period of time this is no different than - // a write combining on writes to a frame buffer. - // - - Private->WinNtThunk->UpdateWindow (Private->WindowHandle); - } - - gBS->RestoreTPL (OriginalTPL); - - return EFI_SUCCESS; -} - -// -// Construction and Destruction functions -// - - -/** - - - @return None - -**/ -// TODO: WinNtIo - add argument and description to function comment -// TODO: EFI_UNSUPPORTED - add return value to function comment -// TODO: EFI_SUCCESS - add return value to function comment -EFI_STATUS -WinNtGopSupported ( - IN EFI_WIN_NT_IO_PROTOCOL *WinNtIo - ) -{ - // - // Check to see if the IO abstraction represents a device type we support. - // - // This would be replaced a check of PCI subsystem ID, etc. - // - if (!CompareGuid (WinNtIo->TypeGuid, &gEfiWinNtGopGuid)) { - return EFI_UNSUPPORTED; - } - - return EFI_SUCCESS; -} - - -/** - Win32 Windows event handler. - - See Win32 Book - - @return See Win32 Book - -**/ -// TODO: hwnd - add argument and description to function comment -// TODO: iMsg - add argument and description to function comment -// TODO: wParam - add argument and description to function comment -// TODO: lParam - add argument and description to function comment -LRESULT -CALLBACK -WinNtGopThreadWindowProc ( - IN HWND hwnd, - IN UINT iMsg, - IN WPARAM wParam, - IN LPARAM lParam - ) -{ - GOP_PRIVATE_DATA *Private; - UINTN Size; - HDC Handle; - PAINTSTRUCT PaintStruct; - LPARAM Index; - EFI_INPUT_KEY Key; - BOOLEAN AltIsPress; - - // - // BugBug - if there are two instances of this DLL in memory (such as is - // the case for ERM), the correct instance of this function may not be called. - // This also means that the address of the mTlsIndex value will be wrong, and - // the value may be wrong too. - // - - - // - // Use mTlsIndex global to get a Thread Local Storage version of Private. - // This works since each Gop protocol has a unique Private data instance and - // a unique thread. - // - AltIsPress = FALSE; - Private = mWinNt->TlsGetValue (mTlsIndex); - ASSERT (NULL != Private); - - switch (iMsg) { - case WM_CREATE: - Size = Private->GraphicsOutput.Mode->Info->HorizontalResolution * Private->GraphicsOutput.Mode->Info->VerticalResolution * sizeof (RGBQUAD); - - // - // Allocate DIB frame buffer directly from NT for performance enhancement - // This buffer is the virtual screen/frame buffer. This buffer is not the - // same a a frame buffer. The first fow of this buffer will be the bottom - // line of the image. This is an artifact of the way we draw to the screen. - // - Private->VirtualScreenInfo = Private->WinNtThunk->HeapAlloc ( - Private->WinNtThunk->GetProcessHeap (), - HEAP_ZERO_MEMORY, - Size - ); - - Private->VirtualScreenInfo->bV4Size = sizeof (BITMAPV4HEADER); - Private->VirtualScreenInfo->bV4Width = Private->GraphicsOutput.Mode->Info->HorizontalResolution; - Private->VirtualScreenInfo->bV4Height = Private->GraphicsOutput.Mode->Info->VerticalResolution; - Private->VirtualScreenInfo->bV4Planes = 1; - Private->VirtualScreenInfo->bV4BitCount = 32; - // - // uncompressed - // - Private->VirtualScreenInfo->bV4V4Compression = BI_RGB; - Private->VirtualScreen = (RGBQUAD *) (Private->VirtualScreenInfo + 1); - return 0; - - case WM_PAINT: - // - // I have not found a way to convert hwnd into a Private context. So for - // now we use this API to convert hwnd to Private data. - // - - Handle = mWinNt->BeginPaint (hwnd, &PaintStruct); - - mWinNt->SetDIBitsToDevice ( - Handle, // Destination Device Context - 0, // Destination X - 0 - 0, // Destination Y - 0 - Private->GraphicsOutput.Mode->Info->HorizontalResolution, // Width - Private->GraphicsOutput.Mode->Info->VerticalResolution, // Height - 0, // Source X - 0, // Source Y - 0, // DIB Start Scan Line - Private->GraphicsOutput.Mode->Info->VerticalResolution, // Number of scan lines - Private->VirtualScreen, // Address of array of DIB bits - (BITMAPINFO *) Private->VirtualScreenInfo, // Address of structure with bitmap info - DIB_RGB_COLORS // RGB or palette indexes - ); - - mWinNt->EndPaint (hwnd, &PaintStruct); - return 0; - - // - // F10 and the ALT key do not create a WM_KEYDOWN message, thus this special case - // WM_SYSKEYDOWN is posted when F10 is pressed or - // holds down ALT key and then presses another key. - // - case WM_SYSKEYDOWN: - - Key.ScanCode = 0; - Key.UnicodeChar = CHAR_NULL; - switch (wParam) { - case VK_F10: - Key.ScanCode = SCAN_F10; - Key.UnicodeChar = CHAR_NULL; - GopPrivateAddKey (Private, Key); - return 0; - } - - // - // If ALT or ALT + modifier key is pressed. - // - if (WinNtGopConvertParamToEfiKey (Private, &wParam, &lParam, &Key)) { - if (Key.ScanCode != 0){ - // - // If ALT is pressed with other ScanCode. - // Always revers the left Alt for simple. - // - Private->LeftAlt = TRUE; - } - GopPrivateAddKey (Private, Key); - // - // When Alt is released there is no windoes message, so - // clean it after using it. - // - Private->RightAlt = FALSE; - Private->LeftAlt = FALSE; - return 0; - } - AltIsPress = TRUE; - - case WM_CHAR: - // - // The ESC key also generate WM_CHAR. - // - if (wParam == 0x1B) { - return 0; - } - - if (AltIsPress == TRUE) { - // - // If AltIsPress is true that means the Alt key is pressed. - // - Private->LeftAlt = TRUE; - } - for (Index = 0; Index < (lParam & 0xffff); Index++) { - if (wParam != 0) { - Key.UnicodeChar = (CHAR16) wParam; - Key.ScanCode = SCAN_NULL; - GopPrivateAddKey (Private, Key); - } - } - if (AltIsPress == TRUE) { - // - // When Alt is released there is no windoes message, so - // clean it after using it. - // - Private->LeftAlt = FALSE; - Private->RightAlt = FALSE; - } - return 0; - - case WM_SYSKEYUP: - // - // ALT is pressed with another key released - // - WinNtGopConvertParamToEfiKeyShiftState (Private, &wParam, &lParam, FALSE); - return 0; - - case WM_KEYDOWN: - Key.ScanCode = SCAN_NULL; - Key.UnicodeChar = CHAR_NULL; - // - // A value key press will cause a WM_KEYDOWN first, then cause a WM_CHAR - // So if there is no modifier key updated, skip the WM_KEYDOWN even. - // - if (WinNtGopConvertParamToEfiKey (Private, &wParam, &lParam, &Key)) { - // - // Support the partial keystroke, add all keydown event into the queue. - // - GopPrivateAddKey (Private, Key); - } - return 0; - - case WM_KEYUP: - WinNtGopConvertParamToEfiKeyShiftState (Private, &wParam, &lParam, FALSE); - return 0; - - case WM_CLOSE: - // - // This close message is issued by user, core is not aware of this, - // so don't release the window display resource, just hide the window. - // - Private->WinNtThunk->ShowWindow (Private->WindowHandle, SW_HIDE); - return 0; - - case WM_DESTROY: - mWinNt->DestroyWindow (hwnd); - mWinNt->PostQuitMessage (0); - - mWinNt->HeapFree (Private->WinNtThunk->GetProcessHeap (), 0, Private->VirtualScreenInfo); - - mWinNt->ExitThread (0); - return 0; - - default: - break; - }; - - return mWinNt->DefWindowProc (hwnd, iMsg, wParam, lParam); -} - - -/** - This thread simulates the end of WinMain () aplication. Each Winow nededs - to process it's events. The messages are dispatched to - WinNtGopThreadWindowProc (). - Be very careful sine WinNtGopThreadWinMain () and WinNtGopThreadWindowProc () - are running in a seperate thread. We have to do this to process the events. - - @param lpParameter Handle of window to manage. - - @return if a WM_QUIT message is returned exit. - -**/ -DWORD -WINAPI -WinNtGopThreadWinMain ( - LPVOID lpParameter - ) -{ - MSG Message; - GOP_PRIVATE_DATA *Private; - RECT Rect; - - Private = (GOP_PRIVATE_DATA *) lpParameter; - ASSERT (NULL != Private); - - // - // Since each thread has unique private data, save the private data in Thread - // Local Storage slot. Then the shared global mTlsIndex can be used to get - // thread specific context. - // - Private->WinNtThunk->TlsSetValue (mTlsIndex, Private); - - Private->ThreadId = Private->WinNtThunk->GetCurrentThreadId (); - - Private->WindowsClass.cbSize = sizeof (WNDCLASSEX); - Private->WindowsClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; - Private->WindowsClass.lpfnWndProc = WinNtGopThreadWindowProc; - Private->WindowsClass.cbClsExtra = 0; - Private->WindowsClass.cbWndExtra = 0; - Private->WindowsClass.hInstance = NULL; - Private->WindowsClass.hIcon = Private->WinNtThunk->LoadIcon (NULL, IDI_APPLICATION); - Private->WindowsClass.hCursor = Private->WinNtThunk->LoadCursor (NULL, IDC_ARROW); - Private->WindowsClass.hbrBackground = (HBRUSH)(UINTN)COLOR_WINDOW; - Private->WindowsClass.lpszMenuName = NULL; - Private->WindowsClass.lpszClassName = WIN_NT_GOP_CLASS_NAME; - Private->WindowsClass.hIconSm = Private->WinNtThunk->LoadIcon (NULL, IDI_APPLICATION); - - // - // This call will fail after the first time, but thats O.K. since we only need - // WIN_NT_GOP_CLASS_NAME to exist to create the window. - // - // Note: Multiple instances of this DLL will use the same instance of this - // Class, including the callback function, unless the Class is unregistered and - // successfully registered again. - // - Private->WinNtThunk->RegisterClassEx (&Private->WindowsClass); - - // - // Setting Rect values to allow for the AdjustWindowRect to provide - // us the correct sizes for the client area when doing the CreateWindowEx - // - Rect.top = 0; - Rect.bottom = Private->GraphicsOutput.Mode->Info->VerticalResolution; - Rect.left = 0; - Rect.right = Private->GraphicsOutput.Mode->Info->HorizontalResolution; - - Private->WinNtThunk->AdjustWindowRect (&Rect, WS_OVERLAPPEDWINDOW, 0); - - Private->WindowHandle = Private->WinNtThunk->CreateWindowEx ( - 0, - WIN_NT_GOP_CLASS_NAME, - Private->WindowName, - WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, - CW_USEDEFAULT, - Rect.right - Rect.left, - Rect.bottom - Rect.top, - NULL, - NULL, - NULL, - (VOID **)&Private - ); - - // - // The reset of this thread is the standard winows program. We need a sperate - // thread since we must process the message loop to make windows act like - // windows. - // - - Private->WinNtThunk->ShowWindow (Private->WindowHandle, SW_SHOW); - Private->WinNtThunk->UpdateWindow (Private->WindowHandle); - - // - // Let the main thread get some work done - // - Private->WinNtThunk->ReleaseSemaphore (Private->ThreadInited, 1, NULL); - - // - // This is the message loop that all Windows programs need. - // - while (Private->WinNtThunk->GetMessage (&Message, Private->WindowHandle, 0, 0)) { - Private->WinNtThunk->TranslateMessage (&Message); - Private->WinNtThunk->DispatchMessage (&Message); - } - - return (DWORD)Message.wParam; -} - - -/** - TODO: Add function description - - @param Private TODO: add argument description - @param HorizontalResolution TODO: add argument description - @param VerticalResolution TODO: add argument description - @param ColorDepth TODO: add argument description - @param RefreshRate TODO: add argument description - - @return TODO: add return values - -**/ -EFI_STATUS -WinNtGopStartWindow ( - IN GOP_PRIVATE_DATA *Private, - IN UINT32 HorizontalResolution, - IN UINT32 VerticalResolution, - IN UINT32 ColorDepth, - IN UINT32 RefreshRate - ) -{ - EFI_STATUS Status; - DWORD NewThreadId; - - mWinNt = Private->WinNtThunk; - - // - // Initialize a Thread Local Storge variable slot. We use TLS to get the - // correct Private data instance into the windows thread. - // - if (mTlsIndex == TLS_OUT_OF_INDEXES) { - ASSERT (0 == mTlsIndexUseCount); - mTlsIndex = Private->WinNtThunk->TlsAlloc (); - } - - // - // always increase the use count! - // - mTlsIndexUseCount++; - - // - // Register to be notified on exit boot services so we can destroy the window. - // - Status = gBS->CreateEventEx ( - EVT_NOTIFY_SIGNAL, - TPL_CALLBACK, - KillNtGopThread, - Private, - &gEfiEventExitBootServicesGuid, - &mGopScreenExitBootServicesEvent - ); - - Private->ThreadInited = Private->WinNtThunk->CreateSemaphore (NULL, 0, 1, NULL); - Private->ThreadHandle = Private->WinNtThunk->CreateThread ( - NULL, - 0, - WinNtGopThreadWinMain, - (VOID *) Private, - 0, - &NewThreadId - ); - - // - // The other thread has entered the windows message loop so we can - // continue our initialization. - // - Private->WinNtThunk->WaitForSingleObject (Private->ThreadInited, INFINITE); - Private->WinNtThunk->CloseHandle (Private->ThreadInited); - - return Status; -} - - -/** - - - @return None - -**/ -// TODO: Private - add argument and description to function comment -// TODO: EFI_SUCCESS - add return value to function comment -EFI_STATUS -WinNtGopConstructor ( - GOP_PRIVATE_DATA *Private - ) -{ - Private->ModeData = mGopModeData; - - Private->GraphicsOutput.QueryMode = WinNtGopQuerytMode; - Private->GraphicsOutput.SetMode = WinNtGopSetMode; - Private->GraphicsOutput.Blt = WinNtGopBlt; - - // - // Allocate buffer for Graphics Output Protocol mode information - // - Private->GraphicsOutput.Mode = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE)); - if (Private->GraphicsOutput.Mode == NULL) { - return EFI_OUT_OF_RESOURCES; - } - Private->GraphicsOutput.Mode->Info = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION)); - if (Private->GraphicsOutput.Mode->Info == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - Private->GraphicsOutput.Mode->MaxMode = sizeof(mGopModeData) / sizeof(GOP_MODE_DATA); - // - // Till now, we have no idea about the window size. - // - Private->GraphicsOutput.Mode->Mode = GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER; - Private->GraphicsOutput.Mode->Info->Version = 0; - Private->GraphicsOutput.Mode->Info->HorizontalResolution = 0; - Private->GraphicsOutput.Mode->Info->VerticalResolution = 0; - Private->GraphicsOutput.Mode->Info->PixelFormat = PixelBltOnly; - Private->GraphicsOutput.Mode->SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION); - Private->GraphicsOutput.Mode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS) (UINTN) NULL; - Private->GraphicsOutput.Mode->FrameBufferSize = 0; - - Private->HardwareNeedsStarting = TRUE; - Private->FillLine = NULL; - - WinNtGopInitializeSimpleTextInForWindow (Private); - - return EFI_SUCCESS; -} - - -/** - - - @return None - -**/ -// TODO: Private - add argument and description to function comment -// TODO: EFI_SUCCESS - add return value to function comment -EFI_STATUS -WinNtGopDestructor ( - GOP_PRIVATE_DATA *Private - ) -{ - if (!Private->HardwareNeedsStarting) { - // - // BugBug: Shutdown GOP Hardware and any child devices. - // - Private->WinNtThunk->SendMessage (Private->WindowHandle, WM_DESTROY, 0, 0); - Private->WinNtThunk->CloseHandle (Private->ThreadHandle); - - mTlsIndexUseCount--; - - // - // The callback function for another window could still be called, - // so we need to make sure there are no more users of mTlsIndex. - // - if (0 == mTlsIndexUseCount) { - ASSERT (TLS_OUT_OF_INDEXES != mTlsIndex); - - Private->WinNtThunk->TlsFree (mTlsIndex); - mTlsIndex = TLS_OUT_OF_INDEXES; - - Private->WinNtThunk->UnregisterClass ( - Private->WindowsClass.lpszClassName, - Private->WindowsClass.hInstance - ); - } - - WinNtGopDestroySimpleTextInForWindow (Private); - } - - // - // Free graphics output protocol occupied resource - // - if (Private->GraphicsOutput.Mode != NULL) { - if (Private->GraphicsOutput.Mode->Info != NULL) { - FreePool (Private->GraphicsOutput.Mode->Info); - } - FreePool (Private->GraphicsOutput.Mode); - } - - return EFI_SUCCESS; -} - - -/** - This is the GOP screen's callback notification function for exit-boot-services. - All we do here is call WinNtGopDestructor(). - - @param Event not used - @param Context pointer to the Private structure. - - @return None. - -**/ -VOID -EFIAPI -KillNtGopThread ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - WinNtGopDestructor (Context); -} diff --git a/Nt32Pkg/WinNtOemHookStatusCodeHandlerDxe/WinNtOemHookStatusCodeHandlerDxe.c b/Nt32Pkg/WinNtOemHookStatusCodeHandlerDxe/WinNtOemHookStatusCodeHandlerDxe.c deleted file mode 100644 index 20bd719ee8..0000000000 --- a/Nt32Pkg/WinNtOemHookStatusCodeHandlerDxe/WinNtOemHookStatusCodeHandlerDxe.c +++ /dev/null @@ -1,62 +0,0 @@ -/** @file - OEM hook status code handler driver which produces general handler and hook it - onto the DXE status code router. - - Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
- SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -// -// The package level header files this module uses -// -#include - -// -// The protocols, PPI and GUID defintions for this module -// -#include - -// -// The Library classes this module consumes -// -#include -#include -#include -#include - -/** - Entry point of OEM hook status code handler driver. - - This function is the entry point of this OEM hook status code handler driver. - It initializes registers OEM status code handler. - - @param ImageHandle The firmware allocated handle for the EFI image. - @param SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS The entry point is executed successfully. - -**/ -EFI_STATUS -EFIAPI -WinNtOemHookStatusCodeHandlerDxeEntry ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - EFI_RSC_HANDLER_PROTOCOL *RscHandlerProtocol; - - Status = gBS->LocateProtocol ( - &gEfiRscHandlerProtocolGuid, - NULL, - (VOID **) &RscHandlerProtocol - ); - ASSERT_EFI_ERROR (Status); - - OemHookStatusCodeInitialize (); - - RscHandlerProtocol->Register (OemHookStatusCodeReport, TPL_HIGH_LEVEL); - - return EFI_SUCCESS; -} diff --git a/Nt32Pkg/WinNtOemHookStatusCodeHandlerDxe/WinNtOemHookStatusCodeHandlerDxe.inf b/Nt32Pkg/WinNtOemHookStatusCodeHandlerDxe/WinNtOemHookStatusCodeHandlerDxe.inf deleted file mode 100644 index fb0c0e1884..0000000000 --- a/Nt32Pkg/WinNtOemHookStatusCodeHandlerDxe/WinNtOemHookStatusCodeHandlerDxe.inf +++ /dev/null @@ -1,46 +0,0 @@ -## @file -# OEM hook status code handler driver which produces general handler and hook it -# onto the DXE status code router. -# -# Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.
-# SPDX-License-Identifier: BSD-2-Clause-Patent -# -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = WinNtOemHookStatusCodeHandlerDxe - FILE_GUID = CA4233AD-847E-4E5D-AD3F-21CABFE5E23C - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - ENTRY_POINT = WinNtOemHookStatusCodeHandlerDxeEntry - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 -# -# HOB Guid C Name: gEfiWinNtThunkProtocolGuid Hob Type: GUID_EXTENSION -# - -[Sources] - WinNtOemHookStatusCodeHandlerDxe.c - - -[Packages] - Nt32Pkg/Nt32Pkg.dec - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - -[LibraryClasses] - DebugLib - UefiDriverEntryPoint - UefiBootServicesTableLib - OemHookStatusCodeLib - -[Protocols] - gEfiRscHandlerProtocolGuid ## CONSUMES - -[Depex] - gEfiRscHandlerProtocolGuid diff --git a/Nt32Pkg/WinNtOemHookStatusCodeHandlerPei/WinNtOemHookStatusCodeHandlerPei.c b/Nt32Pkg/WinNtOemHookStatusCodeHandlerPei/WinNtOemHookStatusCodeHandlerPei.c deleted file mode 100644 index 11fb7209eb..0000000000 --- a/Nt32Pkg/WinNtOemHookStatusCodeHandlerPei/WinNtOemHookStatusCodeHandlerPei.c +++ /dev/null @@ -1,83 +0,0 @@ -/** @file - OEM hook status code handler PEIM which produces general handler and hook it - onto the PEI status code router. - - Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
- SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -// -// The package level header files this module uses -// -#include - -// -// The protocols, PPI and GUID defintions for this module -// -#include -// -// The Library classes this module consumes -// -#include -#include -#include -#include - -EFI_STATUS -EFIAPI -OemHookStatusCodeReportWrapper ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN EFI_STATUS_CODE_TYPE CodeType, - IN EFI_STATUS_CODE_VALUE Value, - IN UINT32 Instance, - IN CONST EFI_GUID *CallerId, OPTIONAL - IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL - ) -{ - return OemHookStatusCodeReport ( - CodeType, - Value, - Instance, - (EFI_GUID *) CallerId, - (EFI_STATUS_CODE_DATA *) Data - ); -} - -/** - Entry point of OEM hook status code handler PEIM. - - This function is the entry point of this OEM hook status code handler PEIM. - It initializes and registers OEM status code handler. - - @param FileHandle Handle of the file being invoked. - @param PeiServices Describes the list of possible PEI Services. - - @retval EFI_SUCESS The entry point executes successfully. - -**/ -EFI_STATUS -EFIAPI -WinNtOemHookStatusCodeHandlerPeiEntry ( - IN EFI_PEI_FILE_HANDLE FileHandle, - IN CONST EFI_PEI_SERVICES **PeiServices - ) -{ - EFI_STATUS Status; - EFI_PEI_RSC_HANDLER_PPI *RscHandlerPpi; - - Status = PeiServicesLocatePpi ( - &gEfiPeiRscHandlerPpiGuid, - 0, - NULL, - (VOID **) &RscHandlerPpi - ); - ASSERT_EFI_ERROR (Status); - - OemHookStatusCodeInitialize (); - - Status = RscHandlerPpi->Register (OemHookStatusCodeReportWrapper); - ASSERT_EFI_ERROR (Status); - - return EFI_SUCCESS; -} diff --git a/Nt32Pkg/WinNtOemHookStatusCodeHandlerPei/WinNtOemHookStatusCodeHandlerPei.inf b/Nt32Pkg/WinNtOemHookStatusCodeHandlerPei/WinNtOemHookStatusCodeHandlerPei.inf deleted file mode 100644 index ece1424e74..0000000000 --- a/Nt32Pkg/WinNtOemHookStatusCodeHandlerPei/WinNtOemHookStatusCodeHandlerPei.inf +++ /dev/null @@ -1,46 +0,0 @@ -## @file -# OEM hook status code handler PEIM which produces general handler and hook it -# onto the PEI status code router. -# -# Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.
-# SPDX-License-Identifier: BSD-2-Clause-Patent - -# -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = WinNtOemHookStatusCodeHandlerPei - FILE_GUID = D233D6BD-F1B1-425A-BF45-5CAF2B88EDDC - MODULE_TYPE = PEIM - VERSION_STRING = 1.0 - ENTRY_POINT = WinNtOemHookStatusCodeHandlerPeiEntry - - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 -# - -[Sources] - WinNtOemHookStatusCodeHandlerPei.c - - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - Nt32Pkg/Nt32Pkg.dec - -[LibraryClasses] - PeimEntryPoint - PeiServicesLib - DebugLib - OemHookStatusCodeLib - -[Ppis] - gEfiPeiRscHandlerPpiGuid ## CONSUMES - -[Depex] - gEfiPeiRscHandlerPpiGuid diff --git a/Nt32Pkg/WinNtSerialIoDxe/ComponentName.c b/Nt32Pkg/WinNtSerialIoDxe/ComponentName.c deleted file mode 100644 index 3902243798..0000000000 --- a/Nt32Pkg/WinNtSerialIoDxe/ComponentName.c +++ /dev/null @@ -1,360 +0,0 @@ -/**@file - -Copyright (c) 2006, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - ComponentName.c - -Abstract: - -**/ - -#include "WinNtSerialIo.h" - -// -// EFI Component Name Functions -// -/** - Retrieves a Unicode string that is the user readable name of the driver. - - This function retrieves the user readable name of a driver in the form of a - Unicode string. If the driver specified by This has a user readable name in - the language specified by Language, then a pointer to the driver name is - returned in DriverName, and EFI_SUCCESS is returned. If the driver specified - by This does not support the language specified by Language, - then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified - in RFC 4646 or ISO 639-2 language code format. - - @param DriverName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - driver specified by This in the language - specified by Language. - - @retval EFI_SUCCESS The Unicode string for the Driver specified by - This and the language specified by Language was - returned in DriverName. - - @retval EFI_INVALID_PARAMETER Language is NULL. - - @retval EFI_INVALID_PARAMETER DriverName is NULL. - - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -WinNtSerialIoComponentNameGetDriverName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName - ); - - -/** - Retrieves a Unicode string that is the user readable name of the controller - that is being managed by a driver. - - This function retrieves the user readable name of the controller specified by - ControllerHandle and ChildHandle in the form of a Unicode string. If the - driver specified by This has a user readable name in the language specified by - Language, then a pointer to the controller name is returned in ControllerName, - and EFI_SUCCESS is returned. If the driver specified by This is not currently - managing the controller specified by ControllerHandle and ChildHandle, - then EFI_UNSUPPORTED is returned. If the driver specified by This does not - support the language specified by Language, then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - - @param ControllerHandle[in] The handle of a controller that the driver - specified by This is managing. This handle - specifies the controller whose name is to be - returned. - - @param ChildHandle[in] The handle of the child controller to retrieve - the name of. This is an optional parameter that - may be NULL. It will be NULL for device - drivers. It will also be NULL for a bus drivers - that wish to retrieve the name of the bus - controller. It will not be NULL for a bus - driver that wishes to retrieve the name of a - child controller. - - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified in - RFC 4646 or ISO 639-2 language code format. - - @param ControllerName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - controller specified by ControllerHandle and - ChildHandle in the language specified by - Language from the point of view of the driver - specified by This. - - @retval EFI_SUCCESS The Unicode string for the user readable name in - the language specified by Language for the - driver specified by This was returned in - DriverName. - - @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. - - @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid - EFI_HANDLE. - - @retval EFI_INVALID_PARAMETER Language is NULL. - - @retval EFI_INVALID_PARAMETER ControllerName is NULL. - - @retval EFI_UNSUPPORTED The driver specified by This is not currently - managing the controller specified by - ControllerHandle and ChildHandle. - - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -WinNtSerialIoComponentNameGetControllerName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName - ); - - -// -// EFI Component Name Protocol -// -GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gWinNtSerialIoComponentName = { - WinNtSerialIoComponentNameGetDriverName, - WinNtSerialIoComponentNameGetControllerName, - "eng" -}; - -// -// EFI Component Name 2 Protocol -// -GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gWinNtSerialIoComponentName2 = { - (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) WinNtSerialIoComponentNameGetDriverName, - (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) WinNtSerialIoComponentNameGetControllerName, - "en" -}; - - -GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mWinNtSerialIoDriverNameTable[] = { - { "eng;en", L"Windows Serial I/O Driver" }, - { NULL , NULL } -}; - -/** - Retrieves a Unicode string that is the user readable name of the driver. - - This function retrieves the user readable name of a driver in the form of a - Unicode string. If the driver specified by This has a user readable name in - the language specified by Language, then a pointer to the driver name is - returned in DriverName, and EFI_SUCCESS is returned. If the driver specified - by This does not support the language specified by Language, - then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified - in RFC 4646 or ISO 639-2 language code format. - - @param DriverName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - driver specified by This in the language - specified by Language. - - @retval EFI_SUCCESS The Unicode string for the Driver specified by - This and the language specified by Language was - returned in DriverName. - - @retval EFI_INVALID_PARAMETER Language is NULL. - - @retval EFI_INVALID_PARAMETER DriverName is NULL. - - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -WinNtSerialIoComponentNameGetDriverName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName - ) -{ - return LookupUnicodeString2 ( - Language, - This->SupportedLanguages, - mWinNtSerialIoDriverNameTable, - DriverName, - (BOOLEAN)(This == &gWinNtSerialIoComponentName) - ); -} - -/** - Retrieves a Unicode string that is the user readable name of the controller - that is being managed by a driver. - - This function retrieves the user readable name of the controller specified by - ControllerHandle and ChildHandle in the form of a Unicode string. If the - driver specified by This has a user readable name in the language specified by - Language, then a pointer to the controller name is returned in ControllerName, - and EFI_SUCCESS is returned. If the driver specified by This is not currently - managing the controller specified by ControllerHandle and ChildHandle, - then EFI_UNSUPPORTED is returned. If the driver specified by This does not - support the language specified by Language, then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - - @param ControllerHandle[in] The handle of a controller that the driver - specified by This is managing. This handle - specifies the controller whose name is to be - returned. - - @param ChildHandle[in] The handle of the child controller to retrieve - the name of. This is an optional parameter that - may be NULL. It will be NULL for device - drivers. It will also be NULL for a bus drivers - that wish to retrieve the name of the bus - controller. It will not be NULL for a bus - driver that wishes to retrieve the name of a - child controller. - - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified in - RFC 4646 or ISO 639-2 language code format. - - @param ControllerName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - controller specified by ControllerHandle and - ChildHandle in the language specified by - Language from the point of view of the driver - specified by This. - - @retval EFI_SUCCESS The Unicode string for the user readable name in - the language specified by Language for the - driver specified by This was returned in - DriverName. - - @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. - - @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid - EFI_HANDLE. - - @retval EFI_INVALID_PARAMETER Language is NULL. - - @retval EFI_INVALID_PARAMETER ControllerName is NULL. - - @retval EFI_UNSUPPORTED The driver specified by This is not currently - managing the controller specified by - ControllerHandle and ChildHandle. - - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -WinNtSerialIoComponentNameGetControllerName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName - ) -{ - EFI_STATUS Status; - EFI_SERIAL_IO_PROTOCOL *SerialIo; - WIN_NT_SERIAL_IO_PRIVATE_DATA *Private; - - // - // Make sure this driver is currently managing ControllHandle - // - Status = EfiTestManagedDevice ( - ControllerHandle, - gWinNtSerialIoDriverBinding.DriverBindingHandle, - &gEfiWinNtIoProtocolGuid - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // This is a bus driver, so ChildHandle must not be NULL. - // - if (ChildHandle == NULL) { - return EFI_UNSUPPORTED; - } - - Status = EfiTestChildHandle ( - ControllerHandle, - ChildHandle, - &gEfiWinNtIoProtocolGuid - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Get our context back - // - Status = gBS->OpenProtocol ( - ChildHandle, - &gEfiSerialIoProtocolGuid, - (VOID **) &SerialIo, - gWinNtSerialIoDriverBinding.DriverBindingHandle, - ChildHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - if (EFI_ERROR (Status)) { - return EFI_UNSUPPORTED; - } - - Private = WIN_NT_SERIAL_IO_PRIVATE_DATA_FROM_THIS (SerialIo); - - return LookupUnicodeString2 ( - Language, - This->SupportedLanguages, - Private->ControllerNameTable, - ControllerName, - (BOOLEAN)(This == &gWinNtSerialIoComponentName) - ); -} diff --git a/Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.c b/Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.c deleted file mode 100644 index 96167d5723..0000000000 --- a/Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.c +++ /dev/null @@ -1,1701 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - WinNtSerialIo.c - -Abstract: - - Our DriverBinding member functions operate on the handles - created by the NT Bus driver. - - Handle(1) - WinNtIo - DevicePath(1) - - If a serial port is added to the system this driver creates a new handle. - The new handle is required, since the serial device must add an UART device - pathnode. - - Handle(2) - SerialIo - DevicePath(1)\UART - - The driver then adds a gEfiWinNtSerialPortGuid as a protocol to Handle(1). - The instance data for this protocol is the private data used to create - Handle(2). - - Handle(1) - WinNtIo - DevicePath(1) - WinNtSerialPort - - If the driver is unloaded Handle(2) is removed from the system and - gEfiWinNtSerialPortGuid is removed from Handle(1). - - Note: Handle(1) is any handle created by the Win NT Bus driver that is passed - into the DriverBinding member functions of this driver. This driver requires - a Handle(1) to contain a WinNtIo protocol, a DevicePath protocol, and - the TypeGuid in the WinNtIo must be gEfiWinNtSerialPortGuid. - - If Handle(1) contains a gEfiWinNtSerialPortGuid protocol then the driver is - loaded on the device. - -**/ - -#include "WinNtSerialIo.h" - -EFI_DRIVER_BINDING_PROTOCOL gWinNtSerialIoDriverBinding = { - WinNtSerialIoDriverBindingSupported, - WinNtSerialIoDriverBindingStart, - WinNtSerialIoDriverBindingStop, - 0xa, - NULL, - NULL -}; - -// -// List of supported baud rate -// -UINT64 mBaudRateCurrentSupport[] = {50, 75, 110, 134, 150, 300, 600, 1200, 1800, 2000, 2400, 3600, 4800, 7200, 9600, 19200, 38400, 57600, 115200, SERIAL_PORT_MAX_BAUD_RATE + 1}; - -/** - Check the device path node whether it's the Flow Control node or not. - - @param[in] FlowControl The device path node to be checked. - - @retval TRUE It's the Flow Control node. - @retval FALSE It's not. - -**/ -BOOLEAN -IsUartFlowControlNode ( - IN UART_FLOW_CONTROL_DEVICE_PATH *FlowControl - ) -{ - return (BOOLEAN) ( - (DevicePathType (FlowControl) == MESSAGING_DEVICE_PATH) && - (DevicePathSubType (FlowControl) == MSG_VENDOR_DP) && - (CompareGuid (&FlowControl->Guid, &gEfiUartDevicePathGuid)) - ); -} - -/** - Check the device path node whether it contains Flow Control node or not. - - @param[in] DevicePath The device path to be checked. - - @retval TRUE It contains the Flow Control node. - @retval FALSE It doesn't. - -**/ -BOOLEAN -ContainsFlowControl ( - IN EFI_DEVICE_PATH_PROTOCOL *DevicePath - ) -{ - while (!IsDevicePathEnd (DevicePath)) { - if (IsUartFlowControlNode ((UART_FLOW_CONTROL_DEVICE_PATH *) DevicePath)) { - return TRUE; - } - DevicePath = NextDevicePathNode (DevicePath); - } - - return FALSE; -} - -/** - The user Entry Point for module WinNtSerialIo. The user code starts with this function. - - @param[in] ImageHandle The firmware allocated handle for the EFI image. - @param[in] SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS The entry point is executed successfully. - @retval other Some error occurs when executing this entry point. - -**/ -EFI_STATUS -EFIAPI -InitializeWinNtSerialIo( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - - // - // Install driver model protocol(s). - // - Status = EfiLibInstallDriverBindingComponentName2 ( - ImageHandle, - SystemTable, - &gWinNtSerialIoDriverBinding, - ImageHandle, - &gWinNtSerialIoComponentName, - &gWinNtSerialIoComponentName2 - ); - ASSERT_EFI_ERROR (Status); - - - return Status; -} - -EFI_STATUS -EFIAPI -WinNtSerialIoDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Handle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -/*++ - -Routine Description: - -Arguments: - -Returns: - - None - ---*/ -// TODO: This - add argument and description to function comment -// TODO: Handle - add argument and description to function comment -// TODO: RemainingDevicePath - add argument and description to function comment -// TODO: EFI_SUCCESS - add return value to function comment -// TODO: EFI_SUCCESS - add return value to function comment -{ - EFI_STATUS Status; - EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath; - EFI_WIN_NT_IO_PROTOCOL *WinNtIo; - UART_DEVICE_PATH *UartNode; - EFI_DEVICE_PATH_PROTOCOL *DevicePath; - UART_FLOW_CONTROL_DEVICE_PATH *FlowControlNode; - EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer; - UINTN EntryCount; - UINTN Index; - BOOLEAN RemainingDevicePathContainsFlowControl; - - // - // Check RemainingDevicePath validation - // - if (RemainingDevicePath != NULL) { - // - // Check if RemainingDevicePath is the End of Device Path Node, - // if yes, go on checking other conditions - // - if (!IsDevicePathEnd (RemainingDevicePath)) { - // - // If RemainingDevicePath isn't the End of Device Path Node, - // check its validation - // - Status = EFI_UNSUPPORTED; - - UartNode = (UART_DEVICE_PATH *) RemainingDevicePath; - if (UartNode->Header.Type != MESSAGING_DEVICE_PATH || - UartNode->Header.SubType != MSG_UART_DP || - DevicePathNodeLength((EFI_DEVICE_PATH_PROTOCOL *)UartNode) != sizeof(UART_DEVICE_PATH)) { - goto Error; - } - if ( UartNode->BaudRate > SERIAL_PORT_MAX_BAUD_RATE) { - goto Error; - } - if (UartNode->Parity < NoParity || UartNode->Parity > SpaceParity) { - goto Error; - } - if (UartNode->DataBits < 5 || UartNode->DataBits > 8) { - goto Error; - } - if (UartNode->StopBits < OneStopBit || UartNode->StopBits > TwoStopBits) { - goto Error; - } - if ((UartNode->DataBits == 5) && (UartNode->StopBits == TwoStopBits)) { - goto Error; - } - if ((UartNode->DataBits >= 6) && (UartNode->DataBits <= 8) && (UartNode->StopBits == OneFiveStopBits)) { - goto Error; - } - - FlowControlNode = (UART_FLOW_CONTROL_DEVICE_PATH *) NextDevicePathNode (UartNode); - if (IsUartFlowControlNode (FlowControlNode)) { - // - // If the second node is Flow Control Node, - // return error when it request other than hardware flow control. - // - if ((FlowControlNode->FlowControlMap & ~UART_FLOW_CONTROL_HARDWARE) != 0) { - goto Error; - } - } - } - } - - // - // Open the IO Abstraction(s) needed to perform the supported test - // - Status = gBS->OpenProtocol ( - Handle, - &gEfiWinNtIoProtocolGuid, - (VOID **) &WinNtIo, - This->DriverBindingHandle, - Handle, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - if (Status == EFI_ALREADY_STARTED) { - if (RemainingDevicePath == NULL || IsDevicePathEnd (RemainingDevicePath)) { - // - // If RemainingDevicePath is NULL or is the End of Device Path Node - // - return EFI_SUCCESS; - } - // - // When the driver has produced device path with flow control node but RemainingDevicePath only contains UART node, - // return unsupported, and vice versa. - // - Status = gBS->OpenProtocolInformation ( - Handle, - &gEfiWinNtIoProtocolGuid, - &OpenInfoBuffer, - &EntryCount - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // See if RemainingDevicePath has a Flow Control device path node - // - RemainingDevicePathContainsFlowControl = ContainsFlowControl (RemainingDevicePath); - - for (Index = 0; Index < EntryCount; Index++) { - if ((OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) { - Status = gBS->OpenProtocol ( - OpenInfoBuffer[Index].ControllerHandle, - &gEfiDevicePathProtocolGuid, - (VOID **) &DevicePath, - This->DriverBindingHandle, - Handle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - if (!EFI_ERROR (Status)) { - if (RemainingDevicePathContainsFlowControl ^ ContainsFlowControl (DevicePath)) { - Status = EFI_UNSUPPORTED; - } - } - break; - } - } - FreePool (OpenInfoBuffer); - return Status; - } - - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Close the I/O Abstraction(s) used to perform the supported test - // - gBS->CloseProtocol ( - Handle, - &gEfiWinNtIoProtocolGuid, - This->DriverBindingHandle, - Handle - ); - - // - // Open the EFI Device Path protocol needed to perform the supported test - // - Status = gBS->OpenProtocol ( - Handle, - &gEfiDevicePathProtocolGuid, - (VOID **) &ParentDevicePath, - This->DriverBindingHandle, - Handle, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - if (Status == EFI_ALREADY_STARTED) { - return EFI_SUCCESS; - } - - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Close protocol, don't use device path protocol in the Support() function - // - gBS->CloseProtocol ( - Handle, - &gEfiDevicePathProtocolGuid, - This->DriverBindingHandle, - Handle - ); - - // - // Make sure that the WinNt Thunk Protocol is valid - // - if (WinNtIo->WinNtThunk->Signature != EFI_WIN_NT_THUNK_PROTOCOL_SIGNATURE) { - Status = EFI_UNSUPPORTED; - goto Error; - } - - // - // Check the GUID to see if this is a handle type the driver supports - // - if (!CompareGuid (WinNtIo->TypeGuid, &gEfiWinNtSerialPortGuid)) { - Status = EFI_UNSUPPORTED; - goto Error; - } - - return EFI_SUCCESS; - -Error: - return Status; -} - -EFI_STATUS -EFIAPI -WinNtSerialIoDriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Handle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -/*++ - -Routine Description: - -Arguments: - -Returns: - - None - ---*/ -// TODO: This - add argument and description to function comment -// TODO: Handle - add argument and description to function comment -// TODO: RemainingDevicePath - add argument and description to function comment -// TODO: EFI_SUCCESS - add return value to function comment -// TODO: EFI_SUCCESS - add return value to function comment -{ - EFI_STATUS Status; - EFI_WIN_NT_IO_PROTOCOL *WinNtIo; - WIN_NT_SERIAL_IO_PRIVATE_DATA *Private; - HANDLE NtHandle; - UART_DEVICE_PATH UartNode; - EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath; - EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer; - UINTN EntryCount; - UINTN Index; - EFI_SERIAL_IO_PROTOCOL *SerialIo; - UART_DEVICE_PATH *Uart; - UINT32 FlowControlMap; - UART_FLOW_CONTROL_DEVICE_PATH *FlowControl; - EFI_DEVICE_PATH_PROTOCOL *TempDevicePath; - UINT32 Control; - - Private = NULL; - NtHandle = INVALID_HANDLE_VALUE; - - // - // Get the Parent Device Path - // - Status = gBS->OpenProtocol ( - Handle, - &gEfiDevicePathProtocolGuid, - (VOID **) &ParentDevicePath, - This->DriverBindingHandle, - Handle, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) { - return Status; - } - - // - // Grab the IO abstraction we need to get any work done - // - Status = gBS->OpenProtocol ( - Handle, - &gEfiWinNtIoProtocolGuid, - (VOID **) &WinNtIo, - This->DriverBindingHandle, - Handle, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) { - gBS->CloseProtocol ( - Handle, - &gEfiDevicePathProtocolGuid, - This->DriverBindingHandle, - Handle - ); - return Status; - } - - if (Status == EFI_ALREADY_STARTED) { - - if (RemainingDevicePath == NULL || IsDevicePathEnd (RemainingDevicePath)) { - // - // If RemainingDevicePath is NULL or is the End of Device Path Node - // - return EFI_SUCCESS; - } - - // - // Make sure a child handle does not already exist. This driver can only - // produce one child per serial port. - // - Status = gBS->OpenProtocolInformation ( - Handle, - &gEfiWinNtIoProtocolGuid, - &OpenInfoBuffer, - &EntryCount - ); - if (EFI_ERROR (Status)) { - return Status; - } - - Status = EFI_ALREADY_STARTED; - for (Index = 0; Index < EntryCount; Index++) { - if ((OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) { - Status = gBS->OpenProtocol ( - OpenInfoBuffer[Index].ControllerHandle, - &gEfiSerialIoProtocolGuid, - (VOID **) &SerialIo, - This->DriverBindingHandle, - Handle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - if (!EFI_ERROR (Status)) { - Uart = (UART_DEVICE_PATH *) RemainingDevicePath; - Status = SerialIo->SetAttributes ( - SerialIo, - Uart->BaudRate, - SerialIo->Mode->ReceiveFifoDepth, - SerialIo->Mode->Timeout, - (EFI_PARITY_TYPE) Uart->Parity, - Uart->DataBits, - (EFI_STOP_BITS_TYPE) Uart->StopBits - ); - FlowControl = (UART_FLOW_CONTROL_DEVICE_PATH *) NextDevicePathNode (Uart); - if (!EFI_ERROR (Status) && IsUartFlowControlNode (FlowControl)) { - Status = SerialIo->GetControl (SerialIo, &Control); - if (!EFI_ERROR (Status)) { - if (FlowControl->FlowControlMap == UART_FLOW_CONTROL_HARDWARE) { - Control |= EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE; - } else { - Control &= ~EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE; - } - // - // Clear the bits that are not allowed to pass to SetControl - // - Control &= (EFI_SERIAL_REQUEST_TO_SEND | EFI_SERIAL_DATA_TERMINAL_READY | - EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE | EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE | - EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE); - Status = SerialIo->SetControl (SerialIo, Control); - } - } - } - break; - } - } - - FreePool (OpenInfoBuffer); - return Status; - } - - FlowControl = NULL; - FlowControlMap = 0; - if (RemainingDevicePath == NULL) { - // - // Build the device path by appending the UART node to the ParentDevicePath - // from the WinNtIo handle. The Uart setings are zero here, since - // SetAttribute() will update them to match the default setings. - // - ZeroMem (&UartNode, sizeof (UART_DEVICE_PATH)); - UartNode.Header.Type = MESSAGING_DEVICE_PATH; - UartNode.Header.SubType = MSG_UART_DP; - SetDevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) &UartNode, sizeof (UART_DEVICE_PATH)); - - } else if (!IsDevicePathEnd (RemainingDevicePath)) { - // - // If RemainingDevicePath isn't the End of Device Path Node, - // only scan the specified device by RemainingDevicePath - // - // - // Match the configuration of the RemainingDevicePath. IsHandleSupported() - // already checked to make sure the RemainingDevicePath contains settings - // that we can support. - // - CopyMem (&UartNode, RemainingDevicePath, sizeof (UART_DEVICE_PATH)); - FlowControl = (UART_FLOW_CONTROL_DEVICE_PATH *) NextDevicePathNode (RemainingDevicePath); - if (IsUartFlowControlNode (FlowControl)) { - FlowControlMap = FlowControl->FlowControlMap; - } else { - FlowControl = NULL; - } - - } else { - // - // If RemainingDevicePath is the End of Device Path Node, - // skip enumerate any device and return EFI_SUCESSS - // - return EFI_SUCCESS; - } - - // - // Check to see if we can access the hardware device. If it's Open in NT we - // will not get access. - // - NtHandle = WinNtIo->WinNtThunk->CreateFile ( - WinNtIo->EnvString, - GENERIC_READ | GENERIC_WRITE, - 0, - NULL, - OPEN_EXISTING, - 0, - NULL - ); - if (NtHandle == INVALID_HANDLE_VALUE) { - Status = EFI_DEVICE_ERROR; - goto Error; - } - - // - // Construct Private data - // - Private = AllocatePool (sizeof (WIN_NT_SERIAL_IO_PRIVATE_DATA)); - if (Private == NULL) { - goto Error; - } - - // - // This signature must be valid before any member function is called - // - Private->Signature = WIN_NT_SERIAL_IO_PRIVATE_DATA_SIGNATURE; - Private->NtHandle = NtHandle; - Private->ControllerHandle = Handle; - Private->Handle = NULL; - Private->WinNtThunk = WinNtIo->WinNtThunk; - Private->ParentDevicePath = ParentDevicePath; - Private->ControllerNameTable = NULL; - - Private->SoftwareLoopbackEnable = FALSE; - Private->HardwareLoopbackEnable = FALSE; - Private->HardwareFlowControl = (BOOLEAN) (FlowControlMap == UART_FLOW_CONTROL_HARDWARE); - Private->Fifo.First = 0; - Private->Fifo.Last = 0; - Private->Fifo.Surplus = SERIAL_MAX_BUFFER_SIZE; - - CopyMem (&Private->UartDevicePath, &UartNode, sizeof (UART_DEVICE_PATH)); - - AddUnicodeString2 ( - "eng", - gWinNtSerialIoComponentName.SupportedLanguages, - &Private->ControllerNameTable, - WinNtIo->EnvString, - TRUE - ); - AddUnicodeString2 ( - "en", - gWinNtSerialIoComponentName2.SupportedLanguages, - &Private->ControllerNameTable, - WinNtIo->EnvString, - FALSE - ); - - - Private->SerialIo.Revision = SERIAL_IO_INTERFACE_REVISION; - Private->SerialIo.Reset = WinNtSerialIoReset; - Private->SerialIo.SetAttributes = WinNtSerialIoSetAttributes; - Private->SerialIo.SetControl = WinNtSerialIoSetControl; - Private->SerialIo.GetControl = WinNtSerialIoGetControl; - Private->SerialIo.Write = WinNtSerialIoWrite; - Private->SerialIo.Read = WinNtSerialIoRead; - Private->SerialIo.Mode = &Private->SerialIoMode; - - // - // Build the device path by appending the UART node to the ParentDevicePath - // from the WinNtIo handle. The Uart setings are zero here, since - // SetAttribute() will update them to match the current setings. - // - Private->DevicePath = AppendDevicePathNode ( - ParentDevicePath, - (EFI_DEVICE_PATH_PROTOCOL *) &Private->UartDevicePath - ); - // - // Only produce the FlowControl node when remaining device path has it - // - if (FlowControl != NULL) { - TempDevicePath = Private->DevicePath; - if (TempDevicePath != NULL) { - Private->DevicePath = AppendDevicePathNode ( - TempDevicePath, - (EFI_DEVICE_PATH_PROTOCOL *) FlowControl - ); - FreePool (TempDevicePath); - } - } - if (Private->DevicePath == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto Error; - } - - // - // Fill in Serial I/O Mode structure based on either the RemainingDevicePath or defaults. - // - Private->SerialIoMode.ControlMask = SERIAL_CONTROL_MASK; - Private->SerialIoMode.Timeout = SERIAL_TIMEOUT_DEFAULT; - Private->SerialIoMode.BaudRate = Private->UartDevicePath.BaudRate; - Private->SerialIoMode.ReceiveFifoDepth = SERIAL_FIFO_DEFAULT; - Private->SerialIoMode.DataBits = Private->UartDevicePath.DataBits; - Private->SerialIoMode.Parity = Private->UartDevicePath.Parity; - Private->SerialIoMode.StopBits = Private->UartDevicePath.StopBits; - - // - // Issue a reset to initialize the COM port - // - Status = Private->SerialIo.Reset (&Private->SerialIo); - if (EFI_ERROR (Status)) { - goto Error; - } - - // - // Create new child handle - // - Status = gBS->InstallMultipleProtocolInterfaces ( - &Private->Handle, - &gEfiSerialIoProtocolGuid, - &Private->SerialIo, - &gEfiDevicePathProtocolGuid, - Private->DevicePath, - NULL - ); - if (EFI_ERROR (Status)) { - goto Error; - } - - // - // Open For Child Device - // - Status = gBS->OpenProtocol ( - Handle, - &gEfiWinNtIoProtocolGuid, - (VOID **) &WinNtIo, - This->DriverBindingHandle, - Private->Handle, - EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER - ); - if (EFI_ERROR (Status)) { - goto Error; - } - - return EFI_SUCCESS; - -Error: - // - // Use the Stop() function to free all resources allocated in Start() - // - if (Private != NULL) { - if (Private->Handle != NULL) { - This->Stop (This, Handle, 1, &Private->Handle); - } else { - if (NtHandle != INVALID_HANDLE_VALUE) { - Private->WinNtThunk->CloseHandle (NtHandle); - } - - if (Private->DevicePath != NULL) { - FreePool (Private->DevicePath); - } - - FreeUnicodeStringTable (Private->ControllerNameTable); - - FreePool (Private); - } - } - - This->Stop (This, Handle, 0, NULL); - - return Status; -} - -EFI_STATUS -EFIAPI -WinNtSerialIoDriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Handle, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - This - TODO: add argument description - Handle - TODO: add argument description - NumberOfChildren - TODO: add argument description - ChildHandleBuffer - TODO: add argument description - -Returns: - - EFI_DEVICE_ERROR - TODO: Add description for return value - EFI_SUCCESS - TODO: Add description for return value - ---*/ -{ - EFI_STATUS Status; - UINTN Index; - BOOLEAN AllChildrenStopped; - EFI_SERIAL_IO_PROTOCOL *SerialIo; - WIN_NT_SERIAL_IO_PRIVATE_DATA *Private; - EFI_WIN_NT_IO_PROTOCOL *WinNtIo; - - // - // Complete all outstanding transactions to Controller. - // Don't allow any new transaction to Controller to be started. - // - - if (NumberOfChildren == 0) { - // - // Close the bus driver - // - Status = gBS->CloseProtocol ( - Handle, - &gEfiWinNtIoProtocolGuid, - This->DriverBindingHandle, - Handle - ); - Status = gBS->CloseProtocol ( - Handle, - &gEfiDevicePathProtocolGuid, - This->DriverBindingHandle, - Handle - ); - return Status; - } - - AllChildrenStopped = TRUE; - - for (Index = 0; Index < NumberOfChildren; Index++) { - Status = gBS->OpenProtocol ( - ChildHandleBuffer[Index], - &gEfiSerialIoProtocolGuid, - (VOID **) &SerialIo, - This->DriverBindingHandle, - Handle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - if (!EFI_ERROR (Status)) { - Private = WIN_NT_SERIAL_IO_PRIVATE_DATA_FROM_THIS (SerialIo); - - ASSERT (Private->Handle == ChildHandleBuffer[Index]); - - Status = gBS->CloseProtocol ( - Handle, - &gEfiWinNtIoProtocolGuid, - This->DriverBindingHandle, - ChildHandleBuffer[Index] - ); - - Status = gBS->UninstallMultipleProtocolInterfaces ( - ChildHandleBuffer[Index], - &gEfiSerialIoProtocolGuid, - &Private->SerialIo, - &gEfiDevicePathProtocolGuid, - Private->DevicePath, - NULL - ); - - if (EFI_ERROR (Status)) { - gBS->OpenProtocol ( - Handle, - &gEfiWinNtIoProtocolGuid, - (VOID **) &WinNtIo, - This->DriverBindingHandle, - ChildHandleBuffer[Index], - EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER - ); - } else { - Private->WinNtThunk->CloseHandle (Private->NtHandle); - - FreePool (Private->DevicePath); - - FreeUnicodeStringTable (Private->ControllerNameTable); - - FreePool (Private); - } - } - - if (EFI_ERROR (Status)) { - AllChildrenStopped = FALSE; - } - } - - if (!AllChildrenStopped) { - return EFI_DEVICE_ERROR; - } - - return EFI_SUCCESS; -} - -// -// Serial IO Protocol member functions -// - -EFI_STATUS -EFIAPI -WinNtSerialIoReset ( - IN EFI_SERIAL_IO_PROTOCOL *This - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - This - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -{ - WIN_NT_SERIAL_IO_PRIVATE_DATA *Private; - EFI_TPL Tpl; - - Tpl = gBS->RaiseTPL (TPL_NOTIFY); - - Private = WIN_NT_SERIAL_IO_PRIVATE_DATA_FROM_THIS (This); - - Private->WinNtThunk->PurgeComm ( - Private->NtHandle, - PURGE_TXCLEAR | PURGE_RXCLEAR - ); - - gBS->RestoreTPL (Tpl); - - return This->SetAttributes ( - This, - This->Mode->BaudRate, - This->Mode->ReceiveFifoDepth, - This->Mode->Timeout, - (EFI_PARITY_TYPE)This->Mode->Parity, - (UINT8) This->Mode->DataBits, - (EFI_STOP_BITS_TYPE)This->Mode->StopBits - ); -} - -EFI_STATUS -EFIAPI -WinNtSerialIoSetAttributes ( - IN EFI_SERIAL_IO_PROTOCOL *This, - IN UINT64 BaudRate, - IN UINT32 ReceiveFifoDepth, - IN UINT32 Timeout, - IN EFI_PARITY_TYPE Parity, - IN UINT8 DataBits, - IN EFI_STOP_BITS_TYPE StopBits - ) -/*++ - -Routine Description: - - This function is used to set the attributes. - -Arguments: - - This - A pointer to the EFI_SERIAL_IO_PROTOCOL structrue. - BaudRate - The Baud rate of the serial device. - ReceiveFifoDepth - The request depth of fifo on receive side. - Timeout - the request timeout for a single charact. - Parity - The type of parity used in serial device. - DataBits - Number of deata bits used in serial device. - StopBits - Number of stop bits used in serial device. - -Returns: - Status code - - None - ---*/ -// TODO: EFI_SUCCESS - add return value to function comment -// TODO: EFI_DEVICE_ERROR - add return value to function comment -// TODO: EFI_DEVICE_ERROR - add return value to function comment -// TODO: EFI_DEVICE_ERROR - add return value to function comment -// TODO: EFI_SUCCESS - add return value to function comment -// TODO: EFI_DEVICE_ERROR - add return value to function comment -// TODO: EFI_SUCCESS - add return value to function comment -{ - EFI_STATUS Status; - UINTN Index; - WIN_NT_SERIAL_IO_PRIVATE_DATA *Private; - COMMTIMEOUTS PortTimeOuts; - DWORD ConvertedTime; - BOOL Result; - UART_DEVICE_PATH *Uart; - EFI_TPL Tpl; - - Private = WIN_NT_SERIAL_IO_PRIVATE_DATA_FROM_THIS (This); - - // - // Some of our arguments have defaults if a null value is passed in, and - // we must set the default values if a null argument is passed in. - // - if (BaudRate == 0) { - BaudRate = PcdGet64 (PcdUartDefaultBaudRate); - } - - if (ReceiveFifoDepth == 0) { - ReceiveFifoDepth = SERIAL_FIFO_DEFAULT; - } - - if (Timeout == 0) { - Timeout = SERIAL_TIMEOUT_DEFAULT; - } - - if (Parity == DefaultParity) { - Parity = (EFI_PARITY_TYPE) (PcdGet8 (PcdUartDefaultParity)); - } - - if (DataBits == 0) { - DataBits = PcdGet8 (PcdUartDefaultDataBits); - } - - if (StopBits == DefaultStopBits) { - StopBits = (EFI_STOP_BITS_TYPE) PcdGet8 (PcdUartDefaultStopBits); - } - - // - // Make sure all parameters are valid - // - if ((BaudRate > SERIAL_PORT_MAX_BAUD_RATE) || (BaudRate < SERIAL_PORT_MIN_BAUD_RATE)) { - return EFI_INVALID_PARAMETER; - } - - // - //The lower baud rate supported by the serial device will be selected without exceeding the unsupported BaudRate parameter - // - - for (Index = 1; Index < (ARRAY_SIZE (mBaudRateCurrentSupport)); Index++) { - if (BaudRate < mBaudRateCurrentSupport[Index]) { - BaudRate = mBaudRateCurrentSupport[Index-1]; - break; - } - } - - if ((ReceiveFifoDepth < 1) || (ReceiveFifoDepth > SERIAL_PORT_MAX_RECEIVE_FIFO_DEPTH)) { - return EFI_INVALID_PARAMETER; - } - - if ((Timeout < SERIAL_PORT_MIN_TIMEOUT) || (Timeout > SERIAL_PORT_MAX_TIMEOUT)) { - return EFI_INVALID_PARAMETER; - } - - if ((Parity < NoParity) || (Parity > SpaceParity)) { - return EFI_INVALID_PARAMETER; - } - - if ((StopBits < OneStopBit) || (StopBits > TwoStopBits)) { - return EFI_INVALID_PARAMETER; - } - - // - // Now we only support DataBits=7,8. - // - if ((DataBits < 7) || (DataBits > 8)) { - return EFI_INVALID_PARAMETER; - } - - // - // Now we only support DataBits=7,8. - // for DataBits = 6,7,8, StopBits can not set OneFiveStopBits. - // - if (StopBits == OneFiveStopBits) { - return EFI_INVALID_PARAMETER; - } - - // - // See if the new attributes already match the current attributes - // - if (Private->UartDevicePath.BaudRate == BaudRate && - Private->UartDevicePath.DataBits == DataBits && - Private->UartDevicePath.Parity == Parity && - Private->UartDevicePath.StopBits == StopBits && - Private->SerialIoMode.ReceiveFifoDepth == ReceiveFifoDepth && - Private->SerialIoMode.Timeout == Timeout ) { - return EFI_SUCCESS; - } - - Tpl = gBS->RaiseTPL (TPL_NOTIFY); - - // - // Get current values from NT - // - ZeroMem (&Private->NtDCB, sizeof (DCB)); - Private->NtDCB.DCBlength = sizeof (DCB); - - if (!Private->WinNtThunk->GetCommState (Private->NtHandle, &Private->NtDCB)) { - Private->NtError = Private->WinNtThunk->GetLastError (); - DEBUG ((EFI_D_ERROR, "SerialSetAttributes: GetCommState %d\n", Private->NtError)); - gBS->RestoreTPL (Tpl); - return EFI_DEVICE_ERROR; - } - - // - // Map EFI com setting to NT - // - Private->NtDCB.BaudRate = ConvertBaud2Nt (BaudRate); - Private->NtDCB.ByteSize = ConvertData2Nt (DataBits); - Private->NtDCB.Parity = ConvertParity2Nt (Parity); - Private->NtDCB.StopBits = ConvertStop2Nt (StopBits); - - Private->NtDCB.fBinary = TRUE; - Private->NtDCB.fParity = Private->NtDCB.Parity == NOPARITY ? FALSE : TRUE; - Private->NtDCB.fOutxCtsFlow = FALSE; - Private->NtDCB.fOutxDsrFlow = FALSE; - Private->NtDCB.fDtrControl = DTR_CONTROL_ENABLE; - Private->NtDCB.fDsrSensitivity = FALSE; - Private->NtDCB.fOutX = FALSE; - Private->NtDCB.fInX = FALSE; - Private->NtDCB.fRtsControl = RTS_CONTROL_ENABLE; - Private->NtDCB.fNull = FALSE; - - // - // Set new values - // - Result = Private->WinNtThunk->SetCommState (Private->NtHandle, &Private->NtDCB); - if (!Result) { - Private->NtError = Private->WinNtThunk->GetLastError (); - DEBUG ((EFI_D_ERROR, "SerialSetAttributes: SetCommState %d\n", Private->NtError)); - gBS->RestoreTPL (Tpl); - return EFI_DEVICE_ERROR; - } - - // - // Set com port read/write timeout values - // - ConvertedTime = ConvertTime2Nt (Timeout); - PortTimeOuts.ReadIntervalTimeout = MAXDWORD; - PortTimeOuts.ReadTotalTimeoutMultiplier = 0; - PortTimeOuts.ReadTotalTimeoutConstant = ConvertedTime; - PortTimeOuts.WriteTotalTimeoutMultiplier = ConvertedTime == 0 ? 1 : ConvertedTime; - PortTimeOuts.WriteTotalTimeoutConstant = 0; - - if (!Private->WinNtThunk->SetCommTimeouts (Private->NtHandle, &PortTimeOuts)) { - Private->NtError = Private->WinNtThunk->GetLastError (); - DEBUG ((EFI_D_ERROR, "SerialSetAttributes: SetCommTimeouts %d\n", Private->NtError)); - gBS->RestoreTPL (Tpl); - return EFI_DEVICE_ERROR; - } - - // - // Update mode - // - Private->SerialIoMode.BaudRate = BaudRate; - Private->SerialIoMode.ReceiveFifoDepth = ReceiveFifoDepth; - Private->SerialIoMode.Timeout = Timeout; - Private->SerialIoMode.Parity = Parity; - Private->SerialIoMode.DataBits = DataBits; - Private->SerialIoMode.StopBits = StopBits; - - // - // See if Device Path Node has actually changed - // - if (Private->UartDevicePath.BaudRate == BaudRate && - Private->UartDevicePath.DataBits == DataBits && - Private->UartDevicePath.Parity == Parity && - Private->UartDevicePath.StopBits == StopBits ) { - gBS->RestoreTPL(Tpl); - return EFI_SUCCESS; - } - - // - // Update the device path - // - Private->UartDevicePath.BaudRate = BaudRate; - Private->UartDevicePath.DataBits = DataBits; - Private->UartDevicePath.Parity = (UINT8) Parity; - Private->UartDevicePath.StopBits = (UINT8) StopBits; - - Status = EFI_SUCCESS; - if (Private->Handle != NULL) { - Uart = (UART_DEVICE_PATH *) ( - (UINTN) Private->DevicePath - + GetDevicePathSize (Private->ParentDevicePath) - - END_DEVICE_PATH_LENGTH - ); - CopyMem (Uart, &Private->UartDevicePath, sizeof (UART_DEVICE_PATH)); - Status = gBS->ReinstallProtocolInterface ( - Private->Handle, - &gEfiDevicePathProtocolGuid, - Private->DevicePath, - Private->DevicePath - ); - } - - gBS->RestoreTPL (Tpl); - - return Status; -} - -EFI_STATUS -EFIAPI -WinNtSerialIoSetControl ( - IN EFI_SERIAL_IO_PROTOCOL *This, - IN UINT32 Control - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - This - TODO: add argument description - Control - TODO: add argument description - -Returns: - - EFI_DEVICE_ERROR - TODO: Add description for return value - EFI_DEVICE_ERROR - TODO: Add description for return value - EFI_SUCCESS - TODO: Add description for return value - ---*/ -{ - WIN_NT_SERIAL_IO_PRIVATE_DATA *Private; - BOOL Result; - DCB Dcb; - EFI_TPL Tpl; - UART_FLOW_CONTROL_DEVICE_PATH *FlowControl; - EFI_STATUS Status; - - // - // first determine the parameter is invalid - // - if (Control & (~(EFI_SERIAL_REQUEST_TO_SEND | EFI_SERIAL_DATA_TERMINAL_READY | - EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE | EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE | - EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE))) { - return EFI_UNSUPPORTED; - } - - Tpl = gBS->RaiseTPL (TPL_NOTIFY); - - Private = WIN_NT_SERIAL_IO_PRIVATE_DATA_FROM_THIS (This); - - Result = Private->WinNtThunk->GetCommState (Private->NtHandle, &Dcb); - - if (!Result) { - Private->NtError = Private->WinNtThunk->GetLastError (); - DEBUG ((EFI_D_ERROR, "SerialSetControl: GetCommState %d\n", Private->NtError)); - gBS->RestoreTPL (Tpl); - return EFI_DEVICE_ERROR; - } - - Dcb.fRtsControl = RTS_CONTROL_DISABLE; - Dcb.fDtrControl = DTR_CONTROL_DISABLE; - Private->HardwareFlowControl = FALSE; - Private->SoftwareLoopbackEnable = FALSE; - Private->HardwareLoopbackEnable = FALSE; - - if (Control & EFI_SERIAL_REQUEST_TO_SEND) { - Dcb.fRtsControl = RTS_CONTROL_ENABLE; - } - - if (Control & EFI_SERIAL_DATA_TERMINAL_READY) { - Dcb.fDtrControl = DTR_CONTROL_ENABLE; - } - - if (Control & EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE) { - Private->HardwareFlowControl = TRUE; - } - - if (Control & EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE) { - Private->SoftwareLoopbackEnable = TRUE; - } - - if (Control & EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE) { - Private->HardwareLoopbackEnable = TRUE; - } - - Result = Private->WinNtThunk->SetCommState ( - Private->NtHandle, - &Dcb - ); - - if (!Result) { - Private->NtError = Private->WinNtThunk->GetLastError (); - DEBUG ((EFI_D_ERROR, "SerialSetControl: SetCommState %d\n", Private->NtError)); - gBS->RestoreTPL (Tpl); - return EFI_DEVICE_ERROR; - } - - Status = EFI_SUCCESS; - if (Private->Handle != NULL) { - FlowControl = (UART_FLOW_CONTROL_DEVICE_PATH *) ( - (UINTN) Private->DevicePath - + GetDevicePathSize (Private->ParentDevicePath) - - END_DEVICE_PATH_LENGTH - + sizeof (UART_DEVICE_PATH) - ); - if (IsUartFlowControlNode (FlowControl) && - ((FlowControl->FlowControlMap == UART_FLOW_CONTROL_HARDWARE) ^ Private->HardwareFlowControl)) { - // - // Flow Control setting is changed, need to reinstall device path protocol - // - FlowControl->FlowControlMap = Private->HardwareFlowControl ? UART_FLOW_CONTROL_HARDWARE : 0; - Status = gBS->ReinstallProtocolInterface ( - Private->Handle, - &gEfiDevicePathProtocolGuid, - Private->DevicePath, - Private->DevicePath - ); - } - } - - gBS->RestoreTPL (Tpl); - - return Status; -} - -EFI_STATUS -EFIAPI -WinNtSerialIoGetControl ( - IN EFI_SERIAL_IO_PROTOCOL *This, - OUT UINT32 *Control - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - This - TODO: add argument description - Control - TODO: add argument description - -Returns: - - EFI_DEVICE_ERROR - TODO: Add description for return value - EFI_DEVICE_ERROR - TODO: Add description for return value - EFI_DEVICE_ERROR - TODO: Add description for return value - EFI_SUCCESS - TODO: Add description for return value - ---*/ -{ - WIN_NT_SERIAL_IO_PRIVATE_DATA *Private; - DWORD ModemStatus; - DWORD Errors; - UINT32 Bits; - DCB Dcb; - EFI_TPL Tpl; - - Tpl = gBS->RaiseTPL (TPL_NOTIFY); - - Private = WIN_NT_SERIAL_IO_PRIVATE_DATA_FROM_THIS (This); - - // - // Get modem status - // - if (!Private->WinNtThunk->GetCommModemStatus (Private->NtHandle, &ModemStatus)) { - Private->NtError = Private->WinNtThunk->GetLastError (); - gBS->RestoreTPL (Tpl); - return EFI_DEVICE_ERROR; - } - - Bits = 0; - if (ModemStatus & MS_CTS_ON) { - Bits |= EFI_SERIAL_CLEAR_TO_SEND; - } - - if (ModemStatus & MS_DSR_ON) { - Bits |= EFI_SERIAL_DATA_SET_READY; - } - - if (ModemStatus & MS_RING_ON) { - Bits |= EFI_SERIAL_RING_INDICATE; - } - - if (ModemStatus & MS_RLSD_ON) { - Bits |= EFI_SERIAL_CARRIER_DETECT; - } - - // - // Get ctrl status - // - if (!Private->WinNtThunk->GetCommState (Private->NtHandle, &Dcb)) { - Private->NtError = Private->WinNtThunk->GetLastError (); - DEBUG ((EFI_D_ERROR, "SerialGetControl: GetCommState %d\n", Private->NtError)); - gBS->RestoreTPL (Tpl); - return EFI_DEVICE_ERROR; - } - - if (Dcb.fDtrControl == DTR_CONTROL_ENABLE) { - Bits |= EFI_SERIAL_DATA_TERMINAL_READY; - } - - if (Dcb.fRtsControl == RTS_CONTROL_ENABLE) { - Bits |= EFI_SERIAL_REQUEST_TO_SEND; - } - - if (Private->HardwareFlowControl) { - Bits |= EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE; - } - - if (Private->SoftwareLoopbackEnable) { - Bits |= EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE; - } - - if (Private->HardwareLoopbackEnable) { - Bits |= EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE; - } - - // - // Get input buffer status - // - if (!Private->WinNtThunk->ClearCommError (Private->NtHandle, &Errors, &Private->NtComStatus)) { - Private->NtError = Private->WinNtThunk->GetLastError (); - DEBUG ((EFI_D_ERROR, "SerialGetControl: ClearCommError %d\n", Private->NtError)); - gBS->RestoreTPL (Tpl); - return EFI_DEVICE_ERROR; - } - - if (Private->NtComStatus.cbInQue == 0) { - Bits |= EFI_SERIAL_INPUT_BUFFER_EMPTY; - } - - *Control = Bits; - - gBS->RestoreTPL (Tpl); - - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -WinNtSerialIoWrite ( - IN EFI_SERIAL_IO_PROTOCOL *This, - IN OUT UINTN *BufferSize, - IN VOID *Buffer - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - This - TODO: add argument description - BufferSize - TODO: add argument description - Buffer - TODO: add argument description - -Returns: - - EFI_DEVICE_ERROR - TODO: Add description for return value - EFI_SUCCESS - TODO: Add description for return value - ---*/ -{ - WIN_NT_SERIAL_IO_PRIVATE_DATA *Private; - UINT8 *ByteBuffer; - UINTN TotalBytesWritten; - DWORD BytesToGo; - DWORD BytesWritten; - BOOL Result; - UINT32 Index; - UINT32 Control; - EFI_TPL Tpl; - - Tpl = gBS->RaiseTPL (TPL_NOTIFY); - - Private = WIN_NT_SERIAL_IO_PRIVATE_DATA_FROM_THIS (This); - - ByteBuffer = (UINT8 *) Buffer; - TotalBytesWritten = 0; - - if (Private->SoftwareLoopbackEnable || Private->HardwareLoopbackEnable) { - for (Index = 0; Index < *BufferSize; Index++) { - if (IsaSerialFifoAdd (&Private->Fifo, ByteBuffer[Index]) == EFI_SUCCESS) { - TotalBytesWritten++; - } else { - break; - } - } - } else { - BytesToGo = (DWORD) (*BufferSize); - - do { - if (Private->HardwareFlowControl) { - // - // Send RTS - // - WinNtSerialIoGetControl (&Private->SerialIo, &Control); - Control |= EFI_SERIAL_REQUEST_TO_SEND; - WinNtSerialIoSetControl (&Private->SerialIo, Control); - } - - // - // Do the write - // - Result = Private->WinNtThunk->WriteFile ( - Private->NtHandle, - &ByteBuffer[TotalBytesWritten], - BytesToGo, - &BytesWritten, - NULL - ); - - if (Private->HardwareFlowControl) { - // - // Assert RTS - // - WinNtSerialIoGetControl (&Private->SerialIo, &Control); - Control &= ~ (UINT32) EFI_SERIAL_REQUEST_TO_SEND; - WinNtSerialIoSetControl (&Private->SerialIo, Control); - } - - TotalBytesWritten += BytesWritten; - BytesToGo -= BytesWritten; - if (!Result) { - Private->NtError = Private->WinNtThunk->GetLastError (); - DEBUG ((EFI_D_ERROR, "SerialWrite: FileWrite %d\n", Private->NtError)); - *BufferSize = TotalBytesWritten; - gBS->RestoreTPL (Tpl); - return EFI_DEVICE_ERROR; - } - } while (BytesToGo > 0); - } - - *BufferSize = TotalBytesWritten; - - gBS->RestoreTPL (Tpl); - - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -WinNtSerialIoRead ( - IN EFI_SERIAL_IO_PROTOCOL *This, - IN OUT UINTN *BufferSize, - OUT VOID *Buffer - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - This - TODO: add argument description - BufferSize - TODO: add argument description - Buffer - TODO: add argument description - -Returns: - - EFI_DEVICE_ERROR - TODO: Add description for return value - ---*/ -{ - WIN_NT_SERIAL_IO_PRIVATE_DATA *Private; - BOOL Result; - DWORD BytesRead; - EFI_STATUS Status; - UINT32 Index; - UINT8 Data; - UINT32 Control; - EFI_TPL Tpl; - - Tpl = gBS->RaiseTPL (TPL_NOTIFY); - - Private = WIN_NT_SERIAL_IO_PRIVATE_DATA_FROM_THIS (This); - - // - // Do the read - // - if (Private->SoftwareLoopbackEnable || Private->HardwareLoopbackEnable) { - for (Index = 0, BytesRead = 0; Index < *BufferSize; Index++) { - if (IsaSerialFifoRemove (&Private->Fifo, &Data) == EFI_SUCCESS) { - ((UINT8 *) Buffer)[Index] = Data; - BytesRead++; - } else { - break; - } - } - } else { - if (Private->HardwareFlowControl) { - WinNtSerialIoGetControl (&Private->SerialIo, &Control); - Control |= EFI_SERIAL_DATA_TERMINAL_READY; - WinNtSerialIoSetControl (&Private->SerialIo, Control); - } - - Result = Private->WinNtThunk->ReadFile ( - Private->NtHandle, - Buffer, - (DWORD) *BufferSize, - &BytesRead, - NULL - ); - - if (Private->HardwareFlowControl) { - WinNtSerialIoGetControl (&Private->SerialIo, &Control); - Control &= ~ (UINT32) EFI_SERIAL_DATA_TERMINAL_READY; - WinNtSerialIoSetControl (&Private->SerialIo, Control); - } - - if (!Result) { - Private->NtError = Private->WinNtThunk->GetLastError (); - gBS->RestoreTPL (Tpl); - return EFI_DEVICE_ERROR; - } - } - - if (BytesRead != *BufferSize) { - Status = EFI_TIMEOUT; - } else { - Status = EFI_SUCCESS; - } - - *BufferSize = (UINTN) BytesRead; - - gBS->RestoreTPL (Tpl); - - return Status; -} - -BOOLEAN -IsaSerialFifoFull ( - IN SERIAL_DEV_FIFO *Fifo - ) -/*++ - - Routine Description: - Detect whether specific FIFO is full or not - - Arguments: - Fifo SERIAL_DEV_FIFO *: A pointer to the Data Structure SERIAL_DEV_FIFO - - Returns: - TRUE: the FIFO is full - FALSE: the FIFO is not full - ---*/ -{ - if (Fifo->Surplus == 0) { - return TRUE; - } - - return FALSE; -} - -BOOLEAN -IsaSerialFifoEmpty ( - IN SERIAL_DEV_FIFO *Fifo - ) -/*++ - - Routine Description: - Detect whether specific FIFO is empty or not - - Arguments: - Fifo SERIAL_DEV_FIFO *: A pointer to the Data Structure SERIAL_DEV_FIFO - - Returns: - TRUE: the FIFO is empty - FALSE: the FIFO is not empty - ---*/ -{ - if (Fifo->Surplus == SERIAL_MAX_BUFFER_SIZE) { - return TRUE; - } - - return FALSE; -} - -EFI_STATUS -IsaSerialFifoAdd ( - IN SERIAL_DEV_FIFO *Fifo, - IN UINT8 Data - ) -/*++ - - Routine Description: - Add data to specific FIFO - - Arguments: - Fifo SERIAL_DEV_FIFO *: A pointer to the Data Structure SERIAL_DEV_FIFO - Data UINT8: the data added to FIFO - - Returns: - EFI_SUCCESS: Add data to specific FIFO successfully - EFI_OUT_RESOURCE: Failed to add data because FIFO is already full - ---*/ -// TODO: EFI_OUT_OF_RESOURCES - add return value to function comment -{ - // - // if FIFO full can not add data - // - if (IsaSerialFifoFull (Fifo)) { - return EFI_OUT_OF_RESOURCES; - } - - // - // FIFO is not full can add data - // - Fifo->Data[Fifo->Last] = Data; - Fifo->Surplus--; - Fifo->Last++; - if (Fifo->Last >= SERIAL_MAX_BUFFER_SIZE) { - Fifo->Last = 0; - } - - return EFI_SUCCESS; -} - -EFI_STATUS -IsaSerialFifoRemove ( - IN SERIAL_DEV_FIFO *Fifo, - OUT UINT8 *Data - ) -/*++ - - Routine Description: - Remove data from specific FIFO - - Arguments: - Fifo SERIAL_DEV_FIFO *: A pointer to the Data Structure SERIAL_DEV_FIFO - Data UINT8*: the data removed from FIFO - - Returns: - EFI_SUCCESS: Remove data from specific FIFO successfully - EFI_OUT_RESOURCE: Failed to remove data because FIFO is empty - ---*/ -// TODO: EFI_OUT_OF_RESOURCES - add return value to function comment -{ - // - // if FIFO is empty, no data can remove - // - if (IsaSerialFifoEmpty (Fifo)) { - return EFI_OUT_OF_RESOURCES; - } - - // - // FIFO is not empty, can remove data - // - *Data = Fifo->Data[Fifo->First]; - Fifo->Surplus++; - Fifo->First++; - if (Fifo->First >= SERIAL_MAX_BUFFER_SIZE) { - Fifo->First = 0; - } - - return EFI_SUCCESS; -} diff --git a/Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.h b/Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.h deleted file mode 100644 index 2dc91d8d06..0000000000 --- a/Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.h +++ /dev/null @@ -1,533 +0,0 @@ -/**@file - -Copyright (c) 2006, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - WinNtSerialIo.h - -Abstract: - - -**/ - -#ifndef _WIN_NT_SERIAL_IO_ -#define _WIN_NT_SERIAL_IO_ - -// -// The package level header files this module uses -// -#include -#include -// -// The protocols, PPI and GUID defintions for this module -// -#include -#include -#include -#include -#include -// -// The Library classes this module consumes -// -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#define SERIAL_MAX_BUFFER_SIZE 256 -#define TIMEOUT_STALL_INTERVAL 10 - -typedef struct { - UINT32 First; - UINT32 Last; - UINT32 Surplus; - UINT8 Data[SERIAL_MAX_BUFFER_SIZE]; -} SERIAL_DEV_FIFO; - -#define WIN_NT_SERIAL_IO_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('N', 'T', 's', 'i') -typedef struct { - UINT64 Signature; - - // - // Protocol data for the new handle we are going to add - // - EFI_HANDLE Handle; - EFI_SERIAL_IO_PROTOCOL SerialIo; - EFI_SERIAL_IO_MODE SerialIoMode; - EFI_DEVICE_PATH_PROTOCOL *DevicePath; - - // - // Private Data - // - EFI_HANDLE ControllerHandle; - EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath; - UART_DEVICE_PATH UartDevicePath; - EFI_WIN_NT_THUNK_PROTOCOL *WinNtThunk; - - EFI_UNICODE_STRING_TABLE *ControllerNameTable; - - // - // Private NT type Data; - // - HANDLE NtHandle; - DCB NtDCB; - DWORD NtError; - COMSTAT NtComStatus; - - BOOLEAN SoftwareLoopbackEnable; - BOOLEAN HardwareFlowControl; - BOOLEAN HardwareLoopbackEnable; - - SERIAL_DEV_FIFO Fifo; - -} WIN_NT_SERIAL_IO_PRIVATE_DATA; - -#define WIN_NT_SERIAL_IO_PRIVATE_DATA_FROM_THIS(a) \ - CR(a, WIN_NT_SERIAL_IO_PRIVATE_DATA, SerialIo, WIN_NT_SERIAL_IO_PRIVATE_DATA_SIGNATURE) - -// -// Global Protocol Variables -// -extern EFI_DRIVER_BINDING_PROTOCOL gWinNtSerialIoDriverBinding; -extern EFI_COMPONENT_NAME_PROTOCOL gWinNtSerialIoComponentName; -extern EFI_COMPONENT_NAME2_PROTOCOL gWinNtSerialIoComponentName2; - -// -// Macros to convert EFI serial types to NT serial types. -// - -// -// one second -// -#define SERIAL_TIMEOUT_DEFAULT (1000 * 1000) -#define SERIAL_BAUD_DEFAULT 115200 -#define SERIAL_FIFO_DEFAULT 14 -#define SERIAL_DATABITS_DEFAULT 8 -#define SERIAL_PARITY_DEFAULT DefaultParity -#define SERIAL_STOPBITS_DEFAULT DefaultStopBits - -#define SERIAL_CONTROL_MASK (EFI_SERIAL_CLEAR_TO_SEND | \ - EFI_SERIAL_DATA_SET_READY | \ - EFI_SERIAL_RING_INDICATE | \ - EFI_SERIAL_CARRIER_DETECT | \ - EFI_SERIAL_REQUEST_TO_SEND | \ - EFI_SERIAL_DATA_TERMINAL_READY | \ - EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE | \ - EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE | \ - EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE | \ - EFI_SERIAL_INPUT_BUFFER_EMPTY) - -#define ConvertBaud2Nt(x) (DWORD) x -#define ConvertData2Nt(x) (BYTE) x - -#define ConvertParity2Nt(x) \ - (BYTE) ( \ - x == DefaultParity ? NOPARITY : \ - x == NoParity ? NOPARITY : \ - x == EvenParity ? EVENPARITY : \ - x == OddParity ? ODDPARITY : \ - x == MarkParity ? MARKPARITY : \ - x == SpaceParity ? SPACEPARITY : 0 \ - ) - -#define ConvertStop2Nt(x) \ - (BYTE) ( \ - x == DefaultParity ? ONESTOPBIT : \ - x == OneFiveStopBits ? ONE5STOPBITS : \ - x == TwoStopBits ? TWOSTOPBITS : 0 \ - ) - -#define ConvertTime2Nt(x) ((x) / 1000) - -// -// 115400 baud with rounding errors -// -#define SERIAL_PORT_MAX_BAUD_RATE 115400 - -#define SERIAL_PORT_MIN_BAUD_RATE 50 -#define SERIAL_PORT_MAX_RECEIVE_FIFO_DEPTH 16 - -#define SERIAL_PORT_MIN_TIMEOUT 1 // 1 uS -#define SERIAL_PORT_MAX_TIMEOUT 100000000 // 100 seconds - -// -// Function Prototypes -// -EFI_STATUS -EFIAPI -InitializeWinNtSerialIo ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - ImageHandle - TODO: add argument description - SystemTable - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -EFIAPI -WinNtSerialIoDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Handle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - This - TODO: add argument description - Handle - TODO: add argument description - RemainingDevicePath - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -EFIAPI -WinNtSerialIoDriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Handle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - This - TODO: add argument description - Handle - TODO: add argument description - RemainingDevicePath - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -EFIAPI -WinNtSerialIoDriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Handle, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - This - TODO: add argument description - Handle - TODO: add argument description - NumberOfChildren - TODO: add argument description - ChildHandleBuffer - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -EFIAPI -WinNtSerialIoReset ( - IN EFI_SERIAL_IO_PROTOCOL *This - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - This - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -EFIAPI -WinNtSerialIoSetAttributes ( - IN EFI_SERIAL_IO_PROTOCOL *This, - IN UINT64 BaudRate, - IN UINT32 ReceiveFifoDepth, - IN UINT32 Timeout, - IN EFI_PARITY_TYPE Parity, - IN UINT8 DataBits, - IN EFI_STOP_BITS_TYPE StopBits - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - This - TODO: add argument description - BaudRate - TODO: add argument description - ReceiveFifoDepth - TODO: add argument description - Timeout - TODO: add argument description - Parity - TODO: add argument description - DataBits - TODO: add argument description - StopBits - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -EFIAPI -WinNtSerialIoSetControl ( - IN EFI_SERIAL_IO_PROTOCOL *This, - IN UINT32 Control - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - This - TODO: add argument description - Control - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -EFIAPI -WinNtSerialIoGetControl ( - IN EFI_SERIAL_IO_PROTOCOL *This, - OUT UINT32 *Control - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - This - TODO: add argument description - Control - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -EFIAPI -WinNtSerialIoWrite ( - IN EFI_SERIAL_IO_PROTOCOL *This, - IN OUT UINTN *BufferSize, - IN VOID *Buffer - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - This - TODO: add argument description - BufferSize - TODO: add argument description - Buffer - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -EFIAPI -WinNtSerialIoRead ( - IN EFI_SERIAL_IO_PROTOCOL *This, - IN OUT UINTN *BufferSize, - OUT VOID *Buffer - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - This - TODO: add argument description - BufferSize - TODO: add argument description - Buffer - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -BOOLEAN -IsaSerialFifoFull ( - IN SERIAL_DEV_FIFO *Fifo - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - Fifo - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -BOOLEAN -IsaSerialFifoEmpty ( - IN SERIAL_DEV_FIFO *Fifo - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - Fifo - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -IsaSerialFifoAdd ( - IN SERIAL_DEV_FIFO *Fifo, - IN UINT8 Data - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - Fifo - TODO: add argument description - Data - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -IsaSerialFifoRemove ( - IN SERIAL_DEV_FIFO *Fifo, - OUT UINT8 *Data - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - Fifo - TODO: add argument description - Data - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -EFI_STATUS -IsaSerialReceiveTransmit ( - WIN_NT_SERIAL_IO_PRIVATE_DATA *Private - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - Private - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -; - -#endif diff --git a/Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIoDxe.inf b/Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIoDxe.inf deleted file mode 100644 index 812cf78c9c..0000000000 --- a/Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIoDxe.inf +++ /dev/null @@ -1,63 +0,0 @@ -## @file -# Serial I/O driver -# -# Our DriverBinding member functions operate on the handles -# created by the NT Bus drive -# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
-# -# SPDX-License-Identifier: BSD-2-Clause-Patent -# -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = WinNtSerialIoDxe - FILE_GUID = 6B41B553-A649-11d4-BD02-0080C73C8881 - MODULE_TYPE = UEFI_DRIVER - VERSION_STRING = 1.0 - ENTRY_POINT = InitializeWinNtSerialIo - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 -# -# DRIVER_BINDING = gWinNtSerialIoDriverBinding -# COMPONENT_NAME = gWinNtSerialIoComponentName -# - -[Sources] - ComponentName.c - WinNtSerialIo.c - WinNtSerialIo.h - -[Packages] - MdePkg/MdePkg.dec - Nt32Pkg/Nt32Pkg.dec - -[LibraryClasses] - MemoryAllocationLib - DevicePathLib - UefiBootServicesTableLib - BaseMemoryLib - UefiLib - UefiDriverEntryPoint - BaseLib - DebugLib - -[Guids] - gEfiWinNtSerialPortGuid # ALWAYS_CONSUMED - gEfiUartDevicePathGuid - -[Protocols] - gEfiSerialIoProtocolGuid # PROTOCOL BY_START - gEfiDevicePathProtocolGuid # PROTOCOL TO_START - gEfiWinNtIoProtocolGuid # PROTOCOL TO_START - -[Pcd] - gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200 - gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits|8 - gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity|1 - gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits|1 - diff --git a/Nt32Pkg/WinNtSimpleFileSystemDxe/ComponentName.c b/Nt32Pkg/WinNtSimpleFileSystemDxe/ComponentName.c deleted file mode 100644 index 3dc115e82f..0000000000 --- a/Nt32Pkg/WinNtSimpleFileSystemDxe/ComponentName.c +++ /dev/null @@ -1,381 +0,0 @@ -/**@file - -Copyright (c) 2006, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - ComponentName.c - -Abstract: - -**/ -// -// The package level header files this module uses -// -#include -#include -// -// The protocols, PPI and GUID defintions for this module -// -#include -#include -#include -#include -#include -#include -#include -// -// The Library classes this module consumes -// -#include -#include -#include -#include -#include -#include -#include - -#include "WinNtSimpleFileSystem.h" - -// -// EFI Component Name Functions -// -/** - Retrieves a Unicode string that is the user readable name of the driver. - - This function retrieves the user readable name of a driver in the form of a - Unicode string. If the driver specified by This has a user readable name in - the language specified by Language, then a pointer to the driver name is - returned in DriverName, and EFI_SUCCESS is returned. If the driver specified - by This does not support the language specified by Language, - then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified - in RFC 4646 or ISO 639-2 language code format. - - @param DriverName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - driver specified by This in the language - specified by Language. - - @retval EFI_SUCCESS The Unicode string for the Driver specified by - This and the language specified by Language was - returned in DriverName. - - @retval EFI_INVALID_PARAMETER Language is NULL. - - @retval EFI_INVALID_PARAMETER DriverName is NULL. - - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -WinNtSimpleFileSystemComponentNameGetDriverName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName - ); - - -/** - Retrieves a Unicode string that is the user readable name of the controller - that is being managed by a driver. - - This function retrieves the user readable name of the controller specified by - ControllerHandle and ChildHandle in the form of a Unicode string. If the - driver specified by This has a user readable name in the language specified by - Language, then a pointer to the controller name is returned in ControllerName, - and EFI_SUCCESS is returned. If the driver specified by This is not currently - managing the controller specified by ControllerHandle and ChildHandle, - then EFI_UNSUPPORTED is returned. If the driver specified by This does not - support the language specified by Language, then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - - @param ControllerHandle[in] The handle of a controller that the driver - specified by This is managing. This handle - specifies the controller whose name is to be - returned. - - @param ChildHandle[in] The handle of the child controller to retrieve - the name of. This is an optional parameter that - may be NULL. It will be NULL for device - drivers. It will also be NULL for a bus drivers - that wish to retrieve the name of the bus - controller. It will not be NULL for a bus - driver that wishes to retrieve the name of a - child controller. - - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified in - RFC 4646 or ISO 639-2 language code format. - - @param ControllerName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - controller specified by ControllerHandle and - ChildHandle in the language specified by - Language from the point of view of the driver - specified by This. - - @retval EFI_SUCCESS The Unicode string for the user readable name in - the language specified by Language for the - driver specified by This was returned in - DriverName. - - @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. - - @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid - EFI_HANDLE. - - @retval EFI_INVALID_PARAMETER Language is NULL. - - @retval EFI_INVALID_PARAMETER ControllerName is NULL. - - @retval EFI_UNSUPPORTED The driver specified by This is not currently - managing the controller specified by - ControllerHandle and ChildHandle. - - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -WinNtSimpleFileSystemComponentNameGetControllerName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName - ); - - -// -// EFI Component Name Protocol -// -GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gWinNtSimpleFileSystemComponentName = { - WinNtSimpleFileSystemComponentNameGetDriverName, - WinNtSimpleFileSystemComponentNameGetControllerName, - "eng" -}; - -// -// EFI Component Name 2 Protocol -// -GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gWinNtSimpleFileSystemComponentName2 = { - (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) WinNtSimpleFileSystemComponentNameGetDriverName, - (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) WinNtSimpleFileSystemComponentNameGetControllerName, - "en" -}; - - -GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mWinNtSimpleFileSystemDriverNameTable[] = { - { - "eng;en", - L"Windows Simple File System Driver" - }, - { - NULL, - NULL - } -}; - -/** - Retrieves a Unicode string that is the user readable name of the driver. - - This function retrieves the user readable name of a driver in the form of a - Unicode string. If the driver specified by This has a user readable name in - the language specified by Language, then a pointer to the driver name is - returned in DriverName, and EFI_SUCCESS is returned. If the driver specified - by This does not support the language specified by Language, - then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified - in RFC 4646 or ISO 639-2 language code format. - - @param DriverName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - driver specified by This in the language - specified by Language. - - @retval EFI_SUCCESS The Unicode string for the Driver specified by - This and the language specified by Language was - returned in DriverName. - - @retval EFI_INVALID_PARAMETER Language is NULL. - - @retval EFI_INVALID_PARAMETER DriverName is NULL. - - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -WinNtSimpleFileSystemComponentNameGetDriverName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName - ) -{ - return LookupUnicodeString2 ( - Language, - This->SupportedLanguages, - mWinNtSimpleFileSystemDriverNameTable, - DriverName, - (BOOLEAN)(This == &gWinNtSimpleFileSystemComponentName) - ); -} - -/** - Retrieves a Unicode string that is the user readable name of the controller - that is being managed by a driver. - - This function retrieves the user readable name of the controller specified by - ControllerHandle and ChildHandle in the form of a Unicode string. If the - driver specified by This has a user readable name in the language specified by - Language, then a pointer to the controller name is returned in ControllerName, - and EFI_SUCCESS is returned. If the driver specified by This is not currently - managing the controller specified by ControllerHandle and ChildHandle, - then EFI_UNSUPPORTED is returned. If the driver specified by This does not - support the language specified by Language, then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - - @param ControllerHandle[in] The handle of a controller that the driver - specified by This is managing. This handle - specifies the controller whose name is to be - returned. - - @param ChildHandle[in] The handle of the child controller to retrieve - the name of. This is an optional parameter that - may be NULL. It will be NULL for device - drivers. It will also be NULL for a bus drivers - that wish to retrieve the name of the bus - controller. It will not be NULL for a bus - driver that wishes to retrieve the name of a - child controller. - - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified in - RFC 4646 or ISO 639-2 language code format. - - @param ControllerName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - controller specified by ControllerHandle and - ChildHandle in the language specified by - Language from the point of view of the driver - specified by This. - - @retval EFI_SUCCESS The Unicode string for the user readable name in - the language specified by Language for the - driver specified by This was returned in - DriverName. - - @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. - - @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid - EFI_HANDLE. - - @retval EFI_INVALID_PARAMETER Language is NULL. - - @retval EFI_INVALID_PARAMETER ControllerName is NULL. - - @retval EFI_UNSUPPORTED The driver specified by This is not currently - managing the controller specified by - ControllerHandle and ChildHandle. - - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -WinNtSimpleFileSystemComponentNameGetControllerName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName - ) -{ - EFI_STATUS Status; - EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem; - WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE *Private; - - // - // This is a device driver, so ChildHandle must be NULL. - // - if (ChildHandle != NULL) { - return EFI_UNSUPPORTED; - } - - // - // Make sure this driver is currently managing ControllerHandle - // - Status = EfiTestManagedDevice ( - ControllerHandle, - gWinNtSimpleFileSystemDriverBinding.DriverBindingHandle, - &gEfiWinNtIoProtocolGuid - ); - if (EFI_ERROR (Status)) { - return EFI_UNSUPPORTED; - } - // - // Get our context back - // - Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiSimpleFileSystemProtocolGuid, - (VOID **) &SimpleFileSystem, - gWinNtSimpleFileSystemDriverBinding.DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - if (EFI_ERROR (Status)) { - return EFI_UNSUPPORTED; - } - - Private = WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (SimpleFileSystem); - - return LookupUnicodeString2 ( - Language, - This->SupportedLanguages, - Private->ControllerNameTable, - ControllerName, - (BOOLEAN)(This == &gWinNtSimpleFileSystemComponentName) - ); -} diff --git a/Nt32Pkg/WinNtSimpleFileSystemDxe/WinNtSimpleFileSystem.c b/Nt32Pkg/WinNtSimpleFileSystemDxe/WinNtSimpleFileSystem.c deleted file mode 100644 index f13f82eee2..0000000000 --- a/Nt32Pkg/WinNtSimpleFileSystemDxe/WinNtSimpleFileSystem.c +++ /dev/null @@ -1,2928 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - WinNtSimpleFileSystem.c - -Abstract: - - Produce Simple File System abstractions for directories on your PC using Win32 APIs. - The configuration of what devices to mount or emulate comes from NT - environment variables. The variables must be visible to the Microsoft* - Developer Studio for them to work. - - * Other names and brands may be claimed as the property of others. - -**/ - -// -// The package level header files this module uses -// -#include -#include -// -// The protocols, PPI and GUID defintions for this module -// -#include -#include -#include -#include -#include -#include -#include -// -// The Library classes this module consumes -// -#include -#include -#include -#include -#include -#include -#include - -#include "WinNtSimpleFileSystem.h" - -EFI_DRIVER_BINDING_PROTOCOL gWinNtSimpleFileSystemDriverBinding = { - WinNtSimpleFileSystemDriverBindingSupported, - WinNtSimpleFileSystemDriverBindingStart, - WinNtSimpleFileSystemDriverBindingStop, - 0xa, - NULL, - NULL -}; - -/** - The user Entry Point for module WinNtSimpleFileSystem. The user code starts with this function. - - @param[in] ImageHandle The firmware allocated handle for the EFI image. - @param[in] SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS The entry point is executed successfully. - @retval other Some error occurs when executing this entry point. - -**/ -EFI_STATUS -EFIAPI -InitializeWinNtSimpleFileSystem( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - - // - // Install driver model protocol(s). - // - Status = EfiLibInstallDriverBindingComponentName2 ( - ImageHandle, - SystemTable, - &gWinNtSimpleFileSystemDriverBinding, - ImageHandle, - &gWinNtSimpleFileSystemComponentName, - &gWinNtSimpleFileSystemComponentName2 - ); - ASSERT_EFI_ERROR (Status); - - - return Status; -} - -CHAR16 * -EfiStrChr ( - IN CHAR16 *Str, - IN CHAR16 Chr - ) -/*++ - -Routine Description: - - Locate the first occurance of a character in a string. - -Arguments: - - Str - Pointer to NULL terminated unicode string. - Chr - Character to locate. - -Returns: - - If Str is NULL, then NULL is returned. - If Chr is not contained in Str, then NULL is returned. - If Chr is contained in Str, then a pointer to the first occurance of Chr in Str is returned. - ---*/ -{ - if (Str == NULL) { - return Str; - } - - while (*Str != '\0' && *Str != Chr) { - ++Str; - } - - return (*Str == Chr) ? Str : NULL; -} - -BOOLEAN -IsZero ( - IN VOID *Buffer, - IN UINTN Length - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - Buffer - TODO: add argument description - Length - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -{ - if (Buffer == NULL || Length == 0) { - return FALSE; - } - - if (*(UINT8 *) Buffer != 0) { - return FALSE; - } - - if (Length > 1) { - if (!CompareMem (Buffer, (UINT8 *) Buffer + 1, Length - 1)) { - return FALSE; - } - } - - return TRUE; -} - -VOID -CutPrefix ( - IN CHAR16 *Str, - IN UINTN Count - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - Str - TODO: add argument description - Count - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -{ - CHAR16 *Pointer; - - if (StrLen (Str) < Count) { - ASSERT (0); - } - - if (Count != 0) { - for (Pointer = Str; *(Pointer + Count); Pointer++) { - *Pointer = *(Pointer + Count); - } - *Pointer = *(Pointer + Count); - } -} - - - -EFI_STATUS -EFIAPI -WinNtSimpleFileSystemDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -/*++ - -Routine Description: - - Check to see if the driver supports a given controller. - -Arguments: - - This - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL. - - ControllerHandle - EFI handle of the controller to test. - - RemainingDevicePath - Pointer to remaining portion of a device path. - -Returns: - - EFI_SUCCESS - The device specified by ControllerHandle and RemainingDevicePath is supported by the driver - specified by This. - - EFI_ALREADY_STARTED - The device specified by ControllerHandle and RemainingDevicePath is already being managed by - the driver specified by This. - - EFI_ACCESS_DENIED - The device specified by ControllerHandle and RemainingDevicePath is already being managed by - a different driver or an application that requires exclusive access. - - EFI_UNSUPPORTED - The device specified by ControllerHandle and RemainingDevicePath is not supported by the - driver specified by This. - ---*/ -{ - EFI_STATUS Status; - EFI_WIN_NT_IO_PROTOCOL *WinNtIo; - - // - // Open the IO Abstraction(s) needed to perform the supported test - // - Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiWinNtIoProtocolGuid, - (VOID **) &WinNtIo, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Make sure GUID is for a File System handle. - // - Status = EFI_UNSUPPORTED; - if (CompareGuid (WinNtIo->TypeGuid, &gEfiWinNtFileSystemGuid)) { - Status = EFI_SUCCESS; - } - - // - // Close the I/O Abstraction(s) used to perform the supported test - // - gBS->CloseProtocol ( - ControllerHandle, - &gEfiWinNtIoProtocolGuid, - This->DriverBindingHandle, - ControllerHandle - ); - - return Status; -} - -EFI_STATUS -EFIAPI -WinNtSimpleFileSystemDriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -/*++ - -Routine Description: - - Starts a device controller or a bus controller. - -Arguments: - - This - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL. - - ControllerHandle - EFI handle of the controller to start. - - RemainingDevicePath - Pointer to remaining portion of a device path. - -Returns: - - EFI_SUCCESS - The device or bus controller has been started. - - EFI_DEVICE_ERROR - The device could not be started due to a device failure. - - EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources. - ---*/ -{ - EFI_STATUS Status; - EFI_WIN_NT_IO_PROTOCOL *WinNtIo; - WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE *Private; - - Private = NULL; - - // - // Open the IO Abstraction(s) needed - // - Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiWinNtIoProtocolGuid, - (VOID **) &WinNtIo, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Validate GUID - // - if (!CompareGuid (WinNtIo->TypeGuid, &gEfiWinNtFileSystemGuid)) { - Status = EFI_UNSUPPORTED; - goto Done; - } - - Private = AllocatePool (sizeof (WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE)); - if (Private == NULL) { - Status = EFI_OUT_OF_RESOURCES; - - goto Done; - } - - Private->Signature = WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE; - Private->WinNtThunk = WinNtIo->WinNtThunk; - - Private->FilePath = WinNtIo->EnvString; - - Private->VolumeLabel = AllocatePool (StrSize (L"EFI_EMULATED")); - if (Private->VolumeLabel == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto Done; - } - - StrCpy (Private->VolumeLabel, L"EFI_EMULATED"); - - Private->SimpleFileSystem.Revision = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION; - Private->SimpleFileSystem.OpenVolume = WinNtSimpleFileSystemOpenVolume; - - Private->WinNtThunk->SetErrorMode (SEM_FAILCRITICALERRORS); - - Private->ControllerNameTable = NULL; - - AddUnicodeString2 ( - "eng", - gWinNtSimpleFileSystemComponentName.SupportedLanguages, - &Private->ControllerNameTable, - WinNtIo->EnvString, - TRUE - ); - AddUnicodeString2 ( - "en", - gWinNtSimpleFileSystemComponentName2.SupportedLanguages, - &Private->ControllerNameTable, - WinNtIo->EnvString, - FALSE - ); - - - Status = gBS->InstallMultipleProtocolInterfaces ( - &ControllerHandle, - &gEfiSimpleFileSystemProtocolGuid, - &Private->SimpleFileSystem, - NULL - ); - -Done: - if (EFI_ERROR (Status)) { - - if (Private != NULL) { - - FreeUnicodeStringTable (Private->ControllerNameTable); - - FreePool (Private); - } - - gBS->CloseProtocol ( - ControllerHandle, - &gEfiWinNtIoProtocolGuid, - This->DriverBindingHandle, - ControllerHandle - ); - } - - return Status; -} - -EFI_STATUS -EFIAPI -WinNtSimpleFileSystemDriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - This - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL. - - ControllerHandle - A handle to the device to be stopped. - - NumberOfChildren - The number of child device handles in ChildHandleBuffer. - - ChildHandleBuffer - An array of child device handles to be freed. - -Returns: - - EFI_SUCCESS - The device has been stopped. - - EFI_DEVICE_ERROR - The device could not be stopped due to a device failure. - ---*/ -// TODO: EFI_UNSUPPORTED - add return value to function comment -{ - EFI_STATUS Status; - EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem; - WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE *Private; - - // - // Get our context back - // - Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiSimpleFileSystemProtocolGuid, - (VOID **) &SimpleFileSystem, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - if (EFI_ERROR (Status)) { - return EFI_UNSUPPORTED; - } - - Private = WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (SimpleFileSystem); - - // - // Uninstall the Simple File System Protocol from ControllerHandle - // - Status = gBS->UninstallMultipleProtocolInterfaces ( - ControllerHandle, - &gEfiSimpleFileSystemProtocolGuid, - &Private->SimpleFileSystem, - NULL - ); - if (!EFI_ERROR (Status)) { - Status = gBS->CloseProtocol ( - ControllerHandle, - &gEfiWinNtIoProtocolGuid, - This->DriverBindingHandle, - ControllerHandle - ); - } - - if (!EFI_ERROR (Status)) { - // - // Free our instance data - // - FreeUnicodeStringTable (Private->ControllerNameTable); - - FreePool (Private); - } - - return Status; -} - -EFI_STATUS -EFIAPI -WinNtSimpleFileSystemOpenVolume ( - IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This, - OUT EFI_FILE_PROTOCOL **Root - ) -/*++ - -Routine Description: - - Open the root directory on a volume. - -Arguments: - - This - A pointer to the volume to open. - - Root - A pointer to storage for the returned opened file handle of the root directory. - -Returns: - - EFI_SUCCESS - The volume was opened. - - EFI_UNSUPPORTED - The volume does not support the requested file system type. - - EFI_NO_MEDIA - The device has no media. - - EFI_DEVICE_ERROR - The device reported an error. - - EFI_VOLUME_CORRUPTED - The file system structures are corrupted. - - EFI_ACCESS_DENIED - The service denied access to the file. - - EFI_OUT_OF_RESOURCES - The file volume could not be opened due to lack of resources. - - EFI_MEDIA_CHANGED - The device has new media or the media is no longer supported. - ---*/ -// TODO: EFI_INVALID_PARAMETER - add return value to function comment -{ - EFI_STATUS Status; - WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE *Private; - WIN_NT_EFI_FILE_PRIVATE *PrivateFile; - EFI_TPL OldTpl; - CHAR16 *TempFileName; - UINTN Size; - - if (This == NULL || Root == NULL) { - return EFI_INVALID_PARAMETER; - } - - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - - Private = WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (This); - - PrivateFile = AllocatePool (sizeof (WIN_NT_EFI_FILE_PRIVATE)); - if (PrivateFile == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto Done; - } - - PrivateFile->FileName = AllocatePool (StrSize (Private->FilePath)); - if (PrivateFile->FileName == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto Done; - } - - PrivateFile->FilePath = AllocatePool (StrSize (Private->FilePath)); - if (PrivateFile->FilePath == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto Done; - } - - StrCpy (PrivateFile->FilePath, Private->FilePath); - StrCpy (PrivateFile->FileName, PrivateFile->FilePath); - PrivateFile->Signature = WIN_NT_EFI_FILE_PRIVATE_SIGNATURE; - PrivateFile->WinNtThunk = Private->WinNtThunk; - PrivateFile->SimpleFileSystem = This; - PrivateFile->IsRootDirectory = TRUE; - PrivateFile->IsDirectoryPath = TRUE; - PrivateFile->IsOpenedByRead = TRUE; - PrivateFile->EfiFile.Revision = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION; - PrivateFile->EfiFile.Open = WinNtSimpleFileSystemOpen; - PrivateFile->EfiFile.Close = WinNtSimpleFileSystemClose; - PrivateFile->EfiFile.Delete = WinNtSimpleFileSystemDelete; - PrivateFile->EfiFile.Read = WinNtSimpleFileSystemRead; - PrivateFile->EfiFile.Write = WinNtSimpleFileSystemWrite; - PrivateFile->EfiFile.GetPosition = WinNtSimpleFileSystemGetPosition; - PrivateFile->EfiFile.SetPosition = WinNtSimpleFileSystemSetPosition; - PrivateFile->EfiFile.GetInfo = WinNtSimpleFileSystemGetInfo; - PrivateFile->EfiFile.SetInfo = WinNtSimpleFileSystemSetInfo; - PrivateFile->EfiFile.Flush = WinNtSimpleFileSystemFlush; - PrivateFile->IsValidFindBuf = FALSE; - - // - // Set DirHandle - // - PrivateFile->DirHandle = PrivateFile->WinNtThunk->CreateFile ( - PrivateFile->FilePath, - GENERIC_READ, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - FILE_FLAG_BACKUP_SEMANTICS, - NULL - ); - - if (PrivateFile->DirHandle == INVALID_HANDLE_VALUE) { - Status = EFI_NOT_FOUND; - goto Done; - } - - // - // Find the first file under it - // - Size = StrSize (PrivateFile->FilePath); - Size += StrSize (L"\\*"); - Status = gBS->AllocatePool ( - EfiBootServicesData, - Size, - (VOID **)&TempFileName - ); - if (EFI_ERROR (Status)) { - goto Done; - } - StrCpy (TempFileName, PrivateFile->FilePath); - StrCat (TempFileName, L"\\*"); - - PrivateFile->LHandle = PrivateFile->WinNtThunk->FindFirstFile (TempFileName, &PrivateFile->FindBuf); - FreePool (TempFileName); - - if (PrivateFile->LHandle == INVALID_HANDLE_VALUE) { - PrivateFile->IsValidFindBuf = FALSE; - } else { - PrivateFile->IsValidFindBuf = TRUE; - } - *Root = &PrivateFile->EfiFile; - - Status = EFI_SUCCESS; - -Done: - if (EFI_ERROR (Status)) { - if (PrivateFile) { - if (PrivateFile->FileName) { - FreePool (PrivateFile->FileName); - } - - if (PrivateFile->FilePath) { - FreePool (PrivateFile->FilePath); - } - - FreePool (PrivateFile); - } - } - - gBS->RestoreTPL (OldTpl); - - return Status; -} - -/** - Count the number of Leading Dot in FileNameToken. - - @param FileNameToken A string representing a token in the path name. - - @return UINTN The number of leading dot in the name. - -**/ -UINTN -CountLeadingDots ( - IN CONST CHAR16 * FileNameToken - ) -{ - UINTN Num; - - Num = 0; - while (*FileNameToken == L'.') { - Num++; - FileNameToken++; - } - - return Num; -} - -BOOLEAN -IsFileNameTokenValid ( - IN CONST CHAR16 * FileNameToken - ) -{ - UINTN Num; - if (StrStr (FileNameToken, L"/") != NULL) { - // - // No L'/' in file name. - // - return FALSE; - } else { - // - // If Token has all dot, the number should not exceed 2 - // - Num = CountLeadingDots (FileNameToken); - - if (Num == StrLen (FileNameToken)) { - // - // If the FileNameToken only contains a number of L'.'. - // - if (Num > 2) { - return FALSE; - } - } - } - - return TRUE; -} - -/** - Return the first string token found in the indirect pointer a String named by FileName. - - On input, FileName is a indirect pointer pointing to a String. - On output, FileName is a updated to point to the next character after the first - found L"\" or NULL if there is no L"\" found. - - @param FileName A indirect pointer pointing to a FileName. - - @return Token The first string token found before a L"\". - -**/ -CHAR16 * -GetNextFileNameToken ( - IN OUT CONST CHAR16 ** FileName - ) -{ - CHAR16 *SlashPos; - CHAR16 *Token; - UINTN Offset; - ASSERT (**FileName != L'\\'); - ASSERT (**FileName != L'\0'); - - SlashPos = StrStr (*FileName, L"\\"); - if (SlashPos == NULL) { - Token = AllocateCopyPool (StrSize(*FileName), *FileName); - *FileName = NULL; - } else { - Offset = SlashPos - *FileName; - Token = AllocateZeroPool ((Offset + 1) * sizeof (CHAR16)); - StrnCpy (Token, *FileName, Offset); - // - // Point *FileName to the next character after L'\'. - // - *FileName = *FileName + Offset + 1; - // - // If *FileName is an empty string, then set *FileName to NULL - // - if (**FileName == L'\0') { - *FileName = NULL; - } - } - - return Token; -} - -/** - Check if a FileName contains only Valid Characters. - - If FileName contains only a single L'\', return TRUE. - If FileName contains two adjacent L'\', return FALSE. - If FileName conatins L'/' , return FALSE. - If FielName contains more than two dots seperated with other FileName characters - by L'\', return FALSE. For example, L'.\...\filename.txt' is invalid path name. But L'..TwoDots\filename.txt' is valid path name. - - @param FileName The File Name String to check. - - @return TRUE FileName only contains valid characters. - @return FALSE FileName contains at least one invalid character. - -**/ - -BOOLEAN -IsFileNameValid ( - IN CONST CHAR16 *FileName - ) -{ - CHAR16 *Token; - BOOLEAN Valid; - - // - // If FileName is just L'\', then it is a valid pathname. - // - if (StrCmp (FileName, L"\\") == 0) { - return TRUE; - } - // - // We don't support two or more adjacent L'\'. - // - if (StrStr (FileName, L"\\\\") != NULL) { - return FALSE; - } - - // - // Is FileName has a leading L"\", skip to next character. - // - if (FileName [0] == L'\\') { - FileName++; - } - - do { - Token = GetNextFileNameToken (&FileName); - Valid = IsFileNameTokenValid (Token); - FreePool (Token); - - if (!Valid) - return FALSE; - } while (FileName != NULL); - - return TRUE; -} - -EFI_STATUS -EFIAPI -WinNtSimpleFileSystemOpen ( - IN EFI_FILE_PROTOCOL *This, - OUT EFI_FILE_PROTOCOL **NewHandle, - IN CHAR16 *FileName, - IN UINT64 OpenMode, - IN UINT64 Attributes - ) -/*++ - -Routine Description: - - Open a file relative to the source file location. - -Arguments: - - This - A pointer to the source file location. - - NewHandle - Pointer to storage for the new file handle. - - FileName - Pointer to the file name to be opened. - - OpenMode - File open mode information. - - Attributes - File creation attributes. - -Returns: - - EFI_SUCCESS - The file was opened. - - EFI_NOT_FOUND - The file could not be found in the volume. - - EFI_NO_MEDIA - The device has no media. - - EFI_MEDIA_CHANGED - The device has new media or the media is no longer supported. - - EFI_DEVICE_ERROR - The device reported an error. - - EFI_VOLUME_CORRUPTED - The file system structures are corrupted. - - EFI_WRITE_PROTECTED - The volume or file is write protected. - - EFI_ACCESS_DENIED - The service denied access to the file. - - EFI_OUT_OF_RESOURCES - Not enough resources were available to open the file. - - EFI_VOLUME_FULL - There is not enough space left to create the new file. - ---*/ -// TODO: EFI_INVALID_PARAMETER - add return value to function comment -// TODO: EFI_INVALID_PARAMETER - add return value to function comment -// TODO: EFI_INVALID_PARAMETER - add return value to function comment -// TODO: EFI_INVALID_PARAMETER - add return value to function comment -{ - WIN_NT_EFI_FILE_PRIVATE *PrivateFile; - WIN_NT_EFI_FILE_PRIVATE *NewPrivateFile; - WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE *PrivateRoot; - EFI_STATUS Status; - CHAR16 *RealFileName; - CHAR16 *TempFileName; - CHAR16 *ParseFileName; - CHAR16 *GuardPointer; - CHAR16 TempChar; - DWORD LastError; - UINTN Count; - BOOLEAN LoopFinish; - UINTN InfoSize; - EFI_FILE_INFO *Info; - UINTN Size; - - // - // Check for obvious invalid parameters. - // - if (This == NULL || NewHandle == NULL || FileName == NULL) { - return EFI_INVALID_PARAMETER; - } - - switch (OpenMode) { - case EFI_FILE_MODE_CREATE | EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE: - if (Attributes &~EFI_FILE_VALID_ATTR) { - return EFI_INVALID_PARAMETER; - } - - if (Attributes & EFI_FILE_READ_ONLY) { - return EFI_INVALID_PARAMETER; - } - - // - // fall through - // - case EFI_FILE_MODE_READ: - case EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE: - break; - - default: - return EFI_INVALID_PARAMETER; - } - - // - // Init local variables - // - PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This); - PrivateRoot = WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (PrivateFile->SimpleFileSystem); - NewPrivateFile = NULL; - - // - // Allocate buffer for FileName as the passed in FileName may be read only - // - TempFileName = AllocatePool (StrSize (FileName)); - if (TempFileName == NULL) { - return EFI_OUT_OF_RESOURCES; - } - StrCpy (TempFileName, FileName); - FileName = TempFileName; - - if (FileName[StrLen (FileName) - 1] == L'\\') { - FileName[StrLen (FileName) - 1] = 0; - } - - // - // If file name does not equal to "." or ".." and not trailed with "\..", - // then we trim the leading/trailing blanks and trailing dots - // - if (StrCmp (FileName, L".") != 0 && StrCmp (FileName, L"..") != 0 && - ((StrLen (FileName) >= 3) ? (StrCmp (&FileName[StrLen (FileName) - 3], L"\\..") != 0) : TRUE)) { - // - // Trim leading blanks - // - Count = 0; - for (TempFileName = FileName; - *TempFileName != 0 && *TempFileName == L' '; - TempFileName++) { - Count++; - } - CutPrefix (FileName, Count); - // - // Trim trailing blanks - // - for (TempFileName = FileName + StrLen (FileName) - 1; - TempFileName >= FileName && (*TempFileName == L' '); - TempFileName--) { - ; - } - *(TempFileName + 1) = 0; - } - - // - // Attempt to open the file - // - NewPrivateFile = AllocatePool (sizeof (WIN_NT_EFI_FILE_PRIVATE)); - if (NewPrivateFile == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto Done; - } - - CopyMem (NewPrivateFile, PrivateFile, sizeof (WIN_NT_EFI_FILE_PRIVATE)); - - NewPrivateFile->FilePath = AllocatePool (StrSize (PrivateFile->FileName)); - if (NewPrivateFile->FilePath == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto Done; - } - - if (PrivateFile->IsDirectoryPath) { - StrCpy (NewPrivateFile->FilePath, PrivateFile->FileName); - } else { - StrCpy (NewPrivateFile->FilePath, PrivateFile->FilePath); - } - - Size = StrSize (NewPrivateFile->FilePath); - Size += StrSize (L"\\"); - Size += StrSize (FileName); - NewPrivateFile->FileName = AllocatePool (Size); - if (NewPrivateFile->FileName == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto Done; - } - - if (*FileName == L'\\') { - StrCpy (NewPrivateFile->FileName, PrivateRoot->FilePath); - StrCat (NewPrivateFile->FileName, L"\\"); - StrCat (NewPrivateFile->FileName, FileName + 1); - } else { - StrCpy (NewPrivateFile->FileName, NewPrivateFile->FilePath); - if (StrCmp (FileName, L"") != 0) { - // - // In case the filename becomes empty, especially after trimming dots and blanks - // - StrCat (NewPrivateFile->FileName, L"\\"); - StrCat (NewPrivateFile->FileName, FileName); - } - } - - if (!IsFileNameValid (NewPrivateFile->FileName)) { - Status = EFI_NOT_FOUND; - goto Done; - } - - // - // Get rid of . and .., except leading . or .. - // - - // - // GuardPointer protect simplefilesystem root path not be destroyed - // - GuardPointer = NewPrivateFile->FileName + StrLen (PrivateRoot->FilePath); - - LoopFinish = FALSE; - - while (!LoopFinish) { - - LoopFinish = TRUE; - - for (ParseFileName = GuardPointer; *ParseFileName; ParseFileName++) { - if (*ParseFileName == L'.' && - (*(ParseFileName + 1) == 0 || *(ParseFileName + 1) == L'\\') && - *(ParseFileName - 1) == L'\\' - ) { - - // - // cut \. - // - CutPrefix (ParseFileName - 1, 2); - LoopFinish = FALSE; - break; - } - - if (*ParseFileName == L'.' && - *(ParseFileName + 1) == L'.' && - (*(ParseFileName + 2) == 0 || *(ParseFileName + 2) == L'\\') && - *(ParseFileName - 1) == L'\\' - ) { - - ParseFileName--; - Count = 3; - - while (ParseFileName != GuardPointer) { - ParseFileName--; - Count++; - if (*ParseFileName == L'\\') { - break; - } - } - - // - // cut \.. and its left directory - // - CutPrefix (ParseFileName, Count); - LoopFinish = FALSE; - break; - } - } - } - - RealFileName = NewPrivateFile->FileName; - while (EfiStrChr (RealFileName, L'\\') != NULL) { - RealFileName = EfiStrChr (RealFileName, L'\\') + 1; - } - - TempChar = 0; - if (RealFileName != NewPrivateFile->FileName) { - TempChar = *(RealFileName - 1); - *(RealFileName - 1) = 0; - } - - FreePool (NewPrivateFile->FilePath); - NewPrivateFile->FilePath = NULL; - NewPrivateFile->FilePath = AllocatePool (StrSize (NewPrivateFile->FileName)); - if (NewPrivateFile->FilePath == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto Done; - } - - StrCpy (NewPrivateFile->FilePath, NewPrivateFile->FileName); - if (TempChar != 0) { - *(RealFileName - 1) = TempChar; - } - - NewPrivateFile->IsRootDirectory = FALSE; - - // - // Test whether file or directory - // - if (OpenMode & EFI_FILE_MODE_CREATE) { - if (Attributes & EFI_FILE_DIRECTORY) { - NewPrivateFile->IsDirectoryPath = TRUE; - } else { - NewPrivateFile->IsDirectoryPath = FALSE; - } - } else { - NewPrivateFile->LHandle = INVALID_HANDLE_VALUE; - NewPrivateFile->LHandle = NewPrivateFile->WinNtThunk->CreateFile ( - NewPrivateFile->FileName, - GENERIC_READ, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - 0, - NULL - ); - - if (NewPrivateFile->LHandle != INVALID_HANDLE_VALUE) { - NewPrivateFile->IsDirectoryPath = FALSE; - NewPrivateFile->WinNtThunk->CloseHandle (NewPrivateFile->LHandle); - } else { - NewPrivateFile->IsDirectoryPath = TRUE; - } - - NewPrivateFile->LHandle = INVALID_HANDLE_VALUE; - } - - if (OpenMode & EFI_FILE_MODE_WRITE) { - NewPrivateFile->IsOpenedByRead = FALSE; - } else { - NewPrivateFile->IsOpenedByRead = TRUE; - } - - Status = EFI_SUCCESS; - - // - // deal with directory - // - if (NewPrivateFile->IsDirectoryPath) { - - Size = StrSize (NewPrivateFile->FileName); - Size += StrSize (L"\\*"); - TempFileName = AllocatePool (Size); - if (TempFileName == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto Done; - } - - StrCpy (TempFileName, NewPrivateFile->FileName); - - if ((OpenMode & EFI_FILE_MODE_CREATE)) { - // - // Create a directory - // - if (!NewPrivateFile->WinNtThunk->CreateDirectory (TempFileName, NULL)) { - - LastError = PrivateFile->WinNtThunk->GetLastError (); - if (LastError != ERROR_ALREADY_EXISTS) { - FreePool (TempFileName); - Status = EFI_ACCESS_DENIED; - goto Done; - } - } - } - - NewPrivateFile->DirHandle = NewPrivateFile->WinNtThunk->CreateFile ( - TempFileName, - NewPrivateFile->IsOpenedByRead ? GENERIC_READ : (GENERIC_READ | GENERIC_WRITE), - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - FILE_FLAG_BACKUP_SEMANTICS, - NULL - ); - - if (NewPrivateFile->DirHandle == INVALID_HANDLE_VALUE) { - - NewPrivateFile->DirHandle = NewPrivateFile->WinNtThunk->CreateFile ( - TempFileName, - GENERIC_READ, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - FILE_FLAG_BACKUP_SEMANTICS, - NULL - ); - - if (NewPrivateFile->DirHandle != INVALID_HANDLE_VALUE) { - NewPrivateFile->WinNtThunk->CloseHandle (NewPrivateFile->DirHandle); - NewPrivateFile->DirHandle = INVALID_HANDLE_VALUE; - Status = EFI_ACCESS_DENIED; - } else { - Status = EFI_NOT_FOUND; - } - - FreePool (TempFileName); - goto Done; - } - - // - // Find the first file under it - // - StrCat (TempFileName, L"\\*"); - NewPrivateFile->LHandle = NewPrivateFile->WinNtThunk->FindFirstFile (TempFileName, &NewPrivateFile->FindBuf); - FreePool (TempFileName); - - if (NewPrivateFile->LHandle == INVALID_HANDLE_VALUE) { - NewPrivateFile->IsValidFindBuf = FALSE; - } else { - NewPrivateFile->IsValidFindBuf = TRUE; - } - } else { - // - // deal with file - // - if (!NewPrivateFile->IsOpenedByRead) { - NewPrivateFile->LHandle = NewPrivateFile->WinNtThunk->CreateFile ( - NewPrivateFile->FileName, - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - (OpenMode & EFI_FILE_MODE_CREATE) ? OPEN_ALWAYS : OPEN_EXISTING, - 0, - NULL - ); - - if (NewPrivateFile->LHandle == INVALID_HANDLE_VALUE) { - NewPrivateFile->LHandle = NewPrivateFile->WinNtThunk->CreateFile ( - NewPrivateFile->FileName, - GENERIC_READ, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - 0, - NULL - ); - - if (NewPrivateFile->LHandle == INVALID_HANDLE_VALUE) { - Status = EFI_NOT_FOUND; - } else { - Status = EFI_ACCESS_DENIED; - NewPrivateFile->WinNtThunk->CloseHandle (NewPrivateFile->LHandle); - NewPrivateFile->LHandle = INVALID_HANDLE_VALUE; - } - } - } else { - NewPrivateFile->LHandle = NewPrivateFile->WinNtThunk->CreateFile ( - NewPrivateFile->FileName, - GENERIC_READ, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - 0, - NULL - ); - - if (NewPrivateFile->LHandle == INVALID_HANDLE_VALUE) { - Status = EFI_NOT_FOUND; - } - } - } - - if ((OpenMode & EFI_FILE_MODE_CREATE) && Status == EFI_SUCCESS) { - // - // Set the attribute - // - InfoSize = 0; - Info = NULL; - - Status = WinNtSimpleFileSystemGetInfo (&NewPrivateFile->EfiFile, &gEfiFileInfoGuid, &InfoSize, Info); - - if (Status != EFI_BUFFER_TOO_SMALL) { - Status = EFI_DEVICE_ERROR; - goto Done; - } - - Info = AllocatePool (InfoSize); - if (Info == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto Done; - } - - Status = WinNtSimpleFileSystemGetInfo (&NewPrivateFile->EfiFile, &gEfiFileInfoGuid, &InfoSize, Info); - - if (EFI_ERROR (Status)) { - FreePool (Info); - goto Done; - } - - Info->Attribute = Attributes; - - WinNtSimpleFileSystemSetInfo (&NewPrivateFile->EfiFile, &gEfiFileInfoGuid, InfoSize, Info); - FreePool (Info); - } - -Done: - FreePool (FileName); - - if (EFI_ERROR (Status)) { - if (NewPrivateFile) { - if (NewPrivateFile->FileName) { - FreePool (NewPrivateFile->FileName); - } - - if (NewPrivateFile->FilePath) { - FreePool (NewPrivateFile->FilePath); - } - - FreePool (NewPrivateFile); - } - } else { - *NewHandle = &NewPrivateFile->EfiFile; - if (StrCmp (NewPrivateFile->FileName, PrivateRoot->FilePath) == 0) { - NewPrivateFile->IsRootDirectory = TRUE; - } - } - - return Status; -} - -EFI_STATUS -EFIAPI -WinNtSimpleFileSystemClose ( - IN EFI_FILE_PROTOCOL *This - ) -/*++ - -Routine Description: - - Close the specified file handle. - -Arguments: - - This - Pointer to a returned opened file handle. - -Returns: - - EFI_SUCCESS - The file handle has been closed. - ---*/ -// TODO: EFI_INVALID_PARAMETER - add return value to function comment -{ - WIN_NT_EFI_FILE_PRIVATE *PrivateFile; - EFI_TPL OldTpl; - - if (This == NULL) { - return EFI_INVALID_PARAMETER; - } - - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - - PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This); - - if (PrivateFile->LHandle != INVALID_HANDLE_VALUE) { - if (PrivateFile->IsDirectoryPath) { - PrivateFile->WinNtThunk->FindClose (PrivateFile->LHandle); - } else { - PrivateFile->WinNtThunk->CloseHandle (PrivateFile->LHandle); - } - - PrivateFile->LHandle = INVALID_HANDLE_VALUE; - } - - if (PrivateFile->IsDirectoryPath && PrivateFile->DirHandle != INVALID_HANDLE_VALUE) { - PrivateFile->WinNtThunk->CloseHandle (PrivateFile->DirHandle); - PrivateFile->DirHandle = INVALID_HANDLE_VALUE; - } - - if (PrivateFile->FileName) { - FreePool (PrivateFile->FileName); - } - - if (PrivateFile->FilePath) { - FreePool (PrivateFile->FilePath); - } - - FreePool (PrivateFile); - - gBS->RestoreTPL (OldTpl); - - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -WinNtSimpleFileSystemDelete ( - IN EFI_FILE_PROTOCOL *This - ) -/*++ - -Routine Description: - - Close and delete a file. - -Arguments: - - This - Pointer to a returned opened file handle. - -Returns: - - EFI_SUCCESS - The file handle was closed and deleted. - - EFI_WARN_DELETE_FAILURE - The handle was closed but could not be deleted. - ---*/ -// TODO: EFI_INVALID_PARAMETER - add return value to function comment -{ - EFI_STATUS Status; - WIN_NT_EFI_FILE_PRIVATE *PrivateFile; - EFI_TPL OldTpl; - - if (This == NULL) { - return EFI_INVALID_PARAMETER; - } - - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - - PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This); - - Status = EFI_WARN_DELETE_FAILURE; - - if (PrivateFile->IsDirectoryPath) { - if (PrivateFile->LHandle != INVALID_HANDLE_VALUE) { - PrivateFile->WinNtThunk->FindClose (PrivateFile->LHandle); - } - - if (PrivateFile->DirHandle != INVALID_HANDLE_VALUE) { - PrivateFile->WinNtThunk->CloseHandle (PrivateFile->DirHandle); - PrivateFile->DirHandle = INVALID_HANDLE_VALUE; - } - - if (PrivateFile->WinNtThunk->RemoveDirectory (PrivateFile->FileName)) { - Status = EFI_SUCCESS; - } - } else { - PrivateFile->WinNtThunk->CloseHandle (PrivateFile->LHandle); - PrivateFile->LHandle = INVALID_HANDLE_VALUE; - - if (!PrivateFile->IsOpenedByRead) { - if (PrivateFile->WinNtThunk->DeleteFile (PrivateFile->FileName)) { - Status = EFI_SUCCESS; - } - } - } - - FreePool (PrivateFile->FileName); - FreePool (PrivateFile->FilePath); - FreePool (PrivateFile); - - gBS->RestoreTPL (OldTpl); - - return Status; -} - -VOID -WinNtSystemTimeToEfiTime ( - IN SYSTEMTIME *SystemTime, - IN TIME_ZONE_INFORMATION *TimeZone, - OUT EFI_TIME *Time - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - SystemTime - TODO: add argument description - TimeZone - TODO: add argument description - Time - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -{ - Time->Year = (UINT16) SystemTime->wYear; - Time->Month = (UINT8) SystemTime->wMonth; - Time->Day = (UINT8) SystemTime->wDay; - Time->Hour = (UINT8) SystemTime->wHour; - Time->Minute = (UINT8) SystemTime->wMinute; - Time->Second = (UINT8) SystemTime->wSecond; - Time->Nanosecond = (UINT32) SystemTime->wMilliseconds * 1000000; - Time->TimeZone = (INT16) TimeZone->Bias; - - if (TimeZone->StandardDate.wMonth) { - Time->Daylight = EFI_TIME_ADJUST_DAYLIGHT; - } -} - -/** - Convert the FileTime to EfiTime. - - @param PrivateFile Pointer to WIN_NT_EFI_FILE_PRIVATE. - @param TimeZone Pointer to the current time zone. - @param FileTime Pointer to file time. - @param EfiTime Pointer to EFI time. -**/ -VOID -WinNtFileTimeToEfiTime ( - IN CONST WIN_NT_EFI_FILE_PRIVATE *PrivateFile, - IN TIME_ZONE_INFORMATION *TimeZone, - IN CONST FILETIME *FileTime, - OUT EFI_TIME *EfiTime - ) -{ - FILETIME TempFileTime; - SYSTEMTIME SystemTime; - - PrivateFile->WinNtThunk->FileTimeToLocalFileTime (FileTime, &TempFileTime); - PrivateFile->WinNtThunk->FileTimeToSystemTime (&TempFileTime, &SystemTime); - WinNtSystemTimeToEfiTime (&SystemTime, TimeZone, EfiTime); -} - -EFI_STATUS -EFIAPI -WinNtSimpleFileSystemRead ( - IN EFI_FILE_PROTOCOL *This, - IN OUT UINTN *BufferSize, - OUT VOID *Buffer - ) -/*++ - -Routine Description: - - Read data from a file. - -Arguments: - - This - Pointer to a returned open file handle. - - BufferSize - On input, the size of the Buffer. On output, the number of bytes stored in the Buffer. - - Buffer - Pointer to the first byte of the read Buffer. - -Returns: - - EFI_SUCCESS - The data was read. - - EFI_NO_MEDIA - The device has no media. - - EFI_DEVICE_ERROR - The device reported an error. - - EFI_VOLUME_CORRUPTED - The file system structures are corrupted. - - EFI_BUFFER_TOO_SMALL - The supplied buffer size was too small to store the current directory entry. - *BufferSize has been updated with the size needed to complete the request. - ---*/ -// TODO: EFI_INVALID_PARAMETER - add return value to function comment -{ - WIN_NT_EFI_FILE_PRIVATE *PrivateFile; - EFI_STATUS Status; - UINTN Size; - UINTN NameSize; - UINTN ResultSize; - UINTN Index; - EFI_FILE_INFO *Info; - WCHAR *pw; - TIME_ZONE_INFORMATION TimeZone; - EFI_FILE_INFO *FileInfo; - UINT64 Pos; - UINT64 FileSize; - UINTN FileInfoSize; - EFI_TPL OldTpl; - - if (This == NULL || BufferSize == NULL) { - return EFI_INVALID_PARAMETER; - } - - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - - PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This); - - if (PrivateFile->LHandle == INVALID_HANDLE_VALUE) { - Status = EFI_DEVICE_ERROR; - goto Done; - } - - if (!PrivateFile->IsDirectoryPath) { - - if (This->GetPosition (This, &Pos) != EFI_SUCCESS) { - Status = EFI_DEVICE_ERROR; - goto Done; - } - - FileInfoSize = SIZE_OF_EFI_FILE_SYSTEM_INFO; - FileInfo = AllocatePool (FileInfoSize); - - Status = This->GetInfo ( - This, - &gEfiFileInfoGuid, - &FileInfoSize, - FileInfo - ); - - if (Status == EFI_BUFFER_TOO_SMALL) { - FreePool (FileInfo); - FileInfo = AllocatePool (FileInfoSize); - Status = This->GetInfo ( - This, - &gEfiFileInfoGuid, - &FileInfoSize, - FileInfo - ); - } - - if (EFI_ERROR (Status)) { - Status = EFI_DEVICE_ERROR; - goto Done; - } - - FileSize = FileInfo->FileSize; - - FreePool (FileInfo); - - if (Pos >= FileSize) { - *BufferSize = 0; - if (Pos == FileSize) { - Status = EFI_SUCCESS; - goto Done; - } else { - Status = EFI_DEVICE_ERROR; - goto Done; - } - } - - Status = PrivateFile->WinNtThunk->ReadFile ( - PrivateFile->LHandle, - Buffer, - (DWORD)*BufferSize, - (LPDWORD)BufferSize, - NULL - ) ? EFI_SUCCESS : EFI_DEVICE_ERROR; - goto Done; - } - - // - // Read on a directory. Perform a find next - // - if (!PrivateFile->IsValidFindBuf) { - *BufferSize = 0; - Status = EFI_SUCCESS; - goto Done; - } - - Size = SIZE_OF_EFI_FILE_INFO; - - NameSize = StrSize (PrivateFile->FindBuf.cFileName); - - ResultSize = Size + NameSize; - - Status = EFI_BUFFER_TOO_SMALL; - - if (*BufferSize >= ResultSize) { - Status = EFI_SUCCESS; - - Info = Buffer; - ZeroMem (Info, ResultSize); - - Info->Size = ResultSize; - - PrivateFile->WinNtThunk->GetTimeZoneInformation (&TimeZone); - WinNtFileTimeToEfiTime (PrivateFile, &TimeZone, &PrivateFile->FindBuf.ftCreationTime, &Info->CreateTime); - WinNtFileTimeToEfiTime (PrivateFile, &TimeZone, &PrivateFile->FindBuf.ftLastAccessTime, &Info->LastAccessTime); - WinNtFileTimeToEfiTime (PrivateFile, &TimeZone, &PrivateFile->FindBuf.ftLastWriteTime, &Info->ModificationTime); - - Info->FileSize = PrivateFile->FindBuf.nFileSizeLow; - - Info->PhysicalSize = PrivateFile->FindBuf.nFileSizeLow; - - if (PrivateFile->FindBuf.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE) { - Info->Attribute |= EFI_FILE_ARCHIVE; - } - - if (PrivateFile->FindBuf.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) { - Info->Attribute |= EFI_FILE_HIDDEN; - } - - if (PrivateFile->FindBuf.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) { - Info->Attribute |= EFI_FILE_SYSTEM; - } - - if (PrivateFile->FindBuf.dwFileAttributes & FILE_ATTRIBUTE_READONLY) { - Info->Attribute |= EFI_FILE_READ_ONLY; - } - - if (PrivateFile->FindBuf.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { - Info->Attribute |= EFI_FILE_DIRECTORY; - } - - NameSize = NameSize / sizeof (WCHAR); - - pw = (WCHAR *) (((CHAR8 *) Buffer) + Size); - - for (Index = 0; Index < NameSize; Index++) { - pw[Index] = PrivateFile->FindBuf.cFileName[Index]; - } - - if (PrivateFile->WinNtThunk->FindNextFile (PrivateFile->LHandle, &PrivateFile->FindBuf)) { - PrivateFile->IsValidFindBuf = TRUE; - } else { - PrivateFile->IsValidFindBuf = FALSE; - } - } - - *BufferSize = ResultSize; - -Done: - gBS->RestoreTPL (OldTpl); - return Status; -} - -EFI_STATUS -EFIAPI -WinNtSimpleFileSystemWrite ( - IN EFI_FILE_PROTOCOL *This, - IN OUT UINTN *BufferSize, - IN VOID *Buffer - ) -/*++ - -Routine Description: - - Write data to a file. - -Arguments: - - This - Pointer to an opened file handle. - - BufferSize - On input, the number of bytes in the Buffer to write to the file. On output, the number of bytes - of data written to the file. - - Buffer - Pointer to the first by of data in the buffer to write to the file. - -Returns: - - EFI_SUCCESS - The data was written to the file. - - EFI_UNSUPPORTED - Writes to an open directory are not supported. - - EFI_NO_MEDIA - The device has no media. - - EFI_DEVICE_ERROR - The device reported an error. - - EFI_VOLUME_CORRUPTED - The file system structures are corrupt. - - EFI_WRITE_PROTECTED - The file, directory, volume, or device is write protected. - - EFI_ACCESS_DENIED - The file was opened read-only. - - EFI_VOLUME_FULL - The volume is full. - ---*/ -// TODO: EFI_INVALID_PARAMETER - add return value to function comment -{ - WIN_NT_EFI_FILE_PRIVATE *PrivateFile; - EFI_STATUS Status; - EFI_TPL OldTpl; - - if (This == NULL || BufferSize == NULL || Buffer == NULL) { - return EFI_INVALID_PARAMETER; - } - - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - - PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This); - - if (PrivateFile->LHandle == INVALID_HANDLE_VALUE) { - Status = EFI_DEVICE_ERROR; - goto Done; - } - - if (PrivateFile->IsDirectoryPath) { - Status = EFI_UNSUPPORTED; - goto Done; - } - - if (PrivateFile->IsOpenedByRead) { - Status = EFI_ACCESS_DENIED; - goto Done; - } - - Status = PrivateFile->WinNtThunk->WriteFile ( - PrivateFile->LHandle, - Buffer, - (DWORD)*BufferSize, - (LPDWORD)BufferSize, - NULL - ) ? EFI_SUCCESS : EFI_DEVICE_ERROR; - -Done: - gBS->RestoreTPL (OldTpl); - return Status; - - // - // bugbug: need to access windows error reporting - // -} - -EFI_STATUS -EFIAPI -WinNtSimpleFileSystemSetPosition ( - IN EFI_FILE_PROTOCOL *This, - IN UINT64 Position - ) -/*++ - -Routine Description: - - Set a file's current position. - -Arguments: - - This - Pointer to an opened file handle. - - Position - The byte position from the start of the file to set. - -Returns: - - EFI_SUCCESS - The file position has been changed. - - EFI_UNSUPPORTED - The seek request for non-zero is not supported for directories. - ---*/ -// TODO: EFI_INVALID_PARAMETER - add return value to function comment -{ - EFI_STATUS Status; - WIN_NT_EFI_FILE_PRIVATE *PrivateFile; - UINT32 PosLow; - UINT32 PosHigh; - CHAR16 *FileName; - EFI_TPL OldTpl; - UINTN Size; - - if (This == NULL) { - return EFI_INVALID_PARAMETER; - } - - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - - PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This); - - if (PrivateFile->IsDirectoryPath) { - if (Position != 0) { - Status = EFI_UNSUPPORTED; - goto Done; - } - - Size = StrSize (PrivateFile->FileName); - Size += StrSize (L"\\*"); - FileName = AllocatePool (Size); - if (FileName == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto Done; - } - - StrCpy (FileName, PrivateFile->FileName); - StrCat (FileName, L"\\*"); - - if (PrivateFile->LHandle != INVALID_HANDLE_VALUE) { - PrivateFile->WinNtThunk->FindClose (PrivateFile->LHandle); - } - - PrivateFile->LHandle = PrivateFile->WinNtThunk->FindFirstFile (FileName, &PrivateFile->FindBuf); - - if (PrivateFile->LHandle == INVALID_HANDLE_VALUE) { - PrivateFile->IsValidFindBuf = FALSE; - } else { - PrivateFile->IsValidFindBuf = TRUE; - } - - FreePool (FileName); - - Status = (PrivateFile->LHandle == INVALID_HANDLE_VALUE) ? EFI_DEVICE_ERROR : EFI_SUCCESS; - } else { - if (Position == (UINT64) -1) { - PosLow = PrivateFile->WinNtThunk->SetFilePointer (PrivateFile->LHandle, (ULONG) 0, NULL, FILE_END); - } else { - PosHigh = (UINT32) RShiftU64 (Position, 32); - - PosLow = PrivateFile->WinNtThunk->SetFilePointer (PrivateFile->LHandle, (ULONG) Position, (PLONG)&PosHigh, FILE_BEGIN); - } - - Status = (PosLow == 0xFFFFFFFF) ? EFI_DEVICE_ERROR : EFI_SUCCESS; - } - -Done: - gBS->RestoreTPL (OldTpl); - return Status; -} - -EFI_STATUS -EFIAPI -WinNtSimpleFileSystemGetPosition ( - IN EFI_FILE_PROTOCOL *This, - OUT UINT64 *Position - ) -/*++ - -Routine Description: - - Get a file's current position. - -Arguments: - - This - Pointer to an opened file handle. - - Position - Pointer to storage for the current position. - -Returns: - - EFI_SUCCESS - The file position has been reported. - - EFI_UNSUPPORTED - Not valid for directories. - ---*/ -// TODO: EFI_INVALID_PARAMETER - add return value to function comment -{ - EFI_STATUS Status; - WIN_NT_EFI_FILE_PRIVATE *PrivateFile; - INT32 PositionHigh; - UINT64 PosHigh64; - EFI_TPL OldTpl; - - if (This == NULL || Position == NULL) { - return EFI_INVALID_PARAMETER; - } - - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This); - - PositionHigh = 0; - PosHigh64 = 0; - - if (PrivateFile->IsDirectoryPath) { - - Status = EFI_UNSUPPORTED; - goto Done; - - } else { - - PositionHigh = 0; - *Position = PrivateFile->WinNtThunk->SetFilePointer ( - PrivateFile->LHandle, - 0, - (PLONG)&PositionHigh, - FILE_CURRENT - ); - - Status = *Position == 0xffffffff ? EFI_DEVICE_ERROR : EFI_SUCCESS; - if (EFI_ERROR (Status)) { - goto Done; - } - - PosHigh64 = PositionHigh; - *Position += LShiftU64 (PosHigh64, 32); - } - -Done: - gBS->RestoreTPL (OldTpl); - return Status; -} - -EFI_STATUS -WinNtSimpleFileSystemFileInfo ( - IN WIN_NT_EFI_FILE_PRIVATE *PrivateFile, - IN OUT UINTN *BufferSize, - OUT VOID *Buffer - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - PrivateFile - TODO: add argument description - BufferSize - TODO: add argument description - Buffer - TODO: add argument description - -Returns: - - TODO: add return values - ---*/ -{ - EFI_STATUS Status; - UINTN Size; - UINTN NameSize; - UINTN ResultSize; - EFI_FILE_INFO *Info; - BY_HANDLE_FILE_INFORMATION FileInfo; - CHAR16 *RealFileName; - CHAR16 *TempPointer; - TIME_ZONE_INFORMATION TimeZone; - - Size = SIZE_OF_EFI_FILE_INFO; - - RealFileName = PrivateFile->FileName; - TempPointer = RealFileName; - while (*TempPointer) { - if (*TempPointer == '\\') { - RealFileName = TempPointer + 1; - } - - TempPointer++; - } - NameSize = StrSize (RealFileName); - - ResultSize = Size + NameSize; - - Status = EFI_BUFFER_TOO_SMALL; - if (*BufferSize >= ResultSize) { - Status = EFI_SUCCESS; - - Info = Buffer; - ZeroMem (Info, ResultSize); - - Info->Size = ResultSize; - PrivateFile->WinNtThunk->GetFileInformationByHandle ( - PrivateFile->IsDirectoryPath ? PrivateFile->DirHandle : PrivateFile->LHandle, - &FileInfo - ); - Info->FileSize = FileInfo.nFileSizeLow; - Info->PhysicalSize = Info->FileSize; - - PrivateFile->WinNtThunk->GetTimeZoneInformation (&TimeZone); - WinNtFileTimeToEfiTime (PrivateFile, &TimeZone, &FileInfo.ftCreationTime, &Info->CreateTime); - WinNtFileTimeToEfiTime (PrivateFile, &TimeZone, &FileInfo.ftLastAccessTime, &Info->LastAccessTime); - WinNtFileTimeToEfiTime (PrivateFile, &TimeZone, &FileInfo.ftLastWriteTime, &Info->ModificationTime); - - if (FileInfo.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE) { - Info->Attribute |= EFI_FILE_ARCHIVE; - } - - if (FileInfo.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) { - Info->Attribute |= EFI_FILE_HIDDEN; - } - - if (FileInfo.dwFileAttributes & FILE_ATTRIBUTE_READONLY) { - Info->Attribute |= EFI_FILE_READ_ONLY; - } - - if (FileInfo.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) { - Info->Attribute |= EFI_FILE_SYSTEM; - } - - if (FileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { - Info->Attribute |= EFI_FILE_DIRECTORY; - } - - if (PrivateFile->IsDirectoryPath) { - Info->Attribute |= EFI_FILE_DIRECTORY; - } - - if (PrivateFile->IsRootDirectory) { - *((CHAR8 *) Buffer + Size) = 0; - } else { - CopyMem ((CHAR8 *) Buffer + Size, RealFileName, NameSize); - } - } - - *BufferSize = ResultSize; - return Status; -} - -EFI_STATUS -EFIAPI -WinNtSimpleFileSystemGetInfo ( - IN EFI_FILE_PROTOCOL *This, - IN EFI_GUID *InformationType, - IN OUT UINTN *BufferSize, - OUT VOID *Buffer - ) -/*++ - -Routine Description: - - Return information about a file or volume. - -Arguments: - - This - Pointer to an opened file handle. - - InformationType - GUID describing the type of information to be returned. - - BufferSize - On input, the size of the information buffer. On output, the number of bytes written to the - information buffer. - - Buffer - Pointer to the first byte of the information buffer. - -Returns: - - EFI_SUCCESS - The requested information has been written into the buffer. - - EFI_UNSUPPORTED - The InformationType is not known. - - EFI_NO_MEDIA - The device has no media. - - EFI_DEVICE_ERROR - The device reported an error. - - EFI_VOLUME_CORRUPTED - The file system structures are corrupt. - - EFI_BUFFER_TOO_SMALL - The buffer size was too small to contain the requested information. The buffer size has - been updated with the size needed to complete the requested operation. - ---*/ -// TODO: EFI_INVALID_PARAMETER - add return value to function comment -{ - EFI_STATUS Status; - WIN_NT_EFI_FILE_PRIVATE *PrivateFile; - EFI_FILE_SYSTEM_INFO *FileSystemInfoBuffer; - UINT32 SectorsPerCluster; - UINT32 BytesPerSector; - UINT32 FreeClusters; - UINT32 TotalClusters; - UINT32 BytesPerCluster; - CHAR16 *DriveName; - BOOLEAN DriveNameFound; - BOOL NtStatus; - UINTN Index; - WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE *PrivateRoot; - EFI_TPL OldTpl; - - if (This == NULL || InformationType == NULL || BufferSize == NULL) { - return EFI_INVALID_PARAMETER; - } - - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - - PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This); - PrivateRoot = WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (PrivateFile->SimpleFileSystem); - - Status = EFI_UNSUPPORTED; - - if (CompareGuid (InformationType, &gEfiFileInfoGuid)) { - Status = WinNtSimpleFileSystemFileInfo (PrivateFile, BufferSize, Buffer); - } - - if (CompareGuid (InformationType, &gEfiFileSystemInfoGuid)) { - if (*BufferSize < SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel)) { - *BufferSize = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel); - Status = EFI_BUFFER_TOO_SMALL; - goto Done; - } - - FileSystemInfoBuffer = (EFI_FILE_SYSTEM_INFO *) Buffer; - FileSystemInfoBuffer->Size = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel); - FileSystemInfoBuffer->ReadOnly = FALSE; - - // - // Try to get the drive name - // - DriveNameFound = FALSE; - DriveName = AllocatePool (StrSize (PrivateFile->FilePath) + 1); - if (DriveName == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto Done; - } - - StrCpy (DriveName, PrivateFile->FilePath); - for (Index = 0; DriveName[Index] != 0 && DriveName[Index] != ':'; Index++) { - ; - } - - if (DriveName[Index] == ':') { - DriveName[Index + 1] = '\\'; - DriveName[Index + 2] = 0; - DriveNameFound = TRUE; - } else if (DriveName[0] == '\\' && DriveName[1] == '\\') { - for (Index = 2; DriveName[Index] != 0 && DriveName[Index] != '\\'; Index++) { - ; - } - - if (DriveName[Index] == '\\') { - DriveNameFound = TRUE; - for (Index++; DriveName[Index] != 0 && DriveName[Index] != '\\'; Index++) { - ; - } - - DriveName[Index] = '\\'; - DriveName[Index + 1] = 0; - } - } - - // - // Try GetDiskFreeSpace first - // - NtStatus = PrivateFile->WinNtThunk->GetDiskFreeSpace ( - DriveNameFound ? DriveName : NULL, - (LPDWORD)&SectorsPerCluster, - (LPDWORD)&BytesPerSector, - (LPDWORD)&FreeClusters, - (LPDWORD)&TotalClusters - ); - if (DriveName) { - FreePool (DriveName); - } - - if (NtStatus) { - // - // Succeeded - // - BytesPerCluster = BytesPerSector * SectorsPerCluster; - FileSystemInfoBuffer->VolumeSize = MultU64x32 (TotalClusters, BytesPerCluster); - FileSystemInfoBuffer->FreeSpace = MultU64x32 (FreeClusters, BytesPerCluster); - FileSystemInfoBuffer->BlockSize = BytesPerCluster; - - } else { - // - // try GetDiskFreeSpaceEx then - // - FileSystemInfoBuffer->BlockSize = 0; - NtStatus = PrivateFile->WinNtThunk->GetDiskFreeSpaceEx ( - PrivateFile->FilePath, - (PULARGE_INTEGER) (&FileSystemInfoBuffer->FreeSpace), - (PULARGE_INTEGER) (&FileSystemInfoBuffer->VolumeSize), - NULL - ); - if (!NtStatus) { - Status = EFI_DEVICE_ERROR; - goto Done; - } - } - - StrCpy ((CHAR16 *) FileSystemInfoBuffer->VolumeLabel, PrivateRoot->VolumeLabel); - *BufferSize = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel); - Status = EFI_SUCCESS; - } - - if (CompareGuid (InformationType, &gEfiFileSystemVolumeLabelInfoIdGuid)) { - if (*BufferSize < StrSize (PrivateRoot->VolumeLabel)) { - *BufferSize = StrSize (PrivateRoot->VolumeLabel); - Status = EFI_BUFFER_TOO_SMALL; - goto Done; - } - - StrCpy ((CHAR16 *) Buffer, PrivateRoot->VolumeLabel); - *BufferSize = StrSize (PrivateRoot->VolumeLabel); - Status = EFI_SUCCESS; - } - -Done: - gBS->RestoreTPL (OldTpl); - return Status; -} - -EFI_STATUS -EFIAPI -WinNtSimpleFileSystemSetInfo ( - IN EFI_FILE_PROTOCOL*This, - IN EFI_GUID *InformationType, - IN UINTN BufferSize, - IN VOID *Buffer - ) -/*++ - -Routine Description: - - Set information about a file or volume. - -Arguments: - - This - Pointer to an opened file handle. - - InformationType - GUID identifying the type of information to set. - - BufferSize - Number of bytes of data in the information buffer. - - Buffer - Pointer to the first byte of data in the information buffer. - -Returns: - - EFI_SUCCESS - The file or volume information has been updated. - - EFI_UNSUPPORTED - The information identifier is not recognised. - - EFI_NO_MEDIA - The device has no media. - - EFI_DEVICE_ERROR - The device reported an error. - - EFI_VOLUME_CORRUPTED - The file system structures are corrupt. - - EFI_WRITE_PROTECTED - The file, directory, volume, or device is write protected. - - EFI_ACCESS_DENIED - The file was opened read-only. - - EFI_VOLUME_FULL - The volume is full. - - EFI_BAD_BUFFER_SIZE - The buffer size is smaller than the type indicated by InformationType. - ---*/ -// TODO: EFI_INVALID_PARAMETER - add return value to function comment -// TODO: EFI_INVALID_PARAMETER - add return value to function comment -{ - WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE *PrivateRoot; - WIN_NT_EFI_FILE_PRIVATE *PrivateFile; - EFI_FILE_INFO *OldFileInfo; - EFI_FILE_INFO *NewFileInfo; - EFI_STATUS Status; - UINTN OldInfoSize; - INTN NtStatus; - UINT32 NewAttr; - UINT32 OldAttr; - CHAR16 *OldFileName; - CHAR16 *NewFileName; - CHAR16 *TempFileName; - CHAR16 *CharPointer; - BOOLEAN AttrChangeFlag; - BOOLEAN NameChangeFlag; - BOOLEAN SizeChangeFlag; - BOOLEAN TimeChangeFlag; - UINT64 CurPos; - SYSTEMTIME NewCreationSystemTime; - SYSTEMTIME NewLastAccessSystemTime; - SYSTEMTIME NewLastWriteSystemTime; - FILETIME NewCreationFileTime; - FILETIME NewLastAccessFileTime; - FILETIME NewLastWriteFileTime; - WIN32_FIND_DATA FindBuf; - EFI_FILE_SYSTEM_INFO *NewFileSystemInfo; - EFI_TPL OldTpl; - UINTN Size; - - // - // Check for invalid parameters. - // - if (This == NULL || InformationType == NULL || BufferSize == 0 || Buffer == NULL) { - return EFI_INVALID_PARAMETER; - } - - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - - // - // Initialise locals. - // - PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This); - PrivateRoot = WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (PrivateFile->SimpleFileSystem); - - Status = EFI_UNSUPPORTED; - OldFileInfo = NewFileInfo = NULL; - OldFileName = NewFileName = NULL; - AttrChangeFlag = NameChangeFlag = SizeChangeFlag = TimeChangeFlag = FALSE; - - // - // Set file system information. - // - if (CompareGuid (InformationType, &gEfiFileSystemInfoGuid)) { - NewFileSystemInfo = (EFI_FILE_SYSTEM_INFO *) Buffer; - if (BufferSize < SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (NewFileSystemInfo->VolumeLabel)) { - Status = EFI_BAD_BUFFER_SIZE; - goto Done; - } - - - FreePool (PrivateRoot->VolumeLabel); - PrivateRoot->VolumeLabel = AllocatePool (StrSize (NewFileSystemInfo->VolumeLabel)); - if (PrivateRoot->VolumeLabel == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto Done; - } - - StrCpy (PrivateRoot->VolumeLabel, NewFileSystemInfo->VolumeLabel); - - Status = EFI_SUCCESS; - goto Done; - } - - // - // Set volume label information. - // - if (CompareGuid (InformationType, &gEfiFileSystemVolumeLabelInfoIdGuid)) { - if (BufferSize < StrSize (PrivateRoot->VolumeLabel)) { - Status = EFI_BAD_BUFFER_SIZE; - goto Done; - } - - StrCpy (PrivateRoot->VolumeLabel, (CHAR16 *) Buffer); - - Status = EFI_SUCCESS; - goto Done; - } - - if (!CompareGuid (InformationType, &gEfiFileInfoGuid)) { - Status = EFI_UNSUPPORTED; - goto Done; - } - - if (BufferSize < SIZE_OF_EFI_FILE_INFO) { - Status = EFI_BAD_BUFFER_SIZE; - goto Done; - } - - // - // Set file/directory information. - // - - // - // Check for invalid set file information parameters. - // - NewFileInfo = (EFI_FILE_INFO *) Buffer; - - if ((NewFileInfo->Size <= SIZE_OF_EFI_FILE_INFO) || - (NewFileInfo->Attribute &~(EFI_FILE_VALID_ATTR)) || - (sizeof (UINTN) == 4 && NewFileInfo->Size > 0xFFFFFFFF) - ) { - Status = EFI_INVALID_PARAMETER; - goto Done; - } - - // - // bugbug: - This is not safe. We need something like EfiStrMaxSize() - // that would have an additional parameter that would be the size - // of the string array just in case there are no NULL characters in - // the string array. - // - // - // Get current file information so we can determine what kind - // of change request this is. - // - OldInfoSize = 0; - Status = WinNtSimpleFileSystemFileInfo (PrivateFile, &OldInfoSize, NULL); - - if (Status != EFI_BUFFER_TOO_SMALL) { - Status = EFI_DEVICE_ERROR; - goto Done; - } - - OldFileInfo = AllocatePool (OldInfoSize); - if (OldFileInfo == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto Done; - } - - Status = WinNtSimpleFileSystemFileInfo (PrivateFile, &OldInfoSize, OldFileInfo); - - if (EFI_ERROR (Status)) { - goto Done; - } - - OldFileName = AllocatePool (StrSize (PrivateFile->FileName)); - if (OldFileName == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto Done; - } - - StrCpy (OldFileName, PrivateFile->FileName); - - // - // Make full pathname from new filename and rootpath. - // - if (NewFileInfo->FileName[0] == '\\') { - Size = StrSize (PrivateRoot->FilePath); - Size += StrSize (L"\\"); - Size += StrSize (NewFileInfo->FileName); - NewFileName = AllocatePool (Size); - if (NewFileName == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto Done; - } - - StrCpy (NewFileName, PrivateRoot->FilePath); - StrCat (NewFileName, L"\\"); - StrCat (NewFileName, NewFileInfo->FileName + 1); - } else { - Size = StrSize (PrivateFile->FilePath); - Size += StrSize (L"\\"); - Size += StrSize (NewFileInfo->FileName); - NewFileName = AllocatePool (Size); - if (NewFileName == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto Done; - } - - StrCpy (NewFileName, PrivateFile->FilePath); - StrCat (NewFileName, L"\\"); - StrCat (NewFileName, NewFileInfo->FileName); - } - - // - // Is there an attribute change request? - // - if (NewFileInfo->Attribute != OldFileInfo->Attribute) { - if ((NewFileInfo->Attribute & EFI_FILE_DIRECTORY) != (OldFileInfo->Attribute & EFI_FILE_DIRECTORY)) { - Status = EFI_INVALID_PARAMETER; - goto Done; - } - - AttrChangeFlag = TRUE; - } - - // - // Is there a name change request? - // bugbug: - Need EfiStrCaseCmp() - // - if (StrCmp (NewFileInfo->FileName, OldFileInfo->FileName)) { - NameChangeFlag = TRUE; - } - - // - // Is there a size change request? - // - if (NewFileInfo->FileSize != OldFileInfo->FileSize) { - SizeChangeFlag = TRUE; - } - - // - // Is there a time stamp change request? - // - if (!IsZero (&NewFileInfo->CreateTime, sizeof (EFI_TIME)) && - CompareMem (&NewFileInfo->CreateTime, &OldFileInfo->CreateTime, sizeof (EFI_TIME)) - ) { - TimeChangeFlag = TRUE; - } else if (!IsZero (&NewFileInfo->LastAccessTime, sizeof (EFI_TIME)) && - CompareMem (&NewFileInfo->LastAccessTime, &OldFileInfo->LastAccessTime, sizeof (EFI_TIME)) - ) { - TimeChangeFlag = TRUE; - } else if (!IsZero (&NewFileInfo->ModificationTime, sizeof (EFI_TIME)) && - CompareMem (&NewFileInfo->ModificationTime, &OldFileInfo->ModificationTime, sizeof (EFI_TIME)) - ) { - TimeChangeFlag = TRUE; - } - - // - // All done if there are no change requests being made. - // - if (!(AttrChangeFlag || NameChangeFlag || SizeChangeFlag || TimeChangeFlag)) { - Status = EFI_SUCCESS; - goto Done; - } - - // - // Set file or directory information. - // - OldAttr = PrivateFile->WinNtThunk->GetFileAttributes (OldFileName); - - // - // Name change. - // - if (NameChangeFlag) { - // - // Close the handles first - // - if (PrivateFile->IsOpenedByRead) { - Status = EFI_ACCESS_DENIED; - goto Done; - } - - for (CharPointer = NewFileName; *CharPointer != 0 && *CharPointer != L'/'; CharPointer++) { - } - - if (*CharPointer != 0) { - Status = EFI_ACCESS_DENIED; - goto Done; - } - - if (PrivateFile->LHandle != INVALID_HANDLE_VALUE) { - if (PrivateFile->IsDirectoryPath) { - PrivateFile->WinNtThunk->FindClose (PrivateFile->LHandle); - } else { - PrivateFile->WinNtThunk->CloseHandle (PrivateFile->LHandle); - PrivateFile->LHandle = INVALID_HANDLE_VALUE; - } - } - - if (PrivateFile->IsDirectoryPath && PrivateFile->DirHandle != INVALID_HANDLE_VALUE) { - PrivateFile->WinNtThunk->CloseHandle (PrivateFile->DirHandle); - PrivateFile->DirHandle = INVALID_HANDLE_VALUE; - } - - NtStatus = PrivateFile->WinNtThunk->MoveFile (OldFileName, NewFileName); - - if (NtStatus) { - // - // modify file name - // - FreePool (PrivateFile->FileName); - - PrivateFile->FileName = AllocatePool (StrSize (NewFileName)); - if (PrivateFile->FileName == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto Done; - } - - StrCpy (PrivateFile->FileName, NewFileName); - - Size = StrSize (NewFileName); - Size += StrSize (L"\\*"); - TempFileName = AllocatePool (Size); - - StrCpy (TempFileName, NewFileName); - - if (!PrivateFile->IsDirectoryPath) { - PrivateFile->LHandle = PrivateFile->WinNtThunk->CreateFile ( - TempFileName, - PrivateFile->IsOpenedByRead ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - 0, - NULL - ); - - FreePool (TempFileName); - - // - // Flush buffers just in case - // - if (PrivateFile->WinNtThunk->FlushFileBuffers (PrivateFile->LHandle) == 0) { - Status = EFI_DEVICE_ERROR; - goto Done; - } - } else { - PrivateFile->DirHandle = PrivateFile->WinNtThunk->CreateFile ( - TempFileName, - PrivateFile->IsOpenedByRead ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - FILE_FLAG_BACKUP_SEMANTICS, - NULL - ); - - StrCat (TempFileName, L"\\*"); - PrivateFile->LHandle = PrivateFile->WinNtThunk->FindFirstFile (TempFileName, &FindBuf); - - FreePool (TempFileName); - } - } else { - Status = EFI_ACCESS_DENIED; -Reopen: ; - - NtStatus = PrivateFile->WinNtThunk->SetFileAttributes (OldFileName, OldAttr); - - if (!NtStatus) { - goto Done; - } - - Size = StrSize (OldFileName); - Size += StrSize (L"\\*"); - TempFileName = AllocatePool (Size); - - StrCpy (TempFileName, OldFileName); - - if (!PrivateFile->IsDirectoryPath) { - PrivateFile->LHandle = PrivateFile->WinNtThunk->CreateFile ( - TempFileName, - PrivateFile->IsOpenedByRead ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - 0, - NULL - ); - } else { - PrivateFile->DirHandle = PrivateFile->WinNtThunk->CreateFile ( - TempFileName, - PrivateFile->IsOpenedByRead ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - FILE_FLAG_BACKUP_SEMANTICS, - NULL - ); - - StrCat (TempFileName, L"\\*"); - PrivateFile->LHandle = PrivateFile->WinNtThunk->FindFirstFile (TempFileName, &FindBuf); - } - - FreePool (TempFileName); - - goto Done; - - } - } - - // - // Size change - // - if (SizeChangeFlag) { - if (PrivateFile->IsDirectoryPath) { - Status = EFI_UNSUPPORTED; - goto Done; - } - - if (PrivateFile->IsOpenedByRead || OldFileInfo->Attribute & EFI_FILE_READ_ONLY) { - Status = EFI_ACCESS_DENIED; - goto Done; - } - - Status = This->GetPosition (This, &CurPos); - if (EFI_ERROR (Status)) { - goto Done; - } - - Status = This->SetPosition (This, NewFileInfo->FileSize); - if (EFI_ERROR (Status)) { - goto Done; - } - - if (PrivateFile->WinNtThunk->SetEndOfFile (PrivateFile->LHandle) == 0) { - Status = EFI_DEVICE_ERROR; - goto Done; - } - - Status = This->SetPosition (This, CurPos); - if (EFI_ERROR (Status)) { - goto Done; - } - } - - // - // Time change - // - if (TimeChangeFlag) { - - NewCreationSystemTime.wYear = NewFileInfo->CreateTime.Year; - NewCreationSystemTime.wMonth = NewFileInfo->CreateTime.Month; - NewCreationSystemTime.wDay = NewFileInfo->CreateTime.Day; - NewCreationSystemTime.wHour = NewFileInfo->CreateTime.Hour; - NewCreationSystemTime.wMinute = NewFileInfo->CreateTime.Minute; - NewCreationSystemTime.wSecond = NewFileInfo->CreateTime.Second; - NewCreationSystemTime.wMilliseconds = 0; - - if (!PrivateFile->WinNtThunk->SystemTimeToFileTime ( - &NewCreationSystemTime, - &NewCreationFileTime - )) { - goto Done; - } - - if (!PrivateFile->WinNtThunk->LocalFileTimeToFileTime ( - &NewCreationFileTime, - &NewCreationFileTime - )) { - goto Done; - } - - NewLastAccessSystemTime.wYear = NewFileInfo->LastAccessTime.Year; - NewLastAccessSystemTime.wMonth = NewFileInfo->LastAccessTime.Month; - NewLastAccessSystemTime.wDay = NewFileInfo->LastAccessTime.Day; - NewLastAccessSystemTime.wHour = NewFileInfo->LastAccessTime.Hour; - NewLastAccessSystemTime.wMinute = NewFileInfo->LastAccessTime.Minute; - NewLastAccessSystemTime.wSecond = NewFileInfo->LastAccessTime.Second; - NewLastAccessSystemTime.wMilliseconds = 0; - - if (!PrivateFile->WinNtThunk->SystemTimeToFileTime ( - &NewLastAccessSystemTime, - &NewLastAccessFileTime - )) { - goto Done; - } - - if (!PrivateFile->WinNtThunk->LocalFileTimeToFileTime ( - &NewLastAccessFileTime, - &NewLastAccessFileTime - )) { - goto Done; - } - - NewLastWriteSystemTime.wYear = NewFileInfo->ModificationTime.Year; - NewLastWriteSystemTime.wMonth = NewFileInfo->ModificationTime.Month; - NewLastWriteSystemTime.wDay = NewFileInfo->ModificationTime.Day; - NewLastWriteSystemTime.wHour = NewFileInfo->ModificationTime.Hour; - NewLastWriteSystemTime.wMinute = NewFileInfo->ModificationTime.Minute; - NewLastWriteSystemTime.wSecond = NewFileInfo->ModificationTime.Second; - NewLastWriteSystemTime.wMilliseconds = 0; - - if (!PrivateFile->WinNtThunk->SystemTimeToFileTime ( - &NewLastWriteSystemTime, - &NewLastWriteFileTime - )) { - goto Done; - } - - if (!PrivateFile->WinNtThunk->LocalFileTimeToFileTime ( - &NewLastWriteFileTime, - &NewLastWriteFileTime - )) { - goto Done; - } - - if (!PrivateFile->WinNtThunk->SetFileTime ( - PrivateFile->IsDirectoryPath ? PrivateFile->DirHandle : PrivateFile->LHandle, - &NewCreationFileTime, - &NewLastAccessFileTime, - &NewLastWriteFileTime - )) { - Status = EFI_DEVICE_ERROR; - goto Done; - } - - } - - // - // No matter about AttrChangeFlag, Attribute must be set. - // Because operation before may cause attribute change. - // - NewAttr = OldAttr; - - if (NewFileInfo->Attribute & EFI_FILE_ARCHIVE) { - NewAttr |= FILE_ATTRIBUTE_ARCHIVE; - } else { - NewAttr &= ~FILE_ATTRIBUTE_ARCHIVE; - } - - if (NewFileInfo->Attribute & EFI_FILE_HIDDEN) { - NewAttr |= FILE_ATTRIBUTE_HIDDEN; - } else { - NewAttr &= ~FILE_ATTRIBUTE_HIDDEN; - } - - if (NewFileInfo->Attribute & EFI_FILE_SYSTEM) { - NewAttr |= FILE_ATTRIBUTE_SYSTEM; - } else { - NewAttr &= ~FILE_ATTRIBUTE_SYSTEM; - } - - if (NewFileInfo->Attribute & EFI_FILE_READ_ONLY) { - NewAttr |= FILE_ATTRIBUTE_READONLY; - } else { - NewAttr &= ~FILE_ATTRIBUTE_READONLY; - } - - NtStatus = PrivateFile->WinNtThunk->SetFileAttributes (NewFileName, NewAttr); - - if (!NtStatus) { - Status = EFI_DEVICE_ERROR; - goto Reopen; - } - -Done: - if (OldFileInfo != NULL) { - FreePool (OldFileInfo); - } - - if (OldFileName != NULL) { - FreePool (OldFileName); - } - - if (NewFileName != NULL) { - FreePool (NewFileName); - } - - gBS->RestoreTPL (OldTpl); - return Status; -} - -EFI_STATUS -EFIAPI -WinNtSimpleFileSystemFlush ( - IN EFI_FILE_PROTOCOL *This - ) -/*++ - -Routine Description: - - Flush all modified data to the media. - -Arguments: - - This - Pointer to an opened file handle. - -Returns: - - EFI_SUCCESS - The data has been flushed. - - EFI_NO_MEDIA - The device has no media. - - EFI_DEVICE_ERROR - The device reported an error. - - EFI_VOLUME_CORRUPTED - The file system structures have been corrupted. - - EFI_WRITE_PROTECTED - The file, directory, volume, or device is write protected. - - EFI_ACCESS_DENIED - The file was opened read-only. - - EFI_VOLUME_FULL - The volume is full. - ---*/ -// TODO: EFI_INVALID_PARAMETER - add return value to function comment -{ - BY_HANDLE_FILE_INFORMATION FileInfo; - WIN_NT_EFI_FILE_PRIVATE *PrivateFile; - EFI_STATUS Status; - EFI_TPL OldTpl; - - if (This == NULL) { - return EFI_INVALID_PARAMETER; - } - - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - - PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This); - - if (PrivateFile->LHandle == INVALID_HANDLE_VALUE) { - Status = EFI_DEVICE_ERROR; - goto Done; - } - - if (PrivateFile->IsDirectoryPath) { - Status = EFI_SUCCESS; - goto Done; - } - - if (PrivateFile->IsOpenedByRead) { - Status = EFI_ACCESS_DENIED; - goto Done; - } - - PrivateFile->WinNtThunk->GetFileInformationByHandle (PrivateFile->LHandle, &FileInfo); - - if (FileInfo.dwFileAttributes & FILE_ATTRIBUTE_READONLY) { - Status = EFI_ACCESS_DENIED; - goto Done; - } - - Status = PrivateFile->WinNtThunk->FlushFileBuffers (PrivateFile->LHandle) ? EFI_SUCCESS : EFI_DEVICE_ERROR; - -Done: - gBS->RestoreTPL (OldTpl); - return Status; - // - // bugbug: - Use Windows error reporting. - // -} - - diff --git a/Nt32Pkg/WinNtSimpleFileSystemDxe/WinNtSimpleFileSystem.h b/Nt32Pkg/WinNtSimpleFileSystemDxe/WinNtSimpleFileSystem.h deleted file mode 100644 index 5675e02c77..0000000000 --- a/Nt32Pkg/WinNtSimpleFileSystemDxe/WinNtSimpleFileSystem.h +++ /dev/null @@ -1,587 +0,0 @@ -/**@file - -Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - WinNtSimpleFileSystem.h - -Abstract: - - Produce Simple File System abstractions for a directory on your PC using Win32 APIs. - The configuration of what devices to mount or emulate comes from NT - environment variables. The variables must be visible to the Microsoft* - Developer Studio for them to work. - - * Other names and brands may be claimed as the property of others. - -**/ - -#ifndef _WIN_NT_SIMPLE_FILE_SYSTEM_H_ -#define _WIN_NT_SIMPLE_FILE_SYSTEM_H_ - - -#define WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE SIGNATURE_32 ('N', 'T', 'f', 's') - -typedef struct { - UINTN Signature; - EFI_WIN_NT_THUNK_PROTOCOL *WinNtThunk; - EFI_SIMPLE_FILE_SYSTEM_PROTOCOL SimpleFileSystem; - CHAR16 *FilePath; - CHAR16 *VolumeLabel; - EFI_UNICODE_STRING_TABLE *ControllerNameTable; -} WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE; - -#define WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS(a) \ - CR (a, \ - WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE, \ - SimpleFileSystem, \ - WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE \ - ) - -#define WIN_NT_EFI_FILE_PRIVATE_SIGNATURE SIGNATURE_32 ('l', 'o', 'f', 's') - -// -// Bit definitions for EFI_TIME.Daylight -// -#define EFI_TIME_ADJUST_DAYLIGHT 0x01 -#define EFI_TIME_IN_DAYLIGHT 0x02 - -typedef struct { - UINTN Signature; - EFI_WIN_NT_THUNK_PROTOCOL *WinNtThunk; - EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem; - EFI_FILE_PROTOCOL EfiFile; - HANDLE LHandle; - HANDLE DirHandle; - BOOLEAN IsRootDirectory; - BOOLEAN IsDirectoryPath; - BOOLEAN IsOpenedByRead; - CHAR16 *FilePath; - WCHAR *FileName; - BOOLEAN IsValidFindBuf; - WIN32_FIND_DATA FindBuf; -} WIN_NT_EFI_FILE_PRIVATE; - -#define WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS(a) \ - CR (a, \ - WIN_NT_EFI_FILE_PRIVATE, \ - EfiFile, \ - WIN_NT_EFI_FILE_PRIVATE_SIGNATURE \ - ) - -// -// Global Protocol Variables -// -extern EFI_DRIVER_BINDING_PROTOCOL gWinNtSimpleFileSystemDriverBinding; -extern EFI_COMPONENT_NAME_PROTOCOL gWinNtSimpleFileSystemComponentName; -extern EFI_COMPONENT_NAME2_PROTOCOL gWinNtSimpleFileSystemComponentName2; - -// -// Driver Binding protocol member functions -// -EFI_STATUS -EFIAPI -WinNtSimpleFileSystemDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL - ) -/*++ - -Routine Description: - - Check to see if the driver supports a given controller. - -Arguments: - - This - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL. - - ControllerHandle - EFI handle of the controller to test. - - RemainingDevicePath - Pointer to remaining portion of a device path. - -Returns: - - EFI_SUCCESS - The device specified by ControllerHandle and RemainingDevicePath is supported by the driver - specified by This. - - EFI_ALREADY_STARTED - The device specified by ControllerHandle and RemainingDevicePath is already being managed by - the driver specified by This. - - EFI_ACCESS_DENIED - The device specified by ControllerHandle and RemainingDevicePath is already being managed by - a different driver or an application that requires exclusive access. - - EFI_UNSUPPORTED - The device specified by ControllerHandle and RemainingDevicePath is not supported by the - driver specified by This. - ---*/ -; - -EFI_STATUS -EFIAPI -WinNtSimpleFileSystemDriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL - ) -/*++ - -Routine Description: - - Starts a device controller or a bus controller. - -Arguments: - - This - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL. - - ControllerHandle - EFI handle of the controller to start. - - RemainingDevicePath - Pointer to remaining portion of a device path. - -Returns: - - EFI_SUCCESS - The device or bus controller has been started. - - EFI_DEVICE_ERROR - The device could not be started due to a device failure. - - EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources. - ---*/ -; - -EFI_STATUS -EFIAPI -WinNtSimpleFileSystemDriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer OPTIONAL - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - This - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL. - - ControllerHandle - A handle to the device to be stopped. - - NumberOfChildren - The number of child device handles in ChildHandleBuffer. - - ChildHandleBuffer - An array of child device handles to be freed. - -Returns: - - EFI_SUCCESS - The device has been stopped. - - EFI_DEVICE_ERROR - The device could not be stopped due to a device failure. - ---*/ -; - -// -// Simple File System protocol member functions -// -EFI_STATUS -EFIAPI -WinNtSimpleFileSystemOpenVolume ( - IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This, - OUT EFI_FILE_PROTOCOL **Root - ) -/*++ - -Routine Description: - - Open the root directory on a volume. - -Arguments: - - This - A pointer to the volume to open. - - Root - A pointer to storage for the returned opened file handle of the root directory. - -Returns: - - EFI_SUCCESS - The volume was opened. - - EFI_UNSUPPORTED - The volume does not support the requested file system type. - - EFI_NO_MEDIA - The device has no media. - - EFI_DEVICE_ERROR - The device reported an error. - - EFI_VOLUME_CORRUPTED - The file system structures are corrupted. - - EFI_ACCESS_DENIED - The service denied access to the file. - - EFI_OUT_OF_RESOURCES - The file volume could not be opened due to lack of resources. - - EFI_MEDIA_CHANGED - The device has new media or the media is no longer supported. - ---*/ -; - -EFI_STATUS -EFIAPI -WinNtSimpleFileSystemOpen ( - IN EFI_FILE_PROTOCOL *This, - OUT EFI_FILE_PROTOCOL **NewHandle, - IN CHAR16 *FileName, - IN UINT64 OpenMode, - IN UINT64 Attributes - ) -/*++ - -Routine Description: - - Open a file relative to the source file location. - -Arguments: - - This - A pointer to the source file location. - - NewHandle - Pointer to storage for the new file handle. - - FileName - Pointer to the file name to be opened. - - OpenMode - File open mode information. - - Attributes - File creation attributes. - -Returns: - - EFI_SUCCESS - The file was opened. - - EFI_NOT_FOUND - The file could not be found in the volume. - - EFI_NO_MEDIA - The device has no media. - - EFI_MEDIA_CHANGED - The device has new media or the media is no longer supported. - - EFI_DEVICE_ERROR - The device reported an error. - - EFI_VOLUME_CORRUPTED - The file system structures are corrupted. - - EFI_WRITE_PROTECTED - The volume or file is write protected. - - EFI_ACCESS_DENIED - The service denied access to the file. - - EFI_OUT_OF_RESOURCES - Not enough resources were available to open the file. - - EFI_VOLUME_FULL - There is not enough space left to create the new file. - ---*/ -; - -EFI_STATUS -EFIAPI -WinNtSimpleFileSystemClose ( - IN EFI_FILE_PROTOCOL *This - ) -/*++ - -Routine Description: - - Close the specified file handle. - -Arguments: - - This - Pointer to a returned opened file handle. - -Returns: - - EFI_SUCCESS - The file handle has been closed. - ---*/ -; - -EFI_STATUS -EFIAPI -WinNtSimpleFileSystemDelete ( - IN EFI_FILE_PROTOCOL *This - ) -/*++ - -Routine Description: - - Close and delete a file. - -Arguments: - - This - Pointer to a returned opened file handle. - -Returns: - - EFI_SUCCESS - The file handle was closed and deleted. - - EFI_WARN_DELETE_FAILURE - The handle was closed but could not be deleted. - ---*/ -; - -EFI_STATUS -EFIAPI -WinNtSimpleFileSystemRead ( - IN EFI_FILE_PROTOCOL *This, - IN OUT UINTN *BufferSize, - OUT VOID *Buffer - ) -/*++ - -Routine Description: - - Read data from a file. - -Arguments: - - This - Pointer to a returned open file handle. - - BufferSize - On input, the size of the Buffer. On output, the number of bytes stored in the Buffer. - - Buffer - Pointer to the first byte of the read Buffer. - -Returns: - - EFI_SUCCESS - The data was read. - - EFI_NO_MEDIA - The device has no media. - - EFI_DEVICE_ERROR - The device reported an error. - - EFI_VOLUME_CORRUPTED - The file system structures are corrupted. - - EFI_BUFFER_TOO_SMALL - The supplied buffer size was too small to store the current directory entry. - *BufferSize has been updated with the size needed to complete the request. - ---*/ -; - -EFI_STATUS -EFIAPI -WinNtSimpleFileSystemWrite ( - IN EFI_FILE_PROTOCOL *This, - IN OUT UINTN *BufferSize, - IN VOID *Buffer - ) -/*++ - -Routine Description: - - Write data to a file. - -Arguments: - - This - Pointer to an opened file handle. - - BufferSize - On input, the number of bytes in the Buffer to write to the file. On output, the number of bytes - of data written to the file. - - Buffer - Pointer to the first by of data in the buffer to write to the file. - -Returns: - - EFI_SUCCESS - The data was written to the file. - - EFI_UNSUPPORTED - Writes to an open directory are not supported. - - EFI_NO_MEDIA - The device has no media. - - EFI_DEVICE_ERROR - The device reported an error. - - EFI_VOLUME_CORRUPTED - The file system structures are corrupt. - - EFI_WRITE_PROTECTED - The file, directory, volume, or device is write protected. - - EFI_ACCESS_DENIED - The file was opened read-only. - - EFI_VOLUME_FULL - The volume is full. - ---*/ -; - -EFI_STATUS -EFIAPI -WinNtSimpleFileSystemSetPosition ( - IN EFI_FILE_PROTOCOL *This, - IN UINT64 Position - ) -/*++ - -Routine Description: - - Set a file's current position. - -Arguments: - - This - Pointer to an opened file handle. - - Position - The byte position from the start of the file to set. - -Returns: - - EFI_SUCCESS - The file position has been changed. - - EFI_UNSUPPORTED - The seek request for non-zero is not supported for directories. - ---*/ -; - -EFI_STATUS -EFIAPI -WinNtSimpleFileSystemGetPosition ( - IN EFI_FILE_PROTOCOL *This, - OUT UINT64 *Position - ) -/*++ - -Routine Description: - - Get a file's current position. - -Arguments: - - This - Pointer to an opened file handle. - - Position - Pointer to storage for the current position. - -Returns: - - EFI_SUCCESS - The file position has been reported. - - EFI_UNSUPPORTED - Not valid for directories. - ---*/ -; - -EFI_STATUS -EFIAPI -WinNtSimpleFileSystemGetInfo ( - IN EFI_FILE_PROTOCOL *This, - IN EFI_GUID *InformationType, - IN OUT UINTN *BufferSize, - OUT VOID *Buffer - ) -/*++ - -Routine Description: - - Return information about a file or volume. - -Arguments: - - This - Pointer to an opened file handle. - - InformationType - GUID describing the type of information to be returned. - - BufferSize - On input, the size of the information buffer. On output, the number of bytes written to the - information buffer. - - Buffer - Pointer to the first byte of the information buffer. - -Returns: - - EFI_SUCCESS - The requested information has been written into the buffer. - - EFI_UNSUPPORTED - The InformationType is not known. - - EFI_NO_MEDIA - The device has no media. - - EFI_DEVICE_ERROR - The device reported an error. - - EFI_VOLUME_CORRUPTED - The file system structures are corrupt. - - EFI_BUFFER_TOO_SMALL - The buffer size was too small to contain the requested information. The buffer size has - been updated with the size needed to complete the requested operation. - ---*/ -; - -EFI_STATUS -EFIAPI -WinNtSimpleFileSystemSetInfo ( - IN EFI_FILE_PROTOCOL *This, - IN EFI_GUID *InformationType, - IN UINTN BufferSize, - IN VOID *Buffer - ) -/*++ - -Routine Description: - - Set information about a file or volume. - -Arguments: - - This - Pointer to an opened file handle. - - InformationType - GUID identifying the type of information to set. - - BufferSize - Number of bytes of data in the information buffer. - - Buffer - Pointer to the first byte of data in the information buffer. - -Returns: - - EFI_SUCCESS - The file or volume information has been updated. - - EFI_UNSUPPORTED - The information identifier is not recognised. - - EFI_NO_MEDIA - The device has no media. - - EFI_DEVICE_ERROR - The device reported an error. - - EFI_VOLUME_CORRUPTED - The file system structures are corrupt. - - EFI_WRITE_PROTECTED - The file, directory, volume, or device is write protected. - - EFI_ACCESS_DENIED - The file was opened read-only. - - EFI_VOLUME_FULL - The volume is full. - - EFI_BAD_BUFFER_SIZE - The buffer size is smaller than the type indicated by InformationType. - ---*/ -; - -EFI_STATUS -EFIAPI -WinNtSimpleFileSystemFlush ( - IN EFI_FILE_PROTOCOL *This - ) -/*++ - -Routine Description: - - Flush all modified data to the media. - -Arguments: - - This - Pointer to an opened file handle. - -Returns: - - EFI_SUCCESS - The data has been flushed. - - EFI_NO_MEDIA - The device has no media. - - EFI_DEVICE_ERROR - The device reported an error. - - EFI_VOLUME_CORRUPTED - The file system structures have been corrupted. - - EFI_WRITE_PROTECTED - The file, directory, volume, or device is write protected. - - EFI_ACCESS_DENIED - The file was opened read-only. - - EFI_VOLUME_FULL - The volume is full. - ---*/ -; - -#endif /* _WIN_NT_SIMPLE_FILE_SYSTEM_H_ */ - -/* eof - WinNtSimpleFileSystem.h */ diff --git a/Nt32Pkg/WinNtSimpleFileSystemDxe/WinNtSimpleFileSystemDxe.inf b/Nt32Pkg/WinNtSimpleFileSystemDxe/WinNtSimpleFileSystemDxe.inf deleted file mode 100644 index 167cbb4ede..0000000000 --- a/Nt32Pkg/WinNtSimpleFileSystemDxe/WinNtSimpleFileSystemDxe.inf +++ /dev/null @@ -1,63 +0,0 @@ -## @file -# Simple filesystem driver -# -# Produce Simple File System abstractions for directories on your PC using Win32 APIs. -# The configuration of what devices to mount or emulate comes from NT -# environment variables. The variables must be visible to the Microsoft* -# Developer Studio for them to work. -# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
-# -# SPDX-License-Identifier: BSD-2-Clause-Patent -# -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = WinNtSimpleFileSystemDxe - FILE_GUID = 9C25E18B-76BA-43da-A132-DBB0997CEFEF - MODULE_TYPE = UEFI_DRIVER - VERSION_STRING = 1.0 - - ENTRY_POINT = InitializeWinNtSimpleFileSystem - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 -# -# DRIVER_BINDING = gWinNtSimpleFileSystemDriverBinding -# COMPONENT_NAME = gWinNtSimpleFileSystemComponentName -# - -[Sources] - ComponentName.c - WinNtSimpleFileSystem.c - WinNtSimpleFileSystem.h - -[Packages] - MdePkg/MdePkg.dec - Nt32Pkg/Nt32Pkg.dec - - -[LibraryClasses] - MemoryAllocationLib - UefiBootServicesTableLib - BaseMemoryLib - UefiLib - UefiDriverEntryPoint - BaseLib - DebugLib - - -[Guids] - gEfiFileSystemVolumeLabelInfoIdGuid # SOMETIMES_CONSUMED - gEfiFileInfoGuid # SOMETIMES_CONSUMED - gEfiFileSystemInfoGuid # SOMETIMES_CONSUMED - gEfiWinNtFileSystemGuid # ALWAYS_CONSUMED - - -[Protocols] - gEfiSimpleFileSystemProtocolGuid # PROTOCOL BY_START - gEfiWinNtIoProtocolGuid # PROTOCOL TO_START - diff --git a/Nt32Pkg/WinNtThunkDxe/WinNtThunk.c b/Nt32Pkg/WinNtThunkDxe/WinNtThunk.c deleted file mode 100644 index e2985edd7e..0000000000 --- a/Nt32Pkg/WinNtThunkDxe/WinNtThunk.c +++ /dev/null @@ -1,99 +0,0 @@ -/**@file - -Copyright (c) 2006, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - WinNtThunk.c - -Abstract: - - Produce WinNtThunk protocol and it's associated device path and controller - state protocols. WinNtThunk is to the NT emulation environment as - PCI_ROOT_BRIGE is to real hardware. The WinNtBusDriver is the child of this - driver. - - Since we are a root hardware abstraction we do not install a Driver Binding - protocol on this handle. This driver can only support one one WinNtThunk protocol - in the system, since the device path is hard coded. - -**/ - -// -// The package level header files this module uses -// -#include -#include -// -// The protocols, PPI and GUID defintions for this module -// -#include -#include -// -// The Library classes this module consumes -// -#include -#include -#include -#include - -#include "WinNtThunk.h" - -// -// WinNtThunk Device Path Protocol Instance -// -WIN_NT_THUNK_DEVICE_PATH mWinNtThunkDevicePath = { - { - HARDWARE_DEVICE_PATH, - HW_VENDOR_DP, - (UINT8) (sizeof (VENDOR_DEVICE_PATH)), - (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8), - EFI_WIN_NT_THUNK_PROTOCOL_GUID, - }, - { - END_DEVICE_PATH_TYPE, - END_ENTIRE_DEVICE_PATH_SUBTYPE, - END_DEVICE_PATH_LENGTH, - 0 - } -}; - - -EFI_STATUS -EFIAPI -InitializeWinNtThunk ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -/*++ - -Routine Description: - Install WinNtThunk Protocol and it's associated Device Path protocol - -Arguments: - (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT) - -Returns: - EFI_SUCEESS - WinNtThunk protocol is added or error status from - gBS->InstallMultiProtocolInterfaces(). - ---*/ -// TODO: ImageHandle - add argument and description to function comment -// TODO: SystemTable - add argument and description to function comment -{ - EFI_STATUS Status; - EFI_HANDLE ControllerHandle; - - ControllerHandle = NULL; - Status = gBS->InstallMultipleProtocolInterfaces ( - &ControllerHandle, - &gEfiWinNtThunkProtocolGuid, - gWinNt, - &gEfiDevicePathProtocolGuid, - &mWinNtThunkDevicePath, - NULL - ); - - return Status; -} diff --git a/Nt32Pkg/WinNtThunkDxe/WinNtThunk.h b/Nt32Pkg/WinNtThunkDxe/WinNtThunk.h deleted file mode 100644 index dd4536de14..0000000000 --- a/Nt32Pkg/WinNtThunkDxe/WinNtThunk.h +++ /dev/null @@ -1,28 +0,0 @@ -/**@file - -Copyright (c) 2006, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - WinNtThunk.h - -Abstract: - -**/ - -#ifndef _WIN_NT_THUNK_H_ -#define _WIN_NT_THUNK_H_ - -// TODO: add protective #ifndef - - -// -// WinNtThunk Device Path Protocol Instance Type -// -typedef struct { - VENDOR_DEVICE_PATH Vendor; - EFI_DEVICE_PATH_PROTOCOL EndDevicePath; -} WIN_NT_THUNK_DEVICE_PATH; - -#endif diff --git a/Nt32Pkg/WinNtThunkDxe/WinNtThunkDxe.inf b/Nt32Pkg/WinNtThunkDxe/WinNtThunkDxe.inf deleted file mode 100644 index fa1d097224..0000000000 --- a/Nt32Pkg/WinNtThunkDxe/WinNtThunkDxe.inf +++ /dev/null @@ -1,46 +0,0 @@ -## @file -# A DXE driver to produce EFI_WIN_NT_THUNK_PROTOCOL -# -# EFI_WIN_NT_THUNK_PROTOCOL is a table of pointers to various Windows APIs used by various drivers to accomplish certain task in an NT32 emulator. -# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
-# -# SPDX-License-Identifier: BSD-2-Clause-Patent -# -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = WinNtThunkDxe - FILE_GUID = 0C95A916-A006-11d4-BCFA-0080C73C8881 - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - - ENTRY_POINT = InitializeWinNtThunk - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 -# - -[Sources] - WinNtThunk.c - WinNtThunk.h - - -[Packages] - MdePkg/MdePkg.dec - Nt32Pkg/Nt32Pkg.dec - -[LibraryClasses] - UefiBootServicesTableLib - WinNtLib - UefiDriverEntryPoint - -[Protocols] - gEfiDevicePathProtocolGuid # PROTOCOL ALWAYS_PRODUCED - gEfiWinNtThunkProtocolGuid # PROTOCOL ALWAYS_PRODUCED - -[depex] - TRUE \ No newline at end of file diff --git a/Nt32Pkg/WinNtThunkPPIToProtocolPei/WinNtThunkPPIToProtocol.c b/Nt32Pkg/WinNtThunkPPIToProtocolPei/WinNtThunkPPIToProtocol.c deleted file mode 100644 index d63a5b667d..0000000000 --- a/Nt32Pkg/WinNtThunkPPIToProtocolPei/WinNtThunkPPIToProtocol.c +++ /dev/null @@ -1,82 +0,0 @@ -/**@file - -Copyright (c) 2006, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - WinNtStuff.c - -Abstract: - - Tiano PEIM to abstract construction of firmware volume in a Windows NT environment. - -Revision History - -**/ - -// -// The package level header files this module uses -// -#include -#include -// -// The protocols, PPI and GUID defintions for this module -// -#include -#include -// -// The Library classes this module consumes -// -#include -#include -#include - -EFI_STATUS -EFIAPI -PeimInitializeWinNtThunkPPIToProtocolPeim ( - IN EFI_FFS_FILE_HEADER *FfsHeader, - IN EFI_PEI_SERVICES **PeiServices - ) -/*++ - -Routine Description: - - Perform a call-back into the SEC simulator to get NT Stuff - -Arguments: - - PeiServices - General purpose services available to every PEIM. - -Returns: - - None - ---*/ -// TODO: FfsHeader - add argument and description to function comment -{ - EFI_STATUS Status; - EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor; - PEI_NT_THUNK_PPI *PeiNtService; - VOID *Ptr; - - DEBUG ((EFI_D_ERROR, "NT 32 WinNT Stuff PEIM Loaded\n")); - - Status = (**PeiServices).LocatePpi ( - (const EFI_PEI_SERVICES **)PeiServices, - &gPeiNtThunkPpiGuid, // GUID - 0, // INSTANCE - &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR - (VOID**)&PeiNtService // PPI - ); - ASSERT_EFI_ERROR (Status); - - Ptr = PeiNtService->NtThunk (); - - BuildGuidDataHob ( - &gEfiWinNtThunkProtocolGuid, // Guid - &Ptr, // Buffer - sizeof (VOID *) // Sizeof Buffer - ); - return Status; -} diff --git a/Nt32Pkg/WinNtThunkPPIToProtocolPei/WinNtThunkPPIToProtocolPei.inf b/Nt32Pkg/WinNtThunkPPIToProtocolPei/WinNtThunkPPIToProtocolPei.inf deleted file mode 100644 index af8043ccc6..0000000000 --- a/Nt32Pkg/WinNtThunkPPIToProtocolPei/WinNtThunkPPIToProtocolPei.inf +++ /dev/null @@ -1,49 +0,0 @@ -## @file -# Stuff driver -# -# Tiano PEIM to abstract construction of firmware volume in a Windows NT environment. -# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
-# -# SPDX-License-Identifier: BSD-2-Clause-Patent -# -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = WinNtThunkPPIToProtocolPei - FILE_GUID = D3AAD8DC-3A48-46ac-B1C7-28A9D3CF6755 - MODULE_TYPE = PEIM - VERSION_STRING = 1.0 - - ENTRY_POINT = PeimInitializeWinNtThunkPPIToProtocolPeim - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 -# - -[Sources] - WinNtThunkPPIToProtocol.c - -[Packages] - MdePkg/MdePkg.dec - Nt32Pkg/Nt32Pkg.dec - - -[LibraryClasses] - HobLib - PeimEntryPoint - DebugLib - - -[Protocols] - gEfiWinNtThunkProtocolGuid # PROTOCOL ALWAYS_CONSUMED - - -[Ppis] - gPeiNtThunkPpiGuid # PPI ALWAYS_CONSUMED - -[depex] - gPeiNtThunkPpiGuid AND gEfiPeiMemoryDiscoveredPpiGuid \ No newline at end of file