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