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