13#define DEFAULT_SG_LIST_HEADS (20)
22 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
25 { 0xffff, 0, 0, 0x3, 1, 0, 1, 0xf, 0, 0, 1, 1, 0 }
28 { 0xffff, 0, 0, 0xf, 1, 0, 1, 0xf, 0, 0, 1, 1, 0 }
31 { 0xffff, 0, 0, 0x3, 1, 0, 1, 0xf, 0, 0, 1, 1, 0 }
34 { 0xffff, 0, 0, 0xb, 1, 0, 1, 0xf, 0, 0, 1, 1, 0 }
37 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
40 { 0xffff, 0, 0, 0x3, 1, 0, 1, 0xf, 0, 0, 1, 1, 0 }
43 { 0xffff, 0, 0, 0xb, 1, 0, 1, 0xf, 0, 1, 0, 1, 0 }
46 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
54 sizeof (mGdtEntries) - 1,
72 BOOLEAN Page1GSupport;
74 Page1GSupport =
FALSE;
77 if (RegEax >= 0x80000001) {
79 if ((RegEdx & BIT26) != 0) {
97CalculatePageTableSize (
98 IN BOOLEAN Page1GSupport
101 UINTN ExtraPageTablePages;
103 UINT8 PhysicalAddressBits;
104 UINT32 NumberOfPml4EntriesNeeded;
105 UINT32 NumberOfPdpEntriesNeeded;
111 PhysicalAddressBits = 32;
112 ExtraPageTablePages = EXTRA_PAGE_TABLE_PAGES;
117 if (PhysicalAddressBits <= 39 ) {
118 NumberOfPml4EntriesNeeded = 1;
119 NumberOfPdpEntriesNeeded = (UINT32)
LShiftU64 (1, (PhysicalAddressBits - 30));
121 NumberOfPml4EntriesNeeded = (UINT32)
LShiftU64 (1, (PhysicalAddressBits - 39));
122 NumberOfPdpEntriesNeeded = 512;
125 if (!Page1GSupport) {
126 TotalPagesNum = (NumberOfPdpEntriesNeeded + 1) * NumberOfPml4EntriesNeeded + 1;
128 TotalPagesNum = NumberOfPml4EntriesNeeded + 1;
131 TotalPagesNum += ExtraPageTablePages;
147 IN BOOLEAN Page1GSupport
150 UINT8 PhysicalAddressBits;
152 UINTN IndexOfPml4Entries;
153 UINTN IndexOfPdpEntries;
154 UINTN IndexOfPageDirectoryEntries;
155 UINT32 NumberOfPml4EntriesNeeded;
156 UINT32 NumberOfPdpEntriesNeeded;
161 UINTN BigPageAddress;
163 UINT64 AddressEncMask;
168 AddressEncMask =
PcdGet64 (PcdPteMemoryEncryptionAddressOrMask) & PAGING_1G_ADDRESS_MASK_64;
174 PhysicalAddressBits = 32;
179 if (PhysicalAddressBits <= 39 ) {
180 NumberOfPml4EntriesNeeded = 1;
181 NumberOfPdpEntriesNeeded = (UINT32)
LShiftU64 (1, (PhysicalAddressBits - 30));
183 NumberOfPml4EntriesNeeded = (UINT32)
LShiftU64 (1, (PhysicalAddressBits - 39));
184 NumberOfPdpEntriesNeeded = 512;
190 BigPageAddress = (
UINTN)PageTablesAddress;
195 PageMap = (VOID *)BigPageAddress;
196 BigPageAddress += SIZE_4KB;
198 PageMapLevel4Entry = PageMap;
200 for (IndexOfPml4Entries = 0; IndexOfPml4Entries < NumberOfPml4EntriesNeeded; IndexOfPml4Entries++, PageMapLevel4Entry++) {
205 PageDirectoryPointerEntry = (VOID *)BigPageAddress;
206 BigPageAddress += SIZE_4KB;
211 PageMapLevel4Entry->Uint64 = (UINT64)(
UINTN)PageDirectoryPointerEntry | AddressEncMask;
212 PageMapLevel4Entry->Bits.ReadWrite = 1;
213 PageMapLevel4Entry->Bits.Present = 1;
216 PageDirectory1GEntry = (VOID *)PageDirectoryPointerEntry;
218 for (IndexOfPageDirectoryEntries = 0; IndexOfPageDirectoryEntries < 512; IndexOfPageDirectoryEntries++, PageDirectory1GEntry++, PageAddress += SIZE_1GB) {
222 PageDirectory1GEntry->Uint64 = (UINT64)PageAddress | AddressEncMask;
223 PageDirectory1GEntry->Bits.ReadWrite = 1;
224 PageDirectory1GEntry->Bits.Present = 1;
225 PageDirectory1GEntry->Bits.MustBe1 = 1;
228 for (IndexOfPdpEntries = 0; IndexOfPdpEntries < NumberOfPdpEntriesNeeded; IndexOfPdpEntries++, PageDirectoryPointerEntry++) {
233 PageDirectoryEntry = (VOID *)BigPageAddress;
234 BigPageAddress += SIZE_4KB;
239 PageDirectoryPointerEntry->Uint64 = (UINT64)(
UINTN)PageDirectoryEntry | AddressEncMask;
240 PageDirectoryPointerEntry->Bits.ReadWrite = 1;
241 PageDirectoryPointerEntry->Bits.Present = 1;
243 for (IndexOfPageDirectoryEntries = 0; IndexOfPageDirectoryEntries < 512; IndexOfPageDirectoryEntries++, PageDirectoryEntry++, PageAddress += SIZE_2MB) {
247 PageDirectoryEntry->Uint64 = (UINT64)PageAddress | AddressEncMask;
248 PageDirectoryEntry->Bits.ReadWrite = 1;
249 PageDirectoryEntry->Bits.Present = 1;
250 PageDirectoryEntry->Bits.MustBe1 = 1;
254 for ( ; IndexOfPdpEntries < 512; IndexOfPdpEntries++, PageDirectoryPointerEntry++) {
256 PageDirectoryPointerEntry,
266 for ( ; IndexOfPml4Entries < 512; IndexOfPml4Entries++, PageMapLevel4Entry++) {
283 SWITCH_32_TO_64_CONTEXT *EntrypointContext,
284 SWITCH_64_TO_32_CONTEXT *ReturnContext
295 LongJump ((BASE_LIBRARY_JUMP_BUFFER *)(
UINTN)EntrypointContext->JumpBuffer, 1);
316 SWITCH_32_TO_64_CONTEXT *Context,
317 SWITCH_64_TO_32_CONTEXT *ReturnContext
326 SetJumpFlag =
SetJump ((BASE_LIBRARY_JUMP_BUFFER *)(
UINTN)Context->JumpBuffer);
328 if (SetJumpFlag == 0) {
332 Create4GPageTables (PageTableAddress, Context->Page1GSupport);
346 "%a() Stack Base: 0x%lx, Stack Size: 0x%lx\n",
348 Context->StackBufferBase,
349 Context->StackBufferLength
361 (UINT64)Context->EntryPoint,
362 (UINT64)(
UINTN)Context,
363 (UINT64)(
UINTN)ReturnContext,
364 Context->StackBufferBase + Context->StackBufferLength
372 if ((
UINTN)ReturnContext->ReturnStatus != 0) {
396 IN COALESCE_ENTRY CoalesceEntry,
399 IN OUT VOID **MemoryBase,
407 SWITCH_32_TO_64_CONTEXT Context;
408 SWITCH_64_TO_32_CONTEXT ReturnContext;
409 BASE_LIBRARY_JUMP_BUFFER JumpBuffer;
412 BOOLEAN Page1GSupport;
414 ZeroMem (&Context,
sizeof (SWITCH_32_TO_64_CONTEXT));
415 ZeroMem (&ReturnContext,
sizeof (SWITCH_64_TO_32_CONTEXT));
417 MemoryBase64 = (UINT64)(
UINTN)*MemoryBase;
418 MemorySize64 = (UINT64)(
UINTN)*MemorySize;
419 MemoryEnd64 = MemoryBase64 + MemorySize64;
421 Page1GSupport = IsPage1GSupport ();
426 if (LongModeBuffer->StackBaseAddress < LongModeBuffer->PageTableAddress) {
427 ReservedRangeBase = LongModeBuffer->StackBaseAddress;
428 ReservedRangeEnd = LongModeBuffer->PageTableAddress + CalculatePageTableSize (Page1GSupport);
430 ReservedRangeBase = LongModeBuffer->PageTableAddress;
431 ReservedRangeEnd = LongModeBuffer->StackBaseAddress + LongModeBuffer->StackSize;
438 if (ReservedRangeBase <= MemoryBase64) {
439 if (ReservedRangeEnd < MemoryEnd64) {
440 MemoryBase64 = ReservedRangeEnd;
442 DEBUG ((DEBUG_ERROR,
"Memory is not enough to process capsule!\n"));
443 return EFI_OUT_OF_RESOURCES;
445 }
else if (ReservedRangeBase < MemoryEnd64) {
446 if ((ReservedRangeEnd < MemoryEnd64) &&
447 (ReservedRangeBase - MemoryBase64 < MemoryEnd64 - ReservedRangeEnd))
449 MemoryBase64 = ReservedRangeEnd;
451 MemorySize64 = (UINT64)(
UINTN)(ReservedRangeBase - MemoryBase64);
459 Context.StackBufferBase = LongModeBuffer->StackBaseAddress;
460 Context.StackBufferLength = LongModeBuffer->StackSize;
462 Context.BlockListAddr = BlockListAddr;
466 Context.Page1GSupport = Page1GSupport;
467 Context.AddressEncMask =
PcdGet64 (PcdPteMemoryEncryptionAddressOrMask) & PAGING_1G_ADDRESS_MASK_64;
472 ReturnContext.ReturnCs = 0x10;
477 ReturnContext.ReturnStatus = 0;
482 AsmReadGdtr ((IA32_DESCRIPTOR *)&ReturnContext.Gdtr);
484 Status = Thunk32To64 (LongModeBuffer->PageTableAddress, &Context, &ReturnContext);
486 if (!EFI_ERROR (Status)) {
487 *MemoryBase = (VOID *)(
UINTN)MemoryBase64;
488 *MemorySize = (
UINTN)MemorySize64;
505FindCapsuleCoalesceImage (
507 OUT UINT16 *CoalesceImageMachineType
516 UINT64 CoalesceImageSize;
517 UINT32 AuthenticationState;
523 if (EFI_ERROR (Status)) {
528 if (!EFI_ERROR (Status)) {
532 Status = LoadFile->LoadFile (
535 &CoalesceImageAddress,
537 CoalesceImageEntryPoint,
540 if (EFI_ERROR (Status)) {
541 DEBUG ((DEBUG_ERROR,
"Unable to find PE32 section in CapsuleX64 image ffs %r!\n", Status));
545 *CoalesceImageMachineType = PeCoffLoaderGetMachineType ((VOID *)(
UINTN)CoalesceImageAddress);
574 &gEfiPeiReadOnlyVariable2PpiGuid,
577 (VOID **)&PPIVariableServices
582 Status = PPIVariableServices->GetVariable (
584 EFI_CAPSULE_LONG_MODE_BUFFER_NAME,
585 &gEfiCapsuleVendorGuid,
590 if (EFI_ERROR (Status)) {
591 DEBUG ((DEBUG_ERROR,
"Error Get LongModeBuffer variable %r!\n", Status));
599#if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
608GetPhysicalAddressBits (
613 UINT8 PhysicalAddressBits;
621 PhysicalAddressBits = ((
EFI_HOB_CPU *)Hob)->SizeOfMemorySpace;
624 if (RegEax >= 0x80000008) {
626 PhysicalAddressBits = (UINT8)RegEax;
628 PhysicalAddressBits = 36;
635 ASSERT (PhysicalAddressBits <= 52);
636 if (PhysicalAddressBits > 48) {
637 PhysicalAddressBits = 48;
640 return PhysicalAddressBits;
660 MemoryResourceEntry = MemoryResource;
661 NextMemoryResourceEntry = MemoryResource + 1;
670 NextMemoryResourceEntry = NextMemoryResourceEntry + 1;
673 MemoryResourceEntry = MemoryResourceEntry + 1;
674 NextMemoryResourceEntry = MemoryResourceEntry + 1;
694 MemoryResourceEntry = MemoryResource;
695 NewMemoryResourceEntry = MemoryResource;
698 NextMemoryResourceEntry = MemoryResourceEntry + 1;
704 if (NewMemoryResourceEntry != MemoryResourceEntry) {
708 NextMemoryResourceEntry = NextMemoryResourceEntry + 1;
711 MemoryResourceEntry = NextMemoryResourceEntry;
712 NewMemoryResourceEntry = NewMemoryResourceEntry + 1;
718 MemoryResourceEnd = NewMemoryResourceEntry;
745 Hob.Raw =
GetFirstHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR);
746 while (Hob.Raw !=
NULL) {
748 if (ResourceDescriptor->
ResourceType == EFI_RESOURCE_SYSTEM_MEMORY) {
752 Hob.Raw = GET_NEXT_HOB (Hob);
753 Hob.Raw =
GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, Hob.Raw);
757 DEBUG ((DEBUG_INFO | DEBUG_WARN,
"No memory resource descriptor reported in HOB list before capsule Coalesce\n"));
758 #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
767 MemoryResource[0].PhysicalStart = 0;
768 MemoryResource[0].ResourceLength =
LShiftU64 (1, GetPhysicalAddressBits ());
771 "MemoryResource[0x0] - Start(0x%0lx) Length(0x%0lx)\n",
772 MemoryResource[0x0].PhysicalStart,
773 MemoryResource[0x0].ResourceLength
775 return MemoryResource;
793 Hob.Raw =
GetFirstHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR);
794 while (Hob.Raw !=
NULL) {
796 if (ResourceDescriptor->
ResourceType == EFI_RESOURCE_SYSTEM_MEMORY) {
799 "MemoryResource[0x%x] - Start(0x%0lx) Length(0x%0lx)\n",
809 Hob.Raw = GET_NEXT_HOB (Hob);
810 Hob.Raw =
GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, Hob.Raw);
816 DEBUG ((DEBUG_INFO,
"Dump MemoryResource[] after sorted and merged\n"));
817 for (Index = 0; MemoryResource[Index].
ResourceLength != 0; Index++) {
820 " MemoryResource[0x%x] - Start(0x%0lx) Length(0x%0lx)\n",
822 MemoryResource[Index].PhysicalStart,
823 MemoryResource[Index].ResourceLength
827 return MemoryResource;
847 CapsuleDataPtr64 = 0;
850 &gEfiPeiReadOnlyVariable2PpiGuid,
853 (VOID **)&PPIVariableServices
856 if (EFI_ERROR (Status)) {
857 DEBUG ((DEBUG_ERROR,
"Failed to find ReadOnlyVariable2PPI\n"));
864 Size =
sizeof (CapsuleDataPtr64);
865 Status = PPIVariableServices->GetVariable (
868 &gEfiCapsuleVendorGuid,
871 (VOID *)&CapsuleDataPtr64
874 if (!EFI_ERROR (Status)) {
905 CHAR16 CapsuleVarName[30];
911 UINTN TempListLength;
915 CapsuleVarName[0] = 0;
917 CapsuleDataPtr64 = 0;
919 if ((ListLength ==
NULL) || (HeadList ==
NULL)) {
920 DEBUG ((DEBUG_ERROR,
"%a Invalid parameters. Inputs can't be NULL\n", __func__));
921 ASSERT (ListLength !=
NULL);
922 ASSERT (HeadList !=
NULL);
923 return EFI_INVALID_PARAMETER;
930 &gEfiPeiReadOnlyVariable2PpiGuid,
933 (VOID **)&PPIVariableServices
936 if (EFI_ERROR (Status)) {
937 DEBUG ((DEBUG_ERROR,
"Failed to find ReadOnlyVariable2PPI\n"));
946 if (TempList ==
NULL) {
947 DEBUG ((DEBUG_ERROR,
"Failed to allocate memory\n"));
948 return EFI_OUT_OF_RESOURCES;
955 TempVarName = CapsuleVarName +
StrLen (CapsuleVarName);
960 (
sizeof (CapsuleVarName) - ((
UINTN)TempVarName - (
UINTN)CapsuleVarName)),
967 Size =
sizeof (CapsuleDataPtr64);
968 Status = PPIVariableServices->GetVariable (
971 &gEfiCapsuleVendorGuid,
974 (VOID *)&CapsuleDataPtr64
977 if (EFI_ERROR (Status)) {
978 if (Status != EFI_NOT_FOUND) {
979 DEBUG ((DEBUG_ERROR,
"Unexpected error getting Capsule Update variable. Status = %r\n", Status));
989 for (TempIndex = 0; TempIndex < ValidIndex; TempIndex++) {
990 if (TempList[TempIndex] == CapsuleDataPtr64) {
1004 if ((ValidIndex + 1) >= TempListLength) {
1006 if (EnlargedTempList ==
NULL) {
1007 DEBUG ((DEBUG_ERROR,
"Fail to allocate memory!\n"));
1008 return EFI_OUT_OF_RESOURCES;
1011 CopyMem (EnlargedTempList, TempList, TempListLength);
1013 TempList = EnlargedTempList;
1014 TempListLength *= 2;
1020 TempList[ValidIndex++] = CapsuleDataPtr64;
1024 if (ValidIndex == 0) {
1025 DEBUG ((DEBUG_ERROR,
"%a didn't find any SG lists in variables\n", __func__));
1026 return EFI_NOT_FOUND;
1030 if (*HeadList ==
NULL) {
1031 DEBUG ((DEBUG_ERROR,
"Failed to allocate memory\n"));
1032 return EFI_OUT_OF_RESOURCES;
1036 *ListLength = ValidIndex;
1068 IN OUT VOID **MemoryBase,
1079 UINT16 CoalesceImageMachineType;
1081 COALESCE_ENTRY CoalesceEntry;
1086 VariableArrayAddress =
NULL;
1093 if (EFI_ERROR (Status) || (BootMode != BOOT_ON_FLASH_UPDATE)) {
1094 DEBUG ((DEBUG_ERROR,
"Boot mode is not correct for capsule update path.\n"));
1095 Status = EFI_NOT_FOUND;
1103 if (EFI_ERROR (Status) || (VariableArrayAddress ==
NULL)) {
1104 DEBUG ((DEBUG_ERROR,
"%a failed to get Scatter Gather List Head Entries. Status = %r\n", __func__, Status));
1119 CoalesceImageEntryPoint = 0;
1120 Status = GetLongModeContext (&LongModeBuffer);
1121 if (EFI_ERROR (Status)) {
1122 DEBUG ((DEBUG_ERROR,
"Fail to find the variable for long mode context!\n"));
1123 Status = EFI_NOT_FOUND;
1127 Status = FindCapsuleCoalesceImage (&CoalesceImageEntryPoint, &CoalesceImageMachineType);
1129 DEBUG ((DEBUG_ERROR,
"Fail to find CapsuleX64 module in FV!\n"));
1130 Status = EFI_NOT_FOUND;
1134 ASSERT (CoalesceImageEntryPoint != 0);
1135 CoalesceEntry = (COALESCE_ENTRY)(
UINTN)CoalesceImageEntryPoint;
1136 Status = ModeSwitch (&LongModeBuffer, CoalesceEntry, (
EFI_PHYSICAL_ADDRESS)(
UINTN)VariableArrayAddress, MemoryResource, MemoryBase, MemorySize);
1151 DEBUG ((DEBUG_INFO,
"Capsule Coalesce Status = %r!\n", Status));
1153 if (Status == EFI_BUFFER_TOO_SMALL) {
1154 DEBUG ((DEBUG_ERROR,
"There is not enough memory to process capsule!\n"));
1157 if (Status == EFI_NOT_FOUND) {
1158 DEBUG ((DEBUG_ERROR,
"Fail to parse capsule descriptor in memory!\n"));
1160 EFI_ERROR_CODE | EFI_ERROR_MAJOR,
1161 (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_EC_INVALID_CAPSULE_DESCRIPTOR)
1187 return EFI_NOT_FOUND;
1206 IN VOID *CapsuleBase
1220 TestPtr = (UINT32 *)CapsuleBase;
1224 if (*TestPtr == 0x54534554) {
1226 DEBUG ((DEBUG_INFO,
"Capsule test pattern mode activated...\n"));
1227 TestSize = TestPtr[1] /
sizeof (UINT32);
1233 while (TestSize > 0) {
1234 if (*TestPtr != TestCounter) {
1244 DEBUG ((DEBUG_INFO,
"Capsule test pattern mode SUCCESS\n"));
1271 IN VOID *CapsuleBase,
1279 UINTN CapsuleNumber;
1285 if (PrivateData->Signature != EFI_CAPSULE_PEIM_PRIVATE_DATA_SIGNATURE) {
1286 return EFI_VOLUME_CORRUPTED;
1289 if (PrivateData->CapsuleAllImageSize >=
MAX_ADDRESS) {
1290 DEBUG ((DEBUG_ERROR,
"CapsuleAllImageSize too big - 0x%lx\n", PrivateData->CapsuleAllImageSize));
1291 return EFI_OUT_OF_RESOURCES;
1295 DEBUG ((DEBUG_ERROR,
"CapsuleNumber too big - 0x%lx\n", PrivateData->CapsuleNumber));
1296 return EFI_OUT_OF_RESOURCES;
1302 Size = (
UINTN)PrivateData->CapsuleAllImageSize;
1303 CapsuleNumber = (
UINTN)PrivateData->CapsuleNumber;
1314 DEBUG ((DEBUG_ERROR,
"AllocatePages Failed!\n"));
1337 for (Index = 0; Index < CapsuleNumber; Index++) {
1338 BaseAddress = NewBuffer + PrivateData->CapsuleOffset[Index];
1354 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
1355 &gEfiPeiCapsulePpiGuid,
VOID *EFIAPI GetFirstHob(IN UINT16 Type)
VOID *EFIAPI GetNextHob(IN UINT16 Type, IN CONST VOID *HobStart)
VOID EFIAPI BuildCvHob(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length)
RETURN_STATUS EFIAPI StrCpyS(OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source)
RETURNS_TWICE UINTN EFIAPI SetJump(OUT BASE_LIBRARY_JUMP_BUFFER *JumpBuffer)
UINT64 EFIAPI LShiftU64(IN UINT64 Operand, IN UINTN Count)
VOID EFIAPI LongJump(IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer, IN UINTN Value)
UINTN EFIAPI StrLen(IN CONST CHAR16 *String)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
EFI_STATUS EFIAPI CapsuleDataCoalesce(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PHYSICAL_ADDRESS *BlockListBuffer, IN MEMORY_RESOURCE_DESCRIPTOR *MemoryResource, IN OUT VOID **MemoryBase, IN OUT UINTN *MemorySize)
#define EFI_CAPSULE_VARIABLE_NAME
BOOLEAN EFIAPI SaveAndSetDebugTimerInterrupt(IN BOOLEAN EnableStatus)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STATUS EFIAPI PeiServicesFfsFindNextVolume(IN UINTN Instance, IN OUT EFI_PEI_FV_HANDLE *VolumeHandle)
EFI_STATUS EFIAPI PeiServicesGetBootMode(OUT EFI_BOOT_MODE *BootMode)
EFI_STATUS EFIAPI PeiServicesAllocatePool(IN UINTN Size, OUT VOID **Buffer)
EFI_STATUS EFIAPI PeiServicesLocatePpi(IN CONST EFI_GUID *Guid, IN UINTN Instance, IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, IN OUT VOID **Ppi)
EFI_STATUS EFIAPI PeiServicesFfsFindFileByName(IN CONST EFI_GUID *FileName, IN CONST EFI_PEI_FV_HANDLE VolumeHandle, OUT EFI_PEI_FILE_HANDLE *FileHandle)
EFI_STATUS EFIAPI PeiServicesAllocatePages(IN EFI_MEMORY_TYPE MemoryType, IN UINTN Pages, OUT EFI_PHYSICAL_ADDRESS *Memory)
EFI_STATUS EFIAPI PeiServicesInstallPpi(IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList)
UINTN EFIAPI AsmWriteCr3(UINTN Cr3)
RETURN_STATUS EFIAPI UnicodeValueToStringS(IN OUT CHAR16 *Buffer, IN UINTN BufferSize, IN UINTN Flags, IN INT64 Value, IN UINTN Width)
#define ENCODE_ERROR(StatusCode)
#define GLOBAL_REMOVE_IF_UNREFERENCED
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define DEBUG_CODE(Expression)
#define REPORT_STATUS_CODE(Type, Value)
UINT32 EFIAPI AsmCpuid(IN UINT32 Index, OUT UINT32 *RegisterEax OPTIONAL, OUT UINT32 *RegisterEbx OPTIONAL, OUT UINT32 *RegisterEcx OPTIONAL, OUT UINT32 *RegisterEdx OPTIONAL)
#define PcdGet64(TokenName)
#define PcdGetBool(TokenName)
#define PcdGetPtr(TokenName)
#define FeaturePcdGet(TokenName)
VOID * EFI_PEI_FILE_HANDLE
UINT64 EFI_PHYSICAL_ADDRESS
#define EFI_PAGES_TO_SIZE(Pages)
#define EFI_IMAGE_MACHINE_X64
#define EFI_SIZE_TO_PAGES(Size)
MEMORY_RESOURCE_DESCRIPTOR * BuildMemoryResourceDescriptor(VOID)
EFI_STATUS EFIAPI CapsuleMain(IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)
VOID MergeMemoryResourceDescriptor(IN OUT MEMORY_RESOURCE_DESCRIPTOR *MemoryResource)
EFI_STATUS EFIAPI CapsuleCoalesce(IN EFI_PEI_SERVICES **PeiServices, IN OUT VOID **MemoryBase, IN OUT UINTN *MemorySize)
VOID SortMemoryResourceDescriptor(IN OUT MEMORY_RESOURCE_DESCRIPTOR *MemoryResource)
EFI_STATUS EFIAPI CreateState(IN EFI_PEI_SERVICES **PeiServices, IN VOID *CapsuleBase, IN UINTN CapsuleSize)
EFI_STATUS EFIAPI CheckCapsuleUpdate(IN EFI_PEI_SERVICES **PeiServices)
EFI_STATUS GetScatterGatherHeadEntries(OUT UINTN *ListLength, OUT EFI_PHYSICAL_ADDRESS **HeadList)
BOOLEAN CapsuleTestPattern(IN EFI_PEI_SERVICES **PeiServices, IN VOID *CapsuleBase)
BOOLEAN AreCapsulesStaged(VOID)
VOID EFIAPI AsmEnablePaging64(IN UINT16 Cs, IN UINT64 EntryPoint, IN UINT64 Context1 OPTIONAL, IN UINT64 Context2 OPTIONAL, IN UINT64 NewStack)
VOID EFIAPI AsmReadGdtr(OUT IA32_DESCRIPTOR *Gdtr)
VOID EFIAPI AsmWriteGdtr(IN CONST IA32_DESCRIPTOR *Gdtr)
EFI_PHYSICAL_ADDRESS PhysicalStart
EFI_RESOURCE_TYPE ResourceType
EFI_PHYSICAL_ADDRESS PhysicalStart