]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkPkg/Include/Protocol/LegacyBios.h
IntelFrameworkPkg/LegacyBios.h: Add a macro to guarantee page 0 access
[mirror_edk2.git] / IntelFrameworkPkg / Include / Protocol / LegacyBios.h
index 88f598044a5c886d5e81be81c7b071dd9e1a8b9d..00a149e38783c24089e0ba0afbc4186c7af3da55 100644 (file)
@@ -9,7 +9,7 @@
   Thunk is the code that switches from 32-bit protected environment into the 16-bit real-mode\r
        environment. Reverse thunk is the code that does the opposite.\r
 \r
-Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials are licensed and made available under \r
 the terms and conditions of the BSD License that accompanies this distribution.  \r
 The full text of the license may be found at\r
@@ -20,7 +20,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
   @par Revision Reference:\r
   This protocol is defined in Framework for EFI Compatibility Support Module spec\r
-  Version 0.97.\r
+  Version 0.98.\r
 \r
 **/\r
 \r
@@ -228,6 +228,31 @@ typedef struct {
   /// Maximum PCI bus number assigned.\r
   ///\r
   UINT8                             LastPciBus;\r
+\r
+  ///\r
+  /// Start Address of Upper Memory Area (UMA) to be set as Read/Write. If\r
+  /// UmaAddress is a valid address in the shadow RAM, it also indicates that the region\r
+  /// from 0xC0000 to (UmaAddress - 1) can be used for Option ROM.\r
+  ///\r
+  UINT32                            UmaAddress;\r
+\r
+  ///\r
+  /// Upper Memory Area size in bytes to be set as Read/Write. If zero, no UMA region\r
+  /// will be set as Read/Write (i.e. all Shadow RAM is set as Read-Only).\r
+  ///\r
+  UINT32                            UmaSize;\r
+\r
+  ///\r
+  /// Start Address of high memory that can be used for permanent allocation. If zero,\r
+  /// high memory is not available for permanent allocation.\r
+  ///\r
+  UINT32                            HiPermanentMemoryAddress;\r
+\r
+  ///\r
+  /// Size of high memory that can be used for permanent allocation in bytes. If zero,\r
+  /// high memory is not available for permanent allocation.\r
+  ///\r
+  UINT32                            HiPermanentMemorySize;\r
 } EFI_COMPATIBILITY16_TABLE;\r
 \r
 ///\r
@@ -1172,7 +1197,7 @@ BOOLEAN
                             - 01 = ROM Found.\r
                             - 02 = ROM is a valid legacy ROM.\r
 \r
-  @retval EFI_SUCCESS       The Legacy Option ROM availible for this device\r
+  @retval EFI_SUCCESS       The Legacy Option ROM available for this device\r
   @retval EFI_UNSUPPORTED   The Legacy Option ROM is not supported.\r
 \r
 **/\r
@@ -1493,6 +1518,42 @@ struct _EFI_LEGACY_BIOS_PROTOCOL {
   EFI_LEGACY_BIOS_BOOT_UNCONVENTIONAL_DEVICE  BootUnconventionalDevice;\r
 };\r
 \r
+//\r
+// Legacy BIOS needs to access memory in page 0 (0-4095), which is disabled if\r
+// NULL pointer detection feature is enabled. Following macro can be used to\r
+// enable/disable page 0 before/after accessing it.\r
+//\r
+#define ACCESS_PAGE0_CODE(statements)                           \\r
+  do {                                                          \\r
+    EFI_STATUS                            Status_;              \\r
+    EFI_GCD_MEMORY_SPACE_DESCRIPTOR       Desc_;                \\r
+                                                                \\r
+    Desc_.Attributes = 0;                                       \\r
+    Status_ = gDS->GetMemorySpaceDescriptor (0, &Desc_);        \\r
+    ASSERT_EFI_ERROR (Status_);                                 \\r
+    if ((Desc_.Attributes & EFI_MEMORY_RP) != 0) {              \\r
+      Status_ = gDS->SetMemorySpaceAttributes (                 \\r
+                      0,                                        \\r
+                      EFI_PAGES_TO_SIZE(1),                     \\r
+                      Desc_.Attributes & ~(UINT64)EFI_MEMORY_RP \\r
+                      );                                        \\r
+      ASSERT_EFI_ERROR (Status_);                               \\r
+    }                                                           \\r
+                                                                \\r
+    {                                                           \\r
+      statements;                                               \\r
+    }                                                           \\r
+                                                                \\r
+    if ((Desc_.Attributes & EFI_MEMORY_RP) != 0) {              \\r
+      Status_ = gDS->SetMemorySpaceAttributes (                 \\r
+                      0,                                        \\r
+                      EFI_PAGES_TO_SIZE(1),                     \\r
+                      Desc_.Attributes                          \\r
+                      );                                        \\r
+      ASSERT_EFI_ERROR (Status_);                               \\r
+    }                                                           \\r
+  } while (FALSE)\r
+\r
 extern EFI_GUID gEfiLegacyBiosProtocolGuid;\r
 \r
 #endif\r