]>
Commit | Line | Data |
---|---|---|
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 | |
20 | { 0x5CF32E0B, 0x8EDF, 0x2E44, { 0x9C, 0xDA, 0x93, 0x20, 0x5E, 0x99, 0xEC, 0x1C } }\r | |
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 | |
31 | typedef struct {\r | |
32 | VENDOR_DEVICE_PATH VendorDevicePath;\r | |
33 | UINT32 Instance;\r | |
34 | } EMU_VENDOR_DEVICE_PATH_NODE;\r | |
35 | \r | |
36 | typedef 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 | |
43 | typedef struct _EMU_THUNK_PROTOCOL EMU_THUNK_PROTOCOL;\r | |
44 | \r | |
45 | \r | |
46 | \r | |
47 | typedef\r | |
48 | UINTN\r | |
49 | (EFIAPI *EMU_WRITE_STD_ERROR) (\r | |
50 | IN UINT8 *Buffer,\r | |
51 | IN UINTN NumberOfBytes\r | |
52 | );\r | |
53 | \r | |
54 | typedef\r | |
55 | EFI_STATUS\r | |
56 | (EFIAPI *EMU_CONFIG_STD_IN) (\r | |
57 | VOID\r | |
58 | );\r | |
59 | \r | |
60 | typedef\r | |
61 | UINTN\r | |
62 | (EFIAPI *EMU_WRITE_STD_OUT) (\r | |
63 | IN UINT8 *Buffer,\r | |
64 | IN UINTN NumberOfBytes\r | |
65 | );\r | |
66 | \r | |
67 | typedef\r | |
68 | UINTN\r | |
69 | (EFIAPI *EMU_READ_STD_IN) (\r | |
70 | OUT UINT8 *Buffer,\r | |
71 | IN UINTN NumberOfBytes\r | |
72 | );\r | |
73 | \r | |
74 | typedef\r | |
75 | BOOLEAN\r | |
76 | (EFIAPI *EMU_POLL_STD_IN) (\r | |
77 | VOID\r | |
78 | );\r | |
79 | \r | |
80 | \r | |
81 | typedef\r | |
82 | VOID *\r | |
83 | (EFIAPI *EMU_OS_MALLOC) (\r | |
84 | IN UINTN Size\r | |
85 | );\r | |
86 | \r | |
87 | typedef\r | |
88 | VOID *\r | |
89 | (EFIAPI *EMU_OS_VMALLOC) (\r | |
90 | IN UINTN Size\r | |
91 | );\r | |
92 | \r | |
93 | typedef\r | |
94 | BOOLEAN\r | |
95 | (EFIAPI *EMU_OS_FREE) (\r | |
96 | IN VOID *Ptr\r | |
97 | );\r | |
98 | \r | |
99 | \r | |
100 | typedef\r | |
101 | EFI_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 | |
107 | typedef\r | |
108 | VOID\r | |
109 | (EFIAPI *EMU_PE_COFF_RELOCATE_EXTRA_ACTION) (\r | |
110 | IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r | |
111 | );\r | |
112 | \r | |
113 | typedef\r | |
114 | VOID\r | |
115 | (EFIAPI *EMU_PE_COFF_UNLOAD_EXTRA_ACTION) (\r | |
116 | IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r | |
117 | );\r | |
118 | \r | |
119 | typedef\r | |
120 | VOID\r | |
121 | (EFIAPI *EMU_ENABLE_INERRUPTS) (\r | |
122 | VOID\r | |
123 | );\r | |
124 | \r | |
125 | typedef\r | |
126 | VOID\r | |
127 | (EFIAPI *EMU_DISABLE_INERRUPTS) (\r | |
128 | VOID\r | |
129 | );\r | |
130 | \r | |
131 | typedef\r | |
132 | UINT64\r | |
133 | (EFIAPI *EMU_QUERY_PERFORMANCE_FREQENCY) (\r | |
134 | VOID\r | |
135 | );\r | |
136 | \r | |
137 | typedef\r | |
138 | UINT64\r | |
139 | (EFIAPI *EMU_QUERY_PERFORMANCE_COUNTER) (\r | |
140 | VOID\r | |
141 | );\r | |
142 | \r | |
143 | typedef\r | |
144 | VOID\r | |
145 | (EFIAPI *EMU_SLEEP) (\r | |
146 | IN UINT64 Milliseconds\r | |
147 | );\r | |
148 | \r | |
149 | typedef\r | |
150 | VOID\r | |
151 | (EFIAPI *EMU_CPU_SLEEP) (\r | |
152 | VOID\r | |
153 | );\r | |
154 | \r | |
155 | typedef\r | |
156 | VOID\r | |
157 | (EFIAPI *EMU_EXIT) (\r | |
158 | IN UINTN Status\r | |
159 | );\r | |
160 | \r | |
161 | typedef\r | |
162 | VOID\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 | |
168 | typedef\r | |
169 | VOID\r | |
170 | (EFIAPI *EMU_SET_TIME) (\r | |
171 | IN EFI_TIME *Time\r | |
172 | );\r | |
173 | \r | |
174 | \r | |
175 | typedef\r | |
176 | VOID\r | |
177 | (EFIAPI EMU_SET_TIMER_CALLBACK) (\r | |
178 | IN UINT64 DeltaMs\r | |
179 | );\r | |
180 | \r | |
181 | typedef\r | |
182 | VOID\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 | |
210 | typedef\r | |
211 | EFI_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 | |
218 | struct _EMU_THUNK_PROTOCOL {\r | |
219 | // Used for early debug printing\r | |
220 | EMU_WRITE_STD_ERROR WriteStdErr;\r | |
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 | |
225 | \r | |
226 | //\r | |
227 | // Map OS malloc/free so we can use OS based guard malloc\r | |
228 | //\r | |
229 | EMU_OS_MALLOC Malloc;\r | |
230 | EMU_OS_VMALLOC Valloc;\r | |
231 | EMU_OS_FREE Free;\r | |
232 | \r | |
233 | \r | |
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 | |
250 | EMU_CPU_SLEEP CpuSleep;\r | |
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 | |
262 | extern EFI_GUID gEmuThunkProtocolGuid;\r | |
263 | \r | |
264 | #endif\r |