return;\r
}\r
\r
-//\r
-// Legacy BIOS needs to access memory between 0-4095, which will cause page\r
-// fault exception if NULL pointer detection mechanism is enabled. Following\r
-// functions can be used to disable/enable NULL pointer detection before/after\r
-// accessing those memory.\r
-//\r
-\r
-/**\r
- Enable NULL pointer detection.\r
-**/\r
-VOID\r
-EnableNullDetection (\r
- VOID\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_GCD_MEMORY_SPACE_DESCRIPTOR Desc;\r
-\r
- if (((PcdGet8 (PcdNullPointerDetectionPropertyMask) & BIT0) == 0)\r
- ||\r
- ((mEndOfDxe) &&\r
- ((PcdGet8 (PcdNullPointerDetectionPropertyMask) & (BIT7|BIT0))\r
- == (BIT7|BIT0)))\r
- ) {\r
- return;\r
- }\r
-\r
- //\r
- // Check current capabilities and attributes\r
- //\r
- Status = gDS->GetMemorySpaceDescriptor (0, &Desc);\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- //\r
- // Try to add EFI_MEMORY_RP support if necessary\r
- //\r
- if ((Desc.Capabilities & EFI_MEMORY_RP) == 0) {\r
- Desc.Capabilities |= EFI_MEMORY_RP;\r
- Status = gDS->SetMemorySpaceCapabilities (0, EFI_PAGES_TO_SIZE(1),\r
- Desc.Capabilities);\r
- ASSERT_EFI_ERROR (Status);\r
- if (EFI_ERROR (Status)) {\r
- return;\r
- }\r
- }\r
-\r
- //\r
- // Don't bother if EFI_MEMORY_RP is already set.\r
- //\r
- if ((Desc.Attributes & EFI_MEMORY_RP) == 0) {\r
- Desc.Attributes |= EFI_MEMORY_RP;\r
- Status = gDS->SetMemorySpaceAttributes (0, EFI_PAGES_TO_SIZE(1),\r
- Desc.Attributes);\r
- ASSERT_EFI_ERROR (Status);\r
- }\r
-}\r
-\r
-/**\r
- Disable NULL pointer detection.\r
-**/\r
-VOID\r
-DisableNullDetection (\r
- VOID\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_GCD_MEMORY_SPACE_DESCRIPTOR Desc;\r
-\r
- if (((PcdGet8 (PcdNullPointerDetectionPropertyMask) & BIT0) == 0)\r
- ||\r
- ((mEndOfDxe) &&\r
- ((PcdGet8 (PcdNullPointerDetectionPropertyMask) & (BIT7|BIT0))\r
- == (BIT7|BIT0)))\r
- ) {\r
- return;\r
- }\r
-\r
- //\r
- // Check current capabilities and attributes\r
- //\r
- Status = gDS->GetMemorySpaceDescriptor (0, &Desc);\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- //\r
- // Try to add EFI_MEMORY_RP support if necessary\r
- //\r
- if ((Desc.Capabilities & EFI_MEMORY_RP) == 0) {\r
- Desc.Capabilities |= EFI_MEMORY_RP;\r
- Status = gDS->SetMemorySpaceCapabilities (0, EFI_PAGES_TO_SIZE(1),\r
- Desc.Capabilities);\r
- ASSERT_EFI_ERROR (Status);\r
- if (EFI_ERROR (Status)) {\r
- return;\r
- }\r
- }\r
-\r
- //\r
- // Don't bother if EFI_MEMORY_RP is already cleared.\r
- //\r
- if ((Desc.Attributes & EFI_MEMORY_RP) != 0) {\r
- Desc.Attributes &= ~EFI_MEMORY_RP;\r
- Status = gDS->SetMemorySpaceAttributes (0, EFI_PAGES_TO_SIZE(1),\r
- Desc.Attributes);\r
- ASSERT_EFI_ERROR (Status);\r
- } else {\r
- DEBUG ((DEBUG_WARN, "!!! Page 0 is supposed to be disabled !!!\r\n"));\r
- }\r
-}\r
-\r
/**\r
Install Driver to produce Legacy BIOS protocol.\r
\r
// Initialize region from 0x0000 to 4k. This initializes interrupt vector\r
// range.\r
//\r
- DisableNullDetection ();\r
- gBS->SetMem ((VOID *) ClearPtr, 0x400, INITIAL_VALUE_BELOW_1K);\r
- ZeroMem ((VOID *) ((UINTN)ClearPtr + 0x400), 0xC00);\r
- EnableNullDetection ();\r
+ ACCESS_PAGE0_CODE (\r
+ gBS->SetMem ((VOID *) ClearPtr, 0x400, INITIAL_VALUE_BELOW_1K);\r
+ ZeroMem ((VOID *) ((UINTN)ClearPtr + 0x400), 0xC00);\r
+ );\r
\r
//\r
// Allocate pages for OPROM usage\r
//\r
// Save Unexpected interrupt vector so can restore it just prior to boot\r
//\r
- DisableNullDetection ();\r
-\r
- BaseVectorMaster = (UINT32 *) (sizeof (UINT32) * PROTECTED_MODE_BASE_VECTOR_MASTER);\r
- Private->BiosUnexpectedInt = BaseVectorMaster[0];\r
- IntRedirCode = (UINT32) (UINTN) Private->IntThunk->InterruptRedirectionCode;\r
- for (Index = 0; Index < 8; Index++) {\r
- BaseVectorMaster[Index] = (EFI_SEGMENT (IntRedirCode + Index * 4) << 16) | EFI_OFFSET (IntRedirCode + Index * 4);\r
- }\r
-\r
- EnableNullDetection ();\r
+ ACCESS_PAGE0_CODE (\r
+ BaseVectorMaster = (UINT32 *) (sizeof (UINT32) * PROTECTED_MODE_BASE_VECTOR_MASTER);\r
+ Private->BiosUnexpectedInt = BaseVectorMaster[0];\r
+ IntRedirCode = (UINT32) (UINTN) Private->IntThunk->InterruptRedirectionCode;\r
+ for (Index = 0; Index < 8; Index++) {\r
+ BaseVectorMaster[Index] = (EFI_SEGMENT (IntRedirCode + Index * 4) << 16) | EFI_OFFSET (IntRedirCode + Index * 4);\r
+ }\r
+ );\r
\r
//\r
// Save EFI value\r