16EFI_GUID mBootScriptExecutorImageGuid = {
17 0x9a8d3433, 0x9fe8, 0x42b6, { 0x87, 0xb, 0x1e, 0x31, 0xc8, 0x4e, 0xbe, 0x3b }
20BOOLEAN mPage1GSupport =
FALSE;
21UINT64 mAddressEncMask = 0;
44 UINTN TempStack[0x10];
45 UINTN AsmTransferControl16Address;
46 IA32_DESCRIPTOR IdtDescriptor;
75 if (EFI_ERROR (Status)) {
90 if (PeiS3ResumeState != 0) {
95 PeiS3ResumeState->ReturnStatus = (UINT64)(
UINTN)Status;
100 DEBUG ((DEBUG_INFO,
"Call AsmDisablePaging64() to return to S3 Resume in PEI Phase\n"));
103 if ((Facs !=
NULL) &&
105 (Facs->FirmwareWakingVector != 0))
111 AsmFixAddress16 = (UINT32)AsmTransferControl16Address;
112 AsmJmpAddr32 = (UINT32)((Facs->FirmwareWakingVector & 0xF) | ((Facs->FirmwareWakingVector & 0xFFFF0) << 12));
116 PeiS3ResumeState->ReturnCs,
117 (UINT32)PeiS3ResumeState->ReturnEntryPoint,
118 (UINT32)(
UINTN)AcpiS3Context,
119 (UINT32)(
UINTN)PeiS3ResumeState,
120 (UINT32)PeiS3ResumeState->ReturnStackPointer
126 DEBUG ((DEBUG_INFO,
"Call SwitchStack() to return to S3 Resume in PEI Phase\n"));
131 (VOID *)(
UINTN)AcpiS3Context,
132 (VOID *)(
UINTN)PeiS3ResumeState,
133 (VOID *)(
UINTN)PeiS3ResumeState->ReturnStackPointer
141 return EFI_UNSUPPORTED;
147 if (Facs->XFirmwareWakingVector != 0) {
151 TempStackTop = (
UINTN)&TempStack +
sizeof (TempStack);
153 ((Facs->Flags & EFI_ACPI_4_0_64BIT_WAKE_SUPPORTED_F) != 0) &&
159 DEBUG ((DEBUG_INFO,
"Transfer from 64bit DXE to 64bit OS waking vector - %x\r\n", (
UINTN)Facs->XFirmwareWakingVector));
160 if (
sizeof (
UINTN) ==
sizeof (UINT64)) {
168 (VOID *)(
UINTN)TempStackTop
172 DEBUG ((DEBUG_ERROR,
"Unsupported for 32bit DXE transfer to 64bit OS waking vector!\r\n"));
179 DEBUG ((DEBUG_INFO,
"Transfer to 32bit OS waking vector - %x\r\n", (
UINTN)Facs->XFirmwareWakingVector));
180 if (
sizeof (
UINTN) ==
sizeof (UINT64)) {
186 (UINT32)Facs->XFirmwareWakingVector,
199 (VOID *)(
UINTN)TempStackTop
207 DEBUG ((DEBUG_INFO,
"Transfer to 16bit OS waking vector - %x\r\n", (
UINTN)Facs->FirmwareWakingVector));
215 return EFI_UNSUPPORTED;
230 IN PHYSICAL_ADDRESS ImageBase,
232 IN EFI_FV_FILETYPE FileType
240 if ((
PcdGet8 (PcdMemoryProfilePropertyMask) & BIT0) != 0) {
242 Status =
gBS->LocateProtocol (&gEdkiiMemoryProfileGuid,
NULL, (VOID **)&ProfileProtocol);
243 if (!EFI_ERROR (Status)) {
247 Status = ProfileProtocol->RegisterImage (
282 Status =
gBS->LocateProtocol (&gEfiDxeSmmReadyToLockProtocolGuid,
NULL, &Interface);
283 if (EFI_ERROR (Status)) {
290 NewImageHandle =
NULL;
291 Status =
gBS->InstallProtocolInterface (
310 ImageContext.
Handle = Buffer;
323 FfsBuffer = 0xFFFFFFFF;
324 Status =
gBS->AllocatePages (
335 Status =
gDS->GetMemorySpaceDescriptor (FfsBuffer, &MemDesc);
336 if (!EFI_ERROR (Status) && ((MemDesc.
Attributes & EFI_MEMORY_XP) != 0)) {
337 gDS->SetMemorySpaceAttributes (
365 gBS->FreePool (Buffer);
376 EFI_FV_FILETYPE_DRIVER
387 &mBootScriptExecutorImageGuid,
393 Status =
SetLockBoxAttributes (&mBootScriptExecutorImageGuid, LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE);
396 gBS->CloseEvent (Event);
428 return EFI_UNSUPPORTED;
434 mAddressEncMask =
PcdGet64 (PcdPteMemoryEncryptionAddressOrMask) & PAGING_1G_ADDRESS_MASK_64;
441 Status =
gBS->LocateProtocol (&gEfiCallerIdGuid,
NULL, &DevicePath);
442 if (EFI_ERROR (Status)) {
448 &gEfiDxeSmmReadyToLockProtocolGuid,
454 ASSERT (ReadyToLockEvent !=
NULL);
461 if (RegEax >= 0x80000001) {
463 if ((RegEdx & BIT26) != 0) {
464 mPage1GSupport =
TRUE;
471 BootScriptExecutorBuffer = 0xFFFFFFFF;
473 Status =
gBS->AllocatePages (
477 &BootScriptExecutorBuffer
485 &gEfiBootScriptExecutorVariableGuid,
486 &BootScriptExecutorBuffer,
487 sizeof (BootScriptExecutorBuffer)
496 &gEfiBootScriptExecutorContextGuid,
497 EfiBootScriptExecutorVariable,
498 sizeof (*EfiBootScriptExecutorVariable)
502 Status =
SetLockBoxAttributes (&gEfiBootScriptExecutorContextGuid, LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE);
#define EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE
#define EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_VERSION
#define EFI_ACPI_4_0_OSPM_64BIT_WAKE__F
VOID *EFIAPI InvalidateInstructionCacheRange(IN VOID *Address, IN UINTN Length)
VOID EFIAPI SwitchStack(IN SWITCH_STACK_ENTRY_POINT EntryPoint, IN VOID *Context1 OPTIONAL, IN VOID *Context2 OPTIONAL, IN VOID *NewStack,...)
VOID EFIAPI CpuDeadLoop(VOID)
VOID(EFIAPI * SWITCH_STACK_ENTRY_POINT)(IN VOID *Context1 OPTIONAL, IN VOID *Context2 OPTIONAL)
RETURN_STATUS EFIAPI S3BootScriptExecute(VOID)
BOOLEAN EFIAPI SaveAndSetDebugTimerInterrupt(IN BOOLEAN EnableStatus)
VOID EFIAPI InitializeDebugAgent(IN UINT32 InitFlag, IN VOID *Context OPTIONAL, IN DEBUG_AGENT_CONTINUE Function OPTIONAL)
VOID EFIAPI SetDevicePathEndNode(OUT VOID *Node)
EFI_STATUS EFIAPI GetSectionFromAnyFv(IN CONST EFI_GUID *NameGuid, IN EFI_SECTION_TYPE SectionType, IN UINTN SectionInstance, OUT VOID **Buffer, OUT UINTN *Size)
VOID SetIdtEntry(IN ACPI_S3_CONTEXT *AcpiS3Context)
VOID EFIAPI AsmWbinvd(VOID)
RETURN_STATUS EFIAPI SetLockBoxAttributes(IN GUID *Guid, IN UINT64 Attributes)
RETURN_STATUS EFIAPI SaveLockBox(IN GUID *Guid, IN VOID *Buffer, IN UINTN Length)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
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 PcdGet8(TokenName)
#define PcdGetBool(TokenName)
#define FeaturePcdGet(TokenName)
RETURN_STATUS EFIAPI PeCoffLoaderLoadImage(IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext)
RETURN_STATUS EFIAPI PeCoffLoaderRelocateImage(IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext)
RETURN_STATUS EFIAPI PeCoffLoaderGetImageInfo(IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext)
RETURN_STATUS EFIAPI PeCoffLoaderImageReadFromMemory(IN VOID *FileHandle, IN UINTN FileOffset, IN OUT UINTN *ReadSize, OUT VOID *Buffer)
VOID EFIAPI ReadyToLockEventNotify(IN EFI_EVENT Event, IN VOID *Context)
VOID RegisterMemoryProfileImage(IN EFI_GUID *FileName, IN PHYSICAL_ADDRESS ImageBase, IN UINT64 ImageSize, IN EFI_FV_FILETYPE FileType)
EFI_STATUS EFIAPI BootScriptExecutorEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS EFIAPI S3BootScriptExecutorEntryFunction(IN ACPI_S3_CONTEXT *AcpiS3Context, IN PEI_S3_RESUME_STATE *PeiS3ResumeState)
VOID AsmTransferControl16(VOID)
VOID AsmTransferControl(IN UINT32 S3WakingVector, IN UINT32 AcpiLowMemoryBase)
VOID AsmTransferControl32(IN UINT32 S3WakingVector, IN UINT32 AcpiLowMemoryBase)
UINT64 EFI_PHYSICAL_ADDRESS
#define EFI_PAGES_TO_SIZE(Pages)
#define EFI_SIZE_TO_PAGES(Size)
VOID EFIAPI EfiInitializeFwVolDevicepathNode(IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode, IN CONST EFI_GUID *NameGuid)
EFI_EVENT EFIAPI EfiCreateProtocolNotifyEvent(IN EFI_GUID *ProtocolGuid, IN EFI_TPL NotifyTpl, IN EFI_EVENT_NOTIFY NotifyFunction, IN VOID *NotifyContext OPTIONAL, OUT VOID **Registration)
EFI_STATUS(EFIAPI * EFI_IMAGE_ENTRY_POINT)(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
VOID EFIAPI AsmDisablePaging64(IN UINT16 Cs, IN UINT32 EntryPoint, IN UINT32 Context1 OPTIONAL, IN UINT32 Context2 OPTIONAL, IN UINT32 NewStack)
VOID EFIAPI AsmReadIdtr(OUT IA32_DESCRIPTOR *Idtr)
PE_COFF_LOADER_READ_FILE ImageRead
PHYSICAL_ADDRESS EntryPoint
PHYSICAL_ADDRESS ImageAddress