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