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