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