IntelFrameworkModulePkg/LegacyBios: Use macro to enable/disable page 0
Current implementation uses following two methods EnableNullDetection() DisableNullDetection() to enable/disable page 0. These two methods will check PCD PcdNullPointerDetectionPropertyMask to know if the page 0 is disabled or not. This is due to the fact that old GCD service doesn't provide paging related attributes of memory block. Since this issue has been fixed, GCD services can be used to determine the paging status of page 0. This is also make it possible to just use a new macro ACCESS_PAGE0_CODE( <code accessing page 0> ); to replace above methods to do the same job, which also makes code more readability. Cc: Liming Gao <liming.gao@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang <jian.j.wang@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
This commit is contained in:
@ -1041,7 +1041,9 @@ GenericLegacyBoot (
|
||||
//
|
||||
// Setup BDA and EBDA standard areas before Legacy Boot
|
||||
//
|
||||
LegacyBiosCompleteBdaBeforeBoot (Private);
|
||||
ACCESS_PAGE0_CODE (
|
||||
LegacyBiosCompleteBdaBeforeBoot (Private);
|
||||
);
|
||||
LegacyBiosCompleteStandardCmosBeforeBoot (Private);
|
||||
|
||||
//
|
||||
@ -1073,10 +1075,10 @@ GenericLegacyBoot (
|
||||
// Use 182/10 to avoid floating point math.
|
||||
//
|
||||
LocalTime = (LocalTime * 182) / 10;
|
||||
DisableNullDetection ();
|
||||
BdaPtr = (UINT32 *) (UINTN)0x46C;
|
||||
*BdaPtr = LocalTime;
|
||||
EnableNullDetection ();
|
||||
ACCESS_PAGE0_CODE (
|
||||
BdaPtr = (UINT32 *) (UINTN)0x46C;
|
||||
*BdaPtr = LocalTime;
|
||||
);
|
||||
|
||||
//
|
||||
// Shadow PCI ROMs. We must do this near the end since this will kick
|
||||
@ -1322,15 +1324,15 @@ GenericLegacyBoot (
|
||||
// set of TIANO vectors) or takes it over.
|
||||
//
|
||||
//
|
||||
DisableNullDetection ();
|
||||
BaseVectorMaster = (UINT32 *) (sizeof (UINT32) * PROTECTED_MODE_BASE_VECTOR_MASTER);
|
||||
for (Index = 0; Index < 8; Index++) {
|
||||
Private->ThunkSavedInt[Index] = BaseVectorMaster[Index];
|
||||
if (Private->ThunkSeg == (UINT16) (BaseVectorMaster[Index] >> 16)) {
|
||||
BaseVectorMaster[Index] = (UINT32) (Private->BiosUnexpectedInt);
|
||||
ACCESS_PAGE0_CODE (
|
||||
BaseVectorMaster = (UINT32 *) (sizeof (UINT32) * PROTECTED_MODE_BASE_VECTOR_MASTER);
|
||||
for (Index = 0; Index < 8; Index++) {
|
||||
Private->ThunkSavedInt[Index] = BaseVectorMaster[Index];
|
||||
if (Private->ThunkSeg == (UINT16) (BaseVectorMaster[Index] >> 16)) {
|
||||
BaseVectorMaster[Index] = (UINT32) (Private->BiosUnexpectedInt);
|
||||
}
|
||||
}
|
||||
}
|
||||
EnableNullDetection ();
|
||||
);
|
||||
|
||||
ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET));
|
||||
Regs.X.AX = Legacy16Boot;
|
||||
@ -1344,12 +1346,12 @@ GenericLegacyBoot (
|
||||
0
|
||||
);
|
||||
|
||||
DisableNullDetection ();
|
||||
BaseVectorMaster = (UINT32 *) (sizeof (UINT32) * PROTECTED_MODE_BASE_VECTOR_MASTER);
|
||||
for (Index = 0; Index < 8; Index++) {
|
||||
BaseVectorMaster[Index] = Private->ThunkSavedInt[Index];
|
||||
}
|
||||
EnableNullDetection ();
|
||||
ACCESS_PAGE0_CODE (
|
||||
BaseVectorMaster = (UINT32 *) (sizeof (UINT32) * PROTECTED_MODE_BASE_VECTOR_MASTER);
|
||||
for (Index = 0; Index < 8; Index++) {
|
||||
BaseVectorMaster[Index] = Private->ThunkSavedInt[Index];
|
||||
}
|
||||
);
|
||||
}
|
||||
Private->LegacyBootEntered = TRUE;
|
||||
if ((mBootMode == BOOT_LEGACY_OS) || (mBootMode == BOOT_UNCONVENTIONAL_DEVICE)) {
|
||||
@ -1737,11 +1739,11 @@ LegacyBiosBuildE820 (
|
||||
//
|
||||
// First entry is 0 to (640k - EBDA)
|
||||
//
|
||||
DisableNullDetection ();
|
||||
E820Table[0].BaseAddr = 0;
|
||||
E820Table[0].Length = (UINT64) ((*(UINT16 *) (UINTN)0x40E) << 4);
|
||||
E820Table[0].Type = EfiAcpiAddressRangeMemory;
|
||||
EnableNullDetection ();
|
||||
ACCESS_PAGE0_CODE (
|
||||
E820Table[0].BaseAddr = 0;
|
||||
E820Table[0].Length = (UINT64) ((*(UINT16 *) (UINTN)0x40E) << 4);
|
||||
E820Table[0].Type = EfiAcpiAddressRangeMemory;
|
||||
);
|
||||
|
||||
//
|
||||
// Second entry is (640k - EBDA) to 640k
|
||||
@ -1975,8 +1977,6 @@ LegacyBiosCompleteBdaBeforeBoot (
|
||||
UINT16 MachineConfig;
|
||||
DEVICE_PRODUCER_DATA_HEADER *SioPtr;
|
||||
|
||||
DisableNullDetection ();
|
||||
|
||||
Bda = (BDA_STRUC *) ((UINTN) 0x400);
|
||||
MachineConfig = 0;
|
||||
|
||||
@ -2035,8 +2035,6 @@ LegacyBiosCompleteBdaBeforeBoot (
|
||||
MachineConfig = (UINT16) (MachineConfig + 0x00 + 0x02 + (SioPtr->MousePresent * 0x04));
|
||||
Bda->MachineConfig = MachineConfig;
|
||||
|
||||
EnableNullDetection ();
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -2063,17 +2061,15 @@ LegacyBiosUpdateKeyboardLedStatus (
|
||||
|
||||
Private = LEGACY_BIOS_INSTANCE_FROM_THIS (This);
|
||||
|
||||
DisableNullDetection ();
|
||||
|
||||
Bda = (BDA_STRUC *) ((UINTN) 0x400);
|
||||
LocalLeds = Leds;
|
||||
Bda->LedStatus = (UINT8) ((Bda->LedStatus &~0x07) | LocalLeds);
|
||||
LocalLeds = (UINT8) (LocalLeds << 4);
|
||||
Bda->ShiftStatus = (UINT8) ((Bda->ShiftStatus &~0x70) | LocalLeds);
|
||||
LocalLeds = (UINT8) (Leds & 0x20);
|
||||
Bda->KeyboardStatus = (UINT8) ((Bda->KeyboardStatus &~0x20) | LocalLeds);
|
||||
|
||||
EnableNullDetection ();
|
||||
ACCESS_PAGE0_CODE (
|
||||
Bda = (BDA_STRUC *) ((UINTN) 0x400);
|
||||
LocalLeds = Leds;
|
||||
Bda->LedStatus = (UINT8) ((Bda->LedStatus &~0x07) | LocalLeds);
|
||||
LocalLeds = (UINT8) (LocalLeds << 4);
|
||||
Bda->ShiftStatus = (UINT8) ((Bda->ShiftStatus &~0x70) | LocalLeds);
|
||||
LocalLeds = (UINT8) (Leds & 0x20);
|
||||
Bda->KeyboardStatus = (UINT8) ((Bda->KeyboardStatus &~0x20) | LocalLeds);
|
||||
);
|
||||
|
||||
//
|
||||
// Call into Legacy16 code to allow it to do any processing
|
||||
@ -2119,9 +2115,9 @@ LegacyBiosCompleteStandardCmosBeforeBoot (
|
||||
// to large capacity drives
|
||||
// CMOS 14 = BDA 40:10 plus bit 3(display enabled)
|
||||
//
|
||||
DisableNullDetection ();
|
||||
Bda = (UINT8)(*((UINT8 *)((UINTN)0x410)) | BIT3);
|
||||
EnableNullDetection ();
|
||||
ACCESS_PAGE0_CODE (
|
||||
Bda = (UINT8)(*((UINT8 *)((UINTN)0x410)) | BIT3);
|
||||
);
|
||||
|
||||
//
|
||||
// Force display enabled
|
||||
|
Reference in New Issue
Block a user