]> git.proxmox.com Git - mirror_edk2.git/blob - InOsEmuPkg/Include/Protocol/EmuThunk.h
411cd3e625865f64fc137f8143d49748db6cf8d5
[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 { 0xA37D7CCD, 0x8E91, 0xFB48, { 0xA0, 0xBD, 0x64, 0xC1, 0x83, 0xA3, 0xB4, 0x3F } }
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 EFI_STATUS
49 (EFIAPI *EMU_WRITE_STD_ERROR) (
50 IN UINT8 *Buffer,
51 IN UINTN NumberOfBytes
52 );
53
54 typedef
55 EFI_STATUS
56 (EFIAPI *EMU_PE_COFF_GET_ENTRY_POINT) (
57 IN VOID *Pe32Data,
58 IN OUT VOID **EntryPoint
59 );
60
61 typedef
62 VOID
63 (EFIAPI *EMU_PE_COFF_RELOCATE_EXTRA_ACTION) (
64 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
65 );
66
67 typedef
68 VOID
69 (EFIAPI *EMU_PE_COFF_UNLOAD_EXTRA_ACTION) (
70 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
71 );
72
73 typedef
74 VOID
75 (EFIAPI *EMU_ENABLE_INERRUPTS) (
76 VOID
77 );
78
79 typedef
80 VOID
81 (EFIAPI *EMU_DISABLE_INERRUPTS) (
82 VOID
83 );
84
85 typedef
86 UINT64
87 (EFIAPI *EMU_QUERY_PERFORMANCE_FREQENCY) (
88 VOID
89 );
90
91 typedef
92 UINT64
93 (EFIAPI *EMU_QUERY_PERFORMANCE_COUNTER) (
94 VOID
95 );
96
97 typedef
98 VOID
99 (EFIAPI *EMU_SLEEP) (
100 IN UINT64 Milliseconds
101 );
102
103 typedef
104 VOID
105 (EFIAPI *EMU_EXIT) (
106 IN UINTN Status
107 );
108
109 typedef
110 VOID
111 (EFIAPI *EMU_GET_TIME) (
112 OUT EFI_TIME *Time,
113 OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL
114 );
115
116 typedef
117 VOID
118 (EFIAPI *EMU_SET_TIME) (
119 IN EFI_TIME *Time
120 );
121
122
123 typedef
124 VOID
125 (EFIAPI EMU_SET_TIMER_CALLBACK) (
126 IN UINT64 DeltaMs
127 );
128
129 typedef
130 VOID
131 (EFIAPI *EMU_SET_TIMER) (
132 IN UINT64 PeriodMs,
133 IN EMU_SET_TIMER_CALLBACK CallBack
134 );
135
136
137
138 /**
139 Enumerates the current set of protocol instances that abstract OS services from EFI.
140
141 A given protocol can have multiple instances. Usually a protocol is configured via a
142 single PCD string. The data associated for each instance is seperated via a ! in the string.
143 EMU_IO_THUNK_PROTOCOL_CLOSE.ConfigString will contain the information in the PCD string up to the next !.
144 Thus each instance has a unique ConfigString.
145
146 @param EmuBusDriver TRUE means only return protocol instances that need to be produced
147 by the EmuBusDriver. FALSE means return all possible protocols
148 @param Instance On input the protocol to search for, or NULL to start a search
149 of all the supported protocol instances.
150 @param NextProtocol On output it represents the next value to be passed into Protocol.
151 @param Interface A pointer to the EMU_IO_THUNK_PROTOCOL_CLOSE interface.
152
153 @retval EFI_SUCCESS The function completed successfully.
154 @retval EFI_NOT_FOUND The next protocol instance was not found.
155 @retval EFI_INVALID_PARAMETER Instance is NULL.
156
157 **/
158 typedef
159 EFI_STATUS
160 (EFIAPI *EMU_GET_NEXT_PROTOCOL) (
161 IN BOOLEAN EmuBusDriver,
162 OUT EMU_IO_THUNK_PROTOCOL **Instance OPTIONAL
163 );
164
165
166 struct _EMU_THUNK_PROTOCOL {
167 // Used for early debug printing
168 EMU_WRITE_STD_ERROR WriteStdErr;
169
170 ///
171 /// PE/COFF loader hooks to get symbols loaded
172 ///
173 EMU_PE_COFF_GET_ENTRY_POINT PeCoffGetEntryPoint;
174 EMU_PE_COFF_RELOCATE_EXTRA_ACTION PeCoffRelocateImageExtraAction;
175 EMU_PE_COFF_UNLOAD_EXTRA_ACTION PeCoffUnloadImageExtraAction;
176
177 ///
178 /// DXE Architecture Protocol Services
179 ///
180 EMU_ENABLE_INERRUPTS EnableInterrupt;
181 EMU_DISABLE_INERRUPTS DisableInterrupt;
182 EMU_QUERY_PERFORMANCE_FREQENCY QueryPerformanceFrequency;
183 EMU_QUERY_PERFORMANCE_COUNTER QueryPerformanceCounter;
184
185 EMU_SLEEP Sleep;
186 EMU_EXIT Exit;
187 EMU_GET_TIME GetTime;
188 EMU_SET_TIME SetTime;
189 EMU_SET_TIMER SetTimer;
190
191 ///
192 /// Generic System Services
193 ///
194 EMU_GET_NEXT_PROTOCOL GetNextProtocol;
195 };
196
197 extern EFI_GUID gEmuThunkProtocolGuid;
198
199 #endif