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