]>
Commit | Line | Data |
---|---|---|
3eb9473e | 1 | /*++\r |
2 | \r | |
3 | Copyright (c) 2004 - 2007, Intel Corporation \r | |
4 | All rights reserved. This program and the accompanying materials \r | |
5 | are licensed and made available under the terms and conditions of the BSD License \r | |
6 | which accompanies this distribution. The full text of the license may be found at \r | |
7 | http://opensource.org/licenses/bsd-license.php \r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | PeiLib.h\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | PEI Library Functions\r | |
19 | \r | |
20 | --*/\r | |
21 | \r | |
22 | #ifndef _PEI_LIB_H_\r | |
23 | #define _PEI_LIB_H_\r | |
24 | \r | |
25 | #include "Tiano.h"\r | |
26 | #include "Pei.h"\r | |
0dbeedde | 27 | #include "PeiHobLib.h"\r |
c7f33ca4 | 28 | #include "PeiPerf.h"\r |
3eb9473e | 29 | #include EFI_PROTOCOL_DEFINITION (Decompress)\r |
30 | #include EFI_PROTOCOL_DEFINITION (TianoDecompress)\r | |
31 | #include EFI_GUID_DEFINITION (PeiPeCoffLoader)\r | |
32 | #include EFI_PPI_DEFINITION (FindFv)\r | |
33 | \r | |
34 | \r | |
35 | #if (PI_SPECIFICATION_VERSION >= 0x00010000)\r | |
36 | \r | |
37 | typedef struct {\r | |
38 | UINT32 PeiServiceTable;\r | |
39 | } PEI_IDT_TABLE;\r | |
40 | \r | |
41 | \r | |
42 | VOID *\r | |
43 | EFIAPI\r | |
44 | ScanGuid (\r | |
45 | IN VOID *Buffer,\r | |
46 | IN UINTN Length,\r | |
47 | IN EFI_GUID *Guid\r | |
48 | )\r | |
49 | /*++\r | |
50 | \r | |
51 | Routine Description:\r | |
52 | \r | |
53 | Scans a target buffer for a GUID, and returns a pointer to the matching GUID\r | |
54 | in the target buffer.\r | |
55 | \r | |
56 | This function searches target the buffer specified by Buffer and Length from\r | |
57 | the lowest address to the highest address at 128-bit increments for the 128-bit\r | |
58 | GUID value that matches Guid. If a match is found, then a pointer to the matching\r | |
59 | GUID in the target buffer is returned. If no match is found, then NULL is returned.\r | |
60 | If Length is 0, then NULL is returned.\r | |
61 | If Length > 0 and Buffer is NULL, then ASSERT().\r | |
62 | If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r | |
63 | If Length is not aligned on a 128-bit boundary, then ASSERT().\r | |
64 | If Length is greater than (EFI_MAX_ADDRESS ?Buffer + 1), then ASSERT(). \r | |
65 | \r | |
66 | Arguments:\r | |
67 | \r | |
68 | Buffer - Pointer to the target buffer to scan.\r | |
69 | Length - Number of bytes in Buffer to scan.\r | |
70 | Guid - Value to search for in the target buffer.\r | |
71 | \r | |
72 | Returns:\r | |
73 | A pointer to the matching Guid in the target buffer or NULL otherwise.\r | |
74 | \r | |
75 | --*/\r | |
76 | ;\r | |
77 | \r | |
78 | VOID *\r | |
79 | EFIAPI\r | |
80 | InvalidateInstructionCacheRange (\r | |
81 | IN VOID *Address,\r | |
82 | IN UINTN Length\r | |
83 | )\r | |
84 | /*++\r | |
85 | \r | |
86 | Routine Description:\r | |
87 | \r | |
88 | Invalidates a range of instruction cache lines in the cache coherency domain\r | |
89 | of the calling CPU.\r | |
90 | \r | |
91 | Invalidates the instruction cache lines specified by Address and Length. If\r | |
92 | Address is not aligned on a cache line boundary, then entire instruction\r | |
93 | cache line containing Address is invalidated. If Address + Length is not\r | |
94 | aligned on a cache line boundary, then the entire instruction cache line\r | |
95 | containing Address + Length -1 is invalidated. This function may choose to\r | |
96 | invalidate the entire instruction cache if that is more efficient than\r | |
97 | invalidating the specified range. If Length is 0, the no instruction cache\r | |
98 | lines are invalidated. Address is returned.\r | |
99 | \r | |
100 | If Length is greater than (EFI_MAX_ADDRESS - Address + 1), then ASSERT().\r | |
101 | \r | |
102 | Arguments:\r | |
103 | \r | |
104 | Address - The base address of the instruction cache lines to\r | |
105 | invalidate. If the CPU is in a physical addressing mode, then\r | |
106 | Address is a physical address. If the CPU is in a virtual\r | |
107 | addressing mode, then Address is a virtual address.\r | |
108 | \r | |
109 | Length - The number of bytes to invalidate from the instruction cache.\r | |
110 | \r | |
111 | Returns:\r | |
112 | Address\r | |
113 | \r | |
114 | **/\r | |
115 | ;\r | |
116 | \r | |
117 | EFI_STATUS\r | |
118 | EFIAPI\r | |
119 | PeiLibFfsFindNextVolume (\r | |
120 | IN UINTN Instance,\r | |
121 | IN OUT EFI_PEI_FV_HANDLE *VolumeHandle\r | |
122 | )\r | |
123 | /*++\r | |
124 | \r | |
125 | Routine Description:\r | |
126 | \r | |
127 | The wrapper of Pei Core Service function FfsFindNextVolume.\r | |
128 | \r | |
129 | Arguments:\r | |
130 | \r | |
131 | Instance - The Fv Volume Instance.\r | |
132 | VolumeHandle - Pointer to the current Fv Volume to search.\r | |
133 | \r | |
134 | Returns:\r | |
135 | EFI_STATUS\r | |
136 | \r | |
137 | --*/\r | |
138 | ;\r | |
139 | \r | |
140 | EFI_STATUS\r | |
141 | EFIAPI\r | |
142 | PeiLibFfsFindNextFile (\r | |
143 | IN EFI_FV_FILETYPE SearchType,\r | |
144 | IN EFI_PEI_FV_HANDLE FwVolHeader,\r | |
145 | IN OUT EFI_PEI_FILE_HANDLE *FileHeader\r | |
146 | )\r | |
147 | /*++\r | |
148 | \r | |
149 | Routine Description:\r | |
150 | \r | |
151 | The wrapper of Pei Core Service function FfsFindNextFile.\r | |
152 | \r | |
153 | Arguments:\r | |
154 | \r | |
155 | SearchType - Filter to find only file of this type.\r | |
156 | FwVolHeader - Pointer to the current FV to search.\r | |
157 | FileHandle - Pointer to the file matching SearchType in FwVolHeader.\r | |
158 | - NULL if file not found\r | |
159 | \r | |
160 | Returns:\r | |
161 | EFI_STATUS\r | |
162 | \r | |
163 | --*/ \r | |
164 | ;\r | |
165 | \r | |
166 | EFI_STATUS\r | |
167 | EFIAPI\r | |
168 | PeiLibFfsFindFileByName (\r | |
169 | IN EFI_GUID *FileName,\r | |
170 | IN EFI_PEI_FV_HANDLE VolumeHandle,\r | |
171 | OUT EFI_PEI_FILE_HANDLE *FileHandle\r | |
172 | )\r | |
173 | /*++\r | |
174 | \r | |
175 | Routine Description:\r | |
176 | \r | |
177 | The wrapper of Pei Core Service function FfsFindFileByName.\r | |
178 | \r | |
179 | Arguments:\r | |
180 | \r | |
181 | FileName - File name to search.\r | |
182 | VolumeHandle - The current FV to search.\r | |
183 | FileHandle - Pointer to the file matching name in VolumeHandle.\r | |
184 | - NULL if file not found\r | |
185 | \r | |
186 | Returns:\r | |
187 | EFI_STATUS\r | |
188 | \r | |
189 | --*/ \r | |
190 | ;\r | |
191 | \r | |
192 | EFI_STATUS\r | |
193 | EFIAPI\r | |
194 | PeiLibFfsFindSectionData (\r | |
195 | IN EFI_SECTION_TYPE SectionType,\r | |
196 | IN EFI_FFS_FILE_HEADER *FfsFileHeader,\r | |
197 | IN OUT VOID **SectionData\r | |
198 | )\r | |
199 | /*++\r | |
200 | \r | |
201 | Routine Description:\r | |
202 | \r | |
203 | The wrapper of Pei Core Service function FfsFindSectionData.\r | |
204 | \r | |
205 | Arguments:\r | |
206 | \r | |
207 | SearchType - Filter to find only sections of this type.\r | |
208 | FileHandle - Pointer to the current file to search.\r | |
209 | SectionData - Pointer to the Section matching SectionType in FfsFileHeader.\r | |
210 | - NULL if section not found\r | |
211 | \r | |
212 | Returns:\r | |
213 | EFI_STATUS\r | |
214 | --*/\r | |
215 | ;\r | |
216 | \r | |
217 | EFI_STATUS\r | |
218 | EFIAPI\r | |
219 | PeiLibFfsGetVolumeInfo (\r | |
220 | IN EFI_PEI_FV_HANDLE *VolumeHandle,\r | |
221 | OUT EFI_FV_INFO *VolumeInfo\r | |
222 | )\r | |
223 | /*++\r | |
224 | \r | |
225 | Routine Description:\r | |
226 | \r | |
227 | The wrapper of Pei Core Service function FfsGetVolumeInfo.\r | |
228 | \r | |
229 | Arguments:\r | |
230 | \r | |
231 | VolumeHandle - The handle to Fv Volume.\r | |
232 | VolumeInfo - The pointer to volume information.\r | |
233 | \r | |
234 | Returns:\r | |
235 | EFI_STATUS\r | |
236 | --*/ \r | |
237 | ;\r | |
238 | \r | |
239 | EFI_STATUS\r | |
240 | EFIAPI\r | |
241 | PeiServicesLocatePpi (\r | |
242 | IN EFI_GUID *Guid,\r | |
243 | IN UINTN Instance,\r | |
244 | IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,\r | |
245 | IN OUT VOID **Ppi\r | |
246 | )\r | |
247 | /*++\r | |
248 | \r | |
249 | Routine Description:\r | |
250 | \r | |
251 | The wrapper of Pei Core Service function LocatePpi.\r | |
252 | \r | |
253 | Arguments:\r | |
254 | \r | |
255 | Guid - Pointer to GUID of the PPI.\r | |
256 | Instance - Instance Number to discover.\r | |
257 | PpiDescriptor - Pointer to reference the found descriptor. If not NULL,\r | |
258 | returns a pointer to the descriptor (includes flags, etc)\r | |
259 | Ppi - Pointer to reference the found PPI\r | |
260 | \r | |
261 | Returns:\r | |
262 | \r | |
263 | Status - EFI_SUCCESS if the PPI is in the database \r | |
264 | EFI_NOT_FOUND if the PPI is not in the database\r | |
265 | --*/ \r | |
266 | ;\r | |
267 | \r | |
268 | VOID\r | |
269 | EFIAPI\r | |
270 | BuildFvHob (\r | |
271 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
272 | IN UINT64 Length\r | |
273 | )\r | |
274 | /*++\r | |
275 | \r | |
276 | Routine Description:\r | |
277 | \r | |
278 | Build FvHob.\r | |
279 | \r | |
280 | Arguments:\r | |
281 | \r | |
282 | BaseAddress - Fv base address.\r | |
283 | Length - Fv Length.\r | |
284 | \r | |
285 | Returns:\r | |
286 | NONE.\r | |
287 | \r | |
288 | --*/ \r | |
289 | ;\r | |
290 | \r | |
291 | VOID\r | |
292 | EFIAPI\r | |
293 | BuildFvHob2 (\r | |
294 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
295 | IN UINT64 Length,\r | |
296 | IN EFI_GUID *FvNameGuid,\r | |
297 | IN EFI_GUID *FileNameGuid\r | |
298 | )\r | |
299 | /*++\r | |
300 | \r | |
301 | Routine Description:\r | |
302 | \r | |
303 | Build FvHob2.\r | |
304 | \r | |
305 | Arguments:\r | |
306 | \r | |
307 | BaseAddress - Fv base address.\r | |
308 | Length - Fv length.\r | |
309 | FvNameGuid - Fv name.\r | |
310 | FileNameGuid - File name which contians encapsulated Fv.\r | |
311 | \r | |
312 | Returns:\r | |
313 | NONE.\r | |
314 | --*/ \r | |
315 | ;\r | |
316 | \r | |
317 | \r | |
318 | VOID \r | |
319 | EFIAPI\r | |
320 | BuildGuidDataHob (\r | |
321 | IN EFI_GUID *Guid,\r | |
322 | IN VOID *Data,\r | |
323 | IN UINTN DataLength\r | |
324 | )\r | |
325 | /*++\r | |
326 | \r | |
327 | Routine Description:\r | |
328 | \r | |
329 | Build Guid data Hob.\r | |
330 | \r | |
331 | Arguments:\r | |
332 | \r | |
333 | Guid - guid to build data hob.\r | |
334 | Data - data to build data hob.\r | |
335 | DataLength - the length of data.\r | |
336 | \r | |
337 | Returns:\r | |
338 | NONE\r | |
339 | \r | |
340 | --*/ \r | |
341 | ;\r | |
342 | \r | |
343 | VOID *\r | |
344 | EFIAPI\r | |
345 | AllocatePages (\r | |
346 | IN UINTN Pages\r | |
347 | )\r | |
348 | /*++\r | |
349 | \r | |
350 | Routine Description:\r | |
351 | \r | |
352 | Allocate Memory.\r | |
353 | \r | |
354 | Arguments:\r | |
355 | \r | |
356 | Pages - Pages to allocate.\r | |
357 | \r | |
358 | Returns:\r | |
359 | Address if successful to allocate memory. \r | |
360 | NULL if fail to allocate memory.\r | |
361 | \r | |
362 | --*/ \r | |
363 | ;\r | |
364 | \r | |
365 | VOID\r | |
366 | SetPeiServicesTablePointer (\r | |
367 | IN EFI_PEI_SERVICES **PeiServices\r | |
368 | )\r | |
369 | /*++\r | |
370 | \r | |
371 | Routine Description:\r | |
372 | \r | |
373 | Save PeiService pointer so that it can be retrieved anywhere.\r | |
374 | \r | |
375 | Arguments:\r | |
376 | \r | |
377 | PeiServices - The direct pointer to PeiServiceTable.\r | |
378 | \r | |
379 | Returns:\r | |
380 | NONE\r | |
381 | \r | |
382 | --*/ \r | |
383 | ;\r | |
384 | \r | |
385 | EFI_PEI_SERVICES **\r | |
386 | GetPeiServicesTablePointer (\r | |
387 | VOID \r | |
388 | )\r | |
389 | /*++\r | |
390 | \r | |
391 | Routine Description:\r | |
392 | \r | |
393 | Get PeiService pointer.\r | |
394 | \r | |
395 | Arguments:\r | |
396 | \r | |
397 | NONE.\r | |
398 | \r | |
399 | Returns:\r | |
400 | The direct pointer to PeiServiceTable.\r | |
401 | \r | |
402 | --*/ \r | |
403 | ;\r | |
404 | \r | |
405 | VOID\r | |
406 | MigrateIdtTable (\r | |
407 | IN EFI_PEI_SERVICES **PeiServices\r | |
408 | )\r | |
409 | /*++\r | |
410 | \r | |
411 | Routine Description:\r | |
412 | \r | |
413 | Migrate IDT from CAR to real memory where preceded with 4 bytes for\r | |
414 | storing PeiService pointer.\r | |
415 | \r | |
416 | Arguments:\r | |
417 | \r | |
418 | PeiServices - The direct pointer to PeiServiceTable.\r | |
419 | \r | |
420 | Returns:\r | |
421 | \r | |
422 | NONE.\r | |
423 | \r | |
424 | --*/ \r | |
425 | ;\r | |
426 | \r | |
427 | \r | |
428 | UINTN\r | |
429 | ReadIdtBase (\r | |
430 | VOID\r | |
431 | )\r | |
432 | /*++\r | |
433 | \r | |
434 | Routine Description:\r | |
435 | \r | |
436 | Read IDT Register BaseAddress.\r | |
437 | \r | |
438 | Arguments:\r | |
439 | \r | |
440 | NONE\r | |
441 | \r | |
442 | Returns:\r | |
443 | IDT Register BaseAddress.\r | |
444 | \r | |
445 | --*/ \r | |
446 | ;\r | |
447 | \r | |
448 | \r | |
449 | UINT16\r | |
450 | ReadIdtLimit (\r | |
451 | VOID\r | |
452 | )\r | |
453 | /*++\r | |
454 | \r | |
455 | Routine Description:\r | |
456 | \r | |
457 | Read IDT Register Limit.\r | |
458 | \r | |
459 | Arguments:\r | |
460 | \r | |
461 | NONE\r | |
462 | \r | |
463 | Returns:\r | |
464 | IDT Register Limit.\r | |
465 | \r | |
466 | --*/ \r | |
467 | ;\r | |
468 | \r | |
469 | \r | |
470 | VOID\r | |
471 | SetIdtBase (\r | |
472 | UINT32 IdtBase,\r | |
473 | UINT16 IdtLimit \r | |
474 | )\r | |
475 | /*++\r | |
476 | \r | |
477 | Routine Description:\r | |
478 | \r | |
479 | Set IDT Register BaseAddress.\r | |
480 | \r | |
481 | Arguments:\r | |
482 | \r | |
483 | IdtBase - IDT.BaseAddress\r | |
484 | IdtLimit - IDT.Limit\r | |
485 | \r | |
486 | Returns:\r | |
487 | NONE\r | |
488 | --*/ \r | |
489 | ;\r | |
490 | \r | |
491 | VOID\r | |
492 | AsmWriteKr7 (\r | |
493 | UINT64 Address\r | |
494 | )\r | |
495 | /*++\r | |
496 | \r | |
497 | Routine Description:\r | |
498 | \r | |
499 | Write 64 bit into Kernel Register7 on IPF.\r | |
500 | \r | |
501 | Arguments:\r | |
502 | \r | |
503 | Address - Data to write into kr7.\r | |
504 | \r | |
505 | Returns:\r | |
506 | NONE\r | |
507 | \r | |
508 | --*/ \r | |
509 | ;\r | |
510 | \r | |
511 | \r | |
512 | UINT64\r | |
513 | AsmReadKr7 (\r | |
514 | VOID\r | |
515 | )\r | |
516 | /*++\r | |
517 | \r | |
518 | Routine Description:\r | |
519 | \r | |
520 | Read 64 bit from Kernel Register7 on IPF.\r | |
521 | \r | |
522 | Arguments:\r | |
523 | \r | |
524 | NONE \r | |
525 | \r | |
526 | Returns:\r | |
527 | Data in kr7.\r | |
528 | \r | |
529 | --*/ \r | |
530 | ;\r | |
531 | \r | |
532 | #endif\r | |
533 | \r | |
534 | VOID\r | |
535 | PeiCopyMem (\r | |
536 | IN VOID *Destination,\r | |
537 | IN VOID *Source,\r | |
538 | IN UINTN Length\r | |
539 | )\r | |
540 | /*++\r | |
541 | \r | |
542 | Routine Description:\r | |
543 | \r | |
544 | Copy Length bytes from Source to Destination.\r | |
545 | \r | |
546 | Arguments:\r | |
547 | \r | |
548 | Destination - Target of copy\r | |
549 | \r | |
550 | Source - Place to copy from\r | |
551 | \r | |
552 | Length - Number of bytes to copy\r | |
553 | \r | |
554 | Returns:\r | |
555 | \r | |
556 | None\r | |
557 | \r | |
558 | --*/\r | |
559 | ;\r | |
560 | \r | |
561 | VOID\r | |
562 | ZeroMem (\r | |
563 | IN VOID *Buffer,\r | |
564 | IN UINTN Size\r | |
565 | )\r | |
566 | /*++\r | |
567 | \r | |
568 | Routine Description:\r | |
569 | \r | |
570 | Set Buffer to zero for Size bytes.\r | |
571 | \r | |
572 | Arguments:\r | |
573 | \r | |
574 | Buffer - Memory to set.\r | |
575 | \r | |
576 | Size - Number of bytes to set\r | |
577 | \r | |
578 | Returns:\r | |
579 | \r | |
580 | None\r | |
581 | \r | |
582 | --*/\r | |
583 | ;\r | |
584 | \r | |
585 | VOID\r | |
586 | CopyMem (\r | |
587 | IN VOID *Destination,\r | |
588 | IN VOID *Source,\r | |
589 | IN UINTN Length\r | |
590 | )\r | |
591 | /*++\r | |
592 | \r | |
593 | Routine Description:\r | |
594 | \r | |
595 | Copy Length bytes from Source to Destination.\r | |
596 | \r | |
597 | Arguments:\r | |
598 | \r | |
599 | Destination - Target of copy\r | |
600 | \r | |
601 | Source - Place to copy from\r | |
602 | \r | |
603 | Length - Number of bytes to copy\r | |
604 | \r | |
605 | Returns:\r | |
606 | \r | |
607 | None\r | |
608 | \r | |
609 | --*/\r | |
610 | ;\r | |
611 | \r | |
612 | BOOLEAN\r | |
613 | CompareGuid (\r | |
614 | IN EFI_GUID *Guid1,\r | |
615 | IN EFI_GUID *Guid2\r | |
616 | )\r | |
617 | /*++\r | |
618 | \r | |
619 | Routine Description:\r | |
620 | \r | |
621 | Compares two GUIDs\r | |
622 | \r | |
623 | Arguments:\r | |
624 | \r | |
625 | Guid1 - guid to compare\r | |
626 | Guid2 - guid to compare\r | |
627 | \r | |
628 | Returns:\r | |
629 | = TRUE if Guid1 == Guid2\r | |
630 | = FALSE if Guid1 != Guid2 \r | |
631 | \r | |
632 | --*/\r | |
633 | ;\r | |
634 | \r | |
635 | EFI_STATUS\r | |
636 | InstallEfiPeiPeCoffLoader (\r | |
637 | IN EFI_PEI_SERVICES **PeiServices,\r | |
638 | IN EFI_PEI_PE_COFF_LOADER_PROTOCOL **This,\r | |
639 | IN EFI_PEI_PPI_DESCRIPTOR *ThisPpi\r | |
640 | )\r | |
641 | /*++\r | |
642 | \r | |
643 | Routine Description:\r | |
644 | \r | |
645 | Install EFI Pei PE coff loader protocol.\r | |
646 | \r | |
647 | Arguments:\r | |
648 | \r | |
649 | PeiServices - The PEI core services table.\r | |
650 | \r | |
651 | This - Pointer to get Pei PE coff loader protocol as output\r | |
652 | \r | |
653 | ThisPpi - Passed in as EFI_NT_LOAD_AS_DLL_PPI on NT_EMULATOR platform\r | |
654 | \r | |
655 | Returns:\r | |
656 | \r | |
657 | EFI_SUCCESS\r | |
658 | \r | |
659 | --*/\r | |
660 | ;\r | |
661 | \r | |
662 | EFI_STATUS\r | |
663 | InstallEfiPeiPeCoffLoader64 (\r | |
664 | IN EFI_PEI_SERVICES **PeiServices,\r | |
665 | IN OUT EFI_PEI_PE_COFF_LOADER_PROTOCOL **This,\r | |
666 | IN EFI_PEI_PPI_DESCRIPTOR *ThisPpi\r | |
667 | );\r | |
668 | \r | |
669 | \r | |
670 | \r | |
671 | EFI_STATUS\r | |
672 | InstallEfiDecompress (\r | |
673 | EFI_DECOMPRESS_PROTOCOL **This\r | |
674 | )\r | |
675 | /*++\r | |
676 | \r | |
677 | Routine Description:\r | |
678 | \r | |
679 | Install EFI decompress protocol.\r | |
680 | \r | |
681 | Arguments:\r | |
682 | \r | |
683 | This - Pointer to get decompress protocol as output\r | |
684 | \r | |
685 | Returns:\r | |
686 | \r | |
687 | EFI_SUCCESS - EFI decompress protocol successfully installed.\r | |
688 | \r | |
689 | --*/\r | |
690 | ;\r | |
691 | \r | |
692 | EFI_STATUS\r | |
693 | InstallTianoDecompress (\r | |
694 | EFI_TIANO_DECOMPRESS_PROTOCOL **This\r | |
695 | )\r | |
696 | /*++\r | |
697 | \r | |
698 | Routine Description:\r | |
699 | \r | |
700 | Install Tiano decompress protocol.\r | |
701 | \r | |
702 | Arguments:\r | |
703 | \r | |
704 | This - Pointer to get decompress protocol as output\r | |
705 | \r | |
706 | Returns:\r | |
707 | \r | |
708 | EFI_SUCCESS - Tiano decompress protocol successfully installed.\r | |
709 | \r | |
710 | --*/\r | |
711 | ;\r | |
712 | \r | |
3eb9473e | 713 | EFI_STATUS\r |
714 | GetTimerValue (\r | |
715 | OUT UINT64 *TimerValue\r | |
716 | )\r | |
717 | /*++\r | |
718 | \r | |
719 | Routine Description:\r | |
720 | \r | |
721 | Get timer value.\r | |
722 | \r | |
723 | Arguments:\r | |
724 | \r | |
725 | TimerValue - Pointer to the returned timer value\r | |
726 | \r | |
727 | Returns:\r | |
728 | \r | |
729 | EFI_SUCCESS - Successfully got timer value\r | |
730 | \r | |
731 | --*/\r | |
732 | ;\r | |
733 | \r | |
3eb9473e | 734 | #ifdef EFI_NT_EMULATOR\r |
735 | EFI_STATUS\r | |
736 | PeCoffLoaderWinNtLoadAsDll (\r | |
737 | IN CHAR8 *PdbFileName,\r | |
738 | IN VOID **ImageEntryPoint,\r | |
739 | OUT VOID **ModHandle\r | |
740 | )\r | |
741 | /*++\r | |
742 | \r | |
743 | Routine Description:\r | |
744 | \r | |
745 | Loads the .DLL file is present when a PE/COFF file is loaded. This provides source level\r | |
746 | debugging for drivers that have cooresponding .DLL files on the local system.\r | |
747 | \r | |
748 | Arguments:\r | |
749 | \r | |
750 | PdbFileName - The name of the .PDB file. This was found from the PE/COFF\r | |
751 | file's debug directory entry.\r | |
752 | \r | |
753 | ImageEntryPoint - A pointer to the DLL entry point of the .DLL file was loaded.\r | |
754 | \r | |
755 | ModHandle - Pointer to loaded library.\r | |
756 | \r | |
757 | Returns:\r | |
758 | \r | |
759 | EFI_SUCCESS - The .DLL file was loaded, and the DLL entry point is returned in ImageEntryPoint\r | |
760 | \r | |
761 | EFI_NOT_FOUND - The .DLL file could not be found\r | |
762 | \r | |
763 | EFI_UNSUPPORTED - The .DLL file was loaded, but the entry point to the .DLL file could not\r | |
764 | determined.\r | |
765 | \r | |
766 | --*/\r | |
767 | ;\r | |
768 | \r | |
769 | #endif\r | |
770 | //\r | |
771 | // hob.c\r | |
772 | //\r | |
773 | EFI_STATUS\r | |
774 | PeiBuildHobModule (\r | |
775 | IN EFI_PEI_SERVICES **PeiServices,\r | |
776 | IN EFI_GUID *ModuleName,\r | |
777 | IN EFI_PHYSICAL_ADDRESS Module,\r | |
778 | IN UINT64 ModuleLength,\r | |
779 | IN EFI_PHYSICAL_ADDRESS EntryPoint\r | |
780 | )\r | |
781 | /*++\r | |
782 | \r | |
783 | Routine Description:\r | |
784 | \r | |
785 | Builds a HOB for a loaded PE32 module\r | |
786 | \r | |
787 | Arguments:\r | |
788 | \r | |
789 | PeiServices - The PEI core services table.\r | |
790 | ModuleName - The GUID File Name of the module\r | |
791 | Memory - The 64 bit physical address of the module\r | |
792 | ModuleLength - The length of the module in bytes\r | |
793 | EntryPoint - The 64 bit physical address of the entry point\r | |
794 | to the module\r | |
795 | \r | |
796 | Returns:\r | |
797 | \r | |
798 | EFI_SUCCESS - Hob is successfully built.\r | |
799 | Others - Errors occur while creating new Hob\r | |
800 | \r | |
801 | --*/\r | |
802 | ;\r | |
803 | \r | |
804 | EFI_STATUS\r | |
805 | PeiBuildHobResourceDescriptor (\r | |
806 | IN EFI_PEI_SERVICES **PeiServices,\r | |
807 | IN EFI_RESOURCE_TYPE ResourceType,\r | |
808 | IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,\r | |
809 | IN EFI_PHYSICAL_ADDRESS PhysicalStart,\r | |
810 | IN UINT64 NumberOfBytes\r | |
811 | )\r | |
812 | /*++\r | |
813 | \r | |
814 | Routine Description:\r | |
815 | \r | |
816 | Builds a HOB that describes a chunck of system memory\r | |
817 | \r | |
818 | Arguments:\r | |
819 | \r | |
820 | PeiServices - The PEI core services table.\r | |
821 | \r | |
822 | ResourceType - The type of resource described by this HOB\r | |
823 | \r | |
824 | ResourceAttribute - The resource attributes of the memory described by this HOB\r | |
825 | \r | |
826 | PhysicalStart - The 64 bit physical address of memory described by this HOB\r | |
827 | \r | |
828 | NumberOfBytes - The length of the memoty described by this HOB in bytes\r | |
829 | \r | |
830 | Returns:\r | |
831 | \r | |
832 | EFI_SUCCESS - Hob is successfully built.\r | |
833 | Others - Errors occur while creating new Hob\r | |
834 | \r | |
835 | --*/\r | |
836 | ;\r | |
837 | \r | |
838 | EFI_STATUS\r | |
839 | PeiBuildHobGuid (\r | |
840 | IN EFI_PEI_SERVICES **PeiServices,\r | |
841 | IN EFI_GUID *Guid,\r | |
842 | IN UINTN DataLength,\r | |
843 | IN OUT VOID **Hob\r | |
844 | )\r | |
845 | /*++\r | |
846 | \r | |
847 | Routine Description:\r | |
848 | \r | |
849 | Builds a custom HOB that is tagged with a GUID for identification\r | |
850 | \r | |
851 | Arguments:\r | |
852 | \r | |
853 | PeiServices - The PEI core services table.\r | |
854 | \r | |
855 | Guid - The GUID of the custome HOB type\r | |
856 | \r | |
857 | DataLength - The size of the data payload for the GUIDed HOB\r | |
858 | \r | |
859 | Hob - Pointer to the Hob\r | |
860 | \r | |
861 | Returns:\r | |
862 | \r | |
863 | EFI_SUCCESS - Hob is successfully built.\r | |
864 | Others - Errors occur while creating new Hob\r | |
865 | \r | |
866 | --*/\r | |
867 | ;\r | |
868 | \r | |
869 | EFI_STATUS\r | |
870 | PeiBuildHobGuidData (\r | |
871 | IN EFI_PEI_SERVICES **PeiServices,\r | |
872 | IN EFI_GUID *Guid,\r | |
873 | IN VOID *Data,\r | |
874 | IN UINTN DataLength\r | |
875 | )\r | |
876 | /*++\r | |
877 | \r | |
878 | Routine Description:\r | |
879 | \r | |
880 | Builds a custom HOB that is tagged with a GUID for identification\r | |
881 | \r | |
882 | Arguments:\r | |
883 | \r | |
884 | PeiServices - The PEI core services table.\r | |
885 | \r | |
886 | Guid - The GUID of the custome HOB type\r | |
887 | \r | |
888 | Data - The data to be copied into the GUIDed HOB data field.\r | |
889 | \r | |
890 | DataLength - The data field length.\r | |
891 | \r | |
892 | Returns:\r | |
893 | \r | |
894 | EFI_SUCCESS - Hob is successfully built.\r | |
895 | Others - Errors occur while creating new Hob\r | |
896 | \r | |
897 | --*/\r | |
898 | ;\r | |
899 | \r | |
900 | EFI_STATUS\r | |
901 | PeiBuildHobFv (\r | |
902 | IN EFI_PEI_SERVICES **PeiServices,\r | |
903 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
904 | IN UINT64 Length\r | |
905 | )\r | |
906 | /*++\r | |
907 | \r | |
908 | Routine Description:\r | |
909 | \r | |
910 | Builds a Firmware Volume HOB\r | |
911 | \r | |
912 | Arguments:\r | |
913 | \r | |
914 | PeiServices - The PEI core services table.\r | |
915 | \r | |
916 | BaseAddress - The base address of the Firmware Volume\r | |
917 | \r | |
918 | Length - The size of the Firmware Volume in bytes\r | |
919 | \r | |
920 | Returns:\r | |
921 | \r | |
922 | EFI_SUCCESS - Hob is successfully built.\r | |
923 | Others - Errors occur while creating new Hob\r | |
924 | \r | |
925 | --*/\r | |
926 | ;\r | |
927 | \r | |
928 | EFI_STATUS\r | |
929 | PeiBuildHobCpu (\r | |
930 | IN EFI_PEI_SERVICES **PeiServices,\r | |
931 | IN UINT8 SizeOfMemorySpace,\r | |
932 | IN UINT8 SizeOfIoSpace\r | |
933 | )\r | |
934 | /*++\r | |
935 | \r | |
936 | Routine Description:\r | |
937 | \r | |
938 | Builds a HOB for the CPU\r | |
939 | \r | |
940 | Arguments:\r | |
941 | \r | |
942 | PeiServices - The PEI core services table.\r | |
943 | \r | |
944 | SizeOfMemorySpace - Identifies the maximum \r | |
945 | physical memory addressibility of the processor.\r | |
946 | \r | |
947 | SizeOfIoSpace - Identifies the maximum physical I/O addressibility \r | |
948 | of the processor.\r | |
949 | \r | |
950 | Returns:\r | |
951 | \r | |
952 | EFI_SUCCESS - Hob is successfully built.\r | |
953 | Others - Errors occur while creating new Hob\r | |
954 | \r | |
955 | --*/\r | |
956 | ;\r | |
957 | \r | |
958 | EFI_STATUS\r | |
959 | PeiBuildHobStack (\r | |
960 | IN EFI_PEI_SERVICES **PeiServices,\r | |
961 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
962 | IN UINT64 Length\r | |
963 | )\r | |
964 | /*++\r | |
965 | \r | |
966 | Routine Description:\r | |
967 | \r | |
968 | Builds a HOB for the Stack\r | |
969 | \r | |
970 | Arguments:\r | |
971 | \r | |
972 | PeiServices - The PEI core services table.\r | |
973 | \r | |
974 | BaseAddress - The 64 bit physical address of the Stack\r | |
975 | \r | |
976 | Length - The length of the stack in bytes\r | |
977 | \r | |
978 | Returns:\r | |
979 | \r | |
980 | EFI_SUCCESS - Hob is successfully built.\r | |
981 | Others - Errors occur while creating new Hob\r | |
982 | \r | |
983 | --*/\r | |
984 | ;\r | |
985 | \r | |
986 | EFI_STATUS\r | |
987 | PeiBuildHobBspStore (\r | |
988 | IN EFI_PEI_SERVICES **PeiServices,\r | |
989 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
990 | IN UINT64 Length,\r | |
991 | IN EFI_MEMORY_TYPE MemoryType\r | |
992 | )\r | |
993 | /*++\r | |
994 | \r | |
995 | Routine Description:\r | |
996 | \r | |
997 | Builds a HOB for the bsp store\r | |
998 | \r | |
999 | Arguments:\r | |
1000 | \r | |
1001 | PeiServices - The PEI core services table.\r | |
1002 | \r | |
1003 | BaseAddress - The 64 bit physical address of the bsp store\r | |
1004 | \r | |
1005 | Length - The length of the bsp store in bytes\r | |
1006 | \r | |
1007 | MemoryType - Memory type\r | |
1008 | \r | |
1009 | Returns:\r | |
1010 | \r | |
1011 | EFI_SUCCESS - Hob is successfully built.\r | |
1012 | Others - Errors occur while creating new Hob\r | |
1013 | \r | |
1014 | --*/\r | |
1015 | ;\r | |
1016 | \r | |
1017 | EFI_STATUS\r | |
1018 | PeiBuildHobMemoryAllocation (\r | |
1019 | IN EFI_PEI_SERVICES **PeiServices,\r | |
1020 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
1021 | IN UINT64 Length,\r | |
1022 | IN EFI_GUID *Name,\r | |
1023 | IN EFI_MEMORY_TYPE MemoryType\r | |
1024 | )\r | |
1025 | /*++\r | |
1026 | \r | |
1027 | Routine Description:\r | |
1028 | \r | |
1029 | Builds a HOB for the memory allocation\r | |
1030 | \r | |
1031 | Arguments:\r | |
1032 | \r | |
1033 | PeiServices - The PEI core services table.\r | |
1034 | \r | |
1035 | BaseAddress - The 64 bit physical address of the memory\r | |
1036 | \r | |
1037 | Length - The length of the memory allocation in bytes\r | |
1038 | \r | |
1039 | Name - Name for Hob\r | |
1040 | \r | |
1041 | MemoryType - Memory type\r | |
1042 | \r | |
1043 | Returns:\r | |
1044 | \r | |
1045 | EFI_SUCCESS - Hob is successfully built.\r | |
1046 | Others - Errors occur while creating new Hob\r | |
1047 | \r | |
1048 | --*/\r | |
1049 | ;\r | |
1050 | \r | |
1051 | //\r | |
1052 | // print.c\r | |
1053 | //\r | |
1054 | UINTN\r | |
1055 | AvSPrint (\r | |
1056 | OUT CHAR8 *StartOfBuffer,\r | |
1057 | IN UINTN StrSize,\r | |
1058 | IN CONST CHAR8 *Format,\r | |
1059 | IN VA_LIST Marker\r | |
1060 | )\r | |
1061 | /*++\r | |
1062 | \r | |
1063 | Routine Description:\r | |
1064 | \r | |
1065 | AvSPrint function to process format and place the results in Buffer. Since a \r | |
1066 | VA_LIST is used this rountine allows the nesting of Vararg routines. Thus \r | |
1067 | this is the main print working routine\r | |
1068 | \r | |
1069 | Arguments:\r | |
1070 | \r | |
1071 | StartOfBuffer - Ascii buffer to print the results of the parsing of Format into.\r | |
1072 | \r | |
1073 | StrSize - Maximum number of characters to put into buffer. Zero means \r | |
1074 | no limit.\r | |
1075 | \r | |
1076 | FormatString - Ascii format string see file header for more details.\r | |
1077 | \r | |
1078 | Marker - Vararg list consumed by processing Format.\r | |
1079 | \r | |
1080 | Returns: \r | |
1081 | \r | |
1082 | Number of characters printed.\r | |
1083 | \r | |
1084 | --*/\r | |
1085 | ;\r | |
1086 | \r | |
1087 | UINTN\r | |
1088 | ASPrint (\r | |
1089 | OUT CHAR8 *Buffer,\r | |
1090 | IN UINTN BufferSize,\r | |
1091 | IN CONST CHAR8 *Format,\r | |
1092 | ...\r | |
1093 | )\r | |
1094 | /*++\r | |
1095 | \r | |
1096 | Routine Description:\r | |
1097 | \r | |
1098 | ASPrint function to process format and place the results in Buffer.\r | |
1099 | \r | |
1100 | Arguments:\r | |
1101 | \r | |
1102 | Buffer - Ascii buffer to print the results of the parsing of Format into.\r | |
1103 | \r | |
1104 | BufferSize - Maximum number of characters to put into buffer. Zero means no \r | |
1105 | limit.\r | |
1106 | \r | |
1107 | Format - Ascii format string see file header for more details.\r | |
1108 | \r | |
1109 | ... - Vararg list consumed by processing Format.\r | |
1110 | \r | |
1111 | Returns: \r | |
1112 | \r | |
1113 | Number of characters printed.\r | |
1114 | \r | |
1115 | --*/\r | |
1116 | ;\r | |
1117 | \r | |
1118 | //\r | |
1119 | // math.c\r | |
1120 | //\r | |
1121 | UINT64\r | |
1122 | MultU64x32 (\r | |
1123 | IN UINT64 Multiplicand,\r | |
1124 | IN UINTN Multiplier\r | |
1125 | )\r | |
1126 | /*++ \r | |
1127 | \r | |
1128 | Routine Description:\r | |
1129 | \r | |
1130 | This routine allows a 64 bit value to be multiplied with a 32 bit \r | |
1131 | value returns 64bit result.\r | |
1132 | No checking if the result is greater than 64bits\r | |
1133 | \r | |
1134 | Arguments:\r | |
1135 | \r | |
1136 | Multiplicand - multiplicand\r | |
1137 | Multiplier - multiplier\r | |
1138 | \r | |
1139 | Returns:\r | |
1140 | \r | |
1141 | Multiplicand * Multiplier\r | |
1142 | \r | |
1143 | --*/\r | |
1144 | ;\r | |
1145 | \r | |
1146 | UINT64\r | |
1147 | DivU64x32 (\r | |
1148 | IN UINT64 Dividend,\r | |
1149 | IN UINTN Divisor,\r | |
1150 | OUT UINTN *Remainder OPTIONAL\r | |
1151 | )\r | |
1152 | /*++\r | |
1153 | \r | |
1154 | Routine Description:\r | |
1155 | \r | |
1156 | This routine allows a 64 bit value to be divided with a 32 bit value returns \r | |
1157 | 64bit result and the Remainder.\r | |
1158 | N.B. only works for 31bit divisors!!\r | |
1159 | \r | |
1160 | Arguments:\r | |
1161 | \r | |
1162 | Dividend - dividend\r | |
1163 | Divisor - divisor\r | |
1164 | Remainder - buffer for remainder\r | |
1165 | \r | |
1166 | Returns:\r | |
1167 | \r | |
1168 | Dividend / Divisor\r | |
1169 | Remainder = Dividend mod Divisor\r | |
1170 | \r | |
1171 | --*/\r | |
1172 | ;\r | |
1173 | \r | |
1174 | UINT64\r | |
1175 | RShiftU64 (\r | |
1176 | IN UINT64 Operand,\r | |
1177 | IN UINTN Count\r | |
1178 | )\r | |
1179 | /*++\r | |
1180 | \r | |
1181 | Routine Description:\r | |
1182 | \r | |
1183 | This routine allows a 64 bit value to be right shifted by 32 bits and returns the \r | |
1184 | shifted value.\r | |
1185 | Count is valid up 63. (Only Bits 0-5 is valid for Count)\r | |
1186 | \r | |
1187 | Arguments:\r | |
1188 | \r | |
1189 | Operand - Value to be shifted\r | |
1190 | Count - Number of times to shift right.\r | |
1191 | \r | |
1192 | Returns:\r | |
1193 | \r | |
1194 | Value shifted right identified by the Count.\r | |
1195 | \r | |
1196 | --*/\r | |
1197 | ;\r | |
1198 | \r | |
1199 | UINT64\r | |
1200 | LShiftU64 (\r | |
1201 | IN UINT64 Operand,\r | |
1202 | IN UINTN Count\r | |
1203 | )\r | |
1204 | /*++\r | |
1205 | \r | |
1206 | Routine Description:\r | |
1207 | \r | |
1208 | This routine allows a 64 bit value to be left shifted by 32 bits and \r | |
1209 | returns the shifted value.\r | |
1210 | Count is valid up 63. (Only Bits 0-5 is valid for Count)\r | |
1211 | \r | |
1212 | Arguments:\r | |
1213 | \r | |
1214 | Operand - Value to be shifted\r | |
1215 | Count - Number of times to shift left.\r | |
1216 | \r | |
1217 | Returns:\r | |
1218 | \r | |
1219 | Value shifted left identified by the Count.\r | |
1220 | \r | |
1221 | --*/\r | |
1222 | ;\r | |
1223 | \r | |
1224 | VOID\r | |
1225 | RegisterNativeCpuIo (\r | |
1226 | IN EFI_PEI_SERVICES **PeiServices,\r | |
1227 | IN VOID *CpuIo\r | |
1228 | )\r | |
1229 | /*++\r | |
1230 | \r | |
1231 | Routine Description:\r | |
1232 | \r | |
1233 | Register a native Cpu IO\r | |
1234 | \r | |
1235 | Arguments:\r | |
1236 | \r | |
1237 | PeiServices - Calling context\r | |
1238 | CpuIo - CpuIo instance to register\r | |
1239 | \r | |
1240 | Returns:\r | |
1241 | \r | |
1242 | None\r | |
1243 | \r | |
1244 | --*/\r | |
1245 | ;\r | |
1246 | \r | |
1247 | VOID\r | |
1248 | GetNativeCpuIo (\r | |
1249 | IN EFI_PEI_SERVICES **PeiServices,\r | |
1250 | OUT VOID **CpuIo\r | |
1251 | )\r | |
1252 | /*++\r | |
1253 | \r | |
1254 | Routine Description:\r | |
1255 | \r | |
1256 | Get registered Cpu IO.\r | |
1257 | \r | |
1258 | Arguments:\r | |
1259 | \r | |
1260 | PeiServices - Calling context\r | |
1261 | CpuIo - CpuIo instance registered before\r | |
1262 | \r | |
1263 | Returns:\r | |
1264 | \r | |
1265 | None\r | |
1266 | \r | |
1267 | --*/\r | |
1268 | ;\r | |
1269 | \r | |
1270 | EFI_STATUS\r | |
c7f33ca4 | 1271 | EFIAPI\r |
3eb9473e | 1272 | FindFv (\r |
1273 | IN EFI_FIND_FV_PPI *This,\r | |
1274 | IN EFI_PEI_SERVICES **PeiServices,\r | |
1275 | IN OUT UINT8 *FvNumber,\r | |
1276 | IN OUT EFI_FIRMWARE_VOLUME_HEADER **FVAddress\r | |
1277 | )\r | |
1278 | /*++\r | |
1279 | \r | |
1280 | Routine Description:\r | |
1281 | \r | |
1282 | Search Fv in Hob.\r | |
1283 | \r | |
1284 | Arguments:\r | |
1285 | \r | |
1286 | This - Interface pointer that implement the Find Fv PPI\r | |
1287 | \r | |
1288 | PeiServices - Pointer to the PEI Service Table\r | |
1289 | \r | |
1290 | FvNumber - On input, the number of the fireware volume which supports FFS to locate\r | |
1291 | On output, the next FV number which supports FFS.\r | |
1292 | \r | |
1293 | FVAddress - The address of the volume which supports FFS to discover\r | |
1294 | \r | |
1295 | Returns:\r | |
1296 | \r | |
1297 | EFI_SUCCESS - An addtional FV which supports FFS found\r | |
1298 | EFI_OUT_OF_RESOURCES - There are no fireware volume which supports FFS for given fvnumber\r | |
1299 | EFI_INVALID_PARAMETER - FvAddress is NULL\r | |
1300 | \r | |
1301 | --*/\r | |
1302 | ;\r | |
1303 | \r | |
1304 | #endif\r |