summaryrefslogtreecommitdiff
path: root/InOsEmuPkg/Include/Protocol/EmuThunk.h
diff options
context:
space:
mode:
authorandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>2011-05-11 18:31:20 +0000
committerandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>2011-05-11 18:31:20 +0000
commit949f388f5fa361e3be374f59edc09b92296abe03 (patch)
tree1fdc4fe9c2c4aa61b8bfbb527134b19918448d29 /InOsEmuPkg/Include/Protocol/EmuThunk.h
parentda92f27632d2c89fa8726948ac9b02461ca8b61e (diff)
downloadedk2-platforms-949f388f5fa361e3be374f59edc09b92296abe03.tar.xz
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
Diffstat (limited to 'InOsEmuPkg/Include/Protocol/EmuThunk.h')
-rw-r--r--InOsEmuPkg/Include/Protocol/EmuThunk.h199
1 files changed, 199 insertions, 0 deletions
diff --git a/InOsEmuPkg/Include/Protocol/EmuThunk.h b/InOsEmuPkg/Include/Protocol/EmuThunk.h
new file mode 100644
index 0000000000..411cd3e625
--- /dev/null
+++ b/InOsEmuPkg/Include/Protocol/EmuThunk.h
@@ -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