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