Add InOsEmuPkg. Like UnixPkg and Nt32Pkg, but EFI code can be common and does not require including system include files. Currently only Unix 64-bit is supported and it has only been tested on Mac OS X. Not all features are ported over, but GOP, via X11, and access to local file systems are supported and you can boot to the shell.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11641 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
andrewfish
2011-05-11 18:31:20 +00:00
parent da92f27632
commit 949f388f5f
142 changed files with 23677 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
/** @file
Setup Variable data structure for Emu platform.
Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>
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.
**/
#ifndef __EMU_SYSTEM_CONFIG_H__
#define __EMU_SYSTEM_CONFIG_H__
#define EFI_EMU_SYSTEM_CONFIG_GUID \
{ 0x9C4FB516, 0x3A1E, 0xD847, { 0xA1, 0xA1, 0x70, 0x58, 0xB6, 0x98, 0x67, 0x32 } }
#pragma pack(1)
typedef struct {
//
// Console output mode
//
UINT32 ConOutColumn;
UINT32 ConOutRow;
} EMU_SYSTEM_CONFIGURATION;
#pragma pack()
extern EFI_GUID gEmuSystemConfigGuid;
#endif

View File

@@ -0,0 +1,22 @@
/*++ @file
Copyright (c) 2011, Apple Inc. All rights reserved.<BR>
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.
**/
#ifndef __EMU_THUNK_LIB_H__
#define __EMU_THUNK_LIB_H__
#include <Protocol/EmuThunk.h>
extern EMU_THUNK_PROTOCOL *gEmuThunk;
#endif

View File

@@ -0,0 +1,43 @@
/*++ @file
Copyright (c) 2011, Apple Inc. 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.
**/
#include <Protocol/SimpleTextInEx.h>
/**
KeyMapMake gets called on key presses.
@param KeyData Key that was pressed.
@retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
**/
EFI_STATUS
EFIAPI
KeyMapMake (
IN EFI_KEY_DATA *KeyData
);
/**
KeyMapBreak gets called on key releases.
@param KeyData Key that was pressed.
@retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
**/
EFI_STATUS
EFIAPI
KeyMapBreak (
IN EFI_KEY_DATA *KeyData
);

View File

@@ -0,0 +1,33 @@
/** @file
All 3rd parties to register the PPIs passed into PEI Core
Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
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.
**/
#include <PiPei.h>
EFI_PEI_PPI_DESCRIPTOR *
GetThunkPpiList (
VOID
);
EFI_STATUS
EFIAPI
AddThunkPpi (
IN UINTN Flags,
IN EFI_GUID *Guid,
IN VOID *Ppi
);

View File

@@ -0,0 +1,35 @@
/** @file
Emulator Thunk to abstract OS services from pure EFI code
Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
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.
**/
#include <Uefi.h>
#include <Protocol/EmuIoThunk.h>
EFI_STATUS
EFIAPI
AddThunkProtocol (
IN EMU_IO_THUNK_PROTOCOL *ThunkIo,
IN CHAR16 *ConfigString,
IN BOOLEAN EmuBusDriver
);
EFI_STATUS
EFIAPI
GetNextThunkProtocol (
IN BOOLEAN EmuBusDriver,
OUT EMU_IO_THUNK_PROTOCOL **Instance
);

View File

@@ -0,0 +1,27 @@
/** @file
Emulator Thunk to abstract OS services from pure EFI code
Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
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.
**/
#ifndef __EMU_PEI_SERVICE_TABLE_UPDATE_PPI_H__
#define __EMU_PEI_SERVICE_TABLE_UPDATE_PPI_H__
#define _EMU_PEI_SERVICE_TABLE_UPDATE_PPI_GUID \
{ 0xFA93020C, 0x6CDF, 0x1946, { 0x86, 0x35, 0x72, 0xCB, 0x51, 0x9E, 0xCF, 0xFD } }
extern EFI_GUID gEmuPeiServicesTableUpdatePpiGuid;
#endif

View File

@@ -0,0 +1,128 @@
/** @file
Emulator Thunk to abstract OS services from pure EFI code
Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
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.
**/
#ifndef __EMU_THUNK_PPI_H__
#define __EMU_THUNK_PPI_H__
#define EMU_THUNK_PPI_GUID \
{ 0xB958B78C, 0x1D3E, 0xEE40, { 0x8B, 0xF4, 0xF0, 0x63, 0x2D, 0x06, 0x39, 0x16 } }
/*++
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.
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
EFI_STATUS
(EFIAPI *EMU_PEI_AUTOSCAN) (
IN UINTN Index,
OUT EFI_PHYSICAL_ADDRESS *MemoryBase,
OUT UINT64 *MemorySize
);
/*++
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
FixUp - Difference between actual FD address and build address
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
EFI_STATUS
(EFIAPI *EMU_PEI_FD_INFORMATION) (
IN UINTN Index,
IN OUT EFI_PHYSICAL_ADDRESS *FdBase,
IN OUT UINT64 *FdSize,
IN OUT EFI_PHYSICAL_ADDRESS *FixUp
);
/*++
Routine Description:
Export of EMU_THUNK_PROTOCOL from the SEC.
Returns:
EFI_SUCCESS - Data returned
**/
typedef
VOID *
(EFIAPI *EMU_PEI_THUNK_INTERFACE) (
VOID
);
/*++
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
EFI_STATUS
(EFIAPI *EMU_PEI_LOAD_FILE) (
VOID *Pe32Data,
EFI_PHYSICAL_ADDRESS *ImageAddress,
UINT64 *ImageSize,
EFI_PHYSICAL_ADDRESS *EntryPoint
);
typedef struct {
EMU_PEI_AUTOSCAN MemoryAutoScan;
EMU_PEI_FD_INFORMATION FirmwareDevices;
EMU_PEI_THUNK_INTERFACE Thunk;
EMU_PEI_LOAD_FILE LoadFile;
} EMU_THUNK_PPI;
extern EFI_GUID gEmuThunkPpiGuid;
#endif

View File

@@ -0,0 +1,140 @@
/** @file
SimpleFileSystem protocol as defined in the UEFI 2.0 specification.
The SimpleFileSystem protocol is the programmatic access to the FAT (12,16,32)
file system specified in UEFI 2.0. It can also be used to abstract a file
system other than FAT.
UEFI 2.0 can boot from any valid EFI image contained in a SimpleFileSystem.
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
Portions copyright (c) 2011, Apple Inc. All rights reserved.
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that 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.
**/
#ifndef _EMU_UGA_IO_H_
#define _EMU_UGA_IO_H_
#include <Protocol/SimplePointer.h>
#include <Protocol/SimpleTextIn.h>
#include <Protocol/SimpleTextInEx.h>
#include <Protocol/UgaDraw.h>
#define EMU_GRAPHICS_WINDOW_PROTOCOL_GUID \
{ 0x30FD316A, 0x6728, 0x2E41, { 0xA6, 0x90, 0x0D, 0x13, 0x33, 0xD8, 0xCA, 0xC1 } }
typedef struct _EMU_GRAPHICS_WINDOW_PROTOCOL EMU_GRAPHICS_WINDOW_PROTOCOL;
typedef
EFI_STATUS
(EFIAPI *EMU_GRAPHICS_WINDOWS_CLOSE)(
EMU_GRAPHICS_WINDOW_PROTOCOL *Uga
);
typedef
EFI_STATUS
(EFIAPI *EMU_GRAPHICS_WINDOWS_SIZE)(
EMU_GRAPHICS_WINDOW_PROTOCOL *Uga,
UINT32 Width,
UINT32 Height
);
typedef
EFI_STATUS
(EFIAPI *EMU_GRAPHICS_WINDOWS_CHECK_KEY)(
EMU_GRAPHICS_WINDOW_PROTOCOL *Uga
);
typedef
EFI_STATUS
(EFIAPI *EMU_GRAPHICS_WINDOWS_GET_KEY)(
EMU_GRAPHICS_WINDOW_PROTOCOL *Uga,
EFI_KEY_DATA *key
);
typedef
EFI_STATUS
(EFIAPI *EMU_GRAPHICS_WINDOWS_KEY_SET_STATE) (
IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows,
IN EFI_KEY_TOGGLE_STATE *KeyToggleState
);
typedef
VOID
(EFIAPI *EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK) (
IN VOID *Context,
IN EFI_KEY_DATA *KeyData
);
typedef
EFI_STATUS
(EFIAPI *EMU_GRAPHICS_WINDOWS_REGISTER_KEY_NOTIFY) (
IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows,
IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK CallBack,
IN VOID *Context
);
typedef struct {
UINTN SourceX;
UINTN SourceY;
UINTN DestinationX;
UINTN DestinationY;
UINTN Width;
UINTN Height;
UINTN Delta;
} EMU_GRAPHICS_WINDOWS__BLT_ARGS;
typedef
EFI_STATUS
(EFIAPI *EMU_GRAPHICS_WINDOWS_BLT)(
IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows,
IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,
IN EFI_UGA_BLT_OPERATION BltOperation,
IN EMU_GRAPHICS_WINDOWS__BLT_ARGS *Args
);
typedef
BOOLEAN
(EFIAPI *EMU_GRAPHICS_WINDOWS_IS_KEY_PRESSED) (
IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows,
IN EFI_KEY_DATA *KeyData
);
typedef
EFI_STATUS
(EFIAPI *EMU_GRAPHICS_WINDOWS_CHECK_POINTER)(
EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows
);
typedef
EFI_STATUS
(EFIAPI *EMU_GRAPHICS_WINDOWS_GET_POINTER_STATE)(
EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows,
EFI_SIMPLE_POINTER_STATE *state
);
struct _EMU_GRAPHICS_WINDOW_PROTOCOL {
EMU_GRAPHICS_WINDOWS_SIZE Size;
EMU_GRAPHICS_WINDOWS_CHECK_KEY CheckKey;
EMU_GRAPHICS_WINDOWS_KEY_SET_STATE KeySetState;
EMU_GRAPHICS_WINDOWS_GET_KEY GetKey;
EMU_GRAPHICS_WINDOWS_REGISTER_KEY_NOTIFY RegisterKeyNotify;
EMU_GRAPHICS_WINDOWS_BLT Blt;
EMU_GRAPHICS_WINDOWS_IS_KEY_PRESSED IsKeyPressed;
EMU_GRAPHICS_WINDOWS_CHECK_POINTER CheckPointer;
EMU_GRAPHICS_WINDOWS_GET_POINTER_STATE GetPointerState;
};
extern EFI_GUID gEmuGraphicsWindowProtocolGuid;
#endif

View File

@@ -0,0 +1,134 @@
/*++ @file
Copyright (c) 2006, Tristan Gingold. All rights reserved.<BR>
Portitions copyright (c) 2010 - 2011, Apple Inc. 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.
**/
#ifndef _EMU_UGA_IO_H_
#define _EMU_UGA_IO_H_
#include <Protocol/SimplePointer.h>
#include <Protocol/SimpleTextIn.h>
#include <Protocol/SimpleTextInEx.h>
#include <Protocol/UgaDraw.h>
#define EMU_GRAPHICS_WINDOW_PROTOCOL_GUID \
{ 0x30FD316A, 0x6728, 0x2E41, { 0xA6, 0x90, 0x0D, 0x13, 0x33, 0xD8, 0xCA, 0xC1 } }
typedef struct _EMU_GRAPHICS_WINDOW_PROTOCOL EMU_GRAPHICS_WINDOW_PROTOCOL;
typedef
EFI_STATUS
(EFIAPI *EMU_GRAPHICS_WINDOWS_CLOSE)(
EMU_GRAPHICS_WINDOW_PROTOCOL *Uga
);
typedef
EFI_STATUS
(EFIAPI *EMU_GRAPHICS_WINDOWS_SIZE)(
EMU_GRAPHICS_WINDOW_PROTOCOL *Uga,
UINT32 Width,
UINT32 Height
);
typedef
EFI_STATUS
(EFIAPI *EMU_GRAPHICS_WINDOWS_CHECK_KEY)(
EMU_GRAPHICS_WINDOW_PROTOCOL *Uga
);
typedef
EFI_STATUS
(EFIAPI *EMU_GRAPHICS_WINDOWS_GET_KEY)(
EMU_GRAPHICS_WINDOW_PROTOCOL *Uga,
EFI_KEY_DATA *key
);
typedef
EFI_STATUS
(EFIAPI *EMU_GRAPHICS_WINDOWS_KEY_SET_STATE) (
IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows,
IN EFI_KEY_TOGGLE_STATE *KeyToggleState
);
typedef
VOID
(EFIAPI *EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK) (
IN VOID *Context,
IN EFI_KEY_DATA *KeyData
);
typedef
EFI_STATUS
(EFIAPI *EMU_GRAPHICS_WINDOWS_REGISTER_KEY_NOTIFY) (
IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows,
IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK MakeCallBack,
IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK BreakCallBack,
IN VOID *Context
);
typedef struct {
UINTN SourceX;
UINTN SourceY;
UINTN DestinationX;
UINTN DestinationY;
UINTN Width;
UINTN Height;
UINTN Delta;
} EMU_GRAPHICS_WINDOWS__BLT_ARGS;
typedef
EFI_STATUS
(EFIAPI *EMU_GRAPHICS_WINDOWS_BLT)(
IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows,
IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,
IN EFI_UGA_BLT_OPERATION BltOperation,
IN EMU_GRAPHICS_WINDOWS__BLT_ARGS *Args
);
typedef
BOOLEAN
(EFIAPI *EMU_GRAPHICS_WINDOWS_IS_KEY_PRESSED) (
IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows,
IN EFI_KEY_DATA *KeyData
);
typedef
EFI_STATUS
(EFIAPI *EMU_GRAPHICS_WINDOWS_CHECK_POINTER)(
EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows
);
typedef
EFI_STATUS
(EFIAPI *EMU_GRAPHICS_WINDOWS_GET_POINTER_STATE)(
EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows,
EFI_SIMPLE_POINTER_STATE *state
);
struct _EMU_GRAPHICS_WINDOW_PROTOCOL {
EMU_GRAPHICS_WINDOWS_SIZE Size;
EMU_GRAPHICS_WINDOWS_CHECK_KEY CheckKey;
EMU_GRAPHICS_WINDOWS_KEY_SET_STATE KeySetState;
EMU_GRAPHICS_WINDOWS_GET_KEY GetKey;
EMU_GRAPHICS_WINDOWS_REGISTER_KEY_NOTIFY RegisterKeyNotify;
EMU_GRAPHICS_WINDOWS_BLT Blt;
EMU_GRAPHICS_WINDOWS_IS_KEY_PRESSED IsKeyPressed;
EMU_GRAPHICS_WINDOWS_CHECK_POINTER CheckPointer;
EMU_GRAPHICS_WINDOWS_GET_POINTER_STATE GetPointerState;
};
extern EFI_GUID gEmuGraphicsWindowProtocolGuid;
#endif

View File

@@ -0,0 +1,51 @@
/** @file
Emulator Thunk to abstract OS services from pure EFI code
Copyright (c) 2010 - 2011, Apple Inc. All rights reserved.<BR>
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.
**/
#ifndef __EMU_IO_THUNK__
#define __EMU_IO_THUNK__
#define EMU_IO_THUNK_PROTOCO_GUID \
{ 0x453368F6, 0x7C85, 0x434A, { 0xA9, 0x8A, 0x72, 0xD1, 0xB7, 0xFF, 0xA9, 0x26 } }
typedef struct _EMU_IO_THUNK_PROTOCOL EMU_IO_THUNK_PROTOCOL;
typedef
EFI_STATUS
(EFIAPI *EMU_IO_THUNK_PROTOCOL_CLOSE_OPEN) (
IN EMU_IO_THUNK_PROTOCOL *This
);
typedef
EFI_STATUS
(EFIAPI *EMU_IO_THUNK_PROTOCOL_CLOSE_CLOSE) (
IN EMU_IO_THUNK_PROTOCOL *This
);
struct _EMU_IO_THUNK_PROTOCOL {
EFI_GUID *Protocol;
VOID *Interface; /// Only be valid after Open() is called
CHAR16 *ConfigString;
UINT16 Instance;
EMU_IO_THUNK_PROTOCOL_CLOSE_OPEN Open;
EMU_IO_THUNK_PROTOCOL_CLOSE_CLOSE Close;
VOID *Private; /// Used by implementation
};
extern EFI_GUID gEmuIoThunkProtocolGuid;
#endif

View File

@@ -0,0 +1,105 @@
/** @file
Emulator Thunk to abstract OS services from pure EFI code
Copyright (c) 2010 - 2011, Apple Inc. All rights reserved.<BR>
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.
**/
#ifndef __EMU_PTHREAD_THUNK__
#define __EMU_PTHREAD_THUNK__
#define EMU_PTHREAD_THUNK_PROTOCO_GUID \
{ 0x3B1E4B7C, 0x09D8, 0x944F, { 0xA4, 0x08, 0x13, 0x09, 0xEB, 0x8B, 0x44, 0x27 } }
typedef struct _EMU_PTREAD_THUNK_PROTOCOL EMU_PTREAD_THUNK_PROTOCOL;
typedef
UINTN
(EFIAPI *PTREAD_THUNK_MUTEXT_LOCK) (
IN VOID *Mutex
);
typedef
UINTN
(EFIAPI *PTREAD_THUNK_MUTEXT_UNLOCK) (
IN VOID *Mutex
);
typedef
UINTN
(EFIAPI *PTREAD_THUNK_MUTEX_TRY_LOCK) (
IN VOID *Mutex
);
typedef
VOID *
(EFIAPI *PTREAD_THUNK_MUTEX_INIT) (
IN VOID
);
typedef
UINTN
(EFIAPI *PTREAD_THUNK_MUTEX_DISTROY) (
IN VOID *Mutex
);
typedef
VOID *
(*PTREAD_THUNK_THEAD_ENTRY) (
IN VOID *Context
);
typedef
UINTN
(EFIAPI *PTREAD_THUNK_CREATE_THREAD) (
IN VOID *Thread,
IN VOID *Attribute,
IN PTREAD_THUNK_THEAD_ENTRY Start,
IN VOID *Context
);
typedef
VOID
(EFIAPI *PTREAD_THUNK_EXIT_THREAD) (
IN VOID *ValuePtr
);
typedef
UINTN
(EFIAPI *PTREAD_THUNK_SELF) (
VOID
);
struct _EMU_PTREAD_THUNK_PROTOCOL {
PTREAD_THUNK_MUTEXT_LOCK MutextLock;
PTREAD_THUNK_MUTEXT_UNLOCK MutexUnlock;
PTREAD_THUNK_MUTEX_TRY_LOCK MutexTryLock;
PTREAD_THUNK_MUTEX_INIT MutexInit;
PTREAD_THUNK_MUTEX_DISTROY MutexDistroy;
PTREAD_THUNK_CREATE_THREAD CreateThread;
PTREAD_THUNK_EXIT_THREAD ExitThread;
PTREAD_THUNK_SELF Self;
};
extern EFI_GUID gEmuPthreadThunkProtocolGuid;
#endif

View File

@@ -0,0 +1,199 @@
/** @file
Emulator Thunk to abstract OS services from pure EFI code
Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
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.
**/
#ifndef __EMU_THUNK_PROTOCOL_H__
#define __EMU_THUNK_PROTOCOL_H__
#define EMU_THUNK_PROTOCOL_GUID \
{ 0xA37D7CCD, 0x8E91, 0xFB48, { 0xA0, 0xBD, 0x64, 0xC1, 0x83, 0xA3, 0xB4, 0x3F } }
// neded for things like EFI_TIME_CAPABILITIES
#include <Uefi.h>
#include <Library/PeCoffExtraActionLib.h>
#include <Protocol/EmuIoThunk.h>
#include <Protocol/DevicePath.h>
typedef struct {
VENDOR_DEVICE_PATH VendorDevicePath;
UINT32 Instance;
} EMU_VENDOR_DEVICE_PATH_NODE;
typedef struct {
EMU_VENDOR_DEVICE_PATH_NODE Vendor;
EFI_DEVICE_PATH_PROTOCOL EndDevicePath;
} EMU_THUNK_DEVICE_PATH;
typedef struct _EMU_THUNK_PROTOCOL EMU_THUNK_PROTOCOL;
typedef
EFI_STATUS
(EFIAPI *EMU_WRITE_STD_ERROR) (
IN UINT8 *Buffer,
IN UINTN NumberOfBytes
);
typedef
EFI_STATUS
(EFIAPI *EMU_PE_COFF_GET_ENTRY_POINT) (
IN VOID *Pe32Data,
IN OUT VOID **EntryPoint
);
typedef
VOID
(EFIAPI *EMU_PE_COFF_RELOCATE_EXTRA_ACTION) (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
);
typedef
VOID
(EFIAPI *EMU_PE_COFF_UNLOAD_EXTRA_ACTION) (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
);
typedef
VOID
(EFIAPI *EMU_ENABLE_INERRUPTS) (
VOID
);
typedef
VOID
(EFIAPI *EMU_DISABLE_INERRUPTS) (
VOID
);
typedef
UINT64
(EFIAPI *EMU_QUERY_PERFORMANCE_FREQENCY) (
VOID
);
typedef
UINT64
(EFIAPI *EMU_QUERY_PERFORMANCE_COUNTER) (
VOID
);
typedef
VOID
(EFIAPI *EMU_SLEEP) (
IN UINT64 Milliseconds
);
typedef
VOID
(EFIAPI *EMU_EXIT) (
IN UINTN Status
);
typedef
VOID
(EFIAPI *EMU_GET_TIME) (
OUT EFI_TIME *Time,
OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL
);
typedef
VOID
(EFIAPI *EMU_SET_TIME) (
IN EFI_TIME *Time
);
typedef
VOID
(EFIAPI EMU_SET_TIMER_CALLBACK) (
IN UINT64 DeltaMs
);
typedef
VOID
(EFIAPI *EMU_SET_TIMER) (
IN UINT64 PeriodMs,
IN EMU_SET_TIMER_CALLBACK CallBack
);
/**
Enumerates the current set of protocol instances that abstract OS services from EFI.
A given protocol can have multiple instances. Usually a protocol is configured via a
single PCD string. The data associated for each instance is seperated via a ! in the string.
EMU_IO_THUNK_PROTOCOL_CLOSE.ConfigString will contain the information in the PCD string up to the next !.
Thus each instance has a unique ConfigString.
@param EmuBusDriver TRUE means only return protocol instances that need to be produced
by the EmuBusDriver. FALSE means return all possible protocols
@param Instance On input the protocol to search for, or NULL to start a search
of all the supported protocol instances.
@param NextProtocol On output it represents the next value to be passed into Protocol.
@param Interface A pointer to the EMU_IO_THUNK_PROTOCOL_CLOSE interface.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_NOT_FOUND The next protocol instance was not found.
@retval EFI_INVALID_PARAMETER Instance is NULL.
**/
typedef
EFI_STATUS
(EFIAPI *EMU_GET_NEXT_PROTOCOL) (
IN BOOLEAN EmuBusDriver,
OUT EMU_IO_THUNK_PROTOCOL **Instance OPTIONAL
);
struct _EMU_THUNK_PROTOCOL {
// Used for early debug printing
EMU_WRITE_STD_ERROR WriteStdErr;
///
/// PE/COFF loader hooks to get symbols loaded
///
EMU_PE_COFF_GET_ENTRY_POINT PeCoffGetEntryPoint;
EMU_PE_COFF_RELOCATE_EXTRA_ACTION PeCoffRelocateImageExtraAction;
EMU_PE_COFF_UNLOAD_EXTRA_ACTION PeCoffUnloadImageExtraAction;
///
/// DXE Architecture Protocol Services
///
EMU_ENABLE_INERRUPTS EnableInterrupt;
EMU_DISABLE_INERRUPTS DisableInterrupt;
EMU_QUERY_PERFORMANCE_FREQENCY QueryPerformanceFrequency;
EMU_QUERY_PERFORMANCE_COUNTER QueryPerformanceCounter;
EMU_SLEEP Sleep;
EMU_EXIT Exit;
EMU_GET_TIME GetTime;
EMU_SET_TIME SetTime;
EMU_SET_TIMER SetTimer;
///
/// Generic System Services
///
EMU_GET_NEXT_PROTOCOL GetNextProtocol;
};
extern EFI_GUID gEmuThunkProtocolGuid;
#endif