Port EdkUnixPkg to UnixPkg. The changes are listed as follows:

1. change *.msa to *.inf, and create platform configuration files .dec&.dsc&.fdf to comply with Edk2 build process
2. using PCD mechanism to replace macro.
3. change Sec code to cowork with PI1.0 Pei Core and produce temparory memory ppi. 

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5380 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
eric_tian 2008-06-30 05:08:49 +00:00
parent 27d55a2d56
commit 804405e7d1
165 changed files with 30405 additions and 0 deletions

View File

@ -0,0 +1,101 @@
/**@file
Copyright (c) 2006 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
BootMode.c
Abstract:
Tiano PEIM to provide the platform support functionality within Unix
**/
//
// The package level header files this module uses
//
#include <PiPei.h>
//
// The protocols, PPI and GUID defintions for this module
//
#include <Ppi/MasterBootMode.h>
#include <Ppi/BootInRecoveryMode.h>
//
// The Library classes this module consumes
//
#include <Library/DebugLib.h>
#include <Library/PeimEntryPoint.h>
//
// 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_FFS_FILE_HEADER *FfsHeader,
IN EFI_PEI_SERVICES **PeiServices
)
/*++
Routine Description:
Peform the boot mode determination logic
Arguments:
PeiServices - General purpose services available to every PEIM.
Returns:
Status - EFI_SUCCESS if the boot mode could be set
--*/
// TODO: FfsHeader - add argument and description to function comment
{
EFI_STATUS Status;
UINTN BootMode;
DEBUG ((EFI_D_ERROR, "Unix 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;
}

View File

@ -0,0 +1,57 @@
#/** @file
# Component description file for BootMode module
#
# This module provides platform specific function to detect boot mode.
# Copyright (c) 2006 - 2008, Intel Corporation
#
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#
#**/
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = BootModePei
FILE_GUID = f3ff9aee-8985-11db-b133-0040d02b1835
MODULE_TYPE = PEIM
VERSION_STRING = 1.0
EDK_RELEASE_VERSION = 0x00020000
EFI_SPECIFICATION_VERSION = 0x00020000
ENTRY_POINT = InitializeBootMode
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources.common]
BootModePei.c
[Packages]
MdePkg/MdePkg.dec
[LibraryClasses]
PeiServicesTablePointerLib
PeiServicesLib
BaseLib
PeimEntryPoint
DebugLib
[Ppis]
gEfiPeiMasterBootModePpiGuid # PPI ALWAYS_PRODUCED
gEfiPeiBootInRecoveryModePpiGuid # PPI SOMETIMES_PRODUCED
[Depex]
TRUE

View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">
<MsaHeader>
<ModuleName>BootMode</ModuleName>
<ModuleType>PEIM</ModuleType>
<GuidValue>f3ff9aee-8985-11db-b133-0040d02b1835</GuidValue>
<Version>1.0</Version>
<Abstract>Component description file for BootMode module</Abstract>
<Description>This module provides platform specific function to detect boot mode.</Description>
<Copyright>Copyright (c) 2006, Intel Corporation</Copyright>
<License>All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
</MsaHeader>
<ModuleDefinitions>
<SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
<BinaryModule>false</BinaryModule>
<OutputFileBasename>BootMode</OutputFileBasename>
</ModuleDefinitions>
<LibraryClassDefinitions>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>DebugLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>PeimEntryPoint</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>BaseLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>PeiServicesLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>PeiServicesTablePointerLib</Keyword>
</LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>BootMode.c</Filename>
<Filename>BootMode.dxs</Filename>
</SourceFiles>
<PackageDependencies>
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
<Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>
</PackageDependencies>
<PPIs>
<Ppi Usage="SOMETIMES_PRODUCED">
<PpiCName>gEfiPeiBootInRecoveryModePpiGuid</PpiCName>
</Ppi>
<Ppi Usage="ALWAYS_PRODUCED">
<PpiCName>gEfiPeiMasterBootModePpiGuid</PpiCName>
</Ppi>
</PPIs>
<Externs>
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
<Extern>
<ModuleEntryPoint>InitializeBootMode</ModuleEntryPoint>
</Extern>
</Externs>
</ModuleSurfaceArea>

536
UnixPkg/CpuRuntimeDxe/Cpu.c Normal file
View File

@ -0,0 +1,536 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
Cpu.c
Abstract:
Unix 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 "PiDxe.h"
#include <Protocol/Cpu.h>
#include <Protocol/DataHub.h>
#include <Guid/DataHubRecords.h>
#include <Protocol/CpuIo.h>
#include <Protocol/FrameworkHii.h>
#include <Guid/DataHubProducer.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/HiiLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Framework/DataHubRecords.h>
#include "CpuDriver.h"
#include "UnixDxe.h"
#include <Protocol/UnixIo.h>
#define EFI_CPU_DATA_MAXIMUM_LENGTH 0x100
CPU_ARCH_PROTOCOL_PRIVATE mCpuTemplate = {
CPU_ARCH_PROT_PRIVATE_SIGNATURE,
NULL,
{
UnixFlushCpuDataCache,
UnixEnableInterrupt,
UnixDisableInterrupt,
UnixGetInterruptState,
UnixInit,
UnixRegisterInterruptHandler,
UnixGetTimerValue,
UnixSetMemoryAttributes,
0,
4
},
{
CpuMemoryServiceRead,
CpuMemoryServiceWrite,
CpuIoServiceRead,
CpuIoServiceWrite
},
0,
TRUE
};
typedef union {
EFI_CPU_DATA_RECORD *DataRecord;
UINT8 *Raw;
} EFI_CPU_DATA_RECORD_BUFFER;
EFI_SUBCLASS_TYPE1_HEADER mCpuDataRecordHeader = {
EFI_PROCESSOR_SUBCLASS_VERSION, // Version
sizeof (EFI_SUBCLASS_TYPE1_HEADER), // Header Size
0, // Instance, Initialize later
EFI_SUBCLASS_INSTANCE_NON_APPLICABLE, // SubInstance
0 // RecordType, Initialize later
};
//
// Service routines for the driver
//
EFI_STATUS
EFIAPI
UnixFlushCpuDataCache (
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 UNIX 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 UNIX emulator
// environment. Classify this to follow EFI spec
//
return EFI_SUCCESS;
}
//
// Other flush types are not supported by UNIX emulator
//
return EFI_UNSUPPORTED;
}
EFI_STATUS
EFIAPI
UnixEnableInterrupt (
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
UnixDisableInterrupt (
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
UnixGetInterruptState (
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
UnixInit (
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
{
CPU_ARCH_PROTOCOL_PRIVATE *Private;
Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);
return EFI_UNSUPPORTED;
}
EFI_STATUS
EFIAPI
UnixRegisterInterruptHandler (
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
{
CPU_ARCH_PROTOCOL_PRIVATE *Private;
//
// Do parameter checking for EFI spec conformance
//
if (InterruptType < 0 || InterruptType > 0xff) {
return EFI_UNSUPPORTED;
}
//
// Do nothing for Nt32 emulation
//
Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);
return EFI_UNSUPPORTED;
}
EFI_STATUS
EFIAPI
UnixGetTimerValue (
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;
}
//
// No timer supported
//
return EFI_UNSUPPORTED;
}
EFI_STATUS
EFIAPI
UnixSetMemoryAttributes (
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
{
CPU_ARCH_PROTOCOL_PRIVATE *Private;
//
// Check for invalid parameter for Spec conformance
//
if (Length == 0) {
return EFI_INVALID_PARAMETER;
}
//
// Do nothing for Nt32 emulation
//
Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);
return EFI_UNSUPPORTED;
}
VOID
CpuUpdateDataHub (
VOID
)
/*++
Routine Description:
This function will log processor version and frequency data to data hub.
Arguments:
Event - Event whose notification function is being invoked.
Context - Pointer to the notification function's context.
Returns:
None.
--*/
{
EFI_STATUS Status;
EFI_CPU_DATA_RECORD_BUFFER RecordBuffer;
UINT32 HeaderSize;
UINT32 TotalSize;
EFI_DATA_HUB_PROTOCOL *DataHub;
EFI_HII_HANDLE HiiHandle;
//
// Locate DataHub protocol.
//
Status = gBS->LocateProtocol (&gEfiDataHubProtocolGuid, NULL, &DataHub);
if (EFI_ERROR (Status)) {
return;
}
//
// Initialize data record header
//
mCpuDataRecordHeader.Instance = 1;
HeaderSize = sizeof (EFI_SUBCLASS_TYPE1_HEADER);
RecordBuffer.Raw = AllocatePool (HeaderSize + EFI_CPU_DATA_MAXIMUM_LENGTH);
if (RecordBuffer.Raw == NULL) {
return ;
}
//
// Initialize strings to HII database
//
HiiLibAddPackages (1, &gEfiProcessorProducerGuid, NULL, &HiiHandle, CpuStrings);
CopyMem (RecordBuffer.Raw, &mCpuDataRecordHeader, HeaderSize);
RecordBuffer.DataRecord->DataRecordHeader.RecordType = ProcessorVersionRecordType;
RecordBuffer.DataRecord->VariableRecord.ProcessorVersion = STRING_TOKEN (STR_INTEL_GENUINE_PROCESSOR);
TotalSize = HeaderSize + sizeof (EFI_PROCESSOR_VERSION_DATA);
Status = DataHub->LogData (
DataHub,
&gEfiProcessorSubClassGuid,
&gEfiProcessorProducerGuid,
EFI_DATA_RECORD_CLASS_DATA,
RecordBuffer.Raw,
TotalSize
);
//
// Store CPU frequency data record to data hub - It's an emulator so make up a value
//
RecordBuffer.DataRecord->DataRecordHeader.RecordType = ProcessorCoreFrequencyRecordType;
RecordBuffer.DataRecord->VariableRecord.ProcessorCoreFrequency.Value = 1234;
RecordBuffer.DataRecord->VariableRecord.ProcessorCoreFrequency.Exponent = 6;
TotalSize = HeaderSize + sizeof (EFI_PROCESSOR_CORE_FREQUENCY_DATA);
Status = DataHub->LogData (
DataHub,
&gEfiProcessorSubClassGuid,
&gEfiProcessorProducerGuid,
EFI_DATA_RECORD_CLASS_DATA,
RecordBuffer.Raw,
TotalSize
);
FreePool (RecordBuffer.Raw);
}
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
--*/
// TODO: SystemTable - add argument and description to function comment
{
EFI_STATUS Status;
CpuUpdateDataHub ();
Status = gBS->InstallMultipleProtocolInterfaces (
&mCpuTemplate.Handle,
&gEfiCpuArchProtocolGuid, &mCpuTemplate.Cpu,
&gEfiCpuIoProtocolGuid, &mCpuTemplate.CpuIo,
NULL
);
ASSERT_EFI_ERROR (Status);
DEBUG ((EFI_D_ERROR, "CPU Architectural Protocol Loaded\n"));
return Status;
}

View File

@ -0,0 +1,73 @@
#/** @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 - 2008, Intel Corporation
#
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#
#**/
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = Cpu
FILE_GUID = f3794b60-8985-11db-8e53-0040d02b1835
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
EDK_RELEASE_VERSION = 0x00020000
EFI_SPECIFICATION_VERSION = 0x00020000
ENTRY_POINT = InitializeCpu
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources.common]
CpuIo.c
Cpu.c
CpuDriver.h
Strings.uni
[Packages]
IntelFrameworkPkg/IntelFrameworkPkg.dec
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
UnixPkg/UnixPkg.dec
MdePkg/MdePkg.dec
[LibraryClasses]
UefiBootServicesTableLib
MemoryAllocationLib
BaseMemoryLib
UefiDriverEntryPoint
UefiLib
HiiLib
DebugLib
BaseLib
[Guids]
gEfiProcessorSubClassGuid # SOMETIMES_CONSUMED
gEfiProcessorProducerGuid # SOMETIMES_CONSUMED
[Protocols]
gEfiUnixIoProtocolGuid # PROTOCOL_NOTIFY SOMETIMES_CONSUMED
gEfiDataHubProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
gEfiHiiProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
gEfiCpuIoProtocolGuid # PROTOCOL ALWAYS_PRODUCED
gEfiCpuArchProtocolGuid # PROTOCOL ALWAYS_PRODUCED
[Depex]
gEfiDataHubProtocolGuid

View File

@ -0,0 +1,108 @@
<?xml version="1.0" encoding="UTF-8"?>
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">
<MsaHeader>
<ModuleName>Cpu</ModuleName>
<ModuleType>DXE_DRIVER</ModuleType>
<GuidValue>f3794b60-8985-11db-8e53-0040d02b1835</GuidValue>
<Version>1.0</Version>
<Abstract>Component description file for Cpu module.</Abstract>
<Description>This CPU module abstracts the interrupt subsystem of a platform and the CPU-specific setjump-long pair.</Description>
<Copyright>Copyright (c) 2006, Intel Corporation</Copyright>
<License>All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
</MsaHeader>
<ModuleDefinitions>
<SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
<BinaryModule>false</BinaryModule>
<OutputFileBasename>Cpu</OutputFileBasename>
</ModuleDefinitions>
<LibraryClassDefinitions>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>BaseLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>DebugLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>HiiLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UefiLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UefiDriverEntryPoint</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>BaseMemoryLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>MemoryAllocationLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UefiBootServicesTableLib</Keyword>
</LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>Strings.uni</Filename>
<Filename>CpuDriver.h</Filename>
<Filename>Cpu.c</Filename>
<Filename>CpuIo.c</Filename>
<Filename>Cpu.dxs</Filename>
</SourceFiles>
<PackageDependencies>
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
<Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>
</PackageDependencies>
<Protocols>
<Protocol Usage="ALWAYS_PRODUCED">
<ProtocolCName>gEfiCpuArchProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="ALWAYS_PRODUCED">
<ProtocolCName>gEfiCpuIoProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="SOMETIMES_CONSUMED">
<ProtocolCName>gEfiHiiProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="SOMETIMES_CONSUMED">
<ProtocolCName>gEfiDataHubProtocolGuid</ProtocolCName>
</Protocol>
<ProtocolNotify Usage="SOMETIMES_CONSUMED">
<ProtocolNotifyCName>gEfiUnixIoProtocolGuid</ProtocolNotifyCName>
</ProtocolNotify>
</Protocols>
<DataHubs>
<DataHubRecord Usage="SOMETIMES_PRODUCED">
<DataHubCName>ProcessorVersion</DataHubCName>
</DataHubRecord>
<DataHubRecord Usage="SOMETIMES_PRODUCED">
<DataHubCName>ProcessorCoreFrequency</DataHubCName>
</DataHubRecord>
</DataHubs>
<Guids>
<GuidCNames Usage="SOMETIMES_CONSUMED">
<GuidCName>gEfiProcessorProducerGuid</GuidCName>
</GuidCNames>
<GuidCNames Usage="SOMETIMES_CONSUMED">
<GuidCName>gEfiProcessorSubClassGuid</GuidCName>
</GuidCNames>
<GuidCNames Usage="SOMETIMES_CONSUMED">
<GuidCName>gEfiUnixCPUModelGuid</GuidCName>
</GuidCNames>
<GuidCNames Usage="SOMETIMES_CONSUMED">
<GuidCName>gEfiUnixCPUSpeedGuid</GuidCName>
</GuidCNames>
</Guids>
<Externs>
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
<Extern>
<ModuleEntryPoint>InitializeCpu</ModuleEntryPoint>
</Extern>
</Externs>
</ModuleSurfaceArea>

View File

@ -0,0 +1,163 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
CpuDriver.h
Abstract:
UNIX Emulation Architectural Protocol Driver as defined in Tiano.
--*/
#ifndef _CPU_ARCHITECTURAL_PROTOCOL_DRIVER_H_
#define _CPU_ARCHITECTURAL_PROTOCOL_DRIVER_H_
extern UINT8 CpuStrings[];
//
// Internal Data Structures
//
#define CPU_ARCH_PROT_PRIVATE_SIGNATURE EFI_SIGNATURE_32 ('c', 'a', 'p', 'd')
typedef struct {
UINTN Signature;
EFI_HANDLE Handle;
EFI_CPU_ARCH_PROTOCOL Cpu;
EFI_CPU_IO_PROTOCOL CpuIo;
//
// Local Data for CPU interface goes here
//
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_IO_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_IO_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_IO_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_IO_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
UnixFlushCpuDataCache (
IN EFI_CPU_ARCH_PROTOCOL *This,
IN EFI_PHYSICAL_ADDRESS Start,
IN UINT64 Length,
IN EFI_CPU_FLUSH_TYPE FlushType
);
EFI_STATUS
EFIAPI
UnixEnableInterrupt (
IN EFI_CPU_ARCH_PROTOCOL *This
);
EFI_STATUS
EFIAPI
UnixDisableInterrupt (
IN EFI_CPU_ARCH_PROTOCOL *This
);
EFI_STATUS
EFIAPI
UnixGetInterruptState (
IN EFI_CPU_ARCH_PROTOCOL *This,
OUT BOOLEAN *State
);
EFI_STATUS
EFIAPI
UnixInit (
IN EFI_CPU_ARCH_PROTOCOL *This,
IN EFI_CPU_INIT_TYPE InitType
);
EFI_STATUS
EFIAPI
UnixRegisterInterruptHandler (
IN EFI_CPU_ARCH_PROTOCOL *This,
IN EFI_EXCEPTION_TYPE InterruptType,
IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
);
EFI_STATUS
EFIAPI
UnixGetTimerValue (
IN EFI_CPU_ARCH_PROTOCOL *This,
IN UINT32 TimerIndex,
OUT UINT64 *TimerValue,
OUT UINT64 *TimerPeriod OPTIONAL
);
EFI_STATUS
EFIAPI
UnixSetMemoryAttributes (
IN EFI_CPU_ARCH_PROTOCOL *This,
IN EFI_PHYSICAL_ADDRESS BaseAddress,
IN UINT64 Length,
IN UINT64 Attributes
);
#endif

View File

@ -0,0 +1,350 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
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 "PiDxe.h"
#include <Protocol/Cpu.h>
#include <Protocol/DataHub.h>
#include <Guid/DataHubRecords.h>
#include <Protocol/CpuIo.h>
#include <Protocol/FrameworkHii.h>
#include <Guid/DataHubProducer.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/HiiLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <CpuDriver.h>
#define IA32_MAX_IO_ADDRESS 0xFFFF
#define IA32_MAX_MEM_ADDRESS 0xFFFFFFFF
EFI_CPU_IO_PROTOCOL mCpuIoProtocol;
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_IO_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;
}
Status = CpuIoCheckAddressRange (Width, Address, Count, Buffer, IA32_MAX_MEM_ADDRESS);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Do nothing for Nt32 version
//
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
CpuMemoryServiceWrite (
IN EFI_CPU_IO_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;
}
Status = CpuIoCheckAddressRange (Width, Address, Count, Buffer, IA32_MAX_MEM_ADDRESS);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Do nothing for Nt32 version
//
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
CpuIoServiceRead (
IN EFI_CPU_IO_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 >= 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_SUCCESS;
}
EFI_STATUS
EFIAPI
CpuIoServiceWrite (
IN EFI_CPU_IO_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 >= 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_SUCCESS;
}
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 = Width & 0x03;
if (Address - 1 + (1 << Width) * Count > Limit) {
return EFI_UNSUPPORTED;
}
AlignMask = (1 << Width) - 1;
if ((UINTN) Buffer & AlignMask) {
return EFI_UNSUPPORTED;
}
return EFI_SUCCESS;
}

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,156 @@
/*++
Copyright (c) 2006 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
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.
--*/
#include "PiDxe.h"
#include <Guid/EventGroup.h>
#include <Protocol/FvbExtension.h>
#include <Protocol/FirmwareVolumeBlock.h>
#include <Guid/AlternateFvBlock.h>
#include <Protocol/DevicePath.h>
#include <Library/UefiLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/BaseLib.h>
#include <Library/DxeServicesTableLib.h>
#include <Library/UefiRuntimeLib.h>
#include <Library/DebugLib.h>
#include <Library/HobLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/PcdLib.h>
#include <Guid/FirmwareFileSystem2.h>
#include <Guid/SystemNvDataGuid.h>
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 (PcdUnixFlashFvRecoverySize),
{
{
0,
}, // ZeroVector[16]
EFI_FIRMWARE_FILE_SYSTEM2_GUID,
FixedPcdGet32 (PcdUnixFlashFvRecoverySize),
EFI_FVH_SIGNATURE,
EFI_FVB2_READ_ENABLED_CAP |
EFI_FVB2_READ_STATUS |
EFI_FVB2_WRITE_ENABLED_CAP |
EFI_FVB2_WRITE_STATUS |
EFI_FVB2_ERASE_POLARITY,
sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),
0, // CheckSum
0, // ExtHeaderOffset
{
0,
}, // Reserved[1]
1, // Revision
{
{
FixedPcdGet32 (PcdUnixFlashFvRecoverySize)/FixedPcdGet32 (PcdUnixFirmwareBlockSize),
FixedPcdGet32 (PcdUnixFirmwareBlockSize),
}
}
},
{
{
0,
0
}
}
},
//
// Systen NvStorage FVB
//
{
FixedPcdGet32 (PcdFlashNvStorageVariableSize) + \
FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + \
FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + \
FixedPcdGet32 (PcdUnixFlashNvStorageEventLogSize),
{
{
0,
}, // ZeroVector[16]
EFI_SYSTEM_NV_DATA_HOB_GUID,
FixedPcdGet32 (PcdFlashNvStorageVariableSize) + \
FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + \
FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + \
FixedPcdGet32 (PcdUnixFlashNvStorageEventLogSize),
EFI_FVH_SIGNATURE,
EFI_FVB2_READ_ENABLED_CAP |
EFI_FVB2_READ_STATUS |
EFI_FVB2_WRITE_ENABLED_CAP |
EFI_FVB2_WRITE_STATUS |
EFI_FVB2_ERASE_POLARITY,
sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),
0, // CheckSum
0, // ExtHeaderOffset
{
0,
}, // Reserved[1]
1, // Revision
{
{
(FixedPcdGet32 (PcdFlashNvStorageVariableSize) + \
FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + \
FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + \
FixedPcdGet32 (PcdUnixFlashNvStorageEventLogSize)) / FixedPcdGet32 (PcdUnixFirmwareBlockSize),
FixedPcdGet32 (PcdUnixFirmwareBlockSize),
}
}
},
{
{
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;
}

View File

@ -0,0 +1,238 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
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 EFI_SIGNATURE_32 ('F', 'V', 'B', 'N')
typedef struct {
MEMMAP_DEVICE_PATH MemMapDevPath;
EFI_DEVICE_PATH_PROTOCOL EndDevPath;
} FV_DEVICE_PATH;
typedef struct {
UINTN Signature;
FV_DEVICE_PATH DevicePath;
UINTN Instance;
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL FwVolBlockInstance;
EFI_FVB_EXTENSION_PROTOCOL FvbExtension;
} 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 EFI_LBA Lba,
IN UINTN BlockOffset,
IN OUT UINTN *NumBytes,
IN UINT8 *Buffer,
IN ESAL_FWB_GLOBAL *Global,
IN BOOLEAN Virtual
)
;
EFI_STATUS
FvbEraseBlock (
IN UINTN Instance,
IN EFI_LBA Lba,
IN ESAL_FWB_GLOBAL *Global,
IN BOOLEAN Virtual
)
;
EFI_STATUS
FvbSetVolumeAttributes (
IN UINTN Instance,
IN OUT EFI_FVB_ATTRIBUTES *Attributes,
IN ESAL_FWB_GLOBAL *Global,
IN BOOLEAN Virtual
)
;
EFI_STATUS
FvbGetVolumeAttributes (
IN UINTN Instance,
OUT EFI_FVB_ATTRIBUTES *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 EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
OUT EFI_FVB_ATTRIBUTES *Attributes
)
;
EFI_STATUS
EFIAPI
FvbProtocolSetAttributes (
IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
IN OUT EFI_FVB_ATTRIBUTES *Attributes
)
;
EFI_STATUS
EFIAPI
FvbProtocolGetPhysicalAddress (
IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
OUT EFI_PHYSICAL_ADDRESS *Address
)
;
EFI_STATUS
EFIAPI
FvbProtocolGetBlockSize (
IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
IN EFI_LBA Lba,
OUT UINTN *BlockSize,
OUT UINTN *NumOfBlocks
)
;
EFI_STATUS
EFIAPI
FvbProtocolRead (
IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
IN EFI_LBA Lba,
IN UINTN Offset,
IN OUT UINTN *NumBytes,
IN UINT8 *Buffer
)
;
EFI_STATUS
EFIAPI
FvbProtocolWrite (
IN 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 EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
...
)
;
EFI_STATUS
EFIAPI
FvbExtendProtocolEraseCustomBlockRange (
IN EFI_FVB_EXTENSION_PROTOCOL *This,
IN EFI_LBA StartLba,
IN UINTN OffsetStartLba,
IN EFI_LBA LastLba,
IN UINTN OffsetLastLba
)
;
#endif

View File

@ -0,0 +1,90 @@
#/** @file
# Component description file for Unix Fimware Volume Block DXE driver module.
#
# This DXE runtime driver implements and produces the Fimware Volue Block Protocol on
# Unix emulator.
# Copyright (c) 2008, Intel Corporation
#
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#
#**/
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = FwBlockService
FILE_GUID = f42fd042-8985-11db-a7db-0040d02b1835
MODULE_TYPE = DXE_RUNTIME_DRIVER
VERSION_STRING = 1.0
EDK_RELEASE_VERSION = 0x00020000
EFI_SPECIFICATION_VERSION = 0x00020000
ENTRY_POINT = FvbInitialize
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources.Ia32]
FvbInfo.c
FWBlockService.c
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
UnixPkg/UnixPkg.dec
[LibraryClasses]
UefiBootServicesTableLib
MemoryAllocationLib
BaseMemoryLib
HobLib
DebugLib
UefiRuntimeLib
DxeServicesTableLib
BaseLib
UefiDriverEntryPoint
UefiLib
[Guids]
gEfiEventVirtualAddressChangeGuid # ALWAYS_CONSUMED Create Event: EVENT_GROUP_GUID
gEfiAlternateFvBlockGuid # ALWAYS_PRODUCED
[Protocols]
gEfiFvbExtensionProtocolGuid # PROTOCOL ALWAYS_PRODUCED
gEfiFirmwareVolumeBlockProtocolGuid # PROTOCOL ALWAYS_PRODUCED
gEfiDevicePathProtocolGuid # PROTOCOL SOMETIMES_PRODUCED
[FixedPcd.common]
gEfiUnixPkgTokenSpaceGuid.PcdUnixFirmwareFdSize
gEfiUnixPkgTokenSpaceGuid.PcdUnixFirmwareBlockSize
gEfiUnixPkgTokenSpaceGuid.PcdUnixFlashFvRecoveryBase
gEfiUnixPkgTokenSpaceGuid.PcdUnixFlashFvRecoverySize
gEfiUnixPkgTokenSpaceGuid.PcdUnixFlashNvStorageEventLogBase
gEfiUnixPkgTokenSpaceGuid.PcdUnixFlashNvStorageEventLogSize
[Pcd.common]
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase
[Depex]
TRUE

View File

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">
<MsaHeader>
<ModuleName>FwBlockService</ModuleName>
<ModuleType>DXE_RUNTIME_DRIVER</ModuleType>
<GuidValue>f42fd042-8985-11db-a7db-0040d02b1835</GuidValue>
<Version>1.0</Version>
<Abstract>Component description file for Unix Fimware Volume Block DXE driver module.</Abstract>
<Description>This DXE runtime driver implements and produces the Fimware Volue Block Protocol on
Unix emulator.
</Description>
<Copyright>Copyright (c) 2006, Intel Corporation</Copyright>
<License>All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
</MsaHeader>
<ModuleDefinitions>
<SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
<BinaryModule>false</BinaryModule>
<OutputFileBasename>FwBlockService</OutputFileBasename>
</ModuleDefinitions>
<LibraryClassDefinitions>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UefiLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UefiDriverEntryPoint</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>BaseLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>DxeServicesTableLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UefiRuntimeLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>DebugLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>HobLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>BaseMemoryLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>MemoryAllocationLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UefiBootServicesTableLib</Keyword>
</LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>UnixFwh.dxs</Filename>
<Filename SupArchList="IA32">FWBlockService.c</Filename>
<Filename SupArchList="IA32">FwBlockService.h</Filename>
<Filename SupArchList="IA32">FvbInfo.c</Filename>
</SourceFiles>
<PackageDependencies>
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
<Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>
</PackageDependencies>
<Protocols>
<Protocol Usage="SOMETIMES_PRODUCED">
<ProtocolCName>gEfiDevicePathProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="ALWAYS_PRODUCED">
<ProtocolCName>gEfiFirmwareVolumeBlockProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="ALWAYS_PRODUCED">
<ProtocolCName>gEfiFvbExtensionProtocolGuid</ProtocolCName>
</Protocol>
</Protocols>
<Events>
<CreateEvents>
<EventTypes EventGuidCName="gEfiEventVirtualAddressChangeGuid" Usage="ALWAYS_CONSUMED">
<EventType>EVENT_GROUP_GUID</EventType>
</EventTypes>
</CreateEvents>
</Events>
<Guids>
<GuidCNames Usage="ALWAYS_PRODUCED">
<GuidCName>gEfiAlternateFvBlockGuid</GuidCName>
</GuidCNames>
</Guids>
<Externs>
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
<Extern>
<ModuleEntryPoint>FvbInitialize</ModuleEntryPoint>
</Extern>
</Externs>
</ModuleSurfaceArea>

View File

@ -0,0 +1,32 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
UnixInclude.h
Abstract:
Public include file for the Unix Library
--*/
#ifndef __UNIX_INCLUDE_H__
#define __UNIX_INCLUDE_H__
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/vfs.h>
#include <sys/poll.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <time.h>
#include <utime.h>
#include <unistd.h>
#endif

View File

@ -0,0 +1,64 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
FlashLayout.h
Abstract:
Platform specific flash layout
BugBug: We need a better way
--*/
#ifndef __EFI_FLASH_LAYOUT__
#define __EFI_FLASH_LAYOUT__
//
// Firmware Volume Information for Nt32
// adding one working block before FFS FV,
// and another one for spare block behind FFS FV
//
//
// Note: When block number is changed in .dsc file,
// this value should be changed accordingly!!!
//
#define FIRMWARE_BLOCK_NUMBER 0x28
#define EFI_WINNT_FIRMWARE_OFFSET 0x0
#define EFI_WINNT_FIRMWARE_LENGTH (0x10000 * FIRMWARE_BLOCK_NUMBER)
#define EFI_WINNT_RUNTIME_UPDATABLE_OFFSET (EFI_WINNT_FIRMWARE_OFFSET + EFI_WINNT_FIRMWARE_LENGTH)
#define EFI_WINNT_RUNTIME_UPDATABLE_LENGTH 0x10000
#define EFI_WINNT_FTW_SPARE_BLOCK_OFFSET (EFI_WINNT_RUNTIME_UPDATABLE_OFFSET + EFI_WINNT_RUNTIME_UPDATABLE_LENGTH)
#define EFI_WINNT_FTW_SPARE_BLOCK_LENGTH 0x10000
#define EFI_WINNT_RUNTIME_UPDATABLE_FV_HEADER_LENGTH 0x48
#define EFI_VARIABLE_STORE_OFFSET EFI_WINNT_RUNTIME_UPDATABLE_OFFSET
#define EFI_VARIABLE_STORE_LENGTH 0x00C000
#define EFI_EVENT_LOG_OFFSET (EFI_VARIABLE_STORE_OFFSET + EFI_VARIABLE_STORE_LENGTH)
#define EFI_EVENT_LOG_LENGTH 0x002000
#define EFI_FTW_WORKING_OFFSET (EFI_EVENT_LOG_OFFSET + EFI_EVENT_LOG_LENGTH)
#define EFI_FTW_WORKING_LENGTH 0x002000
#endif

View File

@ -0,0 +1,27 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
UnixLib.h
Abstract:
Public include file for the Unix Library
--*/
#ifndef __UNIX_LIB_H__
#define __UNIX_LIB_H__
extern EFI_UNIX_THUNK_PROTOCOL *gUnix;
#endif

View File

@ -0,0 +1,66 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
UnixAutoscan.h
Abstract:
Unix Autoscan PPI
--*/
#ifndef __UNIX_PEI_AUTOSCAN_H__
#define __UNIX_PEI_AUTOSCAN_H__
#include <UnixDxe.h>
#define PEI_UNIX_AUTOSCAN_PPI_GUID \
{ \
0xf2ed3d14, 0x8985, 0x11db, {0xb0, 0x57, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
}
typedef
EFI_STATUS
(EFIAPI *PEI_UNIX_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 discontiguous memory regions to be supported by the emulator.
It uses gSystemMemory[] and gSystemMemoryCount that were created by
parsing the host 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_UNIX_AUTOSCAN UnixAutoScan;
} PEI_UNIX_AUTOSCAN_PPI;
extern EFI_GUID gPeiUnixAutoScanPpiGuid;
#endif

View File

@ -0,0 +1,62 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
UnixFwh.h
Abstract:
Unix FWH PPI as defined in Tiano
--*/
#ifndef __UNIX_PEI_FWH_H__
#define __UNIX_PEI_FWH_H__
#include <UnixDxe.h>
#define UNIX_FWH_PPI_GUID \
{ \
0xf2f0dc30, 0x8985, 0x11db, {0xa1, 0x5b, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
}
typedef
EFI_STATUS
(EFIAPI *UNIX_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 host 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 {
UNIX_FWH_INFORMATION UnixFwh;
} UNIX_FWH_PPI;
extern EFI_GUID gUnixFwhPpiGuid;
#endif

View File

@ -0,0 +1,65 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
UnixPeiLoadFile.h
Abstract:
Unix Load File PPI.
When the PEI core is done it calls the DXE IPL via PPI
--*/
#ifndef __UNIX_PEI_LOAD_FILE_H__
#define __UNIX_PEI_LOAD_FILE_H__
#include <UnixDxe.h>
#define UNIX_PEI_LOAD_FILE_GUID \
{ \
0xf2f48768, 0x8985, 0x11db, {0xb8, 0xda, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
}
typedef
EFI_STATUS
(EFIAPI *UNIX_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 {
UNIX_PEI_LOAD_FILE PeiLoadFileService;
} UNIX_PEI_LOAD_FILE_PPI;
extern EFI_GUID gUnixPeiLoadFilePpiGuid;
#endif

View File

@ -0,0 +1,56 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
UnixThunk.h
Abstract:
Unix Thunk interface PPI
--*/
#ifndef __UNIX_PEI_UNIX_THUNK_H__
#define __UNIX_PEI_UNIX_THUNK_H__
#include <UnixDxe.h>
#define PEI_UNIX_THUNK_PPI_GUID \
{ \
0xf2f830f2, 0x8985, 0x11db, {0x80, 0x6b, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
}
typedef
VOID *
(EFIAPI *PEI_UNIX_THUNK_INTERFACE) (
VOID
);
/*++
Routine Description:
Export of EFI_UNIX_THUNK_PROTOCOL from the Unix SEC.
Arguments:
InterfaceBase - Address of the EFI_UNIX_THUNK_PROTOCOL
Returns:
EFI_SUCCESS - Data returned
--*/
typedef struct {
PEI_UNIX_THUNK_INTERFACE UnixThunk;
} PEI_UNIX_THUNK_PPI;
extern EFI_GUID gPeiUnixThunkPpiGuid;
#endif

View File

@ -0,0 +1,142 @@
/*++
Copyright (c) 2004 - 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
UnixIo.h
Abstract:
--*/
#ifndef _UNIX_IO_H_
#define _UNIX_IO_H_
#define EFI_UNIX_IO_PROTOCOL_GUID \
{ \
0xf2e23f54, 0x8985, 0x11db, {0xac, 0x79, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
}
typedef struct {
EFI_UNIX_THUNK_PROTOCOL *UnixThunk;
EFI_GUID *TypeGuid;
UINT16 *EnvString;
UINT16 InstanceNumber;
} EFI_UNIX_IO_PROTOCOL;
extern EFI_GUID gEfiUnixIoProtocolGuid;
//
// The following GUIDs are used in EFI_UNIX_IO_PROTOCOL_GUID
// Device paths. They map 1:1 with UNIX envirnment variables. The variables
// define what virtual hardware the emulator/UnixBusDriver will produce.
//
//
// EFI_UNIX_VIRTUAL_DISKS
//
#define EFI_UNIX_VIRTUAL_DISKS_GUID \
{ \
0xf2ba331a, 0x8985, 0x11db, {0xa4, 0x06, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
}
extern EFI_GUID gEfiUnixVirtualDisksGuid;
//
// EFI_UNIX_PHYSICAL_DISKS
//
#define EFI_UNIX_PHYSICAL_DISKS_GUID \
{ \
0xf2bdcc96, 0x8985, 0x11db, {0x87, 0x19, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
}
extern EFI_GUID gEfiUnixPhysicalDisksGuid;
//
// EFI_UNIX_FILE_SYSTEM
//
#define EFI_UNIX_FILE_SYSTEM_GUID \
{ \
0xf2c16b9e, 0x8985, 0x11db, {0x92, 0xc8, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
}
extern EFI_GUID gEfiUnixFileSystemGuid;
//
// EFI_WIN_NT_SERIAL_PORT
//
#define EFI_UNIX_SERIAL_PORT_GUID \
{ \
0x6d3a727d, 0x66c8, 0x4d19, {0x87, 0xe6, 0x2, 0x15, 0x86, 0x14, 0x90, 0xf3} \
}
extern EFI_GUID gEfiUnixSerialPortGuid;
//
// EFI_UNIX_UGA
//
#define EFI_UNIX_UGA_GUID \
{ \
0xf2c8b80e, 0x8985, 0x11db, {0x93, 0xf1, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
}
extern EFI_GUID gEfiUnixUgaGuid;
//
// EFI_UNIX_GOP
//
#define EFI_UNIX_GOP_GUID \
{ \
0xbace07c2, 0x8987, 0x11db, {0xa5, 0x9a, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
}
extern EFI_GUID gEfiUnixGopGuid;
//
// EFI_UNIX_CONSOLE
//
#define EFI_UNIX_CONSOLE_GUID \
{ \
0xf2cc5d06, 0x8985, 0x11db, {0xbb, 0x19, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
}
extern EFI_GUID gEfiUnixConsoleGuid;
//
// EFI_UNIX_MEMORY
//
#define EFI_UNIX_MEMORY_GUID \
{ \
0xf2d006cc, 0x8985, 0x11db, {0xa4, 0x72, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
}
extern EFI_GUID gEfiUnixMemoryGuid;
//
// EFI_UNIX_CPU_MODEL
//
#define EFI_UNIX_CPU_MODEL_GUID \
{ \
0xf2d3b330, 0x8985, 0x11db, {0x8a, 0xa3, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
}
extern EFI_GUID gEfiUnixCPUModelGuid;
//
// EFI_UNIX_CPU_SPEED
//
#define EFI_UNIX_CPU_SPEED_GUID \
{ \
0xf2d74e5a, 0x8985, 0x11db, {0x97, 0x05, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
}
extern EFI_GUID gEfiUnixCPUSpeedGuid;
#endif

View File

@ -0,0 +1,244 @@
/*++
Copyright (c) 2004, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
UnixThunk.h
Abstract:
This protocol allows an EFI driver in the Unix emulation environment
to make Posix calls.
NEVER make an Unix call directly, always make the call via this protocol.
There are no This pointers on the protocol member functions as they map
exactly into Unix system calls.
--*/
#ifndef _UNIX_THUNK_H_
#define _UNIX_THUNK_H_
#include <sys/termios.h>
#include <stdio.h>
#include <sys/time.h>
#include <sys/dir.h>
#include <unistd.h>
#include <poll.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
#include <signal.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <termio.h>
#include <sys/ioctl.h>
#include <sys/vfs.h>
#include <utime.h>
#define EFI_UNIX_THUNK_PROTOCOL_GUID \
{ \
0xf2e98868, 0x8985, 0x11db, {0x9a, 0x59, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
}
typedef
VOID
(*UnixSleep) (
unsigned long Milliseconds
);
typedef
VOID
(*UnixExit) (
int status // exit code for all threads
);
typedef
VOID
(*UnixSetTimer) (UINT64 PeriodMs, VOID (*CallBack)(UINT64 DeltaMs));
typedef
VOID
(*UnixGetLocalTime) (EFI_TIME *Time);
typedef
struct tm *
(*UnixGmTime)(const time_t *timep);
typedef
long
(*UnixGetTimeZone)(void);
typedef
int
(*UnixGetDayLight)(void);
typedef
int
(*UnixPoll)(struct pollfd *pfd, int nfds, int timeout);
typedef
int
(*UnixRead) (int fd, void *buf, int count);
typedef
int
(*UnixWrite) (int fd, const void *buf, int count);
typedef
char *
(*UnixGetenv) (const char *var);
typedef
int
(*UnixOpen) (const char *name, int flags, int mode);
typedef
long int
(*UnixSeek) (int fd, long int off, int whence);
typedef
int
(*UnixFtruncate) (int fd, long int len);
typedef
int
(*UnixClose) (int fd);
typedef
int
(*UnixMkdir)(const char *pathname, mode_t mode);
typedef
int
(*UnixRmDir)(const char *pathname);
typedef
int
(*UnixUnLink)(const char *pathname);
typedef
int
(*UnixGetErrno)(VOID);
typedef
DIR *
(*UnixOpenDir)(const char *pathname);
typedef
void
(*UnixRewindDir)(DIR *dir);
typedef
struct dirent *
(*UnixReadDir)(DIR *dir);
typedef
int
(*UnixCloseDir)(DIR *dir);
typedef
int
(*UnixStat)(const char *path, struct stat *buf);
typedef
int
(*UnixStatFs)(const char *path, struct statfs *buf);
typedef
int
(*UnixRename)(const char *oldpath, const char *newpath);
typedef
time_t
(*UnixMkTime)(struct tm *tm);
typedef
int
(*UnixFSync)(int fd);
typedef
int
(*UnixChmod)(const char *path, mode_t mode);
typedef
int
(*UnixUTime)(const char *filename, const struct utimbuf *buf);
struct _EFI_UNIX_UGA_IO_PROTOCOL;
typedef
EFI_STATUS
(*UnixUgaCreate)(struct _EFI_UNIX_UGA_IO_PROTOCOL **UgaIo,
CONST CHAR16 *Title);
typedef
int
(*UnixTcflush) (int fildes, int queue_selector);
typedef
void
(*UnixPerror) (__const char *__s);
typedef
int
(*UnixIoCtl) (int fd, unsigned long int __request, ...);
typedef
int
(*UnixFcntl) (int __fd, int __cmd, ...);
typedef
int
(*UnixCfsetispeed) (struct termios *__termios_p, speed_t __speed);
typedef
int
(*UnixCfsetospeed) (struct termios *__termios_p, speed_t __speed);
typedef
int
(*UnixTcgetattr) (int __fd, struct termios *__termios_p);
typedef
int
(*UnixTcsetattr) (int __fd, int __optional_actions,
__const struct termios *__termios_p);
//
//
//
#define EFI_UNIX_THUNK_PROTOCOL_SIGNATURE EFI_SIGNATURE_32 ('L', 'N', 'X', 'T')
typedef struct _EFI_UNIX_THUNK_PROTOCOL {
UINT64 Signature;
UnixSleep Sleep;
UnixExit Exit;
UnixSetTimer SetTimer;
UnixGetLocalTime GetLocalTime;
UnixGmTime GmTime;
UnixGetTimeZone GetTimeZone;
UnixGetDayLight GetDayLight;
UnixPoll Poll;
UnixRead Read;
UnixWrite Write;
UnixGetenv Getenv;
UnixOpen Open;
UnixSeek Lseek;
UnixFtruncate FTruncate;
UnixClose Close;
UnixMkdir MkDir;
UnixRmDir RmDir;
UnixUnLink UnLink;
UnixGetErrno GetErrno;
UnixOpenDir OpenDir;
UnixRewindDir RewindDir;
UnixReadDir ReadDir;
UnixCloseDir CloseDir;
UnixStat Stat;
UnixStatFs StatFs;
UnixRename Rename;
UnixMkTime MkTime;
UnixFSync FSync;
UnixChmod Chmod;
UnixUTime UTime;
UnixTcflush Tcflush;
UnixUgaCreate UgaCreate;
UnixPerror Perror;
UnixIoCtl IoCtl;
UnixFcntl Fcntl;
UnixCfsetispeed Cfsetispeed;
UnixCfsetospeed Cfsetospeed;
UnixTcgetattr Tcgetattr;
UnixTcsetattr Tcsetattr;
} EFI_UNIX_THUNK_PROTOCOL;
extern EFI_GUID gEfiUnixThunkProtocolGuid;
#endif

View File

@ -0,0 +1,72 @@
/*++
Copyright (c) 2006, Tristan Gingold
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the
BSD License which accompanies this distribution. The full text of the
license may be found at http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
UnixUgaIo.h
Abstract:
--*/
#ifndef _UNIX_UGA_IO_H_
#define _UNIX_UGA_IO_H_
#define EFI_UNIX_UGA_IO_PROTOCOL_GUID \
{ \
0xf2e5e2c6, 0x8985, 0x11db, {0xa1, 0x91, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
}
struct _EFI_UNIX_UGA_IO_PROTOCOL;
typedef struct _EFI_UNIX_UGA_IO_PROTOCOL EFI_UNIX_UGA_IO_PROTOCOL;
typedef
EFI_STATUS
(*UGAClose)(EFI_UNIX_UGA_IO_PROTOCOL *Uga);
typedef
EFI_STATUS
(*UGASize)(EFI_UNIX_UGA_IO_PROTOCOL *Uga, UINT32 Width, UINT32 Height);
typedef
EFI_STATUS
(*UGACheckKey)(EFI_UNIX_UGA_IO_PROTOCOL *Uga);
typedef
EFI_STATUS
(*UGAGetKey)(EFI_UNIX_UGA_IO_PROTOCOL *Uga, EFI_INPUT_KEY *key);
typedef
EFI_STATUS
(*UGABlt)(EFI_UNIX_UGA_IO_PROTOCOL *Uga,
IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,
IN EFI_UGA_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);
struct _EFI_UNIX_UGA_IO_PROTOCOL {
VOID *Private;
UGAClose UgaClose;
UGASize UgaSize;
UGACheckKey UgaCheckKey;
UGAGetKey UgaGetKey;
UGABlt UgaBlt;
};
extern EFI_GUID gEfiUnixUgaIoProtocolGuid;
#endif

36
UnixPkg/Include/UnixDxe.h Normal file
View File

@ -0,0 +1,36 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
UnixDxe.h
Abstract:
Public include file for the Unix Library
--*/
#ifndef __UNIX_DXE_H__
#define __UNIX_DXE_H__
#include <Ppi/UnixPeiLoadFile.h>
#include <Ppi/UnixAutoScan.h>
#include <Ppi/UnixThunk.h>
#include <Ppi/UnixFwh.h>
//
// UnixIo.h depends on UnixThunk.h
//
#include <Common/UnixInclude.h>
#include <Protocol/UnixThunk.h>
#include <Protocol/UnixIo.h>
#endif

View File

@ -0,0 +1,30 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
UnixPeim.h
Abstract:
Public include file for the Unix Library
--*/
#ifndef __UNIX_PEIM_H__
#define __UNIX_PEIM_H__
#include <Ppi/UnixPeiLoadFile.h>
#include <Ppi/UnixAutoScan.h>
#include <Ppi/UnixThunk.h>
#include <Ppi/UnixFwh.h>
#include <Protocol/UnixThunk.h>
#endif

View File

@ -0,0 +1,50 @@
#/** @file
# A library to produce the global variable 'gUnix'
#
# This library contains a single global variable 'gUnix' along with a constructor to initialize that global.
# Copyright (c) 2006 - 2008, Intel Corporation.
#
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#
#**/
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = DxeUnixLib
FILE_GUID = f39efc84-8985-11db-ad67-0040d02b1835
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
LIBRARY_CLASS = UnixLib
EDK_RELEASE_VERSION = 0x00020000
EFI_SPECIFICATION_VERSION = 0x00020000
CONSTRUCTOR = UnixLibConstructor
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources.common]
UnixLib.c
[Packages]
MdePkg/MdePkg.dec
UnixPkg/UnixPkg.dec
[LibraryClasses]
HobLib
DebugLib
[Protocols]
gEfiUnixThunkProtocolGuid # PROTOCOL ALWAYS_CONSUMED

View File

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">
<MsaHeader>
<ModuleName>DxeUnixLib</ModuleName>
<ModuleType>DXE_DRIVER</ModuleType>
<GuidValue>f39efc84-8985-11db-ad67-0040d02b1835</GuidValue>
<Version>1.0</Version>
<Abstract>A library to produce the global variable 'gUnix'</Abstract>
<Description>This library contains a single global variable 'gUnix' along with a constructor to initialize that global.</Description>
<Copyright>Copyright (c) 2006, Intel Corporation.</Copyright>
<License>All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
</MsaHeader>
<ModuleDefinitions>
<SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
<BinaryModule>false</BinaryModule>
<OutputFileBasename>DxeUnixLib</OutputFileBasename>
</ModuleDefinitions>
<LibraryClassDefinitions>
<LibraryClass Usage="ALWAYS_PRODUCED">
<Keyword>UnixLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>DebugLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>HobLib</Keyword>
</LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>UnixLib.c</Filename>
</SourceFiles>
<PackageDependencies>
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
<Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>
</PackageDependencies>
<Protocols>
<Protocol Usage="ALWAYS_CONSUMED">
<ProtocolCName>gEfiUnixThunkProtocolGuid</ProtocolCName>
</Protocol>
</Protocols>
<Externs>
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
<Extern>
<Constructor>UnixLibConstructor</Constructor>
</Extern>
</Externs>
</ModuleSurfaceArea>

View File

@ -0,0 +1,51 @@
/*++
Copyright (c) 2006 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
UnixLib.c
Abstract:
Unix Library
--*/
#include "PiDxe.h"
#include "UnixDxe.h"
#include <Library/UnixLib.h>
#include <Library/DebugLib.h>
#include <Library/HobLib.h>
EFI_UNIX_THUNK_PROTOCOL *gUnix;
EFI_STATUS
UnixLibConstructor (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
/*++
Routine Description:
Arguments:
Returns:
--*/
{
EFI_HOB_GUID_TYPE *GuidHob;
GuidHob = GetFirstGuidHob (&gEfiUnixThunkProtocolGuid);
ASSERT (GuidHob != NULL);
gUnix = (EFI_UNIX_THUNK_PROTOCOL *)(*(UINTN *)(GET_GUID_HOB_DATA (GuidHob)));
ASSERT (gUnix != NULL);
return EFI_SUCCESS;
}

View File

@ -0,0 +1,61 @@
#/** @file
# Memory Status Code Library for UEFI drivers
#
# Lib to provide memory journal status code reporting Routines
# Copyright (c) 2007, Intel Corporation.
#
# All rights reserved.
# This software and associated documentation (if any) is furnished
# under a license and may only be used or copied in accordance
# with the terms of the license. Except as permitted by such
# license, no part of this software or documentation may be
# reproduced, stored in a retrieval system, or transmitted in any
# form or by any means without the express written consent of
# Intel Corporation.
#
#
#**/
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = DxeUnixOemHookStatusCodeLib
FILE_GUID = 0BB6F68A-2FC5-4394-9375-2B43F1C34B59
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
LIBRARY_CLASS = OemHookStatusCodeLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
EDK_RELEASE_VERSION = 0x00020000
EFI_SPECIFICATION_VERSION = 0x00020000
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32
#
[Sources.common]
UnixOemHookStatusCodeLib.c
[Packages]
IntelFrameworkPkg/IntelFrameworkPkg.dec
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
UnixPkg/UnixPkg.dec
MdePkg/MdePkg.dec
[LibraryClasses]
ReportStatusCodeLib
BaseMemoryLib
PrintLib
HobLib
DebugLib
[Guids]
gEfiStatusCodeSpecificDataGuid # ALWAYS_CONSUMED
[Protocols]
gEfiUnixThunkProtocolGuid # PROTOCOL ALWAYS_CONSUMED

View File

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">
<MsaHeader>
<ModuleName>DxeUnixOemHookStatusCodeLib</ModuleName>
<ModuleType>DXE_DRIVER</ModuleType>
<GuidValue>0BB6F68A-2FC5-4394-9375-2B43F1C34B59</GuidValue>
<Version>1.0</Version>
<Abstract>Memory Status Code Library for UEFI drivers</Abstract>
<Description>Lib to provide memory journal status code reporting Routines</Description>
<Copyright>Copyright (c) 2007, Intel Corporation.</Copyright>
<License>All rights reserved.
This software and associated documentation (if any) is furnished
under a license and may only be used or copied in accordance
with the terms of the license. Except as permitted by such
license, no part of this software or documentation may be
reproduced, stored in a retrieval system, or transmitted in any
form or by any means without the express written consent of
Intel Corporation.</License>
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
</MsaHeader>
<ModuleDefinitions>
<SupportedArchitectures>IA32</SupportedArchitectures>
<BinaryModule>false</BinaryModule>
<OutputFileBasename>DxeUnixOemHookStatusCodeLib</OutputFileBasename>
</ModuleDefinitions>
<LibraryClassDefinitions>
<LibraryClass Usage="ALWAYS_PRODUCED" SupModuleList="DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER">
<Keyword>OemHookStatusCodeLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>DebugLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>HobLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>PrintLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>BaseMemoryLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>ReportStatusCodeLib</Keyword>
</LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>UnixOemHookStatusCodeLib.c</Filename>
</SourceFiles>
<PackageDependencies>
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
<Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>
</PackageDependencies>
<Protocols>
<Protocol Usage="ALWAYS_CONSUMED">
<ProtocolCName>gEfiUnixThunkProtocolGuid</ProtocolCName>
</Protocol>
</Protocols>
<Guids>
<GuidCNames Usage="ALWAYS_CONSUMED">
<GuidCName>gEfiStatusCodeSpecificDataGuid</GuidCName>
</GuidCNames>
</Guids>
<Externs>
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
</Externs>
</ModuleSurfaceArea>

View File

@ -0,0 +1,238 @@
/** @file
OEM hook status code library functions with no library constructor/destructor
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name: UnixOemHookStatusCodeLib.c
**/
#include "PiDxe.h"
#include <Guid/StatusCodeDataTypeId.h>
#include "UnixDxe.h"
#include <Library/OemHookStatusCodeLib.h>
#include <Library/DebugLib.h>
#include <Library/HobLib.h>
#include <Library/PrintLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/ReportStatusCodeLib.h>
#include <FrameworkModuleBase.h>
#include <DebugInfo.h>
//
// Cache of UnixThunk protocol
//
STATIC
EFI_UNIX_THUNK_PROTOCOL *mUnix;
//
// Cache of standard output handle .
//
STATIC
int mStdOut;
/**
Initialize OEM status code device .
@return Always return EFI_SUCCESS.
**/
EFI_STATUS
EFIAPI
OemHookStatusCodeInitialize (
VOID
)
{
EFI_HOB_GUID_TYPE *GuidHob;
//
// Retrieve UnixThunkProtocol from GUID'ed HOB
//
GuidHob = GetFirstGuidHob (&gEfiUnixThunkProtocolGuid);
ASSERT (GuidHob != NULL);
mUnix = (EFI_UNIX_THUNK_PROTOCOL *)(*(UINTN *)(GET_GUID_HOB_DATA (GuidHob)));
ASSERT (mUnix != NULL);
//
// Cache standard output handle.
//
mStdOut = 1;
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 EFI 1.10 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;
VA_LIST Marker;
EFI_DEBUG_INFO *DebugInfo;
Buffer[0] = '\0';
if (Data != NULL &&
ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) {
//
// Print ASSERT() information into output buffer.
//
CharCount = AsciiSPrint (
Buffer,
EFI_STATUS_CODE_DATA_MAX_SIZE,
"\n\rASSERT!: %a (%d): %a\n\r",
Filename,
LineNumber,
Description
);
//
// Callout to standard output.
//
mUnix->Write (
mStdOut,
Buffer,
CharCount
);
return EFI_SUCCESS;
} else if (Data != NULL &&
ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {
//
// Print DEBUG() information into output buffer.
//
CharCount = AsciiVSPrint (
Buffer,
EFI_STATUS_CODE_DATA_MAX_SIZE,
Format,
Marker
);
} else if (Data != NULL &&
CompareGuid (&Data->Type, &gEfiStatusCodeSpecificDataGuid) &&
(CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) {
//
// Print specific data into output buffer.
//
DebugInfo = (EFI_DEBUG_INFO *) (Data + 1);
Marker = (VA_LIST) (DebugInfo + 1);
Format = (CHAR8 *) (((UINT64 *) Marker) + 12);
CharCount = AsciiVSPrint (Buffer, EFI_STATUS_CODE_DATA_MAX_SIZE, Format, Marker);
} else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {
//
// Print ERROR information into output buffer.
//
CharCount = AsciiSPrint (
Buffer,
EFI_STATUS_CODE_DATA_MAX_SIZE,
"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],
(EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),
" %g",
CallerId
);
}
if (Data != NULL) {
CharCount += AsciiSPrint (
&Buffer[CharCount - 1],
(EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),
" %x",
Data
);
}
CharCount += AsciiSPrint (
&Buffer[CharCount - 1],
(EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),
"\n\r"
);
} else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {
CharCount = AsciiSPrint (
Buffer,
EFI_STATUS_CODE_DATA_MAX_SIZE,
"PROGRESS CODE: V%x I%x\n\r",
Value,
Instance
);
} else {
CharCount = AsciiSPrint (
Buffer,
EFI_STATUS_CODE_DATA_MAX_SIZE,
"Undefined: C%x:V%x I%x\n\r",
CodeType,
Value,
Instance
);
}
//
// Callout to standard output.
//
mUnix->Write (
mStdOut,
Buffer,
CharCount
);
return EFI_SUCCESS;
}

View File

@ -0,0 +1,225 @@
/**@file
Copyright (c) 2006 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
DxeUnixPeCoffLib.c
Abstract:
Wrap the Unix PE/COFF loader with the PE COFF LOADER guid structure
to produce PeCoff library class.
**/
#include <PiDxe.h>
#include <Guid/PeiPeCoffLoader.h>
#include <Library/DebugLib.h>
#include <Library/PeCoffLib.h>
#include <Library/HobLib.h>
EFI_PEI_PE_COFF_LOADER_PROTOCOL *mPeiEfiPeiPeCoffLoader;
/**
The constructor function gets the pointer to PeCofferLoader guid structure
from the guid data hob.
It will ASSERT() if the guid hob of PeCofferLoader guid structure doesn't exist.
@param ImageHandle The firmware allocated handle for the EFI image.
@param SystemTable A pointer to the EFI System Table.
@retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
**/
EFI_STATUS
EFIAPI
DxeUnixPeCoffLibConstructor (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_HOB_GUID_TYPE *GuidHob;
//
// Find guid data hob that contains PeCoffLoader guid structure.
//
GuidHob = GetFirstGuidHob (&gEfiPeiPeCoffLoaderGuid);
ASSERT (GuidHob != NULL);
//
// Get PeCofferLoader guid structure from guid hob data.
//
mPeiEfiPeiPeCoffLoader = (EFI_PEI_PE_COFF_LOADER_PROTOCOL *)(*(UINTN *)(GET_GUID_HOB_DATA (GuidHob)));
return EFI_SUCCESS;
}
/**
Retrieves information about a PE/COFF image.
Computes the PeCoffHeaderOffset, ImageAddress, ImageSize, DestinationAddress, CodeView,
PdbPointer, RelocationsStripped, SectionAlignment, SizeOfHeaders, and DebugDirectoryEntryRva
fields of the ImageContext structure. If ImageContext is NULL, then return RETURN_INVALID_PARAMETER.
If the PE/COFF image accessed through the ImageRead service in the ImageContext structure is not
a supported PE/COFF image type, then return RETURN_UNSUPPORTED. If any errors occur while
computing the fields of ImageContext, then the error status is returned in the ImageError field of
ImageContext.
@param ImageContext Pointer to the image context structure that describes the PE/COFF
image that needs to be examined by this function.
@retval RETURN_SUCCESS The information on the PE/COFF image was collected.
@retval RETURN_INVALID_PARAMETER ImageContext is NULL.
@retval RETURN_UNSUPPORTED The PE/COFF image is not supported.
**/
RETURN_STATUS
EFIAPI
PeCoffLoaderGetImageInfo (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
{
return mPeiEfiPeiPeCoffLoader->GetImageInfo (mPeiEfiPeiPeCoffLoader, ImageContext);
}
/**
Applies relocation fixups to a PE/COFF image that was loaded with PeCoffLoaderLoadImage().
If the DestinationAddress field of ImageContext is 0, then use the ImageAddress field of
ImageContext as the relocation base address. Otherwise, use the DestinationAddress field
of ImageContext as the relocation base address. The caller must allocate the relocation
fixup log buffer and fill in the FixupData field of ImageContext prior to calling this function.
If ImageContext is NULL, then ASSERT().
@param ImageContext Pointer to the image context structure that describes the PE/COFF
image that is being relocated.
@retval RETURN_SUCCESS The PE/COFF image was relocated.
Extended status information is in the ImageError field of ImageContext.
@retval RETURN_LOAD_ERROR The image in not a valid PE/COFF image.
Extended status information is in the ImageError field of ImageContext.
@retval RETURN_UNSUPPORTED A relocation record type is not supported.
Extended status information is in the ImageError field of ImageContext.
**/
RETURN_STATUS
EFIAPI
PeCoffLoaderRelocateImage (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
{
return mPeiEfiPeiPeCoffLoader->RelocateImage (mPeiEfiPeiPeCoffLoader, ImageContext);
}
/**
Loads a PE/COFF image into memory.
Loads the PE/COFF image accessed through the ImageRead service of ImageContext into the buffer
specified by the ImageAddress and ImageSize fields of ImageContext. The caller must allocate
the load buffer and fill in the ImageAddress and ImageSize fields prior to calling this function.
The EntryPoint, FixupDataSize, CodeView, and PdbPointer fields of ImageContext are computed.
If ImageContext is NULL, then ASSERT().
@param ImageContext Pointer to the image context structure that describes the PE/COFF
image that is being loaded.
@retval RETURN_SUCCESS The PE/COFF image was loaded into the buffer specified by
the ImageAddress and ImageSize fields of ImageContext.
Extended status information is in the ImageError field of ImageContext.
@retval RETURN_BUFFER_TOO_SMALL The caller did not provide a large enough buffer.
Extended status information is in the ImageError field of ImageContext.
@retval RETURN_LOAD_ERROR The PE/COFF image is an EFI Runtime image with no relocations.
Extended status information is in the ImageError field of ImageContext.
@retval RETURN_INVALID_PARAMETER The image address is invalid.
Extended status information is in the ImageError field of ImageContext.
**/
RETURN_STATUS
EFIAPI
PeCoffLoaderLoadImage (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
{
return mPeiEfiPeiPeCoffLoader->LoadImage (mPeiEfiPeiPeCoffLoader, ImageContext);
}
/**
ImageRead function that operates on a memory buffer whos base is passed into
FileHandle.
@param FileHandle Ponter to baes of the input stream
@param FileOffset Offset to the start of the buffer
@param ReadSize Number of bytes to copy into the buffer
@param Buffer Location to place results of read
@retval RETURN_SUCCESS Data is read from FileOffset from the Handle into
the buffer.
**/
RETURN_STATUS
EFIAPI
PeCoffLoaderImageReadFromMemory (
IN VOID *FileHandle,
IN UINTN FileOffset,
IN OUT UINTN *ReadSize,
OUT VOID *Buffer
)
{
return RETURN_UNSUPPORTED;
}
/**
Reapply fixups on a fixed up PE32/PE32+ image to allow virutal calling at EFI
runtime.
PE_COFF_LOADER_IMAGE_CONTEXT.FixupData stores information needed to reapply
the fixups with a virtual mapping.
@param ImageBase Base address of relocated image
@param VirtImageBase Virtual mapping for ImageBase
@param ImageSize Size of the image to relocate
@param RelocationData Location to place results of read
**/
VOID
EFIAPI
PeCoffLoaderRelocateImageForRuntime (
IN PHYSICAL_ADDRESS ImageBase,
IN PHYSICAL_ADDRESS VirtImageBase,
IN UINTN ImageSize,
IN VOID *RelocationData
)
{
}
/**
Unloads a loaded PE/COFF image from memory and releases its taken resource.
For Unix emulator, the PE/COFF image loaded by system needs to release.
For real platform, the PE/COFF image loaded by Core doesn't needs to be unloaded,
this function can simply return RETURN_SUCCESS.
@param ImageContext Pointer to the image context structure that describes the PE/COFF
image to be unloaded.
@retval RETURN_SUCCESS The PE/COFF image was unloaded successfully.
**/
RETURN_STATUS
EFIAPI
PeCoffLoaderUnloadImage (
IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
{
return mPeiEfiPeiPeCoffLoader->UnloadImage (mPeiEfiPeiPeCoffLoader, ImageContext);
}

View File

@ -0,0 +1,50 @@
#/** @file
# PeCoff libary for Dxe modules that run Unix emulator.
#
# Lib to provide memory journal status code reporting Routines
# Copyright (c) 2007 - 2008, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#
#**/
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = DxeUnixPeCoffLib
FILE_GUID = 624571b0-4b69-40e3-bd13-78fae0e84270
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
LIBRARY_CLASS = PeCoffLib|DXE_CORE DXE_DRIVER
EDK_RELEASE_VERSION = 0x00020000
EFI_SPECIFICATION_VERSION = 0x00020000
CONSTRUCTOR = DxeUnixPeCoffLibConstructor
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32
#
[Sources.common]
DxeUnixPeCoffLib.c
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
UnixPkg/UnixPkg.dec
[LibraryClasses]
DebugLib
HobLib
[Guids]
gEfiPeiPeCoffLoaderGuid # ALWAYS_CONSUMED

View File

@ -0,0 +1,50 @@
#/** @file
# Component description file for the EdkNt32PeiPeCoffGetEntryPointLib library.
#
# PeCoffGetEntryPointLib library class for NT32 instance implemented by use NTPeiLoadFile PPI.
# Copyright (c) 2008, Intel Corporation
#
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#
#**/
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = EdkUnixPeiPeCoffGetEntryPointLib
FILE_GUID = f3b702e8-8985-11db-9558-0040d02b1835
MODULE_TYPE = PEIM
VERSION_STRING = 1.0
LIBRARY_CLASS = PeCoffGetEntryPointLib
EDK_RELEASE_VERSION = 0x00020000
EFI_SPECIFICATION_VERSION = 0x00020000
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources.common]
PeCoffGetEntryPoint.c
[Packages]
MdePkg/MdePkg.dec
UnixPkg/UnixPkg.dec
[LibraryClasses]
PeiServicesLib
DebugLib
[Ppis]
gUnixPeiLoadFilePpiGuid # PPI ALWAYS_CONSUMED

View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">
<MsaHeader>
<ModuleName>EdkUnixPeiPeCoffGetEntryPointLib</ModuleName>
<ModuleType>PEIM</ModuleType>
<GuidValue>f3b702e8-8985-11db-9558-0040d02b1835</GuidValue>
<Version>1.0</Version>
<Abstract>Component description file for the EdkNt32PeiPeCoffGetEntryPointLib library.</Abstract>
<Description>PeCoffGetEntryPointLib library class for NT32 instance implemented by use NTPeiLoadFile PPI.</Description>
<Copyright>Copyright (c) 2006, Intel Corporation</Copyright>
<License>All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
</MsaHeader>
<ModuleDefinitions>
<SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
<BinaryModule>false</BinaryModule>
<OutputFileBasename>EdkUnixPeiPeCoffGetEntryPointLib</OutputFileBasename>
</ModuleDefinitions>
<LibraryClassDefinitions>
<LibraryClass Usage="ALWAYS_PRODUCED">
<Keyword>PeCoffGetEntryPointLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>PeiServicesLib</Keyword>
</LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>PeCoffGetEntryPoint.c</Filename>
</SourceFiles>
<PackageDependencies>
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>
</PackageDependencies>
<PPIs>
<Ppi Usage="ALWAYS_CONSUMED">
<PpiCName>gUnixPeiLoadFilePpiGuid</PpiCName>
</Ppi>
</PPIs>
<Externs>
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
</Externs>
</ModuleSurfaceArea>

View File

@ -0,0 +1,266 @@
/*++
Copyright (c) 2006 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
PeCoffGetEntryPoint.c
Abstract:
Tiano PE/COFF loader
Revision History
--*/
#include "PiPei.h"
#include <Library/PeCoffGetEntryPointLib.h>
#include <Library/PeiServicesLib.h>
#include <Ppi/UnixPeiLoadFile.h>
#include <IndustryStandard/PeImage.h>
#include <Library/DebugLib.h>
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;
UNIX_PEI_LOAD_FILE_PPI *PeiUnixService;
EFI_PHYSICAL_ADDRESS ImageAddress;
UINT64 ImageSize;
EFI_PHYSICAL_ADDRESS ImageEntryPoint;
ASSERT (Pe32Data != NULL);
ASSERT (EntryPoint != NULL);
Status = PeiServicesLocatePpi (
&gUnixPeiLoadFilePpiGuid,
0,
&PpiDescriptor,
(void **)&PeiUnixService
);
ASSERT_EFI_ERROR (Status);
Status = PeiUnixService->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 Unix 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) {
Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHdr->e_lfanew) & 0x0ffff));
} else {
Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)(Pe32Data);
}
if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {
return Hdr.Te->Machine;
} else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {
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 EFI_IMAGE_MACHINE_IA32:
//
// Assume PE32 image with IA32 Machine field.
//
Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;
break;
case EFI_IMAGE_MACHINE_X64:
case EFI_IMAGE_MACHINE_IPF:
//
// Assume PE32+ image with X64 or IPF 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));
default:
break;
}
}
}
}
return NULL;
}

View File

@ -0,0 +1,262 @@
/**@file
Copyright (c) 2006 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
PeiCoreUnixPeCoffLib.c
Abstract:
Wrap the Unix PE/COFF loader with the PE COFF LOADER guid structure
to produce PeCoff library class.
**/
#include <PiPei.h>
#include <Guid/PeiPeCoffLoader.h>
#include <Library/DebugLib.h>
#include <Library/PeCoffLib.h>
#include <Library/HobLib.h>
#include <Library/PeiServicesLib.h>
EFI_PEI_PE_COFF_LOADER_PROTOCOL *mPeiEfiPeiPeCoffLoader = NULL;
/**
The function caches the pointer of PeCofferLoader guid structure
into the guid data hob.
The funtion must be called after PeCofferLoader guid structure is installed.
It will ASSERT() if PeCofferLoader guid structure is not installed.
@retval EFI_SUCCESS PeCofferLoader guid structure is found.
**/
EFI_STATUS
EFIAPI
GetPeCoffLoaderStucture (
)
{
EFI_STATUS Status;
EFI_HOB_GUID_TYPE *GuidHob;
Status = EFI_NOT_FOUND;
//
// Try to get guid data hob that contains PeCoffLoader guid structure.
//
GuidHob = GetFirstGuidHob (&gEfiPeiPeCoffLoaderGuid);
if (GuidHob == NULL) {
//
// GuidHob is not ready, try to locate PeCoffLoader guid structure.
//
Status = PeiServicesLocatePpi (
&gEfiPeiPeCoffLoaderGuid,
0,
NULL,
&mPeiEfiPeiPeCoffLoader
);
//
// PeCofferLoader guid structure must be installed before this library runs.
//
ASSERT_EFI_ERROR (Status);
//
// Build guid data hob of PeCofferLoader guid structure for DXE module use.
//
BuildGuidDataHob (
&gEfiPeiPeCoffLoaderGuid,
(VOID *) &mPeiEfiPeiPeCoffLoader,
sizeof (VOID *)
);
} else {
//
// Get PeCofferLoader guid structure directly from guid hob data.
//
mPeiEfiPeiPeCoffLoader = (EFI_PEI_PE_COFF_LOADER_PROTOCOL *)(*(UINTN *)(GET_GUID_HOB_DATA (GuidHob)));
}
return EFI_SUCCESS;
}
/**
Retrieves information about a PE/COFF image.
Computes the PeCoffHeaderOffset, ImageAddress, ImageSize, DestinationAddress, CodeView,
PdbPointer, RelocationsStripped, SectionAlignment, SizeOfHeaders, and DebugDirectoryEntryRva
fields of the ImageContext structure. If ImageContext is NULL, then return RETURN_INVALID_PARAMETER.
If the PE/COFF image accessed through the ImageRead service in the ImageContext structure is not
a supported PE/COFF image type, then return RETURN_UNSUPPORTED. If any errors occur while
computing the fields of ImageContext, then the error status is returned in the ImageError field of
ImageContext.
@param ImageContext Pointer to the image context structure that describes the PE/COFF
image that needs to be examined by this function.
@retval RETURN_SUCCESS The information on the PE/COFF image was collected.
@retval RETURN_INVALID_PARAMETER ImageContext is NULL.
@retval RETURN_UNSUPPORTED The PE/COFF image is not supported.
**/
RETURN_STATUS
EFIAPI
PeCoffLoaderGetImageInfo (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
{
if (mPeiEfiPeiPeCoffLoader == NULL) {
GetPeCoffLoaderStucture ();
}
return mPeiEfiPeiPeCoffLoader->GetImageInfo (mPeiEfiPeiPeCoffLoader, ImageContext);
}
/**
Applies relocation fixups to a PE/COFF image that was loaded with PeCoffLoaderLoadImage().
If the DestinationAddress field of ImageContext is 0, then use the ImageAddress field of
ImageContext as the relocation base address. Otherwise, use the DestinationAddress field
of ImageContext as the relocation base address. The caller must allocate the relocation
fixup log buffer and fill in the FixupData field of ImageContext prior to calling this function.
If ImageContext is NULL, then ASSERT().
@param ImageContext Pointer to the image context structure that describes the PE/COFF
image that is being relocated.
@retval RETURN_SUCCESS The PE/COFF image was relocated.
Extended status information is in the ImageError field of ImageContext.
@retval RETURN_LOAD_ERROR The image in not a valid PE/COFF image.
Extended status information is in the ImageError field of ImageContext.
@retval RETURN_UNSUPPORTED A relocation record type is not supported.
Extended status information is in the ImageError field of ImageContext.
**/
RETURN_STATUS
EFIAPI
PeCoffLoaderRelocateImage (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
{
if (mPeiEfiPeiPeCoffLoader == NULL) {
GetPeCoffLoaderStucture ();
}
return mPeiEfiPeiPeCoffLoader->RelocateImage (mPeiEfiPeiPeCoffLoader, ImageContext);
}
/**
Loads a PE/COFF image into memory.
Loads the PE/COFF image accessed through the ImageRead service of ImageContext into the buffer
specified by the ImageAddress and ImageSize fields of ImageContext. The caller must allocate
the load buffer and fill in the ImageAddress and ImageSize fields prior to calling this function.
The EntryPoint, FixupDataSize, CodeView, and PdbPointer fields of ImageContext are computed.
If ImageContext is NULL, then ASSERT().
@param ImageContext Pointer to the image context structure that describes the PE/COFF
image that is being loaded.
@retval RETURN_SUCCESS The PE/COFF image was loaded into the buffer specified by
the ImageAddress and ImageSize fields of ImageContext.
Extended status information is in the ImageError field of ImageContext.
@retval RETURN_BUFFER_TOO_SMALL The caller did not provide a large enough buffer.
Extended status information is in the ImageError field of ImageContext.
@retval RETURN_LOAD_ERROR The PE/COFF image is an EFI Runtime image with no relocations.
Extended status information is in the ImageError field of ImageContext.
@retval RETURN_INVALID_PARAMETER The image address is invalid.
Extended status information is in the ImageError field of ImageContext.
**/
RETURN_STATUS
EFIAPI
PeCoffLoaderLoadImage (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
{
if (mPeiEfiPeiPeCoffLoader == NULL) {
GetPeCoffLoaderStucture ();
}
return mPeiEfiPeiPeCoffLoader->LoadImage (mPeiEfiPeiPeCoffLoader, ImageContext);
}
/**
ImageRead function that operates on a memory buffer whos base is passed into
FileHandle.
@param FileHandle Ponter to baes of the input stream
@param FileOffset Offset to the start of the buffer
@param ReadSize Number of bytes to copy into the buffer
@param Buffer Location to place results of read
@retval RETURN_SUCCESS Data is read from FileOffset from the Handle into
the buffer.
**/
RETURN_STATUS
EFIAPI
PeCoffLoaderImageReadFromMemory (
IN VOID *FileHandle,
IN UINTN FileOffset,
IN OUT UINTN *ReadSize,
OUT VOID *Buffer
)
{
return RETURN_UNSUPPORTED;
}
/**
Reapply fixups on a fixed up PE32/PE32+ image to allow virutal calling at EFI
runtime.
PE_COFF_LOADER_IMAGE_CONTEXT.FixupData stores information needed to reapply
the fixups with a virtual mapping.
@param ImageBase Base address of relocated image
@param VirtImageBase Virtual mapping for ImageBase
@param ImageSize Size of the image to relocate
@param RelocationData Location to place results of read
**/
VOID
EFIAPI
PeCoffLoaderRelocateImageForRuntime (
IN PHYSICAL_ADDRESS ImageBase,
IN PHYSICAL_ADDRESS VirtImageBase,
IN UINTN ImageSize,
IN VOID *RelocationData
)
{
}
/**
Unloads a loaded PE/COFF image from memory and releases its taken resource.
For Unix emulator, the PE/COFF image loaded by system needs to release.
For real platform, the PE/COFF image loaded by Core doesn't needs to be unloaded,
this function can simply return RETURN_SUCCESS.
@param ImageContext Pointer to the image context structure that describes the PE/COFF
image to be unloaded.
@retval RETURN_SUCCESS The PE/COFF image was unloaded successfully.
**/
RETURN_STATUS
EFIAPI
PeCoffLoaderUnloadImage (
IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
{
if (mPeiEfiPeiPeCoffLoader == NULL) {
GetPeCoffLoaderStucture ();
}
return mPeiEfiPeiPeCoffLoader->UnloadImage (mPeiEfiPeiPeCoffLoader, ImageContext);
}

View File

@ -0,0 +1,49 @@
#/** @file
# PeCoff libary for PeiCore modules that run Unix emulator.
#
# Lib to provide memory journal status code reporting Routines
# Copyright (c) 2007 - 2008, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#
#**/
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = PeiCoreUnixPeCoffLib
FILE_GUID = ef9fd7ee-3181-4b16-adc1-8615f88b58b8
MODULE_TYPE = PEI_CORE
VERSION_STRING = 1.0
LIBRARY_CLASS = PeCoffLib|PEI_CORE
EDK_RELEASE_VERSION = 0x00020000
EFI_SPECIFICATION_VERSION = 0x00020000
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32
#
[Sources.common]
PeiCoreUnixPeCoffLib.c
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
UnixPkg/UnixPkg.dec
[LibraryClasses]
PeiServicesLib
DebugLib
HobLib
[Guids]
gEfiPeiPeCoffLoaderGuid # ALWAYS_CONSUMED

View File

@ -0,0 +1,61 @@
#/** @file
# Memory Status Code Library for UEFI drivers
#
# Lib to provide memory journal status code reporting Routines
# Copyright (c) 2007, Intel Corporation.
#
# All rights reserved.
# This software and associated documentation (if any) is furnished
# under a license and may only be used or copied in accordance
# with the terms of the license. Except as permitted by such
# license, no part of this software or documentation may be
# reproduced, stored in a retrieval system, or transmitted in any
# form or by any means without the express written consent of
# Intel Corporation.
#
#
#**/
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = PeiUnixOemHookStatusCodeLib
FILE_GUID = 23E378C1-B199-49ad-9F14-DAF5D3C7EC28
MODULE_TYPE = PEIM
VERSION_STRING = 1.0
LIBRARY_CLASS = OemHookStatusCodeLib|PEIM
EDK_RELEASE_VERSION = 0x00020000
EFI_SPECIFICATION_VERSION = 0x00020000
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32
#
[Sources.common]
UnixOemHookStatusCodeLib.c
[Packages]
MdePkg/MdePkg.dec
UnixPkg/UnixPkg.dec
IntelFrameworkPkg/IntelFrameworkPkg.dec
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
[LibraryClasses]
PeiServicesLib
ReportStatusCodeLib
BaseMemoryLib
PrintLib
DebugLib
[Guids]
gEfiStatusCodeSpecificDataGuid # ALWAYS_CONSUMED
[Ppis]
gPeiUnixThunkPpiGuid # PPI ALWAYS_CONSUMED

View File

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<MsaHeader>
<ModuleName>PeiUnixOemHookStatusCodeLib</ModuleName>
<ModuleType>PEIM</ModuleType>
<GuidValue>23E378C1-B199-49ad-9F14-DAF5D3C7EC28</GuidValue>
<Version>1.0</Version>
<Abstract>Memory Status Code Library for UEFI drivers</Abstract>
<Description>Lib to provide memory journal status code reporting Routines</Description>
<Copyright>Copyright (c) 2007, Intel Corporation.</Copyright>
<License>All rights reserved.
This software and associated documentation (if any) is furnished
under a license and may only be used or copied in accordance
with the terms of the license. Except as permitted by such
license, no part of this software or documentation may be
reproduced, stored in a retrieval system, or transmitted in any
form or by any means without the express written consent of
Intel Corporation.</License>
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
</MsaHeader>
<ModuleDefinitions>
<SupportedArchitectures>IA32</SupportedArchitectures>
<BinaryModule>false</BinaryModule>
<OutputFileBasename>PeiUnixOemHookStatusCodeLib</OutputFileBasename>
</ModuleDefinitions>
<LibraryClassDefinitions>
<LibraryClass Usage="ALWAYS_PRODUCED" SupModuleList="PEIM">
<Keyword>OemHookStatusCodeLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>DebugLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>PrintLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>BaseMemoryLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>ReportStatusCodeLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>PeiServicesLib</Keyword>
</LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>UnixOemHookStatusCodeLib.c</Filename>
</SourceFiles>
<PackageDependencies>
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
<Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>
</PackageDependencies>
<PPIs>
<Ppi Usage="ALWAYS_CONSUMED">
<PpiCName>gPeiUnixThunkPpiGuid</PpiCName>
</Ppi>
</PPIs>
<Guids>
<GuidCNames Usage="ALWAYS_CONSUMED">
<GuidCName>gEfiStatusCodeSpecificDataGuid</GuidCName>
</GuidCNames>
</Guids>
<Externs>
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
</Externs>
</ModuleSurfaceArea>

View File

@ -0,0 +1,246 @@
/** @file
OEM hook status code library functions with no library constructor/destructor
Copyright (c) 2006 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name: UnixOemHookStatusCodeLib.c
**/
#include "PiPei.h"
#include <Guid/StatusCodeDataTypeId.h>
#include <Ppi/UnixThunk.h>
#include <FrameworkModuleBase.h>
#include <Library/OemHookStatusCodeLib.h>
#include <Library/DebugLib.h>
#include <Library/PrintLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/ReportStatusCodeLib.h>
#include <Library/PeiServicesLib.h>
#include <DebugInfo.h>
//
// Cache of UnixThunk protocol
//
STATIC
EFI_UNIX_THUNK_PROTOCOL *mUnix;
//
// Cache of standard output handle .
//
STATIC
int mStdOut;
/**
Initialize OEM status code device .
@return Always return EFI_SUCCESS.
**/
EFI_STATUS
EFIAPI
OemHookStatusCodeInitialize (
VOID
)
{
PEI_UNIX_THUNK_PPI *UnixThunkPpi;
EFI_STATUS Status;
//
// Locate Unix ThunkPpi for retrieving standard output handle
//
Status = PeiServicesLocatePpi (
&gPeiUnixThunkPpiGuid,
0,
NULL,
(VOID **) &UnixThunkPpi
);
ASSERT_EFI_ERROR (Status);
mUnix = (EFI_UNIX_THUNK_PROTOCOL *) UnixThunkPpi->UnixThunk ();
//
// Cache standard output handle.
//
mStdOut = 1;
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 EFI 1.10 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;
VA_LIST Marker;
EFI_DEBUG_INFO *DebugInfo;
Buffer[0] = '\0';
if (Data != NULL &&
ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) {
//
// Print ASSERT() information into output buffer.
//
CharCount = AsciiSPrint (
Buffer,
EFI_STATUS_CODE_DATA_MAX_SIZE,
"\n\rASSERT!: %a (%d): %a\n\r",
Filename,
LineNumber,
Description
);
//
// Callout to standard output.
//
mUnix->Write (
mStdOut,
Buffer,
CharCount
);
return EFI_SUCCESS;
} else if (Data != NULL &&
ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {
//
// Print DEBUG() information into output buffer.
//
CharCount = AsciiVSPrint (
Buffer,
EFI_STATUS_CODE_DATA_MAX_SIZE,
Format,
Marker
);
} else if (Data != NULL &&
CompareGuid (&Data->Type, &gEfiStatusCodeSpecificDataGuid) &&
(CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) {
//
// Print specific data into output buffer.
//
DebugInfo = (EFI_DEBUG_INFO *) (Data + 1);
Marker = (VA_LIST) (DebugInfo + 1);
Format = (CHAR8 *) (((UINT64 *) Marker) + 12);
CharCount = AsciiVSPrint (Buffer, EFI_STATUS_CODE_DATA_MAX_SIZE, Format, Marker);
} else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {
//
// Print ERROR information into output buffer.
//
CharCount = AsciiSPrint (
Buffer,
EFI_STATUS_CODE_DATA_MAX_SIZE,
"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],
(EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),
" %g",
CallerId
);
}
if (Data != NULL) {
CharCount += AsciiSPrint (
&Buffer[CharCount - 1],
(EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),
" %x",
Data
);
}
CharCount += AsciiSPrint (
&Buffer[CharCount - 1],
(EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),
"\n\r"
);
} else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {
CharCount = AsciiSPrint (
Buffer,
EFI_STATUS_CODE_DATA_MAX_SIZE,
"PROGRESS CODE: V%x I%x\n\r",
Value,
Instance
);
} else {
CharCount = AsciiSPrint (
Buffer,
EFI_STATUS_CODE_DATA_MAX_SIZE,
"Undefined: C%x:V%x I%x\n\r",
CodeType,
Value,
Instance
);
}
//
// Callout to standard output.
//
mUnix->Write (
mStdOut,
Buffer,
CharCount
);
return EFI_SUCCESS;
}

View File

@ -0,0 +1,255 @@
/**@file
Copyright (c) 2006 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
PeiUnixPeCoffLib.c
Abstract:
Wrap the Unix PE/COFF loader with the PE COFF LOADER guid structure
to produce PeCoff library class.
**/
#include <PiPei.h>
#include <Guid/PeiPeCoffLoader.h>
#include <Library/DebugLib.h>
#include <Library/PeCoffLib.h>
#include <Library/HobLib.h>
EFI_PEI_PE_COFF_LOADER_PROTOCOL *mPeiEfiPeiPeCoffLoader;
/**
The constructor function caches the pointer of PeCofferLoader guid structure
into the guid data hob.
The constructor must be called after PeCofferLoader guid structure is installed.
It will ASSERT() if PeCofferLoader guid structure is not installed.
@param FfsHeader Pointer to FFS header the loaded driver.
@param PeiServices Pointer to the PEI services.
@retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
**/
EFI_STATUS
EFIAPI
PeiUnixPeCoffLibConstructor (
IN EFI_FFS_FILE_HEADER *FfsHeader,
IN EFI_PEI_SERVICES **PeiServices
)
{
EFI_STATUS Status;
EFI_HOB_GUID_TYPE *GuidHob;
Status = EFI_NOT_FOUND;
//
// Try to get guid data hob that contains PeCoffLoader guid structure.
//
GuidHob = GetFirstGuidHob (&gEfiPeiPeCoffLoaderGuid);
if (GuidHob == NULL) {
//
// GuidHob is not ready, try to locate PeCoffLoader guid structure.
//
Status = (*PeiServices)->LocatePpi (
PeiServices,
&gEfiPeiPeCoffLoaderGuid,
0,
NULL,
&mPeiEfiPeiPeCoffLoader
);
//
// PeCofferLoader guid structure must be installed before this library runs.
//
ASSERT_EFI_ERROR (Status);
//
// Build guid data hob of PeCofferLoader guid structure for DXE module use.
//
BuildGuidDataHob (
&gEfiPeiPeCoffLoaderGuid,
(VOID *) &mPeiEfiPeiPeCoffLoader,
sizeof (VOID *)
);
} else {
//
// Get PeCofferLoader guid structure directly from guid hob data.
//
mPeiEfiPeiPeCoffLoader = (EFI_PEI_PE_COFF_LOADER_PROTOCOL *)(*(UINTN *)(GET_GUID_HOB_DATA (GuidHob)));
}
return EFI_SUCCESS;
}
/**
Retrieves information about a PE/COFF image.
Computes the PeCoffHeaderOffset, ImageAddress, ImageSize, DestinationAddress, CodeView,
PdbPointer, RelocationsStripped, SectionAlignment, SizeOfHeaders, and DebugDirectoryEntryRva
fields of the ImageContext structure. If ImageContext is NULL, then return RETURN_INVALID_PARAMETER.
If the PE/COFF image accessed through the ImageRead service in the ImageContext structure is not
a supported PE/COFF image type, then return RETURN_UNSUPPORTED. If any errors occur while
computing the fields of ImageContext, then the error status is returned in the ImageError field of
ImageContext.
@param ImageContext Pointer to the image context structure that describes the PE/COFF
image that needs to be examined by this function.
@retval RETURN_SUCCESS The information on the PE/COFF image was collected.
@retval RETURN_INVALID_PARAMETER ImageContext is NULL.
@retval RETURN_UNSUPPORTED The PE/COFF image is not supported.
**/
RETURN_STATUS
EFIAPI
PeCoffLoaderGetImageInfo (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
{
return mPeiEfiPeiPeCoffLoader->GetImageInfo (mPeiEfiPeiPeCoffLoader, ImageContext);
}
/**
Applies relocation fixups to a PE/COFF image that was loaded with PeCoffLoaderLoadImage().
If the DestinationAddress field of ImageContext is 0, then use the ImageAddress field of
ImageContext as the relocation base address. Otherwise, use the DestinationAddress field
of ImageContext as the relocation base address. The caller must allocate the relocation
fixup log buffer and fill in the FixupData field of ImageContext prior to calling this function.
If ImageContext is NULL, then ASSERT().
@param ImageContext Pointer to the image context structure that describes the PE/COFF
image that is being relocated.
@retval RETURN_SUCCESS The PE/COFF image was relocated.
Extended status information is in the ImageError field of ImageContext.
@retval RETURN_LOAD_ERROR The image in not a valid PE/COFF image.
Extended status information is in the ImageError field of ImageContext.
@retval RETURN_UNSUPPORTED A relocation record type is not supported.
Extended status information is in the ImageError field of ImageContext.
**/
RETURN_STATUS
EFIAPI
PeCoffLoaderRelocateImage (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
{
return mPeiEfiPeiPeCoffLoader->RelocateImage (mPeiEfiPeiPeCoffLoader, ImageContext);
}
/**
Loads a PE/COFF image into memory.
Loads the PE/COFF image accessed through the ImageRead service of ImageContext into the buffer
specified by the ImageAddress and ImageSize fields of ImageContext. The caller must allocate
the load buffer and fill in the ImageAddress and ImageSize fields prior to calling this function.
The EntryPoint, FixupDataSize, CodeView, and PdbPointer fields of ImageContext are computed.
If ImageContext is NULL, then ASSERT().
@param ImageContext Pointer to the image context structure that describes the PE/COFF
image that is being loaded.
@retval RETURN_SUCCESS The PE/COFF image was loaded into the buffer specified by
the ImageAddress and ImageSize fields of ImageContext.
Extended status information is in the ImageError field of ImageContext.
@retval RETURN_BUFFER_TOO_SMALL The caller did not provide a large enough buffer.
Extended status information is in the ImageError field of ImageContext.
@retval RETURN_LOAD_ERROR The PE/COFF image is an EFI Runtime image with no relocations.
Extended status information is in the ImageError field of ImageContext.
@retval RETURN_INVALID_PARAMETER The image address is invalid.
Extended status information is in the ImageError field of ImageContext.
**/
RETURN_STATUS
EFIAPI
PeCoffLoaderLoadImage (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
{
return mPeiEfiPeiPeCoffLoader->LoadImage (mPeiEfiPeiPeCoffLoader, ImageContext);
}
/**
ImageRead function that operates on a memory buffer whos base is passed into
FileHandle.
@param FileHandle Ponter to baes of the input stream
@param FileOffset Offset to the start of the buffer
@param ReadSize Number of bytes to copy into the buffer
@param Buffer Location to place results of read
@retval RETURN_SUCCESS Data is read from FileOffset from the Handle into
the buffer.
**/
RETURN_STATUS
EFIAPI
PeCoffLoaderImageReadFromMemory (
IN VOID *FileHandle,
IN UINTN FileOffset,
IN OUT UINTN *ReadSize,
OUT VOID *Buffer
)
{
return RETURN_UNSUPPORTED;
}
/**
Reapply fixups on a fixed up PE32/PE32+ image to allow virutal calling at EFI
runtime.
PE_COFF_LOADER_IMAGE_CONTEXT.FixupData stores information needed to reapply
the fixups with a virtual mapping.
@param ImageBase Base address of relocated image
@param VirtImageBase Virtual mapping for ImageBase
@param ImageSize Size of the image to relocate
@param RelocationData Location to place results of read
**/
VOID
EFIAPI
PeCoffLoaderRelocateImageForRuntime (
IN PHYSICAL_ADDRESS ImageBase,
IN PHYSICAL_ADDRESS VirtImageBase,
IN UINTN ImageSize,
IN VOID *RelocationData
)
{
}
/**
Unloads a loaded PE/COFF image from memory and releases its taken resource.
For Unix emulator, the PE/COFF image loaded by system needs to release.
For real platform, the PE/COFF image loaded by Core doesn't needs to be unloaded,
this function can simply return RETURN_SUCCESS.
@param ImageContext Pointer to the image context structure that describes the PE/COFF
image to be unloaded.
@retval RETURN_SUCCESS The PE/COFF image was unloaded successfully.
**/
RETURN_STATUS
EFIAPI
PeCoffLoaderUnloadImage (
IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
{
return mPeiEfiPeiPeCoffLoader->UnloadImage (mPeiEfiPeiPeCoffLoader, ImageContext);
}

View File

@ -0,0 +1,50 @@
#/** @file
# PeCoff libary for PEIM modules that run Unix emulator.
#
# Lib to provide memory journal status code reporting Routines
# Copyright (c) 2007 - 2008, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#
#**/
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = PeiUnixPeCoffLib
FILE_GUID = 91404129-c58a-40bb-8a2b-f05bc05a961c
MODULE_TYPE = PEIM
VERSION_STRING = 1.0
LIBRARY_CLASS = PeCoffLib|PEIM
EDK_RELEASE_VERSION = 0x00020000
EFI_SPECIFICATION_VERSION = 0x00020000
CONSTRUCTOR = PeiUnixPeCoffLibConstructor
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32
#
[Sources.common]
PeiUnixPeCoffLib.c
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
UnixPkg/UnixPkg.dec
[LibraryClasses]
DebugLib
HobLib
[Guids]
gEfiPeiPeCoffLoaderGuid # ALWAYS_CONSUMED

View File

@ -0,0 +1,514 @@
/*++
Copyright (c) 2006 - 2007, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
BdsPlatform.c
Abstract:
This file include all platform action which can be customized
by IBV/OEM.
--*/
#include "BdsPlatform.h"
CHAR16 mFirmwareVendor[] = L"TianoCore.org";
//
// BDS Platform Functions
//
VOID
PlatformBdsInit (
IN EFI_BDS_ARCH_PROTOCOL_INSTANCE *PrivateData
)
/*++
Routine Description:
Platform Bds init. Incude the platform firmware vendor, revision
and so crc check.
Arguments:
PrivateData - The EFI_BDS_ARCH_PROTOCOL_INSTANCE instance
Returns:
None.
--*/
{
//
// set firmwarevendor, here can be IBV/OEM customize
//
gST->FirmwareVendor = AllocateRuntimeCopyPool (
sizeof (mFirmwareVendor),
&mFirmwareVendor
);
ASSERT (gST->FirmwareVendor != NULL);
gST->FirmwareRevision = 0;
//
// Fixup Tasble CRC after we updated Firmware Vendor and Revision
//
gBS->CalculateCrc32 ((VOID *) gST, sizeof (EFI_SYSTEM_TABLE), &gST->Hdr.CRC32);
}
EFI_STATUS
PlatformBdsConnectConsole (
IN BDS_CONSOLE_CONNECT_ENTRY *PlatformConsole
)
/*++
Routine Description:
Connect the predefined platform default console device. Always try to find
and enable the vga device if have.
Arguments:
PlatformConsole - Predfined platform default console device array.
Returns:
EFI_SUCCESS - Success connect at least one ConIn and ConOut
device, there must have one ConOut device is
active vga device.
EFI_STATUS - Return the status of
BdsLibConnectAllDefaultConsoles ()
--*/
{
EFI_STATUS Status;
UINTN Index;
Index = 0;
Status = EFI_SUCCESS;
//
// Have chance to connect the platform default console,
// the platform default console is the minimue device group
// the platform should support
//
while (PlatformConsole[Index].DevicePath != NULL) {
//
// Update the console variable with the connect type
//
if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {
BdsLibUpdateConsoleVariable (L"ConIn", PlatformConsole[Index].DevicePath, NULL);
}
if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {
BdsLibUpdateConsoleVariable (L"ConOut", PlatformConsole[Index].DevicePath, NULL);
}
if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {
BdsLibUpdateConsoleVariable (L"ErrOut", PlatformConsole[Index].DevicePath, NULL);
}
Index++;
}
//
// Connect the all the default console with current cosole variable
//
Status = BdsLibConnectAllDefaultConsoles ();
return Status;
}
VOID
PlatformBdsConnectSequence (
VOID
)
/*++
Routine Description:
Connect with predeined platform connect sequence,
the OEM/IBV can customize with their own connect sequence.
Arguments:
None.
Returns:
None.
--*/
{
UINTN Index;
Index = 0;
//
// Here we can get the customized platform connect sequence
// Notes: we can connect with new variable which record the
// last time boots connect device path sequence
//
while (gPlatformConnectSequence[Index] != NULL) {
//
// Build the platform boot option
//
BdsLibConnectDevicePath (gPlatformConnectSequence[Index]);
Index++;
}
//
// Just use the simple policy to connect all devices
//
BdsLibConnectAll ();
}
VOID
PlatformBdsGetDriverOption (
IN OUT LIST_ENTRY *BdsDriverLists
)
/*++
Routine Description:
Load the predefined driver option, OEM/IBV can customize this
to load their own drivers
Arguments:
BdsDriverLists - The header of the driver option link list.
Returns:
None.
--*/
{
UINTN Index;
Index = 0;
//
// Here we can get the customized platform driver option
//
while (gPlatformDriverOption[Index] != NULL) {
//
// Build the platform boot option
//
BdsLibRegisterNewOption (BdsDriverLists, gPlatformDriverOption[Index], NULL, L"DriverOrder");
Index++;
}
}
VOID
PlatformBdsDiagnostics (
IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,
IN BOOLEAN QuietBoot
)
/*++
Routine Description:
Perform the platform diagnostic, such like test memory. OEM/IBV also
can customize this fuction to support specific platform diagnostic.
Arguments:
MemoryTestLevel - The memory test intensive level
QuietBoot - Indicate if need to enable the quiet boot
Returns:
None.
--*/
{
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) {
EnableQuietBootEx (&gEfiDefaultBmpLogoGuid, mBdsImageHandle);
//
// Perform system diagnostic
//
Status = BdsMemoryTest (MemoryTestLevel);
if (EFI_ERROR (Status)) {
DisableQuietBoot ();
}
return ;
}
//
// Perform system diagnostic
//
Status = BdsMemoryTest (MemoryTestLevel);
}
VOID
PlatformBdsPolicyBehavior (
IN EFI_BDS_ARCH_PROTOCOL_INSTANCE *PrivateData,
IN OUT LIST_ENTRY *DriverOptionList,
IN OUT LIST_ENTRY *BootOptionList
)
/*++
Routine Description:
The function will excute with as the platform policy, current policy
is driven by boot mode. IBV/OEM can customize this code for their specific
policy action.
Arguments:
PrivateData - The EFI_BDS_ARCH_PROTOCOL_INSTANCE instance
DriverOptionList - The header of the driver option link list
BootOptionList - The header of the boot option link list
Returns:
None.
--*/
{
EFI_STATUS Status;
UINT16 Timeout;
//
// Init the time out value
//
Timeout = BdsLibGetTimeout ();
//
// Load the driver option as the driver option list
//
PlatformBdsGetDriverOption (DriverOptionList);
//
// Get current Boot Mode
//
Status = BdsLibGetBootMode (&PrivateData->BootMode);
//
// Go the different platform policy with different boot mode
// Notes: this part code can be change with the table policy
//
switch (PrivateData->BootMode) {
case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:
case BOOT_WITH_MINIMAL_CONFIGURATION:
//
// In no-configuration boot mode, we can connect the
// console directly.
//
BdsLibConnectAllDefaultConsoles ();
PlatformBdsDiagnostics (IGNORE, TRUE);
//
// Perform some platform specific connect sequence
//
PlatformBdsConnectSequence ();
//
// Notes: current time out = 0 can not enter the
// front page
//
PlatformBdsEnterFrontPage (Timeout, FALSE);
//
// Check the boot option with the boot option list
//
BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder");
break;
case BOOT_ON_FLASH_UPDATE:
//
// Boot with the specific configuration
//
PlatformBdsConnectConsole (gPlatformConsole);
PlatformBdsDiagnostics (EXTENSIVE, FALSE);
BdsLibConnectAll ();
ProcessCapsules (BOOT_ON_FLASH_UPDATE);
break;
case BOOT_IN_RECOVERY_MODE:
//
// In recovery mode, just connect platform console
// and show up the front page
//
PlatformBdsConnectConsole (gPlatformConsole);
PlatformBdsDiagnostics (EXTENSIVE, FALSE);
//
// In recovery boot mode, we still enter to the
// frong page now
//
PlatformBdsEnterFrontPage (Timeout, FALSE);
break;
case BOOT_WITH_FULL_CONFIGURATION:
case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:
case BOOT_WITH_DEFAULT_SETTINGS:
default:
//
// Connect platform console
//
Status = PlatformBdsConnectConsole (gPlatformConsole);
if (EFI_ERROR (Status)) {
//
// Here OEM/IBV can customize with defined action
//
PlatformBdsNoConsoleAction ();
}
PlatformBdsDiagnostics (IGNORE, TRUE);
//
// Perform some platform specific connect sequence
//
PlatformBdsConnectSequence ();
//
// Give one chance to enter the setup if we
// have the time out
//
PlatformBdsEnterFrontPage (Timeout, FALSE);
//
// Here we have enough time to do the enumeration of boot device
//
BdsLibEnumerateAllBootOption (BootOptionList);
break;
}
return ;
}
VOID
PlatformBdsBootSuccess (
IN BDS_COMMON_OPTION *Option
)
/*++
Routine Description:
Hook point after a boot attempt succeeds. We don't expect a boot option to
return, so the EFI 1.0 specification defines that you will default to an
interactive mode and stop processing the BootOrder list in this case. This
is alos a platform implementation and can be customized by IBV/OEM.
Arguments:
Option - Pointer to Boot Option that succeeded to boot.
Returns:
None.
--*/
{
CHAR16 *TmpStr;
//
// If Boot returned with EFI_SUCCESS and there is not in the boot device
// select loop then we need to pop up a UI and wait for user input.
//
TmpStr = Option->StatusString;
if (TmpStr != NULL) {
BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);
FreePool (TmpStr);
}
}
VOID
PlatformBdsBootFail (
IN BDS_COMMON_OPTION *Option,
IN EFI_STATUS Status,
IN CHAR16 *ExitData,
IN UINTN ExitDataSize
)
/*++
Routine Description:
Hook point after a boot attempt fails.
Arguments:
Option - Pointer to Boot Option that failed to boot.
Status - Status returned from failed boot.
ExitData - Exit data returned from failed boot.
ExitDataSize - Exit data size returned from failed boot.
Returns:
None.
--*/
{
CHAR16 *TmpStr;
//
// If Boot returned with failed status then we need to pop up a UI and wait
// for user input.
//
TmpStr = Option->StatusString;
if (TmpStr != NULL) {
BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);
FreePool (TmpStr);
}
}
EFI_STATUS
PlatformBdsNoConsoleAction (
VOID
)
/*++
Routine Description:
This function is remained for IBV/OEM to do some platform action,
if there no console device can be connected.
Arguments:
None.
Returns:
EFI_SUCCESS - Direct return success now.
--*/
{
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
PlatformBdsLockNonUpdatableFlash (
VOID
)
{
return EFI_SUCCESS;
}

View File

@ -0,0 +1,165 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
BdsPlatform.h
Abstract:
Head file for BDS Platform specific code
--*/
#ifndef _BDS_PLATFORM_H
#define _BDS_PLATFORM_H
#include <PiDxe.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/BaseLib.h>
#include <Library/PcdLib.h>
#include <Library/GenericBdsLib.h>
#include <Library/PlatformBdsLib.h>
#include <Library/GraphicsLib.h>
#include <Protocol/UnixThunk.h>
#include <Protocol/UnixIo.h>
#include <Guid/Bmp.h>
extern BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole[];
extern EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[];
extern EFI_DEVICE_PATH_PROTOCOL *gPlatformDriverOption[];
#define gEndEntire \
{ \
END_DEVICE_PATH_TYPE,\
END_ENTIRE_DEVICE_PATH_SUBTYPE,\
END_DEVICE_PATH_LENGTH,\
0\
}
typedef struct {
VENDOR_DEVICE_PATH VendorDevicePath;
UINT32 Instance;
} UNIX_VENDOR_DEVICE_PATH_NODE;
//
// Below is the platform console device path
//
typedef struct {
VENDOR_DEVICE_PATH UnixBus;
UNIX_VENDOR_DEVICE_PATH_NODE SerialDevice;
UART_DEVICE_PATH Uart;
VENDOR_DEVICE_PATH TerminalType;
EFI_DEVICE_PATH_PROTOCOL End;
} UNIX_ISA_SERIAL_DEVICE_PATH;
typedef struct {
VENDOR_DEVICE_PATH UnixBus;
UNIX_VENDOR_DEVICE_PATH_NODE UnixUgaDevice;
EFI_DEVICE_PATH_PROTOCOL End;
} UNIX_PLATFORM_UGA_DEVICE_PATH;
typedef struct {
VENDOR_DEVICE_PATH UnixBus;
UNIX_VENDOR_DEVICE_PATH_NODE ConsoleDevice;
EFI_DEVICE_PATH_PROTOCOL End;
} UNIX_CONSOLE_DEVICE_PATH;
//
// Platform BDS Functions
//
VOID
PlatformBdsInit (
IN EFI_BDS_ARCH_PROTOCOL_INSTANCE *PrivateData
)
;
VOID
PlatformBdsPolicyBehavior (
IN EFI_BDS_ARCH_PROTOCOL_INSTANCE *PrivateData,
IN LIST_ENTRY *DriverOptionList,
IN LIST_ENTRY *BootOptionList
)
;
VOID
PlatformBdsGetDriverOption (
IN LIST_ENTRY *BdsDriverLists
)
;
EFI_STATUS
BdsMemoryTest (
EXTENDMEM_COVERAGE_LEVEL Level
)
;
EFI_STATUS
PlatformBdsShowProgress (
EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleForeground,
EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleBackground,
CHAR16 *Title,
EFI_GRAPHICS_OUTPUT_BLT_PIXEL ProgressColor,
UINTN Progress,
UINTN PreviousValue
)
;
VOID
PlatformBdsConnectSequence (
VOID
)
;
VOID
PlatformBdsBootFail (
IN BDS_COMMON_OPTION *Option,
IN EFI_STATUS Status,
IN CHAR16 *ExitData,
IN UINTN ExitDataSize
)
;
VOID
PlatformBdsBootSuccess (
IN BDS_COMMON_OPTION *Option
)
;
EFI_STATUS
ProcessCapsules (
EFI_BOOT_MODE BootMode
)
;
EFI_STATUS
PlatformBdsConnectConsole (
IN BDS_CONSOLE_CONNECT_ENTRY *PlatformConsole
)
;
EFI_STATUS
PlatformBdsNoConsoleAction (
VOID
)
;
VOID
PlatformBdsEnterFrontPage (
IN UINT16 TimeoutDefault,
IN BOOLEAN ConnectAllHappened
);
#endif // _BDS_PLATFORM_H

View File

@ -0,0 +1,80 @@
#/** @file
# Platfrom BDS driver
#
# Do platform action customized by IBV/OEM.
# Copyright (c) 2006, Intel Corporation
#
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#
#**/
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = PlatformBdsLib
FILE_GUID = f392b762-8985-11db-be87-0040d02b1835
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
LIBRARY_CLASS = PlatformBdsLib|DXE_DRIVER
EDK_RELEASE_VERSION = 0x00020000
EFI_SPECIFICATION_VERSION = 0x00020000
ENTRY_POINT = BdsInitialize
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources.common]
BdsPlatform.c
BdsPlatform.h
PlatformData.c
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
UnixPkg/UnixPkg.dec
[LibraryClasses]
# EdkGenericPlatformBdsLib
# HiiLib
# DevicePathLib
# UefiRuntimeServicesTableLib
# UefiBootServicesTableLib
# BaseMemoryLib
# MemoryAllocationLib
# EdkGenericBdsLib
# HobLib
# ReportStatusCodeLib
# EdkIfrSupportLib
# PrintLib
# PerformanceLib
# DxeServicesTableLib
# EdkGraphicsLib
# BaseLib
# UefiDriverEntryPoint
# UefiLib
# DebugLib
BaseLib
MemoryAllocationLib
UefiBootServicesTableLib
BaseMemoryLib
DebugLib
PcdLib
GraphicsLib
GenericBdsLib
[Guids]
gEfiDefaultBmpLogoGuid # ALWAYS_CONSUMED

View File

@ -0,0 +1,206 @@
<?xml version="1.0" encoding="UTF-8"?>
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<MsaHeader>
<ModuleName>Bds</ModuleName>
<ModuleType>DXE_DRIVER</ModuleType>
<GuidValue>f392b762-8985-11db-be87-0040d02b1835</GuidValue>
<Version>1.0</Version>
<Abstract>Platfrom BDS driver</Abstract>
<Description>Do platform action customized by IBV/OEM.</Description>
<Copyright>Copyright (c) 2006, Intel Corporation</Copyright>
<License>All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
</MsaHeader>
<ModuleDefinitions>
<SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
<BinaryModule>false</BinaryModule>
<OutputFileBasename>Bds</OutputFileBasename>
</ModuleDefinitions>
<LibraryClassDefinitions>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>DebugLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UefiLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UefiDriverEntryPoint</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>BaseLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>EdkGraphicsLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>DxeServicesTableLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>PerformanceLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>PrintLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>EdkIfrSupportLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>ReportStatusCodeLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>HobLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>EdkGenericBdsLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>MemoryAllocationLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>BaseMemoryLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UefiBootServicesTableLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UefiRuntimeServicesTableLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>DevicePathLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>HiiLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>EdkGenericPlatformBdsLib</Keyword>
</LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>PlatformData.c</Filename>
<Filename>BdsPlatform.h</Filename>
<Filename>BdsPlatform.c</Filename>
<Filename>Bds.dxs</Filename>
</SourceFiles>
<PackageDependencies>
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
<Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>
</PackageDependencies>
<Protocols>
<Protocol Usage="ALWAYS_PRODUCED">
<ProtocolCName>gEfiBdsArchProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="ALWAYS_CONSUMED">
<ProtocolCName>gEfiLegacyBiosProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="ALWAYS_CONSUMED">
<ProtocolCName>gEfiHiiProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="ALWAYS_CONSUMED">
<ProtocolCName>gEfiFormCallbackProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="ALWAYS_CONSUMED">
<ProtocolCName>gEfiDataHubProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="ALWAYS_CONSUMED">
<ProtocolCName>gEfiFormBrowserProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="ALWAYS_CONSUMED">
<ProtocolCName>gEfiConsoleControlProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="ALWAYS_CONSUMED">
<ProtocolCName>gEfiCpuIoProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="ALWAYS_CONSUMED">
<ProtocolCName>gEfiUgaDrawProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="ALWAYS_CONSUMED">
<ProtocolCName>gEfiLoadFileProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="ALWAYS_CONSUMED">
<ProtocolCName>gEfiSimpleFileSystemProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="ALWAYS_CONSUMED">
<ProtocolCName>gEfiDevicePathProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="ALWAYS_CONSUMED">
<ProtocolCName>gEfiBlockIoProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="ALWAYS_CONSUMED">
<ProtocolCName>gEfiSerialIoProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="ALWAYS_CONSUMED">
<ProtocolCName>gEfiGenericMemTestProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="SOMETIMES_CONSUMED">
<ProtocolCName>gEfiCpuArchProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="SOMETIMES_CONSUMED">
<ProtocolCName>gEfiDriverBindingProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="ALWAYS_CONSUMED">
<ProtocolCName>gEfiUnixThunkProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="ALWAYS_CONSUMED">
<ProtocolCName>gEfiUnixIoProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="ALWAYS_CONSUMED">
<ProtocolCName>gEfiUnixUgaIoProtocolGuid</ProtocolCName>
</Protocol>
</Protocols>
<DataHubs>
<DataHubRecord Usage="SOMETIMES_CONSUMED">
<DataHubCName>BiosVendor</DataHubCName>
</DataHubRecord>
<DataHubRecord Usage="SOMETIMES_CONSUMED">
<DataHubCName>SystemManufacturer</DataHubCName>
</DataHubRecord>
<DataHubRecord Usage="SOMETIMES_CONSUMED">
<DataHubCName>ProcessorVersion</DataHubCName>
</DataHubRecord>
<DataHubRecord Usage="SOMETIMES_CONSUMED">
<DataHubCName>ProcessorFrequency</DataHubCName>
</DataHubRecord>
<DataHubRecord Usage="SOMETIMES_CONSUMED">
<DataHubCName>MemoryArray</DataHubCName>
</DataHubRecord>
<DataHubRecord Usage="SOMETIMES_CONSUMED">
<DataHubCName>SerialIoDevice</DataHubCName>
</DataHubRecord>
<DataHubRecord Usage="SOMETIMES_CONSUMED">
<DataHubCName>SerialIoPort</DataHubCName>
</DataHubRecord>
</DataHubs>
<Guids>
<GuidCNames Usage="ALWAYS_CONSUMED">
<GuidCName>gEfiBootStateGuid</GuidCName>
</GuidCNames>
<GuidCNames Usage="ALWAYS_CONSUMED">
<GuidCName>gEfiGlobalVariableGuid</GuidCName>
</GuidCNames>
<GuidCNames Usage="ALWAYS_CONSUMED">
<GuidCName>gEfiFlashMapHobGuid</GuidCName>
</GuidCNames>
<GuidCNames Usage="ALWAYS_CONSUMED">
<GuidCName>gEfiFileSystemVolumeLabelInfoIdGuid</GuidCName>
</GuidCNames>
<GuidCNames Usage="ALWAYS_CONSUMED">
<GuidCName>gEfiFileInfoGuid</GuidCName>
</GuidCNames>
<GuidCNames Usage="ALWAYS_CONSUMED">
<GuidCName>gEfiDefaultBmpLogoGuid</GuidCName>
</GuidCNames>
</Guids>
<Externs>
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
<Extern>
<ModuleEntryPoint>BdsInitialize</ModuleEntryPoint>
</Extern>
</Externs>
</ModuleSurfaceArea>

View File

@ -0,0 +1,120 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
PlatformData.c
Abstract:
Defined the platform specific device path which will be used by
platform Bbd to perform the platform policy connect.
--*/
#include "BdsPlatform.h"
//
// Predefined platform default time out value
//
UINT16 gPlatformBootTimeOutDefault = 10;
//
// Platform specific keyboard device path
//
UNIX_PLATFORM_UGA_DEVICE_PATH gUgaDevicePath0 =
{
{
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
(UINT8) (sizeof (VENDOR_DEVICE_PATH)),
(UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8),
EFI_UNIX_THUNK_PROTOCOL_GUID
},
{
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
(UINT8) (sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)),
(UINT8) ((sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)) >> 8),
EFI_UNIX_UGA_GUID,
0
},
gEndEntire
};
UNIX_PLATFORM_UGA_DEVICE_PATH gUgaDevicePath1 = {
{
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
(UINT8) (sizeof (VENDOR_DEVICE_PATH)),
(UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8),
EFI_UNIX_THUNK_PROTOCOL_GUID
},
{
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
(UINT8) (sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)),
(UINT8) ((sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)) >> 8),
EFI_UNIX_UGA_GUID,
1
},
gEndEntire
};
UNIX_CONSOLE_DEVICE_PATH gUnixConsoleDevicePath = {
{
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
(UINT8) (sizeof (VENDOR_DEVICE_PATH)),
(UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8),
EFI_UNIX_THUNK_PROTOCOL_GUID
},
{
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
(UINT8) (sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)),
(UINT8) ((sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)) >> 8),
EFI_UNIX_CONSOLE_GUID,
0
},
gEndEntire
};
//
// Predefined platform default console device path
//
BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole[] = {
{
(EFI_DEVICE_PATH_PROTOCOL *) &gUnixConsoleDevicePath,
(CONSOLE_OUT | CONSOLE_IN)
},
{
(EFI_DEVICE_PATH_PROTOCOL *) &gUgaDevicePath0,
(CONSOLE_OUT | CONSOLE_IN)
},
{
(EFI_DEVICE_PATH_PROTOCOL *) &gUgaDevicePath1,
(CONSOLE_OUT | CONSOLE_IN)
},
{
NULL,
0
}
};
//
// Predefined platform specific driver option
//
EFI_DEVICE_PATH_PROTOCOL *gPlatformDriverOption[] = { NULL };
//
// Predefined platform connect sequence
//
EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[] = { NULL };

View File

@ -0,0 +1,54 @@
/*++
Copyright (c) 2006 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
TianoPeCoffLoader.c
Abstract:
Wrap the Base PE/COFF loader with the PE COFF Protocol
--*/
#include <Guid/PeiPeCoffLoader.h>
#include <Library/EdkPeCoffLoaderLib.h>
EFI_PEI_PE_COFF_LOADER_PROTOCOL *mPeiEfiPeiPeCoffLoader;
EFI_STATUS
EFIAPI
PeCoffLoaderConstructor (
IN EFI_FFS_FILE_HEADER *FfsHeader,
IN EFI_PEI_SERVICES **PeiServices
)
{
EFI_STATUS Status;
Status = (*PeiServices)->LocatePpi (
PeiServices,
&gEfiPeiPeCoffLoaderGuid,
0,
NULL,
(VOID **)&mPeiEfiPeiPeCoffLoader
);
return Status;
}
EFI_PEI_PE_COFF_LOADER_PROTOCOL *
EFIAPI
GetPeCoffLoaderProtocol (
)
{
return mPeiEfiPeiPeCoffLoader;
}

View File

@ -0,0 +1,41 @@
#/** @file
# Component description file for the Nt32PeCoffLoaderLib library.
#
# EdkPeCoffLoaderLib library class for NT32 instance implemented by PeiPeCoffLoader PPI.
# Copyright (c) 2006, Intel Corporation
#
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#
#**/
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = UnixPeCoffLoaderLib
FILE_GUID = f3cf597e-8985-11db-95f6-0040d02b1835
MODULE_TYPE = PEIM
VERSION_STRING = 1.0
LIBRARY_CLASS = EdkPeCoffLoaderLib
EDK_RELEASE_VERSION = 0x00020000
EFI_SPECIFICATION_VERSION = 0x00020000
CONSTRUCTOR = PeCoffLoaderConstructor
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources.common]
UnixPeCoffLoader.c
[Guids]
gEfiPeiPeCoffLoaderGuid # SOMETIMES_CONSUMED

View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">
<MsaHeader>
<ModuleName>UnixPeCoffLoaderLib</ModuleName>
<ModuleType>PEIM</ModuleType>
<GuidValue>f3cf597e-8985-11db-95f6-0040d02b1835</GuidValue>
<Version>1.0</Version>
<Abstract>Component description file for the Nt32PeCoffLoaderLib library.</Abstract>
<Description>EdkPeCoffLoaderLib library class for NT32 instance implemented by PeiPeCoffLoader PPI.</Description>
<Copyright>Copyright (c) 2006, Intel Corporation</Copyright>
<License>All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
</MsaHeader>
<ModuleDefinitions>
<SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
<BinaryModule>false</BinaryModule>
<OutputFileBasename>UnixPeCoffLoaderLib</OutputFileBasename>
</ModuleDefinitions>
<LibraryClassDefinitions>
<LibraryClass Usage="ALWAYS_PRODUCED">
<Keyword>EdkPeCoffLoaderLib</Keyword>
</LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>UnixPeCoffLoader.c</Filename>
</SourceFiles>
<PackageDependencies>
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
<Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>
</PackageDependencies>
<Guids>
<GuidCNames Usage="SOMETIMES_CONSUMED">
<GuidCName>gEfiPeiPeCoffLoaderGuid</GuidCName>
</GuidCNames>
</Guids>
<Externs>
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
<Extern>
<Constructor>PeCoffLoaderConstructor</Constructor>
</Extern>
</Externs>
</ModuleSurfaceArea>

View File

@ -0,0 +1,140 @@
/*++
Copyright (c) 2006 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
Metronome.c
Abstract:
UNIX Emulation Metronome Architectural Protocol Driver as defined in DXE CIS
--*/
#include "PiDxe.h"
#include "UnixDxe.h"
#include <Protocol/Metronome.h>
#include "Metronome.h"
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/UnixLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
//
// Global Variables
//
EFI_METRONOME_ARCH_PROTOCOL mMetronome = {
UnixMetronomeDriverWaitForTick,
TICK_PERIOD
};
//
// Worker Functions
//
EFI_STATUS
EFIAPI
UnixMetronomeDriverWaitForTick (
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);
gUnix->Sleep ((UINT32) SleepTime);
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
UnixMetronomeDriverInitialize (
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;
DEBUG ((EFI_D_ERROR, "*******************file %d line %d\n", __FUNCTION__, __LINE__));
Status = gBS->InstallProtocolInterface (
&Handle,
&gEfiMetronomeArchProtocolGuid,
EFI_NATIVE_INTERFACE,
&mMetronome
);
return Status;
}

View File

@ -0,0 +1,84 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
Metronome.h
Abstract:
UNIX Emulation Metronome Architectural Protocol Driver as defined in DXE CIS
--*/
#ifndef _UNIX_THUNK_METRONOME_H_
#define _UNIX_THUNK_METRONOME_H_
//
// Period of on tick in 100 nanosecond units
//
#define TICK_PERIOD 2000
//
// Function Prototypes
//
EFI_STATUS
EFIAPI
UnixMetronomeDriverInitialize (
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
UnixMetronomeDriverWaitForTick (
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

View File

@ -0,0 +1,60 @@
#/** @file
# Unix Emulation Metronome Architectural Protocol Driver as defined in DXE CIS
#
# This metronome module simulates metronome by Sleep WinAPI.
# Copyright (c) 2006, Intel Corporation
#
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#
#**/
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = Metronome
FILE_GUID = f348f6fe-8985-11db-b4c3-0040d02b1835
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
EDK_RELEASE_VERSION = 0x00020000
EFI_SPECIFICATION_VERSION = 0x00020000
ENTRY_POINT = UnixMetronomeDriverInitialize
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources.common]
Metronome.h
Metronome.c
[Packages]
MdePkg/MdePkg.dec
UnixPkg/UnixPkg.dec
[LibraryClasses]
UefiBootServicesTableLib
MemoryAllocationLib
UnixLib
UefiDriverEntryPoint
UefiLib
DebugLib
BaseLib
[Protocols]
gEfiMetronomeArchProtocolGuid # PROTOCOL ALWAYS_PRODUCED
[Depex]
TRUE

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">
<MsaHeader>
<ModuleName>Metronome</ModuleName>
<ModuleType>DXE_DRIVER</ModuleType>
<GuidValue>f348f6fe-8985-11db-b4c3-0040d02b1835</GuidValue>
<Version>1.0</Version>
<Abstract>Unix Emulation Metronome Architectural Protocol Driver as defined in DXE CIS</Abstract>
<Description>
This metronome module simulates metronome by Sleep WinAPI.
</Description>
<Copyright>Copyright (c) 2006, Intel Corporation</Copyright>
<License>All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
</MsaHeader>
<ModuleDefinitions>
<SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
<BinaryModule>false</BinaryModule>
<OutputFileBasename>Metronome</OutputFileBasename>
</ModuleDefinitions>
<LibraryClassDefinitions>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>BaseLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>DebugLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UefiLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UefiDriverEntryPoint</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UnixLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>MemoryAllocationLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UefiBootServicesTableLib</Keyword>
</LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>Metronome.c</Filename>
<Filename>Metronome.h</Filename>
<Filename>Metronome.dxs</Filename>
</SourceFiles>
<PackageDependencies>
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
<Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>
</PackageDependencies>
<Protocols>
<Protocol Usage="ALWAYS_PRODUCED">
<ProtocolCName>gEfiMetronomeArchProtocolGuid</ProtocolCName>
</Protocol>
</Protocols>
<Externs>
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
<Extern>
<ModuleEntryPoint>UnixMetronomeDriverInitialize</ModuleEntryPoint>
</Extern>
</Externs>
</ModuleSurfaceArea>

View File

@ -0,0 +1,57 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
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_SUBCLASS_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 */

Binary file not shown.

View File

@ -0,0 +1,88 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
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_SUBCLASS_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 */

View File

@ -0,0 +1,33 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
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_SUBCLASS_TABLE_DATA(EFI_MISC_BOOT_INFORMATION_STATUS_DATA, BootInformationStatus) = {
EfiBootInformationStatusNoError, // BootInformationStatus
{0} // BootInformationData
};
/* eof - MiscBootInformationData.c */

View File

@ -0,0 +1,45 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
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_SUBCLASS_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
};
/* eof - MiscChassisManufacaturerData.c */

View File

@ -0,0 +1,175 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
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

View File

@ -0,0 +1,37 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
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_SUBCLASS_TABLE_DATA(EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES_DATA, NumberOfInstallableLanguages) = {
1, // NumberOfInstallableLanguages
{ // LanguageFlags
0, // AbbreviatedLanguageFormat
0 // Reserved
},
0, // CurrentLanguageNumber
};
/* eof - MiscNumberOfInstallableLanguagesData.c */

Binary file not shown.

View File

@ -0,0 +1,32 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
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_SUBCLASS_TABLE_DATA(EFI_MISC_OEM_STRING_DATA, OemString) = {
{ STRING_TOKEN(STR_MISC_OEM_STRING) }
};
/* eof - MiscOemStringData.c */

View File

@ -0,0 +1,99 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
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_SUBCLASS_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, 0, {0, 0}}, 0, 0}, {{0, 0, {0, 0}}, 0, 0}, {0, 0, {0, 0}}}} // PortPath
};
//
// Static (possibly build generated) Bios Vendor data.
//
MISC_SUBCLASS_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, 0, {0, 0}}, 0, 0}, {{0, 0, {0, 0}}, 0, 0}, {0, 0, {0, 0}}}} // PortPath
};
MISC_SUBCLASS_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, 0, {0, 0}}, 0, 0}, {{0, 0, {0, 0}}, 0, 0}, {0, 0, {0, 0}}}} // PortPath
};
MISC_SUBCLASS_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, 0, {0, 0}}, 0, 0}, {{0, 0, {0, 0}}, 0, 0}, {0, 0, {0, 0}}}} // PortPath
};
MISC_SUBCLASS_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, 0, {0, 0}}, 0, 0}, {{0, 0, {0, 0}}, 0, 0}, {0, 0, {0, 0}}}} // PortPath
};
MISC_SUBCLASS_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, 0, {0, 0}}, 0, 0}, {{0, 0, {0, 0}}, 0, 0}, {0, 0, {0, 0}}}} // PortPath
};
MISC_SUBCLASS_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, 0, {0, 0}}, 0, 0}, {{0, 0, {0, 0}}, 0, 0}, {0, 0, {0, 0}}}} // PortPath
};
/* eof - MiscPortInternalConnectorDesignatorData.c */

View File

@ -0,0 +1,266 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
MiscPortInternalConnectorDesignatorFunction.c
Abstract:
This driver parses the mMiscSubclassDataTable structure and reports
any generated data to the DataHub.
--*/
#include "MiscSubClassDriver.h"
//
//
//
MISC_SUBCLASS_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.
--*/
{
STATIC BOOLEAN Done = FALSE;
STATIC PS2_CONN_DEVICE_PATH mPs2KeyboardDevicePath = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0303, 0), DP_END };
STATIC PS2_CONN_DEVICE_PATH mPs2MouseDevicePath = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0303, 1), DP_END };
STATIC SERIAL_CONN_DEVICE_PATH mCom1DevicePath = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0501, 0), DP_END };
STATIC SERIAL_CONN_DEVICE_PATH mCom2DevicePath = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0501, 1), DP_END };
//STATIC PARALLEL_CONN_DEVICE_PATH mLpt1DevicePath = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0401, 0), DP_END };
STATIC FLOOPY_CONN_DEVICE_PATH mFloopyADevicePath = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0604, 0), DP_END };
//STATIC FLOOPY_CONN_DEVICE_PATH mFloopyBDevicePath = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0604, 1), DP_END };
//STATIC USB_PORT_DEVICE_PATH mUsb0DevicePath = { DP_ACPI, DP_PCI (0x1d, 0x00), DP_END };
//STATIC USB_PORT_DEVICE_PATH mUsb1DevicePath = { DP_ACPI, DP_PCI (0x1d, 0x01), DP_END };
//STATIC USB_PORT_DEVICE_PATH mUsb2DevicePath = { DP_ACPI, DP_PCI (0x1d, 0x02), DP_END };
//STATIC USB_PORT_DEVICE_PATH mUsb3DevicePath = { DP_ACPI, DP_PCI (0x1d, 0x07), DP_END };
//STATIC IDE_DEVICE_PATH mIdeDevicePath = { DP_ACPI, DP_PCI (0x1F, 0x01), DP_END };
//STATIC GB_NIC_DEVICE_PATH mGbNicDevicePath = { DP_ACPI, DP_PCI( 0x03,0x00 ),DP_PCI( 0x1F,0x00 ),DP_PCI( 0x07,0x00 ), DP_END };
EFI_DEVICE_PATH_PROTOCOL EndDevicePath = DP_END;
//
// First check for invalid parameters.
//
// Shanmu >> to fix the Device Path Issue...
// if (RecordLen == 0 || RecordData == NULL || LogRecordData == NULL) {
//
if (*RecordLen == 0 || RecordData == NULL || LogRecordData == NULL) {
//
// End Shanmu
//
return EFI_INVALID_PARAMETER;
}
//
// Then check for unsupported RecordType.
//
if (RecordType != EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_RECORD_NUMBER) {
return EFI_UNSUPPORTED;
}
//
// Is this the first time through this function?
//
if (!Done) {
//
// Yes, this is the first time. Inspect/Change the contents of the
// RecordData structure.
//
//
// Device path is only updated here as it was not taking that in static data
//
// Shanmu >> to fix the Device Path Issue...
//
/*
switch (((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortInternalConnectorDesignator)
{
case STR_MISC_PORT_INTERNAL_MOUSE:
{
(EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mPs2MouseDevicePath);
}break;
case STR_MISC_PORT_INTERNAL_KEYBOARD:
{
(EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mPs2KeyboardDevicePath);
}break;
case STR_MISC_PORT_INTERNAL_COM1:
{
(EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mCom1DevicePath);
}break;
case STR_MISC_PORT_INTERNAL_COM2:
{
(EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mCom2DevicePath);
}break;
case STR_MISC_PORT_INTERNAL_LPT1:
{
(EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mLpt1DevicePath);
}break;
case STR_MISC_PORT_INTERNAL_USB1:
{
(EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mUsb0DevicePath);
}break;
case STR_MISC_PORT_INTERNAL_USB2:
{
(EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mUsb1DevicePath);
}break;
case STR_MISC_PORT_INTERNAL_USB3:
{
(EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mUsb2DevicePath);
}break;
case STR_MISC_PORT_INTERNAL_NETWORK:
{
(EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mGbNicDevicePath);
}break;
case STR_MISC_PORT_INTERNAL_FLOPPY:
{
(EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mFloopyADevicePath);
}break;
case STR_MISC_PORT_INTERNAL_IDE1:
{
(EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mIdeDevicePath);
}break;
case STR_MISC_PORT_INTERNAL_IDE2:
{
(EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mIdeDevicePath);
}break;
default:
{
(EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = EndDevicePath;
}break;
}
*/
switch (((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortInternalConnectorDesignator) {
case STR_MISC_PORT_INTERNAL_MOUSE:
{
CopyMem (
&((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortPath,
&mPs2MouseDevicePath,
GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mPs2MouseDevicePath)
);
*RecordLen = *RecordLen - sizeof (EFI_MISC_PORT_DEVICE_PATH) + GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mPs2MouseDevicePath);
}
break;
case STR_MISC_PORT_INTERNAL_KEYBOARD:
{
CopyMem (
&((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortPath,
&mPs2KeyboardDevicePath,
GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mPs2KeyboardDevicePath)
);
*RecordLen = *RecordLen - sizeof (EFI_MISC_PORT_DEVICE_PATH) + GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mPs2KeyboardDevicePath);
}
break;
case STR_MISC_PORT_INTERNAL_COM1:
{
CopyMem (
&((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortPath,
&mCom1DevicePath,
GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mCom1DevicePath)
);
*RecordLen = *RecordLen - sizeof (EFI_MISC_PORT_DEVICE_PATH) + GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mCom1DevicePath);
}
break;
case STR_MISC_PORT_INTERNAL_COM2:
{
CopyMem (
&((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortPath,
&mCom2DevicePath,
GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mCom2DevicePath)
);
*RecordLen = *RecordLen - sizeof (EFI_MISC_PORT_DEVICE_PATH) + GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mCom2DevicePath);
}
break;
case STR_MISC_PORT_INTERNAL_FLOPPY:
{
CopyMem (
&((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortPath,
&mFloopyADevicePath,
GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mFloopyADevicePath)
);
*RecordLen = *RecordLen - sizeof (EFI_MISC_PORT_DEVICE_PATH) + GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mFloopyADevicePath);
}
break;
default:
{
CopyMem (
&((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortPath,
&EndDevicePath,
GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &EndDevicePath)
);
*RecordLen = *RecordLen - sizeof (EFI_MISC_PORT_DEVICE_PATH) + GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &EndDevicePath);
}
break;
}
//
// End Shanmu
//
// Set Done flag to TRUE for next pass through this function.
// Set *LogRecordData to TRUE so data will get logged to Data Hub.
//
Done = TRUE;
*LogRecordData = TRUE;
} else {
//
// No, this is the second time. Reset the state of the Done flag
// to FALSE and tell the data logger that there is no more data
// to be logged for this record type. If any memory allocations
// were made by earlier passes, they must be released now.
//
Done = FALSE;
*LogRecordData = FALSE;
}
return EFI_SUCCESS;
}
/* eof - MiscSystemManufacturerFunction.c */

View File

@ -0,0 +1,42 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
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_SUBCLASS_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 */

View File

@ -0,0 +1,119 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
MiscSubclassDriver.h
Abstract:
Header file for MiscSubclass Driver.
--*/
#ifndef _MISC_SUBCLASS_DRIVER_H
#define _MISC_SUBCLASS_DRIVER_H
#include <FrameworkDxe.h>
#include <UnixDxe.h>
#include <Guid/DataHubRecords.h>
#include <Guid/DataHubProducer.h>
#include <Protocol/DataHub.h>
#include <Protocol/UnixIo.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/FrameworkHiiLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/DevicePathLib.h>
#include <Library/PcdLib.h>
#include <MiscDevicePath.h>
#include <Protocol/DataHub.h>
#include <Protocol/FrameworkHii.h>
#include <Library/HiiLib.h>
//
// Data table entry update function.
//
typedef
EFI_STATUS
(EFIAPI EFI_MISC_SUBCLASS_DATA_FUNCTION) (
IN UINT16 RecordType,
IN UINT32 *RecordLen,
IN OUT EFI_MISC_SUBCLASS_RECORDS *RecordData,
OUT BOOLEAN *LogRecordData
);
//
// Data table entry definition.
//
typedef struct {
UINT16 RecordType;
UINT32 RecordLen;
VOID *RecordData;
EFI_MISC_SUBCLASS_DATA_FUNCTION *Function;
} EFI_MISC_SUBCLASS_DATA_TABLE;
//
// Data Table extern definitions.
//
#define MISC_SUBCLASS_TABLE_EXTERNS(NAME1, NAME2) \
extern NAME1 NAME2 ## Data; \
extern EFI_MISC_SUBCLASS_DATA_FUNCTION NAME2 ## Function
//
// Data Table entries
//
#define MISC_SUBCLASS_TABLE_ENTRY_DATA_ONLY(NAME1, NAME2) { \
NAME1 ## _RECORD_NUMBER, sizeof (NAME1 ## _DATA), &NAME2 ## Data, NULL \
}
#define MISC_SUBCLASS_TABLE_ENTRY_FUNCTION_ONLY(NAME1, NAME2) \
{ \
NAME1 ## _RECORD_NUMBER, 0, NULL, &NAME2 ## Function \
}
#define MISC_SUBCLASS_TABLE_ENTRY_DATA_AND_FUNCTION(NAME1, NAME2, NAME3) \
{ \
NAME1 ## _RECORD_NUMBER, sizeof (NAME1 ## _DATA), &NAME2 ## Data, &NAME3 ## Function \
}
//
// Global definition macros.
//
#define MISC_SUBCLASS_TABLE_DATA(NAME1, NAME2) NAME1 NAME2 ## Data
#define MISC_SUBCLASS_TABLE_FUNCTION(NAME2) \
EFI_STATUS EFIAPI NAME2 ## Function ( \
IN UINT16 RecordType, \
IN UINT32 *RecordLen, \
IN OUT EFI_MISC_SUBCLASS_RECORDS * RecordData, \
OUT BOOLEAN *LogRecordData \
)
//
// Data Table Array
//
extern EFI_MISC_SUBCLASS_DATA_TABLE mMiscSubclassDataTable[];
//
// Data Table Array Entries
//
extern UINTN mMiscSubclassDataTableEntries;
#endif /* _MISC_SUBCLASS_DRIVER_H */
/* eof - MiscSubclassDriver.h */

View File

@ -0,0 +1,100 @@
#/** @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, Intel Corporation
#
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#
#**/
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = MiscSubclass
FILE_GUID = f2fbd108-8985-11db-b06a-0040d02b1835
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
EDK_RELEASE_VERSION = 0x00020000
EFI_SPECIFICATION_VERSION = 0x00020000
ENTRY_POINT = MiscSubclassDriverEntryPoint
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources.common]
MiscPortInternalConnectorDesignatorFunction.c
MiscSystemSlotDesignationData.c
MiscSystemOptionStringData.c
MiscSystemManufacturerFunction.c
MiscSystemManufacturerData.c
MiscSystemLanguageStringData.c
MiscResetCapabilitiesData.c
MiscPortInternalConnectorDesignatorData.c
MiscOemStringData.c
MiscNumberOfInstallableLanguagesData.c
MiscChassisManufacturerData.c
MiscBootInformationData.c
MiscBiosVendorData.c
MiscBaseBoardManufacturerData.c
MiscSubclassDriverDataTable.c
MiscSubclassDriverEntryPoint.c
MiscSubClassDriver.uni
MiscSystemSlotDesignation.uni
MiscSystemOptionString.uni
MiscSystemManufacturer.uni
MiscSystemLanguageString.uni
MiscPortInternalConnectorDesignator.uni
MiscOemString.uni
MiscChassisManufacturer.uni
MiscBiosVendor.uni
MiscBaseBoardManufacturer.uni
[Packages]
MdePkg/MdePkg.dec
IntelFrameworkPkg/IntelFrameworkPkg.dec
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
UnixPkg/UnixPkg.dec
[LibraryClasses]
DevicePathLib
UefiBootServicesTableLib
MemoryAllocationLib
BaseMemoryLib
UefiDriverEntryPoint
UefiLib
HiiLib
DebugLib
BaseLib
[Guids]
gEfiMemorySubClassGuid # SOMETIMES_CONSUMED
gEfiMemoryProducerGuid # SOMETIMES_CONSUMED
gEfiProcessorSubClassGuid # SOMETIMES_CONSUMED
gEfiMiscSubClassGuid # ALWAYS_CONSUMED
[Protocols]
gEfiUnixIoProtocolGuid # PROTOCOL_NOTIFY SOMETIMES_CONSUMED
gEfiDataHubProtocolGuid # PROTOCOL ALWAYS_CONSUMED
[Pcd.common]
gEfiUnixPkgTokenSpaceGuid.PcdUnixMemorySize
[Depex]
gEfiDataHubProtocolGuid

View File

@ -0,0 +1,170 @@
<?xml version="1.0" encoding="UTF-8"?>
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">
<MsaHeader>
<ModuleName>MiscSubclass</ModuleName>
<ModuleType>DXE_DRIVER</ModuleType>
<GuidValue>f2fbd108-8985-11db-b06a-0040d02b1835</GuidValue>
<Version>1.0</Version>
<Abstract>Misc Sub class driver</Abstract>
<Description>
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.
</Description>
<Copyright>Copyright (c) 2006, Intel Corporation</Copyright>
<License>All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
</MsaHeader>
<ModuleDefinitions>
<SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
<BinaryModule>false</BinaryModule>
<OutputFileBasename>MiscSubclass</OutputFileBasename>
</ModuleDefinitions>
<LibraryClassDefinitions>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>BaseLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>DebugLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>HiiLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UefiLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UefiDriverEntryPoint</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>BaseMemoryLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>MemoryAllocationLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UefiBootServicesTableLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>DevicePathLib</Keyword>
</LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename ToolCode="DUMMY">MiscBaseBoardManufacturer.uni</Filename>
<Filename ToolCode="DUMMY">MiscBiosVendor.uni</Filename>
<Filename ToolCode="DUMMY">MiscChassisManufacturer.uni</Filename>
<Filename ToolCode="DUMMY">MiscOemString.uni</Filename>
<Filename ToolCode="DUMMY">MiscPortInternalConnectorDesignator.uni</Filename>
<Filename ToolCode="DUMMY">MiscSystemLanguageString.uni</Filename>
<Filename ToolCode="DUMMY">MiscSystemManufacturer.uni</Filename>
<Filename ToolCode="DUMMY">MiscSystemOptionString.uni</Filename>
<Filename ToolCode="DUMMY">MiscSystemSlotDesignation.uni</Filename>
<Filename>MiscSubclassDriver.uni</Filename>
<Filename>MiscDevicePath.h</Filename>
<Filename>MiscSubclassDriver.h</Filename>
<Filename>MiscSubclassDriverEntryPoint.c</Filename>
<Filename>MiscSubclassDriverDataTable.c</Filename>
<Filename>MiscBaseBoardManufacturerData.c</Filename>
<Filename>MiscBiosVendorData.c</Filename>
<Filename>MiscBootInformationData.c</Filename>
<Filename>MiscChassisManufacturerData.c</Filename>
<Filename>MiscNumberOfInstallableLanguagesData.c</Filename>
<Filename>MiscOemStringData.c</Filename>
<Filename>MiscPortInternalConnectorDesignatorData.c</Filename>
<Filename>MiscResetCapabilitiesData.c</Filename>
<Filename>MiscSystemLanguageStringData.c</Filename>
<Filename>MiscSystemManufacturerData.c</Filename>
<Filename>MiscSystemManufacturerFunction.c</Filename>
<Filename>MiscSystemOptionStringData.c</Filename>
<Filename>MiscSystemSlotDesignationData.c</Filename>
<Filename>MiscPortInternalConnectorDesignatorFunction.c</Filename>
<Filename>MiscSubclassDriver.dxs</Filename>
</SourceFiles>
<PackageDependencies>
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
<Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>
</PackageDependencies>
<Protocols>
<Protocol Usage="ALWAYS_CONSUMED">
<ProtocolCName>gEfiDataHubProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="ALWAYS_CONSUMED">
<ProtocolCName>gEfiHiiProtocolGuid</ProtocolCName>
</Protocol>
<ProtocolNotify Usage="SOMETIMES_CONSUMED">
<ProtocolNotifyCName>gEfiUnixIoProtocolGuid</ProtocolNotifyCName>
</ProtocolNotify>
</Protocols>
<DataHubs>
<DataHubRecord Usage="ALWAYS_PRODUCED">
<DataHubCName>MiscPortKeyboard</DataHubCName>
</DataHubRecord>
<DataHubRecord Usage="ALWAYS_PRODUCED">
<DataHubCName>MiscPortMouse</DataHubCName>
</DataHubRecord>
<DataHubRecord Usage="ALWAYS_PRODUCED">
<DataHubCName>MiscPortCom1</DataHubCName>
</DataHubRecord>
<DataHubRecord Usage="ALWAYS_PRODUCED">
<DataHubCName>MiscPortCom2</DataHubCName>
</DataHubRecord>
<DataHubRecord Usage="ALWAYS_PRODUCED">
<DataHubCName>MiscBiosVendor</DataHubCName>
</DataHubRecord>
<DataHubRecord Usage="ALWAYS_PRODUCED">
<DataHubCName>MiscSystemManufacturer</DataHubCName>
</DataHubRecord>
<DataHubRecord Usage="ALWAYS_PRODUCED">
<DataHubCName>MiscBaseBoardManufacturer</DataHubCName>
</DataHubRecord>
<DataHubRecord Usage="ALWAYS_PRODUCED">
<DataHubCName>MiscChassisManufacturer</DataHubCName>
</DataHubRecord>
<DataHubRecord Usage="ALWAYS_PRODUCED">
<DataHubCName>MiscSystemSlotDesignation</DataHubCName>
</DataHubRecord>
<DataHubRecord Usage="ALWAYS_PRODUCED">
<DataHubCName>OemString</DataHubCName>
</DataHubRecord>
<DataHubRecord Usage="ALWAYS_PRODUCED">
<DataHubCName>SystemOptionString</DataHubCName>
</DataHubRecord>
<DataHubRecord Usage="SOMETIMES_CONSUMED">
<DataHubCName>ProcessorSubClassData</DataHubCName>
</DataHubRecord>
<DataHubRecord Usage="SOMETIMES_PRODUCED">
<DataHubCName>MemorySubClassData</DataHubCName>
</DataHubRecord>
</DataHubs>
<Guids>
<GuidCNames Usage="ALWAYS_CONSUMED">
<GuidCName>gEfiMiscSubClassGuid</GuidCName>
</GuidCNames>
<GuidCNames Usage="SOMETIMES_CONSUMED">
<GuidCName>gEfiProcessorSubClassGuid</GuidCName>
</GuidCNames>
<GuidCNames Usage="SOMETIMES_CONSUMED">
<GuidCName>gEfiMemoryProducerGuid</GuidCName>
</GuidCNames>
<GuidCNames Usage="SOMETIMES_CONSUMED">
<GuidCName>gEfiMemorySubClassGuid</GuidCName>
</GuidCNames>
<GuidCNames Usage="SOMETIMES_CONSUMED">
<GuidCName>gEfiUnixMemoryGuid</GuidCName>
</GuidCNames>
</Guids>
<Externs>
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
<Extern>
<ModuleEntryPoint>MiscSubclassDriverEntryPoint</ModuleEntryPoint>
</Extern>
</Externs>
</ModuleSurfaceArea>

Binary file not shown.

View File

@ -0,0 +1,99 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
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_SUBCLASS_TABLE_EXTERNS (
EFI_MISC_CHASSIS_MANUFACTURER_DATA,
MiscChassisManufacturer
);
MISC_SUBCLASS_TABLE_EXTERNS (
EFI_MISC_BIOS_VENDOR_DATA,
MiscBiosVendor
);
MISC_SUBCLASS_TABLE_EXTERNS (
EFI_MISC_SYSTEM_MANUFACTURER_DATA,
MiscSystemManufacturer
);
MISC_SUBCLASS_TABLE_EXTERNS (
EFI_MISC_BASE_BOARD_MANUFACTURER_DATA,
MiscBaseBoardManufacturer
);
MISC_SUBCLASS_TABLE_EXTERNS (
EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA,
MiscPortInternalConnectorDesignator
);
MISC_SUBCLASS_TABLE_EXTERNS (
EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA,
MiscPortKeyboard
);
MISC_SUBCLASS_TABLE_EXTERNS (
EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA,
MiscPortMouse
);
MISC_SUBCLASS_TABLE_EXTERNS (
EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA,
MiscPortCom1
);
MISC_SUBCLASS_TABLE_EXTERNS (
EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA,
MiscPortCom2
);
MISC_SUBCLASS_TABLE_EXTERNS (
EFI_MISC_SYSTEM_SLOT_DESIGNATION_DATA,
MiscSystemSlotDesignation
);
MISC_SUBCLASS_TABLE_EXTERNS (
EFI_MISC_OEM_STRING_DATA,
OemString
);
MISC_SUBCLASS_TABLE_EXTERNS (
EFI_MISC_SYSTEM_OPTION_STRING_DATA,
SystemOptionString
);
//
// Data Table.
//
EFI_MISC_SUBCLASS_DATA_TABLE mMiscSubclassDataTable[] = {
MISC_SUBCLASS_TABLE_ENTRY_DATA_AND_FUNCTION(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR, MiscPortKeyboard, MiscPortInternalConnectorDesignator),
MISC_SUBCLASS_TABLE_ENTRY_DATA_AND_FUNCTION(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR, MiscPortMouse, MiscPortInternalConnectorDesignator),
MISC_SUBCLASS_TABLE_ENTRY_DATA_AND_FUNCTION(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR, MiscPortCom1, MiscPortInternalConnectorDesignator),
MISC_SUBCLASS_TABLE_ENTRY_DATA_AND_FUNCTION(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR, MiscPortCom2, MiscPortInternalConnectorDesignator),
MISC_SUBCLASS_TABLE_ENTRY_DATA_ONLY(EFI_MISC_BIOS_VENDOR, MiscBiosVendor),
MISC_SUBCLASS_TABLE_ENTRY_DATA_ONLY(EFI_MISC_SYSTEM_MANUFACTURER, MiscSystemManufacturer),
MISC_SUBCLASS_TABLE_ENTRY_DATA_ONLY(EFI_MISC_BASE_BOARD_MANUFACTURER, MiscBaseBoardManufacturer),
MISC_SUBCLASS_TABLE_ENTRY_DATA_ONLY(EFI_MISC_CHASSIS_MANUFACTURER, MiscChassisManufacturer),
MISC_SUBCLASS_TABLE_ENTRY_DATA_ONLY(EFI_MISC_SYSTEM_SLOT_DESIGNATION, MiscSystemSlotDesignation),
MISC_SUBCLASS_TABLE_ENTRY_DATA_ONLY(EFI_MISC_OEM_STRING, OemString),
MISC_SUBCLASS_TABLE_ENTRY_DATA_ONLY(EFI_MISC_SYSTEM_OPTION_STRING, SystemOptionString),
};
//
// Number of Data Table entries.
//
UINTN mMiscSubclassDataTableEntries = (sizeof mMiscSubclassDataTable) / sizeof (EFI_MISC_SUBCLASS_DATA_TABLE);
/* eof - MiscSubclassDriverDataTable.c */

View File

@ -0,0 +1,334 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
MiscSubclassDriverEntryPoint.c
Abstract:
This driver parses the mMiscSubclassDataTable structure and reports
any generated data to the DataHub.
--*/
#include "MiscSubClassDriver.h"
extern UINT8 MiscSubClassStrings[];
//
//
//
EFI_STATUS
LogRecordDataToDataHub (
EFI_DATA_HUB_PROTOCOL *DataHub,
UINT32 RecordType,
UINT32 RecordLen,
VOID *RecordData
)
/*++
Description:
Parameters:
DataHub
%%TBD
RecordType
%%TBD
RecordLen
%%TBD
RecordData
%%TBD
Returns:
EFI_INVALID_PARAMETER
EFI_SUCCESS
Other Data Hub errors
--*/
{
EFI_MISC_SUBCLASS_DRIVER_DATA MiscSubclass;
EFI_STATUS EfiStatus;
//
// Do nothing if data parameters are not valid.
//
if (RecordLen == 0 || RecordData == NULL) {
DEBUG (
(EFI_D_ERROR,
"RecordLen == %d RecordData == %xh\n",
RecordLen,
RecordData)
);
return EFI_INVALID_PARAMETER;
}
//
// Assemble Data Hub record.
//
MiscSubclass.Header.Version = EFI_MISC_SUBCLASS_VERSION;
MiscSubclass.Header.HeaderSize = sizeof (EFI_SUBCLASS_TYPE1_HEADER);
MiscSubclass.Header.Instance = 1;
MiscSubclass.Header.SubInstance = 1;
MiscSubclass.Header.RecordType = RecordType;
CopyMem (
&MiscSubclass.Record,
RecordData,
RecordLen
);
//
// Log Data Hub record.
//
EfiStatus = DataHub->LogData (
DataHub,
&gEfiMiscSubClassGuid,
&gEfiMiscSubClassGuid,
EFI_DATA_RECORD_CLASS_DATA,
&MiscSubclass,
sizeof (EFI_SUBCLASS_TYPE1_HEADER) + RecordLen
);
if (EFI_ERROR (EfiStatus)) {
DEBUG (
(EFI_D_ERROR,
"LogData(%d bytes) == %r\n",
sizeof (EFI_SUBCLASS_TYPE1_HEADER) + RecordLen,
EfiStatus)
);
}
return EfiStatus;
}
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.
--*/
{
EFI_MISC_SUBCLASS_DRIVER_DATA RecordData;
EFI_DATA_HUB_PROTOCOL *DataHub;
EFI_HII_HANDLE HiiHandle;
EFI_STATUS EfiStatus;
UINTN Index;
BOOLEAN LogRecordData;
EFI_MEMORY_SUBCLASS_DRIVER_DATA MemorySubClassData;
UINT64 TotalMemorySize;
CHAR16 *UnixMemString;
//
// Initialize constant portion of subclass header.
//
RecordData.Header.Version = EFI_MISC_SUBCLASS_VERSION;
RecordData.Header.HeaderSize = sizeof (EFI_SUBCLASS_TYPE1_HEADER);
RecordData.Header.Instance = 1;
RecordData.Header.SubInstance = 1;
//
// Locate data hub protocol.
//
EfiStatus = gBS->LocateProtocol (&gEfiDataHubProtocolGuid, NULL, (VOID**) &DataHub);
if (EFI_ERROR (EfiStatus)) {
DEBUG ((EFI_D_ERROR, "Could not locate DataHub protocol. %r\n", EfiStatus));
return EfiStatus;
} else if (DataHub == NULL) {
DEBUG ((EFI_D_ERROR, "LocateProtocol(DataHub) returned NULL pointer!\n"));
return EFI_DEVICE_ERROR;
}
//
// Add our default strings to the HII database. They will be modified later.
//
HiiLibAddPackages (1, &gEfiMiscSubClassGuid, NULL, &HiiHandle, MiscSubclassStrings);
if (EFI_ERROR (EfiStatus)) {
DEBUG ((EFI_D_ERROR, "Could not log default strings to Hii. %r\n", EfiStatus));
return EfiStatus;
}
//
//
//
for (Index = 0; Index < mMiscSubclassDataTableEntries; ++Index) {
//
// Stupidity check! Do nothing if RecordLen is zero.
// %%TBD - Should this be an error or a mechanism for ignoring
// records in the Data Table?
//
if (mMiscSubclassDataTable[Index].RecordLen == 0) {
DEBUG (
(EFI_D_ERROR,
"mMiscSubclassDataTable[%d].RecordLen == 0\n",
Index)
);
continue;
}
//
// Initialize per-record portion of subclass header and
// copy static data into data portion of subclass record.
//
RecordData.Header.RecordType = mMiscSubclassDataTable[Index].RecordType;
if (mMiscSubclassDataTable[Index].RecordData == NULL) {
ZeroMem (
&RecordData.Record,
mMiscSubclassDataTable[Index].RecordLen
);
} else {
CopyMem (
&RecordData.Record,
mMiscSubclassDataTable[Index].RecordData,
mMiscSubclassDataTable[Index].RecordLen
);
}
//
// If the entry does not have a function pointer, just log the data.
//
if (mMiscSubclassDataTable[Index].Function == NULL) {
//
// Log RecordData to Data Hub.
//
EfiStatus = DataHub->LogData (
DataHub,
&gEfiMiscSubClassGuid,
&gEfiMiscSubClassGuid,
EFI_DATA_RECORD_CLASS_DATA,
&RecordData,
sizeof (EFI_SUBCLASS_TYPE1_HEADER) + mMiscSubclassDataTable[Index].RecordLen
);
if (EFI_ERROR (EfiStatus)) {
DEBUG (
(EFI_D_ERROR,
"LogData(%d bytes) == %r\n",
sizeof (EFI_SUBCLASS_TYPE1_HEADER) + mMiscSubclassDataTable[Index].RecordLen,
EfiStatus)
);
}
continue;
}
//
// The entry has a valid function pointer.
// Keep calling the function and logging data until there
// is no more data to log.
//
for (;;) {
EfiStatus = (*mMiscSubclassDataTable[Index].Function)(mMiscSubclassDataTable[Index].RecordType, &mMiscSubclassDataTable[Index].RecordLen, &RecordData.Record, &LogRecordData);
if (EFI_ERROR (EfiStatus)) {
break;
}
if (!LogRecordData) {
break;
}
//
//
//
EfiStatus = DataHub->LogData (
DataHub,
&gEfiMiscSubClassGuid,
&gEfiMiscSubClassGuid,
EFI_DATA_RECORD_CLASS_DATA,
&RecordData,
sizeof (EFI_SUBCLASS_TYPE1_HEADER) + mMiscSubclassDataTable[Index].RecordLen
);
if (EFI_ERROR (EfiStatus)) {
DEBUG (
(EFI_D_ERROR,
"LogData(%d bytes) == %r\n",
sizeof (EFI_SUBCLASS_TYPE1_HEADER) + mMiscSubclassDataTable[Index].RecordLen,
EfiStatus)
);
}
}
}
//
// Log Memory Size info based on PCD setting.
//
MemorySubClassData.Header.Instance = 1;
MemorySubClassData.Header.SubInstance = EFI_SUBCLASS_INSTANCE_NON_APPLICABLE;
MemorySubClassData.Header.RecordType = EFI_MEMORY_ARRAY_START_ADDRESS_RECORD_NUMBER;
//
// Process Memory String in form size!size ...
// So 64!64 is 128 MB
//
UnixMemString = PcdGetPtr (PcdUnixMemorySize);
for (TotalMemorySize = 0; *UnixMemString != '\0';) {
TotalMemorySize += StrDecimalToUint64 (UnixMemString);
while (*UnixMemString != '\0') {
if (*UnixMemString == '!') {
UnixMemString++;
break;
}
UnixMemString++;
}
}
MemorySubClassData.Record.ArrayStartAddress.MemoryArrayStartAddress = 0;
MemorySubClassData.Record.ArrayStartAddress.MemoryArrayEndAddress = LShiftU64 (TotalMemorySize, 20) - 1;
MemorySubClassData.Record.ArrayStartAddress.PhysicalMemoryArrayLink.ProducerName = gEfiMemoryProducerGuid;
MemorySubClassData.Record.ArrayStartAddress.PhysicalMemoryArrayLink.Instance = 1;
MemorySubClassData.Record.ArrayStartAddress.PhysicalMemoryArrayLink.SubInstance = EFI_SUBCLASS_INSTANCE_NON_APPLICABLE;
MemorySubClassData.Record.ArrayStartAddress.MemoryArrayPartitionWidth = 0;
//
// Store memory size data record to data hub.
//
EfiStatus = DataHub->LogData (
DataHub,
&gEfiMemorySubClassGuid,
&gEfiMemoryProducerGuid,
EFI_DATA_RECORD_CLASS_DATA,
&MemorySubClassData,
sizeof (EFI_SUBCLASS_TYPE1_HEADER) + sizeof (EFI_MEMORY_ARRAY_START_ADDRESS_DATA)
);
return EFI_SUCCESS;
}

View File

@ -0,0 +1,33 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
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_SUBCLASS_TABLE_DATA(EFI_MISC_SYSTEM_LANGUAGE_STRING_DATA, SystemLanguageString) = {
0,
STRING_TOKEN(STR_MISC_SYSTEM_LANGUAGE_STRING)
};
/* eof - MiscSystemLanguageStringData.c */

View File

@ -0,0 +1,57 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
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_SUBCLASS_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 */

View File

@ -0,0 +1,122 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
MiscSystemManufacturerFunction.c
Abstract:
This driver parses the mMiscSubclassDataTable structure and reports
any generated data to the DataHub.
--*/
#include "MiscSubClassDriver.h"
//
//
//
MISC_SUBCLASS_TABLE_FUNCTION (
MiscSystemManufacturer
)
/*++
Description:
This function makes boot time changes to the contents of the
MiscSystemManufacturer (Type 13).
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.
--*/
{
STATIC BOOLEAN Done = FALSE;
//
// First check for invalid parameters.
//
if (*RecordLen == 0 || RecordData == NULL || LogRecordData == NULL) {
return EFI_INVALID_PARAMETER;
}
//
// Then check for unsupported RecordType.
//
if (RecordType != EFI_MISC_SYSTEM_MANUFACTURER_RECORD_NUMBER) {
return EFI_UNSUPPORTED;
}
//
// Is this the first time through this function?
//
if (!Done) {
//
// Yes, this is the first time. Inspect/Change the contents of the
// RecordData structure.
//
//
// Set system GUID.
//
// ((EFI_MISC_SYSTEM_MANUFACTURER_DATA *)RecordData)->SystemUuid = %%TBD
//
// Set power-on type.
//
// ((EFI_MISC_SYSTEM_MANUFACTURER_DATA *)RecordData)->SystemWakeupType = %%TBD
//
// Set Done flag to TRUE for next pass through this function.
// Set *LogRecordData to TRUE so data will get logged to Data Hub.
//
Done = TRUE;
*LogRecordData = TRUE;
} else {
//
// No, this is the second time. Reset the state of the Done flag
// to FALSE and tell the data logger that there is no more data
// to be logged for this record type. If any memory allocations
// were made by earlier passes, they must be released now.
//
Done = FALSE;
*LogRecordData = FALSE;
}
return EFI_SUCCESS;
}
/* eof - MiscSystemManufacturerFunction.c */

View File

@ -0,0 +1,32 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
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_SUBCLASS_TABLE_DATA(EFI_MISC_SYSTEM_OPTION_STRING_DATA, SystemOptionString) = {
{STRING_TOKEN(STR_MISC_SYSTEM_OPTION_STRING)}
};
/* eof - MiscSystemOptionStringData.c */

View File

@ -0,0 +1,52 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
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_SUBCLASS_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, 0, {0, 0}} // SlotDevicePath
};
/* eof - MiscSystemSlotsData.c */

View File

@ -0,0 +1,356 @@
/*++
Copyright (c) 2004 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
RealTimeClock.c
Abstract:
UNIX Emulation Architectural Protocol Driver as defined in Tiano
--*/
#include "PiDxe.h"
#include "UnixDxe.h"
#include <Protocol/RealTimeClock.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/UnixLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
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
);
STATIC
EFI_STATUS
EFIAPI
UnixGetTime (
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
{
//
// Check parameter for null pointer
//
if (Time == NULL) {
return EFI_INVALID_PARAMETER;
}
gUnix->GetLocalTime (Time);
if (Capabilities != NULL) {
Capabilities->Resolution = 1;
Capabilities->Accuracy = 50000000;
Capabilities->SetsToZero = FALSE;
}
return EFI_SUCCESS;
}
STATIC
EFI_STATUS
EFIAPI
UnixSetTime (
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
{
EFI_STATUS Status;
if (Time == NULL) {
return EFI_INVALID_PARAMETER;
}
//
// Make sure that the time fields are valid
//
Status = RtcTimeFieldsValid (Time);
if (EFI_ERROR (Status)) {
return Status;
}
return EFI_UNSUPPORTED;
}
STATIC
EFI_STATUS
EFIAPI
UnixGetWakeupTime (
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;
}
STATIC
EFI_STATUS
EFIAPI
UnixSetWakeupTime (
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:
ImageHandle - Image Handle
SystemTable - Pointer to system table
Returns:
EFI_SUCEESS - Real Time Clock Services are installed into the Runtime Services Table
--*/
{
EFI_STATUS Status;
EFI_HANDLE Handle;
SystemTable->RuntimeServices->GetTime = UnixGetTime;
SystemTable->RuntimeServices->SetTime = UnixSetTime;
SystemTable->RuntimeServices->GetWakeupTime = UnixGetWakeupTime;
SystemTable->RuntimeServices->SetWakeupTime = UnixSetWakeupTime;
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
--*/
{
static const INTN DayOfMonth[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
if (Time->Day < 1 ||
Time->Day > DayOfMonth[Time->Month - 1] ||
(Time->Month == 2 && (!IsLeapYear (Time) && Time->Day > 28))
) {
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;
}
}

View File

@ -0,0 +1,58 @@
#/** @file
# Unix 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, Intel Corporation
#
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#
#**/
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = RealTimeClock
FILE_GUID = f3552032-8985-11db-8429-0040d02b1835
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
EDK_RELEASE_VERSION = 0x00020000
EFI_SPECIFICATION_VERSION = 0x00020000
ENTRY_POINT = InitializeRealTimeClock
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources.common]
RealTimeClock.c
[Packages]
MdePkg/MdePkg.dec
UnixPkg/UnixPkg.dec
[LibraryClasses]
UefiBootServicesTableLib
MemoryAllocationLib
UnixLib
UefiDriverEntryPoint
UefiLib
DebugLib
BaseLib
[Protocols]
gEfiRealTimeClockArchProtocolGuid # PROTOCOL ALWAYS_PRODUCED
[Depex]
TRUE

View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">
<MsaHeader>
<ModuleName>RealTimeClock</ModuleName>
<ModuleType>DXE_DRIVER</ModuleType>
<GuidValue>f3552032-8985-11db-8429-0040d02b1835</GuidValue>
<Version>1.0</Version>
<Abstract>Unix Emulation Real time clock Architectural Protocol Driver as defined in TIANO</Abstract>
<Description>
This real time clock module simulates virtual device by time WinAPI.
</Description>
<Copyright>Copyright (c) 2006, Intel Corporation</Copyright>
<License>All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
</MsaHeader>
<ModuleDefinitions>
<SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
<BinaryModule>false</BinaryModule>
<OutputFileBasename>RealTimeClock</OutputFileBasename>
</ModuleDefinitions>
<LibraryClassDefinitions>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>BaseLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>DebugLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UefiLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UefiDriverEntryPoint</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UnixLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>MemoryAllocationLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UefiBootServicesTableLib</Keyword>
</LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>RealTimeClock.c</Filename>
<Filename>RealTimeClock.dxs</Filename>
</SourceFiles>
<PackageDependencies>
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
<Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>
</PackageDependencies>
<Protocols>
<Protocol Usage="ALWAYS_PRODUCED">
<ProtocolCName>gEfiRealTimeClockArchProtocolGuid</ProtocolCName>
</Protocol>
</Protocols>
<Externs>
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
<Extern>
<ModuleEntryPoint>InitializeRealTimeClock</ModuleEntryPoint>
</Extern>
</Externs>
</ModuleSurfaceArea>

View File

@ -0,0 +1,131 @@
/*++
Copyright (c) 2004 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
Reset.c
Abstract:
Reset Architectural Protocol as defined in Tiano under UNIX Emulation
--*/
#include "PiDxe.h"
#include "UnixDxe.h"
#include <Protocol/Reset.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/UnixLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
EFI_STATUS
EFIAPI
InitializeUnixReset (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
STATIC
VOID
EFIAPI
UnixResetSystem (
IN EFI_RESET_TYPE ResetType,
IN EFI_STATUS ResetStatus,
IN UINTN DataSize,
IN CHAR16 *ResetData OPTIONAL
);
EFI_STATUS
EFIAPI
InitializeUnixReset (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
/*++
Routine Description:
Arguments:
ImageHandle of the loaded driver
Pointer to the System Table
Returns:
Status
--*/
// TODO: SystemTable - add argument and description to function comment
{
EFI_STATUS Status;
EFI_HANDLE Handle;
SystemTable->RuntimeServices->ResetSystem = UnixResetSystem;
Handle = NULL;
Status = gBS->InstallMultipleProtocolInterfaces (
&Handle,
&gEfiResetArchProtocolGuid,
NULL,
NULL
);
ASSERT_EFI_ERROR (Status);
return Status;
}
STATIC
VOID
EFIAPI
UnixResetSystem (
IN EFI_RESET_TYPE ResetType,
IN EFI_STATUS ResetStatus,
IN UINTN DataSize,
IN CHAR16 *ResetData OPTIONAL
)
/*++
Routine Description:
TODO: Add function description
Arguments:
ResetType - TODO: add argument description
ResetStatus - TODO: add argument description
DataSize - TODO: add argument description
ResetData - TODO: add argument description
Returns:
EFI_SUCCESS - TODO: Add description for return value
--*/
{
//
// BUGBUG Need to kill all console windows later
//
//
// Discard ResetType, always return 0 as exit code
//
gUnix->Exit (0);
//
// Should never go here
//
while (1)
;
}

View File

@ -0,0 +1,58 @@
#/** @file
# Unix Emulation Reset Architectural Protocol Driver as defined in TIANO
#
# This Reset module simulates system reset by process exit on NT.
# Copyright (c) 2006, Intel Corporation
#
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#
#**/
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = Reset
FILE_GUID = f3613084-8985-11db-8c26-0040d02b1835
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
EDK_RELEASE_VERSION = 0x00020000
EFI_SPECIFICATION_VERSION = 0x00020000
ENTRY_POINT = InitializeUnixReset
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources.common]
Reset.c
[Packages]
MdePkg/MdePkg.dec
UnixPkg/UnixPkg.dec
[LibraryClasses]
UefiBootServicesTableLib
MemoryAllocationLib
UnixLib
UefiDriverEntryPoint
UefiLib
DebugLib
BaseLib
[Protocols]
gEfiResetArchProtocolGuid # PROTOCOL ALWAYS_PRODUCED
[Depex]
TRUE

View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">
<MsaHeader>
<ModuleName>Reset</ModuleName>
<ModuleType>DXE_DRIVER</ModuleType>
<GuidValue>f3613084-8985-11db-8c26-0040d02b1835</GuidValue>
<Version>1.0</Version>
<Abstract>Unix Emulation Reset Architectural Protocol Driver as defined in TIANO</Abstract>
<Description>
This Reset module simulates system reset by process exit on NT.
</Description>
<Copyright>Copyright (c) 2006, Intel Corporation</Copyright>
<License>All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
</MsaHeader>
<ModuleDefinitions>
<SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
<BinaryModule>false</BinaryModule>
<OutputFileBasename>Reset</OutputFileBasename>
</ModuleDefinitions>
<LibraryClassDefinitions>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>BaseLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>DebugLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UefiLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UefiDriverEntryPoint</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UnixLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>MemoryAllocationLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UefiBootServicesTableLib</Keyword>
</LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>Reset.c</Filename>
<Filename>Reset.dxs</Filename>
</SourceFiles>
<PackageDependencies>
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
<Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>
</PackageDependencies>
<Protocols>
<Protocol Usage="ALWAYS_PRODUCED">
<ProtocolCName>gEfiResetArchProtocolGuid</ProtocolCName>
</Protocol>
</Protocols>
<Externs>
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
<Extern>
<ModuleEntryPoint>InitializeUnixReset</ModuleEntryPoint>
</Extern>
</Externs>
</ModuleSurfaceArea>

314
UnixPkg/Sec/FwVol.c Normal file
View File

@ -0,0 +1,314 @@
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
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_FVB2_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;
}

1048
UnixPkg/Sec/SecMain.c Normal file

File diff suppressed because it is too large Load Diff

548
UnixPkg/Sec/SecMain.h Normal file
View File

@ -0,0 +1,548 @@
/*++
Copyright (c) 2006 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
SecMain.h
Abstract:
Include file for host API based SEC
--*/
#include "PiPei.h"
#include "Uefi/UefiSpec.h"
#include <Protocol/UnixThunk.h>
#include <Pi/PiFirmwareVolume.h>
#include <Guid/PeiPeCoffLoader.h>
#include <Ppi/StatusCode.h>
#include <Library/PeCoffLib.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/PrintLib.h>
#include <Library/PcdLib.h>
#include <Library/DebugLib.h>
#define STACK_SIZE 0x20000
typedef struct {
EFI_PHYSICAL_ADDRESS Address;
UINT64 Size;
} UNIX_FD_INFO;
typedef struct {
EFI_PHYSICAL_ADDRESS Memory;
UINT64 Size;
} UNIX_SYSTEM_MEMORY;
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 EFI_PEI_SERVICES **PeiServices,
IN EFI_STATUS_CODE_TYPE CodeType,
IN EFI_STATUS_CODE_VALUE Value,
IN UINT32 Instance,
IN EFI_GUID * CallerId,
IN EFI_STATUS_CODE_DATA * Data 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
--*/
;
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
CountSeperatorsInString (
IN const CHAR16 *String,
IN CHAR16 Seperator
)
/*++
Routine Description:
TODO: Add function description
Arguments:
String - TODO: add argument description
Seperator - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
EFIAPI
SecNt32PeCoffGetImageInfo (
IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
);
EFI_STATUS
EFIAPI
SecNt32PeCoffLoadImage (
IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
);
EFI_STATUS
EFIAPI
SecNt32PeCoffRelocateImage (
IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
);
EFI_STATUS
EFIAPI
SecNt32PeCoffUnloadimage (
IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,
IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
);
EFI_STATUS
EFIAPI
SecTemporaryRamSupport (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase,
IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase,
IN UINTN CopySize
);
typedef struct {
EFI_PEI_PE_COFF_LOADER_PROTOCOL PeCoff;
VOID *ModHandle;
} EFI_PEI_PE_COFF_LOADER_PROTOCOL_INSTANCE;
extern EFI_UNIX_THUNK_PROTOCOL *gUnix;

76
UnixPkg/Sec/SecMain.inf Normal file
View File

@ -0,0 +1,76 @@
#/** @file
# Entry Point of Unix Emulator
#
# Main executable file of Unix Emulator that loads PEI core after initialization finished.
# Copyright (c) 2008, Intel Corporation
#
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#
#**/
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = SecMain
FILE_GUID = f43be88c-8985-11db-8f78-0040d02b1835
MODULE_TYPE = SEC
VERSION_STRING = 1.0
EDK_RELEASE_VERSION = 0x00020000
EFI_SPECIFICATION_VERSION = 0x00020000
ENTRY_POINT = main
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources.common]
UgaX11.c
UnixThunk.c
FwVol.c
SecMain.c
Stack.S
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
IntelFrameworkPkg/IntelFrameworkPkg.dec
UnixPkg/UnixPkg.dec
[LibraryClasses]
DebugLib
PcdLib
PrintLib
BaseMemoryLib
BaseLib
PeCoffLib
ReportStatusCodeLib
[Guids]
gEfiPeiPeCoffLoaderGuid # ALWAYS_PRODUCED
[Ppis]
gUnixPeiLoadFilePpiGuid # PPI ALWAYS_PRODUCED
gEfiPeiStatusCodePpiGuid # PPI ALWAYS_PRODUCED
gUnixFwhPpiGuid # PPI ALWAYS_PRODUCED
gPeiUnixAutoScanPpiGuid # PPI ALWAYS_PRODUCED
gPeiUnixThunkPpiGuid # PPI ALWAYS_PRODUCED
gEfiTemporaryRamSupportPpiGuid
[Pcd.common]
gEfiUnixPkgTokenSpaceGuid.PcdUnixBootMode
gEfiUnixPkgTokenSpaceGuid.PcdUnixFirmwareVolume
gEfiUnixPkgTokenSpaceGuid.PcdUnixMemorySizeForSecMain
gEfiUnixPkgTokenSpaceGuid.PcdUnixFirmwareFdSize
[BuildOptions.common]
GCC:*_*_IA32_DLINK_FLAGS =

113
UnixPkg/Sec/SecMain.msa Normal file
View File

@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8"?>
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">
<MsaHeader>
<ModuleName>SecMain</ModuleName>
<ModuleType>SEC</ModuleType>
<GuidValue>f43be88c-8985-11db-8f78-0040d02b1835</GuidValue>
<Version>1.0</Version>
<Abstract>Entry Point of Unix Emulator</Abstract>
<Description>Main executable file of Unix Emulator that loads PEI core after initialization finished.</Description>
<Copyright>Copyright (c) 2006, Intel Corporation</Copyright>
<License>All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
</MsaHeader>
<ModuleDefinitions>
<SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
<BinaryModule>false</BinaryModule>
<OutputFileBasename>SecMain</OutputFileBasename>
</ModuleDefinitions>
<LibraryClassDefinitions>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>PeCoffLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>BaseLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>BaseMemoryLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>PrintLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>PcdLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>DebugLib</Keyword>
</LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename ToolCode="DUMMY">SecMain_build.xml</Filename>
<Filename>SecMain.c</Filename>
<Filename>FwVol.c</Filename>
<Filename>UnixThunk.c</Filename>
<Filename>UgaX11.c</Filename>
<Filename>SecMain.h</Filename>
</SourceFiles>
<PackageDependencies>
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
<Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>
</PackageDependencies>
<PPIs>
<Ppi Usage="ALWAYS_PRODUCED">
<PpiCName>gPeiUnixThunkPpiGuid</PpiCName>
</Ppi>
<Ppi Usage="ALWAYS_PRODUCED">
<PpiCName>gPeiUnixAutoScanPpiGuid</PpiCName>
</Ppi>
<Ppi Usage="ALWAYS_PRODUCED">
<PpiCName>gUnixFwhPpiGuid</PpiCName>
</Ppi>
<Ppi Usage="ALWAYS_PRODUCED">
<PpiCName>gEfiPeiStatusCodePpiGuid</PpiCName>
</Ppi>
<Ppi Usage="ALWAYS_PRODUCED">
<PpiCName>gUnixPeiLoadFilePpiGuid</PpiCName>
</Ppi>
</PPIs>
<Guids>
<GuidCNames Usage="ALWAYS_PRODUCED">
<GuidCName>gEfiPeiPeCoffLoaderGuid</GuidCName>
</GuidCNames>
</Guids>
<Externs>
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
</Externs>
<PcdCoded>
<PcdEntry PcdItemType="DYNAMIC">
<C_Name>PcdUnixMemorySizeForSecMain</C_Name>
<TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>
<HelpText>This PCD defines the memory size of simulated machine. Simulator will allocate
the size of PcdUnixMemorySizeForSecMain in host platform.</HelpText>
</PcdEntry>
<PcdEntry PcdItemType="DYNAMIC">
<C_Name>PcdUnixFirmwareVolume</C_Name>
<TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>
<HelpText>This PCD defines the FD file windows path string. Simulator will load the FD file and execute.</HelpText>
</PcdEntry>
<PcdEntry PcdItemType="DYNAMIC">
<C_Name>PcdUnixBootMode</C_Name>
<TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>
<HelpText>This PCD defines the boot mode for simualtor.
The boot mode can be set as following value:
0x0: Boot with full configuration.
0x1: Boot with minimal configuration.
0x2: Boot assume no configuration changes.
0x3: Boot with full configuration plus diagnostics.
0x4: Boot with default settings.
0x5: Boot on S4 resume.
0x6: Boot on S5 resume.
0x10: Boot on S2 resume.
0x11: Boot on S3 resume.
0x12: Boot on flash update.
0x20: Boot in reovery mode.</HelpText>
</PcdEntry>
</PcdCoded>
</ModuleSurfaceArea>

92
UnixPkg/Sec/Stack.S Normal file
View File

@ -0,0 +1,92 @@
#------------------------------------------------------------------------------
#
# Copyright (c) 2008, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# Stack.asm
#
# Abstract:
#
# Switch the stack from temporary memory to permenent memory.
#
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# VOID
# EFIAPI
# SecSwitchStack (
# UINT32 TemporaryMemoryBase,
# UINT32 PermenentMemoryBase
# );
#------------------------------------------------------------------------------
#include <ProcessorBind.h>
.globl ASM_PFX(SecSwitchStack)
ASM_PFX(SecSwitchStack):
#
# 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!
#
movl 20(%esp), %ebx # Save the first parameter
movl 24(%esp), %ecx # Save the second parameter
#
# Save this function's return address into permenent memory at first.
# Then, Fixup the esp point to permenent memory
#
movl %esp, %eax
subl %ebx, %eax
addl %ecx, %eax
movl (%esp), %edx # copy pushed register's value to permenent memory
movl %edx, (%eax)
movl 4(%esp), %edx
movl %edx, 4(%eax)
movl 8(%esp), %edx
movl %edx, 8(%eax)
movl 12(%esp), %edx
movl %edx, 12(%eax)
movl 16(%esp), %edx
movl %edx, 16(%eax)
movl %eax, %esp # From now, esp is pointed to permenent memory
#
# Fixup the ebp point to permenent memory
#
movl %ebp, %eax
subl %ebx, %eax
addl %ecx, %eax
movl %eax, %ebp # From now, ebp is pointed to permenent memory
#
# Fixup callee's ebp point for PeiDispatch
#
movl (%ebp), %eax
subl %ebx, %eax
addl %ecx, %eax
movl %eax, (%ebp) # From now, Temporary's PPI caller's stack is in permenent memory
pop %edx
pop %ecx
pop %ebx
pop %eax
ret

595
UnixPkg/Sec/UgaX11.c Normal file
View File

@ -0,0 +1,595 @@
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/dir.h>
#include <stdio.h>
#include <stdlib.h>
#include "PiPei.h"
#include "Protocol/UnixThunk.h"
#include "Protocol/SimpleTextIn.h"
#include "Protocol/UgaDraw.h"
#include "Protocol/UnixUgaIo.h"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
#include <X11/extensions/XShm.h>
#include <X11/keysym.h>
#include <Guid/PeiPeCoffLoader.h>
#include <Ppi/StatusCode.h>
#include <Library/PeCoffLib.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/PrintLib.h>
#include <Library/PcdLib.h>
#include <Library/DebugLib.h>
extern void msSleep (unsigned long Milliseconds);
/* XQueryPointer */
struct uga_drv_shift_mask
{
unsigned char shift;
unsigned char size;
unsigned char csize;
};
#define NBR_KEYS 32
typedef struct
{
EFI_UNIX_UGA_IO_PROTOCOL UgaIo;
Display *display;
int screen; /* values for window_size in main */
Window win;
GC gc;
Visual *visual;
int depth;
unsigned int width;
unsigned int height;
unsigned int line_bytes;
unsigned int pixel_shift;
unsigned char *image_data;
struct uga_drv_shift_mask r, g, b;
int use_shm;
XShmSegmentInfo xshm_info;
XImage *image;
unsigned int key_rd;
unsigned int key_wr;
unsigned int key_count;
EFI_INPUT_KEY keys[NBR_KEYS];
} UGA_IO_PRIVATE;
static void
HandleEvents(UGA_IO_PRIVATE *drv);
static void
fill_shift_mask (struct uga_drv_shift_mask *sm, unsigned long mask)
{
sm->shift = 0;
sm->size = 0;
while ((mask & 1) == 0)
{
mask >>= 1;
sm->shift++;
}
while (mask & 1)
{
sm->size++;
mask >>= 1;
}
sm->csize = 8 - sm->size;
}
static int
TryCreateShmImage(UGA_IO_PRIVATE *drv)
{
drv->image = XShmCreateImage (drv->display, drv->visual,
drv->depth, ZPixmap, NULL, &drv->xshm_info,
drv->width, drv->height);
if (drv->image == NULL)
return 0;
switch (drv->image->bitmap_unit) {
case 32:
drv->pixel_shift = 2;
break;
case 16:
drv->pixel_shift = 1;
break;
case 8:
drv->pixel_shift = 0;
break;
}
drv->xshm_info.shmid = shmget
(IPC_PRIVATE, drv->image->bytes_per_line * drv->image->height,
IPC_CREAT | 0777);
if (drv->xshm_info.shmid < 0)
{
XDestroyImage(drv->image);
return 0;
}
drv->image_data = shmat (drv->xshm_info.shmid, NULL, 0);
if(!drv->image_data)
{
shmctl (drv->xshm_info.shmid, IPC_RMID, NULL);
XDestroyImage(drv->image);
return 0;
}
/* Can this fail ? */
shmctl (drv->xshm_info.shmid, IPC_RMID, NULL);
drv->xshm_info.shmaddr = (char*)drv->image_data;
drv->image->data = (char*)drv->image_data;
if (!XShmAttach (drv->display, &drv->xshm_info))
{
shmdt (drv->image_data);
XDestroyImage(drv->image);
return 0;
}
return 1;
}
static
EFI_STATUS
UgaClose (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo)
{
UGA_IO_PRIVATE *drv = (UGA_IO_PRIVATE *)UgaIo;
if (drv == NULL)
return EFI_SUCCESS;
if (drv->image != NULL)
{
XDestroyImage(drv->image);
if (drv->use_shm)
shmdt (drv->image_data);
drv->image_data = NULL;
drv->image = NULL;
}
XDestroyWindow(drv->display, drv->win);
XCloseDisplay(drv->display);
free(drv);
return EFI_SUCCESS;
}
static
EFI_STATUS
UgaSize(EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, UINT32 Width, UINT32 Height)
{
UGA_IO_PRIVATE *drv = (UGA_IO_PRIVATE *)UgaIo;
XSizeHints size_hints;
/* Destroy current buffer if created. */
if (drv->image != NULL)
{
XDestroyImage(drv->image);
if (drv->use_shm)
shmdt (drv->image_data);
drv->image_data = NULL;
drv->image = NULL;
}
drv->width = Width;
drv->height = Height;
XResizeWindow (drv->display, drv->win, Width, Height);
/* Allocate image. */
if (XShmQueryExtension(drv->display) && TryCreateShmImage(drv))
{
drv->use_shm = 1;
}
else
{
drv->use_shm = 0;
if (drv->depth > 16)
drv->pixel_shift = 2;
else if (drv->depth > 8)
drv->pixel_shift = 1;
else
drv->pixel_shift = 0;
drv->image_data = malloc((drv->width * drv->height) << drv->pixel_shift);
drv->image = XCreateImage (drv->display, drv->visual, drv->depth,
ZPixmap, 0, (char *)drv->image_data,
drv->width, drv->height,
8 << drv->pixel_shift, 0);
}
drv->line_bytes = drv->image->bytes_per_line;
fill_shift_mask (&drv->r, drv->image->red_mask);
fill_shift_mask (&drv->g, drv->image->green_mask);
fill_shift_mask (&drv->b, drv->image->blue_mask);
/* Set WM hints. */
size_hints.flags = PSize | PMinSize | PMaxSize;
size_hints.min_width = size_hints.max_width = size_hints.base_width = Width;
size_hints.min_height = size_hints.max_height = size_hints.base_height = Height;
XSetWMNormalHints (drv->display, drv->win, &size_hints);
XMapWindow (drv->display, drv->win);
HandleEvents(drv);
return EFI_SUCCESS;
}
static void
handleKeyEvent(UGA_IO_PRIVATE *drv, XEvent *ev)
{
KeySym keysym;
char str[4];
EFI_INPUT_KEY Key;
int res;
if (drv->key_count == NBR_KEYS)
return;
res = XLookupString(&ev->xkey, str, sizeof(str), &keysym, NULL);
Key.ScanCode = 0;
Key.UnicodeChar = 0;
switch (keysym) {
case XK_Home: Key.ScanCode = SCAN_HOME; break;
case XK_End: Key.ScanCode = SCAN_END; break;
case XK_Left: Key.ScanCode = SCAN_LEFT; break;
case XK_Right: Key.ScanCode = SCAN_RIGHT; break;
case XK_Up: Key.ScanCode = SCAN_UP; break;
case XK_Down: Key.ScanCode = SCAN_DOWN; break;
case XK_Delete: Key.ScanCode = SCAN_DELETE; break;
case XK_Insert: Key.ScanCode = SCAN_INSERT; break;
case XK_Page_Up: Key.ScanCode = SCAN_PAGE_UP; break;
case XK_Page_Down: Key.ScanCode = SCAN_PAGE_DOWN; break;
case XK_Escape: Key.ScanCode = SCAN_ESC; break;
case XK_F1: Key.ScanCode = SCAN_F1; break;
case XK_F2: Key.ScanCode = SCAN_F2; break;
case XK_F3: Key.ScanCode = SCAN_F3; break;
case XK_F4: Key.ScanCode = SCAN_F4; break;
case XK_F5: Key.ScanCode = SCAN_F5; break;
case XK_F6: Key.ScanCode = SCAN_F6; break;
case XK_F7: Key.ScanCode = SCAN_F7; break;
case XK_F8: Key.ScanCode = SCAN_F8; break;
case XK_F9: Key.ScanCode = SCAN_F9; break;
default:
if (res == 1) {
Key.UnicodeChar = str[0];
} else {
return;
}
}
drv->keys[drv->key_wr] = Key;
drv->key_wr = (drv->key_wr + 1) % NBR_KEYS;
drv->key_count++;
}
static void
Redraw(UGA_IO_PRIVATE *drv, UINTN X, UINTN Y, UINTN Width, UINTN Height)
{
if (drv->use_shm)
XShmPutImage (drv->display, drv->win, drv->gc, drv->image,
X, Y, X, Y, Width, Height, False);
else
XPutImage (drv->display, drv->win, drv->gc, drv->image,
X, Y, X, Y, Width, Height);
}
static void
HandleEvent(UGA_IO_PRIVATE *drv, XEvent *ev)
{
switch (ev->type)
{
case Expose:
Redraw(drv, ev->xexpose.x, ev->xexpose.y,
ev->xexpose.width, ev->xexpose.height);
break;
case GraphicsExpose:
Redraw(drv, ev->xgraphicsexpose.x, ev->xgraphicsexpose.y,
ev->xgraphicsexpose.width, ev->xgraphicsexpose.height);
break;
case KeyPress:
handleKeyEvent(drv, ev);
break;
case MappingNotify:
XRefreshKeyboardMapping(&ev->xmapping);
break;
#if 0
case DestroyNotify:
XCloseDisplay (drv->display);
exit (1);
break;
#endif
case NoExpose:
default:
break;
}
}
static void
HandleEvents(UGA_IO_PRIVATE *drv)
{
while (XPending(drv->display) != 0)
{
XEvent ev;
XNextEvent (drv->display, &ev);
HandleEvent(drv, &ev);
}
}
static
unsigned long
UgaPixelToColor (UGA_IO_PRIVATE *drv, EFI_UGA_PIXEL pixel)
{
return ((pixel.Red >> drv->r.csize) << drv->r.shift)
| ((pixel.Green >> drv->g.csize) << drv->g.shift)
| ((pixel.Blue >> drv->b.csize) << drv->b.shift);
}
static
EFI_UGA_PIXEL
UgaColorToPixel (UGA_IO_PRIVATE *drv, unsigned long val)
{
EFI_UGA_PIXEL res;
memset (&res, 0, sizeof (EFI_UGA_PIXEL));
/* FIXME: should round instead of truncate. */
res.Red = (val >> drv->r.shift) << drv->r.csize;
res.Green = (val >> drv->g.shift) << drv->g.csize;
res.Blue = (val >> drv->b.shift) << drv->b.csize;
return res;
}
static
EFI_STATUS
UgaCheckKey(EFI_UNIX_UGA_IO_PROTOCOL *UgaIo)
{
UGA_IO_PRIVATE *drv = (UGA_IO_PRIVATE *)UgaIo;
HandleEvents(drv);
if (drv->key_count != 0)
return EFI_SUCCESS;
else {
/* EFI is certainly polling. Be CPU-friendly. */
msSleep (20);
return EFI_NOT_READY;
}
}
static
EFI_STATUS
UgaGetKey(EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, EFI_INPUT_KEY *key)
{
UGA_IO_PRIVATE *drv = (UGA_IO_PRIVATE *)UgaIo;
EFI_STATUS status;
status = UgaCheckKey(UgaIo);
if (status != EFI_SUCCESS)
return status;
*key = drv->keys[drv->key_rd];
drv->key_rd = (drv->key_rd + 1) % NBR_KEYS;
drv->key_count--;
return EFI_SUCCESS;
}
EFI_STATUS
UgaBlt(EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,
IN EFI_UGA_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
)
{
UGA_IO_PRIVATE *Private = (UGA_IO_PRIVATE *)UgaIo;
UINTN DstY;
UINTN SrcY;
UINTN DstX;
UINTN SrcX;
UINTN Index;
EFI_UGA_PIXEL *Blt;
UINT8 *Dst;
UINT8 *Src;
UINTN Nbr;
unsigned long Color;
//
// Check bounds
//
if (BltOperation == EfiUgaVideoToBltBuffer
|| BltOperation == EfiUgaVideoToVideo) {
//
// Source is Video.
//
if (SourceY + Height > Private->height) {
return EFI_INVALID_PARAMETER;
}
if (SourceX + Width > Private->width) {
return EFI_INVALID_PARAMETER;
}
}
if (BltOperation == EfiUgaBltBufferToVideo
|| BltOperation == EfiUgaVideoToVideo
|| BltOperation == EfiUgaVideoFill) {
//
// Destination is Video
//
if (DestinationY + Height > Private->height) {
return EFI_INVALID_PARAMETER;
}
if (DestinationX + Width > Private->width) {
return EFI_INVALID_PARAMETER;
}
}
switch (BltOperation) {
case EfiUgaVideoToBltBuffer:
Blt = BltBuffer;
Delta -= Width * sizeof (EFI_UGA_PIXEL);
for (SrcY = SourceY; SrcY < (Height + SourceY); SrcY++) {
for (SrcX = SourceX; SrcX < (Width + SourceX); SrcX++) {
*Blt++ = UgaColorToPixel(Private,
XGetPixel(Private->image, SrcX, SrcY));
}
Blt = (EFI_UGA_PIXEL *) ((UINT8 *) Blt + Delta);
}
break;
case EfiUgaBltBufferToVideo:
Blt = BltBuffer;
Delta -= Width * sizeof (EFI_UGA_PIXEL);
for (DstY = DestinationY; DstY < (Height + DestinationY); DstY++) {
for (DstX = DestinationX; DstX < (Width + DestinationX); DstX++) {
XPutPixel(Private->image, DstX, DstY, UgaPixelToColor(Private, *Blt));
Blt++;
}
Blt = (EFI_UGA_PIXEL *) ((UINT8 *) Blt + Delta);
}
break;
case EfiUgaVideoToVideo:
Dst = Private->image_data + (DestinationX << Private->pixel_shift)
+ DestinationY * Private->line_bytes;
Src = Private->image_data + (SourceX << Private->pixel_shift)
+ SourceY * Private->line_bytes;
Nbr = Width << Private->pixel_shift;
if (DestinationY < SourceY) {
for (Index = 0; Index < Height; Index++) {
memcpy (Dst, Src, Nbr);
Dst += Private->line_bytes;
Src += Private->line_bytes;
}
}
else {
Dst += (Height - 1) * Private->line_bytes;
Src += (Height - 1) * Private->line_bytes;
for (Index = 0; Index < Height; Index++) {
//
// Source and Destination Y may be equal, therefore Dst and Src may
// overlap.
//
memmove (Dst, Src, Nbr);
Dst -= Private->line_bytes;
Src -= Private->line_bytes;
}
}
break;
case EfiUgaVideoFill:
Color = UgaPixelToColor(Private, *BltBuffer);
for (DstY = DestinationY; DstY < (Height + DestinationY); DstY++) {
for (DstX = DestinationX; DstX < (Width + DestinationX); DstX++) {
XPutPixel(Private->image, DstX, DstY, Color);
}
}
break;
default:
return EFI_INVALID_PARAMETER;
}
//
// Refresh screen.
//
switch (BltOperation) {
case EfiUgaVideoToVideo:
XCopyArea(Private->display, Private->win, Private->win, Private->gc,
SourceX, SourceY, Width, Height, DestinationX, DestinationY);
while (1) {
XEvent ev;
XNextEvent (Private->display, &ev);
HandleEvent(Private, &ev);
if (ev.type == NoExpose || ev.type == GraphicsExpose)
break;
}
break;
case EfiUgaVideoFill:
Color = UgaPixelToColor(Private, *BltBuffer);
XSetForeground(Private->display, Private->gc, Color);
XFillRectangle(Private->display, Private->win, Private->gc,
DestinationX, DestinationY, Width, Height);
break;
case EfiUgaBltBufferToVideo:
Redraw(Private, DestinationX, DestinationY, Width, Height);
break;
default:
break;
}
return EFI_SUCCESS;
}
EFI_STATUS
UgaCreate (EFI_UNIX_UGA_IO_PROTOCOL **Uga, CONST CHAR16 *Title)
{
UGA_IO_PRIVATE *drv;
unsigned int border_width = 0;
char *display_name = NULL;
int title_len;
drv = (UGA_IO_PRIVATE *)
calloc (1, sizeof (UGA_IO_PRIVATE));
if (drv == NULL)
return EFI_OUT_OF_RESOURCES;
drv->UgaIo.UgaClose = UgaClose;
drv->UgaIo.UgaSize = UgaSize;
drv->UgaIo.UgaCheckKey = UgaCheckKey;
drv->UgaIo.UgaGetKey = UgaGetKey;
drv->UgaIo.UgaBlt = UgaBlt;
drv->key_count = 0;
drv->key_rd = 0;
drv->key_wr = 0;
drv->display = XOpenDisplay (display_name);
if (drv->display == NULL)
{
fprintf (stderr, "uga: cannot connect to X server %s\n",
XDisplayName (display_name));
free (drv);
return EFI_DEVICE_ERROR;
}
drv->screen = DefaultScreen (drv->display);
drv->visual = DefaultVisual (drv->display, drv->screen);
drv->win = XCreateSimpleWindow
(drv->display, RootWindow (drv->display, drv->screen),
0, 0, 4, 4, border_width,
BlackPixel (drv->display, drv->screen),
WhitePixel (drv->display, drv->screen));
drv->depth = DefaultDepth (drv->display, drv->screen);
/* Compute title len and convert to Ascii. */
for (title_len = 0; Title[title_len] != 0; title_len++)
;
{
char title[title_len + 1];
int i;
for (i = 0; i < title_len; i++)
title[i] = Title[i];
title[i] = 0;
XStoreName (drv->display, drv->win, title);
}
XSelectInput (drv->display, drv->win,
ExposureMask | KeyPressMask);
drv->gc = DefaultGC (drv->display, drv->screen);
*Uga = (EFI_UNIX_UGA_IO_PROTOCOL *)drv;
return EFI_SUCCESS;
}

197
UnixPkg/Sec/UnixThunk.c Normal file
View File

@ -0,0 +1,197 @@
/*++
Copyright (c) 2004 - 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
UnixThunk.c
Abstract:
Since the SEC is the only program in our emulation we
must use a Tiano mechanism to export APIs to other modules.
This is the role of the EFI_UNIX_THUNK_PROTOCOL.
The mUnixThunkTable exists so that a change to EFI_UNIX_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 crash.
gUnix is a a public exported global that contains the initialized
data.
--*/
#include "SecMain.h"
#include "Library/UnixLib.h"
static int settimer_initialized;
static struct timeval settimer_timeval;
static void (*settimer_callback)(UINT64 delta);
static void
settimer_handler (int sig)
{
struct timeval timeval;
UINT64 delta;
gettimeofday (&timeval, NULL);
delta = ((UINT64)timeval.tv_sec * 1000) + (timeval.tv_usec / 1000)
- ((UINT64)settimer_timeval.tv_sec * 1000)
- (settimer_timeval.tv_usec / 1000);
settimer_timeval = timeval;
if (settimer_callback)
(*settimer_callback)(delta);
}
static
VOID
SetTimer (UINT64 PeriodMs, VOID (*CallBack)(UINT64 DeltaMs))
{
struct itimerval timerval;
if (!settimer_initialized) {
struct sigaction act;
settimer_initialized = 1;
act.sa_handler = settimer_handler;
act.sa_flags = 0;
sigemptyset (&act.sa_mask);
if (sigaction (SIGALRM, &act, NULL) != 0) {
printf ("SetTimer: sigaction error %s\n", strerror (errno));
}
if (gettimeofday (&settimer_timeval, NULL) != 0) {
printf ("SetTimer: gettimeofday error %s\n", strerror (errno));
}
}
timerval.it_value.tv_sec = PeriodMs / 1000;
timerval.it_value.tv_usec = (PeriodMs % 1000) * 1000;
timerval.it_value.tv_sec = PeriodMs / 1000;
timerval.it_interval = timerval.it_value;
if (setitimer (ITIMER_REAL, &timerval, NULL) != 0) {
printf ("SetTimer: setitimer error %s\n", strerror (errno));
}
settimer_callback = CallBack;
}
void
msSleep (unsigned long Milliseconds)
{
struct timespec ts;
ts.tv_sec = Milliseconds / 1000;
ts.tv_nsec = (Milliseconds % 1000) * 1000000;
while (nanosleep (&ts, &ts) != 0 && errno == EINTR)
;
}
void
GetLocalTime (EFI_TIME *Time)
{
struct tm *tm;
time_t t;
t = time (NULL);
tm = localtime (&t);
Time->Year = 1900 + tm->tm_year;
Time->Month = tm->tm_mon;
Time->Day = tm->tm_mday;
Time->Hour = tm->tm_hour;
Time->Minute = tm->tm_min;
Time->Second = tm->tm_sec;
Time->Nanosecond = 0;
Time->TimeZone = timezone;
Time->Daylight = (daylight ? EFI_TIME_ADJUST_DAYLIGHT : 0)
| (tm->tm_isdst > 0 ? EFI_TIME_IN_DAYLIGHT : 0);
}
static void
TzSet (void)
{
static int done = 0;
if (!done) {
tzset ();
done = 1;
}
}
long
GetTimeZone(void)
{
TzSet ();
return timezone;
}
int
GetDayLight(void)
{
TzSet ();
return daylight;
}
int
GetErrno(void)
{
return errno;
}
extern EFI_STATUS
UgaCreate(struct _EFI_UNIX_UGA_IO_PROTOCOL **UgaIo, CONST CHAR16 *Title);
EFI_UNIX_THUNK_PROTOCOL mUnixThunkTable = {
EFI_UNIX_THUNK_PROTOCOL_SIGNATURE,
msSleep, /* Sleep */
exit, /* Exit */
SetTimer,
GetLocalTime,
gmtime,
GetTimeZone,
GetDayLight,
(UnixPoll)poll,
(UnixRead)read,
(UnixWrite)write,
getenv,
(UnixOpen)open,
lseek,
ftruncate,
close,
mkdir,
rmdir,
unlink,
GetErrno,
opendir,
rewinddir,
readdir,
closedir,
stat,
statfs,
rename,
mktime,
fsync,
chmod,
utime,
tcflush,
UgaCreate,
perror,
ioctl,
fcntl,
cfsetispeed,
cfsetospeed,
tcgetattr,
tcsetattr
};
EFI_UNIX_THUNK_PROTOCOL *gUnix = &mUnixThunkTable;

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