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
) (
84 (EFIAPI
*EMU_PE_COFF_GET_ENTRY_POINT
) (
86 IN OUT VOID
**EntryPoint
91 (EFIAPI
*EMU_PE_COFF_RELOCATE_EXTRA_ACTION
) (
92 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT
*ImageContext
97 (EFIAPI
*EMU_PE_COFF_UNLOAD_EXTRA_ACTION
) (
98 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT
*ImageContext
103 (EFIAPI
*EMU_ENABLE_INERRUPTS
) (
109 (EFIAPI
*EMU_DISABLE_INERRUPTS
) (
115 (EFIAPI
*EMU_QUERY_PERFORMANCE_FREQENCY
) (
121 (EFIAPI
*EMU_QUERY_PERFORMANCE_COUNTER
) (
127 (EFIAPI
*EMU_SLEEP
) (
128 IN UINT64 Milliseconds
139 (EFIAPI
*EMU_GET_TIME
) (
141 OUT EFI_TIME_CAPABILITIES
*Capabilities OPTIONAL
146 (EFIAPI
*EMU_SET_TIME
) (
153 (EFIAPI EMU_SET_TIMER_CALLBACK
) (
159 (EFIAPI
*EMU_SET_TIMER
) (
161 IN EMU_SET_TIMER_CALLBACK CallBack
167 Enumerates the current set of protocol instances that abstract OS services from EFI.
169 A given protocol can have multiple instances. Usually a protocol is configured via a
170 single PCD string. The data associated for each instance is seperated via a ! in the string.
171 EMU_IO_THUNK_PROTOCOL_CLOSE.ConfigString will contain the information in the PCD string up to the next !.
172 Thus each instance has a unique ConfigString.
174 @param EmuBusDriver TRUE means only return protocol instances that need to be produced
175 by the EmuBusDriver. FALSE means return all possible protocols
176 @param Instance On input the protocol to search for, or NULL to start a search
177 of all the supported protocol instances.
178 @param NextProtocol On output it represents the next value to be passed into Protocol.
179 @param Interface A pointer to the EMU_IO_THUNK_PROTOCOL_CLOSE interface.
181 @retval EFI_SUCCESS The function completed successfully.
182 @retval EFI_NOT_FOUND The next protocol instance was not found.
183 @retval EFI_INVALID_PARAMETER Instance is NULL.
188 (EFIAPI
*EMU_GET_NEXT_PROTOCOL
) (
189 IN BOOLEAN EmuBusDriver
,
190 OUT EMU_IO_THUNK_PROTOCOL
**Instance OPTIONAL
194 struct _EMU_THUNK_PROTOCOL
{
195 // Used for early debug printing
196 EMU_WRITE_STD_ERROR WriteStdErr
;
197 EMU_CONFIG_STD_IN ConfigStdIn
;
198 EMU_WRITE_STD_OUT WriteStdOut
;
199 EMU_READ_STD_IN ReadStdIn
;
200 EMU_POLL_STD_IN PollStdIn
;
203 /// PE/COFF loader hooks to get symbols loaded
205 EMU_PE_COFF_GET_ENTRY_POINT PeCoffGetEntryPoint
;
206 EMU_PE_COFF_RELOCATE_EXTRA_ACTION PeCoffRelocateImageExtraAction
;
207 EMU_PE_COFF_UNLOAD_EXTRA_ACTION PeCoffUnloadImageExtraAction
;
210 /// DXE Architecture Protocol Services
212 EMU_ENABLE_INERRUPTS EnableInterrupt
;
213 EMU_DISABLE_INERRUPTS DisableInterrupt
;
214 EMU_QUERY_PERFORMANCE_FREQENCY QueryPerformanceFrequency
;
215 EMU_QUERY_PERFORMANCE_COUNTER QueryPerformanceCounter
;
219 EMU_GET_TIME GetTime
;
220 EMU_SET_TIME SetTime
;
221 EMU_SET_TIMER SetTimer
;
224 /// Generic System Services
226 EMU_GET_NEXT_PROTOCOL GetNextProtocol
;
229 extern EFI_GUID gEmuThunkProtocolGuid
;