10#define MEMORY_ATTRIBUTE_MASK (EFI_RESOURCE_ATTRIBUTE_PRESENT | \
11 EFI_RESOURCE_ATTRIBUTE_INITIALIZED | \
12 EFI_RESOURCE_ATTRIBUTE_TESTED | \
13 EFI_RESOURCE_ATTRIBUTE_READ_PROTECTED | \
14 EFI_RESOURCE_ATTRIBUTE_WRITE_PROTECTED | \
15 EFI_RESOURCE_ATTRIBUTE_EXECUTION_PROTECTED | \
16 EFI_RESOURCE_ATTRIBUTE_READ_ONLY_PROTECTED | \
17 EFI_RESOURCE_ATTRIBUTE_16_BIT_IO | \
18 EFI_RESOURCE_ATTRIBUTE_32_BIT_IO | \
19 EFI_RESOURCE_ATTRIBUTE_64_BIT_IO | \
20 EFI_RESOURCE_ATTRIBUTE_PERSISTENT )
22#define TESTED_MEMORY_ATTRIBUTES (EFI_RESOURCE_ATTRIBUTE_PRESENT | \
23 EFI_RESOURCE_ATTRIBUTE_INITIALIZED | \
24 EFI_RESOURCE_ATTRIBUTE_TESTED )
64 if (GuidHob ==
NULL) {
72 DEBUG ((DEBUG_INFO,
"Find the Pei PCD data base, the total local token number is %d\n", PeiDatabase->LocalTokenCount));
76 if (EFI_ERROR (Status)) {
82 if (EFI_ERROR (Status)) {
89 for (Index = 0; Index < UplDatabase->ExTokenCount; Index++) {
90 ExMapTable[Index].TokenNumber += PeiDatabase->LocalTokenCount;
93 DEBUG ((DEBUG_INFO,
"Fix up UPL PCD database successfully\n"));
109 if (Hob->Raw ==
NULL) {
113 NewHob.Header =
CreateHob (Hob->Header->HobType, Hob->Header->HobLength);
114 ASSERT (NewHob.Header !=
NULL);
115 if (NewHob.Header ==
NULL) {
141 for (Hob.Raw = (UINT8 *)HobList; !END_OF_HOB_LIST (Hob); Hob.Raw = GET_NEXT_HOB (Hob)) {
145 if (GET_HOB_TYPE (Hob) != EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {
152 ResourceHob = Hob.ResourceDescriptor;
153 if (ResourceHob->
ResourceType != EFI_RESOURCE_SYSTEM_MEMORY) {
157 if ((ResourceHob->
ResourceAttribute & MEMORY_ATTRIBUTE_MASK) != TESTED_MEMORY_ATTRIBUTES) {
164 if (Base < ResourceHob->PhysicalStart) {
198 ReturnResourceHob =
NULL;
200 for (Hob.Raw = (UINT8 *)HobList; !END_OF_HOB_LIST (Hob); Hob.Raw = GET_NEXT_HOB (Hob)) {
204 if (GET_HOB_TYPE (Hob) != EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {
211 ResourceHob = Hob.ResourceDescriptor;
212 if (ResourceHob->
ResourceType != EFI_RESOURCE_SYSTEM_MEMORY) {
216 if ((ResourceHob->
ResourceAttribute & MEMORY_ATTRIBUTE_MASK) != TESTED_MEMORY_ATTRIBUTES) {
223 if (ResourceHob == ExceptResourceHob) {
244 if (ReturnResourceHob ==
NULL) {
245 ReturnResourceHob = ResourceHob;
248 ReturnResourceHob = ResourceHob;
253 return ReturnResourceHob;
272 if (Hob.Header->
HobType == EFI_HOB_TYPE_HANDOFF) {
276 if (Hob.Header->
HobType == EFI_HOB_TYPE_MEMORY_ALLOCATION) {
302 UINTN MinimalNeededSize;
317 Hob.Raw = (UINT8 *)BootloaderParameter;
318 MinimalNeededSize =
FixedPcdGet32 (PcdSystemMemoryUefiRegionSize);
320 ASSERT (Hob.Raw !=
NULL);
330 if (PhitResourceHob ==
NULL) {
335 if (ResourceHob ==
NULL) {
336 return EFI_NOT_FOUND;
340 FreeMemoryBottom = MemoryBottom;
342 MemoryTop = FreeMemoryTop;
348 FreeMemoryBottom = Hob.HandoffInformationTable->
EfiMemoryTop;
349 FreeMemoryTop = FreeMemoryBottom + MinimalNeededSize;
350 MemoryTop = FreeMemoryTop;
355 MemoryBottom = Hob.HandoffInformationTable->
EfiMemoryBottom - MinimalNeededSize;
356 FreeMemoryBottom = MemoryBottom;
365 if (ResourceHob ==
NULL) {
366 return EFI_NOT_FOUND;
370 FreeMemoryBottom = MemoryBottom;
372 MemoryTop = FreeMemoryTop;
375 HobInfo = HobConstructor ((VOID *)(
UINTN)MemoryBottom, (VOID *)(
UINTN)MemoryTop, (VOID *)(
UINTN)FreeMemoryBottom, (VOID *)(
UINTN)FreeMemoryTop);
388 while (!END_OF_HOB_LIST (Hob)) {
394 Hob.Raw = GET_NEXT_HOB (Hob);
401 ASSERT (GuidHob !=
NULL);
403 DEBUG ((DEBUG_INFO,
"Multiple Fv Count=%d\n", ExtraData->Count));
404 ASSERT (
AsciiStrCmp (ExtraData->Entry[0].Identifier,
"uefi_fv") == 0);
407 ASSERT ((*DxeFv)->FvLength == ExtraData->Entry[0].Size);
411 for (Idx = 1; Idx < ExtraData->Count; Idx++) {
412 BuildFvHob (ExtraData->Entry[Idx].Base, ExtraData->Entry[Idx].Size);
415 "UPL Multiple fv[%d], Base=0x%x, size=0x%x\n",
417 ExtraData->Entry[Idx].Base,
418 ExtraData->Entry[Idx].Size
426 if (GuidHob !=
NULL) {
429 if (GuidHob ==
NULL) {
431 ASSERT (AcpiBoardInfo !=
NULL);
441 FvHob->
Length = (*DxeFv)->FvLength;
459 PHYSICAL_ADDRESS DxeCoreEntryPoint;
463 mHobList = (VOID *)BootloaderParameter;
466 ProcessLibraryConstructorList ();
468 DEBUG ((DEBUG_INFO,
"Entering Universal Payload...\n"));
469 DEBUG ((DEBUG_INFO,
"sizeof(UINTN) = 0x%x\n",
sizeof (
UINTN)));
482 Status =
BuildHobs (BootloaderParameter, &DxeFv);
EFI_GUID gUefiAcpiBoardInfoGuid
VOID *EFIAPI GetFirstHob(IN UINT16 Type)
VOID *EFIAPI GetFirstGuidHob(IN CONST EFI_GUID *Guid)
VOID EFIAPI BuildFvHob(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length)
INTN EFIAPI AsciiStrCmp(IN CONST CHAR8 *FirstString, IN CONST CHAR8 *SecondString)
VOID EFIAPI CpuDeadLoop(VOID)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
VOID HandOffToDxeCore(IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint, IN EFI_PEI_HOB_POINTERS HobList)
ACPI_BOARD_INFO * BuildHobFromAcpi(IN UINT64 AcpiTableBase)
EFI_STATUS UniversalLoadDxeCore(IN EFI_FIRMWARE_VOLUME_HEADER *DxeFv, OUT PHYSICAL_ADDRESS *DxeCoreEntryPoint)
EFI_STATUS FileFindSection(IN EFI_FFS_FILE_HEADER *FileHeader, IN EFI_SECTION_TYPE SectionType, OUT VOID **SectionData)
EFI_STATUS FvFindFileByTypeGuid(IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader, IN EFI_FV_FILETYPE FileType, IN EFI_GUID *Guid OPTIONAL, OUT EFI_FFS_FILE_HEADER **FileHeader)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define DEBUG_CODE(Expression)
#define FixedPcdGet32(TokenName)
#define PcdGetPtr(TokenName)
VOID * CreateHob(IN UINT16 HobType, IN UINT16 HobLenght)
UINT64 EFI_PHYSICAL_ADDRESS
VOID PrintHob(IN CONST VOID *HobStart)
EFI_STATUS FixUpPcdDatabase(IN EFI_FIRMWARE_VOLUME_HEADER *DxeFv)
EFI_STATUS BuildHobs(IN UINTN BootloaderParameter, OUT EFI_FIRMWARE_VOLUME_HEADER **DxeFv)
VOID AddNewHob(IN EFI_PEI_HOB_POINTERS *Hob)
EFI_HOB_RESOURCE_DESCRIPTOR * FindResourceDescriptorByRange(IN VOID *HobList, IN EFI_PHYSICAL_ADDRESS Base, IN EFI_PHYSICAL_ADDRESS Top)
EFI_STATUS EFIAPI _ModuleEntryPoint(IN UINTN BootloaderParameter)
BOOLEAN IsHobNeed(EFI_PEI_HOB_POINTERS Hob)
EFI_HOB_RESOURCE_DESCRIPTOR * FindAnotherHighestBelow4GResourceDescriptor(IN VOID *HobList, IN UINTN MinimalNeededSize, IN EFI_HOB_RESOURCE_DESCRIPTOR *ExceptResourceHob)
VOID EFIAPI InitializeFloatingPointUnits(VOID)
EFI_PHYSICAL_ADDRESS BaseAddress
EFI_PHYSICAL_ADDRESS EfiFreeMemoryBottom
EFI_PHYSICAL_ADDRESS EfiMemoryTop
EFI_PHYSICAL_ADDRESS EfiFreeMemoryTop
EFI_PHYSICAL_ADDRESS EfiMemoryBottom
EFI_HOB_MEMORY_ALLOCATION_HEADER MemoryAllocationHeader
EFI_PHYSICAL_ADDRESS PhysicalStart
EFI_RESOURCE_TYPE ResourceType
EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute