]> git.proxmox.com Git - mirror_edk2.git/blame - InOsEmuPkg/Unix/Sec/SecMain.h
Fix the issue when checking the value of KeyDescriptor->Modifier to see if it was...
[mirror_edk2.git] / InOsEmuPkg / Unix / Sec / SecMain.h
CommitLineData
949f388f 1/*++ @file\r
2\r
10d1be3e 3Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
949f388f 4Portions copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>\r
10d1be3e 5\r
6This program and the accompanying materials\r
7are licensed and made available under the terms and conditions of the BSD License\r
8which accompanies this distribution. The full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
949f388f 13\r
14**/\r
15\r
16#ifndef _SEC_MAIN_H__\r
17#define _SEC_MAIN_H__\r
18\r
19#include <PiPei.h>\r
20#include <Uefi.h>\r
21\r
22#include <Library/PeCoffLib.h>\r
23#include <Library/BaseLib.h>\r
24#include <Library/BaseMemoryLib.h>\r
25#include <Library/PrintLib.h>\r
26#include <Library/PcdLib.h>\r
27#include <Library/DebugLib.h>\r
28#include <Library/ReportStatusCodeLib.h>\r
29\r
30#include <Library/ThunkPpiList.h>\r
31#include <Library/ThunkProtocolList.h>\r
65e3f333 32#include <Library/PpiListLib.h>\r
33#include <Library/PeiServicesLib.h>\r
34#include <Library/PeCoffGetEntryPointLib.h>\r
949f388f 35\r
36#include <Ppi/EmuThunk.h>\r
37#include <Ppi/StatusCode.h>\r
949f388f 38\r
39#include <Protocol/SimplePointer.h>\r
40#include <Protocol/SimpleTextIn.h>\r
41#include <Protocol/SimpleTextInEx.h>\r
42#include <Protocol/UgaDraw.h>\r
43#include <Protocol/SimpleFileSystem.h>\r
44\r
45#include <Protocol/EmuThunk.h>\r
46#include <Protocol/EmuIoThunk.h>\r
47#include <Protocol/EmuGraphicsWindow.h>\r
10d1be3e 48#include <Protocol/EmuThread.h>\r
949f388f 49\r
50#include <Guid/FileInfo.h>\r
51#include <Guid/FileSystemInfo.h>\r
52#include <Guid/FileSystemVolumeLabelInfo.h>\r
53\r
54#include <stdio.h>\r
55#include <stdlib.h>\r
56\r
57#include <sys/types.h>\r
58#include <sys/stat.h>\r
59#include <sys/termios.h>\r
60#include <sys/time.h>\r
61\r
62#if __CYGWIN__\r
63#include <sys/dirent.h>\r
64#else\r
65#include <sys/dir.h>\r
66#endif\r
67\r
68#include <sys/mman.h>\r
69#include <dlfcn.h>\r
70\r
71#include <unistd.h>\r
72#include <poll.h>\r
73#include <fcntl.h>\r
74#include <time.h>\r
75#include <signal.h>\r
76#include <errno.h>\r
77#include <string.h>\r
78#include <stdlib.h>\r
79#include <sys/ioctl.h>\r
80\r
81#include <sys/socket.h>\r
82#include <netdb.h>\r
83#include <netinet/in.h>\r
84#include <net/if.h>\r
85#include <ifaddrs.h>\r
86\r
87#ifdef __APPLE__\r
88#include <net/if_dl.h>\r
89#include <net/bpf.h>\r
90#include <sys/param.h>\r
91#include <sys/mount.h>\r
92#define _XOPEN_SOURCE\r
93#ifndef _Bool\r
94 #define _Bool char // for clang debug\r
95#endif\r
96#else\r
97#include <termio.h>\r
98#include <sys/vfs.h>\r
99#endif \r
100\r
101#include <utime.h>\r
102\r
103#include "Gasket.h"\r
104\r
105\r
106#define STACK_SIZE 0x20000 \r
107\r
108typedef struct {\r
109 EFI_PHYSICAL_ADDRESS Address;\r
110 UINT64 Size;\r
111} EMU_FD_INFO;\r
112\r
113typedef struct {\r
114 EFI_PHYSICAL_ADDRESS Memory;\r
115 UINT64 Size;\r
116} EMU_SYSTEM_MEMORY;\r
117\r
118\r
119#define MAX_IMAGE_CONTEXT_TO_MOD_HANDLE_ARRAY_SIZE 0x100\r
120\r
121typedef struct {\r
122 PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext;\r
123 VOID *ModHandle;\r
124} IMAGE_CONTEXT_TO_MOD_HANDLE;\r
125\r
126\r
127EFI_STATUS\r
128EFIAPI\r
129SecUnixPeiLoadFile (\r
130 VOID *Pe32Data, \r
131 EFI_PHYSICAL_ADDRESS *ImageAddress, \r
132 UINT64 *ImageSize, \r
133 EFI_PHYSICAL_ADDRESS *EntryPoint \r
134 );\r
135\r
136int\r
137main (\r
138 IN int Argc,\r
139 IN char **Argv,\r
140 IN char **Envp\r
141 );\r
142\r
143VOID\r
144SecLoadFromCore (\r
145 IN UINTN LargestRegion,\r
146 IN UINTN LargestRegionSize,\r
147 IN UINTN BootFirmwareVolumeBase,\r
148 IN VOID *PeiCoreFile\r
149 );\r
150\r
151EFI_STATUS\r
152SecLoadFile (\r
153 IN VOID *Pe32Data,\r
154 IN EFI_PHYSICAL_ADDRESS *ImageAddress,\r
155 IN UINT64 *ImageSize,\r
156 IN EFI_PHYSICAL_ADDRESS *EntryPoint\r
157 );\r
158\r
159EFI_STATUS\r
160SecFfsFindPeiCore (\r
161 IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader,\r
162 OUT VOID **Pe32Data\r
163 );\r
164\r
165EFI_STATUS\r
166SecFfsFindNextFile (\r
167 IN EFI_FV_FILETYPE SearchType,\r
168 IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader,\r
169 IN OUT EFI_FFS_FILE_HEADER **FileHeader\r
170 );\r
171\r
172EFI_STATUS\r
173SecFfsFindSectionData (\r
174 IN EFI_SECTION_TYPE SectionType,\r
175 IN EFI_FFS_FILE_HEADER *FfsFileHeader,\r
176 IN OUT VOID **SectionData\r
177 );\r
178\r
179EFI_STATUS\r
180EFIAPI\r
181SecUnixPeCoffLoaderLoadAsDll (\r
182 IN CHAR8 *PdbFileName,\r
183 IN VOID **ImageEntryPoint,\r
184 OUT VOID **ModHandle\r
185 );\r
186\r
187EFI_STATUS\r
188EFIAPI\r
189SecUnixPeCoffLoaderFreeLibrary (\r
190 OUT VOID *ModHandle\r
191 );\r
192\r
193EFI_STATUS\r
194EFIAPI\r
195SecUnixFdAddress (\r
196 IN UINTN Index,\r
197 IN OUT EFI_PHYSICAL_ADDRESS *FdBase,\r
198 IN OUT UINT64 *FdSize,\r
199 IN OUT EFI_PHYSICAL_ADDRESS *FixUp\r
200 )\r
201;\r
202\r
203EFI_STATUS\r
204EFIAPI\r
205GasketSecUnixFdAddress (\r
206 IN UINTN Index,\r
207 IN OUT EFI_PHYSICAL_ADDRESS *FdBase,\r
208 IN OUT UINT64 *FdSize,\r
209 IN OUT EFI_PHYSICAL_ADDRESS *FixUp\r
210 )\r
211;\r
212\r
213\r
214EFI_STATUS\r
215GetImageReadFunction (\r
216 IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,\r
217 IN EFI_PHYSICAL_ADDRESS *TopOfMemory\r
218 );\r
219\r
220EFI_STATUS\r
221EFIAPI\r
222SecImageRead (\r
223 IN VOID *FileHandle,\r
224 IN UINTN FileOffset,\r
225 IN OUT UINTN *ReadSize,\r
226 OUT VOID *Buffer\r
227 );\r
228\r
229CHAR16 *\r
230AsciiToUnicode (\r
231 IN CHAR8 *Ascii,\r
232 IN UINTN *StrLen OPTIONAL\r
233 );\r
234\r
235UINTN\r
236CountSeperatorsInString (\r
237 IN const CHAR16 *String,\r
238 IN CHAR16 Seperator\r
239 );\r
240\r
241EFI_STATUS\r
242EFIAPI\r
243SecTemporaryRamSupport (\r
244 IN CONST EFI_PEI_SERVICES **PeiServices,\r
245 IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase,\r
246 IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase,\r
247 IN UINTN CopySize\r
248 );\r
249 \r
250EFI_STATUS\r
251EFIAPI\r
252GasketSecTemporaryRamSupport (\r
253 IN CONST EFI_PEI_SERVICES **PeiServices,\r
254 IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase,\r
255 IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase,\r
256 IN UINTN CopySize\r
257 );\r
258\r
259\r
260RETURN_STATUS\r
261EFIAPI\r
262SecPeCoffGetEntryPoint (\r
263 IN VOID *Pe32Data,\r
264 IN OUT VOID **EntryPoint\r
265 );\r
266\r
267VOID\r
268EFIAPI\r
269SecPeCoffRelocateImageExtraAction (\r
270 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
271 );\r
272\r
273VOID\r
274EFIAPI\r
275SecPeCoffLoaderUnloadImageExtraAction (\r
276 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
277 );\r
278\r
279\r
280VOID\r
281EFIAPI\r
282PeiSwitchStacks (\r
283 IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r
284 IN VOID *Context1, OPTIONAL\r
285 IN VOID *Context2, OPTIONAL\r
949f388f 286 IN VOID *NewStack\r
287 );\r
288\r
289VOID\r
290SecInitThunkProtocol (\r
291 VOID\r
292 );\r
65e3f333 293 \r
949f388f 294 \r
65e3f333 295EFI_PHYSICAL_ADDRESS *\r
296MapMemory (\r
297 INTN fd,\r
298 UINT64 length,\r
299 INTN prot,\r
300 INTN flags);\r
301\r
302EFI_STATUS\r
303MapFile (\r
304 IN CHAR8 *FileName,\r
305 IN OUT EFI_PHYSICAL_ADDRESS *BaseAddress,\r
306 OUT UINT64 *Length\r
307 );\r
308\r
309 \r
949f388f 310\r
311VOID SecSleep (UINT64 Milliseconds);\r
312VOID SecEnableInterrupt (VOID);\r
313VOID SecDisableInterrupt (VOID);\r
314BOOLEAN SecInterruptEanbled (VOID);\r
315\r
316\r
317extern EMU_THUNK_PROTOCOL gEmuThunkProtocol;\r
318extern EMU_IO_THUNK_PROTOCOL gX11ThunkIo;\r
319extern EMU_IO_THUNK_PROTOCOL gPosixFileSystemThunkIo;\r
320extern EMU_IO_THUNK_PROTOCOL gPthreadThunkIo;\r
321\r
322\r
323#endif\r