13#define MEMORY_ATTRIBUTE_MASK (EFI_RESOURCE_ATTRIBUTE_PRESENT | \
14 EFI_RESOURCE_ATTRIBUTE_INITIALIZED | \
15 EFI_RESOURCE_ATTRIBUTE_TESTED | \
16 EFI_RESOURCE_ATTRIBUTE_READ_PROTECTED | \
17 EFI_RESOURCE_ATTRIBUTE_WRITE_PROTECTED | \
18 EFI_RESOURCE_ATTRIBUTE_EXECUTION_PROTECTED | \
19 EFI_RESOURCE_ATTRIBUTE_READ_ONLY_PROTECTED | \
20 EFI_RESOURCE_ATTRIBUTE_16_BIT_IO | \
21 EFI_RESOURCE_ATTRIBUTE_32_BIT_IO | \
22 EFI_RESOURCE_ATTRIBUTE_64_BIT_IO | \
23 EFI_RESOURCE_ATTRIBUTE_PERSISTENT )
25#define TESTED_MEMORY_ATTRIBUTES (EFI_RESOURCE_ATTRIBUTE_PRESENT | \
26 EFI_RESOURCE_ATTRIBUTE_INITIALIZED | \
27 EFI_RESOURCE_ATTRIBUTE_TESTED )
35 { EfiMaxMemoryType, 0 }
40CHAR8 *mLineBuffer =
NULL;
53ProcessLibraryConstructorList (
75 for (Str1 = String; *Str1 != L
'\0'; Str1++) {
76 for (Str2 = CharSet; *Str2 != L
'\0'; Str2++) {
108 for (Str1 = String; *Str1 != L
'\0'; Str1++) {
109 for (Str2 = CharSet; *Str2 != L
'\0'; Str2++) {
110 if (*Str1 == *Str2) {
111 return (CHAR8 *)Str1;
127 IN CHAR8 *String OPTIONAL,
134 Begin = (String ==
NULL) ? mLineBuffer : String;
140 if (*Begin == L
'\0') {
146 if ((End !=
NULL) && (*End != L
'\0')) {
179 if (GuidHob ==
NULL) {
187 DEBUG ((DEBUG_INFO,
"Find the Pei PCD data base, the total local token number is %d\n", PeiDatabase->LocalTokenCount));
191 if (EFI_ERROR (Status)) {
197 if (EFI_ERROR (Status)) {
204 for (Index = 0; Index < UplDatabase->ExTokenCount; Index++) {
205 ExMapTable[Index].TokenNumber += PeiDatabase->LocalTokenCount;
208 DEBUG ((DEBUG_INFO,
"Fix up UPL PCD database successfully\n"));
243 if (GuidHob !=
NULL) {
245 Fdt = (VOID *)(
UINTN)PayloadBase->Entry;
246 DEBUG ((DEBUG_INFO,
"PayloadBase Entry = 0x%08x\n", PayloadBase->Entry));
250 return EFI_UNSUPPORTED;
254 if (EFI_ERROR (Status)) {
255 return EFI_UNSUPPORTED;
259 if (ConfigNode <= 0) {
260 return EFI_NOT_FOUND;
264 if (Config1Node <= 0) {
265 return EFI_NOT_FOUND;
269 if (ImageNode <= 0) {
270 return EFI_NOT_FOUND;
279 return EFI_NOT_FOUND;
282 PropertyPtr =
FdtGetProperty (Fdt, FvNode,
"data-offset", &TempLen);
283 Data32 = (UINT32 *)(PropertyPtr->Data);
286 PropertyPtr =
FdtGetProperty (Fdt, FvNode,
"data-size", &TempLen);
287 Data32 = (UINT32 *)(PropertyPtr->Data);
292 ASSERT ((*DxeFv)->FvLength == DataSize);
299 "UPL Multiple fv[%a], Base=0x%08x, size=0x%08x\n",
301 ((
UINTN)PayloadBase->Entry + (
UINTN)DataOffset),
324 UINTN MinimalNeededSize;
333 Hob.Raw = (UINT8 *)BootloaderParameter;
334 MinimalNeededSize =
FixedPcdGet32 (PcdSystemMemoryUefiRegionSize);
336 ASSERT (Hob.Raw !=
NULL);
346 if (PhitResourceHob ==
NULL) {
351 if (ResourceHob ==
NULL) {
356 FreeMemoryBottom = MemoryBottom;
358 MemoryTop = FreeMemoryTop;
364 FreeMemoryBottom = Hob.HandoffInformationTable->
EfiMemoryTop;
365 FreeMemoryTop = FreeMemoryBottom + MinimalNeededSize;
366 MemoryTop = FreeMemoryTop;
371 MemoryBottom = Hob.HandoffInformationTable->
EfiMemoryBottom - MinimalNeededSize;
372 FreeMemoryBottom = MemoryBottom;
381 if (ResourceHob ==
NULL) {
386 FreeMemoryBottom = MemoryBottom;
388 MemoryTop = FreeMemoryTop;
391 HobInfo = HobConstructor ((VOID *)(
UINTN)MemoryBottom, (VOID *)(
UINTN)MemoryTop, (VOID *)(
UINTN)FreeMemoryBottom, (VOID *)(
UINTN)FreeMemoryTop);
397 while (!END_OF_HOB_LIST (Hob)) {
403 Hob.Raw = GET_NEXT_HOB (Hob);
433 if (NewFdtBase != 0) {
435 if (GuidHob !=
NULL) {
438 DEBUG ((DEBUG_INFO,
"Update FDT base to reserved memory\n"));
439 FdtSize =
PcdGet8 (PcdFDTPageSize) * EFI_PAGE_SIZE;
440 CopyMem ((VOID *)NewFdtBase, (VOID *)(Fdt->DeviceTreeAddress), FdtSize);
441 Fdt->DeviceTreeAddress = NewFdtBase;
451 if (GuidHob ==
NULL) {
453 &gEfiMemoryTypeInformationGuid,
454 mDefaultMemoryTypeInformation,
455 sizeof (mDefaultMemoryTypeInformation)
463 if (GuidHob !=
NULL) {
466 if (GuidHob ==
NULL) {
468 ASSERT (AcpiBoardInfo !=
NULL);
484 FvHob->
Length = (*DxeFv)->FvLength;
500 PHYSICAL_ADDRESS DxeCoreEntryPoint;
504 #if FixedPcdGetBool (PcdHandOffFdtEnable) == 1
505 PHYSICAL_ADDRESS HobListPtr;
511 mHobList = (VOID *)
NULL;
513 mHobList = (VOID *)BootloaderParameter;
519 ProcessLibraryConstructorList ();
521 DEBUG ((DEBUG_INFO,
"Entering Universal Payload...\n"));
522 DEBUG ((DEBUG_INFO,
"sizeof(UINTN) = 0x%x\n",
sizeof (
UINTN)));
523 DEBUG ((DEBUG_INFO,
"BootloaderParameter = 0x%x\n", BootloaderParameter));
525 DEBUG ((DEBUG_INFO,
"Start init Hobs...\n"));
526 #if FixedPcdGetBool (PcdHandOffFdtEnable) == 1
527 HobListPtr =
UplInitHob ((VOID *)BootloaderParameter);
532 if (HobListPtr != 0) {
533 FdtBase = (VOID *)BootloaderParameter;
548 ProcessLibraryConstructorList ();
EFI_GUID gUefiAcpiBoardInfoGuid
VOID *EFIAPI GetFirstHob(IN UINT16 Type)
VOID *EFIAPI GetFirstGuidHob(IN CONST EFI_GUID *Guid)
VOID *EFIAPI BuildGuidDataHob(IN CONST EFI_GUID *Guid, IN VOID *Data, IN UINTN DataLength)
VOID EFIAPI BuildFvHob(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length)
UINTN EFIAPI AsciiStrLen(IN CONST CHAR8 *String)
INTN EFIAPI AsciiStrCmp(IN CONST CHAR8 *FirstString, IN CONST CHAR8 *SecondString)
VOID EFIAPI CpuDeadLoop(VOID)
UINT32 EFIAPI SwapBytes32(IN UINT32 Value)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID HandOffToDxeCore(IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint, IN EFI_PEI_HOB_POINTERS HobList)
INT32 EFIAPI FdtNodeDepth(IN CONST VOID *Fdt, IN INT32 NodeOffset)
CONST FDT_PROPERTY *EFIAPI FdtGetProperty(IN CONST VOID *Fdt, IN INT32 NodeOffset, IN CONST CHAR8 *Name, IN INT32 *Length)
INT32 EFIAPI FdtSubnodeOffsetNameLen(IN CONST VOID *Fdt, IN INT32 ParentOffset, IN CONST CHAR8 *Name, IN INT32 NameLength)
INT32 EFIAPI FdtNextNode(IN CONST VOID *Fdt, IN INT32 Offset, IN INT32 *Depth)
INT32 EFIAPI FdtCheckHeader(IN CONST VOID *Fdt)
CONST CHAR8 *EFIAPI FdtGetName(IN VOID *Fdt, IN INT32 NodeOffset, IN INT32 *Length)
UINTN EFIAPI UplInitHob(IN VOID *FdtBase)
UINTN EFIAPI CustomFdtNodeParser(IN VOID *FdtBase, IN VOID *HostList)
VOID PrintHob(IN CONST VOID *HobStart)
VOID CreatNewHobForHoblist(IN UINTN BootloaderParameter)
EFI_STATUS BuildFitLoadablesFvHob(OUT EFI_FIRMWARE_VOLUME_HEADER **DxeFv)
EFI_STATUS FixUpPcdDatabase(IN EFI_FIRMWARE_VOLUME_HEADER *DxeFv)
CHAR8 *EFIAPI AsciiStrBrk(IN CHAR8 *String, IN CHAR8 *CharSet)
UINTN EFIAPI AsciiStrSpn(IN CHAR8 *String, IN CHAR8 *CharSet)
CHAR8 *EFIAPI AsciiStrTokenLine(IN CHAR8 *String OPTIONAL, IN CHAR8 *CharSet)
EFI_STATUS FitBuildHobs(IN UINTN NewFdtBase, OUT EFI_FIRMWARE_VOLUME_HEADER **DxeFv)
EFI_STATUS EFIAPI FitUplEntryPoint(IN UINTN BootloaderParameter)
ACPI_BOARD_INFO * BuildHobFromAcpi(IN UINT64 AcpiTableBase)
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)
BOOLEAN IsHobNeed(EFI_PEI_HOB_POINTERS Hob)
EFI_HOB_RESOURCE_DESCRIPTOR * FindAnotherHighestBelow4GResourceDescriptor(IN VOID *HobList, IN UINTN MinimalNeededSize, IN EFI_HOB_RESOURCE_DESCRIPTOR *ExceptResourceHob)
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 GLOBAL_REMOVE_IF_UNREFERENCED
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define DEBUG_CODE(Expression)
VOID *EFIAPI PayloadAllocatePages(IN UINTN Pages, IN EFI_MEMORY_TYPE MemoryType)
#define FixedPcdGet32(TokenName)
#define PcdGet8(TokenName)
#define FixedPcdGetBool(TokenName)
#define PcdGetPtr(TokenName)
UINT64 EFI_PHYSICAL_ADDRESS
EFI_PHYSICAL_ADDRESS BaseAddress
EFI_PHYSICAL_ADDRESS EfiFreeMemoryBottom
EFI_PHYSICAL_ADDRESS EfiMemoryTop
EFI_PHYSICAL_ADDRESS EfiFreeMemoryTop
EFI_PHYSICAL_ADDRESS EfiMemoryBottom
EFI_PHYSICAL_ADDRESS PhysicalStart