]> git.proxmox.com Git - mirror_edk2.git/blob - UnixPkg/Sec/SecMain.h
Added support for Xcode on Snow Leopard. Upaded with bug fixes for Snow Leopard.
[mirror_edk2.git] / UnixPkg / Sec / SecMain.h
1 /*++
2
3 Copyright (c) 2006 - 2009, Intel Corporation
4 Portions copyright (c) 2008-2009 Apple Inc.
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13
14 Module Name:
15 SecMain.h
16
17 Abstract:
18 Include file for host API based SEC
19
20 --*/
21 #include <FrameworkPei.h>
22
23 #include <Protocol/UnixThunk.h>
24 #include <Ppi/StatusCode.h>
25
26 #include <Library/PeCoffLib.h>
27 #include <Library/BaseLib.h>
28 #include <Library/BaseMemoryLib.h>
29 #include <Library/PrintLib.h>
30 #include <Library/PcdLib.h>
31 #include <Library/DebugLib.h>
32 #include <Library/ReportStatusCodeLib.h>
33
34 #define STACK_SIZE 0x20000
35
36 typedef struct {
37 EFI_PHYSICAL_ADDRESS Address;
38 UINT64 Size;
39 } UNIX_FD_INFO;
40
41 typedef struct {
42 EFI_PHYSICAL_ADDRESS Memory;
43 UINT64 Size;
44 } UNIX_SYSTEM_MEMORY;
45
46
47 #define MAX_IMAGE_CONTEXT_TO_MOD_HANDLE_ARRAY_SIZE 0x100
48
49 typedef struct {
50 PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext;
51 VOID *ModHandle;
52 } IMAGE_CONTEXT_TO_MOD_HANDLE;
53
54
55 EFI_STATUS
56 EFIAPI
57 SecUnixPeiLoadFile (
58 VOID *Pe32Data, // TODO: add IN/OUT modifier to Pe32Data
59 EFI_PHYSICAL_ADDRESS *ImageAddress, // TODO: add IN/OUT modifier to ImageAddress
60 UINT64 *ImageSize, // TODO: add IN/OUT modifier to ImageSize
61 EFI_PHYSICAL_ADDRESS *EntryPoint // TODO: add IN/OUT modifier to EntryPoint
62 )
63 /*++
64
65 Routine Description:
66
67 TODO: Add function description
68
69 Arguments:
70
71 Pe32Data - TODO: add argument description
72 ImageAddress - TODO: add argument description
73 ImageSize - TODO: add argument description
74 EntryPoint - TODO: add argument description
75
76 Returns:
77
78 TODO: add return values
79
80 --*/
81 ;
82
83 EFI_STATUS
84 EFIAPI
85 SecUnixPeiAutoScan (
86 IN UINTN Index,
87 OUT EFI_PHYSICAL_ADDRESS *MemoryBase,
88 OUT UINT64 *MemorySize
89 )
90 /*++
91
92 Routine Description:
93
94 TODO: Add function description
95
96 Arguments:
97
98 Index - TODO: add argument description
99 MemoryBase - TODO: add argument description
100 MemorySize - TODO: add argument description
101
102 Returns:
103
104 TODO: add return values
105
106 --*/
107 ;
108
109 VOID *
110 EFIAPI
111 SecUnixUnixThunkAddress (
112 VOID
113 )
114 /*++
115
116 Routine Description:
117
118 TODO: Add function description
119
120 Arguments:
121
122 InterfaceSize - TODO: add argument description
123 InterfaceBase - TODO: add argument description
124
125 Returns:
126
127 TODO: add return values
128
129 --*/
130 ;
131
132 EFI_STATUS
133 EFIAPI
134 SecUnixUnixFwhAddress (
135 IN OUT UINT64 *FwhSize,
136 IN OUT EFI_PHYSICAL_ADDRESS *FwhBase
137 )
138 /*++
139
140 Routine Description:
141
142 TODO: Add function description
143
144 Arguments:
145
146 FwhSize - TODO: add argument description
147 FwhBase - TODO: add argument description
148
149 Returns:
150
151 TODO: add return values
152
153 --*/
154 ;
155
156 EFI_STATUS
157 EFIAPI
158 SecPeiReportStatusCode (
159 IN CONST EFI_PEI_SERVICES **PeiServices,
160 IN EFI_STATUS_CODE_TYPE CodeType,
161 IN EFI_STATUS_CODE_VALUE Value,
162 IN UINT32 Instance,
163 IN CONST EFI_GUID *CallerId,
164 IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL
165 )
166 /*++
167
168 Routine Description:
169
170 TODO: Add function description
171
172 Arguments:
173
174 PeiServices - TODO: add argument description
175 CodeType - TODO: add argument description
176 Value - TODO: add argument description
177 Instance - TODO: add argument description
178 CallerId - TODO: add argument description
179 Data - TODO: add argument description
180
181 Returns:
182
183 TODO: add return values
184
185 --*/
186 ;
187
188 int
189 main (
190 IN int Argc,
191 IN char **Argv,
192 IN char **Envp
193 )
194 /*++
195
196 Routine Description:
197
198 TODO: Add function description
199
200 Arguments:
201
202 Argc - TODO: add argument description
203 Argv - TODO: add argument description
204 Envp - TODO: add argument description
205
206 Returns:
207
208 TODO: add return values
209
210 --*/
211 ;
212
213 VOID
214 SecLoadFromCore (
215 IN UINTN LargestRegion,
216 IN UINTN LargestRegionSize,
217 IN UINTN BootFirmwareVolumeBase,
218 IN VOID *PeiCoreFile
219 )
220 /*++
221
222 Routine Description:
223
224 TODO: Add function description
225
226 Arguments:
227
228 LargestRegion - TODO: add argument description
229 LargestRegionSize - TODO: add argument description
230 BootFirmwareVolumeBase - TODO: add argument description
231 PeiCoreFile - TODO: add argument description
232
233 Returns:
234
235 TODO: add return values
236
237 --*/
238 ;
239
240 EFI_STATUS
241 SecLoadFile (
242 IN VOID *Pe32Data,
243 IN EFI_PHYSICAL_ADDRESS *ImageAddress,
244 IN UINT64 *ImageSize,
245 IN EFI_PHYSICAL_ADDRESS *EntryPoint
246 )
247 /*++
248
249 Routine Description:
250
251 TODO: Add function description
252
253 Arguments:
254
255 Pe32Data - TODO: add argument description
256 ImageAddress - TODO: add argument description
257 ImageSize - TODO: add argument description
258 EntryPoint - TODO: add argument description
259
260 Returns:
261
262 TODO: add return values
263
264 --*/
265 ;
266
267 EFI_STATUS
268 SecFfsFindPeiCore (
269 IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader,
270 OUT VOID **Pe32Data
271 )
272 /*++
273
274 Routine Description:
275
276 TODO: Add function description
277
278 Arguments:
279
280 FwVolHeader - TODO: add argument description
281 Pe32Data - TODO: add argument description
282
283 Returns:
284
285 TODO: add return values
286
287 --*/
288 ;
289
290 EFI_STATUS
291 SecFfsFindNextFile (
292 IN EFI_FV_FILETYPE SearchType,
293 IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader,
294 IN OUT EFI_FFS_FILE_HEADER **FileHeader
295 )
296 /*++
297
298 Routine Description:
299
300 TODO: Add function description
301
302 Arguments:
303
304 SearchType - TODO: add argument description
305 FwVolHeader - TODO: add argument description
306 FileHeader - TODO: add argument description
307
308 Returns:
309
310 TODO: add return values
311
312 --*/
313 ;
314
315 EFI_STATUS
316 SecFfsFindSectionData (
317 IN EFI_SECTION_TYPE SectionType,
318 IN EFI_FFS_FILE_HEADER *FfsFileHeader,
319 IN OUT VOID **SectionData
320 )
321 /*++
322
323 Routine Description:
324
325 TODO: Add function description
326
327 Arguments:
328
329 SectionType - TODO: add argument description
330 FfsFileHeader - TODO: add argument description
331 SectionData - TODO: add argument description
332
333 Returns:
334
335 TODO: add return values
336
337 --*/
338 ;
339
340 EFI_STATUS
341 EFIAPI
342 SecUnixPeCoffLoaderLoadAsDll (
343 IN CHAR8 *PdbFileName,
344 IN VOID **ImageEntryPoint,
345 OUT VOID **ModHandle
346 )
347 /*++
348
349 Routine Description:
350
351 TODO: Add function description
352
353 Arguments:
354
355 PdbFileName - TODO: add argument description
356 ImageEntryPoint - TODO: add argument description
357 ModHandle - TODO: add argument description
358
359 Returns:
360
361 TODO: add return values
362
363 --*/
364 ;
365
366 EFI_STATUS
367 EFIAPI
368 SecUnixPeCoffLoaderFreeLibrary (
369 OUT VOID *ModHandle
370 )
371 /*++
372
373 Routine Description:
374
375 TODO: Add function description
376
377 Arguments:
378
379 ModHandle - TODO: add argument description
380
381 Returns:
382
383 TODO: add return values
384
385 --*/
386 ;
387
388 EFI_STATUS
389 EFIAPI
390 SecUnixFdAddress (
391 IN UINTN Index,
392 IN OUT EFI_PHYSICAL_ADDRESS *FdBase,
393 IN OUT UINT64 *FdSize,
394 IN OUT EFI_PHYSICAL_ADDRESS *FixUp
395 )
396 ;
397
398 EFI_STATUS
399 GetImageReadFunction (
400 IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
401 IN EFI_PHYSICAL_ADDRESS *TopOfMemory
402 )
403 /*++
404
405 Routine Description:
406
407 TODO: Add function description
408
409 Arguments:
410
411 ImageContext - TODO: add argument description
412 TopOfMemory - TODO: add argument description
413
414 Returns:
415
416 TODO: add return values
417
418 --*/
419 ;
420
421 EFI_STATUS
422 EFIAPI
423 SecImageRead (
424 IN VOID *FileHandle,
425 IN UINTN FileOffset,
426 IN OUT UINTN *ReadSize,
427 OUT VOID *Buffer
428 )
429 /*++
430
431 Routine Description:
432
433 TODO: Add function description
434
435 Arguments:
436
437 FileHandle - TODO: add argument description
438 FileOffset - TODO: add argument description
439 ReadSize - TODO: add argument description
440 Buffer - TODO: add argument description
441
442 Returns:
443
444 TODO: add return values
445
446 --*/
447 ;
448
449 CHAR16 *
450 AsciiToUnicode (
451 IN CHAR8 *Ascii,
452 IN UINTN *StrLen OPTIONAL
453 )
454 /*++
455
456 Routine Description:
457
458 TODO: Add function description
459
460 Arguments:
461
462 Ascii - TODO: add argument description
463 StrLen - TODO: add argument description
464
465 Returns:
466
467 TODO: add return values
468
469 --*/
470 ;
471
472 UINTN
473 CountSeperatorsInString (
474 IN const CHAR16 *String,
475 IN CHAR16 Seperator
476 )
477 /*++
478
479 Routine Description:
480
481 TODO: Add function description
482
483 Arguments:
484
485 String - TODO: add argument description
486 Seperator - TODO: add argument description
487
488 Returns:
489
490 TODO: add return values
491
492 --*/
493 ;
494
495 EFI_STATUS
496 EFIAPI
497 SecTemporaryRamSupport (
498 IN CONST EFI_PEI_SERVICES **PeiServices,
499 IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase,
500 IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase,
501 IN UINTN CopySize
502 );
503
504
505 RETURN_STATUS
506 EFIAPI
507 SecPeCoffGetEntryPoint (
508 IN VOID *Pe32Data,
509 IN OUT VOID **EntryPoint
510 );
511
512 VOID
513 EFIAPI
514 SecPeCoffRelocateImageExtraAction (
515 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
516 );
517
518 VOID
519 EFIAPI
520 SecPeCoffLoaderUnloadImageExtraAction (
521 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
522 );
523
524
525
526 VOID SetTimer (UINT64 PeriodMs, VOID (*CallBack)(UINT64 DeltaMs));
527 void msSleep (unsigned long Milliseconds);
528 void GetLocalTime (EFI_TIME *Time);
529 void TzSet (void);
530 long GetTimeZone(void);
531 int GetDayLight(void);
532 int GetErrno(void);
533
534
535
536 extern EFI_UNIX_THUNK_PROTOCOL *gUnix;