2 Emulator Thunk to abstract OS services from pure EFI code
4 Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #ifndef __EMU_THUNK_PROTOCOL_H__
11 #define __EMU_THUNK_PROTOCOL_H__
13 #define EMU_THUNK_PROTOCOL_GUID \
14 { 0x5CF32E0B, 0x8EDF, 0x2E44, { 0x9C, 0xDA, 0x93, 0x20, 0x5E, 0x99, 0xEC, 0x1C } }
16 // neded for things like EFI_TIME_CAPABILITIES
19 #include <Library/PeCoffExtraActionLib.h>
21 #include <Protocol/EmuIoThunk.h>
22 #include <Protocol/DevicePath.h>
25 VENDOR_DEVICE_PATH VendorDevicePath
;
27 } EMU_VENDOR_DEVICE_PATH_NODE
;
30 EMU_VENDOR_DEVICE_PATH_NODE Vendor
;
31 EFI_DEVICE_PATH_PROTOCOL EndDevicePath
;
32 } EMU_THUNK_DEVICE_PATH
;
34 typedef struct _EMU_THUNK_PROTOCOL EMU_THUNK_PROTOCOL
;
38 (EFIAPI
*EMU_WRITE_STD_ERROR
)(
40 IN UINTN NumberOfBytes
45 (EFIAPI
*EMU_CONFIG_STD_IN
)(
51 (EFIAPI
*EMU_WRITE_STD_OUT
)(
53 IN UINTN NumberOfBytes
58 (EFIAPI
*EMU_READ_STD_IN
)(
60 IN UINTN NumberOfBytes
65 (EFIAPI
*EMU_POLL_STD_IN
)(
71 (EFIAPI
*EMU_OS_MALLOC
)(
77 (EFIAPI
*EMU_OS_VMALLOC
)(
83 (EFIAPI
*EMU_OS_FREE
)(
89 (EFIAPI
*EMU_PE_COFF_GET_ENTRY_POINT
)(
91 IN OUT VOID
**EntryPoint
96 (EFIAPI
*EMU_PE_COFF_RELOCATE_EXTRA_ACTION
)(
97 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT
*ImageContext
102 (EFIAPI
*EMU_PE_COFF_UNLOAD_EXTRA_ACTION
)(
103 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT
*ImageContext
108 (EFIAPI
*EMU_ENABLE_INERRUPTS
)(
114 (EFIAPI
*EMU_DISABLE_INERRUPTS
)(
120 (EFIAPI
*EMU_QUERY_PERFORMANCE_FREQENCY
)(
126 (EFIAPI
*EMU_QUERY_PERFORMANCE_COUNTER
)(
133 IN UINT64 Milliseconds
138 (EFIAPI
*EMU_CPU_SLEEP
)(
150 (EFIAPI
*EMU_GET_TIME
)(
152 OUT EFI_TIME_CAPABILITIES
*Capabilities OPTIONAL
157 (EFIAPI
*EMU_SET_TIME
)(
163 (EFIAPI EMU_SET_TIMER_CALLBACK
)(
169 (EFIAPI
*EMU_SET_TIMER
)(
171 IN EMU_SET_TIMER_CALLBACK CallBack
175 Enumerates the current set of protocol instances that abstract OS services from EFI.
177 A given protocol can have multiple instances. Usually a protocol is configured via a
178 single PCD string. The data associated for each instance is seperated via a ! in the string.
179 EMU_IO_THUNK_PROTOCOL_CLOSE.ConfigString will contain the information in the PCD string up to the next !.
180 Thus each instance has a unique ConfigString.
182 @param EmuBusDriver TRUE means only return protocol instances that need to be produced
183 by the EmuBusDriver. FALSE means return all possible protocols
184 @param Instance On input the protocol to search for, or NULL to start a search
185 of all the supported protocol instances.
186 @param NextProtocol On output it represents the next value to be passed into Protocol.
187 @param Interface A pointer to the EMU_IO_THUNK_PROTOCOL_CLOSE interface.
189 @retval EFI_SUCCESS The function completed successfully.
190 @retval EFI_NOT_FOUND The next protocol instance was not found.
191 @retval EFI_INVALID_PARAMETER Instance is NULL.
196 (EFIAPI
*EMU_GET_NEXT_PROTOCOL
)(
197 IN BOOLEAN EmuBusDriver
,
198 OUT EMU_IO_THUNK_PROTOCOL
**Instance OPTIONAL
201 struct _EMU_THUNK_PROTOCOL
{
202 // Used for early debug printing
203 EMU_WRITE_STD_ERROR WriteStdErr
;
204 EMU_CONFIG_STD_IN ConfigStdIn
;
205 EMU_WRITE_STD_OUT WriteStdOut
;
206 EMU_READ_STD_IN ReadStdIn
;
207 EMU_POLL_STD_IN PollStdIn
;
210 // Map OS malloc/free so we can use OS based guard malloc
212 EMU_OS_MALLOC Malloc
;
213 EMU_OS_VMALLOC Valloc
;
217 /// PE/COFF loader hooks to get symbols loaded
219 EMU_PE_COFF_GET_ENTRY_POINT PeCoffGetEntryPoint
;
220 EMU_PE_COFF_RELOCATE_EXTRA_ACTION PeCoffRelocateImageExtraAction
;
221 EMU_PE_COFF_UNLOAD_EXTRA_ACTION PeCoffUnloadImageExtraAction
;
224 /// DXE Architecture Protocol Services
226 EMU_ENABLE_INERRUPTS EnableInterrupt
;
227 EMU_DISABLE_INERRUPTS DisableInterrupt
;
228 EMU_QUERY_PERFORMANCE_FREQENCY QueryPerformanceFrequency
;
229 EMU_QUERY_PERFORMANCE_COUNTER QueryPerformanceCounter
;
232 EMU_CPU_SLEEP CpuSleep
;
234 EMU_GET_TIME GetTime
;
235 EMU_SET_TIME SetTime
;
236 EMU_SET_TIMER SetTimer
;
239 /// Generic System Services
241 EMU_GET_NEXT_PROTOCOL GetNextProtocol
;
244 extern EFI_GUID gEmuThunkProtocolGuid
;