]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Foundation/Library/Pei/Include/PeiLib.h
1) Sync EdkCompatibilityPkg with EDK 1.04. The changes includes:
[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
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
37typedef struct {\r
38 UINT32 PeiServiceTable;\r
39} PEI_IDT_TABLE;\r
40\r
41\r
42VOID *\r
43EFIAPI\r
44ScanGuid (\r
45 IN VOID *Buffer,\r
46 IN UINTN Length,\r
47 IN EFI_GUID *Guid\r
48 )\r
49/*++\r
50\r
51Routine 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
66Arguments:\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
72Returns:\r
73 A pointer to the matching Guid in the target buffer or NULL otherwise.\r
74\r
75--*/\r
76;\r
77\r
78VOID *\r
79EFIAPI\r
80InvalidateInstructionCacheRange (\r
81 IN VOID *Address,\r
82 IN UINTN Length\r
83 )\r
84/*++\r
85\r
86Routine 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
102Arguments:\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
117EFI_STATUS\r
118EFIAPI\r
119PeiLibFfsFindNextVolume (\r
120 IN UINTN Instance,\r
121 IN OUT EFI_PEI_FV_HANDLE *VolumeHandle\r
122 )\r
123/*++\r
124\r
125Routine Description:\r
126\r
127 The wrapper of Pei Core Service function FfsFindNextVolume.\r
128\r
129Arguments:\r
130\r
131 Instance - The Fv Volume Instance.\r
132 VolumeHandle - Pointer to the current Fv Volume to search.\r
133\r
134Returns:\r
135 EFI_STATUS\r
136 \r
137--*/\r
138;\r
139\r
140EFI_STATUS\r
141EFIAPI\r
142PeiLibFfsFindNextFile (\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
149Routine Description:\r
150\r
151 The wrapper of Pei Core Service function FfsFindNextFile.\r
152\r
153Arguments:\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
160Returns:\r
161 EFI_STATUS\r
162 \r
163--*/ \r
164;\r
165\r
166EFI_STATUS\r
167EFIAPI\r
168PeiLibFfsFindFileByName (\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
175Routine Description:\r
176\r
177 The wrapper of Pei Core Service function FfsFindFileByName.\r
178\r
179Arguments:\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
186Returns:\r
187 EFI_STATUS\r
188 \r
189--*/ \r
190;\r
191\r
192EFI_STATUS\r
193EFIAPI\r
194PeiLibFfsFindSectionData (\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
201Routine Description:\r
202\r
203 The wrapper of Pei Core Service function FfsFindSectionData.\r
204\r
205Arguments:\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
212Returns:\r
213 EFI_STATUS\r
214--*/\r
215;\r
216\r
217EFI_STATUS\r
218EFIAPI\r
219PeiLibFfsGetVolumeInfo (\r
220 IN EFI_PEI_FV_HANDLE *VolumeHandle,\r
221 OUT EFI_FV_INFO *VolumeInfo\r
222 )\r
223/*++\r
224\r
225Routine Description:\r
226\r
227 The wrapper of Pei Core Service function FfsGetVolumeInfo.\r
228\r
229Arguments:\r
230\r
231 VolumeHandle - The handle to Fv Volume.\r
232 VolumeInfo - The pointer to volume information.\r
233 \r
234Returns:\r
235 EFI_STATUS\r
236--*/ \r
237;\r
238\r
239EFI_STATUS\r
240EFIAPI\r
241PeiServicesLocatePpi (\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
249Routine Description:\r
250\r
251 The wrapper of Pei Core Service function LocatePpi.\r
252\r
253Arguments:\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
261Returns:\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
268VOID\r
269EFIAPI\r
270BuildFvHob (\r
271 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
272 IN UINT64 Length\r
273 )\r
274/*++\r
275\r
276Routine Description:\r
277\r
278 Build FvHob.\r
279\r
280Arguments:\r
281\r
282 BaseAddress - Fv base address.\r
283 Length - Fv Length.\r
284\r
285Returns:\r
286 NONE.\r
287 \r
288--*/ \r
289;\r
290\r
291VOID\r
292EFIAPI\r
293BuildFvHob2 (\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
301Routine Description:\r
302\r
303 Build FvHob2.\r
304\r
305Arguments:\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
312Returns:\r
313 NONE.\r
314--*/ \r
315;\r
316\r
317\r
318VOID \r
319EFIAPI\r
320BuildGuidDataHob (\r
321 IN EFI_GUID *Guid,\r
322 IN VOID *Data,\r
323 IN UINTN DataLength\r
324 )\r
325/*++\r
326\r
327Routine Description:\r
328\r
329 Build Guid data Hob.\r
330\r
331Arguments:\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
337Returns:\r
338 NONE\r
339 \r
340--*/ \r
341;\r
342\r
343VOID *\r
344EFIAPI\r
345AllocatePages (\r
346 IN UINTN Pages\r
347 )\r
348/*++\r
349\r
350Routine Description:\r
351\r
352 Allocate Memory.\r
353\r
354Arguments:\r
355\r
356 Pages - Pages to allocate.\r
357\r
358Returns:\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
365VOID\r
366SetPeiServicesTablePointer (\r
367 IN EFI_PEI_SERVICES **PeiServices\r
368 )\r
369/*++\r
370\r
371Routine Description:\r
372\r
373 Save PeiService pointer so that it can be retrieved anywhere.\r
374\r
375Arguments:\r
376\r
377 PeiServices - The direct pointer to PeiServiceTable.\r
378 \r
379Returns:\r
380 NONE\r
381 \r
382--*/ \r
383;\r
384\r
385EFI_PEI_SERVICES **\r
386GetPeiServicesTablePointer (\r
387 VOID \r
388 )\r
389/*++\r
390\r
391Routine Description:\r
392\r
393 Get PeiService pointer.\r
394\r
395Arguments:\r
396\r
397 NONE.\r
398 \r
399Returns:\r
400 The direct pointer to PeiServiceTable.\r
401 \r
402--*/ \r
403;\r
404\r
405VOID\r
406MigrateIdtTable (\r
407 IN EFI_PEI_SERVICES **PeiServices\r
408 )\r
409/*++\r
410\r
411Routine 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
416Arguments:\r
417\r
418 PeiServices - The direct pointer to PeiServiceTable.\r
419 \r
420Returns:\r
421\r
422 NONE.\r
423 \r
424--*/ \r
425;\r
426\r
427\r
428UINTN\r
429ReadIdtBase (\r
430 VOID\r
431 )\r
432/*++\r
433\r
434Routine Description:\r
435\r
436 Read IDT Register BaseAddress.\r
437\r
438Arguments:\r
439\r
440 NONE\r
441 \r
442Returns:\r
443 IDT Register BaseAddress.\r
444\r
445--*/ \r
446;\r
447\r
448\r
449UINT16\r
450ReadIdtLimit (\r
451 VOID\r
452 )\r
453/*++\r
454\r
455Routine Description:\r
456\r
457 Read IDT Register Limit.\r
458\r
459Arguments:\r
460\r
461 NONE\r
462 \r
463Returns:\r
464 IDT Register Limit.\r
465\r
466--*/ \r
467;\r
468\r
469\r
470VOID\r
471SetIdtBase (\r
472 UINT32 IdtBase,\r
473 UINT16 IdtLimit \r
474 )\r
475/*++\r
476\r
477Routine Description:\r
478\r
479 Set IDT Register BaseAddress.\r
480\r
481Arguments:\r
482\r
483 IdtBase - IDT.BaseAddress\r
484 IdtLimit - IDT.Limit\r
485 \r
486Returns:\r
487 NONE\r
488--*/ \r
489;\r
490\r
491VOID\r
492AsmWriteKr7 (\r
493 UINT64 Address\r
494 )\r
495/*++\r
496\r
497Routine Description:\r
498\r
499 Write 64 bit into Kernel Register7 on IPF.\r
500\r
501Arguments:\r
502\r
503 Address - Data to write into kr7.\r
504 \r
505Returns:\r
506 NONE\r
507 \r
508--*/ \r
509;\r
510\r
511\r
512UINT64\r
513AsmReadKr7 (\r
514 VOID\r
515 )\r
516/*++\r
517\r
518Routine Description:\r
519\r
520 Read 64 bit from Kernel Register7 on IPF.\r
521\r
522Arguments:\r
523\r
524 NONE \r
525 \r
526Returns:\r
527 Data in kr7.\r
528 \r
529--*/ \r
530;\r
531\r
532#endif\r
533\r
534VOID\r
535PeiCopyMem (\r
536 IN VOID *Destination,\r
537 IN VOID *Source,\r
538 IN UINTN Length\r
539 )\r
540/*++\r
541\r
542Routine Description:\r
543\r
544 Copy Length bytes from Source to Destination.\r
545\r
546Arguments:\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
554Returns:\r
555\r
556 None\r
557\r
558--*/\r
559;\r
560\r
561VOID\r
562ZeroMem (\r
563 IN VOID *Buffer,\r
564 IN UINTN Size\r
565 )\r
566/*++\r
567\r
568Routine Description:\r
569\r
570 Set Buffer to zero for Size bytes.\r
571\r
572Arguments:\r
573\r
574 Buffer - Memory to set.\r
575\r
576 Size - Number of bytes to set\r
577\r
578Returns:\r
579\r
580 None\r
581\r
582--*/\r
583;\r
584\r
585VOID\r
586CopyMem (\r
587 IN VOID *Destination,\r
588 IN VOID *Source,\r
589 IN UINTN Length\r
590 )\r
591/*++\r
592\r
593Routine Description:\r
594\r
595 Copy Length bytes from Source to Destination.\r
596\r
597Arguments:\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
605Returns:\r
606\r
607 None\r
608\r
609--*/\r
610;\r
611\r
612BOOLEAN\r
613CompareGuid (\r
614 IN EFI_GUID *Guid1,\r
615 IN EFI_GUID *Guid2\r
616 )\r
617/*++\r
618\r
619Routine Description:\r
620\r
621 Compares two GUIDs\r
622\r
623Arguments:\r
624\r
625 Guid1 - guid to compare\r
626 Guid2 - guid to compare\r
627\r
628Returns:\r
629 = TRUE if Guid1 == Guid2\r
630 = FALSE if Guid1 != Guid2 \r
631\r
632--*/\r
633;\r
634\r
635EFI_STATUS\r
636InstallEfiPeiPeCoffLoader (\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
643Routine Description:\r
644\r
645 Install EFI Pei PE coff loader protocol.\r
646 \r
647Arguments:\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
655Returns:\r
656\r
657 EFI_SUCCESS\r
658\r
659--*/\r
660;\r
661\r
662EFI_STATUS\r
663InstallEfiPeiPeCoffLoader64 (\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
671EFI_STATUS\r
672InstallEfiDecompress (\r
673 EFI_DECOMPRESS_PROTOCOL **This\r
674 )\r
675/*++\r
676\r
677Routine Description:\r
678\r
679 Install EFI decompress protocol.\r
680\r
681Arguments:\r
682\r
683 This - Pointer to get decompress protocol as output\r
684\r
685Returns:\r
686\r
687 EFI_SUCCESS - EFI decompress protocol successfully installed.\r
688\r
689--*/\r
690;\r
691\r
692EFI_STATUS\r
693InstallTianoDecompress (\r
694 EFI_TIANO_DECOMPRESS_PROTOCOL **This\r
695 )\r
696/*++\r
697\r
698Routine Description:\r
699\r
700 Install Tiano decompress protocol.\r
701\r
702Arguments:\r
703\r
704 This - Pointer to get decompress protocol as output\r
705\r
706Returns:\r
707\r
708 EFI_SUCCESS - Tiano decompress protocol successfully installed.\r
709\r
710--*/\r
711;\r
712\r
3eb9473e 713EFI_STATUS\r
714GetTimerValue (\r
715 OUT UINT64 *TimerValue\r
716 )\r
717/*++\r
718\r
719Routine Description:\r
720\r
721 Get timer value.\r
722\r
723Arguments:\r
724\r
725 TimerValue - Pointer to the returned timer value\r
726\r
727Returns:\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
735EFI_STATUS\r
736PeCoffLoaderWinNtLoadAsDll (\r
737 IN CHAR8 *PdbFileName,\r
738 IN VOID **ImageEntryPoint,\r
739 OUT VOID **ModHandle\r
740 )\r
741/*++\r
742\r
743Routine 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
748Arguments:\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
757Returns:\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
773EFI_STATUS\r
774PeiBuildHobModule (\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
783Routine Description:\r
784\r
785 Builds a HOB for a loaded PE32 module\r
786\r
787Arguments:\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
796Returns:\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
804EFI_STATUS\r
805PeiBuildHobResourceDescriptor (\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
814Routine Description:\r
815\r
816 Builds a HOB that describes a chunck of system memory\r
817\r
818Arguments:\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
830Returns:\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
838EFI_STATUS\r
839PeiBuildHobGuid (\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
847Routine Description:\r
848\r
849 Builds a custom HOB that is tagged with a GUID for identification\r
850\r
851Arguments:\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
861Returns:\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
869EFI_STATUS\r
870PeiBuildHobGuidData (\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
878Routine Description:\r
879\r
880 Builds a custom HOB that is tagged with a GUID for identification\r
881\r
882Arguments:\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
892Returns:\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
900EFI_STATUS\r
901PeiBuildHobFv (\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
908Routine Description:\r
909\r
910 Builds a Firmware Volume HOB\r
911\r
912Arguments:\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
920Returns:\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
928EFI_STATUS\r
929PeiBuildHobCpu (\r
930 IN EFI_PEI_SERVICES **PeiServices,\r
931 IN UINT8 SizeOfMemorySpace,\r
932 IN UINT8 SizeOfIoSpace\r
933 )\r
934/*++\r
935\r
936Routine Description:\r
937\r
938 Builds a HOB for the CPU\r
939\r
940Arguments:\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
950Returns:\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
958EFI_STATUS\r
959PeiBuildHobStack (\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
966Routine Description:\r
967\r
968 Builds a HOB for the Stack\r
969\r
970Arguments:\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
978Returns:\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
986EFI_STATUS\r
987PeiBuildHobBspStore (\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
995Routine Description:\r
996\r
997 Builds a HOB for the bsp store\r
998\r
999Arguments:\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
1009Returns:\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
1017EFI_STATUS\r
1018PeiBuildHobMemoryAllocation (\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
1027Routine Description:\r
1028\r
1029 Builds a HOB for the memory allocation\r
1030\r
1031Arguments:\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
1043Returns:\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
1054UINTN\r
1055AvSPrint (\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
1063Routine 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
1069Arguments:\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
1080Returns: \r
1081\r
1082 Number of characters printed.\r
1083\r
1084--*/\r
1085;\r
1086\r
1087UINTN\r
1088ASPrint (\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
1096Routine Description:\r
1097\r
1098 ASPrint function to process format and place the results in Buffer.\r
1099\r
1100Arguments:\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
1111Returns: \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
1121UINT64\r
1122MultU64x32 (\r
1123 IN UINT64 Multiplicand,\r
1124 IN UINTN Multiplier\r
1125 )\r
1126/*++ \r
1127 \r
1128Routine 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
1134Arguments:\r
1135\r
1136 Multiplicand - multiplicand\r
1137 Multiplier - multiplier\r
1138\r
1139Returns:\r
1140\r
1141 Multiplicand * Multiplier\r
1142 \r
1143--*/\r
1144;\r
1145\r
1146UINT64\r
1147DivU64x32 (\r
1148 IN UINT64 Dividend,\r
1149 IN UINTN Divisor,\r
1150 OUT UINTN *Remainder OPTIONAL\r
1151 )\r
1152/*++\r
1153\r
1154Routine 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
1160Arguments:\r
1161\r
1162 Dividend - dividend\r
1163 Divisor - divisor\r
1164 Remainder - buffer for remainder\r
1165 \r
1166Returns:\r
1167\r
1168 Dividend / Divisor\r
1169 Remainder = Dividend mod Divisor\r
1170\r
1171--*/\r
1172;\r
1173\r
1174UINT64\r
1175RShiftU64 (\r
1176 IN UINT64 Operand,\r
1177 IN UINTN Count\r
1178 )\r
1179/*++\r
1180\r
1181Routine 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
1187Arguments:\r
1188\r
1189 Operand - Value to be shifted\r
1190 Count - Number of times to shift right.\r
1191 \r
1192Returns:\r
1193\r
1194 Value shifted right identified by the Count.\r
1195\r
1196--*/\r
1197;\r
1198\r
1199UINT64\r
1200LShiftU64 (\r
1201 IN UINT64 Operand,\r
1202 IN UINTN Count\r
1203 )\r
1204/*++\r
1205\r
1206Routine 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
1212Arguments:\r
1213\r
1214 Operand - Value to be shifted\r
1215 Count - Number of times to shift left.\r
1216\r
1217Returns:\r
1218\r
1219 Value shifted left identified by the Count.\r
1220\r
1221--*/\r
1222;\r
1223\r
1224VOID\r
1225RegisterNativeCpuIo (\r
1226 IN EFI_PEI_SERVICES **PeiServices,\r
1227 IN VOID *CpuIo\r
1228 )\r
1229/*++\r
1230\r
1231Routine Description:\r
1232\r
1233 Register a native Cpu IO\r
1234\r
1235Arguments:\r
1236\r
1237 PeiServices - Calling context\r
1238 CpuIo - CpuIo instance to register\r
1239\r
1240Returns:\r
1241\r
1242 None\r
1243\r
1244--*/\r
1245;\r
1246\r
1247VOID\r
1248GetNativeCpuIo (\r
1249 IN EFI_PEI_SERVICES **PeiServices,\r
1250 OUT VOID **CpuIo\r
1251 )\r
1252/*++\r
1253\r
1254Routine Description:\r
1255\r
1256 Get registered Cpu IO.\r
1257\r
1258Arguments:\r
1259\r
1260 PeiServices - Calling context\r
1261 CpuIo - CpuIo instance registered before\r
1262\r
1263Returns:\r
1264\r
1265 None\r
1266\r
1267--*/\r
1268;\r
1269\r
1270EFI_STATUS\r
c7f33ca4 1271EFIAPI\r
3eb9473e 1272FindFv (\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
1280Routine Description:\r
1281\r
1282 Search Fv in Hob.\r
1283\r
1284Arguments:\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
1295Returns:\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