2 Emulator Thunk to abstract OS services from pure EFI code
4 Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #ifndef __EMU_THUNK_PROTOCOL_H__
17 #define __EMU_THUNK_PROTOCOL_H__
19 #define EMU_THUNK_PROTOCOL_GUID \
20 { 0xA37D7CCD, 0x8E91, 0xFB48, { 0xA0, 0xBD, 0x64, 0xC1, 0x83, 0xA3, 0xB4, 0x3F } }
22 // neded for things like EFI_TIME_CAPABILITIES
25 #include <Library/PeCoffExtraActionLib.h>
27 #include <Protocol/EmuIoThunk.h>
28 #include <Protocol/DevicePath.h>
32 VENDOR_DEVICE_PATH VendorDevicePath
;
34 } EMU_VENDOR_DEVICE_PATH_NODE
;
37 EMU_VENDOR_DEVICE_PATH_NODE Vendor
;
38 EFI_DEVICE_PATH_PROTOCOL EndDevicePath
;
39 } EMU_THUNK_DEVICE_PATH
;
43 typedef struct _EMU_THUNK_PROTOCOL EMU_THUNK_PROTOCOL
;
49 (EFIAPI
*EMU_WRITE_STD_ERROR
) (
51 IN UINTN NumberOfBytes
56 (EFIAPI
*EMU_PE_COFF_GET_ENTRY_POINT
) (
58 IN OUT VOID
**EntryPoint
63 (EFIAPI
*EMU_PE_COFF_RELOCATE_EXTRA_ACTION
) (
64 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT
*ImageContext
69 (EFIAPI
*EMU_PE_COFF_UNLOAD_EXTRA_ACTION
) (
70 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT
*ImageContext
75 (EFIAPI
*EMU_ENABLE_INERRUPTS
) (
81 (EFIAPI
*EMU_DISABLE_INERRUPTS
) (
87 (EFIAPI
*EMU_QUERY_PERFORMANCE_FREQENCY
) (
93 (EFIAPI
*EMU_QUERY_PERFORMANCE_COUNTER
) (
100 IN UINT64 Milliseconds
111 (EFIAPI
*EMU_GET_TIME
) (
113 OUT EFI_TIME_CAPABILITIES
*Capabilities OPTIONAL
118 (EFIAPI
*EMU_SET_TIME
) (
125 (EFIAPI EMU_SET_TIMER_CALLBACK
) (
131 (EFIAPI
*EMU_SET_TIMER
) (
133 IN EMU_SET_TIMER_CALLBACK CallBack
139 Enumerates the current set of protocol instances that abstract OS services from EFI.
141 A given protocol can have multiple instances. Usually a protocol is configured via a
142 single PCD string. The data associated for each instance is seperated via a ! in the string.
143 EMU_IO_THUNK_PROTOCOL_CLOSE.ConfigString will contain the information in the PCD string up to the next !.
144 Thus each instance has a unique ConfigString.
146 @param EmuBusDriver TRUE means only return protocol instances that need to be produced
147 by the EmuBusDriver. FALSE means return all possible protocols
148 @param Instance On input the protocol to search for, or NULL to start a search
149 of all the supported protocol instances.
150 @param NextProtocol On output it represents the next value to be passed into Protocol.
151 @param Interface A pointer to the EMU_IO_THUNK_PROTOCOL_CLOSE interface.
153 @retval EFI_SUCCESS The function completed successfully.
154 @retval EFI_NOT_FOUND The next protocol instance was not found.
155 @retval EFI_INVALID_PARAMETER Instance is NULL.
160 (EFIAPI
*EMU_GET_NEXT_PROTOCOL
) (
161 IN BOOLEAN EmuBusDriver
,
162 OUT EMU_IO_THUNK_PROTOCOL
**Instance OPTIONAL
166 struct _EMU_THUNK_PROTOCOL
{
167 // Used for early debug printing
168 EMU_WRITE_STD_ERROR WriteStdErr
;
171 /// PE/COFF loader hooks to get symbols loaded
173 EMU_PE_COFF_GET_ENTRY_POINT PeCoffGetEntryPoint
;
174 EMU_PE_COFF_RELOCATE_EXTRA_ACTION PeCoffRelocateImageExtraAction
;
175 EMU_PE_COFF_UNLOAD_EXTRA_ACTION PeCoffUnloadImageExtraAction
;
178 /// DXE Architecture Protocol Services
180 EMU_ENABLE_INERRUPTS EnableInterrupt
;
181 EMU_DISABLE_INERRUPTS DisableInterrupt
;
182 EMU_QUERY_PERFORMANCE_FREQENCY QueryPerformanceFrequency
;
183 EMU_QUERY_PERFORMANCE_COUNTER QueryPerformanceCounter
;
187 EMU_GET_TIME GetTime
;
188 EMU_SET_TIME SetTime
;
189 EMU_SET_TIMER SetTimer
;
192 /// Generic System Services
194 EMU_GET_NEXT_PROTOCOL GetNextProtocol
;
197 extern EFI_GUID gEmuThunkProtocolGuid
;