diff --git a/EmulatorPkg/Win/Host/WinHost.c b/EmulatorPkg/Win/Host/WinHost.c index a78ca2acff..9a5201f4d1 100644 --- a/EmulatorPkg/Win/Host/WinHost.c +++ b/EmulatorPkg/Win/Host/WinHost.c @@ -452,6 +452,28 @@ Returns: UINTN ResetJumpCode; EMU_THUNK_PPI *SecEmuThunkPpi; + // + // If enabled use the magic page to communicate between modules + // This replaces the PI PeiServicesTable pointer mechanism that + // deos not work in the emulator. It also allows the removal of + // writable globals from SEC, PEI_CORE (libraries), PEIMs + // + EmuMagicPage = (VOID *)(UINTN)(FixedPcdGet64 (PcdPeiServicesTablePage) & MAX_UINTN); + if (EmuMagicPage != NULL) { + UINT64 Size; + Status = WinNtOpenFile ( + NULL, + SIZE_4KB, + 0, + &EmuMagicPage, + &Size + ); + if (EFI_ERROR (Status)) { + SecPrint ("ERROR : Could not allocate PeiServicesTablePage @ %p\n\r", EmuMagicPage); + return EFI_DEVICE_ERROR; + } + } + // // Enable the privilege so that RTC driver can successfully run SetTime() // @@ -575,28 +597,6 @@ Returns: exit (1); } - // - // If enabled use the magic page to communicate between modules - // This replaces the PI PeiServicesTable pointer mechanism that - // deos not work in the emulator. It also allows the removal of - // writable globals from SEC, PEI_CORE (libraries), PEIMs - // - EmuMagicPage = (VOID *)(UINTN)(FixedPcdGet64 (PcdPeiServicesTablePage) & MAX_UINTN); - if (EmuMagicPage != NULL) { - UINT64 Size; - Status = WinNtOpenFile ( - NULL, - SIZE_4KB, - 0, - &EmuMagicPage, - &Size - ); - if (EFI_ERROR (Status)) { - SecPrint ("ERROR : Could not allocate PeiServicesTablePage @ %p\n\r", EmuMagicPage); - return EFI_DEVICE_ERROR; - } - } - // // Open All the firmware volumes and remember the info in the gFdInfo global // Meanwhile, find the SEC Core.