summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/Csm/LegacyBiosDxe
diff options
context:
space:
mode:
authorMichael Kubacki <michael.kubacki@microsoft.com>2021-12-05 14:54:09 -0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2021-12-07 17:24:28 +0000
commitac0a286f4d747a4c6c603a7b225917293cbe1e9f (patch)
tree32654f2b35755afc961e2c97296b2dec5762da75 /OvmfPkg/Csm/LegacyBiosDxe
parentd1050b9dff1cace252aff86630bfdb59dff5f507 (diff)
downloadedk2-ac0a286f4d747a4c6c603a7b225917293cbe1e9f.tar.gz
edk2-ac0a286f4d747a4c6c603a7b225917293cbe1e9f.tar.bz2
edk2-ac0a286f4d747a4c6c603a7b225917293cbe1e9f.zip
OvmfPkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the OvmfPkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Andrew Fish <afish@apple.com>
Diffstat (limited to 'OvmfPkg/Csm/LegacyBiosDxe')
-rw-r--r--OvmfPkg/Csm/LegacyBiosDxe/LegacyBbs.c190
-rw-r--r--OvmfPkg/Csm/LegacyBiosDxe/LegacyBda.c26
-rw-r--r--OvmfPkg/Csm/LegacyBiosDxe/LegacyBios.c518
-rw-r--r--OvmfPkg/Csm/LegacyBiosDxe/LegacyBiosInterface.h779
-rw-r--r--OvmfPkg/Csm/LegacyBiosDxe/LegacyBootSupport.c1190
-rw-r--r--OvmfPkg/Csm/LegacyBiosDxe/LegacyCmos.c6
-rw-r--r--OvmfPkg/Csm/LegacyBiosDxe/LegacyIde.c119
-rw-r--r--OvmfPkg/Csm/LegacyBiosDxe/LegacyPci.c1220
-rw-r--r--OvmfPkg/Csm/LegacyBiosDxe/LegacySio.c308
-rw-r--r--OvmfPkg/Csm/LegacyBiosDxe/Thunk.c175
10 files changed, 2306 insertions, 2225 deletions
diff --git a/OvmfPkg/Csm/LegacyBiosDxe/LegacyBbs.c b/OvmfPkg/Csm/LegacyBiosDxe/LegacyBbs.c
index 5e4c7a249e..cd80720a1d 100644
--- a/OvmfPkg/Csm/LegacyBiosDxe/LegacyBbs.c
+++ b/OvmfPkg/Csm/LegacyBiosDxe/LegacyBbs.c
@@ -14,13 +14,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// FLOPPY_NOT_PRESENT = No floppy controller present
// FLOPPY_PRESENT_NO_MEDIA = Floppy controller present but no media inserted
//
-#define FLOPPY_NOT_PRESENT 0
-#define FLOPPY_PRESENT_WITH_MEDIA 1
-#define FLOPPY_PRESENT_NO_MEDIA 2
+#define FLOPPY_NOT_PRESENT 0
+#define FLOPPY_PRESENT_WITH_MEDIA 1
+#define FLOPPY_PRESENT_NO_MEDIA 2
-BBS_TABLE *mBbsTable;
-BOOLEAN mBbsTableDoneFlag = FALSE;
-BOOLEAN IsHaveMediaInFloppy = TRUE;
+BBS_TABLE *mBbsTable;
+BOOLEAN mBbsTableDoneFlag = FALSE;
+BOOLEAN IsHaveMediaInFloppy = TRUE;
/**
Checks the state of the floppy and if media is inserted.
@@ -44,23 +44,23 @@ HasMediaInFloppy (
VOID
)
{
- EFI_STATUS Status;
- UINTN HandleCount;
- EFI_HANDLE *HandleBuffer;
- UINTN Index;
- EFI_ISA_IO_PROTOCOL *IsaIo;
- EFI_BLOCK_IO_PROTOCOL *BlkIo;
+ EFI_STATUS Status;
+ UINTN HandleCount;
+ EFI_HANDLE *HandleBuffer;
+ UINTN Index;
+ EFI_ISA_IO_PROTOCOL *IsaIo;
+ EFI_BLOCK_IO_PROTOCOL *BlkIo;
- HandleBuffer = NULL;
- HandleCount = 0;
+ HandleBuffer = NULL;
+ HandleCount = 0;
gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiIsaIoProtocolGuid,
- NULL,
- &HandleCount,
- &HandleBuffer
- );
+ ByProtocol,
+ &gEfiIsaIoProtocolGuid,
+ NULL,
+ &HandleCount,
+ &HandleBuffer
+ );
//
// If don't find any ISA/IO protocol assume no floppy. Need for floppy
@@ -76,7 +76,7 @@ HasMediaInFloppy (
Status = gBS->HandleProtocol (
HandleBuffer[Index],
&gEfiIsaIoProtocolGuid,
- (VOID **) &IsaIo
+ (VOID **)&IsaIo
);
if (EFI_ERROR (Status)) {
continue;
@@ -85,6 +85,7 @@ HasMediaInFloppy (
if (IsaIo->ResourceList->Device.HID != EISA_PNP_ID (0x604)) {
continue;
}
+
//
// Update blockio in case the floppy is inserted in during BdsTimeout
//
@@ -103,7 +104,7 @@ HasMediaInFloppy (
Status = gBS->HandleProtocol (
HandleBuffer[Index],
&gEfiBlockIoProtocolGuid,
- (VOID **) &BlkIo
+ (VOID **)&BlkIo
);
if (EFI_ERROR (Status)) {
continue;
@@ -121,10 +122,8 @@ HasMediaInFloppy (
FreePool (HandleBuffer);
return FLOPPY_NOT_PRESENT;
-
}
-
/**
Complete build of BBS TABLE.
@@ -136,8 +135,8 @@ HasMediaInFloppy (
**/
EFI_STATUS
LegacyBiosBuildBbs (
- IN LEGACY_BIOS_INSTANCE *Private,
- IN BBS_TABLE *BbsTable
+ IN LEGACY_BIOS_INSTANCE *Private,
+ IN BBS_TABLE *BbsTable
)
{
UINTN BbsIndex;
@@ -172,18 +171,18 @@ LegacyBiosBuildBbs (
}
}
- BbsTable[0].Bus = 0xff;
- BbsTable[0].Device = 0xff;
- BbsTable[0].Function = 0xff;
- BbsTable[0].DeviceType = BBS_FLOPPY;
- BbsTable[0].Class = 01;
- BbsTable[0].SubClass = 02;
- BbsTable[0].StatusFlags.OldPosition = 0;
- BbsTable[0].StatusFlags.Reserved1 = 0;
- BbsTable[0].StatusFlags.Enabled = 0;
- BbsTable[0].StatusFlags.Failed = 0;
- BbsTable[0].StatusFlags.MediaPresent = 0;
- BbsTable[0].StatusFlags.Reserved2 = 0;
+ BbsTable[0].Bus = 0xff;
+ BbsTable[0].Device = 0xff;
+ BbsTable[0].Function = 0xff;
+ BbsTable[0].DeviceType = BBS_FLOPPY;
+ BbsTable[0].Class = 01;
+ BbsTable[0].SubClass = 02;
+ BbsTable[0].StatusFlags.OldPosition = 0;
+ BbsTable[0].StatusFlags.Reserved1 = 0;
+ BbsTable[0].StatusFlags.Enabled = 0;
+ BbsTable[0].StatusFlags.Failed = 0;
+ BbsTable[0].StatusFlags.MediaPresent = 0;
+ BbsTable[0].StatusFlags.Reserved2 = 0;
//
// Onboard HDD - Note Each HDD controller controls 2 drives
@@ -196,10 +195,8 @@ LegacyBiosBuildBbs (
LegacyBiosBuildIdeData (Private, &HddInfo, 0);
for (HddIndex = 0; HddIndex < MAX_IDE_CONTROLLER; HddIndex++) {
-
BbsIndex = HddIndex * 2 + 1;
for (Index = 0; Index < 2; ++Index) {
-
BbsTable[BbsIndex + Index].Bus = HddInfo[HddIndex].Bus;
BbsTable[BbsIndex + Index].Device = HddInfo[HddIndex].Device;
BbsTable[BbsIndex + Index].Function = HddInfo[HddIndex].Function;
@@ -286,7 +283,7 @@ LegacyBiosBuildBbs (
Status = gBS->HandleProtocol (
BlockIoHandles[BlockIndex],
&gEfiBlockIoProtocolGuid,
- (VOID **) &BlkIo
+ (VOID **)&BlkIo
);
if (EFI_ERROR (Status)) {
@@ -313,7 +310,7 @@ LegacyBiosBuildBbs (
Status = gBS->HandleProtocol (
BlockIoHandles[BlockIndex],
&gEfiDevicePathProtocolGuid,
- (VOID **) &DevicePath
+ (VOID **)&DevicePath
);
if (EFI_ERROR (Status)) {
continue;
@@ -324,14 +321,17 @@ LegacyBiosBuildBbs (
//
DevicePathNode = DevicePath;
while (!IsDevicePathEnd (DevicePathNode)) {
- if (DevicePathType (DevicePathNode) == MESSAGING_DEVICE_PATH &&
- DevicePathSubType (DevicePathNode) == MSG_ATAPI_DP) {
+ if ((DevicePathType (DevicePathNode) == MESSAGING_DEVICE_PATH) &&
+ (DevicePathSubType (DevicePathNode) == MSG_ATAPI_DP))
+ {
break;
}
+
DevicePathNode = NextDevicePathNode (DevicePathNode);
}
+
if (!IsDevicePathEnd (DevicePathNode)) {
- continue;
+ continue;
}
//
@@ -349,7 +349,7 @@ LegacyBiosBuildBbs (
Status = gBS->HandleProtocol (
PciHandle,
&gEfiPciIoProtocolGuid,
- (VOID **) &PciIo
+ (VOID **)&PciIo
);
if (EFI_ERROR (Status)) {
continue;
@@ -367,13 +367,21 @@ LegacyBiosBuildBbs (
}
if (SegNum != 0) {
- DEBUG ((DEBUG_WARN, "CSM cannot use PCI devices in segment %Lu\n",
- (UINT64) SegNum));
+ DEBUG ((
+ DEBUG_WARN,
+ "CSM cannot use PCI devices in segment %Lu\n",
+ (UINT64)SegNum
+ ));
continue;
}
- DEBUG ((DEBUG_INFO, "Add Legacy Bbs entry for PCI %d/%d/%d\n",
- BusNum, DevNum, FuncNum));
+ DEBUG ((
+ DEBUG_INFO,
+ "Add Legacy Bbs entry for PCI %d/%d/%d\n",
+ BusNum,
+ DevNum,
+ FuncNum
+ ));
BbsTable[BbsIndex].Bus = BusNum;
BbsTable[BbsIndex].Device = DevNum;
@@ -403,7 +411,6 @@ LegacyBiosBuildBbs (
return EFI_SUCCESS;
}
-
/**
Get all BBS info
@@ -421,30 +428,30 @@ LegacyBiosBuildBbs (
EFI_STATUS
EFIAPI
LegacyBiosGetBbsInfo (
- IN EFI_LEGACY_BIOS_PROTOCOL *This,
- OUT UINT16 *HddCount,
- OUT HDD_INFO **HddInfo,
- OUT UINT16 *BbsCount,
- OUT BBS_TABLE **BbsTable
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,
+ OUT UINT16 *HddCount,
+ OUT HDD_INFO **HddInfo,
+ OUT UINT16 *BbsCount,
+ OUT BBS_TABLE **BbsTable
)
{
- LEGACY_BIOS_INSTANCE *Private;
- EFI_IA32_REGISTER_SET Regs;
- EFI_TO_COMPATIBILITY16_BOOT_TABLE *EfiToLegacy16BootTable;
-// HDD_INFO *LocalHddInfo;
-// IN BBS_TABLE *LocalBbsTable;
- UINTN NumHandles;
- EFI_HANDLE *HandleBuffer;
- UINTN Index;
- UINTN TempData;
- UINT32 Granularity;
-
- HandleBuffer = NULL;
-
- Private = LEGACY_BIOS_INSTANCE_FROM_THIS (This);
- EfiToLegacy16BootTable = &Private->IntThunk->EfiToLegacy16BootTable;
-// LocalHddInfo = EfiToLegacy16BootTable->HddInfo;
-// LocalBbsTable = (BBS_TABLE*)(UINTN)EfiToLegacy16BootTable->BbsTable;
+ LEGACY_BIOS_INSTANCE *Private;
+ EFI_IA32_REGISTER_SET Regs;
+ EFI_TO_COMPATIBILITY16_BOOT_TABLE *EfiToLegacy16BootTable;
+ // HDD_INFO *LocalHddInfo;
+ // IN BBS_TABLE *LocalBbsTable;
+ UINTN NumHandles;
+ EFI_HANDLE *HandleBuffer;
+ UINTN Index;
+ UINTN TempData;
+ UINT32 Granularity;
+
+ HandleBuffer = NULL;
+
+ Private = LEGACY_BIOS_INSTANCE_FROM_THIS (This);
+ EfiToLegacy16BootTable = &Private->IntThunk->EfiToLegacy16BootTable;
+ // LocalHddInfo = EfiToLegacy16BootTable->HddInfo;
+ // LocalBbsTable = (BBS_TABLE*)(UINTN)EfiToLegacy16BootTable->BbsTable;
if (!mBbsTableDoneFlag) {
mBbsTable = Private->BbsTablePtr;
@@ -457,12 +464,12 @@ LegacyBiosGetBbsInfo (
// Get PciRootBridgeIO protocol
//
gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiPciRootBridgeIoProtocolGuid,
- NULL,
- &NumHandles,
- &HandleBuffer
- );
+ ByProtocol,
+ &gEfiPciRootBridgeIoProtocolGuid,
+ NULL,
+ &NumHandles,
+ &HandleBuffer
+ );
if (NumHandles == 0) {
return EFI_NOT_FOUND;
@@ -475,7 +482,6 @@ LegacyBiosGetBbsInfo (
// PCI bus driver enumerate all subsequent handles
//
gBS->ConnectController (HandleBuffer[Index], NULL, NULL, FALSE);
-
}
LegacyBiosBuildBbs (Private, mBbsTable);
@@ -491,18 +497,18 @@ LegacyBiosGetBbsInfo (
//
// Pass in handoff data
//
- TempData = (UINTN) EfiToLegacy16BootTable;
- Regs.X.ES = NORMALIZE_EFI_SEGMENT ((UINT32) TempData);
- Regs.X.BX = NORMALIZE_EFI_OFFSET ((UINT32) TempData);
+ TempData = (UINTN)EfiToLegacy16BootTable;
+ Regs.X.ES = NORMALIZE_EFI_SEGMENT ((UINT32)TempData);
+ Regs.X.BX = NORMALIZE_EFI_OFFSET ((UINT32)TempData);
Private->LegacyBios.FarCall86 (
- This,
- Private->Legacy16CallSegment,
- Private->Legacy16CallOffset,
- &Regs,
- NULL,
- 0
- );
+ This,
+ Private->Legacy16CallSegment,
+ Private->Legacy16CallOffset,
+ &Regs,
+ NULL,
+ 0
+ );
Private->Cpu->FlushDataCache (Private->Cpu, 0xE0000, 0x20000, EfiCpuFlushTypeWriteBackInvalidate);
Private->LegacyRegion->Lock (Private->LegacyRegion, 0xe0000, 0x20000, &Granularity);
@@ -518,7 +524,7 @@ LegacyBiosGetBbsInfo (
*HddCount = MAX_IDE_CONTROLLER;
*HddInfo = EfiToLegacy16BootTable->HddInfo;
- *BbsTable = (BBS_TABLE*)(UINTN)EfiToLegacy16BootTable->BbsTable;
- *BbsCount = (UINT16) (sizeof (Private->IntThunk->BbsTable) / sizeof (BBS_TABLE));
+ *BbsTable = (BBS_TABLE *)(UINTN)EfiToLegacy16BootTable->BbsTable;
+ *BbsCount = (UINT16)(sizeof (Private->IntThunk->BbsTable) / sizeof (BBS_TABLE));
return EFI_SUCCESS;
}
diff --git a/OvmfPkg/Csm/LegacyBiosDxe/LegacyBda.c b/OvmfPkg/Csm/LegacyBiosDxe/LegacyBda.c
index aa6e07ab91..a873015d06 100644
--- a/OvmfPkg/Csm/LegacyBiosDxe/LegacyBda.c
+++ b/OvmfPkg/Csm/LegacyBiosDxe/LegacyBda.c
@@ -21,25 +21,25 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
EFI_STATUS
LegacyBiosInitBda (
- IN LEGACY_BIOS_INSTANCE *Private
+ IN LEGACY_BIOS_INSTANCE *Private
)
{
- BDA_STRUC *Bda;
- UINT8 *Ebda;
+ BDA_STRUC *Bda;
+ UINT8 *Ebda;
- Bda = (BDA_STRUC *) ((UINTN) 0x400);
- Ebda = (UINT8 *) ((UINTN) 0x9fc00);
+ Bda = (BDA_STRUC *)((UINTN)0x400);
+ Ebda = (UINT8 *)((UINTN)0x9fc00);
ACCESS_PAGE0_CODE (
ZeroMem (Bda, 0x100);
//
// 640k-1k for EBDA
//
- Bda->MemSize = 0x27f;
- Bda->KeyHead = 0x1e;
- Bda->KeyTail = 0x1e;
- Bda->FloppyData = 0x00;
- Bda->FloppyTimeout = 0xff;
+ Bda->MemSize = 0x27f;
+ Bda->KeyHead = 0x1e;
+ Bda->KeyTail = 0x1e;
+ Bda->FloppyData = 0x00;
+ Bda->FloppyTimeout = 0xff;
Bda->KeyStart = 0x001E;
Bda->KeyEnd = 0x003E;
@@ -50,10 +50,10 @@ LegacyBiosInitBda (
// Move LPT time out here and zero out LPT4 since some SCSI OPROMS
// use this as scratch pad (LPT4 is Reserved)
//
- Bda->Lpt1_2Timeout = 0x1414;
- Bda->Lpt3_4Timeout = 0x1400;
+ Bda->Lpt1_2Timeout = 0x1414;
+ Bda->Lpt3_4Timeout = 0x1400;
- );
+ );
ZeroMem (Ebda, 0x400);
*Ebda = 0x01;
diff --git a/OvmfPkg/Csm/LegacyBiosDxe/LegacyBios.c b/OvmfPkg/Csm/LegacyBiosDxe/LegacyBios.c
index 3ce19496b0..d587b55e3b 100644
--- a/OvmfPkg/Csm/LegacyBiosDxe/LegacyBios.c
+++ b/OvmfPkg/Csm/LegacyBiosDxe/LegacyBios.c
@@ -13,7 +13,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//
// define maximum number of HDD system supports
//
-#define MAX_HDD_ENTRIES 0x30
+#define MAX_HDD_ENTRIES 0x30
//
// Module Global:
@@ -25,7 +25,7 @@ LEGACY_BIOS_INSTANCE mPrivateData;
//
// The SMBIOS table in EfiRuntimeServicesData memory
//
-VOID *mRuntimeSmbiosEntryPoint = NULL;
+VOID *mRuntimeSmbiosEntryPoint = NULL;
//
// The SMBIOS table in EfiReservedMemoryType memory
@@ -50,27 +50,27 @@ BOOLEAN mEndOfDxe = FALSE;
**/
EFI_STATUS
AllocateLegacyMemory (
- IN EFI_ALLOCATE_TYPE AllocateType,
- IN EFI_MEMORY_TYPE MemoryType,
- IN EFI_PHYSICAL_ADDRESS StartPageAddress,
- IN UINTN Pages,
- OUT EFI_PHYSICAL_ADDRESS *Result
+ IN EFI_ALLOCATE_TYPE AllocateType,
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN EFI_PHYSICAL_ADDRESS StartPageAddress,
+ IN UINTN Pages,
+ OUT EFI_PHYSICAL_ADDRESS *Result
)
{
- EFI_STATUS Status;
- EFI_PHYSICAL_ADDRESS MemPage;
- EFI_GCD_MEMORY_SPACE_DESCRIPTOR MemDesc;
+ EFI_STATUS Status;
+ EFI_PHYSICAL_ADDRESS MemPage;
+ EFI_GCD_MEMORY_SPACE_DESCRIPTOR MemDesc;
//
// Allocate Pages of memory less <= StartPageAddress
//
- MemPage = (EFI_PHYSICAL_ADDRESS) (UINTN) StartPageAddress;
- Status = gBS->AllocatePages (
- AllocateType,
- MemoryType,
- Pages,
- &MemPage
- );
+ MemPage = (EFI_PHYSICAL_ADDRESS)(UINTN)StartPageAddress;
+ Status = gBS->AllocatePages (
+ AllocateType,
+ MemoryType,
+ Pages,
+ &MemPage
+ );
//
// Do not ASSERT on Status error but let caller decide since some cases
// memory is already taken but that is ok.
@@ -81,13 +81,14 @@ AllocateLegacyMemory (
// Make sure that the buffer can be used to store code.
//
Status = gDS->GetMemorySpaceDescriptor (MemPage, &MemDesc);
- if (!EFI_ERROR (Status) && (MemDesc.Attributes & EFI_MEMORY_XP) != 0) {
+ if (!EFI_ERROR (Status) && ((MemDesc.Attributes & EFI_MEMORY_XP) != 0)) {
Status = gDS->SetMemorySpaceAttributes (
MemPage,
EFI_PAGES_TO_SIZE (Pages),
MemDesc.Attributes & (~EFI_MEMORY_XP)
);
}
+
if (EFI_ERROR (Status)) {
gBS->FreePages (MemPage, Pages);
}
@@ -95,13 +96,12 @@ AllocateLegacyMemory (
}
if (!EFI_ERROR (Status)) {
- *Result = (EFI_PHYSICAL_ADDRESS) (UINTN) MemPage;
+ *Result = (EFI_PHYSICAL_ADDRESS)(UINTN)MemPage;
}
return Status;
}
-
/**
This function is called when EFI needs to reserve an area in the 0xE0000 or 0xF0000
64 KB blocks.
@@ -126,39 +126,38 @@ AllocateLegacyMemory (
EFI_STATUS
EFIAPI
LegacyBiosGetLegacyRegion (
- IN EFI_LEGACY_BIOS_PROTOCOL *This,
- IN UINTN LegacyMemorySize,
- IN UINTN Region,
- IN UINTN Alignment,
- OUT VOID **LegacyMemoryAddress
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,
+ IN UINTN LegacyMemorySize,
+ IN UINTN Region,
+ IN UINTN Alignment,
+ OUT VOID **LegacyMemoryAddress
)
{
-
- LEGACY_BIOS_INSTANCE *Private;
- EFI_IA32_REGISTER_SET Regs;
- EFI_STATUS Status;
- UINT32 Granularity;
+ LEGACY_BIOS_INSTANCE *Private;
+ EFI_IA32_REGISTER_SET Regs;
+ EFI_STATUS Status;
+ UINT32 Granularity;
Private = LEGACY_BIOS_INSTANCE_FROM_THIS (This);
Private->LegacyRegion->UnLock (Private->LegacyRegion, 0xE0000, 0x20000, &Granularity);
ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET));
Regs.X.AX = Legacy16GetTableAddress;
- Regs.X.BX = (UINT16) Region;
- Regs.X.CX = (UINT16) LegacyMemorySize;
- Regs.X.DX = (UINT16) Alignment;
+ Regs.X.BX = (UINT16)Region;
+ Regs.X.CX = (UINT16)LegacyMemorySize;
+ Regs.X.DX = (UINT16)Alignment;
Private->LegacyBios.FarCall86 (
- &Private->LegacyBios,
- Private->Legacy16CallSegment,
- Private->Legacy16CallOffset,
- &Regs,
- NULL,
- 0
- );
+ &Private->LegacyBios,
+ Private->Legacy16CallSegment,
+ Private->Legacy16CallOffset,
+ &Regs,
+ NULL,
+ 0
+ );
if (Regs.X.AX == 0) {
- *LegacyMemoryAddress = (VOID *) (((UINTN) Regs.X.DS << 4) + Regs.X.BX);
- Status = EFI_SUCCESS;
+ *LegacyMemoryAddress = (VOID *)(((UINTN)Regs.X.DS << 4) + Regs.X.BX);
+ Status = EFI_SUCCESS;
} else {
Status = EFI_OUT_OF_RESOURCES;
}
@@ -169,7 +168,6 @@ LegacyBiosGetLegacyRegion (
return Status;
}
-
/**
This function is called when copying data to the region assigned by
EFI_LEGACY_BIOS_PROTOCOL.GetLegacyRegion().
@@ -187,21 +185,22 @@ LegacyBiosGetLegacyRegion (
EFI_STATUS
EFIAPI
LegacyBiosCopyLegacyRegion (
- IN EFI_LEGACY_BIOS_PROTOCOL *This,
- IN UINTN LegacyMemorySize,
- IN VOID *LegacyMemoryAddress,
- IN VOID *LegacyMemorySourceAddress
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,
+ IN UINTN LegacyMemorySize,
+ IN VOID *LegacyMemoryAddress,
+ IN VOID *LegacyMemorySourceAddress
)
{
-
LEGACY_BIOS_INSTANCE *Private;
UINT32 Granularity;
- if ((LegacyMemoryAddress < (VOID *)(UINTN)0xE0000 ) ||
- ((UINTN) LegacyMemoryAddress + LegacyMemorySize > (UINTN) 0x100000)
- ) {
+ if ((LegacyMemoryAddress < (VOID *)(UINTN)0xE0000) ||
+ ((UINTN)LegacyMemoryAddress + LegacyMemorySize > (UINTN)0x100000)
+ )
+ {
return EFI_ACCESS_DENIED;
}
+
//
// There is no protection from writes over lapping if this function is
// called multiple times.
@@ -216,7 +215,6 @@ LegacyBiosCopyLegacyRegion (
return EFI_SUCCESS;
}
-
/**
Find Legacy16 BIOS image in the FLASH device and shadow it into memory. Find
the $EFI table in the shadow area. Thunk into the Legacy16 code after it had
@@ -233,33 +231,33 @@ ShadowAndStartLegacy16 (
IN LEGACY_BIOS_INSTANCE *Private
)
{
- EFI_STATUS Status;
- UINT8 *Ptr;
- UINT8 *PtrEnd;
- BOOLEAN Done;
- EFI_COMPATIBILITY16_TABLE *Table;
- UINT8 CheckSum;
- EFI_IA32_REGISTER_SET Regs;
- EFI_TO_COMPATIBILITY16_INIT_TABLE *EfiToLegacy16InitTable;
- EFI_TO_COMPATIBILITY16_BOOT_TABLE *EfiToLegacy16BootTable;
- VOID *LegacyBiosImage;
- UINTN LegacyBiosImageSize;
- UINTN E820Size;
- UINT32 *ClearPtr;
- BBS_TABLE *BbsTable;
- LEGACY_EFI_HDD_TABLE *LegacyEfiHddTable;
- UINTN Index;
- UINT32 TpmPointer;
- VOID *TpmBinaryImage;
- UINTN TpmBinaryImageSize;
- UINTN Location;
- UINTN Alignment;
- UINTN TempData;
- EFI_PHYSICAL_ADDRESS Address;
- UINT16 OldMask;
- UINT16 NewMask;
- UINT32 Granularity;
- EFI_GCD_MEMORY_SPACE_DESCRIPTOR Descriptor;
+ EFI_STATUS Status;
+ UINT8 *Ptr;
+ UINT8 *PtrEnd;
+ BOOLEAN Done;
+ EFI_COMPATIBILITY16_TABLE *Table;
+ UINT8 CheckSum;
+ EFI_IA32_REGISTER_SET Regs;
+ EFI_TO_COMPATIBILITY16_INIT_TABLE *EfiToLegacy16InitTable;
+ EFI_TO_COMPATIBILITY16_BOOT_TABLE *EfiToLegacy16BootTable;
+ VOID *LegacyBiosImage;
+ UINTN LegacyBiosImageSize;
+ UINTN E820Size;
+ UINT32 *ClearPtr;
+ BBS_TABLE *BbsTable;
+ LEGACY_EFI_HDD_TABLE *LegacyEfiHddTable;
+ UINTN Index;
+ UINT32 TpmPointer;
+ VOID *TpmBinaryImage;
+ UINTN TpmBinaryImageSize;
+ UINTN Location;
+ UINTN Alignment;
+ UINTN TempData;
+ EFI_PHYSICAL_ADDRESS Address;
+ UINT16 OldMask;
+ UINT16 NewMask;
+ UINT32 Granularity;
+ EFI_GCD_MEMORY_SPACE_DESCRIPTOR Descriptor;
Location = 0;
Alignment = 0;
@@ -300,23 +298,23 @@ ShadowAndStartLegacy16 (
// end testtest
//
EfiToLegacy16BootTable = &Private->IntThunk->EfiToLegacy16BootTable;
- Status = Private->LegacyBiosPlatform->GetPlatformInfo (
- Private->LegacyBiosPlatform,
- EfiGetPlatformBinarySystemRom,
- &LegacyBiosImage,
- &LegacyBiosImageSize,
- &Location,
- &Alignment,
- 0,
- 0
- );
+ Status = Private->LegacyBiosPlatform->GetPlatformInfo (
+ Private->LegacyBiosPlatform,
+ EfiGetPlatformBinarySystemRom,
+ &LegacyBiosImage,
+ &LegacyBiosImageSize,
+ &Location,
+ &Alignment,
+ 0,
+ 0
+ );
if (EFI_ERROR (Status)) {
return Status;
}
- Private->BiosStart = (UINT32) (0x100000 - LegacyBiosImageSize);
- Private->OptionRom = 0xc0000;
- Private->LegacyBiosImageSize = (UINT32) LegacyBiosImageSize;
+ Private->BiosStart = (UINT32)(0x100000 - LegacyBiosImageSize);
+ Private->OptionRom = 0xc0000;
+ Private->LegacyBiosImageSize = (UINT32)LegacyBiosImageSize;
//
// Can only shadow into memory allocated for legacy usage.
@@ -328,20 +326,20 @@ ShadowAndStartLegacy16 (
//
Private->LegacyRegion->UnLock (Private->LegacyRegion, 0xc0000, 0x40000, &Granularity);
- ClearPtr = (VOID *) ((UINTN) 0xc0000);
+ ClearPtr = (VOID *)((UINTN)0xc0000);
//
// Initialize region from 0xc0000 to start of BIOS to all ffs. This allows unused
// regions to be used by EMM386 etc.
//
- SetMem ((VOID *) ClearPtr, (UINTN) (0x40000 - LegacyBiosImageSize), 0xff);
+ SetMem ((VOID *)ClearPtr, (UINTN)(0x40000 - LegacyBiosImageSize), 0xff);
TempData = Private->BiosStart;
CopyMem (
- (VOID *) TempData,
+ (VOID *)TempData,
LegacyBiosImage,
- (UINTN) LegacyBiosImageSize
+ (UINTN)LegacyBiosImageSize
);
Private->Cpu->FlushDataCache (Private->Cpu, 0xc0000, 0x40000, EfiCpuFlushTypeWriteBackInvalidate);
@@ -351,12 +349,12 @@ ShadowAndStartLegacy16 (
//
Done = FALSE;
Table = NULL;
- for (Ptr = (UINT8 *) TempData; Ptr < (UINT8 *) ((UINTN) 0x100000) && !Done; Ptr += 0x10) {
- if (*(UINT32 *) Ptr == SIGNATURE_32 ('I', 'F', 'E', '$')) {
- Table = (EFI_COMPATIBILITY16_TABLE *) Ptr;
- PtrEnd = Ptr + Table->TableLength;
+ for (Ptr = (UINT8 *)TempData; Ptr < (UINT8 *)((UINTN)0x100000) && !Done; Ptr += 0x10) {
+ if (*(UINT32 *)Ptr == SIGNATURE_32 ('I', 'F', 'E', '$')) {
+ Table = (EFI_COMPATIBILITY16_TABLE *)Ptr;
+ PtrEnd = Ptr + Table->TableLength;
for (CheckSum = 0; Ptr < PtrEnd; Ptr++) {
- CheckSum = (UINT8) (CheckSum +*Ptr);
+ CheckSum = (UINT8)(CheckSum +*Ptr);
}
Done = TRUE;
@@ -378,24 +376,24 @@ ShadowAndStartLegacy16 (
//
// Remember location of the Legacy16 table
//
- Private->Legacy16Table = Table;
- Private->Legacy16CallSegment = Table->Compatibility16CallSegment;
- Private->Legacy16CallOffset = Table->Compatibility16CallOffset;
- EfiToLegacy16InitTable = &Private->IntThunk->EfiToLegacy16InitTable;
- Private->Legacy16InitPtr = EfiToLegacy16InitTable;
- Private->Legacy16BootPtr = &Private->IntThunk->EfiToLegacy16BootTable;
- Private->InternalIrqRoutingTable = NULL;
- Private->NumberIrqRoutingEntries = 0;
- Private->BbsTablePtr = NULL;
- Private->LegacyEfiHddTable = NULL;
- Private->DiskEnd = 0;
- Private->Disk4075 = 0;
- Private->HddTablePtr = &Private->IntThunk->EfiToLegacy16BootTable.HddInfo;
- Private->NumberHddControllers = MAX_IDE_CONTROLLER;
- Private->Dump[0] = 'D';
- Private->Dump[1] = 'U';
- Private->Dump[2] = 'M';
- Private->Dump[3] = 'P';
+ Private->Legacy16Table = Table;
+ Private->Legacy16CallSegment = Table->Compatibility16CallSegment;
+ Private->Legacy16CallOffset = Table->Compatibility16CallOffset;
+ EfiToLegacy16InitTable = &Private->IntThunk->EfiToLegacy16InitTable;
+ Private->Legacy16InitPtr = EfiToLegacy16InitTable;
+ Private->Legacy16BootPtr = &Private->IntThunk->EfiToLegacy16BootTable;
+ Private->InternalIrqRoutingTable = NULL;
+ Private->NumberIrqRoutingEntries = 0;
+ Private->BbsTablePtr = NULL;
+ Private->LegacyEfiHddTable = NULL;
+ Private->DiskEnd = 0;
+ Private->Disk4075 = 0;
+ Private->HddTablePtr = &Private->IntThunk->EfiToLegacy16BootTable.HddInfo;
+ Private->NumberHddControllers = MAX_IDE_CONTROLLER;
+ Private->Dump[0] = 'D';
+ Private->Dump[1] = 'U';
+ Private->Dump[2] = 'M';
+ Private->Dump[3] = 'P';
ZeroMem (
Private->Legacy16BootPtr,
@@ -405,7 +403,7 @@ ShadowAndStartLegacy16 (
//
// Store away a copy of the EFI System Table
//
- Table->EfiSystemTable = (UINT32) (UINTN) gST;
+ Table->EfiSystemTable = (UINT32)(UINTN)gST;
//
// IPF CSM integration -Bug
@@ -423,31 +421,31 @@ ShadowAndStartLegacy16 (
//
// All legacy interrupt should be masked when do initialization work from legacy 16 code.
//
- Private->Legacy8259->GetMask(Private->Legacy8259, &OldMask, NULL, NULL, NULL);
+ Private->Legacy8259->GetMask (Private->Legacy8259, &OldMask, NULL, NULL, NULL);
NewMask = 0xFFFF;
- Private->Legacy8259->SetMask(Private->Legacy8259, &NewMask, NULL, NULL, NULL);
+ Private->Legacy8259->SetMask (Private->Legacy8259, &NewMask, NULL, NULL, NULL);
//
// Call into Legacy16 code to do an INIT
//
ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET));
Regs.X.AX = Legacy16InitializeYourself;
- Regs.X.ES = EFI_SEGMENT (*((UINT32 *) &EfiToLegacy16InitTable));
- Regs.X.BX = EFI_OFFSET (*((UINT32 *) &EfiToLegacy16InitTable));
+ Regs.X.ES = EFI_SEGMENT (*((UINT32 *)&EfiToLegacy16InitTable));
+ Regs.X.BX = EFI_OFFSET (*((UINT32 *)&EfiToLegacy16InitTable));
Private->LegacyBios.FarCall86 (
- &Private->LegacyBios,
- Table->Compatibility16CallSegment,
- Table->Compatibility16CallOffset,
- &Regs,
- NULL,
- 0
- );
+ &Private->LegacyBios,
+ Table->Compatibility16CallSegment,
+ Table->Compatibility16CallOffset,
+ &Regs,
+ NULL,
+ 0
+ );
//
// Restore original legacy interrupt mask value
//
- Private->Legacy8259->SetMask(Private->Legacy8259, &OldMask, NULL, NULL, NULL);
+ Private->Legacy8259->SetMask (Private->Legacy8259, &OldMask, NULL, NULL, NULL);
if (Regs.X.AX != 0) {
return EFI_DEVICE_ERROR;
@@ -469,30 +467,31 @@ ShadowAndStartLegacy16 (
//
ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET));
Regs.X.AX = Legacy16GetTableAddress;
- Regs.X.CX = (UINT16) E820Size;
+ Regs.X.CX = (UINT16)E820Size;
Regs.X.DX = 1;
Private->LegacyBios.FarCall86 (
- &Private->LegacyBios,
- Table->Compatibility16CallSegment,
- Table->Compatibility16CallOffset,
- &Regs,
- NULL,
- 0
- );
+ &Private->LegacyBios,
+ Table->Compatibility16CallSegment,
+ Table->Compatibility16CallOffset,
+ &Regs,
+ NULL,
+ 0
+ );
- Table->E820Pointer = (UINT32) (Regs.X.DS * 16 + Regs.X.BX);
- Table->E820Length = (UINT32) E820Size;
+ Table->E820Pointer = (UINT32)(Regs.X.DS * 16 + Regs.X.BX);
+ Table->E820Length = (UINT32)E820Size;
if (Regs.X.AX != 0) {
DEBUG ((DEBUG_ERROR, "Legacy16 E820 length insufficient\n"));
} else {
TempData = Table->E820Pointer;
- CopyMem ((VOID *) TempData, Private->E820Table, E820Size);
+ CopyMem ((VOID *)TempData, Private->E820Table, E820Size);
}
+
//
// Get PnPInstallationCheck Info.
//
- Private->PnPInstallationCheckSegment = Table->PnPInstallationCheckSegment;
- Private->PnPInstallationCheckOffset = Table->PnPInstallationCheckOffset;
+ Private->PnPInstallationCheckSegment = Table->PnPInstallationCheckSegment;
+ Private->PnPInstallationCheckOffset = Table->PnPInstallationCheckOffset;
//
// Check if PCI Express is supported. If yes, Save base address.
@@ -508,9 +507,10 @@ ShadowAndStartLegacy16 (
0
);
if (!EFI_ERROR (Status)) {
- Private->Legacy16Table->PciExpressBase = (UINT32)Location;
- Location = 0;
+ Private->Legacy16Table->PciExpressBase = (UINT32)Location;
+ Location = 0;
}
+
//
// Check if TPM is supported. If yes get a region in E0000,F0000 to copy it
// into, copy it and update pointer to binary image. This needs to be
@@ -527,35 +527,34 @@ ShadowAndStartLegacy16 (
0
);
if (!EFI_ERROR (Status)) {
-
ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET));
Regs.X.AX = Legacy16GetTableAddress;
- Regs.X.CX = (UINT16) TpmBinaryImageSize;
+ Regs.X.CX = (UINT16)TpmBinaryImageSize;
Regs.X.DX = 1;
Private->LegacyBios.FarCall86 (
- &Private->LegacyBios,
- Table->Compatibility16CallSegment,
- Table->Compatibility16CallOffset,
- &Regs,
- NULL,
- 0
- );
-
- TpmPointer = (UINT32) (Regs.X.DS * 16 + Regs.X.BX);
+ &Private->LegacyBios,
+ Table->Compatibility16CallSegment,
+ Table->Compatibility16CallOffset,
+ &Regs,
+ NULL,
+ 0
+ );
+
+ TpmPointer = (UINT32)(Regs.X.DS * 16 + Regs.X.BX);
if (Regs.X.AX != 0) {
DEBUG ((DEBUG_ERROR, "TPM cannot be loaded\n"));
} else {
- CopyMem ((VOID *) (UINTN)TpmPointer, TpmBinaryImage, TpmBinaryImageSize);
+ CopyMem ((VOID *)(UINTN)TpmPointer, TpmBinaryImage, TpmBinaryImageSize);
Table->TpmSegment = Regs.X.DS;
Table->TpmOffset = Regs.X.BX;
-
}
}
+
//
// Lock the Legacy BIOS region
//
- Private->Cpu->FlushDataCache (Private->Cpu, Private->BiosStart, (UINT32) LegacyBiosImageSize, EfiCpuFlushTypeWriteBackInvalidate);
- Private->LegacyRegion->Lock (Private->LegacyRegion, Private->BiosStart, (UINT32) LegacyBiosImageSize, &Granularity);
+ Private->Cpu->FlushDataCache (Private->Cpu, Private->BiosStart, (UINT32)LegacyBiosImageSize, EfiCpuFlushTypeWriteBackInvalidate);
+ Private->LegacyRegion->Lock (Private->LegacyRegion, Private->BiosStart, (UINT32)LegacyBiosImageSize, &Granularity);
//
// Get the BbsTable from LOW_MEMORY_THUNK
@@ -563,8 +562,8 @@ ShadowAndStartLegacy16 (
BbsTable = (BBS_TABLE *)(UINTN)Private->IntThunk->BbsTable;
ZeroMem ((VOID *)BbsTable, sizeof (Private->IntThunk->BbsTable));
- EfiToLegacy16BootTable->BbsTable = (UINT32)(UINTN)BbsTable;
- Private->BbsTablePtr = (VOID *) BbsTable;
+ EfiToLegacy16BootTable->BbsTable = (UINT32)(UINTN)BbsTable;
+ Private->BbsTablePtr = (VOID *)BbsTable;
//
// Populate entire table with BBS_IGNORE_ENTRY
@@ -574,10 +573,11 @@ ShadowAndStartLegacy16 (
for (Index = 0; Index < MAX_BBS_ENTRIES; Index++) {
BbsTable[Index].BootPriority = BBS_IGNORE_ENTRY;
}
+
//
// Allocate space for Legacy HDD table
//
- LegacyEfiHddTable = (LEGACY_EFI_HDD_TABLE *) AllocateZeroPool ((UINTN) MAX_HDD_ENTRIES * sizeof (LEGACY_EFI_HDD_TABLE));
+ LegacyEfiHddTable = (LEGACY_EFI_HDD_TABLE *)AllocateZeroPool ((UINTN)MAX_HDD_ENTRIES * sizeof (LEGACY_EFI_HDD_TABLE));
ASSERT (LegacyEfiHddTable);
Private->LegacyEfiHddTable = LegacyEfiHddTable;
@@ -612,7 +612,7 @@ ShadowAndStartLegacy16 (
EFI_STATUS
EFIAPI
LegacyBiosShadowAllLegacyOproms (
- IN EFI_LEGACY_BIOS_PROTOCOL *This
+ IN EFI_LEGACY_BIOS_PROTOCOL *This
)
{
LEGACY_BIOS_INSTANCE *Private;
@@ -657,16 +657,16 @@ LegacyBiosShadowAllLegacyOproms (
**/
UINT16
GetPciInterfaceVersion (
- IN LEGACY_BIOS_INSTANCE *Private
+ IN LEGACY_BIOS_INSTANCE *Private
)
{
- EFI_IA32_REGISTER_SET Reg;
- BOOLEAN ThunkFailed;
- UINT16 PciInterfaceVersion;
+ EFI_IA32_REGISTER_SET Reg;
+ BOOLEAN ThunkFailed;
+ UINT16 PciInterfaceVersion;
PciInterfaceVersion = 0;
- Reg.X.AX = 0xB101;
+ Reg.X.AX = 0xB101;
Reg.E.EDI = 0;
ThunkFailed = Private->LegacyBios.Int86 (&Private->LegacyBios, 0x1A, &Reg);
@@ -684,6 +684,7 @@ GetPciInterfaceVersion (
PciInterfaceVersion = Reg.X.BX;
}
}
+
return PciInterfaceVersion;
}
@@ -699,25 +700,25 @@ GetPciInterfaceVersion (
VOID
EFIAPI
InstallSmbiosEventCallback (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- EFI_STATUS Status;
- SMBIOS_TABLE_ENTRY_POINT *EntryPointStructure;
+ EFI_STATUS Status;
+ SMBIOS_TABLE_ENTRY_POINT *EntryPointStructure;
//
// Get SMBIOS table from EFI configuration table
//
Status = EfiGetSystemConfigurationTable (
- &gEfiSmbiosTableGuid,
- &mRuntimeSmbiosEntryPoint
- );
+ &gEfiSmbiosTableGuid,
+ &mRuntimeSmbiosEntryPoint
+ );
if ((EFI_ERROR (Status)) || (mRuntimeSmbiosEntryPoint == NULL)) {
return;
}
- EntryPointStructure = (SMBIOS_TABLE_ENTRY_POINT *) mRuntimeSmbiosEntryPoint;
+ EntryPointStructure = (SMBIOS_TABLE_ENTRY_POINT *)mRuntimeSmbiosEntryPoint;
//
// Allocate memory for SMBIOS Entry Point Structure.
@@ -728,21 +729,23 @@ InstallSmbiosEventCallback (
// Entrypoint structure with fixed size is allocated only once.
//
mReserveSmbiosEntryPoint = SIZE_4GB - 1;
- Status = gBS->AllocatePages (
- AllocateMaxAddress,
- EfiReservedMemoryType,
- EFI_SIZE_TO_PAGES ((UINTN) (EntryPointStructure->EntryPointLength)),
- &mReserveSmbiosEntryPoint
- );
+ Status = gBS->AllocatePages (
+ AllocateMaxAddress,
+ EfiReservedMemoryType,
+ EFI_SIZE_TO_PAGES ((UINTN)(EntryPointStructure->EntryPointLength)),
+ &mReserveSmbiosEntryPoint
+ );
if (EFI_ERROR (Status)) {
mReserveSmbiosEntryPoint = 0;
return;
}
+
DEBUG ((DEBUG_INFO, "Allocate memory for Smbios Entry Point Structure\n"));
}
if ((mStructureTableAddress != 0) &&
- (mStructureTablePages < EFI_SIZE_TO_PAGES ((UINT32)EntryPointStructure->TableLength))) {
+ (mStructureTablePages < EFI_SIZE_TO_PAGES ((UINT32)EntryPointStructure->TableLength)))
+ {
//
// If original buffer is not enough for the new SMBIOS table, free original buffer and re-allocate
//
@@ -759,22 +762,23 @@ InstallSmbiosEventCallback (
//
mStructureTableAddress = SIZE_4GB - 1;
mStructureTablePages = EFI_SIZE_TO_PAGES (EntryPointStructure->TableLength);
- Status = gBS->AllocatePages (
- AllocateMaxAddress,
- EfiReservedMemoryType,
- mStructureTablePages,
- &mStructureTableAddress
- );
+ Status = gBS->AllocatePages (
+ AllocateMaxAddress,
+ EfiReservedMemoryType,
+ mStructureTablePages,
+ &mStructureTableAddress
+ );
if (EFI_ERROR (Status)) {
gBS->FreePages (
- mReserveSmbiosEntryPoint,
- EFI_SIZE_TO_PAGES ((UINTN) (EntryPointStructure->EntryPointLength))
- );
+ mReserveSmbiosEntryPoint,
+ EFI_SIZE_TO_PAGES ((UINTN)(EntryPointStructure->EntryPointLength))
+ );
mReserveSmbiosEntryPoint = 0;
mStructureTableAddress = 0;
mStructureTablePages = 0;
return;
}
+
DEBUG ((DEBUG_INFO, "Allocate memory for Smbios Structure Table\n"));
}
}
@@ -791,8 +795,8 @@ InstallSmbiosEventCallback (
VOID
EFIAPI
ToggleEndOfDxeStatus (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
mEndOfDxe = TRUE;
@@ -812,8 +816,8 @@ ToggleEndOfDxeStatus (
EFI_STATUS
EFIAPI
LegacyBiosInstall (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
@@ -850,7 +854,7 @@ LegacyBiosInstall (
// When UEFI Secure Boot is enabled, CSM module will not start any more.
//
SecureBoot = NULL;
- GetEfiGlobalVariable2 (EFI_SECURE_BOOT_MODE_NAME, (VOID**)&SecureBoot, NULL);
+ GetEfiGlobalVariable2 (EFI_SECURE_BOOT_MODE_NAME, (VOID **)&SecureBoot, NULL);
if ((SecureBoot != NULL) && (*SecureBoot == SECURE_BOOT_MODE_ENABLE)) {
FreePool (SecureBoot);
return EFI_SECURITY_VIOLATION;
@@ -867,22 +871,22 @@ LegacyBiosInstall (
// Grab a copy of all the protocols we depend on. Any error would
// be a dispatcher bug!.
//
- Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **) &Private->Cpu);
+ Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **)&Private->Cpu);
ASSERT_EFI_ERROR (Status);
- Status = gBS->LocateProtocol (&gEfiTimerArchProtocolGuid, NULL, (VOID **) &Private->Timer);
+ Status = gBS->LocateProtocol (&gEfiTimerArchProtocolGuid, NULL, (VOID **)&Private->Timer);
ASSERT_EFI_ERROR (Status);
- Status = gBS->LocateProtocol (&gEfiLegacyRegion2ProtocolGuid, NULL, (VOID **) &Private->LegacyRegion);
+ Status = gBS->LocateProtocol (&gEfiLegacyRegion2ProtocolGuid, NULL, (VOID **)&Private->LegacyRegion);
ASSERT_EFI_ERROR (Status);
- Status = gBS->LocateProtocol (&gEfiLegacyBiosPlatformProtocolGuid, NULL, (VOID **) &Private->LegacyBiosPlatform);
+ Status = gBS->LocateProtocol (&gEfiLegacyBiosPlatformProtocolGuid, NULL, (VOID **)&Private->LegacyBiosPlatform);
ASSERT_EFI_ERROR (Status);
- Status = gBS->LocateProtocol (&gEfiLegacy8259ProtocolGuid, NULL, (VOID **) &Private->Legacy8259);
+ Status = gBS->LocateProtocol (&gEfiLegacy8259ProtocolGuid, NULL, (VOID **)&Private->Legacy8259);
ASSERT_EFI_ERROR (Status);
- Status = gBS->LocateProtocol (&gEfiLegacyInterruptProtocolGuid, NULL, (VOID **) &Private->LegacyInterrupt);
+ Status = gBS->LocateProtocol (&gEfiLegacyInterruptProtocolGuid, NULL, (VOID **)&Private->LegacyInterrupt);
ASSERT_EFI_ERROR (Status);
//
@@ -891,7 +895,7 @@ LegacyBiosInstall (
Status = gBS->LocateProtocol (
&gEfiGenericMemTestProtocolGuid,
NULL,
- (VOID **) &Private->GenericMemoryTest
+ (VOID **)&Private->GenericMemoryTest
);
ASSERT_EFI_ERROR (Status);
@@ -904,6 +908,7 @@ LegacyBiosInstall (
StartAddress = Descriptor.BaseAddress + Descriptor.Length;
continue;
}
+
Length = MIN (Descriptor.Length, 0xa0000 - StartAddress);
Private->GenericMemoryTest->CompatibleRangeTest (
Private->GenericMemoryTest,
@@ -912,6 +917,7 @@ LegacyBiosInstall (
);
StartAddress = StartAddress + Length;
}
+
//
// Make sure all memory from 1MB to 16MB is tested and added to memory map
//
@@ -921,6 +927,7 @@ LegacyBiosInstall (
StartAddress = Descriptor.BaseAddress + Descriptor.Length;
continue;
}
+
Length = MIN (Descriptor.Length, BASE_16MB - StartAddress);
Private->GenericMemoryTest->CompatibleRangeTest (
Private->GenericMemoryTest,
@@ -932,17 +939,17 @@ LegacyBiosInstall (
Private->Signature = LEGACY_BIOS_INSTANCE_SIGNATURE;
- Private->LegacyBios.Int86 = LegacyBiosInt86;
- Private->LegacyBios.FarCall86 = LegacyBiosFarCall86;
- Private->LegacyBios.CheckPciRom = LegacyBiosCheckPciRom;
- Private->LegacyBios.InstallPciRom = LegacyBiosInstallPciRom;
- Private->LegacyBios.LegacyBoot = LegacyBiosLegacyBoot;
- Private->LegacyBios.UpdateKeyboardLedStatus = LegacyBiosUpdateKeyboardLedStatus;
- Private->LegacyBios.GetBbsInfo = LegacyBiosGetBbsInfo;
- Private->LegacyBios.ShadowAllLegacyOproms = LegacyBiosShadowAllLegacyOproms;
- Private->LegacyBios.PrepareToBootEfi = LegacyBiosPrepareToBootEfi;
- Private->LegacyBios.GetLegacyRegion = LegacyBiosGetLegacyRegion;
- Private->LegacyBios.CopyLegacyRegion = LegacyBiosCopyLegacyRegion;
+ Private->LegacyBios.Int86 = LegacyBiosInt86;
+ Private->LegacyBios.FarCall86 = LegacyBiosFarCall86;
+ Private->LegacyBios.CheckPciRom = LegacyBiosCheckPciRom;
+ Private->LegacyBios.InstallPciRom = LegacyBiosInstallPciRom;
+ Private->LegacyBios.LegacyBoot = LegacyBiosLegacyBoot;
+ Private->LegacyBios.UpdateKeyboardLedStatus = LegacyBiosUpdateKeyboardLedStatus;
+ Private->LegacyBios.GetBbsInfo = LegacyBiosGetBbsInfo;
+ Private->LegacyBios.ShadowAllLegacyOproms = LegacyBiosShadowAllLegacyOproms;
+ Private->LegacyBios.PrepareToBootEfi = LegacyBiosPrepareToBootEfi;
+ Private->LegacyBios.GetLegacyRegion = LegacyBiosGetLegacyRegion;
+ Private->LegacyBios.CopyLegacyRegion = LegacyBiosCopyLegacyRegion;
Private->LegacyBios.BootUnconventionalDevice = LegacyBiosBootUnconventionalDevice;
Private->ImageHandle = ImageHandle;
@@ -994,16 +1001,16 @@ LegacyBiosInstall (
);
ASSERT (MemoryAddress == 0x000000000);
- ClearPtr = (VOID *) ((UINTN) 0x0000);
+ ClearPtr = (VOID *)((UINTN)0x0000);
//
// Initialize region from 0x0000 to 4k. This initializes interrupt vector
// range.
//
ACCESS_PAGE0_CODE (
- gBS->SetMem ((VOID *) ClearPtr, 0x400, INITIAL_VALUE_BELOW_1K);
- ZeroMem ((VOID *) ((UINTN)ClearPtr + 0x400), 0xC00);
- );
+ gBS->SetMem ((VOID *)ClearPtr, 0x400, INITIAL_VALUE_BELOW_1K);
+ ZeroMem ((VOID *)((UINTN)ClearPtr + 0x400), 0xC00);
+ );
//
// Allocate pages for OPROM usage
@@ -1020,7 +1027,7 @@ LegacyBiosInstall (
);
ASSERT_EFI_ERROR (Status);
- ZeroMem ((VOID *) ((UINTN) MemoryAddress), MemorySize);
+ ZeroMem ((VOID *)((UINTN)MemoryAddress), MemorySize);
//
// Allocate all 32k chunks from 0x60000 ~ 0x88000 for Legacy OPROMs that
@@ -1028,8 +1035,8 @@ LegacyBiosInstall (
// OpROMs expect different areas to be free
//
EbdaReservedBaseAddress = MemoryAddress;
- MemoryAddress = PcdGet32 (PcdOpromReservedMemoryBase);
- MemorySize = PcdGet32 (PcdOpromReservedMemorySize);
+ MemoryAddress = PcdGet32 (PcdOpromReservedMemoryBase);
+ MemorySize = PcdGet32 (PcdOpromReservedMemorySize);
//
// Check if base address and size for reserved memory are 4KB aligned.
//
@@ -1048,7 +1055,7 @@ LegacyBiosInstall (
&StartAddress
);
if (!EFI_ERROR (Status)) {
- MemoryPtr = (VOID *) ((UINTN) StartAddress);
+ MemoryPtr = (VOID *)((UINTN)StartAddress);
ZeroMem (MemoryPtr, 0x1000);
} else {
DEBUG ((DEBUG_ERROR, "WARNING: Allocate legacy memory fail for SCSI card - %x\n", MemStart));
@@ -1069,7 +1076,7 @@ LegacyBiosInstall (
);
ASSERT_EFI_ERROR (Status);
- ZeroMem ((VOID *) ((UINTN) MemoryAddressUnder1MB), MemorySize);
+ ZeroMem ((VOID *)((UINTN)MemoryAddressUnder1MB), MemorySize);
//
// Allocate space for thunker and Init Thunker
@@ -1082,10 +1089,10 @@ LegacyBiosInstall (
&MemoryAddress
);
ASSERT_EFI_ERROR (Status);
- Private->IntThunk = (LOW_MEMORY_THUNK *) (UINTN) MemoryAddress;
+ Private->IntThunk = (LOW_MEMORY_THUNK *)(UINTN)MemoryAddress;
EfiToLegacy16InitTable = &Private->IntThunk->EfiToLegacy16InitTable;
- EfiToLegacy16InitTable->ThunkStart = (UINT32) (EFI_PHYSICAL_ADDRESS) (UINTN) MemoryAddress;
- EfiToLegacy16InitTable->ThunkSizeInBytes = (UINT32) (sizeof (LOW_MEMORY_THUNK));
+ EfiToLegacy16InitTable->ThunkStart = (UINT32)(EFI_PHYSICAL_ADDRESS)(UINTN)MemoryAddress;
+ EfiToLegacy16InitTable->ThunkSizeInBytes = (UINT32)(sizeof (LOW_MEMORY_THUNK));
Status = LegacyBiosInitializeThunk (Private);
ASSERT_EFI_ERROR (Status);
@@ -1093,8 +1100,8 @@ LegacyBiosInstall (
//
// Init the legacy memory map in memory < 1 MB.
//
- EfiToLegacy16InitTable->BiosLessThan1MB = (UINT32) MemoryAddressUnder1MB;
- EfiToLegacy16InitTable->LowPmmMemory = (UINT32) MemoryAddressUnder1MB;
+ EfiToLegacy16InitTable->BiosLessThan1MB = (UINT32)MemoryAddressUnder1MB;
+ EfiToLegacy16InitTable->LowPmmMemory = (UINT32)MemoryAddressUnder1MB;
EfiToLegacy16InitTable->LowPmmMemorySizeInBytes = MemorySize;
MemorySize = PcdGet32 (PcdHighPmmMemorySize);
@@ -1121,8 +1128,9 @@ LegacyBiosInstall (
&MemoryAddress
);
}
+
if (!EFI_ERROR (Status)) {
- EfiToLegacy16InitTable->HiPmmMemory = (UINT32) (EFI_PHYSICAL_ADDRESS) (UINTN) MemoryAddress;
+ EfiToLegacy16InitTable->HiPmmMemory = (UINT32)(EFI_PHYSICAL_ADDRESS)(UINTN)MemoryAddress;
EfiToLegacy16InitTable->HiPmmMemorySizeInBytes = MemorySize;
}
@@ -1135,32 +1143,34 @@ LegacyBiosInstall (
if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Initialize interrupt redirection code and entries;
// IDT Vectors 0x68-0x6f must be redirected to IDT Vectors 0x08-0x0f.
//
CopyMem (
- Private->IntThunk->InterruptRedirectionCode,
- (VOID *) (UINTN) InterruptRedirectionTemplate,
- sizeof (Private->IntThunk->InterruptRedirectionCode)
- );
+ Private->IntThunk->InterruptRedirectionCode,
+ (VOID *)(UINTN)InterruptRedirectionTemplate,
+ sizeof (Private->IntThunk->InterruptRedirectionCode)
+ );
//
// Save Unexpected interrupt vector so can restore it just prior to boot
//
ACCESS_PAGE0_CODE (
- BaseVectorMaster = (UINT32 *) (sizeof (UINT32) * PROTECTED_MODE_BASE_VECTOR_MASTER);
+ BaseVectorMaster = (UINT32 *)(sizeof (UINT32) * PROTECTED_MODE_BASE_VECTOR_MASTER);
Private->BiosUnexpectedInt = BaseVectorMaster[0];
- IntRedirCode = (UINT32) (UINTN) Private->IntThunk->InterruptRedirectionCode;
+ IntRedirCode = (UINT32)(UINTN)Private->IntThunk->InterruptRedirectionCode;
for (Index = 0; Index < 8; Index++) {
- BaseVectorMaster[Index] = (EFI_SEGMENT (IntRedirCode + Index * 4) << 16) | EFI_OFFSET (IntRedirCode + Index * 4);
- }
- );
+ BaseVectorMaster[Index] = (EFI_SEGMENT (IntRedirCode + Index * 4) << 16) | EFI_OFFSET (IntRedirCode + Index * 4);
+ }
+
+ );
//
// Save EFI value
//
- Private->ThunkSeg = (UINT16) (EFI_SEGMENT (IntRedirCode));
+ Private->ThunkSeg = (UINT16)(EFI_SEGMENT (IntRedirCode));
//
// Allocate reserved memory for SMBIOS table used in legacy boot if SMBIOS table exists
@@ -1198,18 +1208,20 @@ LegacyBiosInstall (
// Make a new handle and install the protocol
//
Private->Handle = NULL;
- Status = gBS->InstallProtocolInterface (
- &Private->Handle,
- &gEfiLegacyBiosProtocolGuid,
- EFI_NATIVE_INTERFACE,
- &Private->LegacyBios
- );
+ Status = gBS->InstallProtocolInterface (
+ &Private->Handle,
+ &gEfiLegacyBiosProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ &Private->LegacyBios
+ );
Private->Csm16PciInterfaceVersion = GetPciInterfaceVersion (Private);
- DEBUG ((DEBUG_INFO, "CSM16 PCI BIOS Interface Version: %02x.%02x\n",
- (UINT8) (Private->Csm16PciInterfaceVersion >> 8),
- (UINT8) Private->Csm16PciInterfaceVersion
- ));
+ DEBUG ((
+ DEBUG_INFO,
+ "CSM16 PCI BIOS Interface Version: %02x.%02x\n",
+ (UINT8)(Private->Csm16PciInterfaceVersion >> 8),
+ (UINT8)Private->Csm16PciInterfaceVersion
+ ));
ASSERT (Private->Csm16PciInterfaceVersion != 0);
return Status;
}
diff --git a/OvmfPkg/Csm/LegacyBiosDxe/LegacyBiosInterface.h b/OvmfPkg/Csm/LegacyBiosDxe/LegacyBiosInterface.h
index f437d0cc42..5a706d9ea6 100644
--- a/OvmfPkg/Csm/LegacyBiosDxe/LegacyBiosInterface.h
+++ b/OvmfPkg/Csm/LegacyBiosDxe/LegacyBiosInterface.h
@@ -9,7 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _LEGACY_BIOS_INTERFACE_
#define _LEGACY_BIOS_INTERFACE_
-
#include <FrameworkDxe.h>
#include <IndustryStandard/Pci.h>
#include <IndustryStandard/SmBios.h>
@@ -62,7 +61,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// BUGBUG: This entry maybe changed to PCD in future and wait for
// redesign of BDS library
//
-#define MAX_BBS_ENTRIES 0x100
+#define MAX_BBS_ENTRIES 0x100
//
// Thunk Status Codes
@@ -79,8 +78,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//
// 8259 Hardware definitions
//
-#define LEGACY_MODE_BASE_VECTOR_MASTER 0x08
-#define LEGACY_MODE_BASE_VECTOR_SLAVE 0x70
+#define LEGACY_MODE_BASE_VECTOR_MASTER 0x08
+#define LEGACY_MODE_BASE_VECTOR_SLAVE 0x70
//
// The original PC used INT8-F for master PIC. Since these mapped over
@@ -96,53 +95,53 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// offset + 0xabcd could overflow which exceeds 0xFFFF which is invalid in real mode.
// So this will keep offset as small as possible to avoid offset overflow in real mode.
//
-#define NORMALIZE_EFI_SEGMENT(_Adr) (UINT16) (((UINTN) (_Adr)) >> 4)
-#define NORMALIZE_EFI_OFFSET(_Adr) (UINT16) (((UINT16) ((UINTN) (_Adr))) & 0xf)
+#define NORMALIZE_EFI_SEGMENT(_Adr) (UINT16) (((UINTN) (_Adr)) >> 4)
+#define NORMALIZE_EFI_OFFSET(_Adr) (UINT16) (((UINT16) ((UINTN) (_Adr))) & 0xf)
//
// Trace defines
//
//
-#define LEGACY_BDA_TRACE 0x000
-#define LEGACY_BIOS_TRACE 0x040
-#define LEGACY_BOOT_TRACE 0x080
-#define LEGACY_CMOS_TRACE 0x0C0
-#define LEGACY_IDE_TRACE 0x100
-#define LEGACY_MP_TRACE 0x140
-#define LEGACY_PCI_TRACE 0x180
-#define LEGACY_SIO_TRACE 0x1C0
-
-#define LEGACY_PCI_TRACE_000 LEGACY_PCI_TRACE + 0x00
-#define LEGACY_PCI_TRACE_001 LEGACY_PCI_TRACE + 0x01
-#define LEGACY_PCI_TRACE_002 LEGACY_PCI_TRACE + 0x02
-#define LEGACY_PCI_TRACE_003 LEGACY_PCI_TRACE + 0x03
-#define LEGACY_PCI_TRACE_004 LEGACY_PCI_TRACE + 0x04
-#define LEGACY_PCI_TRACE_005 LEGACY_PCI_TRACE + 0x05
-#define LEGACY_PCI_TRACE_006 LEGACY_PCI_TRACE + 0x06
-#define LEGACY_PCI_TRACE_007 LEGACY_PCI_TRACE + 0x07
-#define LEGACY_PCI_TRACE_008 LEGACY_PCI_TRACE + 0x08
-#define LEGACY_PCI_TRACE_009 LEGACY_PCI_TRACE + 0x09
-#define LEGACY_PCI_TRACE_00A LEGACY_PCI_TRACE + 0x0A
-#define LEGACY_PCI_TRACE_00B LEGACY_PCI_TRACE + 0x0B
-#define LEGACY_PCI_TRACE_00C LEGACY_PCI_TRACE + 0x0C
-#define LEGACY_PCI_TRACE_00D LEGACY_PCI_TRACE + 0x0D
-#define LEGACY_PCI_TRACE_00E LEGACY_PCI_TRACE + 0x0E
-#define LEGACY_PCI_TRACE_00F LEGACY_PCI_TRACE + 0x0F
-
-#define BDA_VIDEO_MODE 0x49
-
-#define IDE_PI_REGISTER_PNE BIT0
-#define IDE_PI_REGISTER_SNE BIT2
+#define LEGACY_BDA_TRACE 0x000
+#define LEGACY_BIOS_TRACE 0x040
+#define LEGACY_BOOT_TRACE 0x080
+#define LEGACY_CMOS_TRACE 0x0C0
+#define LEGACY_IDE_TRACE 0x100
+#define LEGACY_MP_TRACE 0x140
+#define LEGACY_PCI_TRACE 0x180
+#define LEGACY_SIO_TRACE 0x1C0
+
+#define LEGACY_PCI_TRACE_000 LEGACY_PCI_TRACE + 0x00
+#define LEGACY_PCI_TRACE_001 LEGACY_PCI_TRACE + 0x01
+#define LEGACY_PCI_TRACE_002 LEGACY_PCI_TRACE + 0x02
+#define LEGACY_PCI_TRACE_003 LEGACY_PCI_TRACE + 0x03
+#define LEGACY_PCI_TRACE_004 LEGACY_PCI_TRACE + 0x04
+#define LEGACY_PCI_TRACE_005 LEGACY_PCI_TRACE + 0x05
+#define LEGACY_PCI_TRACE_006 LEGACY_PCI_TRACE + 0x06
+#define LEGACY_PCI_TRACE_007 LEGACY_PCI_TRACE + 0x07
+#define LEGACY_PCI_TRACE_008 LEGACY_PCI_TRACE + 0x08
+#define LEGACY_PCI_TRACE_009 LEGACY_PCI_TRACE + 0x09
+#define LEGACY_PCI_TRACE_00A LEGACY_PCI_TRACE + 0x0A
+#define LEGACY_PCI_TRACE_00B LEGACY_PCI_TRACE + 0x0B
+#define LEGACY_PCI_TRACE_00C LEGACY_PCI_TRACE + 0x0C
+#define LEGACY_PCI_TRACE_00D LEGACY_PCI_TRACE + 0x0D
+#define LEGACY_PCI_TRACE_00E LEGACY_PCI_TRACE + 0x0E
+#define LEGACY_PCI_TRACE_00F LEGACY_PCI_TRACE + 0x0F
+
+#define BDA_VIDEO_MODE 0x49
+
+#define IDE_PI_REGISTER_PNE BIT0
+#define IDE_PI_REGISTER_SNE BIT2
typedef struct {
- UINTN PciSegment;
- UINTN PciBus;
- UINTN PciDevice;
- UINTN PciFunction;
- UINT32 ShadowAddress;
- UINT32 ShadowedSize;
- UINT8 DiskStart;
- UINT8 DiskEnd;
+ UINTN PciSegment;
+ UINTN PciBus;
+ UINTN PciDevice;
+ UINTN PciFunction;
+ UINT32 ShadowAddress;
+ UINT32 ShadowedSize;
+ UINT8 DiskStart;
+ UINT8 DiskEnd;
} ROM_INSTANCE_ENTRY;
//
@@ -150,15 +149,15 @@ typedef struct {
//
#if defined (MDE_CPU_IA32)
-#define NUM_REAL_GDT_ENTRIES 3
-#define CONVENTIONAL_MEMORY_TOP 0xA0000 // 640 KB
-#define INITIAL_VALUE_BELOW_1K 0x0
+#define NUM_REAL_GDT_ENTRIES 3
+#define CONVENTIONAL_MEMORY_TOP 0xA0000 // 640 KB
+#define INITIAL_VALUE_BELOW_1K 0x0
#elif defined (MDE_CPU_X64)
-#define NUM_REAL_GDT_ENTRIES 8
-#define CONVENTIONAL_MEMORY_TOP 0xA0000 // 640 KB
-#define INITIAL_VALUE_BELOW_1K 0x0
+#define NUM_REAL_GDT_ENTRIES 8
+#define CONVENTIONAL_MEMORY_TOP 0xA0000 // 640 KB
+#define INITIAL_VALUE_BELOW_1K 0x0
#endif
@@ -168,28 +167,28 @@ typedef struct {
// Define what a processor GDT looks like
//
typedef struct {
- UINT32 LimitLo : 16;
- UINT32 BaseLo : 16;
- UINT32 BaseMid : 8;
- UINT32 Type : 4;
- UINT32 System : 1;
- UINT32 Dpl : 2;
- UINT32 Present : 1;
- UINT32 LimitHi : 4;
- UINT32 Software : 1;
- UINT32 Reserved : 1;
- UINT32 DefaultSize : 1;
- UINT32 Granularity : 1;
- UINT32 BaseHi : 8;
+ UINT32 LimitLo : 16;
+ UINT32 BaseLo : 16;
+ UINT32 BaseMid : 8;
+ UINT32 Type : 4;
+ UINT32 System : 1;
+ UINT32 Dpl : 2;
+ UINT32 Present : 1;
+ UINT32 LimitHi : 4;
+ UINT32 Software : 1;
+ UINT32 Reserved : 1;
+ UINT32 DefaultSize : 1;
+ UINT32 Granularity : 1;
+ UINT32 BaseHi : 8;
} GDT32;
typedef struct {
- UINT16 LimitLow;
- UINT16 BaseLow;
- UINT8 BaseMid;
- UINT8 Attribute;
- UINT8 LimitHi;
- UINT8 BaseHi;
+ UINT16 LimitLow;
+ UINT16 BaseLow;
+ UINT8 BaseMid;
+ UINT8 Attribute;
+ UINT8 LimitHi;
+ UINT8 BaseHi;
} GDT64;
//
@@ -197,13 +196,13 @@ typedef struct {
// This data structure must be kept in sync with ASM STRUCT in Thunk.inc
//
typedef struct {
- UINT16 Limit;
- UINT64 Base;
+ UINT16 Limit;
+ UINT64 Base;
} DESCRIPTOR64;
typedef struct {
- UINT16 Limit;
- UINT32 Base;
+ UINT16 Limit;
+ UINT32 Base;
} DESCRIPTOR32;
//
@@ -220,33 +219,33 @@ typedef struct {
// Space for the code
// The address of Code is also the beginning of the relocated Thunk code
//
- CHAR8 Code[4096]; // ?
+ CHAR8 Code[4096]; // ?
//
// The address of the Reverse Thunk code
// Note that this member CONTAINS the address of the relocated reverse thunk
// code unlike the member variable 'Code', which IS the address of the Thunk
// code.
//
- UINT32 LowReverseThunkStart;
+ UINT32 LowReverseThunkStart;
//
// Data for the code (cs releative)
//
- DESCRIPTOR32 GdtDesc; // Protected mode GDT
- DESCRIPTOR32 IdtDesc; // Protected mode IDT
- UINT32 FlatSs;
- UINT32 FlatEsp;
+ DESCRIPTOR32 GdtDesc; // Protected mode GDT
+ DESCRIPTOR32 IdtDesc; // Protected mode IDT
+ UINT32 FlatSs;
+ UINT32 FlatEsp;
- UINT32 LowCodeSelector; // Low code selector in GDT
- UINT32 LowDataSelector; // Low data selector in GDT
- UINT32 LowStack;
- DESCRIPTOR32 RealModeIdtDesc;
+ UINT32 LowCodeSelector; // Low code selector in GDT
+ UINT32 LowDataSelector; // Low data selector in GDT
+ UINT32 LowStack;
+ DESCRIPTOR32 RealModeIdtDesc;
//
// real-mode GDT (temporary GDT with two real mode segment descriptors)
//
- GDT32 RealModeGdt[NUM_REAL_GDT_ENTRIES];
- DESCRIPTOR32 RealModeGdtDesc;
+ GDT32 RealModeGdt[NUM_REAL_GDT_ENTRIES];
+ DESCRIPTOR32 RealModeGdtDesc;
//
// Members specifically for the reverse thunk
@@ -254,36 +253,36 @@ typedef struct {
// before performing the reverse thunk. The RevFlat* members must be set
// before calling the reverse thunk assembly code.
//
- UINT16 RevRealDs;
- UINT16 RevRealSs;
- UINT32 RevRealEsp;
- DESCRIPTOR32 RevRealIdtDesc;
- UINT16 RevFlatDataSelector; // Flat data selector in GDT
- UINT32 RevFlatStack;
+ UINT16 RevRealDs;
+ UINT16 RevRealSs;
+ UINT32 RevRealEsp;
+ DESCRIPTOR32 RevRealIdtDesc;
+ UINT16 RevFlatDataSelector; // Flat data selector in GDT
+ UINT32 RevFlatStack;
//
// A low memory stack
//
- CHAR8 Stack[LOW_STACK_SIZE];
+ CHAR8 Stack[LOW_STACK_SIZE];
//
// Stack for flat mode after reverse thunk
// @bug - This may no longer be necessary if the reverse thunk interface
// is changed to have the flat stack in a different location.
//
- CHAR8 RevThunkStack[LOW_STACK_SIZE];
+ CHAR8 RevThunkStack[LOW_STACK_SIZE];
//
// Legacy16 Init memory map info
//
- EFI_TO_COMPATIBILITY16_INIT_TABLE EfiToLegacy16InitTable;
+ EFI_TO_COMPATIBILITY16_INIT_TABLE EfiToLegacy16InitTable;
- EFI_TO_COMPATIBILITY16_BOOT_TABLE EfiToLegacy16BootTable;
+ EFI_TO_COMPATIBILITY16_BOOT_TABLE EfiToLegacy16BootTable;
- CHAR8 InterruptRedirectionCode[32];
- EFI_LEGACY_INSTALL_PCI_HANDLER PciHandler;
- EFI_DISPATCH_OPROM_TABLE DispatchOpromTable;
- BBS_TABLE BbsTable[MAX_BBS_ENTRIES];
+ CHAR8 InterruptRedirectionCode[32];
+ EFI_LEGACY_INSTALL_PCI_HANDLER PciHandler;
+ EFI_DISPATCH_OPROM_TABLE DispatchOpromTable;
+ BBS_TABLE BbsTable[MAX_BBS_ENTRIES];
} LOW_MEMORY_THUNK;
#elif defined (MDE_CPU_X64)
@@ -293,42 +292,42 @@ typedef struct {
// Space for the code
// The address of Code is also the beginning of the relocated Thunk code
//
- CHAR8 Code[4096]; // ?
+ CHAR8 Code[4096]; // ?
//
// Data for the code (cs releative)
//
- DESCRIPTOR64 X64GdtDesc; // Protected mode GDT
- DESCRIPTOR64 X64IdtDesc; // Protected mode IDT
- UINTN X64Ss;
- UINTN X64Esp;
+ DESCRIPTOR64 X64GdtDesc; // Protected mode GDT
+ DESCRIPTOR64 X64IdtDesc; // Protected mode IDT
+ UINTN X64Ss;
+ UINTN X64Esp;
- UINTN RealStack;
- DESCRIPTOR32 RealModeIdtDesc;
- DESCRIPTOR32 RealModeGdtDesc;
+ UINTN RealStack;
+ DESCRIPTOR32 RealModeIdtDesc;
+ DESCRIPTOR32 RealModeGdtDesc;
//
// real-mode GDT (temporary GDT with two real mode segment descriptors)
//
- GDT64 RealModeGdt[NUM_REAL_GDT_ENTRIES];
- UINT64 PageMapLevel4;
+ GDT64 RealModeGdt[NUM_REAL_GDT_ENTRIES];
+ UINT64 PageMapLevel4;
//
// A low memory stack
//
- CHAR8 Stack[LOW_STACK_SIZE];
+ CHAR8 Stack[LOW_STACK_SIZE];
//
// Legacy16 Init memory map info
//
- EFI_TO_COMPATIBILITY16_INIT_TABLE EfiToLegacy16InitTable;
+ EFI_TO_COMPATIBILITY16_INIT_TABLE EfiToLegacy16InitTable;
- EFI_TO_COMPATIBILITY16_BOOT_TABLE EfiToLegacy16BootTable;
+ EFI_TO_COMPATIBILITY16_BOOT_TABLE EfiToLegacy16BootTable;
- CHAR8 InterruptRedirectionCode[32];
- EFI_LEGACY_INSTALL_PCI_HANDLER PciHandler;
- EFI_DISPATCH_OPROM_TABLE DispatchOpromTable;
- BBS_TABLE BbsTable[MAX_BBS_ENTRIES];
+ CHAR8 InterruptRedirectionCode[32];
+ EFI_LEGACY_INSTALL_PCI_HANDLER PciHandler;
+ EFI_DISPATCH_OPROM_TABLE DispatchOpromTable;
+ BBS_TABLE BbsTable[MAX_BBS_ENTRIES];
} LOW_MEMORY_THUNK;
#endif
@@ -337,42 +336,42 @@ typedef struct {
// PnP Expansion Header
//
typedef struct {
- UINT32 PnpSignature;
- UINT8 Revision;
- UINT8 Length;
- UINT16 NextHeader;
- UINT8 Reserved1;
- UINT8 Checksum;
- UINT32 DeviceId;
- UINT16 MfgPointer;
- UINT16 ProductNamePointer;
- UINT8 Class;
- UINT8 SubClass;
- UINT8 Interface;
- UINT8 DeviceIndicators;
- UINT16 Bcv;
- UINT16 DisconnectVector;
- UINT16 Bev;
- UINT16 Reserved2;
- UINT16 StaticResourceVector;
+ UINT32 PnpSignature;
+ UINT8 Revision;
+ UINT8 Length;
+ UINT16 NextHeader;
+ UINT8 Reserved1;
+ UINT8 Checksum;
+ UINT32 DeviceId;
+ UINT16 MfgPointer;
+ UINT16 ProductNamePointer;
+ UINT8 Class;
+ UINT8 SubClass;
+ UINT8 Interface;
+ UINT8 DeviceIndicators;
+ UINT16 Bcv;
+ UINT16 DisconnectVector;
+ UINT16 Bev;
+ UINT16 Reserved2;
+ UINT16 StaticResourceVector;
} LEGACY_PNP_EXPANSION_HEADER;
typedef struct {
- UINT8 PciSegment;
- UINT8 PciBus;
- UINT8 PciDevice;
- UINT8 PciFunction;
- UINT16 Vid;
- UINT16 Did;
- UINT16 SysSid;
- UINT16 SVid;
- UINT8 Class;
- UINT8 SubClass;
- UINT8 Interface;
- UINT8 Reserved;
- UINTN RomStart;
- UINTN ManufacturerString;
- UINTN ProductNameString;
+ UINT8 PciSegment;
+ UINT8 PciBus;
+ UINT8 PciDevice;
+ UINT8 PciFunction;
+ UINT16 Vid;
+ UINT16 Did;
+ UINT16 SysSid;
+ UINT16 SVid;
+ UINT8 Class;
+ UINT8 SubClass;
+ UINT8 Interface;
+ UINT8 Reserved;
+ UINTN RomStart;
+ UINTN ManufacturerString;
+ UINTN ProductNameString;
} LEGACY_ROM_AND_BBS_TABLE;
//
@@ -382,219 +381,217 @@ typedef struct {
// This mapping is ignored booting to a legacy OS.
//
typedef struct {
- UINT8 PciSegment;
- UINT8 PciBus;
- UINT8 PciDevice;
- UINT8 PciFunction;
- UINT8 StartDriveNumber;
- UINT8 EndDriveNumber;
+ UINT8 PciSegment;
+ UINT8 PciBus;
+ UINT8 PciDevice;
+ UINT8 PciFunction;
+ UINT8 StartDriveNumber;
+ UINT8 EndDriveNumber;
} LEGACY_EFI_HDD_TABLE;
//
// This data is passed to Leacy16Boot
//
typedef enum {
- EfiAcpiAddressRangeMemory = 1,
- EfiAcpiAddressRangeReserved = 2,
- EfiAcpiAddressRangeACPI = 3,
- EfiAcpiAddressRangeNVS = 4,
+ EfiAcpiAddressRangeMemory = 1,
+ EfiAcpiAddressRangeReserved = 2,
+ EfiAcpiAddressRangeACPI = 3,
+ EfiAcpiAddressRangeNVS = 4,
EfiAddressRangePersistentMemory = 7
} EFI_ACPI_MEMORY_TYPE;
typedef struct {
- UINT64 BaseAddr;
- UINT64 Length;
- EFI_ACPI_MEMORY_TYPE Type;
+ UINT64 BaseAddr;
+ UINT64 Length;
+ EFI_ACPI_MEMORY_TYPE Type;
} EFI_E820_ENTRY64;
typedef struct {
- UINT32 BassAddrLow;
- UINT32 BaseAddrHigh;
- UINT32 LengthLow;
- UINT32 LengthHigh;
- EFI_ACPI_MEMORY_TYPE Type;
+ UINT32 BassAddrLow;
+ UINT32 BaseAddrHigh;
+ UINT32 LengthLow;
+ UINT32 LengthHigh;
+ EFI_ACPI_MEMORY_TYPE Type;
} EFI_E820_ENTRY;
#pragma pack()
-extern BBS_TABLE *mBbsTable;
-
-extern EFI_GENERIC_MEMORY_TEST_PROTOCOL *gGenMemoryTest;
-
-extern BOOLEAN mEndOfDxe;
-
-#define PORT_70 0x70
-#define PORT_71 0x71
-
-#define CMOS_0A 0x0a ///< Status register A
-#define CMOS_0D 0x0d ///< Status register D
-#define CMOS_0E 0x0e ///< Diagnostic Status
-#define CMOS_0F 0x0f ///< Shutdown status
-#define CMOS_10 0x10 ///< Floppy type
-#define CMOS_12 0x12 ///< IDE type
-#define CMOS_14 0x14 ///< Same as BDA 40:10
-#define CMOS_15 0x15 ///< Low byte of base memory in 1k increments
-#define CMOS_16 0x16 ///< High byte of base memory in 1k increments
-#define CMOS_17 0x17 ///< Low byte of 1MB+ memory in 1k increments - max 15 MB
-#define CMOS_18 0x18 ///< High byte of 1MB+ memory in 1k increments - max 15 MB
-#define CMOS_19 0x19 ///< C: extended drive type
-#define CMOS_1A 0x1a ///< D: extended drive type
-#define CMOS_2E 0x2e ///< Most significient byte of standard checksum
-#define CMOS_2F 0x2f ///< Least significient byte of standard checksum
-#define CMOS_30 0x30 ///< CMOS 0x17
-#define CMOS_31 0x31 ///< CMOS 0x18
-#define CMOS_32 0x32 ///< Century byte
+extern BBS_TABLE *mBbsTable;
+
+extern EFI_GENERIC_MEMORY_TEST_PROTOCOL *gGenMemoryTest;
+
+extern BOOLEAN mEndOfDxe;
+
+#define PORT_70 0x70
+#define PORT_71 0x71
+
+#define CMOS_0A 0x0a ///< Status register A
+#define CMOS_0D 0x0d ///< Status register D
+#define CMOS_0E 0x0e ///< Diagnostic Status
+#define CMOS_0F 0x0f ///< Shutdown status
+#define CMOS_10 0x10 ///< Floppy type
+#define CMOS_12 0x12 ///< IDE type
+#define CMOS_14 0x14 ///< Same as BDA 40:10
+#define CMOS_15 0x15 ///< Low byte of base memory in 1k increments
+#define CMOS_16 0x16 ///< High byte of base memory in 1k increments
+#define CMOS_17 0x17 ///< Low byte of 1MB+ memory in 1k increments - max 15 MB
+#define CMOS_18 0x18 ///< High byte of 1MB+ memory in 1k increments - max 15 MB
+#define CMOS_19 0x19 ///< C: extended drive type
+#define CMOS_1A 0x1a ///< D: extended drive type
+#define CMOS_2E 0x2e ///< Most significient byte of standard checksum
+#define CMOS_2F 0x2f ///< Least significient byte of standard checksum
+#define CMOS_30 0x30 ///< CMOS 0x17
+#define CMOS_31 0x31 ///< CMOS 0x18
+#define CMOS_32 0x32 ///< Century byte
//
// 8254 Timer registers
//
-#define TIMER0_COUNT_PORT 0x40
-#define TIMER1_COUNT_PORT 0x41
-#define TIMER2_COUNT_PORT 0x42
-#define TIMER_CONTROL_PORT 0x43
+#define TIMER0_COUNT_PORT 0x40
+#define TIMER1_COUNT_PORT 0x41
+#define TIMER2_COUNT_PORT 0x42
+#define TIMER_CONTROL_PORT 0x43
//
// Timer 0, Read/Write LSB then MSB, Square wave output, binary count use.
//
-#define TIMER0_CONTROL_WORD 0x36
+#define TIMER0_CONTROL_WORD 0x36
#define LEGACY_BIOS_INSTANCE_SIGNATURE SIGNATURE_32 ('L', 'B', 'I', 'T')
typedef struct {
- UINTN Signature;
+ UINTN Signature;
- EFI_HANDLE Handle;
- EFI_LEGACY_BIOS_PROTOCOL LegacyBios;
+ EFI_HANDLE Handle;
+ EFI_LEGACY_BIOS_PROTOCOL LegacyBios;
- EFI_HANDLE ImageHandle;
+ EFI_HANDLE ImageHandle;
//
// CPU Architectural Protocol
//
- EFI_CPU_ARCH_PROTOCOL *Cpu;
+ EFI_CPU_ARCH_PROTOCOL *Cpu;
//
// Timer Architectural Protocol
//
- EFI_TIMER_ARCH_PROTOCOL *Timer;
- BOOLEAN TimerUses8254;
+ EFI_TIMER_ARCH_PROTOCOL *Timer;
+ BOOLEAN TimerUses8254;
//
// Protocol to Lock and Unlock 0xc0000 - 0xfffff
//
- EFI_LEGACY_REGION2_PROTOCOL *LegacyRegion;
+ EFI_LEGACY_REGION2_PROTOCOL *LegacyRegion;
- EFI_LEGACY_BIOS_PLATFORM_PROTOCOL *LegacyBiosPlatform;
+ EFI_LEGACY_BIOS_PLATFORM_PROTOCOL *LegacyBiosPlatform;
//
// Interrupt control for thunk and PCI IRQ
//
- EFI_LEGACY_8259_PROTOCOL *Legacy8259;
+ EFI_LEGACY_8259_PROTOCOL *Legacy8259;
//
// PCI Interrupt PIRQ control
//
- EFI_LEGACY_INTERRUPT_PROTOCOL *LegacyInterrupt;
+ EFI_LEGACY_INTERRUPT_PROTOCOL *LegacyInterrupt;
//
// Generic Memory Test
//
- EFI_GENERIC_MEMORY_TEST_PROTOCOL *GenericMemoryTest;
+ EFI_GENERIC_MEMORY_TEST_PROTOCOL *GenericMemoryTest;
//
// TRUE if PCI Interrupt Line registers have been programmed.
//
- BOOLEAN PciInterruptLine;
+ BOOLEAN PciInterruptLine;
//
// Code space below 1MB needed by thunker to transition to real mode.
// Contains stack and real mode code fragments
//
- LOW_MEMORY_THUNK *IntThunk;
+ LOW_MEMORY_THUNK *IntThunk;
//
// Starting shadow address of the Legacy BIOS
//
- UINT32 BiosStart;
- UINT32 LegacyBiosImageSize;
+ UINT32 BiosStart;
+ UINT32 LegacyBiosImageSize;
//
// Start of variables used by CsmItp.mac ITP macro file and/os LegacyBios
//
- UINT8 Dump[4];
+ UINT8 Dump[4];
//
// $EFI Legacy16 code entry info in memory < 1 MB;
//
- EFI_COMPATIBILITY16_TABLE *Legacy16Table;
- VOID *Legacy16InitPtr;
- VOID *Legacy16BootPtr;
- VOID *InternalIrqRoutingTable;
- UINT32 NumberIrqRoutingEntries;
- VOID *BbsTablePtr;
- VOID *HddTablePtr;
- UINT32 NumberHddControllers;
+ EFI_COMPATIBILITY16_TABLE *Legacy16Table;
+ VOID *Legacy16InitPtr;
+ VOID *Legacy16BootPtr;
+ VOID *InternalIrqRoutingTable;
+ UINT32 NumberIrqRoutingEntries;
+ VOID *BbsTablePtr;
+ VOID *HddTablePtr;
+ UINT32 NumberHddControllers;
//
// Cached copy of Legacy16 entry point
//
- UINT16 Legacy16CallSegment;
- UINT16 Legacy16CallOffset;
+ UINT16 Legacy16CallSegment;
+ UINT16 Legacy16CallOffset;
//
// Returned from $EFI and passed in to OPROMS
//
- UINT16 PnPInstallationCheckSegment;
- UINT16 PnPInstallationCheckOffset;
+ UINT16 PnPInstallationCheckSegment;
+ UINT16 PnPInstallationCheckOffset;
//
// E820 table
//
- EFI_E820_ENTRY E820Table[EFI_MAX_E820_ENTRY];
- UINT32 NumberE820Entries;
+ EFI_E820_ENTRY E820Table[EFI_MAX_E820_ENTRY];
+ UINT32 NumberE820Entries;
//
// True if legacy VGA INT 10h handler installed
//
- BOOLEAN VgaInstalled;
+ BOOLEAN VgaInstalled;
//
// Number of IDE drives
//
- UINT8 IdeDriveCount;
+ UINT8 IdeDriveCount;
//
// Current Free Option ROM space. An option ROM must NOT go past
// BiosStart.
//
- UINT32 OptionRom;
+ UINT32 OptionRom;
//
// Save Legacy16 unexpected interrupt vector. Reprogram INT 68-6F from
// EFI values to legacy value just before boot.
//
- UINT32 BiosUnexpectedInt;
- UINT32 ThunkSavedInt[8];
- UINT16 ThunkSeg;
- LEGACY_EFI_HDD_TABLE *LegacyEfiHddTable;
- UINT16 LegacyEfiHddTableIndex;
- UINT8 DiskEnd;
- UINT8 Disk4075;
- UINT16 TraceIndex;
- UINT16 Trace[0x200];
+ UINT32 BiosUnexpectedInt;
+ UINT32 ThunkSavedInt[8];
+ UINT16 ThunkSeg;
+ LEGACY_EFI_HDD_TABLE *LegacyEfiHddTable;
+ UINT16 LegacyEfiHddTableIndex;
+ UINT8 DiskEnd;
+ UINT8 Disk4075;
+ UINT16 TraceIndex;
+ UINT16 Trace[0x200];
//
// Indicate that whether GenericLegacyBoot is entered or not
//
- BOOLEAN LegacyBootEntered;
+ BOOLEAN LegacyBootEntered;
//
// CSM16 PCI Interface Version
//
- UINT16 Csm16PciInterfaceVersion;
-
+ UINT16 Csm16PciInterfaceVersion;
} LEGACY_BIOS_INSTANCE;
-
#pragma pack(1)
/*
@@ -636,41 +633,41 @@ typedef struct {
40:98-101 skip
*/
typedef struct {
- UINT16 Com1;
- UINT16 Com2;
- UINT16 Com3;
- UINT16 Com4;
- UINT16 Lpt1;
- UINT16 Lpt2;
- UINT16 Lpt3;
- UINT16 Ebda;
- UINT16 MachineConfig;
- UINT8 Bda12;
- UINT16 MemSize;
- UINT8 Bda15_16[0x02];
- UINT8 ShiftStatus;
- UINT8 Bda18_19[0x02];
- UINT16 KeyHead;
- UINT16 KeyTail;
- UINT16 Bda1E_3D[0x10];
- UINT16 FloppyData;
- UINT8 FloppyTimeout;
- UINT8 Bda41_74[0x34];
- UINT8 NumberOfDrives;
- UINT8 Bda76_77[0x02];
- UINT16 Lpt1_2Timeout;
- UINT16 Lpt3_4Timeout;
- UINT16 Com1_2Timeout;
- UINT16 Com3_4Timeout;
- UINT16 KeyStart;
- UINT16 KeyEnd;
- UINT8 Bda84_87[0x4];
- UINT8 DataXmit;
- UINT8 Bda89_8F[0x07];
- UINT8 FloppyXRate;
- UINT8 Bda91_95[0x05];
- UINT8 KeyboardStatus;
- UINT8 LedStatus;
+ UINT16 Com1;
+ UINT16 Com2;
+ UINT16 Com3;
+ UINT16 Com4;
+ UINT16 Lpt1;
+ UINT16 Lpt2;
+ UINT16 Lpt3;
+ UINT16 Ebda;
+ UINT16 MachineConfig;
+ UINT8 Bda12;
+ UINT16 MemSize;
+ UINT8 Bda15_16[0x02];
+ UINT8 ShiftStatus;
+ UINT8 Bda18_19[0x02];
+ UINT16 KeyHead;
+ UINT16 KeyTail;
+ UINT16 Bda1E_3D[0x10];
+ UINT16 FloppyData;
+ UINT8 FloppyTimeout;
+ UINT8 Bda41_74[0x34];
+ UINT8 NumberOfDrives;
+ UINT8 Bda76_77[0x02];
+ UINT16 Lpt1_2Timeout;
+ UINT16 Lpt3_4Timeout;
+ UINT16 Com1_2Timeout;
+ UINT16 Com3_4Timeout;
+ UINT16 KeyStart;
+ UINT16 KeyEnd;
+ UINT8 Bda84_87[0x4];
+ UINT8 DataXmit;
+ UINT8 Bda89_8F[0x07];
+ UINT8 FloppyXRate;
+ UINT8 Bda91_95[0x05];
+ UINT8 KeyboardStatus;
+ UINT8 LedStatus;
} BDA_STRUC;
#pragma pack()
@@ -694,12 +691,11 @@ typedef struct {
BOOLEAN
EFIAPI
LegacyBiosInt86 (
- IN EFI_LEGACY_BIOS_PROTOCOL *This,
- IN UINT8 BiosInt,
- IN EFI_IA32_REGISTER_SET *Regs
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,
+ IN UINT8 BiosInt,
+ IN EFI_IA32_REGISTER_SET *Regs
);
-
/**
Thunk to 16-bit real mode and call Segment:Offset. Regs will contain the
16-bit register context on entry and exit. Arguments can be passed on
@@ -721,15 +717,14 @@ LegacyBiosInt86 (
BOOLEAN
EFIAPI
LegacyBiosFarCall86 (
- IN EFI_LEGACY_BIOS_PROTOCOL *This,
- IN UINT16 Segment,
- IN UINT16 Offset,
- IN EFI_IA32_REGISTER_SET *Regs,
- IN VOID *Stack,
- IN UINTN StackSize
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,
+ IN UINT16 Segment,
+ IN UINT16 Offset,
+ IN EFI_IA32_REGISTER_SET *Regs,
+ IN VOID *Stack,
+ IN UINTN StackSize
);
-
/**
Test to see if a legacy PCI ROM exists for this device. Optionally return
the Legacy ROM instance for this PCI device.
@@ -748,14 +743,13 @@ LegacyBiosFarCall86 (
EFI_STATUS
EFIAPI
LegacyBiosCheckPciRom (
- IN EFI_LEGACY_BIOS_PROTOCOL *This,
- IN EFI_HANDLE PciHandle,
- OUT VOID **RomImage OPTIONAL,
- OUT UINTN *RomSize OPTIONAL,
- OUT UINTN *Flags
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,
+ IN EFI_HANDLE PciHandle,
+ OUT VOID **RomImage OPTIONAL,
+ OUT UINTN *RomSize OPTIONAL,
+ OUT UINTN *Flags
);
-
/**
Assign drive number to legacy HDD drives prior to booting an EFI
aware OS so the OS can access drives without an EFI driver.
@@ -772,12 +766,11 @@ LegacyBiosCheckPciRom (
EFI_STATUS
EFIAPI
LegacyBiosPrepareToBootEfi (
- IN EFI_LEGACY_BIOS_PROTOCOL *This,
- OUT UINT16 *BbsCount,
- OUT BBS_TABLE **BbsTable
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,
+ OUT UINT16 *BbsCount,
+ OUT BBS_TABLE **BbsTable
);
-
/**
To boot from an unconventional device like parties and/or execute
HDD diagnostics.
@@ -796,14 +789,13 @@ LegacyBiosPrepareToBootEfi (
EFI_STATUS
EFIAPI
LegacyBiosBootUnconventionalDevice (
- IN EFI_LEGACY_BIOS_PROTOCOL *This,
- IN UDC_ATTRIBUTES Attributes,
- IN UINTN BbsEntry,
- IN VOID *BeerData,
- IN VOID *ServiceAreaData
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,
+ IN UDC_ATTRIBUTES Attributes,
+ IN UINTN BbsEntry,
+ IN VOID *BeerData,
+ IN VOID *ServiceAreaData
);
-
/**
Load a legacy PC-AT OPROM on the PciHandle device. Return information
about how many disks were added by the OPROM and the shadow address and
@@ -834,17 +826,16 @@ LegacyBiosBootUnconventionalDevice (
EFI_STATUS
EFIAPI
LegacyBiosInstallPciRom (
- IN EFI_LEGACY_BIOS_PROTOCOL * This,
- IN EFI_HANDLE PciHandle,
- IN VOID **RomImage,
- OUT UINTN *Flags,
- OUT UINT8 *DiskStart OPTIONAL,
- OUT UINT8 *DiskEnd OPTIONAL,
- OUT VOID **RomShadowAddress OPTIONAL,
- OUT UINT32 *RomShadowedSize OPTIONAL
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,
+ IN EFI_HANDLE PciHandle,
+ IN VOID **RomImage,
+ OUT UINTN *Flags,
+ OUT UINT8 *DiskStart OPTIONAL,
+ OUT UINT8 *DiskEnd OPTIONAL,
+ OUT VOID **RomShadowAddress OPTIONAL,
+ OUT UINT32 *RomShadowedSize OPTIONAL
);
-
/**
Fill in the standard BDA for Keyboard LEDs
@@ -857,11 +848,10 @@ LegacyBiosInstallPciRom (
EFI_STATUS
EFIAPI
LegacyBiosUpdateKeyboardLedStatus (
- IN EFI_LEGACY_BIOS_PROTOCOL *This,
- IN UINT8 Leds
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,
+ IN UINT8 Leds
);
-
/**
Get all BBS info
@@ -879,14 +869,13 @@ LegacyBiosUpdateKeyboardLedStatus (
EFI_STATUS
EFIAPI
LegacyBiosGetBbsInfo (
- IN EFI_LEGACY_BIOS_PROTOCOL *This,
- OUT UINT16 *HddCount,
- OUT HDD_INFO **HddInfo,
- OUT UINT16 *BbsCount,
- OUT BBS_TABLE **BbsTable
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,
+ OUT UINT16 *HddCount,
+ OUT HDD_INFO **HddInfo,
+ OUT UINT16 *BbsCount,
+ OUT BBS_TABLE **BbsTable
);
-
/**
Shadow all legacy16 OPROMs that haven't been shadowed.
Warning: Use this with caution. This routine disconnects all EFI
@@ -901,10 +890,9 @@ LegacyBiosGetBbsInfo (
EFI_STATUS
EFIAPI
LegacyBiosShadowAllLegacyOproms (
- IN EFI_LEGACY_BIOS_PROTOCOL *This
+ IN EFI_LEGACY_BIOS_PROTOCOL *This
);
-
/**
Attempt to legacy boot the BootOption. If the EFI contexted has been
compromised this function will not return.
@@ -920,13 +908,12 @@ LegacyBiosShadowAllLegacyOproms (
EFI_STATUS
EFIAPI
LegacyBiosLegacyBoot (
- IN EFI_LEGACY_BIOS_PROTOCOL *This,
- IN BBS_BBS_DEVICE_PATH *BbsDevicePath,
- IN UINT32 LoadOptionsSize,
- IN VOID *LoadOptions
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,
+ IN BBS_BBS_DEVICE_PATH *BbsDevicePath,
+ IN UINT32 LoadOptionsSize,
+ IN VOID *LoadOptions
);
-
/**
Allocate memory < 1 MB and copy the thunker code into low memory. Se up
all the descriptors.
@@ -938,10 +925,9 @@ LegacyBiosLegacyBoot (
**/
EFI_STATUS
LegacyBiosInitializeThunk (
- IN LEGACY_BIOS_INSTANCE *Private
+ IN LEGACY_BIOS_INSTANCE *Private
);
-
/**
Fill in the standard BDA and EBDA stuff before Legacy16 load
@@ -952,10 +938,9 @@ LegacyBiosInitializeThunk (
**/
EFI_STATUS
LegacyBiosInitBda (
- IN LEGACY_BIOS_INSTANCE *Private
+ IN LEGACY_BIOS_INSTANCE *Private
);
-
/**
Collect IDE Inquiry data from the IDE disks
@@ -968,12 +953,11 @@ LegacyBiosInitBda (
**/
EFI_STATUS
LegacyBiosBuildIdeData (
- IN LEGACY_BIOS_INSTANCE *Private,
- IN HDD_INFO **HddInfo,
- IN UINT16 Flag
+ IN LEGACY_BIOS_INSTANCE *Private,
+ IN HDD_INFO **HddInfo,
+ IN UINT16 Flag
);
-
/**
Enable ide controller. This gets disabled when LegacyBoot.c is about
to run the Option ROMs.
@@ -984,10 +968,9 @@ LegacyBiosBuildIdeData (
**/
VOID
EnableIdeController (
- IN LEGACY_BIOS_INSTANCE *Private
+ IN LEGACY_BIOS_INSTANCE *Private
);
-
/**
If the IDE channel is in compatibility (legacy) mode, remove all
PCI I/O BAR addresses from the controller.
@@ -998,10 +981,9 @@ EnableIdeController (
**/
VOID
InitLegacyIdeController (
- IN EFI_HANDLE IdeController
+ IN EFI_HANDLE IdeController
);
-
/**
Program the interrupt routing register in all the PCI devices. On a PC AT system
this register contains the 8259 IRQ vector that matches its PCI interrupt.
@@ -1014,10 +996,9 @@ InitLegacyIdeController (
**/
EFI_STATUS
PciProgramAllInterruptLineRegisters (
- IN LEGACY_BIOS_INSTANCE *Private
+ IN LEGACY_BIOS_INSTANCE *Private
);
-
/**
Collect EFI Info about legacy devices.
@@ -1028,10 +1009,9 @@ PciProgramAllInterruptLineRegisters (
**/
EFI_STATUS
LegacyBiosBuildSioData (
- IN LEGACY_BIOS_INSTANCE *Private
+ IN LEGACY_BIOS_INSTANCE *Private
);
-
/**
Shadow all the PCI legacy ROMs. Use data from the Legacy BIOS Protocol
to chose the order. Skip any devices that have already have legacy
@@ -1045,10 +1025,9 @@ LegacyBiosBuildSioData (
**/
EFI_STATUS
PciShadowRoms (
- IN LEGACY_BIOS_INSTANCE *Private
+ IN LEGACY_BIOS_INSTANCE *Private
);
-
/**
Fill in the standard BDA and EBDA stuff prior to legacy Boot
@@ -1059,10 +1038,9 @@ PciShadowRoms (
**/
EFI_STATUS
LegacyBiosCompleteBdaBeforeBoot (
- IN LEGACY_BIOS_INSTANCE *Private
+ IN LEGACY_BIOS_INSTANCE *Private
);
-
/**
Fill in the standard CMOS stuff before Legacy16 load
@@ -1073,10 +1051,9 @@ LegacyBiosCompleteBdaBeforeBoot (
**/
EFI_STATUS
LegacyBiosInitCmos (
- IN LEGACY_BIOS_INSTANCE *Private
+ IN LEGACY_BIOS_INSTANCE *Private
);
-
/**
Fill in the standard CMOS stuff prior to legacy Boot
@@ -1087,10 +1064,9 @@ LegacyBiosInitCmos (
**/
EFI_STATUS
LegacyBiosCompleteStandardCmosBeforeBoot (
- IN LEGACY_BIOS_INSTANCE *Private
+ IN LEGACY_BIOS_INSTANCE *Private
);
-
/**
Contains the code that is copied into low memory (below 640K).
This code reflects interrupts 0x68-0x6f to interrupts 0x08-0x0f.
@@ -1105,7 +1081,6 @@ InterruptRedirectionTemplate (
VOID
);
-
/**
Build the E820 table.
@@ -1117,8 +1092,8 @@ InterruptRedirectionTemplate (
**/
EFI_STATUS
LegacyBiosBuildE820 (
- IN LEGACY_BIOS_INSTANCE *Private,
- OUT UINTN *Size
+ IN LEGACY_BIOS_INSTANCE *Private,
+ OUT UINTN *Size
);
/**
@@ -1129,7 +1104,7 @@ LegacyBiosBuildE820 (
**/
VOID
ShutdownAPs (
- IN LEGACY_BIOS_INSTANCE *Private
+ IN LEGACY_BIOS_INSTANCE *Private
);
/**
@@ -1141,7 +1116,7 @@ ShutdownAPs (
**/
VOID
GetRegisters (
- LOW_MEMORY_THUNK *IntThunk
+ LOW_MEMORY_THUNK *IntThunk
);
/**
@@ -1156,9 +1131,9 @@ GetRegisters (
**/
UINTN
CallRealThunkCode (
- UINT8 *RealCode,
- UINT8 BiosInt,
- UINT32 CallAddress
+ UINT8 *RealCode,
+ UINT8 BiosInt,
+ UINT32 CallAddress
);
/**
@@ -1169,7 +1144,7 @@ CallRealThunkCode (
**/
VOID
GenerateSoftInit (
- UINT8 Vector
+ UINT8 Vector
);
/**
@@ -1187,11 +1162,11 @@ GenerateSoftInit (
**/
EFI_STATUS
AllocateLegacyMemory (
- IN EFI_ALLOCATE_TYPE AllocateType,
- IN EFI_MEMORY_TYPE MemoryType,
- IN EFI_PHYSICAL_ADDRESS StartPageAddress,
- IN UINTN Pages,
- OUT EFI_PHYSICAL_ADDRESS *Result
+ IN EFI_ALLOCATE_TYPE AllocateType,
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN EFI_PHYSICAL_ADDRESS StartPageAddress,
+ IN UINTN Pages,
+ OUT EFI_PHYSICAL_ADDRESS *Result
);
/**
@@ -1214,11 +1189,11 @@ AllocateLegacyMemory (
EFI_STATUS
EFIAPI
LegacyBiosGetLegacyRegion (
- IN EFI_LEGACY_BIOS_PROTOCOL *This,
- IN UINTN LegacyMemorySize,
- IN UINTN Region,
- IN UINTN Alignment,
- OUT VOID **LegacyMemoryAddress
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,
+ IN UINTN LegacyMemorySize,
+ IN UINTN Region,
+ IN UINTN Alignment,
+ OUT VOID **LegacyMemoryAddress
);
/**
@@ -1238,10 +1213,10 @@ LegacyBiosGetLegacyRegion (
EFI_STATUS
EFIAPI
LegacyBiosCopyLegacyRegion (
- IN EFI_LEGACY_BIOS_PROTOCOL *This,
- IN UINTN LegacyMemorySize,
- IN VOID *LegacyMemoryAddress,
- IN VOID *LegacyMemorySourceAddress
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,
+ IN UINTN LegacyMemorySize,
+ IN VOID *LegacyMemoryAddress,
+ IN VOID *LegacyMemorySourceAddress
);
/**
@@ -1295,8 +1270,8 @@ HasMediaInFloppy (
**/
EFI_STATUS
CalculateIdentifyDriveChecksum (
- IN UINT8 *IdentifyDriveData,
- OUT UINT8 *Checksum
+ IN UINT8 *IdentifyDriveData,
+ OUT UINT8 *Checksum
);
/**
@@ -1307,7 +1282,7 @@ CalculateIdentifyDriveChecksum (
**/
VOID
UpdateIdentifyDriveData (
- IN UINT8 *IdentifyDriveData
+ IN UINT8 *IdentifyDriveData
);
/**
@@ -1321,8 +1296,8 @@ UpdateIdentifyDriveData (
**/
EFI_STATUS
LegacyBiosBuildBbs (
- IN LEGACY_BIOS_INSTANCE *Private,
- IN BBS_TABLE *BbsTable
+ IN LEGACY_BIOS_INSTANCE *Private,
+ IN BBS_TABLE *BbsTable
);
/**
@@ -1386,14 +1361,14 @@ LegacyCalculateWriteStandardCmosChecksum (
**/
EFI_STATUS
LegacyBiosCheckPciRomEx (
- IN EFI_LEGACY_BIOS_PROTOCOL *This,
- IN EFI_HANDLE PciHandle,
- OUT VOID **RomImage OPTIONAL,
- OUT UINTN *RomSize OPTIONAL,
- OUT UINTN *RuntimeImageLength OPTIONAL,
- OUT UINTN *Flags OPTIONAL,
- OUT UINT8 *OpromRevision OPTIONAL,
- OUT VOID **ConfigUtilityCodeHeader OPTIONAL
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,
+ IN EFI_HANDLE PciHandle,
+ OUT VOID **RomImage OPTIONAL,
+ OUT UINTN *RomSize OPTIONAL,
+ OUT UINTN *RuntimeImageLength OPTIONAL,
+ OUT UINTN *Flags OPTIONAL,
+ OUT UINT8 *OpromRevision OPTIONAL,
+ OUT VOID **ConfigUtilityCodeHeader OPTIONAL
);
/**
@@ -1408,8 +1383,8 @@ LegacyBiosCheckPciRomEx (
**/
EFI_STATUS
RelocateImageUnder4GIfNeeded (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
);
/**
@@ -1433,12 +1408,12 @@ RelocateImageUnder4GIfNeeded (
BOOLEAN
EFIAPI
InternalLegacyBiosFarCall (
- IN EFI_LEGACY_BIOS_PROTOCOL *This,
- IN UINT16 Segment,
- IN UINT16 Offset,
- IN EFI_IA32_REGISTER_SET *Regs,
- IN VOID *Stack,
- IN UINTN StackSize
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,
+ IN UINT16 Segment,
+ IN UINT16 Offset,
+ IN EFI_IA32_REGISTER_SET *Regs,
+ IN VOID *Stack,
+ IN UINTN StackSize
);
/**
@@ -1454,7 +1429,7 @@ InternalLegacyBiosFarCall (
**/
EFI_STATUS
LegacyBiosInstallVgaRom (
- IN LEGACY_BIOS_INSTANCE *Private
+ IN LEGACY_BIOS_INSTANCE *Private
);
#endif
diff --git a/OvmfPkg/Csm/LegacyBiosDxe/LegacyBootSupport.c b/OvmfPkg/Csm/LegacyBiosDxe/LegacyBootSupport.c
index 9a09d72307..83d94cf289 100644
--- a/OvmfPkg/Csm/LegacyBiosDxe/LegacyBootSupport.c
+++ b/OvmfPkg/Csm/LegacyBiosDxe/LegacyBootSupport.c
@@ -13,18 +13,18 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define BOOT_EFI_OS 1
#define BOOT_UNCONVENTIONAL_DEVICE 2
-UINT32 mLoadOptionsSize = 0;
-UINTN mBootMode = BOOT_LEGACY_OS;
-VOID *mLoadOptions = NULL;
-BBS_BBS_DEVICE_PATH *mBbsDevicePathPtr = NULL;
-BBS_BBS_DEVICE_PATH mBbsDevicePathNode;
-UDC_ATTRIBUTES mAttributes = { 0, 0, 0, 0 };
-UINTN mBbsEntry = 0;
-VOID *mBeerData = NULL;
-VOID *mServiceAreaData = NULL;
-UINT64 mLowWater = 0xffffffffffffffffULL;
-
-extern BBS_TABLE *mBbsTable;
+UINT32 mLoadOptionsSize = 0;
+UINTN mBootMode = BOOT_LEGACY_OS;
+VOID *mLoadOptions = NULL;
+BBS_BBS_DEVICE_PATH *mBbsDevicePathPtr = NULL;
+BBS_BBS_DEVICE_PATH mBbsDevicePathNode;
+UDC_ATTRIBUTES mAttributes = { 0, 0, 0, 0 };
+UINTN mBbsEntry = 0;
+VOID *mBeerData = NULL;
+VOID *mServiceAreaData = NULL;
+UINT64 mLowWater = 0xffffffffffffffffULL;
+
+extern BBS_TABLE *mBbsTable;
extern VOID *mRuntimeSmbiosEntryPoint;
extern EFI_PHYSICAL_ADDRESS mReserveSmbiosEntryPoint;
@@ -39,12 +39,12 @@ extern EFI_PHYSICAL_ADDRESS mStructureTableAddress;
**/
VOID
PrintBbsTable (
- IN BBS_TABLE *BbsTable
+ IN BBS_TABLE *BbsTable
)
{
- UINT16 Index;
- UINT16 SubIndex;
- CHAR8 *String;
+ UINT16 Index;
+ UINT16 SubIndex;
+ CHAR8 *String;
DEBUG ((DEBUG_INFO, "\n"));
DEBUG ((DEBUG_INFO, " NO Prio bb/dd/ff cl/sc Type Stat segm:offs mfgs:mfgo dess:deso\n"));
@@ -60,25 +60,25 @@ PrintBbsTable (
DEBUG ((
DEBUG_INFO,
" %02x: %04x %02x/%02x/%02x %02x/%02x %04x %04x",
- (UINTN) Index,
- (UINTN) BbsTable[Index].BootPriority,
- (UINTN) BbsTable[Index].Bus,
- (UINTN) BbsTable[Index].Device,
- (UINTN) BbsTable[Index].Function,
- (UINTN) BbsTable[Index].Class,
- (UINTN) BbsTable[Index].SubClass,
- (UINTN) BbsTable[Index].DeviceType,
- (UINTN) * (UINT16 *) &BbsTable[Index].StatusFlags
+ (UINTN)Index,
+ (UINTN)BbsTable[Index].BootPriority,
+ (UINTN)BbsTable[Index].Bus,
+ (UINTN)BbsTable[Index].Device,
+ (UINTN)BbsTable[Index].Function,
+ (UINTN)BbsTable[Index].Class,
+ (UINTN)BbsTable[Index].SubClass,
+ (UINTN)BbsTable[Index].DeviceType,
+ (UINTN)*(UINT16 *)&BbsTable[Index].StatusFlags
));
DEBUG ((
DEBUG_INFO,
" %04x:%04x %04x:%04x %04x:%04x",
- (UINTN) BbsTable[Index].BootHandlerSegment,
- (UINTN) BbsTable[Index].BootHandlerOffset,
- (UINTN) BbsTable[Index].MfgStringSegment,
- (UINTN) BbsTable[Index].MfgStringOffset,
- (UINTN) BbsTable[Index].DescStringSegment,
- (UINTN) BbsTable[Index].DescStringOffset
+ (UINTN)BbsTable[Index].BootHandlerSegment,
+ (UINTN)BbsTable[Index].BootHandlerOffset,
+ (UINTN)BbsTable[Index].MfgStringSegment,
+ (UINTN)BbsTable[Index].MfgStringOffset,
+ (UINTN)BbsTable[Index].DescStringSegment,
+ (UINTN)BbsTable[Index].DescStringOffset
));
//
@@ -86,18 +86,20 @@ PrintBbsTable (
//
String = (CHAR8 *)(((UINTN)BbsTable[Index].DescStringSegment << 4) + BbsTable[Index].DescStringOffset);
if (String != NULL) {
- DEBUG ((DEBUG_INFO," ("));
+ DEBUG ((DEBUG_INFO, " ("));
for (SubIndex = 0; String[SubIndex] != 0; SubIndex++) {
DEBUG ((DEBUG_INFO, "%c", String[SubIndex]));
}
- DEBUG ((DEBUG_INFO,")"));
+
+ DEBUG ((DEBUG_INFO, ")"));
}
- DEBUG ((DEBUG_INFO,"\n"));
+
+ DEBUG ((DEBUG_INFO, "\n"));
}
DEBUG ((DEBUG_INFO, "\n"));
- return ;
+ return;
}
/**
@@ -109,10 +111,10 @@ PrintBbsTable (
**/
VOID
PrintHddInfo (
- IN HDD_INFO *HddInfo
+ IN HDD_INFO *HddInfo
)
{
- UINTN Index;
+ UINTN Index;
DEBUG ((DEBUG_INFO, "\n"));
for (Index = 0; Index < MAX_IDE_CONTROLLER; Index++) {
@@ -129,7 +131,7 @@ PrintHddInfo (
DEBUG ((DEBUG_INFO, "\n"));
- return ;
+ return;
}
/**
@@ -140,16 +142,16 @@ PrintPciInterruptRegister (
VOID
)
{
- EFI_STATUS Status;
- UINTN Index;
- EFI_HANDLE *Handles;
- UINTN HandleNum;
- EFI_PCI_IO_PROTOCOL *PciIo;
- UINT8 Interrupt[2];
- UINTN Segment;
- UINTN Bus;
- UINTN Device;
- UINTN Function;
+ EFI_STATUS Status;
+ UINTN Index;
+ EFI_HANDLE *Handles;
+ UINTN HandleNum;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ UINT8 Interrupt[2];
+ UINTN Segment;
+ UINTN Bus;
+ UINTN Device;
+ UINTN Function;
gBS->LocateHandleBuffer (
ByProtocol,
@@ -167,7 +169,7 @@ PrintPciInterruptRegister (
DEBUG ((DEBUG_INFO, " bb/dd/ff interrupt line interrupt pin\n"));
DEBUG ((DEBUG_INFO, "======================================\n"));
for (Index = 0; Index < HandleNum; Index++) {
- Status = gBS->HandleProtocol (Handles[Index], &gEfiPciIoProtocolGuid, (VOID **) &PciIo);
+ Status = gBS->HandleProtocol (Handles[Index], &gEfiPciIoProtocolGuid, (VOID **)&PciIo);
if (!EFI_ERROR (Status)) {
Status = PciIo->Pci.Read (
PciIo,
@@ -177,6 +179,7 @@ PrintPciInterruptRegister (
Interrupt
);
}
+
if (!EFI_ERROR (Status)) {
Status = PciIo->GetLocation (
PciIo,
@@ -186,11 +189,20 @@ PrintPciInterruptRegister (
&Function
);
}
+
if (!EFI_ERROR (Status)) {
- DEBUG ((DEBUG_INFO, " %02x/%02x/%02x 0x%02x 0x%02x\n",
- Bus, Device, Function, Interrupt[0], Interrupt[1]));
+ DEBUG ((
+ DEBUG_INFO,
+ " %02x/%02x/%02x 0x%02x 0x%02x\n",
+ Bus,
+ Device,
+ Function,
+ Interrupt[0],
+ Interrupt[1]
+ ));
}
}
+
DEBUG ((DEBUG_INFO, "\n"));
if (Handles != NULL) {
@@ -206,7 +218,7 @@ PrintPciInterruptRegister (
**/
VOID
UpdateIdentifyDriveData (
- IN UINT8 *IdentifyDriveData
+ IN UINT8 *IdentifyDriveData
);
/**
@@ -219,30 +231,30 @@ UpdateIdentifyDriveData (
**/
EFI_STATUS
UpdateSioData (
- IN LEGACY_BIOS_INSTANCE *Private
+ IN LEGACY_BIOS_INSTANCE *Private
)
{
- EFI_STATUS Status;
- UINTN Index;
- UINTN Index1;
- UINT8 LegacyInterrupts[16];
- EFI_LEGACY_IRQ_ROUTING_ENTRY *RoutingTable;
- UINTN RoutingTableEntries;
- EFI_LEGACY_IRQ_PRIORITY_TABLE_ENTRY *IrqPriorityTable;
- UINTN NumberPriorityEntries;
- EFI_TO_COMPATIBILITY16_BOOT_TABLE *EfiToLegacy16BootTable;
- UINT8 HddIrq;
- UINT16 LegacyInt;
- UINT16 LegMask;
- UINT32 Register;
- UINTN HandleCount;
- EFI_HANDLE *HandleBuffer;
- EFI_ISA_IO_PROTOCOL *IsaIo;
-
- LegacyInt = 0;
- HandleBuffer = NULL;
-
- EfiToLegacy16BootTable = &Private->IntThunk->EfiToLegacy16BootTable;
+ EFI_STATUS Status;
+ UINTN Index;
+ UINTN Index1;
+ UINT8 LegacyInterrupts[16];
+ EFI_LEGACY_IRQ_ROUTING_ENTRY *RoutingTable;
+ UINTN RoutingTableEntries;
+ EFI_LEGACY_IRQ_PRIORITY_TABLE_ENTRY *IrqPriorityTable;
+ UINTN NumberPriorityEntries;
+ EFI_TO_COMPATIBILITY16_BOOT_TABLE *EfiToLegacy16BootTable;
+ UINT8 HddIrq;
+ UINT16 LegacyInt;
+ UINT16 LegMask;
+ UINT32 Register;
+ UINTN HandleCount;
+ EFI_HANDLE *HandleBuffer;
+ EFI_ISA_IO_PROTOCOL *IsaIo;
+
+ LegacyInt = 0;
+ HandleBuffer = NULL;
+
+ EfiToLegacy16BootTable = &Private->IntThunk->EfiToLegacy16BootTable;
LegacyBiosBuildSioData (Private);
SetMem (LegacyInterrupts, sizeof (LegacyInterrupts), 0);
@@ -270,21 +282,21 @@ UpdateSioData (
}
Private->LegacyBiosPlatform->GetRoutingTable (
- Private->LegacyBiosPlatform,
- (VOID *) &RoutingTable,
- &RoutingTableEntries,
- NULL,
- NULL,
- (VOID **) &IrqPriorityTable,
- &NumberPriorityEntries
- );
+ Private->LegacyBiosPlatform,
+ (VOID *)&RoutingTable,
+ &RoutingTableEntries,
+ NULL,
+ NULL,
+ (VOID **)&IrqPriorityTable,
+ &NumberPriorityEntries
+ );
//
// Remove legacy interrupts from the list of PCI interrupts available.
//
for (Index = 0; Index <= 0x0b; Index++) {
for (Index1 = 0; Index1 <= NumberPriorityEntries; Index1++) {
if (LegacyInterrupts[Index] != 0) {
- LegacyInt = (UINT16) (LegacyInt | (1 << LegacyInterrupts[Index]));
+ LegacyInt = (UINT16)(LegacyInt | (1 << LegacyInterrupts[Index]));
if (LegacyInterrupts[Index] == IrqPriorityTable[Index1].Irq) {
IrqPriorityTable[Index1].Used = LEGACY_USED;
}
@@ -293,37 +305,37 @@ UpdateSioData (
}
Private->Legacy8259->GetMask (
- Private->Legacy8259,
- &LegMask,
- NULL,
- NULL,
- NULL
- );
+ Private->Legacy8259,
+ &LegMask,
+ NULL,
+ NULL,
+ NULL
+ );
//
// Set SIO interrupts and disable mouse. Let mouse driver
// re-enable it.
//
- LegMask = (UINT16) ((LegMask &~LegacyInt) | 0x1000);
+ LegMask = (UINT16)((LegMask &~LegacyInt) | 0x1000);
Private->Legacy8259->SetMask (
- Private->Legacy8259,
- &LegMask,
- NULL,
- NULL,
- NULL
- );
+ Private->Legacy8259,
+ &LegMask,
+ NULL,
+ NULL,
+ NULL
+ );
//
// Disable mouse in keyboard controller
//
Register = 0xA7;
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiIsaIoProtocolGuid,
- NULL,
- &HandleCount,
- &HandleBuffer
- );
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiIsaIoProtocolGuid,
+ NULL,
+ &HandleCount,
+ &HandleBuffer
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -332,11 +344,10 @@ UpdateSioData (
Status = gBS->HandleProtocol (
HandleBuffer[Index],
&gEfiIsaIoProtocolGuid,
- (VOID **) &IsaIo
+ (VOID **)&IsaIo
);
ASSERT_EFI_ERROR (Status);
IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, 0x64, 1, &Register);
-
}
if (HandleBuffer != NULL) {
@@ -344,7 +355,6 @@ UpdateSioData (
}
return EFI_SUCCESS;
-
}
/**
@@ -360,12 +370,13 @@ UpdateSioData (
**/
EFI_STATUS
CalculateIdentifyDriveChecksum (
- IN UINT8 *IdentifyDriveData,
- OUT UINT8 *Checksum
+ IN UINT8 *IdentifyDriveData,
+ OUT UINT8 *Checksum
)
{
- UINTN Index;
- UINT8 LocalChecksum;
+ UINTN Index;
+ UINT8 LocalChecksum;
+
LocalChecksum = 0;
*Checksum = 0;
if (IdentifyDriveData[510] != 0xA5) {
@@ -373,14 +384,13 @@ CalculateIdentifyDriveChecksum (
}
for (Index = 0; Index < 512; Index++) {
- LocalChecksum = (UINT8) (LocalChecksum + IdentifyDriveData[Index]);
+ LocalChecksum = (UINT8)(LocalChecksum + IdentifyDriveData[Index]);
}
*Checksum = LocalChecksum;
return EFI_SUCCESS;
}
-
/**
Identify drive data must be updated to actual parameters before boot.
@@ -390,7 +400,7 @@ CalculateIdentifyDriveChecksum (
**/
VOID
UpdateIdentifyDriveData (
- IN UINT8 *IdentifyDriveData
+ IN UINT8 *IdentifyDriveData
)
{
UINT16 NumberCylinders;
@@ -406,31 +416,32 @@ UpdateIdentifyDriveData (
// Status indicates if Integrity byte is correct. Checksum should be
// 0 if valid.
//
- ReadInfo = (ATAPI_IDENTIFY *) IdentifyDriveData;
- Status = CalculateIdentifyDriveChecksum (IdentifyDriveData, &OriginalChecksum);
+ ReadInfo = (ATAPI_IDENTIFY *)IdentifyDriveData;
+ Status = CalculateIdentifyDriveChecksum (IdentifyDriveData, &OriginalChecksum);
if (OriginalChecksum != 0) {
Status = EFI_SECURITY_VIOLATION;
}
+
//
// If NumberCylinders = 0 then do data(Controller present but don drive attached).
//
NumberCylinders = ReadInfo->Raw[1];
if (NumberCylinders != 0) {
- ReadInfo->Raw[54] = NumberCylinders;
+ ReadInfo->Raw[54] = NumberCylinders;
- NumberHeads = ReadInfo->Raw[3];
- ReadInfo->Raw[55] = NumberHeads;
+ NumberHeads = ReadInfo->Raw[3];
+ ReadInfo->Raw[55] = NumberHeads;
- NumberSectorsTrack = ReadInfo->Raw[6];
- ReadInfo->Raw[56] = NumberSectorsTrack;
+ NumberSectorsTrack = ReadInfo->Raw[6];
+ ReadInfo->Raw[56] = NumberSectorsTrack;
//
// Copy Multisector info and set valid bit.
//
- ReadInfo->Raw[59] = (UINT16) (ReadInfo->Raw[47] + 0x100);
- CapacityInSectors = (UINT32) ((UINT32) (NumberCylinders) * (UINT32) (NumberHeads) * (UINT32) (NumberSectorsTrack));
- ReadInfo->Raw[57] = (UINT16) (CapacityInSectors >> 16);
- ReadInfo->Raw[58] = (UINT16) (CapacityInSectors & 0xffff);
+ ReadInfo->Raw[59] = (UINT16)(ReadInfo->Raw[47] + 0x100);
+ CapacityInSectors = (UINT32)((UINT32)(NumberCylinders) * (UINT32)(NumberHeads) * (UINT32)(NumberSectorsTrack));
+ ReadInfo->Raw[57] = (UINT16)(CapacityInSectors >> 16);
+ ReadInfo->Raw[58] = (UINT16)(CapacityInSectors & 0xffff);
if (Status == EFI_SUCCESS) {
//
// Forece checksum byte to 0 and get new checksum.
@@ -441,8 +452,8 @@ UpdateIdentifyDriveData (
//
// Force new checksum such that sum is 0.
//
- FinalChecksum = (UINT8) ((UINT8)0 - FinalChecksum);
- ReadInfo->Raw[255] = (UINT16) (ReadInfo->Raw[255] | (FinalChecksum << 8));
+ FinalChecksum = (UINT8)((UINT8)0 - FinalChecksum);
+ ReadInfo->Raw[255] = (UINT16)(ReadInfo->Raw[255] | (FinalChecksum << 8));
}
}
}
@@ -457,7 +468,7 @@ UpdateIdentifyDriveData (
**/
VOID
UpdateAllIdentifyDriveData (
- IN LEGACY_BIOS_INSTANCE *Private
+ IN LEGACY_BIOS_INSTANCE *Private
)
{
UINTN Index;
@@ -470,11 +481,11 @@ UpdateAllIdentifyDriveData (
// Each controller can have 2 devices. Update for each device
//
if ((HddInfo[Index].Status & HDD_MASTER_IDE) != 0) {
- UpdateIdentifyDriveData ((UINT8 *) (&HddInfo[Index].IdentifyDrive[0].Raw[0]));
+ UpdateIdentifyDriveData ((UINT8 *)(&HddInfo[Index].IdentifyDrive[0].Raw[0]));
}
if ((HddInfo[Index].Status & HDD_SLAVE_IDE) != 0) {
- UpdateIdentifyDriveData ((UINT8 *) (&HddInfo[Index].IdentifyDrive[1].Raw[0]));
+ UpdateIdentifyDriveData ((UINT8 *)(&HddInfo[Index].IdentifyDrive[1].Raw[0]));
}
}
}
@@ -489,15 +500,15 @@ UpdateAllIdentifyDriveData (
**/
VOID
EnableIdeController (
- IN LEGACY_BIOS_INSTANCE *Private
+ IN LEGACY_BIOS_INSTANCE *Private
)
{
- EFI_PCI_IO_PROTOCOL *PciIo;
- EFI_STATUS Status;
- EFI_HANDLE IdeController;
- UINT8 ByteBuffer;
- UINTN HandleCount;
- EFI_HANDLE *HandleBuffer;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ EFI_STATUS Status;
+ EFI_HANDLE IdeController;
+ UINT8 ByteBuffer;
+ UINTN HandleCount;
+ EFI_HANDLE *HandleBuffer;
Status = Private->LegacyBiosPlatform->GetPlatformHandle (
Private->LegacyBiosPlatform,
@@ -509,11 +520,11 @@ EnableIdeController (
);
if (!EFI_ERROR (Status)) {
IdeController = HandleBuffer[0];
- Status = gBS->HandleProtocol (
- IdeController,
- &gEfiPciIoProtocolGuid,
- (VOID **) &PciIo
- );
+ Status = gBS->HandleProtocol (
+ IdeController,
+ &gEfiPciIoProtocolGuid,
+ (VOID **)&PciIo
+ );
ByteBuffer = 0x1f;
if (!EFI_ERROR (Status)) {
PciIo->Pci.Write (PciIo, EfiPciIoWidthUint8, 0x04, 1, &ByteBuffer);
@@ -521,7 +532,6 @@ EnableIdeController (
}
}
-
/**
Enable ide controller. This gets disabled when LegacyBoot.c is about
to run the Option ROMs.
@@ -532,15 +542,15 @@ EnableIdeController (
**/
VOID
EnableAllControllers (
- IN LEGACY_BIOS_INSTANCE *Private
+ IN LEGACY_BIOS_INSTANCE *Private
)
{
- UINTN HandleCount;
- EFI_HANDLE *HandleBuffer;
- UINTN Index;
- EFI_PCI_IO_PROTOCOL *PciIo;
- PCI_TYPE01 PciConfigHeader;
- EFI_STATUS Status;
+ UINTN HandleCount;
+ EFI_HANDLE *HandleBuffer;
+ UINTN Index;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ PCI_TYPE01 PciConfigHeader;
+ EFI_STATUS Status;
//
//
@@ -563,17 +573,17 @@ EnableAllControllers (
Status = gBS->HandleProtocol (
HandleBuffer[Index],
&gEfiPciIoProtocolGuid,
- (VOID **) &PciIo
+ (VOID **)&PciIo
);
ASSERT_EFI_ERROR (Status);
PciIo->Pci.Read (
- PciIo,
- EfiPciIoWidthUint32,
- 0,
- sizeof (PciConfigHeader) / sizeof (UINT32),
- &PciConfigHeader
- );
+ PciIo,
+ EfiPciIoWidthUint32,
+ 0,
+ sizeof (PciConfigHeader) / sizeof (UINT32),
+ &PciConfigHeader
+ );
//
// We do not enable PPB here. This is for HotPlug Consideration.
@@ -600,8 +610,8 @@ EnableAllControllers (
IS_PCI_IDE (&PciConfigHeader) ||
IS_PCI_P2P (&PciConfigHeader) ||
IS_PCI_P2P_SUB (&PciConfigHeader) ||
- IS_PCI_LPC (&PciConfigHeader) )) {
-
+ IS_PCI_LPC (&PciConfigHeader)))
+ {
PciConfigHeader.Hdr.Command |= 0x1f;
PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 4, 1, &PciConfigHeader.Hdr.Command);
@@ -627,52 +637,52 @@ EnableAllControllers (
**/
EFI_STATUS
LegacyGetDataOrTable (
- IN EFI_LEGACY_BIOS_PROTOCOL *This,
- IN EFI_GET_PLATFORM_INFO_MODE Id
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,
+ IN EFI_GET_PLATFORM_INFO_MODE Id
)
{
- VOID *Table;
- UINT32 TablePtr;
- UINTN TableSize;
- UINTN Alignment;
- UINTN Location;
- EFI_STATUS Status;
- EFI_LEGACY_BIOS_PLATFORM_PROTOCOL *LegacyBiosPlatform;
- EFI_COMPATIBILITY16_TABLE *Legacy16Table;
- EFI_IA32_REGISTER_SET Regs;
- LEGACY_BIOS_INSTANCE *Private;
+ VOID *Table;
+ UINT32 TablePtr;
+ UINTN TableSize;
+ UINTN Alignment;
+ UINTN Location;
+ EFI_STATUS Status;
+ EFI_LEGACY_BIOS_PLATFORM_PROTOCOL *LegacyBiosPlatform;
+ EFI_COMPATIBILITY16_TABLE *Legacy16Table;
+ EFI_IA32_REGISTER_SET Regs;
+ LEGACY_BIOS_INSTANCE *Private;
- Private = LEGACY_BIOS_INSTANCE_FROM_THIS (This);
+ Private = LEGACY_BIOS_INSTANCE_FROM_THIS (This);
- LegacyBiosPlatform = Private->LegacyBiosPlatform;
- Legacy16Table = Private->Legacy16Table;
+ LegacyBiosPlatform = Private->LegacyBiosPlatform;
+ Legacy16Table = Private->Legacy16Table;
//
// Phase 1 - get an address allocated in 16-bit code
//
while (TRUE) {
switch (Id) {
- case EfiGetPlatformBinaryMpTable:
- case EfiGetPlatformBinaryOemIntData:
- case EfiGetPlatformBinaryOem32Data:
- case EfiGetPlatformBinaryOem16Data:
+ case EfiGetPlatformBinaryMpTable:
+ case EfiGetPlatformBinaryOemIntData:
+ case EfiGetPlatformBinaryOem32Data:
+ case EfiGetPlatformBinaryOem16Data:
{
Status = LegacyBiosPlatform->GetPlatformInfo (
- LegacyBiosPlatform,
- Id,
- (VOID *) &Table,
- &TableSize,
- &Location,
- &Alignment,
- 0,
- 0
- );
+ LegacyBiosPlatform,
+ Id,
+ (VOID *)&Table,
+ &TableSize,
+ &Location,
+ &Alignment,
+ 0,
+ 0
+ );
DEBUG ((DEBUG_INFO, "LegacyGetDataOrTable - ID: %x, %r\n", (UINTN)Id, Status));
DEBUG ((DEBUG_INFO, " Table - %x, Size - %x, Location - %x, Alignment - %x\n", (UINTN)Table, (UINTN)TableSize, (UINTN)Location, (UINTN)Alignment));
break;
}
- default:
+ default:
{
return EFI_INVALID_PARAMETER;
}
@@ -684,17 +694,17 @@ LegacyGetDataOrTable (
ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET));
Regs.X.AX = Legacy16GetTableAddress;
- Regs.X.CX = (UINT16) TableSize;
- Regs.X.BX = (UINT16) Location;
- Regs.X.DX = (UINT16) Alignment;
+ Regs.X.CX = (UINT16)TableSize;
+ Regs.X.BX = (UINT16)Location;
+ Regs.X.DX = (UINT16)Alignment;
Private->LegacyBios.FarCall86 (
- This,
- Private->Legacy16CallSegment,
- Private->Legacy16CallOffset,
- &Regs,
- NULL,
- 0
- );
+ This,
+ Private->Legacy16CallSegment,
+ Private->Legacy16CallOffset,
+ &Regs,
+ NULL,
+ 0
+ );
if (Regs.X.AX != 0) {
DEBUG ((DEBUG_ERROR, "Table ID %x length insufficient\n", Id));
@@ -703,38 +713,38 @@ LegacyGetDataOrTable (
break;
}
}
+
//
// Phase 2 Call routine second time with address to allow address adjustment
//
Status = LegacyBiosPlatform->GetPlatformInfo (
- LegacyBiosPlatform,
- Id,
- (VOID *) &Table,
- &TableSize,
- &Location,
- &Alignment,
- Regs.X.DS,
- Regs.X.BX
- );
+ LegacyBiosPlatform,
+ Id,
+ (VOID *)&Table,
+ &TableSize,
+ &Location,
+ &Alignment,
+ Regs.X.DS,
+ Regs.X.BX
+ );
switch (Id) {
- case EfiGetPlatformBinaryMpTable:
+ case EfiGetPlatformBinaryMpTable:
{
- Legacy16Table->MpTablePtr = (UINT32) (Regs.X.DS * 16 + Regs.X.BX);
- Legacy16Table->MpTableLength = (UINT32)TableSize;
+ Legacy16Table->MpTablePtr = (UINT32)(Regs.X.DS * 16 + Regs.X.BX);
+ Legacy16Table->MpTableLength = (UINT32)TableSize;
DEBUG ((DEBUG_INFO, "MP table in legacy region - %x\n", (UINTN)Legacy16Table->MpTablePtr));
break;
}
- case EfiGetPlatformBinaryOemIntData:
+ case EfiGetPlatformBinaryOemIntData:
{
-
- Legacy16Table->OemIntSegment = Regs.X.DS;
- Legacy16Table->OemIntOffset = Regs.X.BX;
+ Legacy16Table->OemIntSegment = Regs.X.DS;
+ Legacy16Table->OemIntOffset = Regs.X.BX;
DEBUG ((DEBUG_INFO, "OemInt table in legacy region - %04x:%04x\n", (UINTN)Legacy16Table->OemIntSegment, (UINTN)Legacy16Table->OemIntOffset));
break;
}
- case EfiGetPlatformBinaryOem32Data:
+ case EfiGetPlatformBinaryOem32Data:
{
Legacy16Table->Oem32Segment = Regs.X.DS;
Legacy16Table->Oem32Offset = Regs.X.BX;
@@ -742,7 +752,7 @@ LegacyGetDataOrTable (
break;
}
- case EfiGetPlatformBinaryOem16Data:
+ case EfiGetPlatformBinaryOem16Data:
{
//
// Legacy16Table->Oem16Segment = Regs.X.DS;
@@ -751,7 +761,7 @@ LegacyGetDataOrTable (
break;
}
- default:
+ default:
{
return EFI_INVALID_PARAMETER;
}
@@ -760,13 +770,14 @@ LegacyGetDataOrTable (
if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Phase 3 Copy table to final location
//
- TablePtr = (UINT32) (Regs.X.DS * 16 + Regs.X.BX);
+ TablePtr = (UINT32)(Regs.X.DS * 16 + Regs.X.BX);
CopyMem (
- (VOID *) (UINTN)TablePtr,
+ (VOID *)(UINTN)TablePtr,
Table,
TableSize
);
@@ -783,53 +794,54 @@ CreateSmbiosTableInReservedMemory (
VOID
)
{
- SMBIOS_TABLE_ENTRY_POINT *EntryPointStructure;
+ SMBIOS_TABLE_ENTRY_POINT *EntryPointStructure;
if ((mRuntimeSmbiosEntryPoint == NULL) ||
(mReserveSmbiosEntryPoint == 0) ||
- (mStructureTableAddress == 0)) {
+ (mStructureTableAddress == 0))
+ {
return;
}
- EntryPointStructure = (SMBIOS_TABLE_ENTRY_POINT *) mRuntimeSmbiosEntryPoint;
+ EntryPointStructure = (SMBIOS_TABLE_ENTRY_POINT *)mRuntimeSmbiosEntryPoint;
//
// Copy SMBIOS Entry Point Structure
//
CopyMem (
- (VOID *)(UINTN) mReserveSmbiosEntryPoint,
+ (VOID *)(UINTN)mReserveSmbiosEntryPoint,
EntryPointStructure,
EntryPointStructure->EntryPointLength
- );
+ );
//
// Copy SMBIOS Structure Table into EfiReservedMemoryType memory
//
CopyMem (
- (VOID *)(UINTN) mStructureTableAddress,
- (VOID *)(UINTN) EntryPointStructure->TableAddress,
+ (VOID *)(UINTN)mStructureTableAddress,
+ (VOID *)(UINTN)EntryPointStructure->TableAddress,
EntryPointStructure->TableLength
- );
+ );
//
// Update TableAddress in Entry Point Structure
//
- EntryPointStructure = (SMBIOS_TABLE_ENTRY_POINT *)(UINTN) mReserveSmbiosEntryPoint;
- EntryPointStructure->TableAddress = (UINT32)(UINTN) mStructureTableAddress;
+ EntryPointStructure = (SMBIOS_TABLE_ENTRY_POINT *)(UINTN)mReserveSmbiosEntryPoint;
+ EntryPointStructure->TableAddress = (UINT32)(UINTN)mStructureTableAddress;
//
// Fixup checksums in the Entry Point Structure
//
- EntryPointStructure->IntermediateChecksum = 0;
+ EntryPointStructure->IntermediateChecksum = 0;
EntryPointStructure->EntryPointStructureChecksum = 0;
EntryPointStructure->IntermediateChecksum =
CalculateCheckSum8 (
- (UINT8 *) EntryPointStructure + OFFSET_OF (SMBIOS_TABLE_ENTRY_POINT, IntermediateAnchorString),
+ (UINT8 *)EntryPointStructure + OFFSET_OF (SMBIOS_TABLE_ENTRY_POINT, IntermediateAnchorString),
EntryPointStructure->EntryPointLength - OFFSET_OF (SMBIOS_TABLE_ENTRY_POINT, IntermediateAnchorString)
);
EntryPointStructure->EntryPointStructureChecksum =
- CalculateCheckSum8 ((UINT8 *) EntryPointStructure, EntryPointStructure->EntryPointLength);
+ CalculateCheckSum8 ((UINT8 *)EntryPointStructure, EntryPointStructure->EntryPointLength);
}
/**
@@ -845,47 +857,47 @@ CreateSmbiosTableInReservedMemory (
**/
EFI_STATUS
GenericLegacyBoot (
- IN EFI_LEGACY_BIOS_PROTOCOL *This
+ IN EFI_LEGACY_BIOS_PROTOCOL *This
)
{
- EFI_STATUS Status;
- LEGACY_BIOS_INSTANCE *Private;
- EFI_IA32_REGISTER_SET Regs;
- EFI_TO_COMPATIBILITY16_BOOT_TABLE *EfiToLegacy16BootTable;
- EFI_LEGACY_BIOS_PLATFORM_PROTOCOL *LegacyBiosPlatform;
- UINTN CopySize;
- VOID *AcpiPtr;
- HDD_INFO *HddInfo;
- HDD_INFO *LocalHddInfo;
- UINTN Index;
- EFI_COMPATIBILITY16_TABLE *Legacy16Table;
- UINT32 *BdaPtr;
- UINT16 HddCount;
- UINT16 BbsCount;
- BBS_TABLE *LocalBbsTable;
- UINT32 *BaseVectorMaster;
- EFI_TIME BootTime;
- UINT32 LocalTime;
- EFI_HANDLE IdeController;
- UINTN HandleCount;
- EFI_HANDLE *HandleBuffer;
- VOID *AcpiTable;
- UINTN ShadowAddress;
- UINT32 Granularity;
+ EFI_STATUS Status;
+ LEGACY_BIOS_INSTANCE *Private;
+ EFI_IA32_REGISTER_SET Regs;
+ EFI_TO_COMPATIBILITY16_BOOT_TABLE *EfiToLegacy16BootTable;
+ EFI_LEGACY_BIOS_PLATFORM_PROTOCOL *LegacyBiosPlatform;
+ UINTN CopySize;
+ VOID *AcpiPtr;
+ HDD_INFO *HddInfo;
+ HDD_INFO *LocalHddInfo;
+ UINTN Index;
+ EFI_COMPATIBILITY16_TABLE *Legacy16Table;
+ UINT32 *BdaPtr;
+ UINT16 HddCount;
+ UINT16 BbsCount;
+ BBS_TABLE *LocalBbsTable;
+ UINT32 *BaseVectorMaster;
+ EFI_TIME BootTime;
+ UINT32 LocalTime;
+ EFI_HANDLE IdeController;
+ UINTN HandleCount;
+ EFI_HANDLE *HandleBuffer;
+ VOID *AcpiTable;
+ UINTN ShadowAddress;
+ UINT32 Granularity;
LocalHddInfo = NULL;
HddCount = 0;
BbsCount = 0;
LocalBbsTable = NULL;
- Private = LEGACY_BIOS_INSTANCE_FROM_THIS (This);
+ Private = LEGACY_BIOS_INSTANCE_FROM_THIS (This);
DEBUG_CODE (
DEBUG ((DEBUG_ERROR, "Start of legacy boot\n"));
- );
+ );
- Legacy16Table = Private->Legacy16Table;
- EfiToLegacy16BootTable = &Private->IntThunk->EfiToLegacy16BootTable;
- HddInfo = &EfiToLegacy16BootTable->HddInfo[0];
+ Legacy16Table = Private->Legacy16Table;
+ EfiToLegacy16BootTable = &Private->IntThunk->EfiToLegacy16BootTable;
+ HddInfo = &EfiToLegacy16BootTable->HddInfo[0];
LegacyBiosPlatform = Private->LegacyBiosPlatform;
@@ -900,17 +912,18 @@ GenericLegacyBoot (
IdeController = NULL;
if ((mBootMode == BOOT_LEGACY_OS) || (mBootMode == BOOT_UNCONVENTIONAL_DEVICE)) {
Status = LegacyBiosPlatform->GetPlatformHandle (
- Private->LegacyBiosPlatform,
- EfiGetPlatformIdeHandle,
- 0,
- &HandleBuffer,
- &HandleCount,
- NULL
- );
+ Private->LegacyBiosPlatform,
+ EfiGetPlatformIdeHandle,
+ 0,
+ &HandleBuffer,
+ &HandleCount,
+ NULL
+ );
if (!EFI_ERROR (Status)) {
IdeController = HandleBuffer[0];
}
}
+
//
// Unlock the Legacy BIOS region
//
@@ -928,37 +941,37 @@ GenericLegacyBoot (
if (CopySize > Private->Legacy16Table->E820Length) {
ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET));
Regs.X.AX = Legacy16GetTableAddress;
- Regs.X.BX = (UINT16) 0x0; // Any region
- Regs.X.CX = (UINT16) CopySize;
- Regs.X.DX = (UINT16) 0x4; // Alignment
+ Regs.X.BX = (UINT16)0x0; // Any region
+ Regs.X.CX = (UINT16)CopySize;
+ Regs.X.DX = (UINT16)0x4; // Alignment
Private->LegacyBios.FarCall86 (
- &Private->LegacyBios,
- Private->Legacy16Table->Compatibility16CallSegment,
- Private->Legacy16Table->Compatibility16CallOffset,
- &Regs,
- NULL,
- 0
- );
-
- Private->Legacy16Table->E820Pointer = (UINT32) (Regs.X.DS * 16 + Regs.X.BX);
- Private->Legacy16Table->E820Length = (UINT32) CopySize;
+ &Private->LegacyBios,
+ Private->Legacy16Table->Compatibility16CallSegment,
+ Private->Legacy16Table->Compatibility16CallOffset,
+ &Regs,
+ NULL,
+ 0
+ );
+
+ Private->Legacy16Table->E820Pointer = (UINT32)(Regs.X.DS * 16 + Regs.X.BX);
+ Private->Legacy16Table->E820Length = (UINT32)CopySize;
if (Regs.X.AX != 0) {
DEBUG ((DEBUG_ERROR, "Legacy16 E820 length insufficient\n"));
return EFI_OUT_OF_RESOURCES;
} else {
CopyMem (
- (VOID *)(UINTN) Private->Legacy16Table->E820Pointer,
+ (VOID *)(UINTN)Private->Legacy16Table->E820Pointer,
Private->E820Table,
CopySize
);
}
} else {
CopyMem (
- (VOID *)(UINTN) Private->Legacy16Table->E820Pointer,
+ (VOID *)(UINTN)Private->Legacy16Table->E820Pointer,
Private->E820Table,
CopySize
);
- Private->Legacy16Table->E820Length = (UINT32) CopySize;
+ Private->Legacy16Table->E820Length = (UINT32)CopySize;
}
//
@@ -967,26 +980,29 @@ GenericLegacyBoot (
if (mReserveSmbiosEntryPoint == 0) {
DEBUG ((DEBUG_INFO, "Smbios table is not found!\n"));
}
+
CreateSmbiosTableInReservedMemory ();
EfiToLegacy16BootTable->SmbiosTable = (UINT32)(UINTN)mReserveSmbiosEntryPoint;
AcpiTable = NULL;
- Status = EfiGetSystemConfigurationTable (
- &gEfiAcpi20TableGuid,
- &AcpiTable
- );
+ Status = EfiGetSystemConfigurationTable (
+ &gEfiAcpi20TableGuid,
+ &AcpiTable
+ );
if (EFI_ERROR (Status)) {
Status = EfiGetSystemConfigurationTable (
&gEfiAcpi10TableGuid,
&AcpiTable
);
}
+
//
// We do not ASSERT if AcpiTable not found. It is possible that a platform does not produce AcpiTable.
//
if (AcpiTable == NULL) {
DEBUG ((DEBUG_INFO, "ACPI table is not found!\n"));
}
+
EfiToLegacy16BootTable->AcpiTable = (UINT32)(UINTN)AcpiTable;
//
@@ -995,21 +1011,21 @@ GenericLegacyBoot (
// Rev != 0 Length is UINT32 at offset 20 decimal
//
if (AcpiTable != NULL) {
-
AcpiPtr = AcpiTable;
- if (*((UINT8 *) AcpiPtr + 15) == 0) {
+ if (*((UINT8 *)AcpiPtr + 15) == 0) {
CopySize = 20;
} else {
- AcpiPtr = ((UINT8 *) AcpiPtr + 20);
- CopySize = (*(UINT32 *) AcpiPtr);
+ AcpiPtr = ((UINT8 *)AcpiPtr + 20);
+ CopySize = (*(UINT32 *)AcpiPtr);
}
CopyMem (
- (VOID *)(UINTN) Private->Legacy16Table->AcpiRsdPtrPointer,
+ (VOID *)(UINTN)Private->Legacy16Table->AcpiRsdPtrPointer,
AcpiTable,
CopySize
);
}
+
//
// Make sure all PCI Interrupt Line register are programmed to match 8259
//
@@ -1034,12 +1050,13 @@ GenericLegacyBoot (
if ((mBootMode == BOOT_LEGACY_OS) || (mBootMode == BOOT_UNCONVENTIONAL_DEVICE)) {
UpdateSioData (Private);
}
+
//
// Setup BDA and EBDA standard areas before Legacy Boot
//
ACCESS_PAGE0_CODE (
LegacyBiosCompleteBdaBeforeBoot (Private);
- );
+ );
LegacyBiosCompleteStandardCmosBeforeBoot (Private);
//
@@ -1063,7 +1080,7 @@ GenericLegacyBoot (
// Adjust value by 1 second.
//
gRT->GetTime (&BootTime, NULL);
- LocalTime = BootTime.Hour * 3600 + BootTime.Minute * 60 + BootTime.Second;
+ LocalTime = BootTime.Hour * 3600 + BootTime.Minute * 60 + BootTime.Second;
LocalTime += 1;
//
@@ -1072,9 +1089,9 @@ GenericLegacyBoot (
//
LocalTime = (LocalTime * 182) / 10;
ACCESS_PAGE0_CODE (
- BdaPtr = (UINT32 *) (UINTN)0x46C;
- *BdaPtr = LocalTime;
- );
+ BdaPtr = (UINT32 *)(UINTN)0x46C;
+ *BdaPtr = LocalTime;
+ );
//
// Shadow PCI ROMs. We must do this near the end since this will kick
@@ -1130,13 +1147,15 @@ GenericLegacyBoot (
for (Index = 0; Index < MAX_IDE_CONTROLLER; Index++) {
if ((LocalHddInfo[Index].IdentifyDrive[0].Raw[0] != 0) &&
(LocalBbsTable[2 * Index + 1].BootPriority == BBS_IGNORE_ENTRY)
- ) {
+ )
+ {
LocalBbsTable[2 * Index + 1].BootPriority = BBS_UNPRIORITIZED_ENTRY;
}
if ((LocalHddInfo[Index].IdentifyDrive[1].Raw[0] != 0) &&
(LocalBbsTable[2 * Index + 2].BootPriority == BBS_IGNORE_ENTRY)
- ) {
+ )
+ {
LocalBbsTable[2 * Index + 2].BootPriority = BBS_UNPRIORITIZED_ENTRY;
}
}
@@ -1154,24 +1173,27 @@ GenericLegacyBoot (
mBbsTable,
mLoadOptionsSize,
mLoadOptions,
- (VOID *) &Private->IntThunk->EfiToLegacy16BootTable
+ (VOID *)&Private->IntThunk->EfiToLegacy16BootTable
);
//
// If no boot device return to BDS
//
if ((mBootMode == BOOT_LEGACY_OS) || (mBootMode == BOOT_UNCONVENTIONAL_DEVICE)) {
- for (Index = 0; Index < BbsCount; Index++){
+ for (Index = 0; Index < BbsCount; Index++) {
if ((LocalBbsTable[Index].BootPriority != BBS_DO_NOT_BOOT_FROM) &&
(LocalBbsTable[Index].BootPriority != BBS_UNPRIORITIZED_ENTRY) &&
- (LocalBbsTable[Index].BootPriority != BBS_IGNORE_ENTRY)) {
+ (LocalBbsTable[Index].BootPriority != BBS_IGNORE_ENTRY))
+ {
break;
}
}
+
if (Index == BbsCount) {
return EFI_DEVICE_ERROR;
}
}
+
//
// Let the Legacy16 code know the device path type for legacy boot
//
@@ -1218,17 +1240,18 @@ GenericLegacyBoot (
Regs.X.BX = NORMALIZE_EFI_OFFSET ((UINTN)EfiToLegacy16BootTable);
Private->LegacyBios.FarCall86 (
- This,
- Private->Legacy16CallSegment,
- Private->Legacy16CallOffset,
- &Regs,
- NULL,
- 0
- );
+ This,
+ Private->Legacy16CallSegment,
+ Private->Legacy16CallOffset,
+ &Regs,
+ NULL,
+ 0
+ );
if (Regs.X.AX != 0) {
return EFI_DEVICE_ERROR;
}
+
//
// Lock the Legacy BIOS region
//
@@ -1240,13 +1263,18 @@ GenericLegacyBoot (
);
if ((Private->Legacy16Table->TableLength >= OFFSET_OF (EFI_COMPATIBILITY16_TABLE, HiPermanentMemoryAddress)) &&
- ((Private->Legacy16Table->UmaAddress != 0) && (Private->Legacy16Table->UmaSize != 0))) {
+ ((Private->Legacy16Table->UmaAddress != 0) && (Private->Legacy16Table->UmaSize != 0)))
+ {
//
// Here we could reduce UmaAddress down as far as Private->OptionRom, taking into
// account the granularity of the access control.
//
- DEBUG((DEBUG_INFO, "Unlocking UMB RAM region 0x%x-0x%x\n", Private->Legacy16Table->UmaAddress,
- Private->Legacy16Table->UmaAddress + Private->Legacy16Table->UmaSize));
+ DEBUG ((
+ DEBUG_INFO,
+ "Unlocking UMB RAM region 0x%x-0x%x\n",
+ Private->Legacy16Table->UmaAddress,
+ Private->Legacy16Table->UmaAddress + Private->Legacy16Table->UmaSize
+ ));
Private->LegacyRegion->UnLock (
Private->LegacyRegion,
@@ -1271,7 +1299,6 @@ GenericLegacyBoot (
//
EnableAllControllers (Private);
if ((mBootMode == BOOT_LEGACY_OS) || (mBootMode == BOOT_UNCONVENTIONAL_DEVICE)) {
-
//
// Signal all the events that are waiting on EVT_SIGNAL_LEGACY_BOOT
//
@@ -1297,7 +1324,6 @@ GenericLegacyBoot (
//
SaveAndSetDebugTimerInterrupt (FALSE);
-
//
// Put the 8259 into its legacy mode by reprogramming the vector bases
//
@@ -1321,34 +1347,37 @@ GenericLegacyBoot (
//
//
ACCESS_PAGE0_CODE (
- BaseVectorMaster = (UINT32 *) (sizeof (UINT32) * PROTECTED_MODE_BASE_VECTOR_MASTER);
+ 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);
- }
+ Private->ThunkSavedInt[Index] = BaseVectorMaster[Index];
+ if (Private->ThunkSeg == (UINT16)(BaseVectorMaster[Index] >> 16)) {
+ BaseVectorMaster[Index] = (UINT32)(Private->BiosUnexpectedInt);
}
- );
+ }
+
+ );
ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET));
Regs.X.AX = Legacy16Boot;
Private->LegacyBios.FarCall86 (
- This,
- Private->Legacy16CallSegment,
- Private->Legacy16CallOffset,
- &Regs,
- NULL,
- 0
- );
+ This,
+ Private->Legacy16CallSegment,
+ Private->Legacy16CallOffset,
+ &Regs,
+ NULL,
+ 0
+ );
ACCESS_PAGE0_CODE (
- BaseVectorMaster = (UINT32 *) (sizeof (UINT32) * PROTECTED_MODE_BASE_VECTOR_MASTER);
+ BaseVectorMaster = (UINT32 *)(sizeof (UINT32) * PROTECTED_MODE_BASE_VECTOR_MASTER);
for (Index = 0; Index < 8; Index++) {
- BaseVectorMaster[Index] = Private->ThunkSavedInt[Index];
- }
- );
+ BaseVectorMaster[Index] = Private->ThunkSavedInt[Index];
+ }
+
+ );
}
+
Private->LegacyBootEntered = TRUE;
if ((mBootMode == BOOT_LEGACY_OS) || (mBootMode == BOOT_UNCONVENTIONAL_DEVICE)) {
//
@@ -1364,7 +1393,6 @@ GenericLegacyBoot (
}
}
-
/**
Assign drive number to legacy HDD drives prior to booting an EFI
aware OS so the OS can access drives without an EFI driver.
@@ -1381,22 +1409,22 @@ GenericLegacyBoot (
EFI_STATUS
EFIAPI
LegacyBiosPrepareToBootEfi (
- IN EFI_LEGACY_BIOS_PROTOCOL *This,
- OUT UINT16 *BbsCount,
- OUT BBS_TABLE **BbsTable
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,
+ OUT UINT16 *BbsCount,
+ OUT BBS_TABLE **BbsTable
)
{
- EFI_STATUS Status;
- EFI_TO_COMPATIBILITY16_BOOT_TABLE *EfiToLegacy16BootTable;
- LEGACY_BIOS_INSTANCE *Private;
-
- Private = LEGACY_BIOS_INSTANCE_FROM_THIS (This);
- EfiToLegacy16BootTable = &Private->IntThunk->EfiToLegacy16BootTable;
- mBootMode = BOOT_EFI_OS;
- mBbsDevicePathPtr = NULL;
- Status = GenericLegacyBoot (This);
- *BbsTable = (BBS_TABLE*)(UINTN)EfiToLegacy16BootTable->BbsTable;
- *BbsCount = (UINT16) (sizeof (Private->IntThunk->BbsTable) / sizeof (BBS_TABLE));
+ EFI_STATUS Status;
+ EFI_TO_COMPATIBILITY16_BOOT_TABLE *EfiToLegacy16BootTable;
+ LEGACY_BIOS_INSTANCE *Private;
+
+ Private = LEGACY_BIOS_INSTANCE_FROM_THIS (This);
+ EfiToLegacy16BootTable = &Private->IntThunk->EfiToLegacy16BootTable;
+ mBootMode = BOOT_EFI_OS;
+ mBbsDevicePathPtr = NULL;
+ Status = GenericLegacyBoot (This);
+ *BbsTable = (BBS_TABLE *)(UINTN)EfiToLegacy16BootTable->BbsTable;
+ *BbsCount = (UINT16)(sizeof (Private->IntThunk->BbsTable) / sizeof (BBS_TABLE));
return Status;
}
@@ -1418,28 +1446,28 @@ LegacyBiosPrepareToBootEfi (
EFI_STATUS
EFIAPI
LegacyBiosBootUnconventionalDevice (
- IN EFI_LEGACY_BIOS_PROTOCOL *This,
- IN UDC_ATTRIBUTES Attributes,
- IN UINTN BbsEntry,
- IN VOID *BeerData,
- IN VOID *ServiceAreaData
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,
+ IN UDC_ATTRIBUTES Attributes,
+ IN UINTN BbsEntry,
+ IN VOID *BeerData,
+ IN VOID *ServiceAreaData
)
{
- EFI_STATUS Status;
- EFI_TO_COMPATIBILITY16_BOOT_TABLE *EfiToLegacy16BootTable;
- LEGACY_BIOS_INSTANCE *Private;
- UD_TABLE *UcdTable;
- UINTN Index;
- UINT16 BootPriority;
- BBS_TABLE *BbsTable;
-
- BootPriority = 0;
- Private = LEGACY_BIOS_INSTANCE_FROM_THIS (This);
- mBootMode = BOOT_UNCONVENTIONAL_DEVICE;
+ EFI_STATUS Status;
+ EFI_TO_COMPATIBILITY16_BOOT_TABLE *EfiToLegacy16BootTable;
+ LEGACY_BIOS_INSTANCE *Private;
+ UD_TABLE *UcdTable;
+ UINTN Index;
+ UINT16 BootPriority;
+ BBS_TABLE *BbsTable;
+
+ BootPriority = 0;
+ Private = LEGACY_BIOS_INSTANCE_FROM_THIS (This);
+ mBootMode = BOOT_UNCONVENTIONAL_DEVICE;
mBbsDevicePathPtr = &mBbsDevicePathNode;
- mAttributes = Attributes;
- mBbsEntry = BbsEntry;
- mBeerData = BeerData, mServiceAreaData = ServiceAreaData;
+ mAttributes = Attributes;
+ mBbsEntry = BbsEntry;
+ mBeerData = BeerData, mServiceAreaData = ServiceAreaData;
EfiToLegacy16BootTable = &Private->IntThunk->EfiToLegacy16BootTable;
@@ -1449,58 +1477,62 @@ LegacyBiosBootUnconventionalDevice (
if ((Attributes.DirectoryServiceValidity == 0) &&
(Attributes.RabcaUsedFlag == 0) &&
(Attributes.ExecuteHddDiagnosticsFlag == 0)
- ) {
+ )
+ {
return EFI_INVALID_PARAMETER;
}
if (((Attributes.DirectoryServiceValidity != 0) && (ServiceAreaData == NULL)) ||
(((Attributes.DirectoryServiceValidity | Attributes.RabcaUsedFlag) != 0) && (BeerData == NULL))
- ) {
+ )
+ {
return EFI_INVALID_PARAMETER;
}
- UcdTable = (UD_TABLE *) AllocatePool (
- sizeof (UD_TABLE)
- );
+ UcdTable = (UD_TABLE *)AllocatePool (
+ sizeof (UD_TABLE)
+ );
if (NULL == UcdTable) {
return EFI_OUT_OF_RESOURCES;
}
EfiToLegacy16BootTable->UnconventionalDeviceTable = (UINT32)(UINTN)UcdTable;
- UcdTable->Attributes = Attributes;
- UcdTable->BbsTableEntryNumberForParentDevice = (UINT8) BbsEntry;
+ UcdTable->Attributes = Attributes;
+ UcdTable->BbsTableEntryNumberForParentDevice = (UINT8)BbsEntry;
//
// Force all existing BBS entries to DoNotBoot. This allows 16-bit CSM
// to assign drive numbers but bot boot from. Only newly created entries
// will be valid.
//
- BbsTable = (BBS_TABLE*)(UINTN)EfiToLegacy16BootTable->BbsTable;
+ BbsTable = (BBS_TABLE *)(UINTN)EfiToLegacy16BootTable->BbsTable;
for (Index = 0; Index < EfiToLegacy16BootTable->NumberBbsEntries; Index++) {
BbsTable[Index].BootPriority = BBS_DO_NOT_BOOT_FROM;
}
+
//
// If parent is onboard IDE then assign controller & device number
// else they are 0.
//
if (BbsEntry < MAX_IDE_CONTROLLER * 2) {
- UcdTable->DeviceNumber = (UINT8) ((BbsEntry - 1) % 2);
+ UcdTable->DeviceNumber = (UINT8)((BbsEntry - 1) % 2);
}
if (BeerData != NULL) {
CopyMem (
- (VOID *) UcdTable->BeerData,
+ (VOID *)UcdTable->BeerData,
BeerData,
- (UINTN) 128
+ (UINTN)128
);
}
if (ServiceAreaData != NULL) {
CopyMem (
- (VOID *) UcdTable->ServiceAreaData,
+ (VOID *)UcdTable->ServiceAreaData,
ServiceAreaData,
- (UINTN) 64
+ (UINTN)64
);
}
+
//
// For each new entry do the following:
// 1. Increment current number of BBS entries
@@ -1514,8 +1546,8 @@ LegacyBiosBootUnconventionalDevice (
EfiToLegacy16BootTable->NumberBbsEntries += 1;
CopyMem (
- (VOID *) &BbsTable[EfiToLegacy16BootTable->NumberBbsEntries].BootPriority,
- (VOID *) &BbsTable[BbsEntry].BootPriority,
+ (VOID *)&BbsTable[EfiToLegacy16BootTable->NumberBbsEntries].BootPriority,
+ (VOID *)&BbsTable[BbsEntry].BootPriority,
sizeof (BBS_TABLE)
);
@@ -1523,10 +1555,10 @@ LegacyBiosBootUnconventionalDevice (
BbsTable[EfiToLegacy16BootTable->NumberBbsEntries].BootHandlerSegment = 0;
BbsTable[EfiToLegacy16BootTable->NumberBbsEntries].DeviceType = 0x80;
- UcdTable->BbsTableEntryNumberForHddDiag = (UINT8) (EfiToLegacy16BootTable->NumberBbsEntries - 1);
+ UcdTable->BbsTableEntryNumberForHddDiag = (UINT8)(EfiToLegacy16BootTable->NumberBbsEntries - 1);
BbsTable[EfiToLegacy16BootTable->NumberBbsEntries].BootPriority = BootPriority;
- BootPriority += 1;
+ BootPriority += 1;
//
// Set device type as BBS_TYPE_DEV for PARTIES diagnostic
@@ -1537,22 +1569,23 @@ LegacyBiosBootUnconventionalDevice (
if (((Attributes.DirectoryServiceValidity | Attributes.RabcaUsedFlag)) != 0) {
EfiToLegacy16BootTable->NumberBbsEntries += 1;
CopyMem (
- (VOID *) &BbsTable[EfiToLegacy16BootTable->NumberBbsEntries].BootPriority,
- (VOID *) &BbsTable[BbsEntry].BootPriority,
+ (VOID *)&BbsTable[EfiToLegacy16BootTable->NumberBbsEntries].BootPriority,
+ (VOID *)&BbsTable[BbsEntry].BootPriority,
sizeof (BBS_TABLE)
);
BbsTable[EfiToLegacy16BootTable->NumberBbsEntries].BootHandlerOffset = 0;
BbsTable[EfiToLegacy16BootTable->NumberBbsEntries].BootHandlerSegment = 0;
BbsTable[EfiToLegacy16BootTable->NumberBbsEntries].DeviceType = 0x01;
- UcdTable->BbsTableEntryNumberForBoot = (UINT8) (EfiToLegacy16BootTable->NumberBbsEntries - 1);
- BbsTable[EfiToLegacy16BootTable->NumberBbsEntries].BootPriority = BootPriority;
+ UcdTable->BbsTableEntryNumberForBoot = (UINT8)(EfiToLegacy16BootTable->NumberBbsEntries - 1);
+ BbsTable[EfiToLegacy16BootTable->NumberBbsEntries].BootPriority = BootPriority;
//
// Set device type as BBS_TYPE_FLOPPY for PARTIES boot as floppy
//
mBbsDevicePathNode.DeviceType = BBS_TYPE_FLOPPY;
}
+
//
// Build the BBS Device Path for this boot selection
//
@@ -1562,7 +1595,7 @@ LegacyBiosBootUnconventionalDevice (
mBbsDevicePathNode.StatusFlag = 0;
mBbsDevicePathNode.String[0] = 0;
- Status = GenericLegacyBoot (This);
+ Status = GenericLegacyBoot (This);
return Status;
}
@@ -1581,10 +1614,10 @@ LegacyBiosBootUnconventionalDevice (
EFI_STATUS
EFIAPI
LegacyBiosLegacyBoot (
- IN EFI_LEGACY_BIOS_PROTOCOL *This,
- IN BBS_BBS_DEVICE_PATH *BbsDevicePath,
- IN UINT32 LoadOptionsSize,
- IN VOID *LoadOptions
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,
+ IN BBS_BBS_DEVICE_PATH *BbsDevicePath,
+ IN UINT32 LoadOptionsSize,
+ IN VOID *LoadOptions
)
{
EFI_STATUS Status;
@@ -1608,46 +1641,46 @@ LegacyBiosLegacyBoot (
**/
EFI_ACPI_MEMORY_TYPE
EfiMemoryTypeToE820Type (
- IN UINT32 Type
+ IN UINT32 Type
)
{
switch (Type) {
- case EfiLoaderCode:
- case EfiLoaderData:
- case EfiBootServicesCode:
- case EfiBootServicesData:
- case EfiConventionalMemory:
- //
- // The memory of EfiRuntimeServicesCode and EfiRuntimeServicesData are
- // usable memory for legacy OS, because legacy OS is not aware of EFI runtime concept.
- // In ACPI specification, EfiRuntimeServiceCode and EfiRuntimeServiceData
- // should be mapped to AddressRangeReserved. This statement is for UEFI OS, not for legacy OS.
- //
- case EfiRuntimeServicesCode:
- case EfiRuntimeServicesData:
- return EfiAcpiAddressRangeMemory;
+ case EfiLoaderCode:
+ case EfiLoaderData:
+ case EfiBootServicesCode:
+ case EfiBootServicesData:
+ case EfiConventionalMemory:
+ //
+ // The memory of EfiRuntimeServicesCode and EfiRuntimeServicesData are
+ // usable memory for legacy OS, because legacy OS is not aware of EFI runtime concept.
+ // In ACPI specification, EfiRuntimeServiceCode and EfiRuntimeServiceData
+ // should be mapped to AddressRangeReserved. This statement is for UEFI OS, not for legacy OS.
+ //
+ case EfiRuntimeServicesCode:
+ case EfiRuntimeServicesData:
+ return EfiAcpiAddressRangeMemory;
- case EfiPersistentMemory:
- return EfiAddressRangePersistentMemory;
+ case EfiPersistentMemory:
+ return EfiAddressRangePersistentMemory;
- case EfiACPIReclaimMemory:
- return EfiAcpiAddressRangeACPI;
+ case EfiACPIReclaimMemory:
+ return EfiAcpiAddressRangeACPI;
- case EfiACPIMemoryNVS:
- return EfiAcpiAddressRangeNVS;
+ case EfiACPIMemoryNVS:
+ return EfiAcpiAddressRangeNVS;
- //
- // All other types map to reserved.
- // Adding the code just waists FLASH space.
- //
- // case EfiReservedMemoryType:
- // case EfiUnusableMemory:
- // case EfiMemoryMappedIO:
- // case EfiMemoryMappedIOPortSpace:
- // case EfiPalCode:
- //
- default:
- return EfiAcpiAddressRangeReserved;
+ //
+ // All other types map to reserved.
+ // Adding the code just waists FLASH space.
+ //
+ // case EfiReservedMemoryType:
+ // case EfiUnusableMemory:
+ // case EfiMemoryMappedIO:
+ // case EfiMemoryMappedIOPortSpace:
+ // case EfiPalCode:
+ //
+ default:
+ return EfiAcpiAddressRangeReserved;
}
}
@@ -1662,47 +1695,47 @@ EfiMemoryTypeToE820Type (
**/
EFI_STATUS
LegacyBiosBuildE820 (
- IN LEGACY_BIOS_INSTANCE *Private,
- OUT UINTN *Size
+ IN LEGACY_BIOS_INSTANCE *Private,
+ OUT UINTN *Size
)
{
- EFI_STATUS Status;
- EFI_E820_ENTRY64 *E820Table;
- EFI_MEMORY_DESCRIPTOR *EfiMemoryMap;
- EFI_MEMORY_DESCRIPTOR *EfiMemoryMapEnd;
- EFI_MEMORY_DESCRIPTOR *EfiEntry;
- EFI_MEMORY_DESCRIPTOR *NextEfiEntry;
- EFI_MEMORY_DESCRIPTOR TempEfiEntry;
- UINTN EfiMemoryMapSize;
- UINTN EfiMapKey;
- UINTN EfiDescriptorSize;
- UINT32 EfiDescriptorVersion;
- UINTN Index;
- EFI_PEI_HOB_POINTERS Hob;
- EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob;
- UINTN TempIndex;
- UINTN IndexSort;
- UINTN TempNextIndex;
- EFI_E820_ENTRY64 TempE820;
- EFI_ACPI_MEMORY_TYPE TempType;
- BOOLEAN ChangedFlag;
- UINTN Above1MIndex;
- UINT64 MemoryBlockLength;
-
- E820Table = (EFI_E820_ENTRY64 *) Private->E820Table;
+ EFI_STATUS Status;
+ EFI_E820_ENTRY64 *E820Table;
+ EFI_MEMORY_DESCRIPTOR *EfiMemoryMap;
+ EFI_MEMORY_DESCRIPTOR *EfiMemoryMapEnd;
+ EFI_MEMORY_DESCRIPTOR *EfiEntry;
+ EFI_MEMORY_DESCRIPTOR *NextEfiEntry;
+ EFI_MEMORY_DESCRIPTOR TempEfiEntry;
+ UINTN EfiMemoryMapSize;
+ UINTN EfiMapKey;
+ UINTN EfiDescriptorSize;
+ UINT32 EfiDescriptorVersion;
+ UINTN Index;
+ EFI_PEI_HOB_POINTERS Hob;
+ EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob;
+ UINTN TempIndex;
+ UINTN IndexSort;
+ UINTN TempNextIndex;
+ EFI_E820_ENTRY64 TempE820;
+ EFI_ACPI_MEMORY_TYPE TempType;
+ BOOLEAN ChangedFlag;
+ UINTN Above1MIndex;
+ UINT64 MemoryBlockLength;
+
+ E820Table = (EFI_E820_ENTRY64 *)Private->E820Table;
//
// Get the EFI memory map.
//
- EfiMemoryMapSize = 0;
- EfiMemoryMap = NULL;
- Status = gBS->GetMemoryMap (
- &EfiMemoryMapSize,
- EfiMemoryMap,
- &EfiMapKey,
- &EfiDescriptorSize,
- &EfiDescriptorVersion
- );
+ EfiMemoryMapSize = 0;
+ EfiMemoryMap = NULL;
+ Status = gBS->GetMemoryMap (
+ &EfiMemoryMapSize,
+ EfiMemoryMap,
+ &EfiMapKey,
+ &EfiDescriptorSize,
+ &EfiDescriptorVersion
+ );
ASSERT (Status == EFI_BUFFER_TOO_SMALL);
do {
@@ -1712,7 +1745,7 @@ LegacyBiosBuildE820 (
// EfiMemoryMapEnd which is dependent upon EfiMemoryMapSize. Otherwise
// we process bogus entries and create bogus E820 entries.
//
- EfiMemoryMap = (EFI_MEMORY_DESCRIPTOR *) AllocatePool (EfiMemoryMapSize);
+ EfiMemoryMap = (EFI_MEMORY_DESCRIPTOR *)AllocatePool (EfiMemoryMapSize);
ASSERT (EfiMemoryMap != NULL);
Status = gBS->GetMemoryMap (
&EfiMemoryMapSize,
@@ -1736,17 +1769,17 @@ LegacyBiosBuildE820 (
// First entry is 0 to (640k - EBDA)
//
ACCESS_PAGE0_CODE (
- E820Table[0].BaseAddr = 0;
- E820Table[0].Length = (UINT64) ((*(UINT16 *) (UINTN)0x40E) << 4);
- E820Table[0].Type = EfiAcpiAddressRangeMemory;
- );
+ E820Table[0].BaseAddr = 0;
+ E820Table[0].Length = (UINT64)((*(UINT16 *)(UINTN)0x40E) << 4);
+ E820Table[0].Type = EfiAcpiAddressRangeMemory;
+ );
//
// Second entry is (640k - EBDA) to 640k
//
- E820Table[1].BaseAddr = E820Table[0].Length;
- E820Table[1].Length = (UINT64) ((640 * 1024) - E820Table[0].Length);
- E820Table[1].Type = EfiAcpiAddressRangeReserved;
+ E820Table[1].BaseAddr = E820Table[0].Length;
+ E820Table[1].Length = (UINT64)((640 * 1024) - E820Table[0].Length);
+ E820Table[1].Type = EfiAcpiAddressRangeReserved;
//
// Third Entry is legacy BIOS
@@ -1760,9 +1793,9 @@ LegacyBiosBuildE820 (
// The CSM binary image size is not the actually size that CSM binary used,
// to avoid memory corrupt, we declare the 0E0000 - 0FFFFF is used by CSM binary.
//
- E820Table[2].BaseAddr = 0xE0000;
- E820Table[2].Length = 0x20000;
- E820Table[2].Type = EfiAcpiAddressRangeReserved;
+ E820Table[2].BaseAddr = 0xE0000;
+ E820Table[2].Length = 0x20000;
+ E820Table[2].Type = EfiAcpiAddressRangeReserved;
Above1MIndex = 2;
@@ -1775,7 +1808,7 @@ LegacyBiosBuildE820 (
//
EfiEntry = EfiMemoryMap;
NextEfiEntry = NEXT_MEMORY_DESCRIPTOR (EfiEntry, EfiDescriptorSize);
- EfiMemoryMapEnd = (EFI_MEMORY_DESCRIPTOR *) ((UINT8 *) EfiMemoryMap + EfiMemoryMapSize);
+ EfiMemoryMapEnd = (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)EfiMemoryMap + EfiMemoryMapSize);
while (EfiEntry < EfiMemoryMapEnd) {
while (NextEfiEntry < EfiMemoryMapEnd) {
if (EfiEntry->PhysicalStart > NextEfiEntry->PhysicalStart) {
@@ -1787,14 +1820,14 @@ LegacyBiosBuildE820 (
NextEfiEntry = NEXT_MEMORY_DESCRIPTOR (NextEfiEntry, EfiDescriptorSize);
}
- EfiEntry = NEXT_MEMORY_DESCRIPTOR (EfiEntry, EfiDescriptorSize);
- NextEfiEntry = NEXT_MEMORY_DESCRIPTOR (EfiEntry, EfiDescriptorSize);
+ EfiEntry = NEXT_MEMORY_DESCRIPTOR (EfiEntry, EfiDescriptorSize);
+ NextEfiEntry = NEXT_MEMORY_DESCRIPTOR (EfiEntry, EfiDescriptorSize);
}
EfiEntry = EfiMemoryMap;
- EfiMemoryMapEnd = (EFI_MEMORY_DESCRIPTOR *) ((UINT8 *) EfiMemoryMap + EfiMemoryMapSize);
+ EfiMemoryMapEnd = (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)EfiMemoryMap + EfiMemoryMapSize);
for (Index = Above1MIndex; (EfiEntry < EfiMemoryMapEnd) && (Index < EFI_MAX_E820_ENTRY - 1); ) {
- MemoryBlockLength = (UINT64) (LShiftU64 (EfiEntry->NumberOfPages, 12));
+ MemoryBlockLength = (UINT64)(LShiftU64 (EfiEntry->NumberOfPages, 12));
if ((EfiEntry->PhysicalStart + MemoryBlockLength) < 0x100000) {
//
// Skip the memory block if under 1MB
@@ -1804,7 +1837,7 @@ LegacyBiosBuildE820 (
//
// When the memory block spans below 1MB, ensure the memory block start address is at least 1MB
//
- MemoryBlockLength -= 0x100000 - EfiEntry->PhysicalStart;
+ MemoryBlockLength -= 0x100000 - EfiEntry->PhysicalStart;
EfiEntry->PhysicalStart = 0x100000;
}
@@ -1823,11 +1856,12 @@ LegacyBiosBuildE820 (
// Make a new entry
//
++Index;
- E820Table[Index].BaseAddr = EfiEntry->PhysicalStart;
- E820Table[Index].Length = MemoryBlockLength;
- E820Table[Index].Type = TempType;
+ E820Table[Index].BaseAddr = EfiEntry->PhysicalStart;
+ E820Table[Index].Length = MemoryBlockLength;
+ E820Table[Index].Type = TempType;
}
}
+
EfiEntry = NEXT_MEMORY_DESCRIPTOR (EfiEntry, EfiDescriptorSize);
}
@@ -1837,26 +1871,27 @@ LegacyBiosBuildE820 (
// Process the reserved memory map to produce E820 map ;
//
for (Hob.Raw = GetHobList (); !END_OF_HOB_LIST (Hob); Hob.Raw = GET_NEXT_HOB (Hob)) {
- if (Hob.Raw != NULL && GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {
+ if ((Hob.Raw != NULL) && (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR)) {
ResourceHob = Hob.ResourceDescriptor;
if (((ResourceHob->ResourceType == EFI_RESOURCE_MEMORY_MAPPED_IO) ||
- (ResourceHob->ResourceType == EFI_RESOURCE_FIRMWARE_DEVICE) ||
- (ResourceHob->ResourceType == EFI_RESOURCE_MEMORY_RESERVED) ) &&
+ (ResourceHob->ResourceType == EFI_RESOURCE_FIRMWARE_DEVICE) ||
+ (ResourceHob->ResourceType == EFI_RESOURCE_MEMORY_RESERVED)) &&
(ResourceHob->PhysicalStart > 0x100000) &&
- (Index < EFI_MAX_E820_ENTRY - 1)) {
+ (Index < EFI_MAX_E820_ENTRY - 1))
+ {
++Index;
- E820Table[Index].BaseAddr = ResourceHob->PhysicalStart;
- E820Table[Index].Length = ResourceHob->ResourceLength;
- E820Table[Index].Type = EfiAcpiAddressRangeReserved;
+ E820Table[Index].BaseAddr = ResourceHob->PhysicalStart;
+ E820Table[Index].Length = ResourceHob->ResourceLength;
+ E820Table[Index].Type = EfiAcpiAddressRangeReserved;
}
}
}
- Index ++;
+ Index++;
Private->IntThunk->EfiToLegacy16InitTable.NumberE820Entries = (UINT32)Index;
Private->IntThunk->EfiToLegacy16BootTable.NumberE820Entries = (UINT32)Index;
- Private->NumberE820Entries = (UINT32)Index;
- *Size = (UINTN) (Index * sizeof (EFI_E820_ENTRY64));
+ Private->NumberE820Entries = (UINT32)Index;
+ *Size = (UINTN)(Index * sizeof (EFI_E820_ENTRY64));
//
// Sort E820Table from low to high
@@ -1865,18 +1900,18 @@ LegacyBiosBuildE820 (
ChangedFlag = FALSE;
for (TempNextIndex = 1; TempNextIndex < Index - TempIndex; TempNextIndex++) {
if (E820Table[TempNextIndex - 1].BaseAddr > E820Table[TempNextIndex].BaseAddr) {
- ChangedFlag = TRUE;
- TempE820.BaseAddr = E820Table[TempNextIndex - 1].BaseAddr;
- TempE820.Length = E820Table[TempNextIndex - 1].Length;
- TempE820.Type = E820Table[TempNextIndex - 1].Type;
-
- E820Table[TempNextIndex - 1].BaseAddr = E820Table[TempNextIndex].BaseAddr;
- E820Table[TempNextIndex - 1].Length = E820Table[TempNextIndex].Length;
- E820Table[TempNextIndex - 1].Type = E820Table[TempNextIndex].Type;
-
- E820Table[TempNextIndex].BaseAddr = TempE820.BaseAddr;
- E820Table[TempNextIndex].Length = TempE820.Length;
- E820Table[TempNextIndex].Type = TempE820.Type;
+ ChangedFlag = TRUE;
+ TempE820.BaseAddr = E820Table[TempNextIndex - 1].BaseAddr;
+ TempE820.Length = E820Table[TempNextIndex - 1].Length;
+ TempE820.Type = E820Table[TempNextIndex - 1].Type;
+
+ E820Table[TempNextIndex - 1].BaseAddr = E820Table[TempNextIndex].BaseAddr;
+ E820Table[TempNextIndex - 1].Length = E820Table[TempNextIndex].Length;
+ E820Table[TempNextIndex - 1].Type = E820Table[TempNextIndex].Type;
+
+ E820Table[TempNextIndex].BaseAddr = TempE820.BaseAddr;
+ E820Table[TempNextIndex].Length = TempE820.Length;
+ E820Table[TempNextIndex].Type = TempE820.Type;
}
}
@@ -1889,49 +1924,50 @@ LegacyBiosBuildE820 (
// Remove the overlap range
//
for (TempIndex = 1; TempIndex < Index; TempIndex++) {
- if (E820Table[TempIndex - 1].BaseAddr <= E820Table[TempIndex].BaseAddr &&
+ if ((E820Table[TempIndex - 1].BaseAddr <= E820Table[TempIndex].BaseAddr) &&
((E820Table[TempIndex - 1].BaseAddr + E820Table[TempIndex - 1].Length) >=
- (E820Table[TempIndex].BaseAddr +E820Table[TempIndex].Length))) {
- //
- //Overlap range is found
- //
- ASSERT (E820Table[TempIndex - 1].Type == E820Table[TempIndex].Type);
-
- if (TempIndex == Index - 1) {
- E820Table[TempIndex].BaseAddr = 0;
- E820Table[TempIndex].Length = 0;
- E820Table[TempIndex].Type = (EFI_ACPI_MEMORY_TYPE) 0;
- Index--;
- break;
- } else {
- for (IndexSort = TempIndex; IndexSort < Index - 1; IndexSort ++) {
- E820Table[IndexSort].BaseAddr = E820Table[IndexSort + 1].BaseAddr;
- E820Table[IndexSort].Length = E820Table[IndexSort + 1].Length;
- E820Table[IndexSort].Type = E820Table[IndexSort + 1].Type;
- }
- Index--;
- }
- }
- }
+ (E820Table[TempIndex].BaseAddr +E820Table[TempIndex].Length)))
+ {
+ //
+ // Overlap range is found
+ //
+ ASSERT (E820Table[TempIndex - 1].Type == E820Table[TempIndex].Type);
+ if (TempIndex == Index - 1) {
+ E820Table[TempIndex].BaseAddr = 0;
+ E820Table[TempIndex].Length = 0;
+ E820Table[TempIndex].Type = (EFI_ACPI_MEMORY_TYPE)0;
+ Index--;
+ break;
+ } else {
+ for (IndexSort = TempIndex; IndexSort < Index - 1; IndexSort++) {
+ E820Table[IndexSort].BaseAddr = E820Table[IndexSort + 1].BaseAddr;
+ E820Table[IndexSort].Length = E820Table[IndexSort + 1].Length;
+ E820Table[IndexSort].Type = E820Table[IndexSort + 1].Type;
+ }
+ Index--;
+ }
+ }
+ }
Private->IntThunk->EfiToLegacy16InitTable.NumberE820Entries = (UINT32)Index;
Private->IntThunk->EfiToLegacy16BootTable.NumberE820Entries = (UINT32)Index;
- Private->NumberE820Entries = (UINT32)Index;
- *Size = (UINTN) (Index * sizeof (EFI_E820_ENTRY64));
+ Private->NumberE820Entries = (UINT32)Index;
+ *Size = (UINTN)(Index * sizeof (EFI_E820_ENTRY64));
//
// Determine OS usable memory above 1MB
//
Private->IntThunk->EfiToLegacy16BootTable.OsMemoryAbove1Mb = 0x0000;
for (TempIndex = Above1MIndex; TempIndex < Index; TempIndex++) {
- if (E820Table[TempIndex].BaseAddr >= 0x100000 && E820Table[TempIndex].BaseAddr < 0x100000000ULL) { // not include above 4G memory
+ if ((E820Table[TempIndex].BaseAddr >= 0x100000) && (E820Table[TempIndex].BaseAddr < 0x100000000ULL)) {
+ // not include above 4G memory
//
// ACPIReclaimMemory is also usable memory for ACPI OS, after OS dumps all ACPI tables.
//
if ((E820Table[TempIndex].Type == EfiAcpiAddressRangeMemory) || (E820Table[TempIndex].Type == EfiAcpiAddressRangeACPI)) {
- Private->IntThunk->EfiToLegacy16BootTable.OsMemoryAbove1Mb += (UINT32) (E820Table[TempIndex].Length);
+ Private->IntThunk->EfiToLegacy16BootTable.OsMemoryAbove1Mb += (UINT32)(E820Table[TempIndex].Length);
} else {
break; // break at first not normal memory, because SMM may use reserved memory.
}
@@ -1944,7 +1980,9 @@ LegacyBiosBuildE820 (
// Print DEBUG information
//
for (TempIndex = 0; TempIndex < Index; TempIndex++) {
- DEBUG((DEBUG_INFO, "E820[%2d]: 0x%016lx - 0x%016lx, Type = %d\n",
+ DEBUG ((
+ DEBUG_INFO,
+ "E820[%2d]: 0x%016lx - 0x%016lx, Type = %d\n",
TempIndex,
E820Table[TempIndex].BaseAddr,
(E820Table[TempIndex].BaseAddr + E820Table[TempIndex].Length),
@@ -1955,7 +1993,6 @@ LegacyBiosBuildE820 (
return EFI_SUCCESS;
}
-
/**
Fill in the standard BDA and EBDA stuff prior to legacy Boot
@@ -1966,21 +2003,21 @@ LegacyBiosBuildE820 (
**/
EFI_STATUS
LegacyBiosCompleteBdaBeforeBoot (
- IN LEGACY_BIOS_INSTANCE *Private
+ IN LEGACY_BIOS_INSTANCE *Private
)
{
- BDA_STRUC *Bda;
- UINT16 MachineConfig;
- DEVICE_PRODUCER_DATA_HEADER *SioPtr;
+ BDA_STRUC *Bda;
+ UINT16 MachineConfig;
+ DEVICE_PRODUCER_DATA_HEADER *SioPtr;
- Bda = (BDA_STRUC *) ((UINTN) 0x400);
+ Bda = (BDA_STRUC *)((UINTN)0x400);
MachineConfig = 0;
- SioPtr = &(Private->IntThunk->EfiToLegacy16BootTable.SioData);
- Bda->Com1 = SioPtr->Serial[0].Address;
- Bda->Com2 = SioPtr->Serial[1].Address;
- Bda->Com3 = SioPtr->Serial[2].Address;
- Bda->Com4 = SioPtr->Serial[3].Address;
+ SioPtr = &(Private->IntThunk->EfiToLegacy16BootTable.SioData);
+ Bda->Com1 = SioPtr->Serial[0].Address;
+ Bda->Com2 = SioPtr->Serial[1].Address;
+ Bda->Com3 = SioPtr->Serial[2].Address;
+ Bda->Com4 = SioPtr->Serial[3].Address;
if (SioPtr->Serial[0].Address != 0x00) {
MachineConfig += 0x200;
@@ -2014,22 +2051,22 @@ LegacyBiosCompleteBdaBeforeBoot (
MachineConfig += 0x4000;
}
- Bda->NumberOfDrives = (UINT8) (Bda->NumberOfDrives + Private->IdeDriveCount);
+ Bda->NumberOfDrives = (UINT8)(Bda->NumberOfDrives + Private->IdeDriveCount);
if (SioPtr->Floppy.NumberOfFloppy != 0x00) {
- MachineConfig = (UINT16) (MachineConfig + 0x01 + (SioPtr->Floppy.NumberOfFloppy - 1) * 0x40);
- Bda->FloppyXRate = 0x07;
+ MachineConfig = (UINT16)(MachineConfig + 0x01 + (SioPtr->Floppy.NumberOfFloppy - 1) * 0x40);
+ Bda->FloppyXRate = 0x07;
}
- Bda->Lpt1_2Timeout = 0x1414;
- Bda->Lpt3_4Timeout = 0x1414;
- Bda->Com1_2Timeout = 0x0101;
- Bda->Com3_4Timeout = 0x0101;
+ Bda->Lpt1_2Timeout = 0x1414;
+ Bda->Lpt3_4Timeout = 0x1414;
+ Bda->Com1_2Timeout = 0x0101;
+ Bda->Com3_4Timeout = 0x0101;
//
// Force VGA and Coprocessor, indicate 101/102 keyboard
//
- MachineConfig = (UINT16) (MachineConfig + 0x00 + 0x02 + (SioPtr->MousePresent * 0x04));
- Bda->MachineConfig = MachineConfig;
+ MachineConfig = (UINT16)(MachineConfig + 0x00 + 0x02 + (SioPtr->MousePresent * 0x04));
+ Bda->MachineConfig = MachineConfig;
return EFI_SUCCESS;
}
@@ -2046,26 +2083,26 @@ LegacyBiosCompleteBdaBeforeBoot (
EFI_STATUS
EFIAPI
LegacyBiosUpdateKeyboardLedStatus (
- IN EFI_LEGACY_BIOS_PROTOCOL *This,
- IN UINT8 Leds
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,
+ IN UINT8 Leds
)
{
- LEGACY_BIOS_INSTANCE *Private;
- BDA_STRUC *Bda;
- UINT8 LocalLeds;
- EFI_IA32_REGISTER_SET Regs;
+ LEGACY_BIOS_INSTANCE *Private;
+ BDA_STRUC *Bda;
+ UINT8 LocalLeds;
+ EFI_IA32_REGISTER_SET Regs;
- Private = LEGACY_BIOS_INSTANCE_FROM_THIS (This);
+ Private = LEGACY_BIOS_INSTANCE_FROM_THIS (This);
ACCESS_PAGE0_CODE (
- Bda = (BDA_STRUC *) ((UINTN) 0x400);
+ 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);
- );
+ 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
@@ -2075,18 +2112,17 @@ LegacyBiosUpdateKeyboardLedStatus (
Regs.H.CL = Leds;
Private->LegacyBios.FarCall86 (
- &Private->LegacyBios,
- Private->Legacy16Table->Compatibility16CallSegment,
- Private->Legacy16Table->Compatibility16CallOffset,
- &Regs,
- NULL,
- 0
- );
+ &Private->LegacyBios,
+ Private->Legacy16Table->Compatibility16CallSegment,
+ Private->Legacy16Table->Compatibility16CallOffset,
+ &Regs,
+ NULL,
+ 0
+ );
return EFI_SUCCESS;
}
-
/**
Fill in the standard CMOS stuff prior to legacy Boot
@@ -2097,7 +2133,7 @@ LegacyBiosUpdateKeyboardLedStatus (
**/
EFI_STATUS
LegacyBiosCompleteStandardCmosBeforeBoot (
- IN LEGACY_BIOS_INSTANCE *Private
+ IN LEGACY_BIOS_INSTANCE *Private
)
{
UINT8 Bda;
@@ -2113,7 +2149,7 @@ LegacyBiosCompleteStandardCmosBeforeBoot (
//
ACCESS_PAGE0_CODE (
Bda = (UINT8)(*((UINT8 *)((UINTN)0x410)) | BIT3);
- );
+ );
//
// Force display enabled
@@ -2143,7 +2179,7 @@ LegacyBiosCompleteStandardCmosBeforeBoot (
//
Size = (15 * SIZE_1MB) >> 10;
if (Private->IntThunk->EfiToLegacy16InitTable.OsMemoryAbove1Mb < (15 * SIZE_1MB)) {
- Size = Private->IntThunk->EfiToLegacy16InitTable.OsMemoryAbove1Mb >> 10;
+ Size = Private->IntThunk->EfiToLegacy16InitTable.OsMemoryAbove1Mb >> 10;
}
LegacyWriteStandardCmos (CMOS_17, (UINT8)(Size & 0xFF));
@@ -2168,8 +2204,8 @@ LegacyBiosCompleteStandardCmosBeforeBoot (
**/
EFI_STATUS
RelocateImageUnder4GIfNeeded (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
return EFI_SUCCESS;
diff --git a/OvmfPkg/Csm/LegacyBiosDxe/LegacyCmos.c b/OvmfPkg/Csm/LegacyBiosDxe/LegacyCmos.c
index de25e06184..7220d8e65a 100644
--- a/OvmfPkg/Csm/LegacyBiosDxe/LegacyCmos.c
+++ b/OvmfPkg/Csm/LegacyBiosDxe/LegacyCmos.c
@@ -66,12 +66,12 @@ LegacyCalculateWriteStandardCmosChecksum (
for (Checksum = 0, Register = 0x10; Register < 0x2e; Register++) {
Checksum = (UINT16)(Checksum + LegacyReadStandardCmos (Register));
}
+
LegacyWriteStandardCmos (CMOS_2E, (UINT8)(Checksum >> 8));
LegacyWriteStandardCmos (CMOS_2F, (UINT8)(Checksum & 0xff));
return EFI_SUCCESS;
}
-
/**
Fill in the standard CMOS stuff before Legacy16 load
@@ -82,7 +82,7 @@ LegacyCalculateWriteStandardCmosChecksum (
**/
EFI_STATUS
LegacyBiosInitCmos (
- IN LEGACY_BIOS_INSTANCE *Private
+ IN LEGACY_BIOS_INSTANCE *Private
)
{
UINT32 Size;
@@ -103,7 +103,7 @@ LegacyBiosInitCmos (
Size = 15 * SIZE_1MB;
if (Private->IntThunk->EfiToLegacy16InitTable.OsMemoryAbove1Mb < (15 * SIZE_1MB)) {
- Size = Private->IntThunk->EfiToLegacy16InitTable.OsMemoryAbove1Mb >> 10;
+ Size = Private->IntThunk->EfiToLegacy16InitTable.OsMemoryAbove1Mb >> 10;
}
LegacyWriteStandardCmos (CMOS_17, (UINT8)(Size & 0xFF));
diff --git a/OvmfPkg/Csm/LegacyBiosDxe/LegacyIde.c b/OvmfPkg/Csm/LegacyBiosDxe/LegacyIde.c
index 789f48370e..323f76c970 100644
--- a/OvmfPkg/Csm/LegacyBiosDxe/LegacyIde.c
+++ b/OvmfPkg/Csm/LegacyBiosDxe/LegacyIde.c
@@ -9,7 +9,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "LegacyBiosInterface.h"
-BOOLEAN mIdeDataBuiltFlag = FALSE;
+BOOLEAN mIdeDataBuiltFlag = FALSE;
/**
Collect IDE Inquiry data from the IDE disks
@@ -23,9 +23,9 @@ BOOLEAN mIdeDataBuiltFlag = FALSE;
**/
EFI_STATUS
LegacyBiosBuildIdeData (
- IN LEGACY_BIOS_INSTANCE *Private,
- IN HDD_INFO **HddInfo,
- IN UINT16 Flag
+ IN LEGACY_BIOS_INSTANCE *Private,
+ IN HDD_INFO **HddInfo,
+ IN UINT16 Flag
)
{
EFI_STATUS Status;
@@ -60,14 +60,14 @@ LegacyBiosBuildIdeData (
//
PciDevicePath = NULL;
LocalHddInfo = *HddInfo;
- Status = Private->LegacyBiosPlatform->GetPlatformHandle (
- Private->LegacyBiosPlatform,
- EfiGetPlatformIdeHandle,
- 0,
- &HandleBuffer,
- &HandleCount,
- (VOID *) &LocalHddInfo
- );
+ Status = Private->LegacyBiosPlatform->GetPlatformHandle (
+ Private->LegacyBiosPlatform,
+ EfiGetPlatformIdeHandle,
+ 0,
+ &HandleBuffer,
+ &HandleCount,
+ (VOID *)&LocalHddInfo
+ );
if (!EFI_ERROR (Status)) {
IdeController = HandleBuffer[0];
//
@@ -75,10 +75,10 @@ LegacyBiosBuildIdeData (
//
if (Flag != 0) {
gBS->DisconnectController (
- IdeController,
- NULL,
- NULL
- );
+ IdeController,
+ NULL,
+ NULL
+ );
}
gBS->ConnectController (IdeController, NULL, NULL, FALSE);
@@ -88,13 +88,13 @@ LegacyBiosBuildIdeData (
// And GetIdeHandle will switch to Legacy mode, if required.
//
Private->LegacyBiosPlatform->GetPlatformHandle (
- Private->LegacyBiosPlatform,
- EfiGetPlatformIdeHandle,
- 0,
- &HandleBuffer,
- &HandleCount,
- (VOID *) &LocalHddInfo
- );
+ Private->LegacyBiosPlatform,
+ EfiGetPlatformIdeHandle,
+ 0,
+ &HandleBuffer,
+ &HandleCount,
+ (VOID *)&LocalHddInfo
+ );
}
mIdeDataBuiltFlag = TRUE;
@@ -103,19 +103,19 @@ LegacyBiosBuildIdeData (
// Get Identity command from all drives
//
gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiDiskInfoProtocolGuid,
- NULL,
- &HandleCount,
- &HandleBuffer
- );
-
- Private->IdeDriveCount = (UINT8) HandleCount;
+ ByProtocol,
+ &gEfiDiskInfoProtocolGuid,
+ NULL,
+ &HandleCount,
+ &HandleBuffer
+ );
+
+ Private->IdeDriveCount = (UINT8)HandleCount;
for (Index = 0; Index < HandleCount; Index++) {
Status = gBS->HandleProtocol (
HandleBuffer[Index],
&gEfiDiskInfoProtocolGuid,
- (VOID **) &DiskInfo
+ (VOID **)&DiskInfo
);
ASSERT_EFI_ERROR (Status);
@@ -126,7 +126,7 @@ LegacyBiosBuildIdeData (
Status = gBS->HandleProtocol (
HandleBuffer[Index],
&gEfiDevicePathProtocolGuid,
- (VOID *) &DevicePath
+ (VOID *)&DevicePath
);
ASSERT_EFI_ERROR (Status);
@@ -134,12 +134,14 @@ LegacyBiosBuildIdeData (
while (!IsDevicePathEnd (DevicePathNode)) {
TempDevicePathNode = NextDevicePathNode (DevicePathNode);
if ((DevicePathType (DevicePathNode) == HARDWARE_DEVICE_PATH) &&
- ( DevicePathSubType (DevicePathNode) == HW_PCI_DP) &&
- ( DevicePathType(TempDevicePathNode) == MESSAGING_DEVICE_PATH) &&
- ( DevicePathSubType(TempDevicePathNode) == MSG_ATAPI_DP) ) {
- PciDevicePath = (PCI_DEVICE_PATH *) DevicePathNode;
+ (DevicePathSubType (DevicePathNode) == HW_PCI_DP) &&
+ (DevicePathType (TempDevicePathNode) == MESSAGING_DEVICE_PATH) &&
+ (DevicePathSubType (TempDevicePathNode) == MSG_ATAPI_DP))
+ {
+ PciDevicePath = (PCI_DEVICE_PATH *)DevicePathNode;
break;
}
+
DevicePathNode = NextDevicePathNode (DevicePathNode);
}
@@ -161,7 +163,8 @@ LegacyBiosBuildIdeData (
for (PciIndex = 0; PciIndex < 8; PciIndex++) {
if ((PciDevicePath->Device == LocalHddInfo[PciIndex].Device) &&
(PciDevicePath->Function == LocalHddInfo[PciIndex].Function)
- ) {
+ )
+ {
break;
}
}
@@ -186,15 +189,15 @@ LegacyBiosBuildIdeData (
InquiryData = NULL;
InquiryDataSize = 0;
- Status = DiskInfo->Inquiry (
- DiskInfo,
- NULL,
- &InquiryDataSize
- );
+ Status = DiskInfo->Inquiry (
+ DiskInfo,
+ NULL,
+ &InquiryDataSize
+ );
if (Status == EFI_BUFFER_TOO_SMALL) {
- InquiryData = (UINT8 *) AllocatePool (
- InquiryDataSize
- );
+ InquiryData = (UINT8 *)AllocatePool (
+ InquiryDataSize
+ );
if (InquiryData != NULL) {
Status = DiskInfo->Inquiry (
DiskInfo,
@@ -227,6 +230,7 @@ LegacyBiosBuildIdeData (
LocalHddInfo[PciIndex + IdeChannel].Status |= HDD_SLAVE_ATAPI_ZIPDISK;
}
}
+
FreePool (InquiryData);
} else {
if (IdeDevice == 0) {
@@ -246,7 +250,6 @@ LegacyBiosBuildIdeData (
return EFI_SUCCESS;
}
-
/**
If the IDE channel is in compatibility (legacy) mode, remove all
PCI I/O BAR addresses from the controller.
@@ -257,13 +260,13 @@ LegacyBiosBuildIdeData (
**/
VOID
InitLegacyIdeController (
- IN EFI_HANDLE IdeController
+ IN EFI_HANDLE IdeController
)
{
- EFI_PCI_IO_PROTOCOL *PciIo;
- UINT32 IOBarClear;
- EFI_STATUS Status;
- PCI_TYPE00 PciData;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ UINT32 IOBarClear;
+ EFI_STATUS Status;
+ PCI_TYPE00 PciData;
//
// If the IDE channel is in compatibility (legacy) mode, remove all
@@ -277,20 +280,21 @@ InitLegacyIdeController (
(VOID **)&PciIo
);
if (EFI_ERROR (Status)) {
- return ;
+ return;
}
Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0, sizeof (PciData), &PciData);
if (EFI_ERROR (Status)) {
- return ;
+ return;
}
//
// Check whether this is IDE
//
if ((PciData.Hdr.ClassCode[2] != PCI_CLASS_MASS_STORAGE) ||
- (PciData.Hdr.ClassCode[1] != PCI_CLASS_MASS_STORAGE_IDE)) {
- return ;
+ (PciData.Hdr.ClassCode[1] != PCI_CLASS_MASS_STORAGE_IDE))
+ {
+ return;
}
//
@@ -301,10 +305,11 @@ InitLegacyIdeController (
PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x10, 1, &IOBarClear);
PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x14, 1, &IOBarClear);
}
+
if ((PciData.Hdr.ClassCode[0] & IDE_PI_REGISTER_SNE) == 0) {
PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x18, 1, &IOBarClear);
PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x1C, 1, &IOBarClear);
}
- return ;
+ return;
}
diff --git a/OvmfPkg/Csm/LegacyBiosDxe/LegacyPci.c b/OvmfPkg/Csm/LegacyBiosDxe/LegacyPci.c
index ea0df4972b..07ee5ab099 100644
--- a/OvmfPkg/Csm/LegacyBiosDxe/LegacyPci.c
+++ b/OvmfPkg/Csm/LegacyBiosDxe/LegacyPci.c
@@ -9,32 +9,32 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "LegacyBiosInterface.h"
#include <IndustryStandard/Pci30.h>
-#define PCI_START_ADDRESS(x) (((x) + 0x7ff) & ~0x7ff)
+#define PCI_START_ADDRESS(x) (((x) + 0x7ff) & ~0x7ff)
#define MAX_BRIDGE_INDEX 0x20
typedef struct {
- UINTN PciSegment;
- UINTN PciBus;
- UINTN PciDevice;
- UINTN PciFunction;
- UINT8 PrimaryBus;
- UINT8 SecondaryBus;
- UINT8 SubordinateBus;
+ UINTN PciSegment;
+ UINTN PciBus;
+ UINTN PciDevice;
+ UINTN PciFunction;
+ UINT8 PrimaryBus;
+ UINT8 SecondaryBus;
+ UINT8 SubordinateBus;
} BRIDGE_TABLE;
-#define ROM_MAX_ENTRIES 24
-BRIDGE_TABLE Bridges[MAX_BRIDGE_INDEX];
-UINTN SortedBridgeIndex[MAX_BRIDGE_INDEX];
-UINTN NumberOfBridges;
+#define ROM_MAX_ENTRIES 24
+BRIDGE_TABLE Bridges[MAX_BRIDGE_INDEX];
+UINTN SortedBridgeIndex[MAX_BRIDGE_INDEX];
+UINTN NumberOfBridges;
LEGACY_PNP_EXPANSION_HEADER *mBasePnpPtr;
-UINT16 mBbsRomSegment;
-UINTN mHandleCount;
-EFI_HANDLE mVgaHandle;
-BOOLEAN mIgnoreBbsUpdateFlag;
-BOOLEAN mVgaInstallationInProgress = FALSE;
-UINT32 mRomCount = 0x00;
-ROM_INSTANCE_ENTRY mRomEntry[ROM_MAX_ENTRIES];
-EDKII_IOMMU_PROTOCOL *mIoMmu;
+UINT16 mBbsRomSegment;
+UINTN mHandleCount;
+EFI_HANDLE mVgaHandle;
+BOOLEAN mIgnoreBbsUpdateFlag;
+BOOLEAN mVgaInstallationInProgress = FALSE;
+UINT32 mRomCount = 0x00;
+ROM_INSTANCE_ENTRY mRomEntry[ROM_MAX_ENTRIES];
+EDKII_IOMMU_PROTOCOL *mIoMmu;
/**
Query shadowed legacy ROM parameters registered by RomShadow() previously.
@@ -51,20 +51,20 @@ EDKII_IOMMU_PROTOCOL *mIoMmu;
**/
EFI_STATUS
GetShadowedRomParameters (
- IN EFI_HANDLE PciHandle,
- OUT UINT8 *DiskStart OPTIONAL,
- OUT UINT8 *DiskEnd OPTIONAL,
- OUT VOID **RomShadowAddress OPTIONAL,
- OUT UINTN *ShadowedSize OPTIONAL
+ IN EFI_HANDLE PciHandle,
+ OUT UINT8 *DiskStart OPTIONAL,
+ OUT UINT8 *DiskEnd OPTIONAL,
+ OUT VOID **RomShadowAddress OPTIONAL,
+ OUT UINTN *ShadowedSize OPTIONAL
)
{
- EFI_STATUS Status;
- EFI_PCI_IO_PROTOCOL *PciIo;
- UINTN Index;
- UINTN PciSegment;
- UINTN PciBus;
- UINTN PciDevice;
- UINTN PciFunction;
+ EFI_STATUS Status;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ UINTN Index;
+ UINTN PciSegment;
+ UINTN PciBus;
+ UINTN PciDevice;
+ UINTN PciFunction;
//
// Get the PCI I/O Protocol on PciHandle
@@ -72,7 +72,7 @@ GetShadowedRomParameters (
Status = gBS->HandleProtocol (
PciHandle,
&gEfiPciIoProtocolGuid,
- (VOID **) &PciIo
+ (VOID **)&PciIo
);
if (EFI_ERROR (Status)) {
return Status;
@@ -89,11 +89,12 @@ GetShadowedRomParameters (
&PciFunction
);
- for(Index = 0; Index < mRomCount; Index++) {
+ for (Index = 0; Index < mRomCount; Index++) {
if ((mRomEntry[Index].PciSegment == PciSegment) &&
(mRomEntry[Index].PciBus == PciBus) &&
(mRomEntry[Index].PciDevice == PciDevice) &&
- (mRomEntry[Index].PciFunction == PciFunction)) {
+ (mRomEntry[Index].PciFunction == PciFunction))
+ {
break;
}
}
@@ -141,15 +142,15 @@ GetShadowedRomParameters (
**/
EFI_STATUS
RomShadow (
- IN EFI_HANDLE PciHandle,
- IN UINT32 ShadowAddress,
- IN UINT32 ShadowedSize,
- IN UINT8 DiskStart,
- IN UINT8 DiskEnd
+ IN EFI_HANDLE PciHandle,
+ IN UINT32 ShadowAddress,
+ IN UINT32 ShadowedSize,
+ IN UINT8 DiskStart,
+ IN UINT8 DiskEnd
)
{
- EFI_STATUS Status;
- EFI_PCI_IO_PROTOCOL *PciIo;
+ EFI_STATUS Status;
+ EFI_PCI_IO_PROTOCOL *PciIo;
//
// See if there is room to register another option ROM
@@ -157,17 +158,19 @@ RomShadow (
if (mRomCount >= ROM_MAX_ENTRIES) {
return EFI_OUT_OF_RESOURCES;
}
+
//
// Get the PCI I/O Protocol on PciHandle
//
Status = gBS->HandleProtocol (
PciHandle,
&gEfiPciIoProtocolGuid,
- (VOID **) &PciIo
+ (VOID **)&PciIo
);
if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Get the location of the PCI device
//
@@ -188,7 +191,6 @@ RomShadow (
return EFI_SUCCESS;
}
-
/**
Return EFI_SUCCESS if PciHandle has had a legacy BIOS ROM shadowed. This
information represents every call to RomShadow ()
@@ -201,16 +203,16 @@ RomShadow (
**/
EFI_STATUS
IsLegacyRom (
- IN EFI_HANDLE PciHandle
+ IN EFI_HANDLE PciHandle
)
{
- EFI_STATUS Status;
- EFI_PCI_IO_PROTOCOL *PciIo;
- UINTN Index;
- UINTN Segment;
- UINTN Bus;
- UINTN Device;
- UINTN Function;
+ EFI_STATUS Status;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ UINTN Index;
+ UINTN Segment;
+ UINTN Bus;
+ UINTN Device;
+ UINTN Function;
//
// Get the PCI I/O Protocol on PciHandle
@@ -218,11 +220,12 @@ IsLegacyRom (
Status = gBS->HandleProtocol (
PciHandle,
&gEfiPciIoProtocolGuid,
- (VOID **) &PciIo
+ (VOID **)&PciIo
);
if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Get the location of the PCI device
//
@@ -238,11 +241,12 @@ IsLegacyRom (
// See if the option ROM from PciHandle has been previously posted
//
for (Index = 0; Index < mRomCount; Index++) {
- if (mRomEntry[Index].PciSegment == Segment &&
- mRomEntry[Index].PciBus == Bus &&
- mRomEntry[Index].PciDevice == Device &&
- mRomEntry[Index].PciFunction == Function
- ) {
+ if ((mRomEntry[Index].PciSegment == Segment) &&
+ (mRomEntry[Index].PciBus == Bus) &&
+ (mRomEntry[Index].PciDevice == Device) &&
+ (mRomEntry[Index].PciFunction == Function)
+ )
+ {
return EFI_SUCCESS;
}
}
@@ -271,14 +275,14 @@ IsLegacyRom (
**/
EFI_STATUS
GetPciLegacyRom (
- IN UINT16 Csm16Revision,
- IN UINT16 VendorId,
- IN UINT16 DeviceId,
- IN OUT VOID **Rom,
- IN OUT UINTN *ImageSize,
- OUT UINTN *MaxRuntimeImageLength OPTIONAL,
- OUT UINT8 *OpRomRevision OPTIONAL,
- OUT VOID **ConfigUtilityCodeHeader OPTIONAL
+ IN UINT16 Csm16Revision,
+ IN UINT16 VendorId,
+ IN UINT16 DeviceId,
+ IN OUT VOID **Rom,
+ IN OUT UINTN *ImageSize,
+ OUT UINTN *MaxRuntimeImageLength OPTIONAL,
+ OUT UINT8 *OpRomRevision OPTIONAL,
+ OUT VOID **ConfigUtilityCodeHeader OPTIONAL
)
{
BOOLEAN Match;
@@ -288,7 +292,6 @@ GetPciLegacyRom (
VOID *BackupImage;
VOID *BestImage;
-
if (*ImageSize < sizeof (EFI_PCI_ROM_HEADER)) {
return EFI_NOT_FOUND;
}
@@ -297,13 +300,14 @@ GetPciLegacyRom (
BackupImage = NULL;
RomHeader.Raw = *Rom;
while (RomHeader.Generic->Signature == PCI_EXPANSION_ROM_HEADER_SIGNATURE) {
- if (RomHeader.Generic->PcirOffset == 0 ||
- (RomHeader.Generic->PcirOffset & 3) !=0 ||
- *ImageSize < RomHeader.Raw - (UINT8 *) *Rom + RomHeader.Generic->PcirOffset + sizeof (PCI_DATA_STRUCTURE)) {
+ if ((RomHeader.Generic->PcirOffset == 0) ||
+ ((RomHeader.Generic->PcirOffset & 3) != 0) ||
+ (*ImageSize < RomHeader.Raw - (UINT8 *)*Rom + RomHeader.Generic->PcirOffset + sizeof (PCI_DATA_STRUCTURE)))
+ {
break;
}
- Pcir = (PCI_3_0_DATA_STRUCTURE *) (RomHeader.Raw + RomHeader.Generic->PcirOffset);
+ Pcir = (PCI_3_0_DATA_STRUCTURE *)(RomHeader.Raw + RomHeader.Generic->PcirOffset);
//
// Check signature in the PCI Data Structure.
//
@@ -321,7 +325,7 @@ GetPciLegacyRom (
if (Pcir->DeviceId == DeviceId) {
Match = TRUE;
} else if ((Pcir->Revision >= 3) && (Pcir->DeviceListOffset != 0)) {
- DeviceIdList = (UINT16 *)(((UINT8 *) Pcir) + Pcir->DeviceListOffset);
+ DeviceIdList = (UINT16 *)(((UINT8 *)Pcir) + Pcir->DeviceListOffset);
//
// Checking the device list
//
@@ -330,7 +334,8 @@ GetPciLegacyRom (
Match = TRUE;
break;
}
- DeviceIdList ++;
+
+ DeviceIdList++;
}
}
}
@@ -345,7 +350,7 @@ GetPciLegacyRom (
// case 1.1: meets OpRom 3.0
// Perfect!!!
//
- BestImage = RomHeader.Raw;
+ BestImage = RomHeader.Raw;
break;
} else {
//
@@ -369,7 +374,7 @@ GetPciLegacyRom (
// case 2.2: meets OpRom 2.x
// Perfect!!!
//
- BestImage = RomHeader.Raw;
+ BestImage = RomHeader.Raw;
break;
}
}
@@ -389,15 +394,17 @@ GetPciLegacyRom (
if (BackupImage == NULL) {
return EFI_NOT_FOUND;
}
+
//
// The versions of CSM16 and OpRom don't match exactly
//
BestImage = BackupImage;
}
+
RomHeader.Raw = BestImage;
- Pcir = (PCI_3_0_DATA_STRUCTURE *) (RomHeader.Raw + RomHeader.Generic->PcirOffset);
- *Rom = BestImage;
- *ImageSize = Pcir->ImageLength * 512;
+ Pcir = (PCI_3_0_DATA_STRUCTURE *)(RomHeader.Raw + RomHeader.Generic->PcirOffset);
+ *Rom = BestImage;
+ *ImageSize = Pcir->ImageLength * 512;
if (MaxRuntimeImageLength != NULL) {
if (Pcir->Revision < 3) {
@@ -444,22 +451,22 @@ GetPciLegacyRom (
**/
EFI_STATUS
CreateBridgeTable (
- IN EFI_LEGACY_IRQ_ROUTING_ENTRY *RoutingTable,
- IN UINTN RoutingTableEntries
+ IN EFI_LEGACY_IRQ_ROUTING_ENTRY *RoutingTable,
+ IN UINTN RoutingTableEntries
)
{
- EFI_STATUS Status;
- UINTN HandleCount;
- EFI_HANDLE *HandleBuffer;
- UINTN BridgeIndex;
- UINTN Index;
- UINTN Index1;
- EFI_PCI_IO_PROTOCOL *PciIo;
- PCI_TYPE01 PciConfigHeader;
- BRIDGE_TABLE SlotBridges[MAX_BRIDGE_INDEX];
- UINTN SlotBridgeIndex;
-
- BridgeIndex = 0x00;
+ EFI_STATUS Status;
+ UINTN HandleCount;
+ EFI_HANDLE *HandleBuffer;
+ UINTN BridgeIndex;
+ UINTN Index;
+ UINTN Index1;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ PCI_TYPE01 PciConfigHeader;
+ BRIDGE_TABLE SlotBridges[MAX_BRIDGE_INDEX];
+ UINTN SlotBridgeIndex;
+
+ BridgeIndex = 0x00;
SlotBridgeIndex = 0x00;
//
@@ -475,11 +482,12 @@ CreateBridgeTable (
if (EFI_ERROR (Status)) {
return EFI_NOT_FOUND;
}
+
for (Index = 0; Index < HandleCount; Index++) {
Status = gBS->HandleProtocol (
HandleBuffer[Index],
&gEfiPciIoProtocolGuid,
- (VOID **) &PciIo
+ (VOID **)&PciIo
);
if (EFI_ERROR (Status)) {
continue;
@@ -502,19 +510,20 @@ CreateBridgeTable (
&Bridges[BridgeIndex].PciFunction
);
- Bridges[BridgeIndex].PrimaryBus = PciConfigHeader.Bridge.PrimaryBus;
+ Bridges[BridgeIndex].PrimaryBus = PciConfigHeader.Bridge.PrimaryBus;
- Bridges[BridgeIndex].SecondaryBus = PciConfigHeader.Bridge.SecondaryBus;
+ Bridges[BridgeIndex].SecondaryBus = PciConfigHeader.Bridge.SecondaryBus;
Bridges[BridgeIndex].SubordinateBus = PciConfigHeader.Bridge.SubordinateBus;
- for (Index1 = 0; Index1 < RoutingTableEntries; Index1++){
+ for (Index1 = 0; Index1 < RoutingTableEntries; Index1++) {
//
// Test whether we have found the Bridge in the slot, must be the one that directly interfaced to the board
// Once we find one, store it in the SlotBridges[]
//
- if ((RoutingTable[Index1].Slot != 0) && (Bridges[BridgeIndex].PrimaryBus == RoutingTable[Index1].Bus)
- && ((Bridges[BridgeIndex].PciDevice << 3) == RoutingTable[Index1].Device)) {
+ if ( (RoutingTable[Index1].Slot != 0) && (Bridges[BridgeIndex].PrimaryBus == RoutingTable[Index1].Bus)
+ && ((Bridges[BridgeIndex].PciDevice << 3) == RoutingTable[Index1].Device))
+ {
CopyMem (&SlotBridges[SlotBridgeIndex], &Bridges[BridgeIndex], sizeof (BRIDGE_TABLE));
SlotBridgeIndex++;
@@ -529,10 +538,11 @@ CreateBridgeTable (
//
// Pack up Bridges by removing those useless ones
//
- for (Index = 0; Index < BridgeIndex;){
+ for (Index = 0; Index < BridgeIndex;) {
for (Index1 = 0; Index1 < SlotBridgeIndex; Index1++) {
if (((Bridges[Index].PciBus == SlotBridges[Index1].PrimaryBus) && (Bridges[Index].PciDevice == SlotBridges[Index1].PciDevice)) ||
- ((Bridges[Index].PciBus >= SlotBridges[Index1].SecondaryBus) && (Bridges[Index].PciBus <= SlotBridges[Index1].SubordinateBus))) {
+ ((Bridges[Index].PciBus >= SlotBridges[Index1].SecondaryBus) && (Bridges[Index].PciBus <= SlotBridges[Index1].SubordinateBus)))
+ {
//
// We have found one that meets our criteria
//
@@ -545,7 +555,7 @@ CreateBridgeTable (
// This one doesn't meet criteria, pack it
//
if (Index1 >= SlotBridgeIndex) {
- for (Index1 = Index; BridgeIndex > 1 && Index1 < BridgeIndex - 1 ; Index1++) {
+ for (Index1 = Index; BridgeIndex > 1 && Index1 < BridgeIndex - 1; Index1++) {
CopyMem (&Bridges[Index1], &Bridges[Index1 + 1], sizeof (BRIDGE_TABLE));
}
@@ -574,18 +584,19 @@ CreateBridgeTable (
if ((Bridges[Index].SecondaryBus == Bridges[Index1].SecondaryBus) &&
(Bridges[Index].SubordinateBus > Bridges[Index1].SubordinateBus)
- ) {
+ )
+ {
SortedBridgeIndex[Index] = Index1;
SortedBridgeIndex[Index1] = Index;
}
}
}
}
+
FreePool (HandleBuffer);
return EFI_SUCCESS;
}
-
/**
Find base Bridge for device.
@@ -601,14 +612,15 @@ CreateBridgeTable (
**/
EFI_STATUS
GetBaseBus (
- IN LEGACY_BIOS_INSTANCE *Private,
- IN UINTN PciBus,
- IN UINTN PciDevice,
- IN EFI_LEGACY_IRQ_ROUTING_ENTRY *RoutingTable,
- IN UINTN RoutingTableEntries
+ IN LEGACY_BIOS_INSTANCE *Private,
+ IN UINTN PciBus,
+ IN UINTN PciDevice,
+ IN EFI_LEGACY_IRQ_ROUTING_ENTRY *RoutingTable,
+ IN UINTN RoutingTableEntries
)
{
- UINTN Index;
+ UINTN Index;
+
for (Index = 0; Index < RoutingTableEntries; Index++) {
if ((RoutingTable[Index].Bus == PciBus) && (RoutingTable[Index].Device == (PciDevice << 3))) {
return EFI_SUCCESS;
@@ -635,11 +647,11 @@ GetBaseBus (
**/
EFI_STATUS
TranslateBusPirq (
- IN LEGACY_BIOS_INSTANCE *Private,
- IN OUT UINTN *PciBus,
- IN OUT UINTN *PciDevice,
- IN OUT UINTN *PciFunction,
- IN OUT UINT8 *PirqIndex
+ IN LEGACY_BIOS_INSTANCE *Private,
+ IN OUT UINTN *PciBus,
+ IN OUT UINTN *PciDevice,
+ IN OUT UINTN *PciFunction,
+ IN OUT UINT8 *PirqIndex
)
{
/*
@@ -689,24 +701,25 @@ No other busses match criteria. Device to be programmed is Bus 5, Device 1.
Rotate (B,C,D,A) by 1 giving C,D,A,B. Translated PIRQ is C.
*/
- UINTN LocalBus;
- UINTN LocalDevice;
- UINTN BaseBus;
- UINTN BaseDevice;
- UINTN BaseFunction;
- UINT8 LocalPirqIndex;
- BOOLEAN BaseIndexFlag;
- UINTN BridgeIndex;
- UINTN SBridgeIndex;
- BaseIndexFlag = FALSE;
- BridgeIndex = 0x00;
-
- LocalPirqIndex = *PirqIndex;
- LocalBus = *PciBus;
- LocalDevice = *PciDevice;
- BaseBus = *PciBus;
- BaseDevice = *PciDevice;
- BaseFunction = *PciFunction;
+ UINTN LocalBus;
+ UINTN LocalDevice;
+ UINTN BaseBus;
+ UINTN BaseDevice;
+ UINTN BaseFunction;
+ UINT8 LocalPirqIndex;
+ BOOLEAN BaseIndexFlag;
+ UINTN BridgeIndex;
+ UINTN SBridgeIndex;
+
+ BaseIndexFlag = FALSE;
+ BridgeIndex = 0x00;
+
+ LocalPirqIndex = *PirqIndex;
+ LocalBus = *PciBus;
+ LocalDevice = *PciDevice;
+ BaseBus = *PciBus;
+ BaseDevice = *PciDevice;
+ BaseFunction = *PciFunction;
//
// LocalPirqIndex list PIRQs in rotated fashion
@@ -732,17 +745,17 @@ Rotate (B,C,D,A) by 1 giving C,D,A,B. Translated PIRQ is C.
BaseFunction = Bridges[SBridgeIndex].PciFunction;
BaseIndexFlag = TRUE;
} else {
- LocalPirqIndex = (UINT8) ((LocalPirqIndex + (UINT8)Bridges[SBridgeIndex].PciDevice)%4);
+ LocalPirqIndex = (UINT8)((LocalPirqIndex + (UINT8)Bridges[SBridgeIndex].PciDevice)%4);
}
//
// Check if at device. If not get new PCI location & PIRQ
//
- if (Bridges[SBridgeIndex].SecondaryBus == (UINT8) LocalBus) {
+ if (Bridges[SBridgeIndex].SecondaryBus == (UINT8)LocalBus) {
//
// Translate PIRQ
//
- LocalPirqIndex = (UINT8) ((LocalPirqIndex + (UINT8) (LocalDevice)) % 4);
+ LocalPirqIndex = (UINT8)((LocalPirqIndex + (UINT8)(LocalDevice)) % 4);
break;
}
}
@@ -751,19 +764,18 @@ Rotate (B,C,D,A) by 1 giving C,D,A,B. Translated PIRQ is C.
//
// In case we fail to find the Bridge just above us, this is some potential error and we want to warn the user
//
- if(BridgeIndex >= NumberOfBridges){
+ if (BridgeIndex >= NumberOfBridges) {
DEBUG ((DEBUG_ERROR, "Cannot Find IRQ Routing for Bus %d, Device %d, Function %d\n", *PciBus, *PciDevice, *PciFunction));
}
- *PirqIndex = LocalPirqIndex;
- *PciBus = BaseBus;
- *PciDevice = BaseDevice;
- *PciFunction = BaseFunction;
+ *PirqIndex = LocalPirqIndex;
+ *PciBus = BaseBus;
+ *PciDevice = BaseDevice;
+ *PciFunction = BaseFunction;
return EFI_SUCCESS;
}
-
/**
Copy the $PIR table as required.
@@ -776,59 +788,59 @@ Rotate (B,C,D,A) by 1 giving C,D,A,B. Translated PIRQ is C.
**/
VOID
CopyPirqTable (
- IN LEGACY_BIOS_INSTANCE *Private,
- IN EFI_LEGACY_IRQ_ROUTING_ENTRY *RoutingTable,
- IN UINTN RoutingTableEntries,
- IN EFI_LEGACY_PIRQ_TABLE_HEADER *PirqTable,
- IN UINTN PirqTableSize
+ IN LEGACY_BIOS_INSTANCE *Private,
+ IN EFI_LEGACY_IRQ_ROUTING_ENTRY *RoutingTable,
+ IN UINTN RoutingTableEntries,
+ IN EFI_LEGACY_PIRQ_TABLE_HEADER *PirqTable,
+ IN UINTN PirqTableSize
)
{
- EFI_IA32_REGISTER_SET Regs;
- UINT32 Granularity;
+ EFI_IA32_REGISTER_SET Regs;
+ UINT32 Granularity;
//
// Copy $PIR table, if it exists.
//
if (PirqTable != NULL) {
Private->LegacyRegion->UnLock (
- Private->LegacyRegion,
- 0xE0000,
- 0x20000,
- &Granularity
- );
-
- Private->InternalIrqRoutingTable = RoutingTable;
- Private->NumberIrqRoutingEntries = (UINT16) (RoutingTableEntries);
+ Private->LegacyRegion,
+ 0xE0000,
+ 0x20000,
+ &Granularity
+ );
+
+ Private->InternalIrqRoutingTable = RoutingTable;
+ Private->NumberIrqRoutingEntries = (UINT16)(RoutingTableEntries);
ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET));
Regs.X.AX = Legacy16GetTableAddress;
- Regs.X.CX = (UINT16) PirqTableSize;
+ Regs.X.CX = (UINT16)PirqTableSize;
//
// Allocate at F segment according to PCI IRQ Routing Table Specification
//
- Regs.X.BX = (UINT16) 0x1;
+ Regs.X.BX = (UINT16)0x1;
//
// 16-byte boundary alignment requirement according to
// PCI IRQ Routing Table Specification
//
Regs.X.DX = 0x10;
Private->LegacyBios.FarCall86 (
- &Private->LegacyBios,
- Private->Legacy16CallSegment,
- Private->Legacy16CallOffset,
- &Regs,
- NULL,
- 0
- );
+ &Private->LegacyBios,
+ Private->Legacy16CallSegment,
+ Private->Legacy16CallOffset,
+ &Regs,
+ NULL,
+ 0
+ );
- Private->Legacy16Table->IrqRoutingTablePointer = (UINT32) (Regs.X.DS * 16 + Regs.X.BX);
+ Private->Legacy16Table->IrqRoutingTablePointer = (UINT32)(Regs.X.DS * 16 + Regs.X.BX);
if (Regs.X.AX != 0) {
DEBUG ((DEBUG_ERROR, "PIRQ table length insufficient - %x\n", PirqTableSize));
} else {
DEBUG ((DEBUG_INFO, "PIRQ table in legacy region - %x\n", Private->Legacy16Table->IrqRoutingTablePointer));
Private->Legacy16Table->IrqRoutingTableLength = (UINT32)PirqTableSize;
CopyMem (
- (VOID *) (UINTN)Private->Legacy16Table->IrqRoutingTablePointer,
+ (VOID *)(UINTN)Private->Legacy16Table->IrqRoutingTablePointer,
PirqTable,
PirqTableSize
);
@@ -890,10 +902,10 @@ DumpPciHandle (
**/
VOID
InstallLegacyIrqHandler (
- IN LEGACY_BIOS_INSTANCE *Private,
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINT8 PciIrq,
- IN PCI_TYPE00 *PciConfigHeader
+ IN LEGACY_BIOS_INSTANCE *Private,
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN UINT8 PciIrq,
+ IN PCI_TYPE00 *PciConfigHeader
)
{
EFI_IA32_REGISTER_SET Regs;
@@ -924,7 +936,7 @@ InstallLegacyIrqHandler (
NULL
);
- LegMask = (UINT16) (LegMask | (UINT16) (1 << PciIrq));
+ LegMask = (UINT16)(LegMask | (UINT16)(1 << PciIrq));
Legacy8259->SetMask (
Legacy8259,
@@ -935,18 +947,18 @@ InstallLegacyIrqHandler (
);
PciIo->GetLocation (
- PciIo,
- &PciSegment,
- &PciBus,
- &PciDevice,
- &PciFunction
- );
- Private->IntThunk->PciHandler.PciBus = (UINT8) PciBus;
- Private->IntThunk->PciHandler.PciDeviceFun = (UINT8) ((PciDevice << 3) + PciFunction);
- Private->IntThunk->PciHandler.PciSegment = (UINT8) PciSegment;
- Private->IntThunk->PciHandler.PciClass = PciConfigHeader->Hdr.ClassCode[2];
- Private->IntThunk->PciHandler.PciSubclass = PciConfigHeader->Hdr.ClassCode[1];
- Private->IntThunk->PciHandler.PciInterface = PciConfigHeader->Hdr.ClassCode[0];
+ PciIo,
+ &PciSegment,
+ &PciBus,
+ &PciDevice,
+ &PciFunction
+ );
+ Private->IntThunk->PciHandler.PciBus = (UINT8)PciBus;
+ Private->IntThunk->PciHandler.PciDeviceFun = (UINT8)((PciDevice << 3) + PciFunction);
+ Private->IntThunk->PciHandler.PciSegment = (UINT8)PciSegment;
+ Private->IntThunk->PciHandler.PciClass = PciConfigHeader->Hdr.ClassCode[2];
+ Private->IntThunk->PciHandler.PciSubclass = PciConfigHeader->Hdr.ClassCode[1];
+ Private->IntThunk->PciHandler.PciInterface = PciConfigHeader->Hdr.ClassCode[0];
//
// Use native mode base address registers in two cases:
@@ -954,30 +966,30 @@ InstallLegacyIrqHandler (
// in native mode OR
// 2. PCI device Sub Class Code is not IDE
//
- Private->IntThunk->PciHandler.PrimaryBusMaster = (UINT16)(PciConfigHeader->Device.Bar[4] & 0xfffc);
+ Private->IntThunk->PciHandler.PrimaryBusMaster = (UINT16)(PciConfigHeader->Device.Bar[4] & 0xfffc);
if (((PciConfigHeader->Hdr.ClassCode[0] & 0x01) != 0) || (PciConfigHeader->Hdr.ClassCode[1] != PCI_CLASS_MASS_STORAGE_IDE)) {
- Private->IntThunk->PciHandler.PrimaryIrq = PciIrq;
- Private->IntThunk->PciHandler.PrimaryBase = (UINT16) (PciConfigHeader->Device.Bar[0] & 0xfffc);
- Private->IntThunk->PciHandler.PrimaryControl = (UINT16) ((PciConfigHeader->Device.Bar[1] & 0xfffc) + 2);
+ Private->IntThunk->PciHandler.PrimaryIrq = PciIrq;
+ Private->IntThunk->PciHandler.PrimaryBase = (UINT16)(PciConfigHeader->Device.Bar[0] & 0xfffc);
+ Private->IntThunk->PciHandler.PrimaryControl = (UINT16)((PciConfigHeader->Device.Bar[1] & 0xfffc) + 2);
} else {
- Private->IntThunk->PciHandler.PrimaryIrq = 14;
- Private->IntThunk->PciHandler.PrimaryBase = 0x1f0;
- Private->IntThunk->PciHandler.PrimaryControl = 0x3f6;
+ Private->IntThunk->PciHandler.PrimaryIrq = 14;
+ Private->IntThunk->PciHandler.PrimaryBase = 0x1f0;
+ Private->IntThunk->PciHandler.PrimaryControl = 0x3f6;
}
+
//
// Secondary controller data
//
if (Private->IntThunk->PciHandler.PrimaryBusMaster != 0) {
- Private->IntThunk->PciHandler.SecondaryBusMaster = (UINT16) ((PciConfigHeader->Device.Bar[4] & 0xfffc) + 8);
- PrimaryMaster = (UINT16) (Private->IntThunk->PciHandler.PrimaryBusMaster + 2);
- SecondaryMaster = (UINT16) (Private->IntThunk->PciHandler.SecondaryBusMaster + 2);
+ Private->IntThunk->PciHandler.SecondaryBusMaster = (UINT16)((PciConfigHeader->Device.Bar[4] & 0xfffc) + 8);
+ PrimaryMaster = (UINT16)(Private->IntThunk->PciHandler.PrimaryBusMaster + 2);
+ SecondaryMaster = (UINT16)(Private->IntThunk->PciHandler.SecondaryBusMaster + 2);
//
// Clear pending interrupts in Bus Master registers
//
IoWrite16 (PrimaryMaster, 0x04);
IoWrite16 (SecondaryMaster, 0x04);
-
}
//
@@ -987,14 +999,13 @@ InstallLegacyIrqHandler (
// 2. PCI device Sub Class Code is not IDE
//
if (((PciConfigHeader->Hdr.ClassCode[0] & 0x04) != 0) || (PciConfigHeader->Hdr.ClassCode[1] != PCI_CLASS_MASS_STORAGE_IDE)) {
- Private->IntThunk->PciHandler.SecondaryIrq = PciIrq;
- Private->IntThunk->PciHandler.SecondaryBase = (UINT16) (PciConfigHeader->Device.Bar[2] & 0xfffc);
- Private->IntThunk->PciHandler.SecondaryControl = (UINT16) ((PciConfigHeader->Device.Bar[3] & 0xfffc) + 2);
+ Private->IntThunk->PciHandler.SecondaryIrq = PciIrq;
+ Private->IntThunk->PciHandler.SecondaryBase = (UINT16)(PciConfigHeader->Device.Bar[2] & 0xfffc);
+ Private->IntThunk->PciHandler.SecondaryControl = (UINT16)((PciConfigHeader->Device.Bar[3] & 0xfffc) + 2);
} else {
-
- Private->IntThunk->PciHandler.SecondaryIrq = 15;
- Private->IntThunk->PciHandler.SecondaryBase = 0x170;
- Private->IntThunk->PciHandler.SecondaryControl = 0x376;
+ Private->IntThunk->PciHandler.SecondaryIrq = 15;
+ Private->IntThunk->PciHandler.SecondaryBase = 0x170;
+ Private->IntThunk->PciHandler.SecondaryControl = 0x376;
}
//
@@ -1021,20 +1032,20 @@ InstallLegacyIrqHandler (
);
Regs.X.AX = Legacy16InstallPciHandler;
- TempData = (UINTN) &Private->IntThunk->PciHandler;
- Regs.X.ES = EFI_SEGMENT ((UINT32) TempData);
- Regs.X.BX = EFI_OFFSET ((UINT32) TempData);
+ TempData = (UINTN)&Private->IntThunk->PciHandler;
+ Regs.X.ES = EFI_SEGMENT ((UINT32)TempData);
+ Regs.X.BX = EFI_OFFSET ((UINT32)TempData);
DumpPciHandle (&Private->IntThunk->PciHandler);
Private->LegacyBios.FarCall86 (
- &Private->LegacyBios,
- Private->Legacy16CallSegment,
- Private->Legacy16CallOffset,
- &Regs,
- NULL,
- 0
- );
+ &Private->LegacyBios,
+ Private->Legacy16CallSegment,
+ Private->Legacy16CallOffset,
+ &Regs,
+ NULL,
+ 0
+ );
Private->Cpu->FlushDataCache (Private->Cpu, 0xE0000, 0x20000, EfiCpuFlushTypeWriteBackInvalidate);
Private->LegacyRegion->Lock (
@@ -1043,10 +1054,8 @@ InstallLegacyIrqHandler (
0x20000,
&Granularity
);
-
}
-
/**
Program the interrupt routing register in all the PCI devices. On a PC AT system
this register contains the 8259 IRQ vector that matches its PCI interrupt.
@@ -1059,37 +1068,37 @@ InstallLegacyIrqHandler (
**/
EFI_STATUS
PciProgramAllInterruptLineRegisters (
- IN LEGACY_BIOS_INSTANCE *Private
+ IN LEGACY_BIOS_INSTANCE *Private
)
{
- EFI_STATUS Status;
- EFI_PCI_IO_PROTOCOL *PciIo;
- EFI_LEGACY_8259_PROTOCOL *Legacy8259;
- EFI_LEGACY_INTERRUPT_PROTOCOL *LegacyInterrupt;
- EFI_LEGACY_BIOS_PLATFORM_PROTOCOL *LegacyBiosPlatform;
- UINT8 InterruptPin;
- UINTN Index;
- UINTN HandleCount;
- EFI_HANDLE *HandleBuffer;
- UINTN MassStorageHandleCount;
- EFI_HANDLE *MassStorageHandleBuffer;
- UINTN MassStorageHandleIndex;
- UINT8 PciIrq;
- UINT16 Command;
- UINTN PciSegment;
- UINTN PciBus;
- UINTN PciDevice;
- UINTN PciFunction;
- EFI_LEGACY_IRQ_ROUTING_ENTRY *RoutingTable;
- UINTN RoutingTableEntries;
- UINT16 LegMask;
- UINT16 LegEdgeLevel;
- PCI_TYPE00 PciConfigHeader;
- EFI_LEGACY_PIRQ_TABLE_HEADER *PirqTable;
- UINTN PirqTableSize;
- UINTN Flags;
- HDD_INFO *HddInfo;
- UINT64 Supports;
+ EFI_STATUS Status;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ EFI_LEGACY_8259_PROTOCOL *Legacy8259;
+ EFI_LEGACY_INTERRUPT_PROTOCOL *LegacyInterrupt;
+ EFI_LEGACY_BIOS_PLATFORM_PROTOCOL *LegacyBiosPlatform;
+ UINT8 InterruptPin;
+ UINTN Index;
+ UINTN HandleCount;
+ EFI_HANDLE *HandleBuffer;
+ UINTN MassStorageHandleCount;
+ EFI_HANDLE *MassStorageHandleBuffer;
+ UINTN MassStorageHandleIndex;
+ UINT8 PciIrq;
+ UINT16 Command;
+ UINTN PciSegment;
+ UINTN PciBus;
+ UINTN PciDevice;
+ UINTN PciFunction;
+ EFI_LEGACY_IRQ_ROUTING_ENTRY *RoutingTable;
+ UINTN RoutingTableEntries;
+ UINT16 LegMask;
+ UINT16 LegEdgeLevel;
+ PCI_TYPE00 PciConfigHeader;
+ EFI_LEGACY_PIRQ_TABLE_HEADER *PirqTable;
+ UINTN PirqTableSize;
+ UINTN Flags;
+ HDD_INFO *HddInfo;
+ UINT64 Supports;
//
// Note - This routine use to return immediately if Private->PciInterruptLine
@@ -1101,15 +1110,15 @@ PciProgramAllInterruptLineRegisters (
// EFI_ALREADY_STARTED. In addition check if PCI device InterruptLine != 0.
// If zero then function unprogrammed else skip function.
//
- Legacy8259 = Private->Legacy8259;
- LegacyInterrupt = Private->LegacyInterrupt;
- LegacyBiosPlatform = Private->LegacyBiosPlatform;
+ Legacy8259 = Private->Legacy8259;
+ LegacyInterrupt = Private->LegacyInterrupt;
+ LegacyBiosPlatform = Private->LegacyBiosPlatform;
LegacyBiosPlatform->GetRoutingTable (
Private->LegacyBiosPlatform,
- (VOID *) &RoutingTable,
+ (VOID *)&RoutingTable,
&RoutingTableEntries,
- (VOID *) &PirqTable,
+ (VOID *)&PirqTable,
&PirqTableSize,
NULL,
NULL
@@ -1136,6 +1145,7 @@ PciProgramAllInterruptLineRegisters (
if (EFI_ERROR (Status)) {
return EFI_NOT_FOUND;
}
+
if (HandleCount == mHandleCount) {
FreePool (HandleBuffer);
return EFI_ALREADY_STARTED;
@@ -1164,7 +1174,7 @@ PciProgramAllInterruptLineRegisters (
Status = gBS->HandleProtocol (
HandleBuffer[Index],
&gEfiPciIoProtocolGuid,
- (VOID **) &PciIo
+ (VOID **)&PciIo
);
ASSERT_EFI_ERROR (Status);
@@ -1192,13 +1202,14 @@ PciProgramAllInterruptLineRegisters (
);
if (!EFI_ERROR (Status)) {
Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE;
- Status = PciIo->Attributes (
- PciIo,
- EfiPciIoAttributeOperationEnable,
- Supports,
- NULL
- );
+ Status = PciIo->Attributes (
+ PciIo,
+ EfiPciIoAttributeOperationEnable,
+ Supports,
+ NULL
+ );
}
+
PciIo->Pci.Write (PciIo, EfiPciIoWidthUint16, 0x04, 1, &Command);
if (EFI_ERROR (Status)) {
@@ -1238,6 +1249,7 @@ PciProgramAllInterruptLineRegisters (
&InterruptPin
);
}
+
//
// Translate InterruptPin(0-3) into PIRQ
//
@@ -1290,7 +1302,7 @@ PciProgramAllInterruptLineRegisters (
// since ConnectController may force native mode and we don't
// want that for primary IDE controller
//
- MassStorageHandleCount = 0;
+ MassStorageHandleCount = 0;
MassStorageHandleBuffer = NULL;
LegacyBiosPlatform->GetPlatformHandle (
Private->LegacyBiosPlatform,
@@ -1327,6 +1339,7 @@ PciProgramAllInterruptLineRegisters (
}
}
}
+
//
// Write InterruptPin and enable 8259.
//
@@ -1337,7 +1350,7 @@ PciProgramAllInterruptLineRegisters (
1,
&PciIrq
);
- Private->IntThunk->EfiToLegacy16BootTable.PciIrqMask = (UINT16) (Private->IntThunk->EfiToLegacy16BootTable.PciIrqMask | (UINT16) (1 << PciIrq));
+ Private->IntThunk->EfiToLegacy16BootTable.PciIrqMask = (UINT16)(Private->IntThunk->EfiToLegacy16BootTable.PciIrqMask | (UINT16)(1 << PciIrq));
Legacy8259->GetMask (
Legacy8259,
@@ -1347,8 +1360,8 @@ PciProgramAllInterruptLineRegisters (
NULL
);
- LegMask = (UINT16) (LegMask & (UINT16)~(1 << PciIrq));
- LegEdgeLevel = (UINT16) (LegEdgeLevel | (UINT16) (1 << PciIrq));
+ LegMask = (UINT16)(LegMask & (UINT16) ~(1 << PciIrq));
+ LegEdgeLevel = (UINT16)(LegEdgeLevel | (UINT16)(1 << PciIrq));
Legacy8259->SetMask (
Legacy8259,
&LegMask,
@@ -1358,11 +1371,11 @@ PciProgramAllInterruptLineRegisters (
);
}
}
+
FreePool (HandleBuffer);
return EFI_SUCCESS;
}
-
/**
Find & verify PnP Expansion header in ROM image
@@ -1377,43 +1390,43 @@ PciProgramAllInterruptLineRegisters (
**/
EFI_STATUS
FindNextPnpExpansionHeader (
- IN LEGACY_BIOS_INSTANCE *Private,
- IN BOOLEAN FirstHeader,
- IN OUT LEGACY_PNP_EXPANSION_HEADER **PnpPtr
+ IN LEGACY_BIOS_INSTANCE *Private,
+ IN BOOLEAN FirstHeader,
+ IN OUT LEGACY_PNP_EXPANSION_HEADER **PnpPtr
)
{
- UINTN TempData;
- LEGACY_PNP_EXPANSION_HEADER *LocalPnpPtr;
+ UINTN TempData;
+ LEGACY_PNP_EXPANSION_HEADER *LocalPnpPtr;
+
LocalPnpPtr = *PnpPtr;
if (FirstHeader == FIRST_INSTANCE) {
- mBasePnpPtr = LocalPnpPtr;
- mBbsRomSegment = (UINT16) ((UINTN) mBasePnpPtr >> 4);
+ mBasePnpPtr = LocalPnpPtr;
+ mBbsRomSegment = (UINT16)((UINTN)mBasePnpPtr >> 4);
//
// Offset 0x1a gives offset to PnP expansion header for the first
// instance, there after the structure gives the offset to the next
// structure
//
- LocalPnpPtr = (LEGACY_PNP_EXPANSION_HEADER *) ((UINT8 *) LocalPnpPtr + 0x1a);
- TempData = (*((UINT16 *) LocalPnpPtr));
+ LocalPnpPtr = (LEGACY_PNP_EXPANSION_HEADER *)((UINT8 *)LocalPnpPtr + 0x1a);
+ TempData = (*((UINT16 *)LocalPnpPtr));
} else {
- TempData = (UINT16) LocalPnpPtr->NextHeader;
+ TempData = (UINT16)LocalPnpPtr->NextHeader;
}
- LocalPnpPtr = (LEGACY_PNP_EXPANSION_HEADER *) (((UINT8 *) mBasePnpPtr + TempData));
+ LocalPnpPtr = (LEGACY_PNP_EXPANSION_HEADER *)(((UINT8 *)mBasePnpPtr + TempData));
//
// Search for PnP table in Shadowed ROM
//
*PnpPtr = LocalPnpPtr;
- if (*(UINT32 *) LocalPnpPtr == SIGNATURE_32 ('$', 'P', 'n', 'P')) {
+ if (*(UINT32 *)LocalPnpPtr == SIGNATURE_32 ('$', 'P', 'n', 'P')) {
return EFI_SUCCESS;
} else {
return EFI_NOT_FOUND;
}
}
-
/**
Update list of Bev or BCV table entries.
@@ -1432,38 +1445,39 @@ UpdateBevBcvTable (
IN EFI_PCI_IO_PROTOCOL *PciIo
)
{
- VOID *RomEnd;
- BBS_TABLE *BbsTable;
- UINTN BbsIndex;
- EFI_LEGACY_EXPANSION_ROM_HEADER *PciPtr;
- LEGACY_PNP_EXPANSION_HEADER *PnpPtr;
- BOOLEAN Instance;
- EFI_STATUS Status;
- UINTN Segment;
- UINTN Bus;
- UINTN Device;
- UINTN Function;
- UINT8 Class;
- UINT16 DeviceType;
- Segment = 0;
- Bus = 0;
- Device = 0;
- Function = 0;
- Class = 0;
- DeviceType = BBS_UNKNOWN;
+ VOID *RomEnd;
+ BBS_TABLE *BbsTable;
+ UINTN BbsIndex;
+ EFI_LEGACY_EXPANSION_ROM_HEADER *PciPtr;
+ LEGACY_PNP_EXPANSION_HEADER *PnpPtr;
+ BOOLEAN Instance;
+ EFI_STATUS Status;
+ UINTN Segment;
+ UINTN Bus;
+ UINTN Device;
+ UINTN Function;
+ UINT8 Class;
+ UINT16 DeviceType;
+
+ Segment = 0;
+ Bus = 0;
+ Device = 0;
+ Function = 0;
+ Class = 0;
+ DeviceType = BBS_UNKNOWN;
//
// Skip floppy and 2*onboard IDE controller entries(Master/Slave per
// controller).
//
- BbsIndex = Private->IntThunk->EfiToLegacy16BootTable.NumberBbsEntries;
+ BbsIndex = Private->IntThunk->EfiToLegacy16BootTable.NumberBbsEntries;
- BbsTable = (BBS_TABLE*)(UINTN) Private->IntThunk->EfiToLegacy16BootTable.BbsTable;
- PnpPtr = (LEGACY_PNP_EXPANSION_HEADER *) RomStart;
- PciPtr = (EFI_LEGACY_EXPANSION_ROM_HEADER *) RomStart;
+ BbsTable = (BBS_TABLE *)(UINTN)Private->IntThunk->EfiToLegacy16BootTable.BbsTable;
+ PnpPtr = (LEGACY_PNP_EXPANSION_HEADER *)RomStart;
+ PciPtr = (EFI_LEGACY_EXPANSION_ROM_HEADER *)RomStart;
- RomEnd = (VOID *) (PciPtr->Size512 * 512 + (UINTN) PciPtr);
- Instance = FIRST_INSTANCE;
+ RomEnd = (VOID *)(PciPtr->Size512 * 512 + (UINTN)PciPtr);
+ Instance = FIRST_INSTANCE;
//
// OPROMs like PXE may not be tied to a piece of hardware and thus
// don't have a PciIo associated with them
@@ -1494,20 +1508,21 @@ UpdateBevBcvTable (
}
while (TRUE) {
- Status = FindNextPnpExpansionHeader (Private, Instance, &PnpPtr);
- Instance = NOT_FIRST_INSTANCE;
+ Status = FindNextPnpExpansionHeader (Private, Instance, &PnpPtr);
+ Instance = NOT_FIRST_INSTANCE;
if (EFI_ERROR (Status)) {
break;
}
+
//
// There can be additional $PnP headers within the OPROM.
// Example: SCSI can have one per drive.
//
BbsTable[BbsIndex].BootPriority = BBS_UNPRIORITIZED_ENTRY;
BbsTable[BbsIndex].DeviceType = DeviceType;
- BbsTable[BbsIndex].Bus = (UINT32) Bus;
- BbsTable[BbsIndex].Device = (UINT32) Device;
- BbsTable[BbsIndex].Function = (UINT32) Function;
+ BbsTable[BbsIndex].Bus = (UINT32)Bus;
+ BbsTable[BbsIndex].Device = (UINT32)Device;
+ BbsTable[BbsIndex].Function = (UINT32)Function;
BbsTable[BbsIndex].StatusFlags.OldPosition = 0;
BbsTable[BbsIndex].StatusFlags.Reserved1 = 0;
BbsTable[BbsIndex].StatusFlags.Enabled = 0;
@@ -1532,22 +1547,21 @@ UpdateBevBcvTable (
}
if (PnpPtr->Bev != 0) {
- BbsTable[BbsIndex].BootHandlerOffset = PnpPtr->Bev;
- BbsTable[BbsIndex].DeviceType = BBS_BEV_DEVICE;
+ BbsTable[BbsIndex].BootHandlerOffset = PnpPtr->Bev;
+ BbsTable[BbsIndex].DeviceType = BBS_BEV_DEVICE;
++BbsIndex;
}
- if ((PnpPtr == (LEGACY_PNP_EXPANSION_HEADER *) PciPtr) || (PnpPtr > (LEGACY_PNP_EXPANSION_HEADER *) RomEnd)) {
+ if ((PnpPtr == (LEGACY_PNP_EXPANSION_HEADER *)PciPtr) || (PnpPtr > (LEGACY_PNP_EXPANSION_HEADER *)RomEnd)) {
break;
}
}
- BbsTable[BbsIndex].BootPriority = BBS_IGNORE_ENTRY;
- Private->IntThunk->EfiToLegacy16BootTable.NumberBbsEntries = (UINT32) BbsIndex;
+ BbsTable[BbsIndex].BootPriority = BBS_IGNORE_ENTRY;
+ Private->IntThunk->EfiToLegacy16BootTable.NumberBbsEntries = (UINT32)BbsIndex;
return EFI_SUCCESS;
}
-
/**
Shadow all the PCI legacy ROMs. Use data from the Legacy BIOS Protocol
to chose the order. Skip any devices that have already have legacy
@@ -1561,22 +1575,22 @@ UpdateBevBcvTable (
**/
EFI_STATUS
PciShadowRoms (
- IN LEGACY_BIOS_INSTANCE *Private
+ IN LEGACY_BIOS_INSTANCE *Private
)
{
- EFI_STATUS Status;
- EFI_PCI_IO_PROTOCOL *PciIo;
- PCI_TYPE00 Pci;
- UINTN Index;
- UINTN HandleCount;
- EFI_HANDLE *HandleBuffer;
- EFI_HANDLE VgaHandle;
- EFI_HANDLE FirstHandle;
- VOID **RomStart;
- UINTN Flags;
- PCI_TYPE00 PciConfigHeader;
- UINT16 *Command;
- UINT64 Supports;
+ EFI_STATUS Status;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ PCI_TYPE00 Pci;
+ UINTN Index;
+ UINTN HandleCount;
+ EFI_HANDLE *HandleBuffer;
+ EFI_HANDLE VgaHandle;
+ EFI_HANDLE FirstHandle;
+ VOID **RomStart;
+ UINTN Flags;
+ PCI_TYPE00 PciConfigHeader;
+ UINT16 *Command;
+ UINT64 Supports;
//
// Make the VGA device first
@@ -1606,6 +1620,7 @@ PciShadowRoms (
if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Place the VGA handle as first.
//
@@ -1617,27 +1632,28 @@ PciShadowRoms (
break;
}
}
+
//
// Allocate memory to save Command WORD from each device. We do this
// to restore devices to same state as EFI after switching to legacy.
//
- Command = (UINT16 *) AllocatePool (
- sizeof (UINT16) * (HandleCount + 1)
- );
+ Command = (UINT16 *)AllocatePool (
+ sizeof (UINT16) * (HandleCount + 1)
+ );
if (NULL == Command) {
FreePool (HandleBuffer);
return EFI_OUT_OF_RESOURCES;
}
+
//
// Disconnect all EFI devices first. This covers cases where alegacy BIOS
// may control multiple PCI devices.
//
for (Index = 0; Index < HandleCount; Index++) {
-
Status = gBS->HandleProtocol (
HandleBuffer[Index],
&gEfiPciIoProtocolGuid,
- (VOID **) &PciIo
+ (VOID **)&PciIo
);
ASSERT_EFI_ERROR (Status);
@@ -1659,6 +1675,7 @@ PciShadowRoms (
if (!EFI_ERROR (Status)) {
continue;
}
+
//
// Stop EFI Drivers with oprom.
//
@@ -1668,15 +1685,15 @@ PciShadowRoms (
NULL
);
}
+
//
// For every device that has not had a legacy ROM started. Start a legacy ROM.
//
for (Index = 0; Index < HandleCount; Index++) {
-
Status = gBS->HandleProtocol (
HandleBuffer[Index],
&gEfiPciIoProtocolGuid,
- (VOID **) &PciIo
+ (VOID **)&PciIo
);
ASSERT_EFI_ERROR (Status);
@@ -1698,9 +1715,10 @@ PciShadowRoms (
// one will work in legacy mode (OPROM will be given control) and
// other Video devices will work in native mode (OS driver will handle these devices).
//
- if (IS_PCI_DISPLAY (&Pci) && Index != 0) {
+ if (IS_PCI_DISPLAY (&Pci) && (Index != 0)) {
continue;
}
+
//
// Skip any device that already has a legacy ROM run
//
@@ -1712,7 +1730,7 @@ PciShadowRoms (
//
// If legacy VBIOS Oprom has not been dispatched before, install legacy VBIOS here.
//
- if (IS_PCI_DISPLAY (&Pci) && Index == 0) {
+ if (IS_PCI_DISPLAY (&Pci) && (Index == 0)) {
Status = LegacyBiosInstallVgaRom (Private);
//
// A return status of EFI_NOT_FOUND is considered valid (No EFI
@@ -1732,7 +1750,7 @@ PciShadowRoms (
&Flags,
NULL,
NULL,
- (VOID **) &RomStart,
+ (VOID **)&RomStart,
NULL
);
if (EFI_ERROR (Status)) {
@@ -1740,6 +1758,7 @@ PciShadowRoms (
continue;
}
}
+
//
// Restore Command register so legacy has same devices enabled or disabled
// as EFI.
@@ -1766,13 +1785,14 @@ PciShadowRoms (
);
if (!EFI_ERROR (Status)) {
Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE;
- Status = PciIo->Attributes (
- PciIo,
- EfiPciIoAttributeOperationEnable,
- Supports,
- NULL
- );
+ Status = PciIo->Attributes (
+ PciIo,
+ EfiPciIoAttributeOperationEnable,
+ Supports,
+ NULL
+ );
}
+
if (!EFI_ERROR (Status)) {
Command[Index] = 0x1f;
}
@@ -1793,7 +1813,6 @@ PciShadowRoms (
return EFI_SUCCESS;
}
-
/**
Test to see if a legacy PCI ROM exists for this device. Optionally return
the Legacy ROM instance for this PCI device.
@@ -1812,11 +1831,11 @@ PciShadowRoms (
EFI_STATUS
EFIAPI
LegacyBiosCheckPciRom (
- IN EFI_LEGACY_BIOS_PROTOCOL *This,
- IN EFI_HANDLE PciHandle,
- OUT VOID **RomImage OPTIONAL,
- OUT UINTN *RomSize OPTIONAL,
- OUT UINTN *Flags
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,
+ IN EFI_HANDLE PciHandle,
+ OUT VOID **RomImage OPTIONAL,
+ OUT UINTN *RomSize OPTIONAL,
+ OUT UINTN *Flags
)
{
return LegacyBiosCheckPciRomEx (
@@ -1829,7 +1848,6 @@ LegacyBiosCheckPciRom (
NULL,
NULL
);
-
}
/**
@@ -1854,31 +1872,31 @@ LegacyBiosCheckPciRom (
**/
EFI_STATUS
LegacyBiosCheckPciRomEx (
- IN EFI_LEGACY_BIOS_PROTOCOL *This,
- IN EFI_HANDLE PciHandle,
- OUT VOID **RomImage OPTIONAL,
- OUT UINTN *RomSize OPTIONAL,
- OUT UINTN *RuntimeImageLength OPTIONAL,
- OUT UINTN *Flags OPTIONAL,
- OUT UINT8 *OpromRevision OPTIONAL,
- OUT VOID **ConfigUtilityCodeHeader OPTIONAL
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,
+ IN EFI_HANDLE PciHandle,
+ OUT VOID **RomImage OPTIONAL,
+ OUT UINTN *RomSize OPTIONAL,
+ OUT UINTN *RuntimeImageLength OPTIONAL,
+ OUT UINTN *Flags OPTIONAL,
+ OUT UINT8 *OpromRevision OPTIONAL,
+ OUT VOID **ConfigUtilityCodeHeader OPTIONAL
)
{
- EFI_STATUS Status;
- LEGACY_BIOS_INSTANCE *Private;
- EFI_PCI_IO_PROTOCOL *PciIo;
- UINTN LocalRomSize;
- VOID *LocalRomImage;
- PCI_TYPE00 PciConfigHeader;
- VOID *LocalConfigUtilityCodeHeader;
+ EFI_STATUS Status;
+ LEGACY_BIOS_INSTANCE *Private;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ UINTN LocalRomSize;
+ VOID *LocalRomImage;
+ PCI_TYPE00 PciConfigHeader;
+ VOID *LocalConfigUtilityCodeHeader;
LocalConfigUtilityCodeHeader = NULL;
- *Flags = NO_ROM;
- Status = gBS->HandleProtocol (
- PciHandle,
- &gEfiPciIoProtocolGuid,
- (VOID **) &PciIo
- );
+ *Flags = NO_ROM;
+ Status = gBS->HandleProtocol (
+ PciHandle,
+ &gEfiPciIoProtocolGuid,
+ (VOID **)&PciIo
+ );
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
@@ -1891,10 +1909,11 @@ LegacyBiosCheckPciRomEx (
*Flags |= (UINTN)(ROM_FOUND | VALID_LEGACY_ROM);
return EFI_SUCCESS;
}
+
//
// Check for PCI ROM Bar
//
- LocalRomSize = (UINTN) PciIo->RomSize;
+ LocalRomSize = (UINTN)PciIo->RomSize;
LocalRomImage = PciIo->RomImage;
if (LocalRomSize != 0) {
*Flags |= ROM_FOUND;
@@ -1912,16 +1931,16 @@ LegacyBiosCheckPciRomEx (
);
Private = LEGACY_BIOS_INSTANCE_FROM_THIS (This);
- Status = GetPciLegacyRom (
- Private->Csm16PciInterfaceVersion,
- PciConfigHeader.Hdr.VendorId,
- PciConfigHeader.Hdr.DeviceId,
- &LocalRomImage,
- &LocalRomSize,
- RuntimeImageLength,
- OpromRevision,
- &LocalConfigUtilityCodeHeader
- );
+ Status = GetPciLegacyRom (
+ Private->Csm16PciInterfaceVersion,
+ PciConfigHeader.Hdr.VendorId,
+ PciConfigHeader.Hdr.DeviceId,
+ &LocalRomImage,
+ &LocalRomSize,
+ RuntimeImageLength,
+ OpromRevision,
+ &LocalConfigUtilityCodeHeader
+ );
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
@@ -1964,11 +1983,11 @@ EnablePs2Keyboard (
VOID
)
{
- EFI_STATUS Status;
- EFI_HANDLE *HandleBuffer;
- UINTN HandleCount;
- EFI_ISA_IO_PROTOCOL *IsaIo;
- UINTN Index;
+ EFI_STATUS Status;
+ EFI_HANDLE *HandleBuffer;
+ UINTN HandleCount;
+ EFI_ISA_IO_PROTOCOL *IsaIo;
+ UINTN Index;
//
// Get SimpleTextIn and find PS2 controller
@@ -1983,6 +2002,7 @@ EnablePs2Keyboard (
if (EFI_ERROR (Status)) {
return EFI_NOT_FOUND;
}
+
for (Index = 0; Index < HandleCount; Index++) {
//
// Open the IO Abstraction(s) needed to perform the supported test
@@ -1990,7 +2010,7 @@ EnablePs2Keyboard (
Status = gBS->OpenProtocol (
HandleBuffer[Index],
&gEfiIsaIoProtocolGuid,
- (VOID **) &IsaIo,
+ (VOID **)&IsaIo,
NULL,
HandleBuffer[Index],
EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL
@@ -2001,7 +2021,7 @@ EnablePs2Keyboard (
// Use the ISA I/O Protocol to see if Controller is the Keyboard
// controller
//
- if (IsaIo->ResourceList->Device.HID != EISA_PNP_ID (0x303) || IsaIo->ResourceList->Device.UID != 0) {
+ if ((IsaIo->ResourceList->Device.HID != EISA_PNP_ID (0x303)) || (IsaIo->ResourceList->Device.UID != 0)) {
Status = EFI_UNSUPPORTED;
}
@@ -2017,11 +2037,11 @@ EnablePs2Keyboard (
gBS->ConnectController (HandleBuffer[Index], NULL, NULL, FALSE);
}
}
+
FreePool (HandleBuffer);
return EFI_SUCCESS;
}
-
/**
Load a legacy PC-AT OpROM for VGA controller.
@@ -2035,7 +2055,7 @@ EnablePs2Keyboard (
**/
EFI_STATUS
LegacyBiosInstallVgaRom (
- IN LEGACY_BIOS_INSTANCE *Private
+ IN LEGACY_BIOS_INSTANCE *Private
)
{
EFI_STATUS Status;
@@ -2103,7 +2123,7 @@ LegacyBiosInstallVgaRom (
Status = gBS->HandleProtocol (
OpenInfoBuffer[Index].AgentHandle,
&gEfiLegacyBiosGuid,
- (VOID **) &Interface
+ (VOID **)&Interface
);
if (!EFI_ERROR (Status)) {
//
@@ -2132,19 +2152,20 @@ LegacyBiosInstallVgaRom (
return Status;
}
}
+
//
// Find all the Thunk Driver
//
HandleBuffer = NULL;
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiLegacyBiosGuid,
- NULL,
- &HandleCount,
- &HandleBuffer
- );
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiLegacyBiosGuid,
+ NULL,
+ &HandleCount,
+ &HandleBuffer
+ );
ASSERT_EFI_ERROR (Status);
- ConnectHandleBuffer = (EFI_HANDLE *) AllocatePool (sizeof (EFI_HANDLE) * (HandleCount + 1));
+ ConnectHandleBuffer = (EFI_HANDLE *)AllocatePool (sizeof (EFI_HANDLE) * (HandleCount + 1));
ASSERT (ConnectHandleBuffer != NULL);
CopyMem (
@@ -2162,7 +2183,7 @@ LegacyBiosInstallVgaRom (
Status = gBS->HandleProtocol (
VgaHandle,
&gEfiPciIoProtocolGuid,
- (VOID **) &PciIo
+ (VOID **)&PciIo
);
ASSERT_EFI_ERROR (Status);
PciIo->Pci.Read (
@@ -2208,7 +2229,6 @@ LegacyBiosInstallVgaRom (
FreePool (ConnectHandleBuffer);
if (EFI_ERROR (Status)) {
-
Private->VgaInstalled = FALSE;
//
@@ -2221,7 +2241,6 @@ LegacyBiosInstallVgaRom (
return EFI_SUCCESS;
}
-
/**
Load a legacy PC-AT OpROM.
@@ -2249,41 +2268,41 @@ LegacyBiosInstallVgaRom (
EFI_STATUS
EFIAPI
LegacyBiosInstallRom (
- IN EFI_LEGACY_BIOS_PROTOCOL *This,
- IN LEGACY_BIOS_INSTANCE *Private,
- IN EFI_HANDLE PciHandle,
- IN UINT8 OpromRevision,
- IN VOID *RomImage,
- IN UINTN ImageSize,
- IN OUT UINTN *RuntimeImageLength,
- OUT UINT8 *DiskStart OPTIONAL,
- OUT UINT8 *DiskEnd OPTIONAL,
- OUT VOID **RomShadowAddress OPTIONAL
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,
+ IN LEGACY_BIOS_INSTANCE *Private,
+ IN EFI_HANDLE PciHandle,
+ IN UINT8 OpromRevision,
+ IN VOID *RomImage,
+ IN UINTN ImageSize,
+ IN OUT UINTN *RuntimeImageLength,
+ OUT UINT8 *DiskStart OPTIONAL,
+ OUT UINT8 *DiskEnd OPTIONAL,
+ OUT VOID **RomShadowAddress OPTIONAL
)
{
- EFI_STATUS Status;
- EFI_STATUS PciEnableStatus;
- EFI_PCI_IO_PROTOCOL *PciIo;
- UINT8 LocalDiskStart;
- UINT8 LocalDiskEnd;
- UINTN Segment;
- UINTN Bus;
- UINTN Device;
- UINTN Function;
- EFI_IA32_REGISTER_SET Regs;
- UINT8 VideoMode;
- UINT8 OldVideoMode;
- EFI_TIME BootTime;
- UINT32 *BdaPtr;
- UINT32 LocalTime;
- UINT32 StartBbsIndex;
- UINT32 EndBbsIndex;
- UINT32 MaxRomAddr;
- UINTN TempData;
- UINTN InitAddress;
- UINTN RuntimeAddress;
- EFI_PHYSICAL_ADDRESS PhysicalAddress;
- UINT32 Granularity;
+ EFI_STATUS Status;
+ EFI_STATUS PciEnableStatus;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ UINT8 LocalDiskStart;
+ UINT8 LocalDiskEnd;
+ UINTN Segment;
+ UINTN Bus;
+ UINTN Device;
+ UINTN Function;
+ EFI_IA32_REGISTER_SET Regs;
+ UINT8 VideoMode;
+ UINT8 OldVideoMode;
+ EFI_TIME BootTime;
+ UINT32 *BdaPtr;
+ UINT32 LocalTime;
+ UINT32 StartBbsIndex;
+ UINT32 EndBbsIndex;
+ UINT32 MaxRomAddr;
+ UINTN TempData;
+ UINTN InitAddress;
+ UINTN RuntimeAddress;
+ EFI_PHYSICAL_ADDRESS PhysicalAddress;
+ UINT32 Granularity;
PciIo = NULL;
LocalDiskStart = 0;
@@ -2297,14 +2316,14 @@ LegacyBiosInstallRom (
PhysicalAddress = 0;
MaxRomAddr = PcdGet32 (PcdEndOpromShadowAddress);
- if ((Private->Legacy16Table->TableLength >= OFFSET_OF(EFI_COMPATIBILITY16_TABLE, HiPermanentMemoryAddress)) &&
+ if ((Private->Legacy16Table->TableLength >= OFFSET_OF (EFI_COMPATIBILITY16_TABLE, HiPermanentMemoryAddress)) &&
(Private->Legacy16Table->UmaAddress != 0) &&
(Private->Legacy16Table->UmaSize != 0) &&
- (MaxRomAddr > (Private->Legacy16Table->UmaAddress))) {
+ (MaxRomAddr > (Private->Legacy16Table->UmaAddress)))
+ {
MaxRomAddr = Private->Legacy16Table->UmaAddress;
}
-
PciProgramAllInterruptLineRegisters (Private);
if ((OpromRevision >= 3) && (Private->Csm16PciInterfaceVersion >= 0x0300)) {
@@ -2313,12 +2332,12 @@ LegacyBiosInstallRom (
// first test if there is enough space for its INIT code
//
PhysicalAddress = CONVENTIONAL_MEMORY_TOP;
- Status = gBS->AllocatePages (
- AllocateMaxAddress,
- EfiBootServicesCode,
- EFI_SIZE_TO_PAGES (ImageSize),
- &PhysicalAddress
- );
+ Status = gBS->AllocatePages (
+ AllocateMaxAddress,
+ EfiBootServicesCode,
+ EFI_SIZE_TO_PAGES (ImageSize),
+ &PhysicalAddress
+ );
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "return LegacyBiosInstallRom(%d): EFI_OUT_OF_RESOURCES (no more space for OpROM)\n", DEBUG_LINE_NUMBER));
@@ -2331,7 +2350,8 @@ LegacyBiosInstallRom (
);
return EFI_OUT_OF_RESOURCES;
}
- InitAddress = (UINTN) PhysicalAddress;
+
+ InitAddress = (UINTN)PhysicalAddress;
//
// then test if there is enough space for its RT code
//
@@ -2353,7 +2373,7 @@ LegacyBiosInstallRom (
// CSM16 2.x meets PCI 2.x/3.0 OpROM
// test if there is enough space for its INIT code
//
- InitAddress = PCI_START_ADDRESS (Private->OptionRom);
+ InitAddress = PCI_START_ADDRESS (Private->OptionRom);
if (InitAddress + ImageSize > MaxRomAddr) {
DEBUG ((DEBUG_ERROR, "return LegacyBiosInstallRom(%d): EFI_OUT_OF_RESOURCES (no more space for OpROM)\n", DEBUG_LINE_NUMBER));
//
@@ -2378,14 +2398,14 @@ LegacyBiosInstallRom (
Private->LegacyRegion->UnLock (
Private->LegacyRegion,
- (UINT32) RuntimeAddress,
- (UINT32) ImageSize,
+ (UINT32)RuntimeAddress,
+ (UINT32)ImageSize,
&Granularity
);
DEBUG ((DEBUG_INFO, " Shadowing OpROM init/runtime/isize = %x/%x/%x\n", InitAddress, RuntimeAddress, ImageSize));
- CopyMem ((VOID *) InitAddress, RomImage, ImageSize);
+ CopyMem ((VOID *)InitAddress, RomImage, ImageSize);
//
// Read the highest disk number "installed: and assume a new disk will
@@ -2397,32 +2417,32 @@ LegacyBiosInstallRom (
// 3. Onboard IDE controllers will change 40:75
//
ACCESS_PAGE0_CODE (
- LocalDiskStart = (UINT8) ((*(UINT8 *) ((UINTN) 0x475)) + 0x80);
+ LocalDiskStart = (UINT8)((*(UINT8 *)((UINTN)0x475)) + 0x80);
if ((Private->Disk4075 + 0x80) < LocalDiskStart) {
- //
- // Update table since onboard IDE drives found
- //
- Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciSegment = 0xff;
- Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciBus = 0xff;
- Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciDevice = 0xff;
- Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciFunction = 0xff;
- Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].StartDriveNumber = (UINT8) (Private->Disk4075 + 0x80);
- Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].EndDriveNumber = LocalDiskStart;
- Private->LegacyEfiHddTableIndex ++;
- Private->Disk4075 = (UINT8) (LocalDiskStart & 0x7f);
- Private->DiskEnd = LocalDiskStart;
- }
+ //
+ // Update table since onboard IDE drives found
+ //
+ Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciSegment = 0xff;
+ Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciBus = 0xff;
+ Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciDevice = 0xff;
+ Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciFunction = 0xff;
+ Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].StartDriveNumber = (UINT8)(Private->Disk4075 + 0x80);
+ Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].EndDriveNumber = LocalDiskStart;
+ Private->LegacyEfiHddTableIndex++;
+ Private->Disk4075 = (UINT8)(LocalDiskStart & 0x7f);
+ Private->DiskEnd = LocalDiskStart;
+ }
if (PciHandle != mVgaHandle) {
+ EnablePs2Keyboard ();
- EnablePs2Keyboard ();
+ //
+ // Store current mode settings since PrepareToScanRom may change mode.
+ //
+ VideoMode = *(UINT8 *)((UINTN)(0x400 + BDA_VIDEO_MODE));
+ }
- //
- // Store current mode settings since PrepareToScanRom may change mode.
- //
- VideoMode = *(UINT8 *) ((UINTN) (0x400 + BDA_VIDEO_MODE));
- }
- );
+ );
//
// Notify the platform that we are about to scan the ROM
@@ -2466,9 +2486,9 @@ LegacyBiosInstallRom (
//
ACCESS_PAGE0_CODE (
LocalTime = (LocalTime * 182) / 10;
- BdaPtr = (UINT32 *) ((UINTN) 0x46C);
+ BdaPtr = (UINT32 *)((UINTN)0x46C);
*BdaPtr = LocalTime;
- );
+ );
//
// Pass in handoff data
@@ -2476,11 +2496,10 @@ LegacyBiosInstallRom (
PciEnableStatus = EFI_UNSUPPORTED;
ZeroMem (&Regs, sizeof (Regs));
if (PciHandle != NULL) {
-
Status = gBS->HandleProtocol (
PciHandle,
&gEfiPciIoProtocolGuid,
- (VOID **) &PciIo
+ (VOID **)&PciIo
);
ASSERT_EFI_ERROR (Status);
@@ -2504,23 +2523,23 @@ LegacyBiosInstallRom (
DEBUG ((DEBUG_INFO, "Shadowing OpROM on the PCI device %x/%x/%x\n", Bus, Device, Function));
}
- mIgnoreBbsUpdateFlag = FALSE;
- Regs.X.AX = Legacy16DispatchOprom;
+ mIgnoreBbsUpdateFlag = FALSE;
+ Regs.X.AX = Legacy16DispatchOprom;
//
// Generate DispatchOpRomTable data
//
Private->IntThunk->DispatchOpromTable.PnPInstallationCheckSegment = Private->Legacy16Table->PnPInstallationCheckSegment;
Private->IntThunk->DispatchOpromTable.PnPInstallationCheckOffset = Private->Legacy16Table->PnPInstallationCheckOffset;
- Private->IntThunk->DispatchOpromTable.OpromSegment = (UINT16) (InitAddress >> 4);
- Private->IntThunk->DispatchOpromTable.PciBus = (UINT8) Bus;
- Private->IntThunk->DispatchOpromTable.PciDeviceFunction = (UINT8) ((Device << 3) | Function);
- Private->IntThunk->DispatchOpromTable.NumberBbsEntries = (UINT8) Private->IntThunk->EfiToLegacy16BootTable.NumberBbsEntries;
- Private->IntThunk->DispatchOpromTable.BbsTablePointer = (UINT32) (UINTN) Private->BbsTablePtr;
+ Private->IntThunk->DispatchOpromTable.OpromSegment = (UINT16)(InitAddress >> 4);
+ Private->IntThunk->DispatchOpromTable.PciBus = (UINT8)Bus;
+ Private->IntThunk->DispatchOpromTable.PciDeviceFunction = (UINT8)((Device << 3) | Function);
+ Private->IntThunk->DispatchOpromTable.NumberBbsEntries = (UINT8)Private->IntThunk->EfiToLegacy16BootTable.NumberBbsEntries;
+ Private->IntThunk->DispatchOpromTable.BbsTablePointer = (UINT32)(UINTN)Private->BbsTablePtr;
Private->IntThunk->DispatchOpromTable.RuntimeSegment = (UINT16)((OpromRevision < 3) ? 0xffff : (RuntimeAddress >> 4));
- TempData = (UINTN) &Private->IntThunk->DispatchOpromTable;
- Regs.X.ES = EFI_SEGMENT ((UINT32) TempData);
- Regs.X.BX = EFI_OFFSET ((UINT32) TempData);
+ TempData = (UINTN)&Private->IntThunk->DispatchOpromTable;
+ Regs.X.ES = EFI_SEGMENT ((UINT32)TempData);
+ Regs.X.BX = EFI_OFFSET ((UINT32)TempData);
//
// Skip dispatching ROM for those PCI devices that can not be enabled by PciIo->Attributes
// Otherwise, it may cause the system to hang in some cases
@@ -2528,35 +2547,37 @@ LegacyBiosInstallRom (
if (!EFI_ERROR (PciEnableStatus)) {
DEBUG ((DEBUG_INFO, " Legacy16DispatchOprom - %02x/%02x/%02x\n", Bus, Device, Function));
Private->LegacyBios.FarCall86 (
- &Private->LegacyBios,
- Private->Legacy16CallSegment,
- Private->Legacy16CallOffset,
- &Regs,
- NULL,
- 0
- );
+ &Private->LegacyBios,
+ Private->Legacy16CallSegment,
+ Private->Legacy16CallOffset,
+ &Regs,
+ NULL,
+ 0
+ );
} else {
Regs.X.BX = 0;
}
- if (Private->IntThunk->DispatchOpromTable.NumberBbsEntries != (UINT8) Private->IntThunk->EfiToLegacy16BootTable.NumberBbsEntries) {
- Private->IntThunk->EfiToLegacy16BootTable.NumberBbsEntries = (UINT8) Private->IntThunk->DispatchOpromTable.NumberBbsEntries;
- mIgnoreBbsUpdateFlag = TRUE;
+ if (Private->IntThunk->DispatchOpromTable.NumberBbsEntries != (UINT8)Private->IntThunk->EfiToLegacy16BootTable.NumberBbsEntries) {
+ Private->IntThunk->EfiToLegacy16BootTable.NumberBbsEntries = (UINT8)Private->IntThunk->DispatchOpromTable.NumberBbsEntries;
+ mIgnoreBbsUpdateFlag = TRUE;
}
+
//
// Check if non-BBS compliant drives found
//
if (Regs.X.BX != 0) {
- LocalDiskEnd = (UINT8) (LocalDiskStart + Regs.H.BL);
- Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciSegment = (UINT8) Segment;
- Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciBus = (UINT8) Bus;
- Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciDevice = (UINT8) Device;
- Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciFunction = (UINT8) Function;
- Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].StartDriveNumber = Private->DiskEnd;
- Private->DiskEnd = LocalDiskEnd;
- Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].EndDriveNumber = Private->DiskEnd;
- Private->LegacyEfiHddTableIndex += 1;
+ LocalDiskEnd = (UINT8)(LocalDiskStart + Regs.H.BL);
+ Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciSegment = (UINT8)Segment;
+ Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciBus = (UINT8)Bus;
+ Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciDevice = (UINT8)Device;
+ Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciFunction = (UINT8)Function;
+ Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].StartDriveNumber = Private->DiskEnd;
+ Private->DiskEnd = LocalDiskEnd;
+ Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].EndDriveNumber = Private->DiskEnd;
+ Private->LegacyEfiHddTableIndex += 1;
}
+
//
// Skip video mode set, if installing VGA
//
@@ -2564,9 +2585,11 @@ LegacyBiosInstallRom (
//
// Set mode settings since PrepareToScanRom may change mode
//
- ACCESS_PAGE0_CODE ({
- OldVideoMode = *(UINT8 *) ((UINTN) (0x400 + BDA_VIDEO_MODE));
- });
+ ACCESS_PAGE0_CODE (
+ {
+ OldVideoMode = *(UINT8 *)((UINTN)(0x400 + BDA_VIDEO_MODE));
+ }
+ );
if (VideoMode != OldVideoMode) {
//
@@ -2577,6 +2600,7 @@ LegacyBiosInstallRom (
Private->LegacyBios.Int86 (&Private->LegacyBios, 0x10, &Regs);
}
}
+
//
// Regs.X.AX from the adapter initializion is ignored since some adapters
// do not follow the standard of setting AX = 0 on success.
@@ -2584,14 +2608,14 @@ LegacyBiosInstallRom (
//
// The ROM could have updated its size so we need to read again.
//
- if (((EFI_LEGACY_EXPANSION_ROM_HEADER *) RuntimeAddress)->Signature != PCI_EXPANSION_ROM_HEADER_SIGNATURE) {
+ if (((EFI_LEGACY_EXPANSION_ROM_HEADER *)RuntimeAddress)->Signature != PCI_EXPANSION_ROM_HEADER_SIGNATURE) {
//
// Now we check the signature (0xaa55) to judge whether the run-time code is truly generated by INIT function.
// If signature is not valid, that means the INIT function didn't copy the run-time code to RuntimeAddress.
//
*RuntimeImageLength = 0;
} else {
- *RuntimeImageLength = ((EFI_LEGACY_EXPANSION_ROM_HEADER *) RuntimeAddress)->Size512 * 512;
+ *RuntimeImageLength = ((EFI_LEGACY_EXPANSION_ROM_HEADER *)RuntimeAddress)->Size512 * 512;
}
DEBUG ((DEBUG_INFO, " fsize = %x\n", *RuntimeImageLength));
@@ -2604,13 +2628,13 @@ LegacyBiosInstallRom (
//
// Make area from end of shadowed rom to end of original rom all ffs
//
- gBS->SetMem ((VOID *) (InitAddress + *RuntimeImageLength), ImageSize - *RuntimeImageLength, 0xff);
+ gBS->SetMem ((VOID *)(InitAddress + *RuntimeImageLength), ImageSize - *RuntimeImageLength, 0xff);
}
}
ACCESS_PAGE0_CODE (
- LocalDiskEnd = (UINT8) ((*(UINT8 *) ((UINTN) 0x475)) + 0x80);
- );
+ LocalDiskEnd = (UINT8)((*(UINT8 *)((UINTN)0x475)) + 0x80);
+ );
//
// Allow platform to perform any required actions after the
@@ -2634,29 +2658,30 @@ LegacyBiosInstallRom (
TempData = RuntimeAddress;
UpdateBevBcvTable (
Private,
- (EFI_LEGACY_EXPANSION_ROM_HEADER *) TempData,
+ (EFI_LEGACY_EXPANSION_ROM_HEADER *)TempData,
PciIo
);
- EndBbsIndex = Private->IntThunk->EfiToLegacy16BootTable.NumberBbsEntries;
- LocalDiskEnd = (UINT8) (LocalDiskStart + (UINT8) (EndBbsIndex - StartBbsIndex));
+ EndBbsIndex = Private->IntThunk->EfiToLegacy16BootTable.NumberBbsEntries;
+ LocalDiskEnd = (UINT8)(LocalDiskStart + (UINT8)(EndBbsIndex - StartBbsIndex));
if (LocalDiskEnd != LocalDiskStart) {
- Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciSegment = (UINT8) Segment;
- Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciBus = (UINT8) Bus;
- Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciDevice = (UINT8) Device;
- Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciFunction = (UINT8) Function;
- Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].StartDriveNumber = Private->DiskEnd;
- Private->DiskEnd = LocalDiskEnd;
- Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].EndDriveNumber = Private->DiskEnd;
- Private->LegacyEfiHddTableIndex += 1;
+ Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciSegment = (UINT8)Segment;
+ Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciBus = (UINT8)Bus;
+ Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciDevice = (UINT8)Device;
+ Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciFunction = (UINT8)Function;
+ Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].StartDriveNumber = Private->DiskEnd;
+ Private->DiskEnd = LocalDiskEnd;
+ Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].EndDriveNumber = Private->DiskEnd;
+ Private->LegacyEfiHddTableIndex += 1;
}
}
+
//
// Mark PCI device as having a legacy BIOS ROM loaded.
//
RomShadow (
PciHandle,
- (UINT32) RuntimeAddress,
- (UINT32) *RuntimeImageLength,
+ (UINT32)RuntimeAddress,
+ (UINT32)*RuntimeImageLength,
LocalDiskStart,
LocalDiskEnd
);
@@ -2666,7 +2691,7 @@ LegacyBiosInstallRom (
// Stuff caller's OPTIONAL return parameters.
//
if (RomShadowAddress != NULL) {
- *RomShadowAddress = (VOID *) RuntimeAddress;
+ *RomShadowAddress = (VOID *)RuntimeAddress;
}
if (DiskStart != NULL) {
@@ -2677,7 +2702,7 @@ LegacyBiosInstallRom (
*DiskEnd = LocalDiskEnd;
}
- Private->OptionRom = (UINT32) (RuntimeAddress + *RuntimeImageLength);
+ Private->OptionRom = (UINT32)(RuntimeAddress + *RuntimeImageLength);
Status = EFI_SUCCESS;
@@ -2713,14 +2738,14 @@ Done:
**/
EFI_STATUS
IoMmuGrantAccess (
- IN EFI_HANDLE PciHandle,
- IN EFI_PHYSICAL_ADDRESS HostAddress,
- IN UINTN NumberOfBytes
+ IN EFI_HANDLE PciHandle,
+ IN EFI_PHYSICAL_ADDRESS HostAddress,
+ IN UINTN NumberOfBytes
)
{
- EFI_PHYSICAL_ADDRESS DeviceAddress;
- VOID *Mapping;
- EFI_STATUS Status;
+ EFI_PHYSICAL_ADDRESS DeviceAddress;
+ VOID *Mapping;
+ EFI_STATUS Status;
if (PciHandle == NULL) {
return EFI_UNSUPPORTED;
@@ -2730,6 +2755,7 @@ IoMmuGrantAccess (
if (mIoMmu == NULL) {
gBS->LocateProtocol (&gEdkiiIoMmuProtocolGuid, NULL, (VOID **)&mIoMmu);
}
+
if (mIoMmu != NULL) {
Status = mIoMmu->Map (
mIoMmu,
@@ -2739,7 +2765,7 @@ IoMmuGrantAccess (
&DeviceAddress,
&Mapping
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "LegacyPci - IoMmuMap - %r\n", Status));
} else {
ASSERT (DeviceAddress == HostAddress);
@@ -2749,11 +2775,12 @@ IoMmuGrantAccess (
Mapping,
EDKII_IOMMU_ACCESS_READ | EDKII_IOMMU_ACCESS_WRITE
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "LegacyPci - IoMmuSetAttribute - %r\n", Status));
}
}
}
+
return Status;
}
@@ -2787,34 +2814,34 @@ IoMmuGrantAccess (
EFI_STATUS
EFIAPI
LegacyBiosInstallPciRom (
- IN EFI_LEGACY_BIOS_PROTOCOL * This,
- IN EFI_HANDLE PciHandle,
- IN VOID **RomImage,
- OUT UINTN *Flags,
- OUT UINT8 *DiskStart OPTIONAL,
- OUT UINT8 *DiskEnd OPTIONAL,
- OUT VOID **RomShadowAddress OPTIONAL,
- OUT UINT32 *RomShadowedSize OPTIONAL
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,
+ IN EFI_HANDLE PciHandle,
+ IN VOID **RomImage,
+ OUT UINTN *Flags,
+ OUT UINT8 *DiskStart OPTIONAL,
+ OUT UINT8 *DiskEnd OPTIONAL,
+ OUT VOID **RomShadowAddress OPTIONAL,
+ OUT UINT32 *RomShadowedSize OPTIONAL
)
{
- EFI_STATUS Status;
- LEGACY_BIOS_INSTANCE *Private;
- VOID *LocalRomImage;
- UINTN ImageSize;
- UINTN RuntimeImageLength;
- EFI_PCI_IO_PROTOCOL *PciIo;
- PCI_TYPE01 PciConfigHeader;
- UINTN HandleCount;
- EFI_HANDLE *HandleBuffer;
- UINTN PciSegment;
- UINTN PciBus;
- UINTN PciDevice;
- UINTN PciFunction;
- UINTN LastBus;
- UINTN Index;
- UINT8 OpromRevision;
- UINT32 Granularity;
- PCI_3_0_DATA_STRUCTURE *Pcir;
+ EFI_STATUS Status;
+ LEGACY_BIOS_INSTANCE *Private;
+ VOID *LocalRomImage;
+ UINTN ImageSize;
+ UINTN RuntimeImageLength;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ PCI_TYPE01 PciConfigHeader;
+ UINTN HandleCount;
+ EFI_HANDLE *HandleBuffer;
+ UINTN PciSegment;
+ UINTN PciBus;
+ UINTN PciDevice;
+ UINTN PciFunction;
+ UINTN LastBus;
+ UINTN Index;
+ UINT8 OpromRevision;
+ UINT32 Granularity;
+ PCI_3_0_DATA_STRUCTURE *Pcir;
OpromRevision = 0;
@@ -2836,7 +2863,7 @@ LegacyBiosInstallPciRom (
Status = gBS->HandleProtocol (
HandleBuffer[Index],
&gEfiPciIoProtocolGuid,
- (VOID **) &PciIo
+ (VOID **)&PciIo
);
if (EFI_ERROR (Status)) {
continue;
@@ -2860,7 +2887,7 @@ LegacyBiosInstallPciRom (
0x20000,
&Granularity
);
- Private->Legacy16Table->LastPciBus = (UINT8) LastBus;
+ Private->Legacy16Table->LastPciBus = (UINT8)LastBus;
Private->LegacyRegion->Lock (
Private->LegacyRegion,
0xE0000,
@@ -2878,7 +2905,7 @@ LegacyBiosInstallPciRom (
Status = gBS->HandleProtocol (
PciHandle,
&gEfiPciIoProtocolGuid,
- (VOID **) &PciIo
+ (VOID **)&PciIo
);
if (!EFI_ERROR (Status)) {
@@ -2894,16 +2921,17 @@ LegacyBiosInstallPciRom (
// if video installed & OPROM is video return
//
if (
- (
- ((PciConfigHeader.Hdr.ClassCode[2] == PCI_CLASS_OLD) &&
- (PciConfigHeader.Hdr.ClassCode[1] == PCI_CLASS_OLD_VGA))
- ||
- ((PciConfigHeader.Hdr.ClassCode[2] == PCI_CLASS_DISPLAY) &&
- (PciConfigHeader.Hdr.ClassCode[1] == PCI_CLASS_DISPLAY_VGA))
- )
- &&
- (!Private->VgaInstalled)
- ) {
+ (
+ ((PciConfigHeader.Hdr.ClassCode[2] == PCI_CLASS_OLD) &&
+ (PciConfigHeader.Hdr.ClassCode[1] == PCI_CLASS_OLD_VGA))
+ ||
+ ((PciConfigHeader.Hdr.ClassCode[2] == PCI_CLASS_DISPLAY) &&
+ (PciConfigHeader.Hdr.ClassCode[1] == PCI_CLASS_DISPLAY_VGA))
+ )
+ &&
+ (!Private->VgaInstalled)
+ )
+ {
mVgaInstallationInProgress = TRUE;
//
@@ -2911,6 +2939,7 @@ LegacyBiosInstallPciRom (
//
}
}
+
//
// To run any legacy image, the VGA needs to be installed first.
// if installing the video, then don't need the thunk as already installed.
@@ -2931,8 +2960,8 @@ LegacyBiosInstallPciRom (
// A return status of EFI_NOT_FOUND is considered valid (No EFI
// driver is controlling video.
//
- mVgaInstallationInProgress = TRUE;
- Status = LegacyBiosInstallVgaRom (Private);
+ mVgaInstallationInProgress = TRUE;
+ Status = LegacyBiosInstallVgaRom (Private);
if (EFI_ERROR (Status)) {
if (Status != EFI_NOT_FOUND) {
mVgaInstallationInProgress = FALSE;
@@ -2943,6 +2972,7 @@ LegacyBiosInstallPciRom (
}
}
}
+
//
// See if the option ROM for PciHandle has already been executed
//
@@ -2955,7 +2985,7 @@ LegacyBiosInstallPciRom (
DiskStart,
DiskEnd,
RomShadowAddress,
- (UINTN *) RomShadowedSize
+ (UINTN *)RomShadowedSize
);
return EFI_SUCCESS;
}
@@ -2999,8 +3029,8 @@ LegacyBiosInstallPciRom (
// A return status of EFI_NOT_FOUND is considered valid (No EFI
// driver is controlling video.
//
- mVgaInstallationInProgress = TRUE;
- Status = LegacyBiosInstallVgaRom (Private);
+ mVgaInstallationInProgress = TRUE;
+ Status = LegacyBiosInstallVgaRom (Private);
if (EFI_ERROR (Status)) {
if (Status != EFI_NOT_FOUND) {
mVgaInstallationInProgress = FALSE;
@@ -3012,15 +3042,16 @@ LegacyBiosInstallPciRom (
}
LocalRomImage = *RomImage;
- if (((PCI_EXPANSION_ROM_HEADER *) LocalRomImage)->Signature != PCI_EXPANSION_ROM_HEADER_SIGNATURE ||
- ((PCI_EXPANSION_ROM_HEADER *) LocalRomImage)->PcirOffset == 0 ||
- (((PCI_EXPANSION_ROM_HEADER *) LocalRomImage)->PcirOffset & 3 ) != 0) {
+ if ((((PCI_EXPANSION_ROM_HEADER *)LocalRomImage)->Signature != PCI_EXPANSION_ROM_HEADER_SIGNATURE) ||
+ (((PCI_EXPANSION_ROM_HEADER *)LocalRomImage)->PcirOffset == 0) ||
+ ((((PCI_EXPANSION_ROM_HEADER *)LocalRomImage)->PcirOffset & 3) != 0))
+ {
mVgaInstallationInProgress = FALSE;
return EFI_UNSUPPORTED;
}
Pcir = (PCI_3_0_DATA_STRUCTURE *)
- ((UINT8 *) LocalRomImage + ((PCI_EXPANSION_ROM_HEADER *) LocalRomImage)->PcirOffset);
+ ((UINT8 *)LocalRomImage + ((PCI_EXPANSION_ROM_HEADER *)LocalRomImage)->PcirOffset);
if ((Pcir->Signature != PCI_DATA_STRUCTURE_SIGNATURE) || (Pcir->CodeType != PCI_CODE_TYPE_PCAT_IMAGE)) {
mVgaInstallationInProgress = FALSE;
@@ -3033,6 +3064,7 @@ LegacyBiosInstallPciRom (
} else {
OpromRevision = 0;
}
+
if (Pcir->Revision < 3) {
RuntimeImageLength = 0;
} else {
@@ -3059,22 +3091,22 @@ LegacyBiosInstallPciRom (
//
ASSERT (Private->TraceIndex < 0x200);
Private->Trace[Private->TraceIndex] = LEGACY_PCI_TRACE_000;
- Private->TraceIndex ++;
- Private->TraceIndex = (UINT16) (Private->TraceIndex % 0x200);
- Status = LegacyBiosInstallRom (
- This,
- Private,
- PciHandle,
- OpromRevision,
- LocalRomImage,
- ImageSize,
- &RuntimeImageLength,
- DiskStart,
- DiskEnd,
- RomShadowAddress
- );
+ Private->TraceIndex++;
+ Private->TraceIndex = (UINT16)(Private->TraceIndex % 0x200);
+ Status = LegacyBiosInstallRom (
+ This,
+ Private,
+ PciHandle,
+ OpromRevision,
+ LocalRomImage,
+ ImageSize,
+ &RuntimeImageLength,
+ DiskStart,
+ DiskEnd,
+ RomShadowAddress
+ );
if (RomShadowedSize != NULL) {
- *RomShadowedSize = (UINT32) RuntimeImageLength;
+ *RomShadowedSize = (UINT32)RuntimeImageLength;
}
mVgaInstallationInProgress = FALSE;
diff --git a/OvmfPkg/Csm/LegacyBiosDxe/LegacySio.c b/OvmfPkg/Csm/LegacyBiosDxe/LegacySio.c
index 6b9bb5ed8b..0cb48fa8ab 100644
--- a/OvmfPkg/Csm/LegacyBiosDxe/LegacySio.c
+++ b/OvmfPkg/Csm/LegacyBiosDxe/LegacySio.c
@@ -21,32 +21,32 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
EFI_STATUS
LegacyBiosBuildSioDataFromSio (
- IN DEVICE_PRODUCER_DATA_HEADER *SioPtr
+ IN DEVICE_PRODUCER_DATA_HEADER *SioPtr
)
{
- EFI_STATUS Status;
- DEVICE_PRODUCER_SERIAL *SioSerial;
- DEVICE_PRODUCER_PARALLEL *SioParallel;
- DEVICE_PRODUCER_FLOPPY *SioFloppy;
- UINTN HandleCount;
- EFI_HANDLE *HandleBuffer;
- UINTN Index;
- UINTN ChildIndex;
- EFI_SIO_PROTOCOL *Sio;
- ACPI_RESOURCE_HEADER_PTR Resources;
- EFI_ACPI_IO_PORT_DESCRIPTOR *IoResource;
- EFI_ACPI_FIXED_LOCATION_IO_PORT_DESCRIPTOR *FixedIoResource;
- EFI_ACPI_DMA_DESCRIPTOR *DmaResource;
- EFI_ACPI_IRQ_NOFLAG_DESCRIPTOR *IrqResource;
- UINT16 Address;
- UINT8 Dma;
- UINT8 Irq;
- UINTN EntryCount;
- EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;
- EFI_BLOCK_IO_PROTOCOL *BlockIo;
- EFI_SERIAL_IO_PROTOCOL *SerialIo;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- ACPI_HID_DEVICE_PATH *Acpi;
+ EFI_STATUS Status;
+ DEVICE_PRODUCER_SERIAL *SioSerial;
+ DEVICE_PRODUCER_PARALLEL *SioParallel;
+ DEVICE_PRODUCER_FLOPPY *SioFloppy;
+ UINTN HandleCount;
+ EFI_HANDLE *HandleBuffer;
+ UINTN Index;
+ UINTN ChildIndex;
+ EFI_SIO_PROTOCOL *Sio;
+ ACPI_RESOURCE_HEADER_PTR Resources;
+ EFI_ACPI_IO_PORT_DESCRIPTOR *IoResource;
+ EFI_ACPI_FIXED_LOCATION_IO_PORT_DESCRIPTOR *FixedIoResource;
+ EFI_ACPI_DMA_DESCRIPTOR *DmaResource;
+ EFI_ACPI_IRQ_NOFLAG_DESCRIPTOR *IrqResource;
+ UINT16 Address;
+ UINT8 Dma;
+ UINT8 Irq;
+ UINTN EntryCount;
+ EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;
+ EFI_SERIAL_IO_PROTOCOL *SerialIo;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ ACPI_HID_DEVICE_PATH *Acpi;
//
// Get the list of ISA controllers in the system
@@ -61,11 +61,12 @@ LegacyBiosBuildSioDataFromSio (
if (EFI_ERROR (Status)) {
return EFI_NOT_FOUND;
}
+
//
// Collect legacy information from each of the ISA controllers in the system
//
for (Index = 0; Index < HandleCount; Index++) {
- Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiSioProtocolGuid, (VOID **) &Sio);
+ Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiSioProtocolGuid, (VOID **)&Sio);
if (EFI_ERROR (Status)) {
continue;
}
@@ -73,46 +74,46 @@ LegacyBiosBuildSioDataFromSio (
Address = MAX_UINT16;
Dma = MAX_UINT8;
Irq = MAX_UINT8;
- Status = Sio->GetResources (Sio, &Resources);
+ Status = Sio->GetResources (Sio, &Resources);
if (!EFI_ERROR (Status)) {
//
// Get the base address information from ACPI resource descriptor.
//
while (Resources.SmallHeader->Byte != ACPI_END_TAG_DESCRIPTOR) {
switch (Resources.SmallHeader->Byte) {
- case ACPI_IO_PORT_DESCRIPTOR:
- IoResource = (EFI_ACPI_IO_PORT_DESCRIPTOR *) Resources.SmallHeader;
- Address = IoResource->BaseAddressMin;
- break;
-
- case ACPI_FIXED_LOCATION_IO_PORT_DESCRIPTOR:
- FixedIoResource = (EFI_ACPI_FIXED_LOCATION_IO_PORT_DESCRIPTOR *) Resources.SmallHeader;
- Address = FixedIoResource->BaseAddress;
- break;
-
- case ACPI_DMA_DESCRIPTOR:
- DmaResource = (EFI_ACPI_DMA_DESCRIPTOR *) Resources.SmallHeader;
- Dma = (UINT8) LowBitSet32 (DmaResource->ChannelMask);
- break;
-
- case ACPI_IRQ_DESCRIPTOR:
- case ACPI_IRQ_NOFLAG_DESCRIPTOR:
- IrqResource = (EFI_ACPI_IRQ_NOFLAG_DESCRIPTOR *) Resources.SmallHeader;
- Irq = (UINT8) LowBitSet32 (IrqResource->Mask);
- break;
-
- default:
- break;
+ case ACPI_IO_PORT_DESCRIPTOR:
+ IoResource = (EFI_ACPI_IO_PORT_DESCRIPTOR *)Resources.SmallHeader;
+ Address = IoResource->BaseAddressMin;
+ break;
+
+ case ACPI_FIXED_LOCATION_IO_PORT_DESCRIPTOR:
+ FixedIoResource = (EFI_ACPI_FIXED_LOCATION_IO_PORT_DESCRIPTOR *)Resources.SmallHeader;
+ Address = FixedIoResource->BaseAddress;
+ break;
+
+ case ACPI_DMA_DESCRIPTOR:
+ DmaResource = (EFI_ACPI_DMA_DESCRIPTOR *)Resources.SmallHeader;
+ Dma = (UINT8)LowBitSet32 (DmaResource->ChannelMask);
+ break;
+
+ case ACPI_IRQ_DESCRIPTOR:
+ case ACPI_IRQ_NOFLAG_DESCRIPTOR:
+ IrqResource = (EFI_ACPI_IRQ_NOFLAG_DESCRIPTOR *)Resources.SmallHeader;
+ Irq = (UINT8)LowBitSet32 (IrqResource->Mask);
+ break;
+
+ default:
+ break;
}
if (Resources.SmallHeader->Bits.Type == 0) {
- Resources.SmallHeader = (ACPI_SMALL_RESOURCE_HEADER *) ((UINT8 *) Resources.SmallHeader
- + Resources.SmallHeader->Bits.Length
- + sizeof (*Resources.SmallHeader));
+ Resources.SmallHeader = (ACPI_SMALL_RESOURCE_HEADER *)((UINT8 *)Resources.SmallHeader
+ + Resources.SmallHeader->Bits.Length
+ + sizeof (*Resources.SmallHeader));
} else {
- Resources.LargeHeader = (ACPI_LARGE_RESOURCE_HEADER *) ((UINT8 *) Resources.LargeHeader
- + Resources.LargeHeader->Length
- + sizeof (*Resources.LargeHeader));
+ Resources.LargeHeader = (ACPI_LARGE_RESOURCE_HEADER *)((UINT8 *)Resources.LargeHeader
+ + Resources.LargeHeader->Length
+ + sizeof (*Resources.LargeHeader));
}
}
}
@@ -126,13 +127,14 @@ LegacyBiosBuildSioDataFromSio (
Acpi = NULL;
while (!IsDevicePathEnd (DevicePath)) {
- Acpi = (ACPI_HID_DEVICE_PATH *) DevicePath;
+ Acpi = (ACPI_HID_DEVICE_PATH *)DevicePath;
DevicePath = NextDevicePathNode (DevicePath);
}
if ((Acpi == NULL) || (DevicePathType (Acpi) != ACPI_DEVICE_PATH) ||
((DevicePathSubType (Acpi) != ACPI_DP) && (DevicePathSubType (Acpi) != ACPI_EXTENDED_DP))
- ) {
+ )
+ {
continue;
}
@@ -141,9 +143,8 @@ LegacyBiosBuildSioDataFromSio (
//
// Ignore DMA resource since it is always returned NULL
//
- if (Acpi->HID == EISA_PNP_ID (0x500) || Acpi->HID == EISA_PNP_ID (0x501)) {
-
- if (Acpi->UID < 4 && Address != MAX_UINT16 && Irq != MAX_UINT8) {
+ if ((Acpi->HID == EISA_PNP_ID (0x500)) || (Acpi->HID == EISA_PNP_ID (0x501))) {
+ if ((Acpi->UID < 4) && (Address != MAX_UINT16) && (Irq != MAX_UINT8)) {
//
// Get the handle of the child device that has opened the Super I/O Protocol
//
@@ -156,14 +157,15 @@ LegacyBiosBuildSioDataFromSio (
if (EFI_ERROR (Status)) {
continue;
}
+
for (ChildIndex = 0; ChildIndex < EntryCount; ChildIndex++) {
if ((OpenInfoBuffer[ChildIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
- Status = gBS->HandleProtocol (OpenInfoBuffer[ChildIndex].ControllerHandle, &gEfiSerialIoProtocolGuid, (VOID **) &SerialIo);
+ Status = gBS->HandleProtocol (OpenInfoBuffer[ChildIndex].ControllerHandle, &gEfiSerialIoProtocolGuid, (VOID **)&SerialIo);
if (!EFI_ERROR (Status)) {
- SioSerial = &SioPtr->Serial[Acpi->UID];
- SioSerial->Address = Address;
- SioSerial->Irq = Irq;
- SioSerial->Mode = DEVICE_SERIAL_MODE_NORMAL | DEVICE_SERIAL_MODE_DUPLEX_HALF;
+ SioSerial = &SioPtr->Serial[Acpi->UID];
+ SioSerial->Address = Address;
+ SioSerial->Irq = Irq;
+ SioSerial->Mode = DEVICE_SERIAL_MODE_NORMAL | DEVICE_SERIAL_MODE_DUPLEX_HALF;
break;
}
}
@@ -172,36 +174,39 @@ LegacyBiosBuildSioDataFromSio (
FreePool (OpenInfoBuffer);
}
}
+
//
// See if this is an ISA parallel port
//
// Ignore DMA resource since it is always returned NULL, port
// only used in output mode.
//
- if (Acpi->HID == EISA_PNP_ID (0x400) || Acpi->HID == EISA_PNP_ID (0x401)) {
- if (Acpi->UID < 3 && Address != MAX_UINT16 && Irq != MAX_UINT8 && Dma != MAX_UINT8) {
- SioParallel = &SioPtr->Parallel[Acpi->UID];
- SioParallel->Address = Address;
- SioParallel->Irq = Irq;
- SioParallel->Dma = Dma;
- SioParallel->Mode = DEVICE_PARALLEL_MODE_MODE_OUTPUT_ONLY;
+ if ((Acpi->HID == EISA_PNP_ID (0x400)) || (Acpi->HID == EISA_PNP_ID (0x401))) {
+ if ((Acpi->UID < 3) && (Address != MAX_UINT16) && (Irq != MAX_UINT8) && (Dma != MAX_UINT8)) {
+ SioParallel = &SioPtr->Parallel[Acpi->UID];
+ SioParallel->Address = Address;
+ SioParallel->Irq = Irq;
+ SioParallel->Dma = Dma;
+ SioParallel->Mode = DEVICE_PARALLEL_MODE_MODE_OUTPUT_ONLY;
}
}
+
//
// See if this is an ISA floppy controller
//
if (Acpi->HID == EISA_PNP_ID (0x604)) {
- if (Address != MAX_UINT16 && Irq != MAX_UINT8 && Dma != MAX_UINT8) {
- Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiBlockIoProtocolGuid, (VOID **) &BlockIo);
+ if ((Address != MAX_UINT16) && (Irq != MAX_UINT8) && (Dma != MAX_UINT8)) {
+ Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiBlockIoProtocolGuid, (VOID **)&BlockIo);
if (!EFI_ERROR (Status)) {
- SioFloppy = &SioPtr->Floppy;
- SioFloppy->Address = Address;
- SioFloppy->Irq = Irq;
- SioFloppy->Dma = Dma;
+ SioFloppy = &SioPtr->Floppy;
+ SioFloppy->Address = Address;
+ SioFloppy->Irq = Irq;
+ SioFloppy->Dma = Dma;
SioFloppy->NumberOfFloppy++;
}
}
}
+
//
// See if this is a mouse
// Always set mouse found so USB hot plug will work
@@ -225,7 +230,6 @@ LegacyBiosBuildSioDataFromSio (
FreePool (HandleBuffer);
return EFI_SUCCESS;
-
}
/**
@@ -239,27 +243,27 @@ LegacyBiosBuildSioDataFromSio (
**/
EFI_STATUS
LegacyBiosBuildSioDataFromIsaIo (
- IN DEVICE_PRODUCER_DATA_HEADER *SioPtr
+ IN DEVICE_PRODUCER_DATA_HEADER *SioPtr
)
{
- EFI_STATUS Status;
- DEVICE_PRODUCER_SERIAL *SioSerial;
- DEVICE_PRODUCER_PARALLEL *SioParallel;
- DEVICE_PRODUCER_FLOPPY *SioFloppy;
- UINTN HandleCount;
- EFI_HANDLE *HandleBuffer;
- UINTN Index;
- UINTN ResourceIndex;
- UINTN ChildIndex;
- EFI_ISA_IO_PROTOCOL *IsaIo;
- EFI_ISA_ACPI_RESOURCE_LIST *ResourceList;
- EFI_ISA_ACPI_RESOURCE *IoResource;
- EFI_ISA_ACPI_RESOURCE *DmaResource;
- EFI_ISA_ACPI_RESOURCE *InterruptResource;
- UINTN EntryCount;
- EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;
- EFI_BLOCK_IO_PROTOCOL *BlockIo;
- EFI_SERIAL_IO_PROTOCOL *SerialIo;
+ EFI_STATUS Status;
+ DEVICE_PRODUCER_SERIAL *SioSerial;
+ DEVICE_PRODUCER_PARALLEL *SioParallel;
+ DEVICE_PRODUCER_FLOPPY *SioFloppy;
+ UINTN HandleCount;
+ EFI_HANDLE *HandleBuffer;
+ UINTN Index;
+ UINTN ResourceIndex;
+ UINTN ChildIndex;
+ EFI_ISA_IO_PROTOCOL *IsaIo;
+ EFI_ISA_ACPI_RESOURCE_LIST *ResourceList;
+ EFI_ISA_ACPI_RESOURCE *IoResource;
+ EFI_ISA_ACPI_RESOURCE *DmaResource;
+ EFI_ISA_ACPI_RESOURCE *InterruptResource;
+ UINTN EntryCount;
+ EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;
+ EFI_SERIAL_IO_PROTOCOL *SerialIo;
//
// Get the list of ISA controllers in the system
@@ -274,12 +278,12 @@ LegacyBiosBuildSioDataFromIsaIo (
if (EFI_ERROR (Status)) {
return EFI_NOT_FOUND;
}
+
//
// Collect legacy information from each of the ISA controllers in the system
//
for (Index = 0; Index < HandleCount; Index++) {
-
- Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiIsaIoProtocolGuid, (VOID **) &IsaIo);
+ Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiIsaIoProtocolGuid, (VOID **)&IsaIo);
if (EFI_ERROR (Status)) {
continue;
}
@@ -289,6 +293,7 @@ LegacyBiosBuildSioDataFromIsaIo (
if (ResourceList == NULL) {
continue;
}
+
//
// Collect the resource types neededto fill in the SIO data structure
//
@@ -298,38 +303,40 @@ LegacyBiosBuildSioDataFromIsaIo (
for (ResourceIndex = 0;
ResourceList->ResourceItem[ResourceIndex].Type != EfiIsaAcpiResourceEndOfList;
ResourceIndex++
- ) {
+ )
+ {
switch (ResourceList->ResourceItem[ResourceIndex].Type) {
- case EfiIsaAcpiResourceIo:
- IoResource = &ResourceList->ResourceItem[ResourceIndex];
- break;
+ case EfiIsaAcpiResourceIo:
+ IoResource = &ResourceList->ResourceItem[ResourceIndex];
+ break;
- case EfiIsaAcpiResourceMemory:
- break;
+ case EfiIsaAcpiResourceMemory:
+ break;
- case EfiIsaAcpiResourceDma:
- DmaResource = &ResourceList->ResourceItem[ResourceIndex];
- break;
+ case EfiIsaAcpiResourceDma:
+ DmaResource = &ResourceList->ResourceItem[ResourceIndex];
+ break;
- case EfiIsaAcpiResourceInterrupt:
- InterruptResource = &ResourceList->ResourceItem[ResourceIndex];
- break;
+ case EfiIsaAcpiResourceInterrupt:
+ InterruptResource = &ResourceList->ResourceItem[ResourceIndex];
+ break;
- default:
- break;
+ default:
+ break;
}
}
+
//
// See if this is an ISA serial port
//
// Ignore DMA resource since it is always returned NULL
//
- if (ResourceList->Device.HID == EISA_PNP_ID (0x500) || ResourceList->Device.HID == EISA_PNP_ID (0x501)) {
-
- if (ResourceList->Device.UID <= 3 &&
- IoResource != NULL &&
- InterruptResource != NULL
- ) {
+ if ((ResourceList->Device.HID == EISA_PNP_ID (0x500)) || (ResourceList->Device.HID == EISA_PNP_ID (0x501))) {
+ if ((ResourceList->Device.UID <= 3) &&
+ (IoResource != NULL) &&
+ (InterruptResource != NULL)
+ )
+ {
//
// Get the handle of the child device that has opened the ISA I/O Protocol
//
@@ -342,17 +349,18 @@ LegacyBiosBuildSioDataFromIsaIo (
if (EFI_ERROR (Status)) {
continue;
}
+
//
// We want resource for legacy even if no 32-bit driver installed
//
for (ChildIndex = 0; ChildIndex < EntryCount; ChildIndex++) {
if ((OpenInfoBuffer[ChildIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
- Status = gBS->HandleProtocol (OpenInfoBuffer[ChildIndex].ControllerHandle, &gEfiSerialIoProtocolGuid, (VOID **) &SerialIo);
+ Status = gBS->HandleProtocol (OpenInfoBuffer[ChildIndex].ControllerHandle, &gEfiSerialIoProtocolGuid, (VOID **)&SerialIo);
if (!EFI_ERROR (Status)) {
- SioSerial = &SioPtr->Serial[ResourceList->Device.UID];
- SioSerial->Address = (UINT16) IoResource->StartRange;
- SioSerial->Irq = (UINT8) InterruptResource->StartRange;
- SioSerial->Mode = DEVICE_SERIAL_MODE_NORMAL | DEVICE_SERIAL_MODE_DUPLEX_HALF;
+ SioSerial = &SioPtr->Serial[ResourceList->Device.UID];
+ SioSerial->Address = (UINT16)IoResource->StartRange;
+ SioSerial->Irq = (UINT8)InterruptResource->StartRange;
+ SioSerial->Mode = DEVICE_SERIAL_MODE_NORMAL | DEVICE_SERIAL_MODE_DUPLEX_HALF;
break;
}
}
@@ -361,40 +369,44 @@ LegacyBiosBuildSioDataFromIsaIo (
FreePool (OpenInfoBuffer);
}
}
+
//
// See if this is an ISA parallel port
//
// Ignore DMA resource since it is always returned NULL, port
// only used in output mode.
//
- if (ResourceList->Device.HID == EISA_PNP_ID (0x400) || ResourceList->Device.HID == EISA_PNP_ID (0x401)) {
- if (ResourceList->Device.UID <= 2 &&
- IoResource != NULL &&
- InterruptResource != NULL &&
- DmaResource != NULL
- ) {
- SioParallel = &SioPtr->Parallel[ResourceList->Device.UID];
- SioParallel->Address = (UINT16) IoResource->StartRange;
- SioParallel->Irq = (UINT8) InterruptResource->StartRange;
- SioParallel->Dma = (UINT8) DmaResource->StartRange;
- SioParallel->Mode = DEVICE_PARALLEL_MODE_MODE_OUTPUT_ONLY;
+ if ((ResourceList->Device.HID == EISA_PNP_ID (0x400)) || (ResourceList->Device.HID == EISA_PNP_ID (0x401))) {
+ if ((ResourceList->Device.UID <= 2) &&
+ (IoResource != NULL) &&
+ (InterruptResource != NULL) &&
+ (DmaResource != NULL)
+ )
+ {
+ SioParallel = &SioPtr->Parallel[ResourceList->Device.UID];
+ SioParallel->Address = (UINT16)IoResource->StartRange;
+ SioParallel->Irq = (UINT8)InterruptResource->StartRange;
+ SioParallel->Dma = (UINT8)DmaResource->StartRange;
+ SioParallel->Mode = DEVICE_PARALLEL_MODE_MODE_OUTPUT_ONLY;
}
}
+
//
// See if this is an ISA floppy controller
//
if (ResourceList->Device.HID == EISA_PNP_ID (0x604)) {
- if (IoResource != NULL && InterruptResource != NULL && DmaResource != NULL) {
- Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiBlockIoProtocolGuid, (VOID **) &BlockIo);
+ if ((IoResource != NULL) && (InterruptResource != NULL) && (DmaResource != NULL)) {
+ Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiBlockIoProtocolGuid, (VOID **)&BlockIo);
if (!EFI_ERROR (Status)) {
- SioFloppy = &SioPtr->Floppy;
- SioFloppy->Address = (UINT16) IoResource->StartRange;
- SioFloppy->Irq = (UINT8) InterruptResource->StartRange;
- SioFloppy->Dma = (UINT8) DmaResource->StartRange;
+ SioFloppy = &SioPtr->Floppy;
+ SioFloppy->Address = (UINT16)IoResource->StartRange;
+ SioFloppy->Irq = (UINT8)InterruptResource->StartRange;
+ SioFloppy->Dma = (UINT8)DmaResource->StartRange;
SioFloppy->NumberOfFloppy++;
}
}
}
+
//
// See if this is a mouse
// Always set mouse found so USB hot plug will work
@@ -430,14 +442,14 @@ LegacyBiosBuildSioDataFromIsaIo (
**/
EFI_STATUS
LegacyBiosBuildSioData (
- IN LEGACY_BIOS_INSTANCE *Private
+ IN LEGACY_BIOS_INSTANCE *Private
)
{
- EFI_STATUS Status;
- DEVICE_PRODUCER_DATA_HEADER *SioPtr;
- EFI_HANDLE IsaBusController;
- UINTN HandleCount;
- EFI_HANDLE *HandleBuffer;
+ EFI_STATUS Status;
+ DEVICE_PRODUCER_DATA_HEADER *SioPtr;
+ EFI_HANDLE IsaBusController;
+ UINTN HandleCount;
+ EFI_HANDLE *HandleBuffer;
//
// Get the pointer to the SIO data structure
diff --git a/OvmfPkg/Csm/LegacyBiosDxe/Thunk.c b/OvmfPkg/Csm/LegacyBiosDxe/Thunk.c
index dd706fbd6e..62f19b6519 100644
--- a/OvmfPkg/Csm/LegacyBiosDxe/Thunk.c
+++ b/OvmfPkg/Csm/LegacyBiosDxe/Thunk.c
@@ -9,7 +9,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "LegacyBiosInterface.h"
-THUNK_CONTEXT mThunkContext;
+THUNK_CONTEXT mThunkContext;
/**
Sets the counter value for Timer #0 in a legacy 8254 timer.
@@ -23,8 +23,8 @@ SetPitCount (
)
{
IoWrite8 (TIMER_CONTROL_PORT, TIMER0_CONTROL_WORD);
- IoWrite8 (TIMER0_COUNT_PORT, (UINT8) (Count & 0xFF));
- IoWrite8 (TIMER0_COUNT_PORT, (UINT8) ((Count>>8) & 0xFF));
+ IoWrite8 (TIMER0_COUNT_PORT, (UINT8)(Count & 0xFF));
+ IoWrite8 (TIMER0_COUNT_PORT, (UINT8)((Count>>8) & 0xFF));
}
/**
@@ -45,13 +45,13 @@ SetPitCount (
BOOLEAN
EFIAPI
LegacyBiosInt86 (
- IN EFI_LEGACY_BIOS_PROTOCOL *This,
- IN UINT8 BiosInt,
- IN EFI_IA32_REGISTER_SET *Regs
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,
+ IN UINT8 BiosInt,
+ IN EFI_IA32_REGISTER_SET *Regs
)
{
- UINT16 Segment;
- UINT16 Offset;
+ UINT16 Segment;
+ UINT16 Offset;
Regs->X.Flags.Reserved1 = 1;
Regs->X.Flags.Reserved2 = 0;
@@ -67,9 +67,9 @@ LegacyBiosInt86 (
// We use this base address to get the legacy interrupt handler.
//
ACCESS_PAGE0_CODE (
- Segment = (UINT16)(((UINT32 *)0)[BiosInt] >> 16);
- Offset = (UINT16)((UINT32 *)0)[BiosInt];
- );
+ Segment = (UINT16)(((UINT32 *)0)[BiosInt] >> 16);
+ Offset = (UINT16)((UINT32 *)0)[BiosInt];
+ );
return InternalLegacyBiosFarCall (
This,
@@ -102,12 +102,12 @@ LegacyBiosInt86 (
BOOLEAN
EFIAPI
LegacyBiosFarCall86 (
- IN EFI_LEGACY_BIOS_PROTOCOL *This,
- IN UINT16 Segment,
- IN UINT16 Offset,
- IN EFI_IA32_REGISTER_SET *Regs,
- IN VOID *Stack,
- IN UINTN StackSize
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,
+ IN UINT16 Segment,
+ IN UINT16 Offset,
+ IN EFI_IA32_REGISTER_SET *Regs,
+ IN VOID *Stack,
+ IN UINTN StackSize
)
{
Regs->X.Flags.Reserved1 = 1;
@@ -134,8 +134,8 @@ LegacyBiosFarCall86 (
VOID
EFIAPI
LegacyBiosNullInterruptHandler (
- IN EFI_EXCEPTION_TYPE InterruptType,
- IN EFI_SYSTEM_CONTEXT SystemContext
+ IN EFI_EXCEPTION_TYPE InterruptType,
+ IN EFI_SYSTEM_CONTEXT SystemContext
)
{
}
@@ -161,12 +161,12 @@ LegacyBiosNullInterruptHandler (
BOOLEAN
EFIAPI
InternalLegacyBiosFarCall (
- IN EFI_LEGACY_BIOS_PROTOCOL *This,
- IN UINT16 Segment,
- IN UINT16 Offset,
- IN EFI_IA32_REGISTER_SET *Regs,
- IN VOID *Stack,
- IN UINTN StackSize
+ IN EFI_LEGACY_BIOS_PROTOCOL *This,
+ IN UINT16 Segment,
+ IN UINT16 Offset,
+ IN EFI_IA32_REGISTER_SET *Regs,
+ IN VOID *Stack,
+ IN UINTN StackSize
)
{
UINTN Status;
@@ -180,19 +180,19 @@ InternalLegacyBiosFarCall (
Private = LEGACY_BIOS_INSTANCE_FROM_THIS (This);
ZeroMem (&ThunkRegSet, sizeof (ThunkRegSet));
- ThunkRegSet.X.DI = Regs->X.DI;
- ThunkRegSet.X.SI = Regs->X.SI;
- ThunkRegSet.X.BP = Regs->X.BP;
- ThunkRegSet.X.BX = Regs->X.BX;
- ThunkRegSet.X.DX = Regs->X.DX;
+ ThunkRegSet.X.DI = Regs->X.DI;
+ ThunkRegSet.X.SI = Regs->X.SI;
+ ThunkRegSet.X.BP = Regs->X.BP;
+ ThunkRegSet.X.BX = Regs->X.BX;
+ ThunkRegSet.X.DX = Regs->X.DX;
//
// Sometimes, ECX is used to pass in 32 bit data. For example, INT 1Ah, AX = B10Dh is
// "PCI BIOS v2.0c + Write Configuration DWORD" and ECX has the dword to write.
//
- ThunkRegSet.E.ECX = Regs->E.ECX;
- ThunkRegSet.X.AX = Regs->X.AX;
- ThunkRegSet.E.DS = Regs->X.DS;
- ThunkRegSet.E.ES = Regs->X.ES;
+ ThunkRegSet.E.ECX = Regs->E.ECX;
+ ThunkRegSet.X.AX = Regs->X.AX;
+ ThunkRegSet.E.DS = Regs->X.DS;
+ ThunkRegSet.E.ES = Regs->X.ES;
CopyMem (&(ThunkRegSet.E.EFLAGS.UintN), &(Regs->X.Flags), sizeof (Regs->X.Flags));
@@ -200,7 +200,7 @@ InternalLegacyBiosFarCall (
// Clear the error flag; thunk code may set it. Stack16 should be the high address
// Make Statk16 address the low 16 bit must be not zero.
//
- Stack16 = (UINT16 *)((UINT8 *) mThunkContext.RealModeBuffer + mThunkContext.RealModeBufferSize - sizeof (UINT16));
+ Stack16 = (UINT16 *)((UINT8 *)mThunkContext.RealModeBuffer + mThunkContext.RealModeBufferSize - sizeof (UINT16));
//
// Save current rate of DXE Timer
@@ -229,22 +229,25 @@ InternalLegacyBiosFarCall (
// handled properly from real mode.
//
DEBUG_CODE_BEGIN ();
- UINTN Vector;
- UINTN Count;
-
- for (Vector = 0x20, Count = 0; Vector < 0x100; Vector++) {
- Status = Private->Cpu->RegisterInterruptHandler (Private->Cpu, Vector, LegacyBiosNullInterruptHandler);
- if (Status == EFI_ALREADY_STARTED) {
- Count++;
- }
- if (Status == EFI_SUCCESS) {
- Private->Cpu->RegisterInterruptHandler (Private->Cpu, Vector, NULL);
- }
+ UINTN Vector;
+ UINTN Count;
+
+ for (Vector = 0x20, Count = 0; Vector < 0x100; Vector++) {
+ Status = Private->Cpu->RegisterInterruptHandler (Private->Cpu, Vector, LegacyBiosNullInterruptHandler);
+ if (Status == EFI_ALREADY_STARTED) {
+ Count++;
}
- if (Count >= 2) {
- DEBUG ((DEBUG_ERROR, "ERROR: More than one HW interrupt active with CSM enabled\n"));
+
+ if (Status == EFI_SUCCESS) {
+ Private->Cpu->RegisterInterruptHandler (Private->Cpu, Vector, NULL);
}
- ASSERT (Count < 2);
+ }
+
+ if (Count >= 2) {
+ DEBUG ((DEBUG_ERROR, "ERROR: More than one HW interrupt active with CSM enabled\n"));
+ }
+
+ ASSERT (Count < 2);
DEBUG_CODE_END ();
//
@@ -252,11 +255,11 @@ InternalLegacyBiosFarCall (
// period is less than the CSM required rate of 54.9254, then force the 8254
// PIT counter to 0, which is the CSM required rate of 54.9254 ms
//
- if (Private->TimerUses8254 && TimerPeriod < 549254) {
+ if (Private->TimerUses8254 && (TimerPeriod < 549254)) {
SetPitCount (0);
}
- if (Stack != NULL && StackSize != 0) {
+ if ((Stack != NULL) && (StackSize != 0)) {
//
// Copy Stack to low memory stack
//
@@ -264,12 +267,12 @@ InternalLegacyBiosFarCall (
CopyMem (Stack16, Stack, StackSize);
}
- ThunkRegSet.E.SS = (UINT16) (((UINTN) Stack16 >> 16) << 12);
- ThunkRegSet.E.ESP = (UINT16) (UINTN) Stack16;
- ThunkRegSet.E.CS = Segment;
- ThunkRegSet.E.Eip = Offset;
+ ThunkRegSet.E.SS = (UINT16)(((UINTN)Stack16 >> 16) << 12);
+ ThunkRegSet.E.ESP = (UINT16)(UINTN)Stack16;
+ ThunkRegSet.E.CS = Segment;
+ ThunkRegSet.E.Eip = Offset;
- mThunkContext.RealModeState = &ThunkRegSet;
+ mThunkContext.RealModeState = &ThunkRegSet;
//
// Set Legacy16 state. 0x08, 0x70 is legacy 8259 vector bases.
@@ -279,7 +282,7 @@ InternalLegacyBiosFarCall (
AsmThunk16 (&mThunkContext);
- if (Stack != NULL && StackSize != 0) {
+ if ((Stack != NULL) && (StackSize != 0)) {
//
// Copy low memory stack to Stack
//
@@ -311,17 +314,17 @@ InternalLegacyBiosFarCall (
// PcdEbdaReservedMemorySize should be adjusted to larger for more OPROMs.
//
DEBUG_CODE_BEGIN ();
- {
- UINTN EbdaBaseAddress;
- UINTN ReservedEbdaBaseAddress;
-
- ACCESS_PAGE0_CODE (
- EbdaBaseAddress = (*(UINT16 *) (UINTN) 0x40E) << 4;
- ReservedEbdaBaseAddress = CONVENTIONAL_MEMORY_TOP
- - PcdGet32 (PcdEbdaReservedMemorySize);
- ASSERT (ReservedEbdaBaseAddress <= EbdaBaseAddress);
+ {
+ UINTN EbdaBaseAddress;
+ UINTN ReservedEbdaBaseAddress;
+
+ ACCESS_PAGE0_CODE (
+ EbdaBaseAddress = (*(UINT16 *)(UINTN)0x40E) << 4;
+ ReservedEbdaBaseAddress = CONVENTIONAL_MEMORY_TOP
+ - PcdGet32 (PcdEbdaReservedMemorySize);
+ ASSERT (ReservedEbdaBaseAddress <= EbdaBaseAddress);
);
- }
+ }
DEBUG_CODE_END ();
//
@@ -329,21 +332,21 @@ InternalLegacyBiosFarCall (
//
SaveAndSetDebugTimerInterrupt (InterruptState);
- Regs->E.EDI = ThunkRegSet.E.EDI;
- Regs->E.ESI = ThunkRegSet.E.ESI;
- Regs->E.EBP = ThunkRegSet.E.EBP;
- Regs->E.EBX = ThunkRegSet.E.EBX;
- Regs->E.EDX = ThunkRegSet.E.EDX;
- Regs->E.ECX = ThunkRegSet.E.ECX;
- Regs->E.EAX = ThunkRegSet.E.EAX;
- Regs->X.SS = ThunkRegSet.E.SS;
- Regs->X.CS = ThunkRegSet.E.CS;
- Regs->X.DS = ThunkRegSet.E.DS;
- Regs->X.ES = ThunkRegSet.E.ES;
+ Regs->E.EDI = ThunkRegSet.E.EDI;
+ Regs->E.ESI = ThunkRegSet.E.ESI;
+ Regs->E.EBP = ThunkRegSet.E.EBP;
+ Regs->E.EBX = ThunkRegSet.E.EBX;
+ Regs->E.EDX = ThunkRegSet.E.EDX;
+ Regs->E.ECX = ThunkRegSet.E.ECX;
+ Regs->E.EAX = ThunkRegSet.E.EAX;
+ Regs->X.SS = ThunkRegSet.E.SS;
+ Regs->X.CS = ThunkRegSet.E.CS;
+ Regs->X.DS = ThunkRegSet.E.DS;
+ Regs->X.ES = ThunkRegSet.E.ES;
CopyMem (&(Regs->X.Flags), &(ThunkRegSet.E.EFLAGS.UintN), sizeof (Regs->X.Flags));
- return (BOOLEAN) (Regs->X.Flags.CF == 1);
+ return (BOOLEAN)(Regs->X.Flags.CF == 1);
}
/**
@@ -357,16 +360,16 @@ InternalLegacyBiosFarCall (
**/
EFI_STATUS
LegacyBiosInitializeThunk (
- IN LEGACY_BIOS_INSTANCE *Private
+ IN LEGACY_BIOS_INSTANCE *Private
)
{
- EFI_STATUS Status;
- EFI_PHYSICAL_ADDRESS MemoryAddress;
- UINT8 TimerVector;
+ EFI_STATUS Status;
+ EFI_PHYSICAL_ADDRESS MemoryAddress;
+ UINT8 TimerVector;
- MemoryAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) Private->IntThunk;
+ MemoryAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Private->IntThunk;
- mThunkContext.RealModeBuffer = (VOID *) (UINTN) (MemoryAddress + ((sizeof (LOW_MEMORY_THUNK) / EFI_PAGE_SIZE) + 1) * EFI_PAGE_SIZE);
+ mThunkContext.RealModeBuffer = (VOID *)(UINTN)(MemoryAddress + ((sizeof (LOW_MEMORY_THUNK) / EFI_PAGE_SIZE) + 1) * EFI_PAGE_SIZE);
mThunkContext.RealModeBufferSize = EFI_PAGE_SIZE;
mThunkContext.ThunkAttributes = THUNK_ATTRIBUTE_BIG_REAL_MODE | THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15;
@@ -376,7 +379,7 @@ LegacyBiosInitializeThunk (
// Get the interrupt vector number corresponding to IRQ0 from the 8259 driver
//
TimerVector = 0;
- Status = Private->Legacy8259->GetVector (Private->Legacy8259, Efi8259Irq0, &TimerVector);
+ Status = Private->Legacy8259->GetVector (Private->Legacy8259, Efi8259Irq0, &TimerVector);
ASSERT_EFI_ERROR (Status);
//