]> git.proxmox.com Git - mirror_edk2.git/blame - InOsEmuPkg/Include/Protocol/EmuThunk.h
Clarify the requirements for the Destination parameter of UnicodeStrToAsciiStr.
[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
1d7ac5a6 86\r
87typedef\r
88VOID *\r
89(EFIAPI *EMU_OS_VMALLOC) (\r
90 IN UINTN Size\r
91 );\r
c2175068 92 \r
93typedef \r
1d7ac5a6 94BOOLEAN\r
c2175068 95(EFIAPI *EMU_OS_FREE) (\r
96 IN VOID *Ptr\r
97 );\r
98\r
949f388f 99\r
100typedef \r
101EFI_STATUS\r
102(EFIAPI *EMU_PE_COFF_GET_ENTRY_POINT) (\r
103 IN VOID *Pe32Data,\r
104 IN OUT VOID **EntryPoint\r
105 );\r
106\r
107typedef \r
108VOID\r
109(EFIAPI *EMU_PE_COFF_RELOCATE_EXTRA_ACTION) (\r
110 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
111 );\r
112\r
113typedef \r
114VOID\r
115(EFIAPI *EMU_PE_COFF_UNLOAD_EXTRA_ACTION) (\r
116 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
117 );\r
118\r
119typedef\r
120VOID\r
121(EFIAPI *EMU_ENABLE_INERRUPTS) (\r
122 VOID\r
123 );\r
124 \r
125typedef\r
126VOID\r
127(EFIAPI *EMU_DISABLE_INERRUPTS) (\r
128 VOID\r
129 );\r
130\r
131typedef\r
132UINT64\r
133(EFIAPI *EMU_QUERY_PERFORMANCE_FREQENCY) (\r
134 VOID\r
135 );\r
136\r
137typedef\r
138UINT64\r
139(EFIAPI *EMU_QUERY_PERFORMANCE_COUNTER) (\r
140 VOID\r
141 );\r
142\r
143typedef\r
144VOID\r
145(EFIAPI *EMU_SLEEP) (\r
146 IN UINT64 Milliseconds\r
147 );\r
148\r
57c7d70f 149typedef\r
150VOID\r
151(EFIAPI *EMU_CPU_SLEEP) (\r
152 VOID\r
153 );\r
154\r
949f388f 155typedef\r
156VOID\r
157(EFIAPI *EMU_EXIT) (\r
158 IN UINTN Status\r
159 );\r
160 \r
161typedef\r
162VOID\r
163(EFIAPI *EMU_GET_TIME) (\r
164 OUT EFI_TIME *Time,\r
165 OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL\r
166 );\r
167 \r
168typedef\r
169VOID\r
170(EFIAPI *EMU_SET_TIME) (\r
171 IN EFI_TIME *Time\r
172 );\r
173\r
174\r
175typedef\r
176VOID\r
177(EFIAPI EMU_SET_TIMER_CALLBACK) (\r
178 IN UINT64 DeltaMs\r
179 );\r
180\r
181typedef\r
182VOID\r
183(EFIAPI *EMU_SET_TIMER) (\r
184 IN UINT64 PeriodMs,\r
185 IN EMU_SET_TIMER_CALLBACK CallBack\r
186 );\r
187 \r
188\r
189\r
190/**\r
191 Enumerates the current set of protocol instances that abstract OS services from EFI.\r
192 \r
193 A given protocol can have multiple instances. Usually a protocol is configured via a\r
194 single PCD string. The data associated for each instance is seperated via a ! in the string. \r
195 EMU_IO_THUNK_PROTOCOL_CLOSE.ConfigString will contain the information in the PCD string up to the next !.\r
196 Thus each instance has a unique ConfigString. \r
197\r
198 @param EmuBusDriver TRUE means only return protocol instances that need to be produced\r
199 by the EmuBusDriver. FALSE means return all possible protocols\r
200 @param Instance On input the protocol to search for, or NULL to start a search \r
201 of all the supported protocol instances. \r
202 @param NextProtocol On output it represents the next value to be passed into Protocol. \r
203 @param Interface A pointer to the EMU_IO_THUNK_PROTOCOL_CLOSE interface. \r
204\r
205 @retval EFI_SUCCESS The function completed successfully.\r
206 @retval EFI_NOT_FOUND The next protocol instance was not found.\r
207 @retval EFI_INVALID_PARAMETER Instance is NULL.\r
208\r
209**/\r
210typedef\r
211EFI_STATUS\r
212(EFIAPI *EMU_GET_NEXT_PROTOCOL) (\r
213 IN BOOLEAN EmuBusDriver,\r
214 OUT EMU_IO_THUNK_PROTOCOL **Instance OPTIONAL\r
215 );\r
216 \r
217\r
218struct _EMU_THUNK_PROTOCOL {\r
219 // Used for early debug printing\r
220 EMU_WRITE_STD_ERROR WriteStdErr;\r
7e284acb 221 EMU_CONFIG_STD_IN ConfigStdIn;\r
222 EMU_WRITE_STD_OUT WriteStdOut;\r
223 EMU_READ_STD_IN ReadStdIn;\r
224 EMU_POLL_STD_IN PollStdIn;\r
949f388f 225 \r
c2175068 226 //\r
227 // Map OS malloc/free so we can use OS based guard malloc\r
228 //\r
229 EMU_OS_MALLOC Malloc;\r
1d7ac5a6 230 EMU_OS_VMALLOC Valloc;\r
c2175068 231 EMU_OS_FREE Free;\r
232 \r
233 \r
949f388f 234 ///\r
235 /// PE/COFF loader hooks to get symbols loaded\r
236 ///\r
237 EMU_PE_COFF_GET_ENTRY_POINT PeCoffGetEntryPoint;\r
238 EMU_PE_COFF_RELOCATE_EXTRA_ACTION PeCoffRelocateImageExtraAction;\r
239 EMU_PE_COFF_UNLOAD_EXTRA_ACTION PeCoffUnloadImageExtraAction;\r
240 \r
241 ///\r
242 /// DXE Architecture Protocol Services\r
243 ///\r
244 EMU_ENABLE_INERRUPTS EnableInterrupt;\r
245 EMU_DISABLE_INERRUPTS DisableInterrupt;\r
246 EMU_QUERY_PERFORMANCE_FREQENCY QueryPerformanceFrequency;\r
247 EMU_QUERY_PERFORMANCE_COUNTER QueryPerformanceCounter;\r
248\r
249 EMU_SLEEP Sleep;\r
57c7d70f 250 EMU_CPU_SLEEP CpuSleep;\r
949f388f 251 EMU_EXIT Exit;\r
252 EMU_GET_TIME GetTime; \r
253 EMU_SET_TIME SetTime;\r
254 EMU_SET_TIMER SetTimer; \r
255 \r
256 ///\r
257 /// Generic System Services\r
258 ///\r
259 EMU_GET_NEXT_PROTOCOL GetNextProtocol;\r
260};\r
261\r
262extern EFI_GUID gEmuThunkProtocolGuid;\r
263\r
264#endif\r