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 { 0x5CF32E0B, 0x8EDF, 0x2E44, { 0x9C, 0xDA, 0x93, 0x20, 0x5E, 0x99, 0xEC, 0x1C } }
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_CONFIG_STD_IN
) (
62 (EFIAPI
*EMU_WRITE_STD_OUT
) (
64 IN UINTN NumberOfBytes
69 (EFIAPI
*EMU_READ_STD_IN
) (
71 IN UINTN NumberOfBytes
76 (EFIAPI
*EMU_POLL_STD_IN
) (
83 (EFIAPI
*EMU_OS_MALLOC
) (
89 (EFIAPI
*EMU_OS_VMALLOC
) (
95 (EFIAPI
*EMU_OS_FREE
) (
102 (EFIAPI
*EMU_PE_COFF_GET_ENTRY_POINT
) (
104 IN OUT VOID
**EntryPoint
109 (EFIAPI
*EMU_PE_COFF_RELOCATE_EXTRA_ACTION
) (
110 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT
*ImageContext
115 (EFIAPI
*EMU_PE_COFF_UNLOAD_EXTRA_ACTION
) (
116 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT
*ImageContext
121 (EFIAPI
*EMU_ENABLE_INERRUPTS
) (
127 (EFIAPI
*EMU_DISABLE_INERRUPTS
) (
133 (EFIAPI
*EMU_QUERY_PERFORMANCE_FREQENCY
) (
139 (EFIAPI
*EMU_QUERY_PERFORMANCE_COUNTER
) (
145 (EFIAPI
*EMU_SLEEP
) (
146 IN UINT64 Milliseconds
151 (EFIAPI
*EMU_CPU_SLEEP
) (
163 (EFIAPI
*EMU_GET_TIME
) (
165 OUT EFI_TIME_CAPABILITIES
*Capabilities OPTIONAL
170 (EFIAPI
*EMU_SET_TIME
) (
177 (EFIAPI EMU_SET_TIMER_CALLBACK
) (
183 (EFIAPI
*EMU_SET_TIMER
) (
185 IN EMU_SET_TIMER_CALLBACK CallBack
191 Enumerates the current set of protocol instances that abstract OS services from EFI.
193 A given protocol can have multiple instances. Usually a protocol is configured via a
194 single PCD string. The data associated for each instance is seperated via a ! in the string.
195 EMU_IO_THUNK_PROTOCOL_CLOSE.ConfigString will contain the information in the PCD string up to the next !.
196 Thus each instance has a unique ConfigString.
198 @param EmuBusDriver TRUE means only return protocol instances that need to be produced
199 by the EmuBusDriver. FALSE means return all possible protocols
200 @param Instance On input the protocol to search for, or NULL to start a search
201 of all the supported protocol instances.
202 @param NextProtocol On output it represents the next value to be passed into Protocol.
203 @param Interface A pointer to the EMU_IO_THUNK_PROTOCOL_CLOSE interface.
205 @retval EFI_SUCCESS The function completed successfully.
206 @retval EFI_NOT_FOUND The next protocol instance was not found.
207 @retval EFI_INVALID_PARAMETER Instance is NULL.
212 (EFIAPI
*EMU_GET_NEXT_PROTOCOL
) (
213 IN BOOLEAN EmuBusDriver
,
214 OUT EMU_IO_THUNK_PROTOCOL
**Instance OPTIONAL
218 struct _EMU_THUNK_PROTOCOL
{
219 // Used for early debug printing
220 EMU_WRITE_STD_ERROR WriteStdErr
;
221 EMU_CONFIG_STD_IN ConfigStdIn
;
222 EMU_WRITE_STD_OUT WriteStdOut
;
223 EMU_READ_STD_IN ReadStdIn
;
224 EMU_POLL_STD_IN PollStdIn
;
227 // Map OS malloc/free so we can use OS based guard malloc
229 EMU_OS_MALLOC Malloc
;
230 EMU_OS_VMALLOC Valloc
;
235 /// PE/COFF loader hooks to get symbols loaded
237 EMU_PE_COFF_GET_ENTRY_POINT PeCoffGetEntryPoint
;
238 EMU_PE_COFF_RELOCATE_EXTRA_ACTION PeCoffRelocateImageExtraAction
;
239 EMU_PE_COFF_UNLOAD_EXTRA_ACTION PeCoffUnloadImageExtraAction
;
242 /// DXE Architecture Protocol Services
244 EMU_ENABLE_INERRUPTS EnableInterrupt
;
245 EMU_DISABLE_INERRUPTS DisableInterrupt
;
246 EMU_QUERY_PERFORMANCE_FREQENCY QueryPerformanceFrequency
;
247 EMU_QUERY_PERFORMANCE_COUNTER QueryPerformanceCounter
;
250 EMU_CPU_SLEEP CpuSleep
;
252 EMU_GET_TIME GetTime
;
253 EMU_SET_TIME SetTime
;
254 EMU_SET_TIMER SetTimer
;
257 /// Generic System Services
259 EMU_GET_NEXT_PROTOCOL GetNextProtocol
;
262 extern EFI_GUID gEmuThunkProtocolGuid
;