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