Unix version of EFI emulator

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2182 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
tgingold
2007-01-06 14:59:06 +00:00
parent 8ba7afaf2e
commit c9093a06e7
187 changed files with 54299 additions and 0 deletions

View File

@@ -0,0 +1,129 @@
/*++
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.c
Abstract:
NT Emulation Metronome Architectural Protocol Driver as defined in DXE CIS
--*/
#include "Metronome.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;
Status = gBS->InstallProtocolInterface (
&Handle,
&gEfiMetronomeArchProtocolGuid,
EFI_NATIVE_INTERFACE,
&mMetronome
);
return Status;
}

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:
Metronome.dxs
Abstract:
Dependency expression source file.
--*/
#include <AutoGen.h>
#include <DxeDepex.h>
DEPENDENCY_START
TRUE
DEPENDENCY_END

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:
NT 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,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>