3 Copyright (c) 2004, 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
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.
27 #include "peiHobLib.h"
28 #include EFI_PROTOCOL_DEFINITION (Decompress)
29 #include EFI_PROTOCOL_DEFINITION (TianoDecompress)
30 #include EFI_GUID_DEFINITION (PeiPeCoffLoader)
42 Copy Length bytes from Source to Destination.
46 Destination - Target of copy
48 Source - Place to copy from
50 Length - Number of bytes to copy
68 Set Buffer to zero for Size bytes.
72 Buffer - Memory to set.
74 Size - Number of bytes to set
93 Copy Length bytes from Source to Destination.
97 Destination - Target of copy
99 Source - Place to copy from
101 Length - Number of bytes to copy
123 Guid1 - guid to compare
124 Guid2 - guid to compare
127 = TRUE if Guid1 == Guid2
128 = FALSE if Guid1 != Guid2
134 InstallEfiPeiPeCoffLoader (
135 IN EFI_PEI_SERVICES
**PeiServices
,
136 IN EFI_PEI_PE_COFF_LOADER_PROTOCOL
**This
,
137 IN EFI_PEI_PPI_DESCRIPTOR
*ThisPpi
143 Install EFI Pei PE coff loader protocol.
147 PeiServices - The PEI core services table.
149 This - Pointer to get Pei PE coff loader protocol as output
151 ThisPpi - Passed in as EFI_NT_LOAD_AS_DLL_PPI on NT_EMULATOR platform
161 InstallEfiDecompress (
162 EFI_DECOMPRESS_PROTOCOL
**This
168 Install EFI decompress protocol.
172 This - Pointer to get decompress protocol as output
176 EFI_SUCCESS - EFI decompress protocol successfully installed.
182 InstallTianoDecompress (
183 EFI_TIANO_DECOMPRESS_PROTOCOL
**This
189 Install Tiano decompress protocol.
193 This - Pointer to get decompress protocol as output
197 EFI_SUCCESS - Tiano decompress protocol successfully installed.
204 EFI_PEI_SERVICES
**PeiServices
,
206 IN EFI_FFS_FILE_HEADER
*FileHeader
,
207 IN BOOLEAN EntryExit
,
214 Log a timestamp count.
218 PeiServices - Pointer to the PEI Core Services table
220 Token - Pointer to Token Name
222 FileHeader - Pointer to the file header
224 EntryExit - Indicates start or stop measurement
226 Value - The start time or the stop time
235 OUT UINT64
*TimerValue
245 TimerValue - Pointer to the returned timer value
249 EFI_SUCCESS - Successfully got timer value
254 #ifdef EFI_PEI_PERFORMANCE
255 #define PEI_PERF_START(Ps, Token, FileHeader, Value) PeiPerfMeasure (Ps, Token, FileHeader, FALSE, Value)
256 #define PEI_PERF_END(Ps, Token, FileHeader, Value) PeiPerfMeasure (Ps, Token, FileHeader, TRUE, Value)
258 #define PEI_PERF_START(Ps, Token, FileHeader, Value)
259 #define PEI_PERF_END(Ps, Token, FileHeader, Value)
262 #ifdef EFI_NT_EMULATOR
264 PeCoffLoaderWinNtLoadAsDll (
265 IN CHAR8
*PdbFileName
,
266 IN VOID
**ImageEntryPoint
,
273 Loads the .DLL file is present when a PE/COFF file is loaded. This provides source level
274 debugging for drivers that have cooresponding .DLL files on the local system.
278 PdbFileName - The name of the .PDB file. This was found from the PE/COFF
279 file's debug directory entry.
281 ImageEntryPoint - A pointer to the DLL entry point of the .DLL file was loaded.
283 ModHandle - Pointer to loaded library.
287 EFI_SUCCESS - The .DLL file was loaded, and the DLL entry point is returned in ImageEntryPoint
289 EFI_NOT_FOUND - The .DLL file could not be found
291 EFI_UNSUPPORTED - The .DLL file was loaded, but the entry point to the .DLL file could not
303 IN EFI_PEI_SERVICES
**PeiServices
,
304 IN EFI_GUID
*ModuleName
,
305 IN EFI_PHYSICAL_ADDRESS Module
,
306 IN UINT64 ModuleLength
,
307 IN EFI_PHYSICAL_ADDRESS EntryPoint
313 Builds a HOB for a loaded PE32 module
317 PeiServices - The PEI core services table.
318 ModuleName - The GUID File Name of the module
319 Memory - The 64 bit physical address of the module
320 ModuleLength - The length of the module in bytes
321 EntryPoint - The 64 bit physical address of the entry point
326 EFI_SUCCESS - Hob is successfully built.
327 Others - Errors occur while creating new Hob
333 PeiBuildHobResourceDescriptor (
334 IN EFI_PEI_SERVICES
**PeiServices
,
335 IN EFI_RESOURCE_TYPE ResourceType
,
336 IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute
,
337 IN EFI_PHYSICAL_ADDRESS PhysicalStart
,
338 IN UINT64 NumberOfBytes
344 Builds a HOB that describes a chunck of system memory
348 PeiServices - The PEI core services table.
350 ResourceType - The type of resource described by this HOB
352 ResourceAttribute - The resource attributes of the memory described by this HOB
354 PhysicalStart - The 64 bit physical address of memory described by this HOB
356 NumberOfBytes - The length of the memoty described by this HOB in bytes
360 EFI_SUCCESS - Hob is successfully built.
361 Others - Errors occur while creating new Hob
368 IN EFI_PEI_SERVICES
**PeiServices
,
377 Builds a custom HOB that is tagged with a GUID for identification
381 PeiServices - The PEI core services table.
383 Guid - The GUID of the custome HOB type
385 DataLength - The size of the data payload for the GUIDed HOB
387 Hob - Pointer to the Hob
391 EFI_SUCCESS - Hob is successfully built.
392 Others - Errors occur while creating new Hob
398 PeiBuildHobGuidData (
399 IN EFI_PEI_SERVICES
**PeiServices
,
408 Builds a custom HOB that is tagged with a GUID for identification
412 PeiServices - The PEI core services table.
414 Guid - The GUID of the custome HOB type
416 Data - The data to be copied into the GUIDed HOB data field.
418 DataLength - The data field length.
422 EFI_SUCCESS - Hob is successfully built.
423 Others - Errors occur while creating new Hob
430 IN EFI_PEI_SERVICES
**PeiServices
,
431 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
438 Builds a Firmware Volume HOB
442 PeiServices - The PEI core services table.
444 BaseAddress - The base address of the Firmware Volume
446 Length - The size of the Firmware Volume in bytes
450 EFI_SUCCESS - Hob is successfully built.
451 Others - Errors occur while creating new Hob
458 IN EFI_PEI_SERVICES
**PeiServices
,
459 IN UINT8 SizeOfMemorySpace
,
460 IN UINT8 SizeOfIoSpace
466 Builds a HOB for the CPU
470 PeiServices - The PEI core services table.
472 SizeOfMemorySpace - Identifies the maximum
473 physical memory addressibility of the processor.
475 SizeOfIoSpace - Identifies the maximum physical I/O addressibility
480 EFI_SUCCESS - Hob is successfully built.
481 Others - Errors occur while creating new Hob
488 IN EFI_PEI_SERVICES
**PeiServices
,
489 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
496 Builds a HOB for the Stack
500 PeiServices - The PEI core services table.
502 BaseAddress - The 64 bit physical address of the Stack
504 Length - The length of the stack in bytes
508 EFI_SUCCESS - Hob is successfully built.
509 Others - Errors occur while creating new Hob
515 PeiBuildHobBspStore (
516 IN EFI_PEI_SERVICES
**PeiServices
,
517 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
519 IN EFI_MEMORY_TYPE MemoryType
525 Builds a HOB for the bsp store
529 PeiServices - The PEI core services table.
531 BaseAddress - The 64 bit physical address of the bsp store
533 Length - The length of the bsp store in bytes
535 MemoryType - Memory type
539 EFI_SUCCESS - Hob is successfully built.
540 Others - Errors occur while creating new Hob
546 PeiBuildHobMemoryAllocation (
547 IN EFI_PEI_SERVICES
**PeiServices
,
548 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
551 IN EFI_MEMORY_TYPE MemoryType
557 Builds a HOB for the memory allocation
561 PeiServices - The PEI core services table.
563 BaseAddress - The 64 bit physical address of the memory
565 Length - The length of the memory allocation in bytes
569 MemoryType - Memory type
573 EFI_SUCCESS - Hob is successfully built.
574 Others - Errors occur while creating new Hob
584 OUT CHAR8
*StartOfBuffer
,
586 IN CONST CHAR8
*Format
,
593 AvSPrint function to process format and place the results in Buffer. Since a
594 VA_LIST is used this rountine allows the nesting of Vararg routines. Thus
595 this is the main print working routine
599 StartOfBuffer - Ascii buffer to print the results of the parsing of Format into.
601 StrSize - Maximum number of characters to put into buffer. Zero means
604 FormatString - Ascii format string see file header for more details.
606 Marker - Vararg list consumed by processing Format.
610 Number of characters printed.
619 IN CONST CHAR8
*Format
,
626 ASPrint function to process format and place the results in Buffer.
630 Buffer - Ascii buffer to print the results of the parsing of Format into.
632 BufferSize - Maximum number of characters to put into buffer. Zero means no
635 Format - Ascii format string see file header for more details.
637 ... - Vararg list consumed by processing Format.
641 Number of characters printed.
651 IN UINT64 Multiplicand
,
658 This routine allows a 64 bit value to be multiplied with a 32 bit
659 value returns 64bit result.
660 No checking if the result is greater than 64bits
664 Multiplicand - multiplicand
665 Multiplier - multiplier
669 Multiplicand * Multiplier
678 OUT UINTN
*Remainder OPTIONAL
684 This routine allows a 64 bit value to be divided with a 32 bit value returns
685 64bit result and the Remainder.
686 N.B. only works for 31bit divisors!!
692 Remainder - buffer for remainder
697 Remainder = Dividend mod Divisor
711 This routine allows a 64 bit value to be right shifted by 32 bits and returns the
713 Count is valid up 63. (Only Bits 0-5 is valid for Count)
717 Operand - Value to be shifted
718 Count - Number of times to shift right.
722 Value shifted right identified by the Count.
736 This routine allows a 64 bit value to be left shifted by 32 bits and
737 returns the shifted value.
738 Count is valid up 63. (Only Bits 0-5 is valid for Count)
742 Operand - Value to be shifted
743 Count - Number of times to shift left.
747 Value shifted left identified by the Count.
753 RegisterNativeCpuIo (
754 IN EFI_PEI_SERVICES
**PeiServices
,
761 Register a native Cpu IO
765 PeiServices - Calling context
766 CpuIo - CpuIo instance to register
777 IN EFI_PEI_SERVICES
**PeiServices
,
784 Get registered Cpu IO.
788 PeiServices - Calling context
789 CpuIo - CpuIo instance registered before