X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=IntelFrameworkPkg%2FInclude%2FProtocol%2FLegacyBios.h;h=00a149e38783c24089e0ba0afbc4186c7af3da55;hp=641f101bcedeb27902828cd0fb1827294e57bca0;hb=7619eed8aa260c9527d72ccd525ce70060b64f1f;hpb=2b55daaef0f3f53059c5c858ca6fd53b03eb5d4c diff --git a/IntelFrameworkPkg/Include/Protocol/LegacyBios.h b/IntelFrameworkPkg/Include/Protocol/LegacyBios.h index 641f101bce..00a149e387 100644 --- a/IntelFrameworkPkg/Include/Protocol/LegacyBios.h +++ b/IntelFrameworkPkg/Include/Protocol/LegacyBios.h @@ -1518,6 +1518,42 @@ struct _EFI_LEGACY_BIOS_PROTOCOL { EFI_LEGACY_BIOS_BOOT_UNCONVENTIONAL_DEVICE BootUnconventionalDevice; }; +// +// Legacy BIOS needs to access memory in page 0 (0-4095), which is disabled if +// NULL pointer detection feature is enabled. Following macro can be used to +// enable/disable page 0 before/after accessing it. +// +#define ACCESS_PAGE0_CODE(statements) \ + do { \ + EFI_STATUS Status_; \ + EFI_GCD_MEMORY_SPACE_DESCRIPTOR Desc_; \ + \ + Desc_.Attributes = 0; \ + Status_ = gDS->GetMemorySpaceDescriptor (0, &Desc_); \ + ASSERT_EFI_ERROR (Status_); \ + if ((Desc_.Attributes & EFI_MEMORY_RP) != 0) { \ + Status_ = gDS->SetMemorySpaceAttributes ( \ + 0, \ + EFI_PAGES_TO_SIZE(1), \ + Desc_.Attributes & ~(UINT64)EFI_MEMORY_RP \ + ); \ + ASSERT_EFI_ERROR (Status_); \ + } \ + \ + { \ + statements; \ + } \ + \ + if ((Desc_.Attributes & EFI_MEMORY_RP) != 0) { \ + Status_ = gDS->SetMemorySpaceAttributes ( \ + 0, \ + EFI_PAGES_TO_SIZE(1), \ + Desc_.Attributes \ + ); \ + ASSERT_EFI_ERROR (Status_); \ + } \ + } while (FALSE) + extern EFI_GUID gEfiLegacyBiosProtocolGuid; #endif