]> git.proxmox.com Git - mirror_edk2.git/blame - EmulatorPkg/Include/Protocol/EmuThunk.h
EmulatorPkg/PeiTimerLib: Bug fix in NanoSecondDelay
[mirror_edk2.git] / EmulatorPkg / Include / Protocol / EmuThunk.h
CommitLineData
949f388f 1/** @file\r
2 Emulator Thunk to abstract OS services from pure EFI code\r
3\r
4 Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>\r
d18d8a1d 5\r
e3ba31da 6 SPDX-License-Identifier: BSD-2-Clause-Patent\r
949f388f 7\r
8**/\r
9\r
10#ifndef __EMU_THUNK_PROTOCOL_H__\r
11#define __EMU_THUNK_PROTOCOL_H__\r
12\r
13#define EMU_THUNK_PROTOCOL_GUID \\r
7e284acb 14 { 0x5CF32E0B, 0x8EDF, 0x2E44, { 0x9C, 0xDA, 0x93, 0x20, 0x5E, 0x99, 0xEC, 0x1C } }\r
949f388f 15\r
16// neded for things like EFI_TIME_CAPABILITIES\r
17#include <Uefi.h>\r
18\r
19#include <Library/PeCoffExtraActionLib.h>\r
20\r
21#include <Protocol/EmuIoThunk.h>\r
22#include <Protocol/DevicePath.h>\r
23\r
949f388f 24typedef struct {\r
a550d468
MK
25 VENDOR_DEVICE_PATH VendorDevicePath;\r
26 UINT32 Instance;\r
949f388f 27} EMU_VENDOR_DEVICE_PATH_NODE;\r
28\r
29typedef struct {\r
a550d468
MK
30 EMU_VENDOR_DEVICE_PATH_NODE Vendor;\r
31 EFI_DEVICE_PATH_PROTOCOL EndDevicePath;\r
949f388f 32} EMU_THUNK_DEVICE_PATH;\r
33\r
a550d468 34typedef struct _EMU_THUNK_PROTOCOL EMU_THUNK_PROTOCOL;\r
949f388f 35\r
d18d8a1d 36typedef\r
7e284acb 37UINTN\r
a550d468 38(EFIAPI *EMU_WRITE_STD_ERROR)(\r
7e284acb 39 IN UINT8 *Buffer,\r
40 IN UINTN NumberOfBytes\r
d18d8a1d 41 );\r
42\r
43typedef\r
7e284acb 44EFI_STATUS\r
a550d468 45(EFIAPI *EMU_CONFIG_STD_IN)(\r
7e284acb 46 VOID\r
47 );\r
d18d8a1d 48\r
49typedef\r
7e284acb 50UINTN\r
a550d468 51(EFIAPI *EMU_WRITE_STD_OUT)(\r
949f388f 52 IN UINT8 *Buffer,\r
53 IN UINTN NumberOfBytes\r
54 );\r
d18d8a1d 55\r
56typedef\r
7e284acb 57UINTN\r
a550d468 58(EFIAPI *EMU_READ_STD_IN)(\r
7e284acb 59 OUT UINT8 *Buffer,\r
60 IN UINTN NumberOfBytes\r
61 );\r
62\r
d18d8a1d 63typedef\r
7e284acb 64BOOLEAN\r
a550d468 65(EFIAPI *EMU_POLL_STD_IN)(\r
7e284acb 66 VOID\r
67 );\r
68\r
c2175068 69typedef\r
70VOID *\r
a550d468 71(EFIAPI *EMU_OS_MALLOC)(\r
c2175068 72 IN UINTN Size\r
73 );\r
1d7ac5a6 74\r
75typedef\r
76VOID *\r
a550d468 77(EFIAPI *EMU_OS_VMALLOC)(\r
1d7ac5a6 78 IN UINTN Size\r
79 );\r
d18d8a1d 80\r
81typedef\r
1d7ac5a6 82BOOLEAN\r
a550d468 83(EFIAPI *EMU_OS_FREE)(\r
c2175068 84 IN VOID *Ptr\r
85 );\r
86\r
d18d8a1d 87typedef\r
949f388f 88EFI_STATUS\r
a550d468 89(EFIAPI *EMU_PE_COFF_GET_ENTRY_POINT)(\r
949f388f 90 IN VOID *Pe32Data,\r
91 IN OUT VOID **EntryPoint\r
92 );\r
93\r
d18d8a1d 94typedef\r
949f388f 95VOID\r
a550d468 96(EFIAPI *EMU_PE_COFF_RELOCATE_EXTRA_ACTION)(\r
949f388f 97 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
98 );\r
99\r
d18d8a1d 100typedef\r
949f388f 101VOID\r
a550d468 102(EFIAPI *EMU_PE_COFF_UNLOAD_EXTRA_ACTION)(\r
949f388f 103 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
104 );\r
105\r
106typedef\r
107VOID\r
a550d468 108(EFIAPI *EMU_ENABLE_INERRUPTS)(\r
949f388f 109 VOID\r
110 );\r
d18d8a1d 111\r
949f388f 112typedef\r
113VOID\r
a550d468 114(EFIAPI *EMU_DISABLE_INERRUPTS)(\r
949f388f 115 VOID\r
116 );\r
117\r
118typedef\r
119UINT64\r
a550d468 120(EFIAPI *EMU_QUERY_PERFORMANCE_FREQENCY)(\r
949f388f 121 VOID\r
122 );\r
123\r
124typedef\r
125UINT64\r
a550d468 126(EFIAPI *EMU_QUERY_PERFORMANCE_COUNTER)(\r
949f388f 127 VOID\r
128 );\r
129\r
130typedef\r
131VOID\r
a550d468 132(EFIAPI *EMU_SLEEP)(\r
f6ce1a5c 133 IN UINT64 Nanoseconds\r
949f388f 134 );\r
135\r
57c7d70f 136typedef\r
137VOID\r
a550d468 138(EFIAPI *EMU_CPU_SLEEP)(\r
57c7d70f 139 VOID\r
140 );\r
141\r
949f388f 142typedef\r
143VOID\r
a550d468 144(EFIAPI *EMU_EXIT)(\r
949f388f 145 IN UINTN Status\r
146 );\r
d18d8a1d 147\r
949f388f 148typedef\r
149VOID\r
a550d468 150(EFIAPI *EMU_GET_TIME)(\r
949f388f 151 OUT EFI_TIME *Time,\r
152 OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL\r
153 );\r
d18d8a1d 154\r
949f388f 155typedef\r
156VOID\r
a550d468 157(EFIAPI *EMU_SET_TIME)(\r
949f388f 158 IN EFI_TIME *Time\r
159 );\r
160\r
949f388f 161typedef\r
162VOID\r
a550d468 163(EFIAPI EMU_SET_TIMER_CALLBACK)(\r
949f388f 164 IN UINT64 DeltaMs\r
165 );\r
166\r
167typedef\r
168VOID\r
a550d468 169(EFIAPI *EMU_SET_TIMER)(\r
949f388f 170 IN UINT64 PeriodMs,\r
171 IN EMU_SET_TIMER_CALLBACK CallBack\r
172 );\r
d18d8a1d 173\r
949f388f 174/**\r
175 Enumerates the current set of protocol instances that abstract OS services from EFI.\r
d18d8a1d 176\r
949f388f 177 A given protocol can have multiple instances. Usually a protocol is configured via a\r
d18d8a1d 178 single PCD string. The data associated for each instance is seperated via a ! in the string.\r
949f388f 179 EMU_IO_THUNK_PROTOCOL_CLOSE.ConfigString will contain the information in the PCD string up to the next !.\r
d18d8a1d 180 Thus each instance has a unique ConfigString.\r
949f388f 181\r
182 @param EmuBusDriver TRUE means only return protocol instances that need to be produced\r
183 by the EmuBusDriver. FALSE means return all possible protocols\r
d18d8a1d 184 @param Instance On input the protocol to search for, or NULL to start a search\r
185 of all the supported protocol instances.\r
186 @param NextProtocol On output it represents the next value to be passed into Protocol.\r
187 @param Interface A pointer to the EMU_IO_THUNK_PROTOCOL_CLOSE interface.\r
949f388f 188\r
189 @retval EFI_SUCCESS The function completed successfully.\r
190 @retval EFI_NOT_FOUND The next protocol instance was not found.\r
191 @retval EFI_INVALID_PARAMETER Instance is NULL.\r
192\r
193**/\r
194typedef\r
195EFI_STATUS\r
a550d468 196(EFIAPI *EMU_GET_NEXT_PROTOCOL)(\r
949f388f 197 IN BOOLEAN EmuBusDriver,\r
198 OUT EMU_IO_THUNK_PROTOCOL **Instance OPTIONAL\r
199 );\r
d18d8a1d 200\r
949f388f 201struct _EMU_THUNK_PROTOCOL {\r
202 // Used for early debug printing\r
a550d468
MK
203 EMU_WRITE_STD_ERROR WriteStdErr;\r
204 EMU_CONFIG_STD_IN ConfigStdIn;\r
205 EMU_WRITE_STD_OUT WriteStdOut;\r
206 EMU_READ_STD_IN ReadStdIn;\r
207 EMU_POLL_STD_IN PollStdIn;\r
d18d8a1d 208\r
c2175068 209 //\r
210 // Map OS malloc/free so we can use OS based guard malloc\r
211 //\r
a550d468
MK
212 EMU_OS_MALLOC Malloc;\r
213 EMU_OS_VMALLOC Valloc;\r
214 EMU_OS_FREE Free;\r
d18d8a1d 215\r
949f388f 216 ///\r
217 /// PE/COFF loader hooks to get symbols loaded\r
218 ///\r
a550d468
MK
219 EMU_PE_COFF_GET_ENTRY_POINT PeCoffGetEntryPoint;\r
220 EMU_PE_COFF_RELOCATE_EXTRA_ACTION PeCoffRelocateImageExtraAction;\r
221 EMU_PE_COFF_UNLOAD_EXTRA_ACTION PeCoffUnloadImageExtraAction;\r
d18d8a1d 222\r
949f388f 223 ///\r
224 /// DXE Architecture Protocol Services\r
225 ///\r
a550d468
MK
226 EMU_ENABLE_INERRUPTS EnableInterrupt;\r
227 EMU_DISABLE_INERRUPTS DisableInterrupt;\r
228 EMU_QUERY_PERFORMANCE_FREQENCY QueryPerformanceFrequency;\r
229 EMU_QUERY_PERFORMANCE_COUNTER QueryPerformanceCounter;\r
230\r
231 EMU_SLEEP Sleep;\r
232 EMU_CPU_SLEEP CpuSleep;\r
233 EMU_EXIT Exit;\r
234 EMU_GET_TIME GetTime;\r
235 EMU_SET_TIME SetTime;\r
236 EMU_SET_TIMER SetTimer;\r
d18d8a1d 237\r
949f388f 238 ///\r
239 /// Generic System Services\r
240 ///\r
a550d468 241 EMU_GET_NEXT_PROTOCOL GetNextProtocol;\r
949f388f 242};\r
243\r
a550d468 244extern EFI_GUID gEmuThunkProtocolGuid;\r
949f388f 245\r
246#endif\r